@ttt-productions/upload-ui 0.7.9 → 0.7.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,8 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic mutation hook to clear a terminal pendingMedia item from the tray.
|
|
3
|
+
*
|
|
4
|
+
* Pure adapter: the consumer supplies `clearFn` (typically a wrapped Firebase
|
|
5
|
+
* callable in the consuming app, or a fetch call elsewhere). The package owns the
|
|
6
|
+
* useMutation wiring and the optional `onError` toast hook; the consumer owns
|
|
7
|
+
* the network call.
|
|
8
|
+
*
|
|
9
|
+
* The provider's Firestore listener observes the `uploadTrayClearedAt` write
|
|
10
|
+
* and removes the item from the tray selector automatically — no optimistic
|
|
11
|
+
* update is needed in this hook.
|
|
12
|
+
*
|
|
13
|
+
* The returned object is the standard `useMutation` result (`mutate`,
|
|
14
|
+
* `mutateAsync`, `isPending`, …). Pass `mutationKey` to register the clear in
|
|
15
|
+
* React Query's shared `MutationCache` under a stable key, so a consumer can
|
|
16
|
+
* read per-item pending with `useMutationState` (the pendingMediaId is the
|
|
17
|
+
* mutation variables) — pending that survives the clearing row unmounting.
|
|
18
|
+
*/
|
|
19
|
+
import { type MutationKey } from '@tanstack/react-query';
|
|
1
20
|
export interface ClearUploadActivityOptions {
|
|
2
21
|
/** Network call performing the clear. Receives the pendingMediaId. */
|
|
3
22
|
clearFn: (pendingMediaId: string) => Promise<void>;
|
|
4
23
|
/** Optional error callback. Receives the error and the pendingMediaId that failed. */
|
|
5
24
|
onError?: (error: Error, pendingMediaId: string) => void;
|
|
25
|
+
/**
|
|
26
|
+
* Optional stable key for the underlying mutation, registering it in the
|
|
27
|
+
* shared `MutationCache` so pending can be read with `useMutationState`.
|
|
28
|
+
* Omitted ⇒ an unkeyed mutation (the prior behavior).
|
|
29
|
+
*/
|
|
30
|
+
mutationKey?: MutationKey;
|
|
6
31
|
}
|
|
7
32
|
export declare function useClearUploadActivity(options: ClearUploadActivityOptions): import("@tanstack/react-query").UseMutationResult<void, Error, string, unknown>;
|
|
8
33
|
//# sourceMappingURL=use-clear-upload-activity.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-clear-upload-activity.d.ts","sourceRoot":"","sources":["../../src/react/use-clear-upload-activity.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-clear-upload-activity.d.ts","sourceRoot":"","sources":["../../src/react/use-clear-upload-activity.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEtE,MAAM,WAAW,0BAA0B;IACzC,sEAAsE;IACtE,OAAO,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACnD,sFAAsF;IACtF,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,IAAI,CAAC;IACzD;;;;OAIG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,0BAA0B,mFASzE"}
|
|
@@ -10,11 +10,18 @@
|
|
|
10
10
|
* The provider's Firestore listener observes the `uploadTrayClearedAt` write
|
|
11
11
|
* and removes the item from the tray selector automatically — no optimistic
|
|
12
12
|
* update is needed in this hook.
|
|
13
|
+
*
|
|
14
|
+
* The returned object is the standard `useMutation` result (`mutate`,
|
|
15
|
+
* `mutateAsync`, `isPending`, …). Pass `mutationKey` to register the clear in
|
|
16
|
+
* React Query's shared `MutationCache` under a stable key, so a consumer can
|
|
17
|
+
* read per-item pending with `useMutationState` (the pendingMediaId is the
|
|
18
|
+
* mutation variables) — pending that survives the clearing row unmounting.
|
|
13
19
|
*/
|
|
14
20
|
import { useMutation } from '@tanstack/react-query';
|
|
15
21
|
export function useClearUploadActivity(options) {
|
|
16
|
-
const { clearFn, onError } = options;
|
|
22
|
+
const { clearFn, onError, mutationKey } = options;
|
|
17
23
|
return useMutation({
|
|
24
|
+
mutationKey,
|
|
18
25
|
mutationFn: clearFn,
|
|
19
26
|
onError: (error, pendingMediaId) => {
|
|
20
27
|
onError?.(error, pendingMediaId);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-clear-upload-activity.js","sourceRoot":"","sources":["../../src/react/use-clear-upload-activity.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb
|
|
1
|
+
{"version":3,"file":"use-clear-upload-activity.js","sourceRoot":"","sources":["../../src/react/use-clear-upload-activity.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,WAAW,EAAoB,MAAM,uBAAuB,CAAC;AAetE,MAAM,UAAU,sBAAsB,CAAC,OAAmC;IACxE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAClD,OAAO,WAAW,CAAsB;QACtC,WAAW;QACX,UAAU,EAAE,OAAO;QACnB,OAAO,EAAE,CAAC,KAAK,EAAE,cAAc,EAAE,EAAE;YACjC,OAAO,EAAE,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;QACnC,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["'use client';\n\n/**\n * Generic mutation hook to clear a terminal pendingMedia item from the tray.\n *\n * Pure adapter: the consumer supplies `clearFn` (typically a wrapped Firebase\n * callable in the consuming app, or a fetch call elsewhere). The package owns the\n * useMutation wiring and the optional `onError` toast hook; the consumer owns\n * the network call.\n *\n * The provider's Firestore listener observes the `uploadTrayClearedAt` write\n * and removes the item from the tray selector automatically — no optimistic\n * update is needed in this hook.\n *\n * The returned object is the standard `useMutation` result (`mutate`,\n * `mutateAsync`, `isPending`, …). Pass `mutationKey` to register the clear in\n * React Query's shared `MutationCache` under a stable key, so a consumer can\n * read per-item pending with `useMutationState` (the pendingMediaId is the\n * mutation variables) — pending that survives the clearing row unmounting.\n */\n\nimport { useMutation, type MutationKey } from '@tanstack/react-query';\n\nexport interface ClearUploadActivityOptions {\n /** Network call performing the clear. Receives the pendingMediaId. */\n clearFn: (pendingMediaId: string) => Promise<void>;\n /** Optional error callback. Receives the error and the pendingMediaId that failed. */\n onError?: (error: Error, pendingMediaId: string) => void;\n /**\n * Optional stable key for the underlying mutation, registering it in the\n * shared `MutationCache` so pending can be read with `useMutationState`.\n * Omitted ⇒ an unkeyed mutation (the prior behavior).\n */\n mutationKey?: MutationKey;\n}\n\nexport function useClearUploadActivity(options: ClearUploadActivityOptions) {\n const { clearFn, onError, mutationKey } = options;\n return useMutation<void, Error, string>({\n mutationKey,\n mutationFn: clearFn,\n onError: (error, pendingMediaId) => {\n onError?.(error, pendingMediaId);\n },\n });\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttt-productions/upload-ui",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.10",
|
|
4
4
|
"description": "Upload UI primitives: local upload guard provider, useGuardedUpload helper, DeferredUploadFormShell for forms that defer Firebase Storage upload until form submit.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|