@dimah-s3/ui 1.7.1 → 2.0.0-beta.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.
Files changed (133) hide show
  1. package/README.md +73 -16
  2. package/css/shadcn.css +57 -23
  3. package/dist/components/dimah-s3/attachment/circle-progress.d.ts +14 -5
  4. package/dist/components/dimah-s3/attachment/circle-progress.d.ts.map +1 -1
  5. package/dist/components/dimah-s3/attachment/dismiss-attachment-action.d.ts +6 -2
  6. package/dist/components/dimah-s3/attachment/dismiss-attachment-action.d.ts.map +1 -1
  7. package/dist/components/dimah-s3/attachment/file-attachment.d.ts +33 -18
  8. package/dist/components/dimah-s3/attachment/file-attachment.d.ts.map +1 -1
  9. package/dist/components/dimah-s3/attachment/file-name.d.ts +18 -0
  10. package/dist/components/dimah-s3/attachment/file-name.d.ts.map +1 -0
  11. package/dist/{lib/file-type-icon.d.ts → components/dimah-s3/attachment/file-type-glyph.d.ts} +5 -11
  12. package/dist/components/dimah-s3/attachment/file-type-glyph.d.ts.map +1 -0
  13. package/dist/components/dimah-s3/attachment/folder-glyph.d.ts +9 -0
  14. package/dist/components/dimah-s3/attachment/folder-glyph.d.ts.map +1 -0
  15. package/dist/components/dimah-s3/attachment/status-attachment.d.ts +9 -11
  16. package/dist/components/dimah-s3/attachment/status-attachment.d.ts.map +1 -1
  17. package/dist/components/dimah-s3/delete/delete-confirm-dialog.d.ts +20 -0
  18. package/dist/components/dimah-s3/delete/delete-confirm-dialog.d.ts.map +1 -0
  19. package/dist/components/dimah-s3/delete/delete-toasts.d.ts +34 -0
  20. package/dist/components/dimah-s3/delete/delete-toasts.d.ts.map +1 -0
  21. package/dist/components/dimah-s3/delete/delete-trigger.d.ts +18 -0
  22. package/dist/components/dimah-s3/delete/delete-trigger.d.ts.map +1 -0
  23. package/dist/components/dimah-s3/delete/delete.d.ts +83 -0
  24. package/dist/components/dimah-s3/delete/delete.d.ts.map +1 -0
  25. package/dist/components/dimah-s3/download/download-progress.d.ts +16 -0
  26. package/dist/components/dimah-s3/download/download-progress.d.ts.map +1 -0
  27. package/dist/components/dimah-s3/download/download-toasts.d.ts +25 -0
  28. package/dist/components/dimah-s3/download/download-toasts.d.ts.map +1 -0
  29. package/dist/components/dimah-s3/download/download-trigger.d.ts +32 -0
  30. package/dist/components/dimah-s3/download/download-trigger.d.ts.map +1 -0
  31. package/dist/components/dimah-s3/download/download.d.ts +30 -0
  32. package/dist/components/dimah-s3/download/download.d.ts.map +1 -0
  33. package/dist/components/dimah-s3/list/object-list-breadcrumb.d.ts +6 -5
  34. package/dist/components/dimah-s3/list/object-list-breadcrumb.d.ts.map +1 -1
  35. package/dist/components/dimah-s3/list/object-list-content.d.ts +8 -0
  36. package/dist/components/dimah-s3/list/object-list-content.d.ts.map +1 -0
  37. package/dist/components/dimah-s3/list/object-list-context.d.ts +76 -0
  38. package/dist/components/dimah-s3/list/object-list-context.d.ts.map +1 -0
  39. package/dist/components/dimah-s3/list/object-list-controls.d.ts +46 -0
  40. package/dist/components/dimah-s3/list/object-list-controls.d.ts.map +1 -0
  41. package/dist/components/dimah-s3/list/object-list-entry.d.ts +28 -0
  42. package/dist/components/dimah-s3/list/object-list-entry.d.ts.map +1 -0
  43. package/dist/components/dimah-s3/list/object-list-feedback.d.ts +26 -0
  44. package/dist/components/dimah-s3/list/object-list-feedback.d.ts.map +1 -0
  45. package/dist/components/dimah-s3/list/object-list-header.d.ts +81 -0
  46. package/dist/components/dimah-s3/list/object-list-header.d.ts.map +1 -0
  47. package/dist/components/dimah-s3/list/object-list-item-menu.d.ts +65 -0
  48. package/dist/components/dimah-s3/list/object-list-item-menu.d.ts.map +1 -0
  49. package/dist/components/dimah-s3/list/object-list-keyboard.d.ts +21 -0
  50. package/dist/components/dimah-s3/list/object-list-keyboard.d.ts.map +1 -0
  51. package/dist/components/dimah-s3/list/object-list-states.d.ts +25 -11
  52. package/dist/components/dimah-s3/list/object-list-states.d.ts.map +1 -1
  53. package/dist/components/dimah-s3/list/object-list-upload.d.ts +29 -6
  54. package/dist/components/dimah-s3/list/object-list-upload.d.ts.map +1 -1
  55. package/dist/components/dimah-s3/list/object-list-usage.d.ts +8 -6
  56. package/dist/components/dimah-s3/list/object-list-usage.d.ts.map +1 -1
  57. package/dist/components/dimah-s3/list/object-list.d.ts +78 -137
  58. package/dist/components/dimah-s3/list/object-list.d.ts.map +1 -1
  59. package/dist/components/dimah-s3/preview/object-card.d.ts +38 -0
  60. package/dist/components/dimah-s3/preview/object-card.d.ts.map +1 -0
  61. package/dist/components/dimah-s3/preview/object-image.d.ts +30 -0
  62. package/dist/components/dimah-s3/preview/object-image.d.ts.map +1 -0
  63. package/dist/components/dimah-s3/upload/avatar-upload.d.ts +47 -0
  64. package/dist/components/dimah-s3/upload/avatar-upload.d.ts.map +1 -0
  65. package/dist/components/dimah-s3/upload/upload-dropzone.d.ts +48 -25
  66. package/dist/components/dimah-s3/upload/upload-dropzone.d.ts.map +1 -1
  67. package/dist/components/dimah-s3/upload/upload-field.d.ts +96 -0
  68. package/dist/components/dimah-s3/upload/upload-field.d.ts.map +1 -0
  69. package/dist/components/dimah-s3/upload/upload-file-list.d.ts +34 -0
  70. package/dist/components/dimah-s3/upload/upload-file-list.d.ts.map +1 -0
  71. package/dist/components/dimah-s3/upload/upload-status.d.ts +25 -20
  72. package/dist/components/dimah-s3/upload/upload-status.d.ts.map +1 -1
  73. package/dist/components/dimah-s3/upload/upload-toasts.d.ts +23 -0
  74. package/dist/components/dimah-s3/upload/upload-toasts.d.ts.map +1 -0
  75. package/dist/components/dimah-s3/upload/upload-trigger.d.ts +23 -0
  76. package/dist/components/dimah-s3/upload/upload-trigger.d.ts.map +1 -0
  77. package/dist/components/dimah-s3/upload/upload.d.ts +79 -0
  78. package/dist/components/dimah-s3/upload/upload.d.ts.map +1 -0
  79. package/dist/hooks/use-file-preview.d.ts +7 -0
  80. package/dist/hooks/use-file-preview.d.ts.map +1 -0
  81. package/dist/hooks/use-own-drag.d.ts +17 -0
  82. package/dist/hooks/use-own-drag.d.ts.map +1 -0
  83. package/dist/hooks/use-paste-files.d.ts +18 -0
  84. package/dist/hooks/use-paste-files.d.ts.map +1 -0
  85. package/dist/hooks/use-toast-owner.d.ts +16 -0
  86. package/dist/hooks/use-toast-owner.d.ts.map +1 -0
  87. package/dist/index.d.ts +39 -18
  88. package/dist/index.d.ts.map +1 -1
  89. package/dist/index.js +4226 -2676
  90. package/dist/index.js.map +1 -1
  91. package/dist/lib/attachment-layout.d.ts +3 -33
  92. package/dist/lib/attachment-layout.d.ts.map +1 -1
  93. package/dist/lib/format-expires-in.d.ts +2 -2
  94. package/dist/lib/format-expires-in.d.ts.map +1 -1
  95. package/dist/lib/is-field-target.d.ts +6 -0
  96. package/dist/lib/is-field-target.d.ts.map +1 -0
  97. package/dist/lib/upload-hints.d.ts +16 -0
  98. package/dist/lib/upload-hints.d.ts.map +1 -0
  99. package/package.json +24 -13
  100. package/styles.css +4 -3
  101. package/dist/components/dimah-s3/delete/delete-button.d.ts +0 -43
  102. package/dist/components/dimah-s3/delete/delete-button.d.ts.map +0 -1
  103. package/dist/components/dimah-s3/download/download-button.d.ts +0 -39
  104. package/dist/components/dimah-s3/download/download-button.d.ts.map +0 -1
  105. package/dist/components/dimah-s3/download/progress-download-button.d.ts +0 -44
  106. package/dist/components/dimah-s3/download/progress-download-button.d.ts.map +0 -1
  107. package/dist/components/dimah-s3/list/object-list-menu.d.ts +0 -65
  108. package/dist/components/dimah-s3/list/object-list-menu.d.ts.map +0 -1
  109. package/dist/components/dimah-s3/list/object-list-rows.d.ts +0 -32
  110. package/dist/components/dimah-s3/list/object-list-rows.d.ts.map +0 -1
  111. package/dist/components/dimah-s3/list/object-list-selection-state.d.ts +0 -38
  112. package/dist/components/dimah-s3/list/object-list-selection-state.d.ts.map +0 -1
  113. package/dist/components/dimah-s3/list/object-list-selection.d.ts +0 -36
  114. package/dist/components/dimah-s3/list/object-list-selection.d.ts.map +0 -1
  115. package/dist/components/dimah-s3/upload/multi-upload-status.d.ts +0 -8
  116. package/dist/components/dimah-s3/upload/multi-upload-status.d.ts.map +0 -1
  117. package/dist/components/dimah-s3/upload/upload-button.d.ts +0 -32
  118. package/dist/components/dimah-s3/upload/upload-button.d.ts.map +0 -1
  119. package/dist/hooks/use-delete-toast.d.ts +0 -12
  120. package/dist/hooks/use-delete-toast.d.ts.map +0 -1
  121. package/dist/hooks/use-delete-ui.d.ts +0 -16
  122. package/dist/hooks/use-delete-ui.d.ts.map +0 -1
  123. package/dist/hooks/use-download-toast.d.ts +0 -17
  124. package/dist/hooks/use-download-toast.d.ts.map +0 -1
  125. package/dist/hooks/use-download-ui.d.ts +0 -19
  126. package/dist/hooks/use-download-ui.d.ts.map +0 -1
  127. package/dist/hooks/use-file-reject-toast.d.ts +0 -7
  128. package/dist/hooks/use-file-reject-toast.d.ts.map +0 -1
  129. package/dist/hooks/use-upload-toast.d.ts +0 -7
  130. package/dist/hooks/use-upload-toast.d.ts.map +0 -1
  131. package/dist/hooks/use-upload-ui.d.ts +0 -13
  132. package/dist/hooks/use-upload-ui.d.ts.map +0 -1
  133. package/dist/lib/file-type-icon.d.ts.map +0 -1
