@bouko/react 3.0.4 → 3.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/dist/components/button/icon.d.ts +5 -1
- package/dist/components/button/icon.js +19 -16
- package/dist/components/layout/fade.js +1 -1
- package/dist/components/layout/flex.d.ts +1 -0
- package/dist/components/layout/flex.js +4 -2
- package/dist/hooks/router/params.d.ts +1 -0
- package/dist/hooks/router/params.js +11 -4
- package/package.json +1 -1
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
import type { Clickable } from "../../core/types";
|
|
2
|
-
|
|
2
|
+
type Props = Clickable & {
|
|
3
|
+
variant?: "accent" | "primary" | "outline" | "ghost" | "secondary" | "error" | "future";
|
|
4
|
+
};
|
|
5
|
+
export declare function IconButton({ variant, style, icon, action, disabled }: Props): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export default IconButton;
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn, tv } from "@bouko/style";
|
|
2
3
|
import Check from "../../assets/icons/check.svg";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return (_jsx("button", { className: cn("flex hover:brightness-115 disabled:!cursor-not-allowed", style), style: styles(color), onClick: action, disabled: !action || disabled, children: icon || _jsx(Check, {}) }));
|
|
4
|
+
export function IconButton({ variant, style, icon, action, disabled = false }) {
|
|
5
|
+
return (_jsx("button", { className: cn(styles({ variant }), style), onClick: action, disabled: !action || disabled, children: icon || _jsx(Check, {}) }));
|
|
6
6
|
}
|
|
7
|
-
const styles = (
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
7
|
+
const styles = tv({
|
|
8
|
+
base: "flex justify-center items-center p-2 rounded-full outline-none border text-sm text-primary-dark duration-200 cursor-pointer disabled:cursor-not-allowed hover:brightness-115",
|
|
9
|
+
defaultVariants: { variant: "surface" },
|
|
10
|
+
variants: {
|
|
11
|
+
variant: {
|
|
12
|
+
surface: "bg-surface border-border",
|
|
13
|
+
accent: "bg-accent border-accent-darker text-background-light",
|
|
14
|
+
primary: "bg-primary border-primary-dark",
|
|
15
|
+
outline: "bg-transparent border-accent hover:border-accent-dark text-primary",
|
|
16
|
+
ghost: "bg-transparent border-transparent text-primary hover:brightness-110",
|
|
17
|
+
secondary: "bg-background-dark dark:bg-background-light border-border-dark dark:border-border-light text-background-darker dark:text-primary",
|
|
18
|
+
error: "bg-error border-error-dark",
|
|
19
|
+
future: "rounded-lg text-primary border-transparent backdrop-blur-sm test-button"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
20
22
|
});
|
|
23
|
+
export default IconButton;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { cn, tv } from "@bouko/style";
|
|
3
|
-
export function FadeBox({ style, direction = "
|
|
3
|
+
export function FadeBox({ style, direction = "up", gradient, children }) {
|
|
4
4
|
return (_jsxs("div", { className: cn("relative", style), children: [children, _jsx("div", { className: cn(styles({ direction }), gradient) })] }));
|
|
5
5
|
}
|
|
6
6
|
const styles = tv({
|
|
@@ -29,7 +29,8 @@ const row = tv({
|
|
|
29
29
|
variants: {
|
|
30
30
|
centerX: { true: "justify-center" },
|
|
31
31
|
centerY: { true: "items-center" },
|
|
32
|
-
center: { true: "items-center justify-center" }
|
|
32
|
+
center: { true: "items-center justify-center" },
|
|
33
|
+
equal: { true: "[&>*]:flex-1" }
|
|
33
34
|
}
|
|
34
35
|
});
|
|
35
36
|
const column = tv({
|
|
@@ -37,6 +38,7 @@ const column = tv({
|
|
|
37
38
|
variants: {
|
|
38
39
|
centerX: { true: "items-center" },
|
|
39
40
|
centerY: { true: "justify-center" },
|
|
40
|
-
center: { true: "items-center justify-center" }
|
|
41
|
+
center: { true: "items-center justify-center" },
|
|
42
|
+
equal: { true: "[&>*]:flex-1" }
|
|
41
43
|
}
|
|
42
44
|
});
|
|
@@ -8,6 +8,7 @@ export function usePagination({ fetcher, pageSize }) {
|
|
|
8
8
|
const [params, setParams] = useSearchParams();
|
|
9
9
|
const [items, setItems] = useState([]);
|
|
10
10
|
const [loading, setLoading] = useState(false);
|
|
11
|
+
const [fetchedAt, setFetchedAt] = useState(null);
|
|
11
12
|
const raw = params.get("page");
|
|
12
13
|
const page = Math.max(1, Number(raw) || 1);
|
|
13
14
|
const setPage = (nextPage) => {
|
|
@@ -16,9 +17,14 @@ export function usePagination({ fetcher, pageSize }) {
|
|
|
16
17
|
};
|
|
17
18
|
const fetchPage = useCallback(async (refresh = false) => {
|
|
18
19
|
setLoading(true);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
const result = await fetcher({
|
|
21
|
+
page,
|
|
22
|
+
pageSize,
|
|
23
|
+
refresh
|
|
24
|
+
});
|
|
25
|
+
setItems(result);
|
|
26
|
+
setFetchedAt(new Date());
|
|
27
|
+
setLoading(false);
|
|
22
28
|
}, [page, pageSize]);
|
|
23
29
|
useEffect(() => {
|
|
24
30
|
fetchPage(false);
|
|
@@ -29,6 +35,7 @@ export function usePagination({ fetcher, pageSize }) {
|
|
|
29
35
|
page,
|
|
30
36
|
prev: () => page > 1 ? setPage(page - 1) : undefined,
|
|
31
37
|
next: () => !(page > 1 && items.length === 0) ? setPage(page + 1) : undefined,
|
|
32
|
-
refresh: () => fetchPage(true)
|
|
38
|
+
refresh: () => fetchPage(true),
|
|
39
|
+
fetchedAt
|
|
33
40
|
};
|
|
34
41
|
}
|