@bouko/react 0.3.0 → 0.3.2

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.
@@ -3,7 +3,7 @@ type Props = InputHTMLAttributes<HTMLInputElement> & {
3
3
  label?: string;
4
4
  style?: string;
5
5
  required?: boolean;
6
- note?: string;
6
+ note?: ReactNode;
7
7
  children: ReactNode;
8
8
  };
9
9
  export default function Field({ style, label, required, note, children }: Props): import("react/jsx-runtime").JSX.Element;
@@ -4,7 +4,7 @@ export default function Field({ style, label, required = true, note, children })
4
4
  return (_jsxs("div", { className: cn(styles.container, style), children: [label && _jsxs("span", { className: styles.label, children: [label, " ", !required ? _jsx("span", { className: "italic text-slate-400", children: "(optional)" }) : ""] }), children, note && _jsx("span", { className: styles.note, children: note })] }));
5
5
  }
6
6
  const styles = {
7
- container: "flex flex-col gap-1 overflow-hidden",
7
+ container: "flex flex-col shrink-0 gap-1 w-full overflow-hidden",
8
8
  label: "text-xs text-slate-600",
9
9
  input: "px-3 py-2 bg-slate-200/50 border border-slate-300 outline-blue-500 rounded text-sm",
10
10
  note: "mt-1 text-xs text-slate-500"
@@ -1,9 +1,10 @@
1
1
  import type { ReactNode } from "react";
2
2
  type Props = {
3
3
  container?: string;
4
+ icon?: ReactNode;
4
5
  title: ReactNode;
5
6
  subtitle: ReactNode;
6
7
  reverse?: boolean;
7
8
  };
8
- export default function Heading({ container, title, subtitle, reverse }: Props): import("react/jsx-runtime").JSX.Element;
9
+ export default function Heading({ container, icon, title, subtitle, reverse }: Props): import("react/jsx-runtime").JSX.Element;
9
10
  export {};
@@ -1,10 +1,12 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { ColumnBox } from "./flex";
2
+ import { RowBox, ColumnBox } from "./flex";
3
3
  import { cn } from "@bouko/style";
4
- export default function Heading({ container, title, subtitle, reverse }) {
5
- return (_jsxs(ColumnBox, { style: cn(container, reverse && "flex-col-reverse"), children: [_jsx("span", { className: styles.title, children: title }), _jsx("span", { className: styles.subtitle, children: subtitle })] }));
4
+ export default function Heading({ container, icon, title, subtitle, reverse }) {
5
+ return (_jsxs(RowBox, { style: cn(container, styles.container), children: [icon, _jsxs(ColumnBox, { style: cn(styles.subcontainer, reverse && "flex-col-reverse"), children: [_jsx("span", { className: styles.title, children: title }), _jsx("span", { className: styles.subtitle, children: subtitle })] })] }));
6
6
  }
7
7
  const styles = {
8
+ container: "gap-2 items-center",
9
+ subcontainer: "grow",
8
10
  title: "flex items-center gap-2 font-bold",
9
11
  subtitle: "text-sm font-semibold text-primary-lighter"
10
12
  };
@@ -1,6 +1,6 @@
1
- import type { Field as FieldProps } from "../core/types";
2
- type Props = FieldProps & {
1
+ import { type Field as FieldProps } from "@bouko/form";
2
+ type Props<T> = FieldProps<T> & {
3
3
  placeholder?: string;
4
4
  };
5
- export default function Input({ style, label, required, note, update, ...props }: Props): import("react/jsx-runtime").JSX.Element;
5
+ export default function Input<T>({ id, style, label, required, note, update, ...props }: Props<T>): import("react/jsx-runtime").JSX.Element;
6
6
  export {};
@@ -1,5 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import Field from "./field";
3
- export default function Input({ style, label, required = true, note, update, ...props }) {
4
- return (_jsx(Field, { style: style, label: label, required: required, note: note, children: _jsx("input", { className: "px-3 py-2 bg-slate-200/50 border border-slate-300 outline-blue-500 rounded text-sm", onChange: ({ target: { value } }) => update(value), ...props }) }));
3
+ import { setField } from "@bouko/form";
4
+ export default function Input({ id, style, label, required = true, note, update, ...props }) {
5
+ return (_jsx(Field, { style: style, label: label, required: required, note: note, children: _jsx("input", { className: "px-3 py-2 bg-slate-200/50 border border-slate-300 outline-blue-500 rounded text-sm", onChange: ({ target: { value } }) => setField(update, id, value), ...props }) }));
5
6
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
 
3
3
  "name": "@bouko/react",
4
- "version": "0.3.0",
4
+ "version": "0.3.2",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "license": "MIT",