@@ -1,14 +1,37 @@
1
- import type { UseUploadReturn } from "@dimah-s3/react";
1
+ import type { UploadCallOptions, UseObjectListReturn, UseUploadReturn } from "@dimah-s3/react";
2
2
  /**
3
- * Reloads the list once when an upload batch settles with at least one success.
3
+ * Call options for files uploaded into `parent` (`null` is the root): the
4
+ * source's `uploadOptions` for that folder. `undefined` when the source has
5
+ * none, so the hook's own options apply.
6
+ */
7
+ export declare function folderUploadCall<TItem>(list: UseObjectListReturn<TItem>, parent: string | null): UploadCallOptions | undefined;
8
+ /**
9
+ * Reloads the list once each time the upload queue settles with new
10
+ * successful files. Files that succeeded before mount do not count.
4
11
  * Call it from the list root, outside the folder key, so opening another
5
12
  * folder does not reload again.
6
13
  */
7
- export declare function useRefreshListAfterUpload(upload: UseUploadReturn | undefined, refresh: (() => void | Promise<void>) | undefined): void;
8
- export declare function ObjectListUpload({ upload }: {
9
- upload: UseUploadReturn;
14
+ export declare function useRefreshListAfterUpload(upload: UseUploadReturn | undefined, refresh: () => void | Promise<void>): void;
15
+ /**
16
+ * Progress and errors for the list's `upload`, under the header.
17
+ * Hidden while idle and after a queue that fully succeeded.
18
+ */
19
+ export declare function ObjectListUploadStatus({ className }: {
20
+ className?: string;
10
21
  }): import("react").JSX.Element | null;
11
- export declare function ObjectListDropOverlay({ upload }: {
22
+ /**
23
+ * Overlay and live message while files are dragged over the list.
24
+ *
25
+ * `active` is the frame's own drag state, so a drag over another drop
26
+ * target of the same hook stays quiet. `target` is what takes the drag
27
+ * inside the frame: over a folder row the overlay steps aside and the live
28
+ * message names `folder`; over a dropzone both step aside, since the
29
+ * dropzone shows and announces its own state.
30
+ */
31
+ export declare function ObjectListDropOverlay({ upload, active, target, folder, }: {
12
32
  upload: UseUploadReturn;
33
+ active: boolean;
34
+ target?: "frame" | "folder" | "dropzone";
35
+ folder?: string | null;
13
36
  }): import("react").JSX.Element;
14
37
  //# sourceMappingURL=object-list-upload.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"object-list-upload.d.ts","sourceRoot":"","sources":["../../../../src/components/dimah-s3/list/object-list-upload.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAKvD;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,eAAe,GAAG,SAAS,EACnC,OAAO,EAAE,CAAC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS,QA0BlD;AAED,wBAAgB,gBAAgB,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,eAAe,CAAA;CAAE,sCAQvE;AAED,wBAAgB,qBAAqB,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,eAAe,CAAA;CAAE,+BA8B5E"}
1
+ {"version":3,"file":"object-list-upload.d.ts","sourceRoot":"","sources":["../../../../src/components/dimah-s3/list/object-list-upload.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EAChB,MAAM,iBAAiB,CAAC;AAMzB;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EACpC,IAAI,EAAE,mBAAmB,CAAC,KAAK,CAAC,EAChC,MAAM,EAAE,MAAM,GAAG,IAAI,GACpB,iBAAiB,GAAG,SAAS,CAI/B;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,eAAe,GAAG,SAAS,EACnC,OAAO,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,QA2BpC;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,EAAE,SAAS,EAAE,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,sCAgB3E;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,MAAM,EACN,MAAM,EACN,MAAgB,EAChB,MAAa,GACd,EAAE;IACD,MAAM,EAAE,eAAe,CAAC;IACxB,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,UAAU,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB,+BAyCA"}
@@ -1,7 +1,9 @@
1
- import { type ObjectListUsage } from "@dimah-s3/react";
2
- import type { ObjectListUsageLimits } from "./object-list.js";
3
- export declare function ObjectListUsageLine({ usage, limits, }: {
4
- usage: ObjectListUsage;
5
- limits?: ObjectListUsageLimits;
6
- }): import("react").JSX.Element;
1
+ /**
2
+ * Bytes and file count from `list.usage`, with a meter when the usage
3
+ * carries the server's `maxBytes` or `maxFiles`. Renders nothing until the
4
+ * query sends `usage`.
5
+ */
6
+ export declare function ObjectListUsage({ className }: {
7
+ className?: string;
8
+ }): import("react").JSX.Element | null;
7
9
  //# sourceMappingURL=object-list-usage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"object-list-usage.d.ts","sourceRoot":"","sources":["../../../../src/components/dimah-s3/list/object-list-usage.tsx"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAEpF,wBAAgB,mBAAmB,CAAC,EAClC,KAAK,EACL,MAAM,GACP,EAAE;IACD,KAAK,EAAE,eAAe,CAAC;IACvB,MAAM,CAAC,EAAE,qBAAqB,CAAC;CAChC,+BAkEA"}
1
+ {"version":3,"file":"object-list-usage.d.ts","sourceRoot":"","sources":["../../../../src/components/dimah-s3/list/object-list-usage.tsx"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,EAAE,SAAS,EAAE,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,sCA6EpE"}
@@ -1,169 +1,110 @@
1
1
  import { type ReactNode } from "react";
2
- import type { APIError } from "@dimah-s3/core";
3
- import type { ObjectListFolder, ObjectListUsage, UseDeleteReturn, UseUploadReturn } from "@dimah-s3/react";
4
- /**
5
- * List state. `{@link useObjectList}` returns this shape. A server render or
6
- * your own store can pass the same fields without the hook.
7
- */
8
- export type ObjectListView<TItem> = {
9
- items: readonly TItem[];
10
- folders?: readonly ObjectListFolder[];
11
- /** Path from the root, root excluded. */
12
- trail?: readonly ObjectListFolder[];
13
- error?: APIError | null;
14
- isLoading?: boolean;
15
- isLoadingMore?: boolean;
16
- isRefreshing?: boolean;
17
- hasMore?: boolean;
18
- loadMore?: () => void | Promise<void>;
19
- refresh?: () => void | Promise<void>;
20
- openFolder?: (folder: ObjectListFolder) => void;
21
- /** Pass `[]` for the root. */
22
- navigate?: (trail: readonly ObjectListFolder[]) => void;
2
+ import type { AnyDownloadReturn, DeleteResult, ObjectListFolder, UseDeleteReturn, UseDownloadReturn, UseObjectListReturn, UseObjectListSelectionReturn, UseUploadReturn } from "@dimah-s3/react";
3
+ import { type ObjectListRenderers, type ObjectListView } from "./object-list-context.js";
4
+ /** Props for {@link ObjectList}. */
5
+ export type ObjectListProps<TItem> = ObjectListRenderers<TItem> & {
6
+ /** `useObjectList` return. The component renders it and does not fetch. */
7
+ list: UseObjectListReturn<TItem>;
23
8
  /**
24
- * Current folder id. Changing it clears the checkbox selection.
25
- * `useObjectList` sets this.
9
+ * `useObjectListSelection` return. Adds checkboxes, the selection bar,
10
+ * Ctrl+A / Cmd+A, Escape, Space, and Shift ranges.
26
11
  */
27
- parent?: string | null;
12
+ selection?: UseObjectListSelectionReturn<TItem>;
28
13
  /**
29
- * Catalog totals. Omit it, or pass `null`, and the usage line stays hidden.
30
- * `useObjectList` sets this from the query.
14
+ * `useUpload`. Drop or paste files onto the list to upload them into the
15
+ * open folder. When the source has `uploadOptions`, files go where it
16
+ * says, folder rows take drops, and their menu has Upload to this folder.
17
+ * `UploadTrigger` and `UploadDropzone` inside the list use the same hook
18
+ * and folder without their own `Upload`. The list reloads once each time
19
+ * the queue settles with new uploads.
31
20
  */
32
- usage?: ObjectListUsage | null;
33
- };
34
- /** Checked rows on the loaded page. */
35
- export type ObjectListSelectionChange<TItem> = {
36
- items: readonly TItem[];
37
- folders: readonly ObjectListFolder[];
38
- };
39
- /** Caps for the usage line. The list does not read them from the server. */
40
- export type ObjectListUsageLimits = {
21
+ upload?: UseUploadReturn;
41
22
  /**
42
- * Byte cap. Pass the same number as `db({ quota: { maxBytes } })` when
43
- * that plugin is what enforces the limit.
23
+ * `useDownload` or `useFetchDownload`. Adds Download to the file menu.
24
+ * `DownloadTrigger` inside the list uses it without its own `Download`.
44
25
  */
45
- maxBytes?: number;
26
+ download?: AnyDownloadReturn;
46
27
  /**
47
- * File-count cap. Pass the same number as `db({ quota: { maxFiles } })`
48
- * when that plugin is what enforces the limit.
28
+ * Navigate-mode `useDownload` for Copy link, such as one with
29
+ * `disposition: "inline"`. Falls back to a navigate-mode `download`.
49
30
  */
50
- maxFiles?: number;
51
- };
52
- /** Props for {@link ObjectList}. Pass a list view as `list`. */
53
- export type ObjectListProps<TItem> = {
54
- list: ObjectListView<TItem>;
55
- getKey: (item: TItem) => string;
56
- getLabel: (item: TItem) => string;
57
- getDescription?: (item: TItem) => ReactNode;
58
- /** Filename used for the type glyph. Defaults to `getLabel`. */
59
- getFileName?: (item: TItem) => string;
60
- getFileType?: (item: TItem) => string | null;
61
- /** Image thumbnail. The label stays the accessible name. */
62
- getPreviewUrl?: (item: TItem) => string | null;
63
- /** Replaces the file row. */
64
- renderItem?: (item: TItem) => ReactNode;
65
- /** Replaces the folder row. */
66
- renderFolder?: (folder: ObjectListFolder) => ReactNode;
67
- /** Trailing controls for a file, such as download and delete. */
68
- renderActions?: (item: TItem) => ReactNode;
31
+ share?: UseDownloadReturn;
32
+ /**
33
+ * `useDelete`. Adds Delete to the file menu and to the selection bar,
34
+ * with one confirmation for the whole list. `DeleteTrigger` inside the
35
+ * list uses it too. Deleted files leave the rows at once; the list then
36
+ * reloads.
37
+ */
38
+ delete?: UseDeleteReturn;
69
39
  /**
70
- * Extra content beside the file name, such as a status.
71
- * Ignored when {@link ObjectListProps.renderItem} replaces the row.
40
+ * Show toasts for `upload`, `download`, and `delete`. They step aside for
41
+ * an `UploadToasts`, `DownloadToasts`, or `DeleteToasts` you mount for the
42
+ * same hook. Off, delete results and the list's own controls (Copy link,
43
+ * bulk Delete) report in a polite live region instead, unless you mount a
44
+ * `DeleteToasts` for the same hook. @default true
72
45
  */
73
- renderMeta?: (item: TItem) => ReactNode;
46
+ toasts?: boolean;
47
+ /** Controlled view. Pass it with `onViewChange`. */
48
+ view?: ObjectListView;
49
+ /** Uncontrolled starting view. @default "list" */
50
+ defaultView?: ObjectListView;
51
+ onViewChange?: (view: ObjectListView) => void;
74
52
  /**
75
- * Called when the default file row is clicked.
76
- * Ignored when {@link ObjectListProps.renderItem} replaces the row.
53
+ * Called when a file row is clicked or activated with Enter.
54
+ * Folders always open in place.
77
55
  */
78
56
  onOpenItem?: (item: TItem) => void;
79
- /** Trailing controls for a folder. Kept outside the open button. */
80
- renderFolderActions?: (folder: ObjectListFolder) => ReactNode;
81
- /** Trailing header content, such as an upload button. */
82
- header?: ReactNode;
83
- /** Root breadcrumb label. */
57
+ /**
58
+ * Object keys stored in a folder. Selected folders join a bulk delete
59
+ * only when this is set. Pair it with `isSelectable` on the selection.
60
+ */
61
+ resolveFolderKeys?: (folder: ObjectListFolder) => Promise<readonly string[]>;
62
+ /** Called after each confirmed delete in the list, with every key's outcome. */
63
+ onDeleted?: (result: DeleteResult) => void;
64
+ /** Root breadcrumb label and the list's accessible name. @default "Files" */
84
65
  rootLabel?: string;
85
- /** Show the path. @default true */
66
+ /** Show the path in the default header. @default true */
86
67
  breadcrumb?: boolean;
87
- emptyTitle?: string;
88
- emptyDescription?: string;
68
+ /** Trailing controls in the default header, such as an upload button. */
69
+ toolbar?: ReactNode;
70
+ /** Extra controls on the selection bar, beside Delete. */
71
+ selectionActions?: ReactNode;
72
+ /** Replaces the empty state. `ObjectListEmpty` takes your own text. */
73
+ empty?: ReactNode;
89
74
  /**
90
- * Replaces the empty state.
91
- * When set, `emptyTitle` and `emptyDescription` are not used.
75
+ * `auto` loads the next page as the end of the rows comes into view.
76
+ * `button` waits for Load more. @default "auto"
92
77
  */
93
- empty?: ReactNode;
94
- className?: string;
78
+ loadMore?: "auto" | "button";
95
79
  /**
96
80
  * Fixed frame height. The header stays put and the rows scroll inside.
97
- * A number is pixels. A string is a CSS length, such as `"18rem"` or `"100%"`.
81
+ * A number is pixels. A string is a CSS length, such as `"18rem"`.
98
82
  */
99
83
  height?: number | string;
100
84
  /**
101
- * Largest frame height. The list grows with its content until this cap,
85
+ * Largest frame height. The list grows with its rows until this cap,
102
86
  * then the rows scroll and the header stays put.
103
- * A number is pixels. A string is a CSS length.
104
87
  */
105
88
  maxHeight?: number | string;
89
+ className?: string;
106
90
  /**
107
- * Checkboxes for the file rows loaded so far. The selection clears when
108
- * `list.parent` changes. Rows on the next page are not selected.
109
- * When `list.hasMore` is set, the header checkbox selects this page.
110
- * A folder gets a checkbox only when {@link ObjectListProps.resolveFolderKeys}
111
- * is set. Escape clears the selection. Ctrl+A or Cmd+A, with focus inside
112
- * the list, selects the same rows as the header checkbox.
113
- */
114
- selectable?: boolean;
115
- /**
116
- * S3 object key for a file. Defaults to `getKey`.
117
- * Bulk delete uses this, not the row id.
118
- */
119
- getObjectKey?: (item: TItem) => string;
120
- /**
121
- * Object keys stored in a folder. The folder gets a checkbox only when
122
- * this is set, and bulk delete includes the keys it returns.
123
- */
124
- resolveFolderKeys?: (folder: ObjectListFolder) => Promise<readonly string[]>;
125
- /** Selection bar delete. Implies {@link ObjectListProps.selectable}. */
126
- delete?: UseDeleteReturn;
127
- /**
128
- * Called when the checked rows change, including when the folder changes
129
- * and the selection clears. `items` and `folders` are from the loaded page.
130
- */
131
- onSelectionChange?: (selection: ObjectListSelectionChange<TItem>) => void;
132
- /**
133
- * Extra controls on the selection bar, beside Delete.
134
- * Implies {@link ObjectListProps.selectable}.
135
- */
136
- selectionActions?: ReactNode;
137
- /** Called after a bulk delete, including keys that failed. */
138
- onDeleted?: (result: {
139
- deleted: string[];
140
- failed: string[];
141
- }) => void;
142
- /**
143
- * Drop and paste files onto this list. Pass `useUpload` with `noClick`
144
- * and `noKeyboard`. `getUploadOptions` chooses the folder from
145
- * `list.parent`; this component does not write metadata. Clicking the
146
- * list does not open the file picker. The list renders the hook's file
147
- * input, so `upload.open()` from any trigger, such as a menu item or an
148
- * empty-state button, opens the picker. A paste uploads while focus is
149
- * inside the list. The destination is the open folder, including when
150
- * the pointer is over a folder row. When the batch settles and at least
151
- * one file succeeded, `list.refresh` runs once. A mixed batch still
152
- * reloads. Share this hook with `UploadButton` in `header` and set that
153
- * button's `toast` and `status` to false so progress stays here.
154
- */
155
- upload?: UseUploadReturn;
156
- /**
157
- * Caps drawn next to `list.usage`. Ignored when `list.usage` is omitted.
158
- * Without this, the line shows the totals and no meter.
91
+ * Your own layout from the list parts. Omit it for the default:
92
+ * header, usage, upload status, and content.
159
93
  */
160
- usageLimits?: ObjectListUsageLimits;
94
+ children?: ReactNode;
161
95
  };
162
96
  /**
163
- * Folder catalog. Renders `list` and does not fetch.
164
- * File rows stay generic: pass accessors, or replace a row with `renderItem`.
165
- * When `list.hasMore` is set, the next page loads as the end of the rows
166
- * comes into view.
97
+ * File and folder catalog for a `useObjectList` return.
98
+ *
99
+ * Works on its own: pass `list`, then the hooks you have — `selection`,
100
+ * `upload`, `download`, `share`, `delete` — to switch features on. Use the
101
+ * `render*` props to change parts of each entry, or pass `children` to
102
+ * arrange the parts (`ObjectListHeader`, `ObjectListSearch`,
103
+ * `ObjectListContent`, …) yourself.
104
+ *
105
+ * The list is the `Upload`, `Download`, and `Delete` root for its hooks,
106
+ * so the family parts work inside it, and one delete confirmation serves
107
+ * every row and the selection bar.
167
108
  */
168
- export declare function ObjectList<TItem>(props: ObjectListProps<TItem>): import("react").JSX.Element;
109
+ export declare function ObjectList<TItem>({ list, selection, upload, download, share, delete: del, toasts, view: viewProp, defaultView, onViewChange, onOpenItem, resolveFolderKeys, onDeleted, rootLabel, breadcrumb, toolbar, selectionActions, empty, loadMore, height, maxHeight, className, children, renderEntry, renderActions, renderDescription, renderMeta, }: ObjectListProps<TItem>): import("react").JSX.Element;
169
110
  //# sourceMappingURL=object-list.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"object-list.d.ts","sourceRoot":"","sources":["../../../../src/components/dimah-s3/list/object-list.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAqB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,eAAe,EAChB,MAAM,iBAAiB,CAAC;AA0BzB;;;GAGG;AACH,MAAM,MA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C;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,MAAM,CAAC;IACvC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,OAAO,CAAC,SAAS,MAAM,EAAE,CAAC,CAAC;IAC7E,wEAAwE;IACxE,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,CAAC,SAAS,EAAE,yBAAyB,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC;IAC1E;;;OAGG;IACH,gBAAgB,CAAC,EAAE,SAAS,CAAC;IAC7B,8DAA8D;IAC9D,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,EAAE,CAAC;QAAC,MAAM,EAAE,MAAM,EAAE,CAAA;KAAE,KAAK,IAAI,CAAC;IACtE;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB;;;OAGG;IACH,WAAW,CAAC,EAAE,qBAAqB,CAAC;CACrC,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,eAAe,CAAC,KAAK,CAAC,+BAG9D"}
1
+ {"version":3,"file":"object-list.d.ts","sourceRoot":"","sources":["../../../../src/components/dimah-s3/list/object-list.tsx"],"names":[],"mappings":"AAEA,OAAO,EAOL,KAAK,SAAS,EAEf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,mBA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B,0DAA0D;IAC1D,gBAAgB,CAAC,EAAE,SAAS,CAAC;IAC7B,uEAAuE;IACvE,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC7B;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,EAChC,IAAI,EACJ,SAAS,EACT,MAAM,EACN,QAAQ,EACR,KAAK,EACL,MAAM,EAAE,GAAG,EACX,MAAa,EACb,IAAI,EAAE,QAAQ,EACd,WAAoB,EACpB,YAAY,EACZ,UAAU,EACV,iBAAiB,EACjB,SAAS,EACT,SAAS,EACT,UAAiB,EACjB,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,+BAkIxB"}
@@ -0,0 +1,38 @@
1
+ import type { AnyDownloadReturn, DeleteResult, UseDeleteReturn } from "@dimah-s3/react";
2
+ import { type FileAttachmentProps } from "../attachment/file-attachment.js";
3
+ /** Props for {@link ObjectCard}. Other props go to `FileAttachment`. */
4
+ export type ObjectCardProps = Omit<FileAttachmentProps, "state" | "fileName" | "percent" | "error" | "onCancel" | "onDismiss"> & {
5
+ /** Stored object key. Named `objectKey` because React reserves the `key` prop. */
6
+ objectKey: string;
7
+ /** Display name, and the name the browser saves. Defaults to the key's file name. */
8
+ fileName?: string;
9
+ /** A `useDownload` or `useFetchDownload` return. Adds a download action. */
10
+ download?: AnyDownloadReturn;
11
+ /** A `useDelete` return. Adds a delete action with its confirm dialog. */
12
+ delete?: UseDeleteReturn;
13
+ /** Called once a confirmed delete settles. Remove the card when it lists the key. */
14
+ onDeleted?: (result: DeleteResult) => void;
15
+ };
16
+ /**
17
+ * Card for one stored object, with download and delete actions for the
18
+ * hooks you pass. While a `useFetchDownload` call for the key runs, the
19
+ * card shows its progress ring and the bytes received; while the key is
20
+ * deleting, a spinner. `actions` go before the download and delete
21
+ * actions.
22
+ *
23
+ * Each card is its own `Download` and `Delete` root. It does not toast:
24
+ * mount `DownloadToasts` and `DeleteToasts` for the hooks.
25
+ *
26
+ * @example
27
+ * ```tsx
28
+ * <ObjectCard
29
+ * objectKey={file.key}
30
+ * fileSize={file.size}
31
+ * download={download}
32
+ * delete={remove}
33
+ * onDeleted={(result) => result.deleted.includes(file.key) && drop(file)}
34
+ * />
35
+ * ```
36
+ */
37
+ export declare function ObjectCard({ objectKey, fileName, fileSize, download, delete: del, onDeleted, description, actions, ...props }: ObjectCardProps): import("react").JSX.Element;
38
+ //# sourceMappingURL=object-card.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object-card.d.ts","sourceRoot":"","sources":["../../../../src/components/dimah-s3/preview/object-card.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EACZ,eAAe,EAChB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,kDAAkD,CAAC;AAW1D,wEAAwE;AACxE,MAAM,MAAM,eAAe,GAAG,IAAI,CAChC,mBAAmB,EACnB,OAAO,GAAG,UAAU,GAAG,SAAS,GAAG,OAAO,GAAG,UAAU,GAAG,WAAW,CACtE,GAAG;IACF,kFAAkF;IAClF,SAAS,EAAE,MAAM,CAAC;IAClB,qFAAqF;IACrF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B,0EAA0E;IAC1E,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,qFAAqF;IACrF,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;CAC5C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,UAAU,CAAC,EACzB,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,MAAM,EAAE,GAAG,EACX,SAAS,EACT,WAAW,EACX,OAAO,EACP,GAAG,KAAK,EACT,EAAE,eAAe,+BAuFjB"}
@@ -0,0 +1,30 @@
1
+ import { type ImgHTMLAttributes, type ReactNode } from "react";
2
+ import type { S3Api, S3RouteName } from "@dimah-s3/core";
3
+ /** Props for {@link ObjectImage}. Other props go to the `<img>`. */
4
+ export type ObjectImageProps = Omit<ImgHTMLAttributes<HTMLImageElement>, "src"> & {
5
+ /** Named server route that presigns the GET. */
6
+ route: S3RouteName;
7
+ /** Stored object key. `null` shows `fallback`. */
8
+ objectKey: string | null;
9
+ /** Required. Pass `""` when the image is decorative. */
10
+ alt: string;
11
+ /** Optional when an `<S3Provider>` is in the tree. */
12
+ api?: S3Api;
13
+ /** Shown while there is no key, while the URL is signed, and on errors. */
14
+ fallback?: ReactNode;
15
+ };
16
+ /**
17
+ * Image of a stored object. It presigns an inline URL with `useObjectUrl`,
18
+ * which refreshes it before it expires and shares it with other images of
19
+ * the same object.
20
+ *
21
+ * `fallback` renders instead of the image while there is no key, while the
22
+ * URL is signed, when signing fails and when the image fails to load.
23
+ *
24
+ * @example
25
+ * ```tsx
26
+ * <ObjectImage route="avatars" objectKey={user.avatarKey} alt={user.name} />
27
+ * ```
28
+ */
29
+ export declare function ObjectImage({ route, objectKey, alt, api, fallback, onError, ...props }: ObjectImageProps): string | number | bigint | boolean | import("react").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | Iterable<ReactNode> | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | import("react").ReactPortal | null | undefined> | null;
30
+ //# sourceMappingURL=object-image.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object-image.d.ts","sourceRoot":"","sources":["../../../../src/components/dimah-s3/preview/object-image.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,KAAK,iBAAiB,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACzE,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAGzD,oEAAoE;AACpE,MAAM,MAAM,gBAAgB,GAAG,IAAI,CACjC,iBAAiB,CAAC,gBAAgB,CAAC,EACnC,KAAK,CACN,GAAG;IACF,gDAAgD;IAChD,KAAK,EAAE,WAAW,CAAC;IACnB,kDAAkD;IAClD,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,wDAAwD;IACxD,GAAG,EAAE,MAAM,CAAC;IACZ,sDAAsD;IACtD,GAAG,CAAC,EAAE,KAAK,CAAC;IACZ,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,SAAS,EACT,GAAG,EACH,GAAG,EACH,QAAe,EACf,OAAO,EACP,GAAG,KAAK,EACT,EAAE,gBAAgB,mTAkBlB"}
@@ -0,0 +1,47 @@
1
+ import type { S3Api, S3RouteName } from "@dimah-s3/core";
2
+ import { type UploadResult, type UseUploadReturn } from "@dimah-s3/react";
3
+ /** Props for {@link AvatarUpload}. */
4
+ export type AvatarUploadProps = {
5
+ /** The `useUpload` return that uploads the picked image. */
6
+ upload: UseUploadReturn;
7
+ /** Named server route that presigns the GET for `objectKey`. */
8
+ route: S3RouteName;
9
+ /** Key of the current image. `null` or absent shows a placeholder. */
10
+ objectKey?: string | null;
11
+ /** Accessible name of the button, such as "Change profile photo". */
12
+ label: string;
13
+ /** Runs once per uploaded image. Store `result.key` and pass it back as `objectKey`. */
14
+ onChange?: (result: UploadResult) => void;
15
+ /** Width and height in pixels. @default 96 */
16
+ size?: number;
17
+ /** `circle` for people, `square` (rounded corners) for logos and covers. @default "circle" */
18
+ shape?: "circle" | "square";
19
+ className?: string;
20
+ /** Signs the image URL. Optional when an `<S3Provider>` is in the tree. */
21
+ api?: S3Api;
22
+ };
23
+ /**
24
+ * Image button that uploads a new picture, round by default. A click opens the file
25
+ * picker, and an image dropped on it uploads too. It is disabled while the
26
+ * hook is (`upload.disabled`).
27
+ *
28
+ * It shows the picked file's preview while it uploads and after, with a
29
+ * progress ring while it is in flight. Otherwise it shows `objectKey`, or a
30
+ * placeholder. A polite live region announces the upload phase, errors
31
+ * and rejected files.
32
+ *
33
+ * @example
34
+ * ```tsx
35
+ * const upload = useUpload({ route: "avatars", accept: ["image/*"] });
36
+ *
37
+ * <AvatarUpload
38
+ * upload={upload}
39
+ * route="avatars"
40
+ * objectKey={user.avatarKey}
41
+ * label="Change profile photo"
42
+ * onChange={(result) => saveAvatar(result.key)}
43
+ * />
44
+ * ```
45
+ */
46
+ export declare function AvatarUpload({ upload, route, objectKey, label, onChange, size, shape, api, className, }: AvatarUploadProps): import("react").JSX.Element;
47
+ //# sourceMappingURL=avatar-upload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"avatar-upload.d.ts","sourceRoot":"","sources":["../../../../src/components/dimah-s3/upload/avatar-upload.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,eAAe,EACrB,MAAM,iBAAiB,CAAC;AAMzB,sCAAsC;AACtC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,4DAA4D;IAC5D,MAAM,EAAE,eAAe,CAAC;IACxB,gEAAgE;IAChE,KAAK,EAAE,WAAW,CAAC;IACnB,sEAAsE;IACtE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,qEAAqE;IACrE,KAAK,EAAE,MAAM,CAAC;IACd,wFAAwF;IACxF,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;IAC1C,8CAA8C;IAC9C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8FAA8F;IAC9F,KAAK,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2EAA2E;IAC3E,GAAG,CAAC,EAAE,KAAK,CAAC;CACb,CAAC;AAgBF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,YAAY,CAAC,EAC3B,MAAM,EACN,KAAK,EACL,SAAgB,EAChB,KAAK,EACL,QAAQ,EACR,IAAS,EACT,KAAgB,EAChB,GAAG,EACH,SAAS,GACV,EAAE,iBAAiB,+BA4FnB"}
@@ -1,27 +1,50 @@
1
- import type { ReactNode } from "react";
2
- import { type UseUploadReturn } from "@dimah-s3/react";
3
- import { type AttachmentLayoutAliases, type StatusSlot } from "../../../lib/attachment-layout.js";
4
- /** Props for {@link UploadDropzone}. Pass a {@link UseUploadReturn} as `upload`. */
5
- export type UploadDropzoneProps = AttachmentLayoutAliases & {
6
- upload: UseUploadReturn;
7
- className?: string;
8
- /** Dropzone label. */
9
- label?: string;
10
- /**
11
- * Custom dropzone chrome (icon + hints). Replaces the built-in idle content
12
- * only — status still renders via the `status` prop.
13
- */
14
- children?: ReactNode;
15
- disabled?: boolean;
16
- /** Show toasts during upload. @default true */
17
- toast?: boolean;
18
- /**
19
- * Inline status control.
20
- * - `true` (default): render inside the dropzone
21
- * - `false`: hide status
22
- * - `(node) => ReactNode`: wrap or relocate the status node
23
- */
24
- status?: StatusSlot;
1
+ import { type HTMLAttributes } from "react";
2
+ import type { UploadCallOptions } from "@dimah-s3/react";
3
+ /** Props for {@link UploadDropzone}. Other props go to the dropzone `<div>`. */
4
+ export type UploadDropzoneProps = HTMLAttributes<HTMLDivElement> & {
5
+ /** Call options for the files dropped on it, and picked or pasted through its trigger. */
6
+ call?: UploadCallOptions;
25
7
  };
26
- export declare function UploadDropzone({ upload, className, label, children, disabled, toast: enableToast, status: statusSlot, attachmentSize, attachmentOrientation, }: UploadDropzoneProps): import("react").JSX.Element;
8
+ /**
9
+ * Drop area of the nearest `Upload`. Render it inside `<Upload>`.
10
+ *
11
+ * Files dropped anywhere on it upload, also over the status inside it. Its
12
+ * drag state follows only the files over this element, not the whole hook,
13
+ * and a polite live region announces whether they can be dropped. It stays
14
+ * usable while files upload, so new files follow the hook's `queue` option.
15
+ *
16
+ * Without `children` it renders an `UploadDropzoneTrigger` and an
17
+ * `UploadStatus`, so progress shows inside the dropzone. Pass `children`
18
+ * to arrange them yourself, or to keep the status outside it.
19
+ *
20
+ * It sets `data-drag-active` while files are over it, `data-drag-reject`
21
+ * when they cannot be dropped, and `data-disabled` while the hook is
22
+ * disabled or the root is full.
23
+ *
24
+ * @example
25
+ * ```tsx
26
+ * <Upload upload={upload}>
27
+ * <UploadDropzone />
28
+ * </Upload>
29
+ * ```
30
+ */
31
+ export declare function UploadDropzone({ call, className, children, onDragEnter, onDragLeave, onDrop, ...props }: UploadDropzoneProps): import("react").JSX.Element;
32
+ /** Props for {@link UploadDropzoneTrigger}. Other props go to the trigger `<div>`. */
33
+ export type UploadDropzoneTriggerProps = HTMLAttributes<HTMLDivElement>;
34
+ /**
35
+ * The part of an `UploadDropzone` that opens the file picker. Render it
36
+ * inside `<UploadDropzone>`.
37
+ *
38
+ * It is a button: a click, Enter or Space opens the picker, and files
39
+ * pasted while it has focus upload. The route's limits describe it. While
40
+ * the hook is disabled it is `aria-disabled` and out of the tab order;
41
+ * while the root is full, as in a full `UploadField`, it stays focusable
42
+ * but is `aria-disabled`, and "Maximum files reached." leads its
43
+ * description.
44
+ *
45
+ * The default content is an icon, a title that follows the drag, and the
46
+ * route's limits. `children` replace them; the limits stay attached as the
47
+ * description. It is a button, so do not put controls inside it.
48
+ */
49
+ export declare function UploadDropzoneTrigger({ className, children, "aria-describedby": describedBy, ...props }: UploadDropzoneTriggerProps): import("react").JSX.Element;
27
50
  //# sourceMappingURL=upload-dropzone.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"upload-dropzone.d.ts","sourceRoot":"","sources":["../../../../src/components/dimah-s3/upload/upload-dropzone.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,EAIL,KAAK,eAAe,EACrB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAEL,KAAK,uBAAuB,EAC5B,KAAK,UAAU,EAChB,MAAM,yBAAyB,CAAC;AA+CjC,oFAAoF;AACpF,MAAM,MAAM,mBAAmB,GAAG,uBAAuB,GAAG;IAC1D,MAAM,EAAE,eAAe,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sBAAsB;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB,CAAC;AAEF,wBAAgB,cAAc,CAAC,EAC7B,MAAM,EACN,SAAS,EACT,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,KAAK,EAAE,WAAkB,EACzB,MAAM,EAAE,UAAiB,EACzB,cAAc,EACd,qBAAqB,GACtB,EAAE,mBAAmB,+BAoFrB"}
1
+ {"version":3,"file":"upload-dropzone.d.ts","sourceRoot":"","sources":["../../../../src/components/dimah-s3/upload/upload-dropzone.tsx"],"names":[],"mappings":"AAEA,OAAO,EAML,KAAK,cAAc,EACpB,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EAAqB,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAuB5E,gFAAgF;AAChF,MAAM,MAAM,mBAAmB,GAAG,cAAc,CAAC,cAAc,CAAC,GAAG;IACjE,0FAA0F;IAC1F,IAAI,CAAC,EAAE,iBAAiB,CAAC;CAC1B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,cAAc,CAAC,EAC7B,IAAI,EACJ,SAAS,EACT,QAAQ,EACR,WAAW,EACX,WAAW,EACX,MAAM,EACN,GAAG,KAAK,EACT,EAAE,mBAAmB,+BAoErB;AAED,sFAAsF;AACtF,MAAM,MAAM,0BAA0B,GAAG,cAAc,CAAC,cAAc,CAAC,CAAC;AAExE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,SAAS,EACT,QAAQ,EACR,kBAAkB,EAAE,WAAW,EAC/B,GAAG,KAAK,EACT,EAAE,0BAA0B,+BA6G5B"}