axokit-react 0.0.4 → 0.0.6

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # AxoKit — AsyncButton & useAsyncAction
1
+ # AxoKit React — AsyncButton & useAsyncAction
2
2
 
3
- A tiny headless React UI primitive for handling asynchronous button states.
3
+ Production-ready async interaction primitives for React & Next.js.
4
4
 
5
5
  Package name: `axokit-react` (install with `npm install axokit-react`).
6
6
 
@@ -12,12 +12,20 @@ Package name: `axokit-react` (install with `npm install axokit-react`).
12
12
  - Minimal styles; load your own CSS or Tailwind classes
13
13
  - Works with React 18+
14
14
 
15
+ ## Why AxoKit?
16
+
17
+ - Production‑ready async state management with minimal boilerplate.
18
+ - Works with both component and hook patterns.
19
+ - Tiny footprint and zero runtime dependencies.
20
+ - Fully typed for TypeScript and compatible with React 18+.
21
+ - Accessible ARIA attributes and easy styling with Tailwind or CSS.
22
+
15
23
  ## Installation
16
24
 
17
25
  ```bash
18
26
  npm install axokit-react
19
27
  # also install peer dependencies
20
- npm install react react-dom
28
+ Requires `react` and `react-dom` 18+ as peer dependencies.
21
29
  ```
22
30
 
23
31
  ## Usage (component)
@@ -44,6 +52,16 @@ function SaveButton() {
44
52
  }
45
53
  ```
46
54
 
55
+ ## Next.js (App Router)
56
+
57
+ If you're using the App Router, add `'use client'` at the top of your component file:
58
+
59
+ ```tsx
60
+ 'use client';
61
+
62
+ import { AsyncButton } from 'axokit-react';
63
+ ```
64
+
47
65
  ## Usage (hook)
48
66
 
49
67
  ```tsx
@@ -64,11 +82,33 @@ function HookExample() {
64
82
  }
65
83
  ```
66
84
 
85
+ ## Example
86
+
87
+ ```tsx
88
+ import { AsyncButton } from 'axokit-react';
89
+
90
+ function Demo() {
91
+ const doWork = () => fetch('/api/work');
92
+ return (
93
+ <AsyncButton
94
+ onAction={doWork}
95
+ loadingText="Working…"
96
+ successText="Done!"
97
+ errorText="Failed"
98
+ showSpinner
99
+ className="btn"
100
+ >
101
+ Click me
102
+ </AsyncButton>
103
+ );
104
+ }
105
+ ```
106
+
67
107
  ## API
68
108
 
69
109
  ### `AsyncButton(props)`
70
110
 
71
- - `onAction: () => Promise<any>` — **required**.
111
+ - `onAction: () => Promise<unknown>` — **required**.
72
112
  - `loadingText?: string` — default: `"Loading..."`.
73
113
  - `successText?: string` — default: `"Done!"`.
74
114
  - `errorText?: string` — default: `"Try again"`.
@@ -106,4 +146,6 @@ Use `data-state` to adjust styles via CSS/Tailwind.
106
146
 
107
147
  MIT
108
148
 
109
- Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
149
+ ## Keywords
150
+
151
+ async, react, async-button, useAsyncAction, hook, component, loading, success, error, state, nextjs, tailwind, aria, accessible, typescript
package/dist/index.d.ts CHANGED
@@ -14,9 +14,9 @@ interface UseAsyncActionReturn {
14
14
  trigger: () => Promise<void>;
15
15
  reset: () => void;
16
16
  }
17
- declare function useAsyncAction(action: () => Promise<any>, options?: UseAsyncActionOptions): UseAsyncActionReturn;
17
+ declare function useAsyncAction(action: () => Promise<unknown>, options?: UseAsyncActionOptions): UseAsyncActionReturn;
18
18
  interface AsyncButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
19
- onAction: () => Promise<any>;
19
+ onAction: () => Promise<unknown>;
20
20
  loadingText?: string;
21
21
  successText?: string;
22
22
  errorText?: string;
package/dist/index.js CHANGED
@@ -45,6 +45,7 @@ function useAsyncAction(action, options = {}) {
45
45
  const timeoutRef = React.useRef(null);
46
46
  const mountedRef = React.useRef(true);
47
47
  React.useEffect(() => {
48
+ mountedRef.current = true;
48
49
  return () => {
49
50
  mountedRef.current = false;
50
51
  if (timeoutRef.current) {
package/dist/index.mjs CHANGED
@@ -8,6 +8,7 @@ function useAsyncAction(action, options = {}) {
8
8
  const timeoutRef = React.useRef(null);
9
9
  const mountedRef = React.useRef(true);
10
10
  React.useEffect(() => {
11
+ mountedRef.current = true;
11
12
  return () => {
12
13
  mountedRef.current = false;
13
14
  if (timeoutRef.current) {
package/package.json CHANGED
@@ -1,7 +1,24 @@
1
1
  {
2
2
  "name": "axokit-react",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "Headless async button and hook for React",
5
+ "keywords": [
6
+ "react",
7
+ "async",
8
+ "async-button",
9
+ "useAsyncAction",
10
+ "hook",
11
+ "component",
12
+ "loading",
13
+ "success",
14
+ "error",
15
+ "state",
16
+ "nextjs",
17
+ "tailwind",
18
+ "aria",
19
+ "accessible",
20
+ "typescript"
21
+ ],
5
22
  "main": "dist/index.js",
6
23
  "module": "dist/index.mjs",
7
24
  "types": "dist/index.d.ts",