@bouko/react 1.5.7 → 1.5.9
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.d.ts +1 -0
- package/dist/components/button.js +5 -3
- package/dist/components/heading.js +2 -2
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/input.d.ts +5 -1
- package/dist/components/input.js +3 -2
- package/dist/components/layout/separator.d.ts +3 -0
- package/dist/components/layout/separator.js +24 -0
- package/dist/core/functions.d.ts +1 -0
- package/dist/core/functions.js +6 -0
- package/dist/hooks/element/container.d.ts +4 -0
- package/dist/hooks/element/container.js +7 -0
- package/dist/hooks/element/resize.d.ts +1 -0
- package/dist/hooks/element/resize.js +12 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -4,16 +4,18 @@ export function Button({ variant, style, ...props }) {
|
|
|
4
4
|
return (_jsx("button", { className: cn(styles({ variant }), style), ...props }));
|
|
5
5
|
}
|
|
6
6
|
const styles = tv({
|
|
7
|
-
base: "flex items-center gap-2
|
|
7
|
+
base: "flex items-center gap-2 bg-accent hover:bg-accent-dark border border-accent-dark rounded font-semibold text-background-light duration-200 cursor-pointer disabled:cursor-not-allowed",
|
|
8
|
+
defaultVariants: { size: "md" },
|
|
8
9
|
variants: {
|
|
9
10
|
variant: {
|
|
10
11
|
primary: "bg-primary hover:bg-primary-dark border-primary-dark",
|
|
11
|
-
outline: "!bg-transparent border-
|
|
12
|
+
outline: "!bg-transparent border-accent hover:border-accent-dark text-primary",
|
|
12
13
|
ghost: "!bg-transparent border-transparent text-accent hover:text-accent-dark"
|
|
13
14
|
},
|
|
14
15
|
size: {
|
|
15
16
|
sm: "px-3 py-1 text-sm",
|
|
16
|
-
|
|
17
|
+
md: "px-4 py-2",
|
|
18
|
+
lg: "px-5 py-3 text-lg"
|
|
17
19
|
}
|
|
18
20
|
}
|
|
19
21
|
});
|
|
@@ -9,6 +9,6 @@ const base = {
|
|
|
9
9
|
container: "gap-2 items-center",
|
|
10
10
|
subcontainer: "flex grow flex-col",
|
|
11
11
|
badge: "mb-2",
|
|
12
|
-
title: "flex items-center gap-2 font-bold",
|
|
13
|
-
subtitle: "
|
|
12
|
+
title: "flex items-center gap-2 text-lg font-bold",
|
|
13
|
+
subtitle: "font-semibold text-primary-lighter"
|
|
14
14
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Separator } from "./layout/separator";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Separator } from "./layout/separator";
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { type Field as FieldProps } from "@bouko/form";
|
|
2
2
|
type Props<T> = FieldProps<T> & {
|
|
3
3
|
placeholder?: string;
|
|
4
|
+
styles?: {
|
|
5
|
+
container?: string;
|
|
6
|
+
input?: string;
|
|
7
|
+
};
|
|
4
8
|
};
|
|
5
|
-
export default function Input<T>({ id, style, label, required, note, update, ...props }: Props<T>): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export default function Input<T>({ id, styles, style, label, required, note, update, ...props }: Props<T>): import("react/jsx-runtime").JSX.Element;
|
|
6
10
|
export {};
|
package/dist/components/input.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import Field from "./field";
|
|
3
|
+
import { cn } from "@bouko/style";
|
|
3
4
|
import { setField } from "@bouko/form";
|
|
4
|
-
export default function Input({ id, style, label, required = true, note, update, ...props }) {
|
|
5
|
-
return (_jsx(Field, { style:
|
|
5
|
+
export default function Input({ id, styles, style, label, required = true, note, update, ...props }) {
|
|
6
|
+
return (_jsx(Field, { style: styles?.container, label: label, required: required, note: note, children: _jsx("input", { className: cn("px-3 py-2 bg-input border border-outline duration-200 focus:border-outline-light outline-none rounded text-sm", styles?.input), onChange: ({ target: { value } }) => setField(update, id, value), ...props }) }));
|
|
6
7
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { useContainer, useResize } from "../../hooks";
|
|
5
|
+
import { cn, tv } from "@bouko/style";
|
|
6
|
+
export default function Separator({ style }) {
|
|
7
|
+
const { container, ref } = useContainer();
|
|
8
|
+
const [flow, setFlow] = useState();
|
|
9
|
+
useResize(container, () => {
|
|
10
|
+
const css = getComputedStyle(container);
|
|
11
|
+
setFlow(css.flexDirection);
|
|
12
|
+
});
|
|
13
|
+
return (_jsx("div", { className: cn(styles({ flow }), style), ref: ref }));
|
|
14
|
+
}
|
|
15
|
+
;
|
|
16
|
+
const styles = tv({
|
|
17
|
+
base: "bg-border-dark",
|
|
18
|
+
variants: {
|
|
19
|
+
flow: {
|
|
20
|
+
row: "w-px min-w-px h-full",
|
|
21
|
+
column: "w-full h-px min-h-px"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
});
|
package/dist/core/functions.d.ts
CHANGED
package/dist/core/functions.js
CHANGED
|
@@ -13,3 +13,9 @@ export const getFileData = (files) => Promise.all(files.map((file) => {
|
|
|
13
13
|
reader.readAsDataURL(file);
|
|
14
14
|
});
|
|
15
15
|
}));
|
|
16
|
+
export const getEnv = (key) => {
|
|
17
|
+
const value = process.env[key];
|
|
18
|
+
if (!value)
|
|
19
|
+
throw new Error(`Missing required env: ${key}`);
|
|
20
|
+
return value;
|
|
21
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function useResizeObserver(element: HTMLElement | null | undefined, action: () => void): void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
export default function useResizeObserver(element, action) {
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
if (!element)
|
|
6
|
+
return;
|
|
7
|
+
const observer = new ResizeObserver(action);
|
|
8
|
+
observer.observe(element);
|
|
9
|
+
action();
|
|
10
|
+
return () => observer.disconnect();
|
|
11
|
+
}, [element, action]);
|
|
12
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export { default as CheckBox } from "./components/checkbox";
|
|
|
7
7
|
export { default as Heading } from "./components/heading";
|
|
8
8
|
export { default as Badge } from "./components/badge";
|
|
9
9
|
export { default as FadeCarousel } from "./components/fade-carousel";
|
|
10
|
+
export * from "./components";
|
|
10
11
|
export * from "./components/flex";
|
|
11
12
|
export * from "./components/button";
|
|
12
13
|
export * from "./core/types";
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ export { default as CheckBox } from "./components/checkbox";
|
|
|
7
7
|
export { default as Heading } from "./components/heading";
|
|
8
8
|
export { default as Badge } from "./components/badge";
|
|
9
9
|
export { default as FadeCarousel } from "./components/fade-carousel";
|
|
10
|
+
export * from "./components";
|
|
10
11
|
export * from "./components/flex";
|
|
11
12
|
export * from "./components/button";
|
|
12
13
|
export * from "./core/types";
|