@t8/react-pending 1.0.22 → 1.0.23
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/index.d.ts +4 -0
- package/dist/src/PendingState.d.ts +6 -0
- package/dist/src/PendingStateContext.d.ts +3 -0
- package/dist/src/PendingStateProvider.d.ts +8 -0
- package/dist/src/usePendingState.d.ts +23 -0
- package/package.json +7 -5
- package/tsconfig.build.json +4 -0
- package/tsconfig.json +2 -1
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Store } from "@t8/react-store";
|
|
2
|
+
import { type ReactNode } from "react";
|
|
3
|
+
import type { PendingState } from "./PendingState.ts";
|
|
4
|
+
export type PendingStateProviderProps = {
|
|
5
|
+
value?: Record<string, PendingState> | Map<string, Store<PendingState>> | null | undefined;
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
};
|
|
8
|
+
export declare const PendingStateProvider: ({ value, children, }: PendingStateProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type SetStoreState, Store } from "@t8/react-store";
|
|
2
|
+
import type { PendingState } from "./PendingState.ts";
|
|
3
|
+
export type WithStateOptions = {
|
|
4
|
+
silent?: boolean;
|
|
5
|
+
throws?: boolean;
|
|
6
|
+
delay?: number;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Returns an array containing `[state, withState, setState]`:
|
|
10
|
+
* - `state` reflects the state of a value passed to `withState()`;
|
|
11
|
+
* - `withState(value, [options])` enables the tracking of the state
|
|
12
|
+
* of `value`; setting the options to `{silent: true}` prevents
|
|
13
|
+
* `withState()` from updating the state while `value` is pending
|
|
14
|
+
* (e.g. for background or optimistic updates);
|
|
15
|
+
* - `setState()` to directly update the state.
|
|
16
|
+
*/
|
|
17
|
+
export declare function usePendingState(
|
|
18
|
+
/**
|
|
19
|
+
* A unique store key or a store. Providing a store key or a
|
|
20
|
+
* shared store allows to share the state across multiple
|
|
21
|
+
* components.
|
|
22
|
+
*/
|
|
23
|
+
store?: string | Store<PendingState> | null): [PendingState, <T>(value: T) => T, SetStoreState<PendingState>];
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@t8/react-pending",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.23",
|
|
4
4
|
"description": "Concise async action state tracking for React apps",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
6
7
|
"type": "module",
|
|
7
8
|
"scripts": {
|
|
8
|
-
"build": "npx npm-run-all clean compile",
|
|
9
|
+
"build": "npx npm-run-all clean compile types",
|
|
9
10
|
"clean": "node -e \"require('node:fs').rmSync('dist', { force: true, recursive: true });\"",
|
|
10
11
|
"compile": "npx esbuild index.ts --bundle --outdir=dist --platform=neutral --external:react",
|
|
11
12
|
"demo": "npx @t8/serve 3000 * tests/async_status -b src/index.tsx",
|
|
@@ -13,7 +14,8 @@
|
|
|
13
14
|
"preversion": "npx npm-run-all typecheck shape build test",
|
|
14
15
|
"shape": "npx codeshape",
|
|
15
16
|
"test": "npx playwright test --project=chromium",
|
|
16
|
-
"typecheck": "tsc --noEmit"
|
|
17
|
+
"typecheck": "tsc --noEmit",
|
|
18
|
+
"types": "tsc -p tsconfig.build.json"
|
|
17
19
|
},
|
|
18
20
|
"author": "axtk",
|
|
19
21
|
"license": "MIT",
|
|
@@ -32,7 +34,7 @@
|
|
|
32
34
|
},
|
|
33
35
|
"devDependencies": {
|
|
34
36
|
"@playwright/test": "^1.56.0",
|
|
35
|
-
"@t8/serve": "^0.1.
|
|
37
|
+
"@t8/serve": "^0.1.35",
|
|
36
38
|
"@types/node": "^24.5.2",
|
|
37
39
|
"@types/react": "^19.1.10",
|
|
38
40
|
"@types/react-dom": "^19.1.9",
|
|
@@ -40,6 +42,6 @@
|
|
|
40
42
|
"typescript": "^5.9.3"
|
|
41
43
|
},
|
|
42
44
|
"dependencies": {
|
|
43
|
-
"@t8/react-store": "^1.0.
|
|
45
|
+
"@t8/react-store": "^1.0.34"
|
|
44
46
|
}
|
|
45
47
|
}
|
package/tsconfig.json
CHANGED