authorgravatar for git@paperclover.netclover caruso <git@paperclover.net> 2026-01-29 22:37:25-08:00
committergravatar for git@paperclover.netclover caruso <git@paperclover.net> 2026-01-29 22:37:59-08:00
loge15e516edd86fdbdbe591469271dfa311cc01e23
tree538ad21267e1df1e033c89688e830432988b5933
parent1ea8a97377ab12b84a6d111aa16a911898376d94
signaturelock-open Commit is signed but in an unrecognized format.

fix: ,mybad


2 files changed, 11 insertions(+), 4 deletions(-)

jsr.json+1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1{1{
2 "name": "@clo/react-mutation",2 "name": "@clo/react-mutation",
3 "version": "1.0.0-beta.13",3 "version": "1.0.0-beta.14",
4 "exports": {4 "exports": {
5 ".": "./src/mod.ts",5 ".": "./src/mod.ts",
6 "./tanstack-query.ts": "./src/tanstack-query.ts",6 "./tanstack-query.ts": "./src/tanstack-query.ts",
src/react.ts+10-3
...@@ -1,5 +1,6 @@...@@ -1,5 +1,6 @@
1import { message as errMessage } from "@clo/lib/error.ts";1import { message as errMessage } from "@clo/lib/error.ts";
2import type { Timer } from "@clo/lib/ts.ts";2import type { Timer } from "@clo/lib/ts.ts";
3import { isDisabled } from "@testing-library/user-event/dist/cjs/utils/index.js";
3import {4import {
4 type FC,5 type FC,
5 type MouseEvent,6 type MouseEvent,
...@@ -46,9 +47,15 @@ export interface UseMutateResultBase<Args extends unknown[], Result> {...@@ -46,9 +47,15 @@ export interface UseMutateResultBase<Args extends unknown[], Result> {
46 runWithOptions: (47 runWithOptions: (
47 ..._: [...args: Args, options: RunOptions<Result>]48 ..._: [...args: Args, options: RunOptions<Result>]
48 ) => void;49 ) => void;
50
51 /** Unset error and success states */
49 clear: () => void;52 clear: () => void;
53 /** Set `error`, useful for input validators or whatever */
50 setError: (error: unknown) => void;54 setError: (error: unknown) => void;
55 /** The arguments of the latest mutation call */
51 args: Args | undefined;56 args: Args | undefined;
57 /** `true` when controls should be disabled */
58 isDisabled: boolean;
52}59}
5360
54export interface UseMutateSuccess<Result> {61export interface UseMutateSuccess<Result> {
...@@ -89,8 +96,6 @@ export interface UseMutateIdle {...@@ -89,8 +96,6 @@ export interface UseMutateIdle {
89 result: undefined;96 result: undefined;
90 error: undefined;97 error: undefined;
91 errorMessage: undefined;98 errorMessage: undefined;
92 /** `true` when controls should be disabled */
93 isDisabled: boolean;
94 /** `true` when a `mutate` function is currently running. */99 /** `true` when a `mutate` function is currently running. */
95 isMutating: boolean;100 isMutating: boolean;
96 /** `true` when a loading indicator should be shown. */101 /** `true` when a loading indicator should be shown. */
...@@ -116,6 +121,7 @@ type AnyMutationStateWithoutRun<Args extends unknown[], Result> =...@@ -116,6 +121,7 @@ type AnyMutationStateWithoutRun<Args extends unknown[], Result> =
116 isSuccess: boolean;121 isSuccess: boolean;
117 isError: boolean;122 isError: boolean;
118 args: Args | undefined;123 args: Args | undefined;
124 isDisabled: boolean;
119 };125 };
120126
121export type AnyMutationState<Args extends unknown[], Result> =127export type AnyMutationState<Args extends unknown[], Result> =
...@@ -134,6 +140,7 @@ function initialState() {...@@ -134,6 +140,7 @@ function initialState() {
134 isError: false,140 isError: false,
135 isOptimisticData: false,141 isOptimisticData: false,
136 args: undefined,142 args: undefined,
143 isDisabled: true,
137 } as const;144 } as const;
138}145}
139146
...@@ -368,7 +375,7 @@ class Observer<Args extends unknown[], Result> {...@@ -368,7 +375,7 @@ class Observer<Args extends unknown[], Result> {
368 // TODO: when auth drops this will be dependant on the auth status and isMutating375 // TODO: when auth drops this will be dependant on the auth status and isMutating
369 get isDisabled() {376 get isDisabled() {
370 self.watched.add("isMutating");377 self.watched.add("isMutating");
371 return self.state.isMutating;378 return !self.mutation || self.state.isMutating;
372 },379 },
373 get isPending() {380 get isPending() {
374 self.watched.add("isPending");381 self.watched.add("isPending");