@bouko/react 1.9.3 → 1.9.5

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.
@@ -1,12 +1,25 @@
1
- import type { ReactNode } from "react";
1
+ import { type ReactNode } from "react";
2
+ type Styles = {
3
+ container?: string;
4
+ text?: string;
5
+ title?: string;
6
+ subtitle?: string;
7
+ };
8
+ type Options = {
9
+ size?: "md" | "lg";
10
+ align?: "left" | "center";
11
+ };
2
12
  export type HeadingProps = {
3
- styles?: Record<string, string>;
13
+ options?: Options;
14
+ styles?: Styles;
4
15
  container?: string;
5
16
  badge?: string;
6
17
  icon?: ReactNode;
7
18
  title: ReactNode;
19
+ size?: "md" | "lg";
8
20
  align?: "left" | "center";
9
21
  subtitle?: ReactNode;
10
22
  reverse?: boolean;
11
23
  };
12
- export default function Heading({ styles, container, badge, icon, title, align, subtitle, reverse }: HeadingProps): import("react/jsx-runtime").JSX.Element;
24
+ export default function Heading({ styles, options, container, badge, icon, title, subtitle, reverse }: HeadingProps): import("react/jsx-runtime").JSX.Element;
25
+ export {};
@@ -1,14 +1,45 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { RowBox, ColumnBox } from "../flex";
3
- import { cn } from "@bouko/style";
4
3
  import Badge from "../text/badge";
5
- export default function Heading({ styles = {}, container, badge, icon, title, align = "left", subtitle, reverse }) {
6
- return (_jsxs(RowBox, { style: cn(base.container, styles.container, container), children: [icon, _jsxs(ColumnBox, { style: cn(base.subcontainer, align === "center" && "items-center", reverse && "flex-col-reverse"), children: [badge && _jsx(Badge, { style: base.badge, children: badge }), _jsx("span", { className: cn(base.title, styles.title), children: title }), subtitle && _jsx("span", { className: cn(base.subtitle, styles.subtitle, align === "center" && "text-center"), children: subtitle })] })] }));
4
+ import { cn, tv } from "@bouko/style";
5
+ export default function Heading({ styles = {}, options = {}, container, badge, icon, title, subtitle, reverse }) {
6
+ const custom = test(options);
7
+ return (_jsxs(RowBox, { style: cn(base.container, styles.container, container), children: [icon, _jsxs(ColumnBox, { style: cn(custom.subcontainer(), reverse && "flex-col-reverse"), children: [badge && _jsx(Badge, { style: base.badge, children: badge }), _jsx(RowBox, { style: cn(custom.title(), styles.title, styles.text), children: title }), subtitle && _jsx(RowBox, { style: cn(custom.subtitle(), styles.subtitle, styles.text), children: subtitle })] })] }));
7
8
  }
8
9
  const base = {
9
10
  container: "gap-2 items-center",
10
- subcontainer: "flex grow flex-col",
11
11
  badge: "mb-2",
12
- title: "flex items-center gap-2 text-lg font-bold",
13
- subtitle: "font-semibold text-primary-lighter"
14
12
  };
13
+ const test = tv({
14
+ slots: {
15
+ subcontainer: "grow",
16
+ title: "items-center gap-2 text-xl font-bold text-primary",
17
+ subtitle: "items-center gap-2 font-semibold text-primary-light dark:text-primary-dark"
18
+ },
19
+ defaultVariants: {
20
+ size: "md",
21
+ align: "center"
22
+ },
23
+ variants: {
24
+ size: {
25
+ md: {
26
+ title: "text-xl 2xl:text-2xl",
27
+ subtitle: "text-base 2xl:text-lg"
28
+ },
29
+ lg: {
30
+ subcontainer: "gap-3",
31
+ title: "text-5xl 2xl:text-6xl",
32
+ subtitle: "text-sm sm:text-base 2xl:text-lg"
33
+ }
34
+ },
35
+ align: {
36
+ left: {
37
+ subcontainer: "items-start"
38
+ },
39
+ center: {
40
+ subcontainer: "items-center",
41
+ subtitle: "justify-center text-center"
42
+ }
43
+ }
44
+ }
45
+ });
@@ -1 +1,3 @@
1
+ import { ReactNode } from "react";
2
+ export declare const rn: (...elements: ReactNode[]) => import("react/jsx-runtime").JSX.Element;
1
3
  export declare const formatText: (text: string) => import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Fragment } from "react";
2
3
  const delimiterConfig = [
3
4
  { delimiter: "**", render: (text, key) => _jsx("span", { className: "font-bold", children: text }, key) },
4
5
  { delimiter: "~~", render: (text, key) => _jsx("span", { className: "font-semibold", children: text }, key) },
@@ -8,6 +9,7 @@ const escapeRegex = (str) => str.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
8
9
  const delimiters = delimiterConfig.map(({ delimiter }) => escapeRegex(delimiter) + ".*?" + escapeRegex(delimiter)).join("|");
9
10
  const WRAPPED_TEXT_REGEX = new RegExp(`(${delimiters})`, "g");
10
11
  const isWrapped = (x, wrapper) => x.startsWith(wrapper) && x.endsWith(wrapper);
12
+ export const rn = (...elements) => (_jsx(Fragment, { children: elements.map((x, i) => (_jsx(Fragment, { children: x }, i))) }));
11
13
  export const formatText = (text) => {
12
14
  const parts = text
13
15
  .split(WRAPPED_TEXT_REGEX)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
 
3
3
  "name": "@bouko/react",
4
- "version": "1.9.3",
4
+ "version": "1.9.5",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "license": "MIT",