asterui 0.12.33 → 0.12.35

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
@@ -2,16 +2,48 @@
2
2
 
3
3
  A comprehensive React component library built with [DaisyUI](https://daisyui.com) and [Tailwind CSS](https://tailwindcss.com).
4
4
 
5
- ## Prerequisites
5
+ ## Demo
6
6
 
7
- AsterUI requires Tailwind CSS v4 and DaisyUI v5 to be configured in your project.
7
+ View the documentation at: [https://asterui.com](https://asterui.com)
8
8
 
9
- Install Tailwind and DaisyUI:
9
+ ## Quick Start
10
+
11
+ The fastest way to get started is with `create-asterui`, which sets up a new project with Vite, Tailwind CSS v4, DaisyUI v5, and AsterUI pre-configured:
12
+
13
+ ```bash
14
+ npm create asterui@latest
15
+ # or
16
+ pnpm create asterui@latest
17
+ # or
18
+ yarn create asterui
19
+ ```
20
+
21
+ The CLI will guide you through interactive prompts to configure:
22
+ - **Language** - TypeScript (recommended) or JavaScript
23
+ - **Themes** - Light/Dark, Business/Corporate, all themes, or custom selection
24
+ - **Package manager** - npm, pnpm, or yarn (auto-detected)
25
+ - **Optional components** - Chart, QRCode, VirtualList (adds required peer dependencies)
26
+
27
+ Then start the dev server:
10
28
 
11
29
  ```bash
30
+ cd my-app
31
+ npm run dev
32
+ ```
33
+
34
+ ## Manual Installation
35
+
36
+ To add AsterUI to an existing project, you'll need Tailwind CSS v4 and DaisyUI v5.
37
+
38
+ ### 1. Install dependencies
39
+
40
+ ```bash
41
+ npm install asterui
12
42
  npm install -D tailwindcss @tailwindcss/vite daisyui
13
43
  ```
14
44
 
45
+ ### 2. Configure Vite
46
+
15
47
  Add the Tailwind plugin to your `vite.config.ts`:
16
48
 
17
49
  ```ts
@@ -24,7 +56,9 @@ export default defineConfig({
24
56
  })
25
57
  ```
26
58
 
27
- Configure your CSS file (e.g., `src/index.css`):
59
+ ### 3. Configure CSS
60
+
61
+ Update your CSS file (e.g., `src/index.css`):
28
62
 
29
63
  ```css
30
64
  @import "tailwindcss";
@@ -34,16 +68,6 @@ Configure your CSS file (e.g., `src/index.css`):
34
68
 
35
69
  The `@source` directive tells Tailwind to scan the AsterUI package for classes to include in your build.
36
70
 
37
- ## Installation
38
-
39
- ```bash
40
- npm install asterui
41
- # or
42
- pnpm add asterui
43
- # or
44
- yarn add asterui
45
- ```
46
-
47
71
  ## Usage
48
72
 
49
73
  ```tsx
@@ -53,46 +77,46 @@ const { Link, Paragraph } = Typography
53
77
 
54
78
  export default function App() {
55
79
  const handleSubmit = (values: { email: string; password: string; remember: boolean }) => {
56
- Modal.success({
57
- title: 'Login Successful',
58
- content: <pre className="text-left">{JSON.stringify(values, null, 2)}</pre>,
59
- })
80
+ Modal.success({
81
+ title: 'Login Successful',
82
+ content: <pre className="text-left">{JSON.stringify(values, null, 2)}</pre>,
83
+ })
60
84
  }
61
85
 
62
86
  return (
63
87
  <Flex justify="center" align="center" minHeight="screen" className="bg-base-200 p-4">
64
88
  <Card title="Sign In" className="w-full max-w-md">
65
89
  <Form onFinish={handleSubmit} initialValues={{ remember: false }}>
66
- <Form.Item name="email" label="Email" rules={[{ required: true }, { type: 'email' }]}>
67
- <Input placeholder="you@example.com" />
90
+ <Form.Item name="email" label="Email" rules={[{ required: true }, { type: 'email' }]}>
91
+ <Input placeholder="you@example.com" />
92
+ </Form.Item>
93
+ <Form.Item
94
+ name="password"
95
+ label="Password"
96
+ rules={[
97
+ { required: true },
98
+ { min: 8, message: 'Password must be at least 8 characters' },
99
+ { pattern: /[A-Z]/, message: 'Must contain an uppercase letter' },
100
+ { pattern: /[a-z]/, message: 'Must contain a lowercase letter' },
101
+ { pattern: /[0-9]/, message: 'Must contain a number' },
102
+ { pattern: /[!@#$%^&*.?]/, message: 'Must contain a special character' },
103
+ ]}
104
+ >
105
+ <Input type="password" placeholder="Enter your password" />
106
+ </Form.Item>
107
+ <Space justify="between" align="center" className="mb-4">
108
+ <Form.Item name="remember" valuePropName="checked" inline>
109
+ <Checkbox>Remember me</Checkbox>
68
110
  </Form.Item>
69
- <Form.Item
70
- name="password"
71
- label="Password"
72
- rules={[
73
- { required: true },
74
- { min: 8, message: 'Password must be at least 8 characters' },
75
- { pattern: /[A-Z]/, message: 'Must contain an uppercase letter' },
76
- { pattern: /[a-z]/, message: 'Must contain a lowercase letter' },
77
- { pattern: /[0-9]/, message: 'Must contain a number' },
78
- { pattern: /[!@#$%^&*.?]/, message: 'Must contain a special character' },
79
- ]}
80
- >
81
- <Input type="password" placeholder="Enter your password" />
82
- </Form.Item>
83
- <Space justify="between" align="center" className="mb-4">
84
- <Form.Item name="remember" valuePropName="checked" inline>
85
- <Checkbox>Remember me</Checkbox>
86
- </Form.Item>
87
- <Link size="sm">Forgot password?</Link>
88
- </Space>
89
- <Button color="primary" htmlType="submit" shape="block">
90
- Sign In
91
- </Button>
92
- <Divider>or</Divider>
93
- <Paragraph align="center" size="sm">
94
- Don't have an account? <Link>Sign up</Link>
95
- </Paragraph>
111
+ <Link size="sm">Forgot password?</Link>
112
+ </Space>
113
+ <Button color="primary" htmlType="submit" shape="block">
114
+ Sign In
115
+ </Button>
116
+ <Divider>or</Divider>
117
+ <Paragraph align="center" size="sm">
118
+ Don't have an account? <Link>Sign up</Link>
119
+ </Paragraph>
96
120
  </Form>
97
121
  </Card>
98
122
  </Flex>
@@ -104,6 +128,24 @@ export default function App() {
104
128
 
105
129
  90+ components including forms, data display, navigation, feedback, and layout. See the full list at [asterui.com/components](https://asterui.com/components).
106
130
 
131
+ ## Optional Components
132
+
133
+ Some components require additional peer dependencies and use separate imports:
134
+
135
+ ```bash
136
+ # For Chart component
137
+ npm install apexcharts
138
+ import { Chart } from 'asterui/chart'
139
+
140
+ # For QRCode component
141
+ npm install qrcode
142
+ import { QRCode } from 'asterui/qrcode'
143
+
144
+ # For VirtualList component
145
+ npm install @tanstack/react-virtual
146
+ import { VirtualList } from 'asterui/virtuallist'
147
+ ```
148
+
107
149
  ## Requirements
108
150
 
109
151
  - React 18 or 19
@@ -1,62 +1,73 @@
1
- import { jsx as e, jsxs as y } from "react/jsx-runtime";
2
- import { useRef as Q, useState as j, useEffect as R } from "react";
3
- import F from "qrcode";
4
- const k = ({
5
- value: m,
6
- size: a = 160,
1
+ import { jsx as e, jsxs as p } from "react/jsx-runtime";
2
+ import { useRef as Q, useState as w, useEffect as C } from "react";
3
+ const F = ({
4
+ value: h,
5
+ size: t = 160,
7
6
  errorLevel: v = "M",
8
7
  icon: f,
9
- iconSize: t = 40,
10
- type: h = "canvas",
11
- color: x = "#000000",
12
- bgColor: g = "#FFFFFF",
13
- bordered: l = !0,
14
- status: n = "active",
15
- onRefresh: p,
16
- className: C = "",
8
+ iconSize: a = 40,
9
+ type: g = "canvas",
10
+ color: u = "#000000",
11
+ bgColor: x = "#FFFFFF",
12
+ bordered: n = !0,
13
+ status: s = "active",
14
+ onRefresh: N,
15
+ className: R = "",
17
16
  ...c
18
17
  }) => {
19
- const s = Q(null), [w, i] = j(n === "loading");
20
- R(() => {
21
- i(n === "loading");
22
- }, [n]), R(() => {
23
- if (n !== "active" || !m) return;
18
+ const r = Q(null), [k, l] = w(s === "loading"), [j, L] = w(!1);
19
+ C(() => {
20
+ l(s === "loading");
21
+ }, [s]), C(() => {
22
+ if (s !== "active" || !h) return;
24
23
  (async () => {
25
24
  try {
26
- if (i(!0), h === "canvas" && s.current && (await F.toCanvas(s.current, m, {
27
- width: a,
25
+ l(!0);
26
+ let o;
27
+ try {
28
+ o = await import("qrcode");
29
+ } catch {
30
+ L(!0), l(!1);
31
+ return;
32
+ }
33
+ if (g === "canvas" && r.current && (await o.toCanvas(r.current, h, {
34
+ width: t,
28
35
  margin: 1,
29
36
  color: {
30
- dark: x,
31
- light: g
37
+ dark: u,
38
+ light: x
32
39
  },
33
40
  errorCorrectionLevel: v
34
41
  }), f)) {
35
- const o = s.current.getContext("2d");
36
- if (o) {
37
- const d = new Image();
38
- d.crossOrigin = "anonymous", d.onload = () => {
39
- const u = (a - t) / 2, b = (a - t) / 2;
40
- o.fillStyle = g, o.fillRect(u - 4, b - 4, t + 8, t + 8), o.drawImage(d, u, b, t, t);
41
- }, d.src = f;
42
+ const d = r.current.getContext("2d");
43
+ if (d) {
44
+ const m = new Image();
45
+ m.crossOrigin = "anonymous", m.onload = () => {
46
+ const y = (t - a) / 2, b = (t - a) / 2;
47
+ d.fillStyle = x, d.fillRect(y - 4, b - 4, a + 8, a + 8), d.drawImage(m, y, b, a, a);
48
+ }, m.src = f;
42
49
  }
43
50
  }
44
- i(!1);
45
- } catch (N) {
46
- console.error("QR Code generation error:", N), i(!1);
51
+ l(!1);
52
+ } catch (o) {
53
+ console.error("QR Code generation error:", o), l(!1);
47
54
  }
48
55
  })();
49
- }, [m, a, v, f, t, h, x, g, n]);
50
- const r = [
56
+ }, [h, t, v, f, a, g, u, x, s]);
57
+ const i = [
51
58
  "inline-flex items-center justify-center",
52
- l && "border border-base-content/20 p-3",
59
+ n && "border border-base-content/20 p-3",
53
60
  "bg-base-100",
54
- C
61
+ R
55
62
  ].filter(Boolean).join(" ");
56
- return n === "loading" || w ? /* @__PURE__ */ e("div", { className: r, style: { width: a + (l ? 24 : 0), height: a + (l ? 24 : 0) }, "data-state": "loading", ...c, children: /* @__PURE__ */ y("div", { className: "flex flex-col items-center justify-center gap-2", children: [
63
+ return j ? /* @__PURE__ */ e("div", { className: i, style: { width: t + (n ? 24 : 0), height: t + (n ? 24 : 0) }, "data-state": "error", ...c, children: /* @__PURE__ */ p("div", { className: "flex flex-col items-center justify-center gap-2 p-4 text-center", children: [
64
+ /* @__PURE__ */ e("svg", { className: "w-8 h-8 text-warning", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" }) }),
65
+ /* @__PURE__ */ e("span", { className: "text-sm text-base-content/70", children: "Missing dependency" }),
66
+ /* @__PURE__ */ e("code", { className: "text-xs bg-base-200 px-2 py-1 rounded", children: "npm install qrcode" })
67
+ ] }) }) : s === "loading" || k ? /* @__PURE__ */ e("div", { className: i, style: { width: t + (n ? 24 : 0), height: t + (n ? 24 : 0) }, "data-state": "loading", ...c, children: /* @__PURE__ */ p("div", { className: "flex flex-col items-center justify-center gap-2", children: [
57
68
  /* @__PURE__ */ e("span", { className: "loading loading-spinner loading-lg" }),
58
69
  /* @__PURE__ */ e("span", { className: "text-sm text-base-content/70", children: "Loading..." })
59
- ] }) }) : n === "expired" ? /* @__PURE__ */ e("div", { className: r, style: { width: a + (l ? 24 : 0), height: a + (l ? 24 : 0) }, "data-state": "expired", ...c, children: /* @__PURE__ */ y("div", { className: "flex flex-col items-center justify-center gap-2", children: [
70
+ ] }) }) : s === "expired" ? /* @__PURE__ */ e("div", { className: i, style: { width: t + (n ? 24 : 0), height: t + (n ? 24 : 0) }, "data-state": "expired", ...c, children: /* @__PURE__ */ p("div", { className: "flex flex-col items-center justify-center gap-2", children: [
60
71
  /* @__PURE__ */ e("svg", { className: "w-12 h-12 text-base-content/30", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ e(
61
72
  "path",
62
73
  {
@@ -66,12 +77,12 @@ const k = ({
66
77
  }
67
78
  ) }),
68
79
  /* @__PURE__ */ e("span", { className: "text-sm text-base-content/70", children: "QR Code Expired" }),
69
- p && /* @__PURE__ */ e("button", { className: "btn btn-sm btn-primary", onClick: p, children: "Refresh" })
70
- ] }) }) : h === "canvas" ? /* @__PURE__ */ e("div", { className: "inline-block", "data-state": "active", ...c, children: /* @__PURE__ */ e("div", { className: r, children: /* @__PURE__ */ e("canvas", { ref: s, style: { display: "block" } }) }) }) : /* @__PURE__ */ e("div", { className: "inline-block", "data-state": "active", ...c, children: /* @__PURE__ */ e("div", { className: r, children: /* @__PURE__ */ e("div", { style: { width: a, height: a }, className: "bg-base-content/5", children: /* @__PURE__ */ e("span", { className: "text-xs text-base-content/50", children: "SVG mode placeholder" }) }) }) });
80
+ N && /* @__PURE__ */ e("button", { className: "btn btn-sm btn-primary", onClick: N, children: "Refresh" })
81
+ ] }) }) : g === "canvas" ? /* @__PURE__ */ e("div", { className: "inline-block", "data-state": "active", ...c, children: /* @__PURE__ */ e("div", { className: i, children: /* @__PURE__ */ e("canvas", { ref: r, style: { display: "block" } }) }) }) : /* @__PURE__ */ e("div", { className: "inline-block", "data-state": "active", ...c, children: /* @__PURE__ */ e("div", { className: i, children: /* @__PURE__ */ e("div", { style: { width: t, height: t }, className: "bg-base-content/5", children: /* @__PURE__ */ e("span", { className: "text-xs text-base-content/50", children: "SVG mode placeholder" }) }) }) });
71
82
  };
72
- k.displayName = "QRCode";
83
+ F.displayName = "QRCode";
73
84
  export {
74
- k as QRCode,
75
- k as default
85
+ F as QRCode,
86
+ F as default
76
87
  };
77
88
  //# sourceMappingURL=QRCode.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"QRCode.js","sources":["../../src/components/QRCode.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react'\nimport QRCodeLib from 'qrcode'\n\nexport type QRCodeErrorLevel = 'L' | 'M' | 'Q' | 'H'\nexport type QRCodeType = 'canvas' | 'svg'\nexport type QRCodeStatus = 'active' | 'loading' | 'expired'\n\nexport interface QRCodeProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'color'> {\n value: string\n size?: number\n errorLevel?: QRCodeErrorLevel\n icon?: string\n iconSize?: number\n type?: QRCodeType\n color?: string\n bgColor?: string\n bordered?: boolean\n status?: QRCodeStatus\n onRefresh?: () => void\n}\n\nexport const QRCode: React.FC<QRCodeProps> = ({\n value,\n size = 160,\n errorLevel = 'M',\n icon,\n iconSize = 40,\n type = 'canvas',\n color = '#000000',\n bgColor = '#FFFFFF',\n bordered = true,\n status = 'active',\n onRefresh,\n className = '',\n ...rest\n}) => {\n const canvasRef = useRef<HTMLCanvasElement>(null)\n const [loading, setLoading] = useState(status === 'loading')\n\n useEffect(() => {\n setLoading(status === 'loading')\n }, [status])\n\n useEffect(() => {\n if (status !== 'active' || !value) return\n\n const generateQRCode = async () => {\n try {\n setLoading(true)\n\n if (type === 'canvas' && canvasRef.current) {\n await QRCodeLib.toCanvas(canvasRef.current, value, {\n width: size,\n margin: 1,\n color: {\n dark: color,\n light: bgColor,\n },\n errorCorrectionLevel: errorLevel,\n })\n\n if (icon) {\n const canvas = canvasRef.current\n const ctx = canvas.getContext('2d')\n if (ctx) {\n const img = new Image()\n img.crossOrigin = 'anonymous'\n img.onload = () => {\n const iconX = (size - iconSize) / 2\n const iconY = (size - iconSize) / 2\n ctx.fillStyle = bgColor\n ctx.fillRect(iconX - 4, iconY - 4, iconSize + 8, iconSize + 8)\n ctx.drawImage(img, iconX, iconY, iconSize, iconSize)\n }\n img.src = icon\n }\n }\n }\n\n setLoading(false)\n } catch (error) {\n console.error('QR Code generation error:', error)\n setLoading(false)\n }\n }\n\n generateQRCode()\n }, [value, size, errorLevel, icon, iconSize, type, color, bgColor, status])\n\n // Download functionality can be implemented by consumers\n // by accessing the canvas ref and converting to data URL\n\n const containerClasses = [\n 'inline-flex items-center justify-center',\n bordered && 'border border-base-content/20 p-3',\n 'bg-base-100',\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n if (status === 'loading' || loading) {\n return (\n <div className={containerClasses} style={{ width: size + (bordered ? 24 : 0), height: size + (bordered ? 24 : 0) }} data-state=\"loading\" {...rest}>\n <div className=\"flex flex-col items-center justify-center gap-2\">\n <span className=\"loading loading-spinner loading-lg\"></span>\n <span className=\"text-sm text-base-content/70\">Loading...</span>\n </div>\n </div>\n )\n }\n\n if (status === 'expired') {\n return (\n <div className={containerClasses} style={{ width: size + (bordered ? 24 : 0), height: size + (bordered ? 24 : 0) }} data-state=\"expired\" {...rest}>\n <div className=\"flex flex-col items-center justify-center gap-2\">\n <svg className=\"w-12 h-12 text-base-content/30\" fill=\"currentColor\" viewBox=\"0 0 20 20\">\n <path\n fillRule=\"evenodd\"\n d=\"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z\"\n clipRule=\"evenodd\"\n />\n </svg>\n <span className=\"text-sm text-base-content/70\">QR Code Expired</span>\n {onRefresh && (\n <button className=\"btn btn-sm btn-primary\" onClick={onRefresh}>\n Refresh\n </button>\n )}\n </div>\n </div>\n )\n }\n\n if (type === 'canvas') {\n return (\n <div className=\"inline-block\" data-state=\"active\" {...rest}>\n <div className={containerClasses}>\n <canvas ref={canvasRef} style={{ display: 'block' }} />\n </div>\n </div>\n )\n }\n\n return (\n <div className=\"inline-block\" data-state=\"active\" {...rest}>\n <div className={containerClasses}>\n <div style={{ width: size, height: size }} className=\"bg-base-content/5\">\n <span className=\"text-xs text-base-content/50\">SVG mode placeholder</span>\n </div>\n </div>\n </div>\n )\n}\n\nQRCode.displayName = 'QRCode'\n\nexport default QRCode\n"],"names":["QRCode","value","size","errorLevel","icon","iconSize","type","color","bgColor","bordered","status","onRefresh","className","rest","canvasRef","useRef","loading","setLoading","useState","useEffect","QRCodeLib","ctx","img","iconX","iconY","error","containerClasses","jsx","jsxs"],"mappings":";;;AAqBO,MAAMA,IAAgC,CAAC;AAAA,EAC5C,OAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,YAAAC,IAAa;AAAA,EACb,MAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,MAAAC,IAAO;AAAA,EACP,OAAAC,IAAQ;AAAA,EACR,SAAAC,IAAU;AAAA,EACV,UAAAC,IAAW;AAAA,EACX,QAAAC,IAAS;AAAA,EACT,WAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,GAAGC;AACL,MAAM;AACJ,QAAMC,IAAYC,EAA0B,IAAI,GAC1C,CAACC,GAASC,CAAU,IAAIC,EAASR,MAAW,SAAS;AAE3D,EA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AA,EAAI,WAAU,gBAAe,cAAW,UAAU,GAAGd,GACpD,UAAA,gBAAAc,EAAC,OAAA,EAAI,WAAWD,GACd,4BAAC,OAAA,EAAI,OAAO,EAAE,OAAOxB,GAAM,QAAQA,EAAA,GAAQ,WAAU,qBACnD,UAAA,gBAAAyB,EAAC,QAAA,EAAK,WAAU,gCAA+B,UAAA,uBAAA,CAAoB,EAAA,CACrE,GACF,GACF;AAEJ;AAEA3B,EAAO,cAAc;"}
1
+ {"version":3,"file":"QRCode.js","sources":["../../src/components/QRCode.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react'\n\nexport type QRCodeErrorLevel = 'L' | 'M' | 'Q' | 'H'\nexport type QRCodeType = 'canvas' | 'svg'\nexport type QRCodeStatus = 'active' | 'loading' | 'expired'\n\nexport interface QRCodeProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'color'> {\n value: string\n size?: number\n errorLevel?: QRCodeErrorLevel\n icon?: string\n iconSize?: number\n type?: QRCodeType\n color?: string\n bgColor?: string\n bordered?: boolean\n status?: QRCodeStatus\n onRefresh?: () => void\n}\n\nexport const QRCode: React.FC<QRCodeProps> = ({\n value,\n size = 160,\n errorLevel = 'M',\n icon,\n iconSize = 40,\n type = 'canvas',\n color = '#000000',\n bgColor = '#FFFFFF',\n bordered = true,\n status = 'active',\n onRefresh,\n className = '',\n ...rest\n}) => {\n const canvasRef = useRef<HTMLCanvasElement>(null)\n const [loading, setLoading] = useState(status === 'loading')\n const [missingDep, setMissingDep] = useState(false)\n\n useEffect(() => {\n setLoading(status === 'loading')\n }, [status])\n\n useEffect(() => {\n if (status !== 'active' || !value) return\n\n const generateQRCode = async () => {\n try {\n setLoading(true)\n\n // Dynamic import to gracefully handle missing dependency\n let QRCodeLib\n try {\n QRCodeLib = await import('qrcode')\n } catch {\n setMissingDep(true)\n setLoading(false)\n return\n }\n\n if (type === 'canvas' && canvasRef.current) {\n await QRCodeLib.toCanvas(canvasRef.current, value, {\n width: size,\n margin: 1,\n color: {\n dark: color,\n light: bgColor,\n },\n errorCorrectionLevel: errorLevel,\n })\n\n if (icon) {\n const canvas = canvasRef.current\n const ctx = canvas.getContext('2d')\n if (ctx) {\n const img = new Image()\n img.crossOrigin = 'anonymous'\n img.onload = () => {\n const iconX = (size - iconSize) / 2\n const iconY = (size - iconSize) / 2\n ctx.fillStyle = bgColor\n ctx.fillRect(iconX - 4, iconY - 4, iconSize + 8, iconSize + 8)\n ctx.drawImage(img, iconX, iconY, iconSize, iconSize)\n }\n img.src = icon\n }\n }\n }\n\n setLoading(false)\n } catch (error) {\n console.error('QR Code generation error:', error)\n setLoading(false)\n }\n }\n\n generateQRCode()\n }, [value, size, errorLevel, icon, iconSize, type, color, bgColor, status])\n\n // Download functionality can be implemented by consumers\n // by accessing the canvas ref and converting to data URL\n\n const containerClasses = [\n 'inline-flex items-center justify-center',\n bordered && 'border border-base-content/20 p-3',\n 'bg-base-100',\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n if (missingDep) {\n return (\n <div className={containerClasses} style={{ width: size + (bordered ? 24 : 0), height: size + (bordered ? 24 : 0) }} data-state=\"error\" {...rest}>\n <div className=\"flex flex-col items-center justify-center gap-2 p-4 text-center\">\n <svg className=\"w-8 h-8 text-warning\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z\" />\n </svg>\n <span className=\"text-sm text-base-content/70\">Missing dependency</span>\n <code className=\"text-xs bg-base-200 px-2 py-1 rounded\">npm install qrcode</code>\n </div>\n </div>\n )\n }\n\n if (status === 'loading' || loading) {\n return (\n <div className={containerClasses} style={{ width: size + (bordered ? 24 : 0), height: size + (bordered ? 24 : 0) }} data-state=\"loading\" {...rest}>\n <div className=\"flex flex-col items-center justify-center gap-2\">\n <span className=\"loading loading-spinner loading-lg\"></span>\n <span className=\"text-sm text-base-content/70\">Loading...</span>\n </div>\n </div>\n )\n }\n\n if (status === 'expired') {\n return (\n <div className={containerClasses} style={{ width: size + (bordered ? 24 : 0), height: size + (bordered ? 24 : 0) }} data-state=\"expired\" {...rest}>\n <div className=\"flex flex-col items-center justify-center gap-2\">\n <svg className=\"w-12 h-12 text-base-content/30\" fill=\"currentColor\" viewBox=\"0 0 20 20\">\n <path\n fillRule=\"evenodd\"\n d=\"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z\"\n clipRule=\"evenodd\"\n />\n </svg>\n <span className=\"text-sm text-base-content/70\">QR Code Expired</span>\n {onRefresh && (\n <button className=\"btn btn-sm btn-primary\" onClick={onRefresh}>\n Refresh\n </button>\n )}\n </div>\n </div>\n )\n }\n\n if (type === 'canvas') {\n return (\n <div className=\"inline-block\" data-state=\"active\" {...rest}>\n <div className={containerClasses}>\n <canvas ref={canvasRef} style={{ display: 'block' }} />\n </div>\n </div>\n )\n }\n\n return (\n <div className=\"inline-block\" data-state=\"active\" {...rest}>\n <div className={containerClasses}>\n <div style={{ width: size, height: size }} className=\"bg-base-content/5\">\n <span className=\"text-xs text-base-content/50\">SVG mode placeholder</span>\n </div>\n </div>\n </div>\n )\n}\n\nQRCode.displayName = 'QRCode'\n\nexport default QRCode\n"],"names":["QRCode","value","size","errorLevel","icon","iconSize","type","color","bgColor","bordered","status","onRefresh","className","rest","canvasRef","useRef","loading","setLoading","useState","missingDep","setMissingDep","useEffect","QRCodeLib","ctx","img","iconX","iconY","error","containerClasses","jsx","jsxs"],"mappings":";;AAoBO,MAAMA,IAAgC,CAAC;AAAA,EAC5C,OAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,YAAAC,IAAa;AAAA,EACb,MAAAC;AAAA,EACA,UAAAC,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A,gBAAA2B,EAAC,QAAA,EAAK,WAAU,gCAA+B,UAAA,uBAAA,CAAoB,EAAA,CACrE,GACF,GACF;AAEJ;AAEA7B,EAAO,cAAc;"}
@@ -21,13 +21,13 @@ const w = {
21
21
  evenly: "justify-evenly"
22
22
  }, E = ({
23
23
  direction: r = "horizontal",
24
- size: s = "md",
24
+ size: s = "sm",
25
25
  align: p,
26
26
  justify: a,
27
27
  wrap: u = !1,
28
28
  split: l,
29
- className: d = "",
30
- style: m,
29
+ className: m = "",
30
+ style: d,
31
31
  children: e,
32
32
  ...g
33
33
  }) => {
@@ -38,9 +38,9 @@ const w = {
38
38
  y,
39
39
  C,
40
40
  u ? "flex-wrap" : "",
41
- d
41
+ m
42
42
  ].filter(Boolean).join(" "), x = {
43
- ...m,
43
+ ...d,
44
44
  ...o ? { gap: `${s}px` } : {}
45
45
  };
46
46
  return /* @__PURE__ */ f("div", { className: j, style: x, ...g, children: (() => {
@@ -1 +1 @@
1
- {"version":3,"file":"Space.js","sources":["../../src/components/Space.tsx"],"sourcesContent":["import React from 'react'\n\nexport interface SpaceProps extends React.HTMLAttributes<HTMLDivElement> {\n direction?: 'horizontal' | 'vertical'\n size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | number\n align?: 'start' | 'end' | 'center' | 'baseline' | 'stretch'\n justify?: 'start' | 'end' | 'center' | 'between' | 'around' | 'evenly'\n wrap?: boolean\n split?: React.ReactNode\n children: React.ReactNode\n}\n\nconst gapClasses = {\n xs: 'gap-1',\n sm: 'gap-2',\n md: 'gap-4',\n lg: 'gap-6',\n xl: 'gap-8',\n} as const\n\nconst alignClasses = {\n start: 'items-start',\n end: 'items-end',\n center: 'items-center',\n baseline: 'items-baseline',\n stretch: 'items-stretch',\n} as const\n\nconst justifyClasses = {\n start: 'justify-start',\n end: 'justify-end',\n center: 'justify-center',\n between: 'justify-between',\n around: 'justify-around',\n evenly: 'justify-evenly',\n} as const\n\nexport const Space: React.FC<SpaceProps> = ({\n direction = 'horizontal',\n size = 'md',\n align,\n justify,\n wrap = false,\n split,\n className = '',\n style,\n children,\n ...rest\n}) => {\n const isNumericSize = typeof size === 'number'\n const gapClass = isNumericSize ? '' : gapClasses[size]\n const effectiveAlign = align ?? (direction === 'vertical' ? 'start' : undefined)\n const alignClass = effectiveAlign ? alignClasses[effectiveAlign] : ''\n const justifyClass = justify ? justifyClasses[justify] : ''\n const wrapClass = wrap ? 'flex-wrap' : ''\n const directionClass = direction === 'horizontal' ? 'flex-row' : 'flex-col'\n\n const classes = [\n 'flex',\n directionClass,\n gapClass,\n alignClass,\n justifyClass,\n wrapClass,\n className\n ].filter(Boolean).join(' ')\n\n const combinedStyle: React.CSSProperties = {\n ...style,\n ...(isNumericSize ? { gap: `${size}px` } : {}),\n }\n\n // If split is provided, interleave separator between children\n const renderChildren = () => {\n if (!split) return children\n\n const childArray = React.Children.toArray(children).filter(Boolean)\n if (childArray.length <= 1) return children\n\n const result: React.ReactNode[] = []\n childArray.forEach((child, index) => {\n result.push(child)\n if (index < childArray.length - 1) {\n result.push(\n <span key={`split-${index}`} className=\"flex-shrink-0\">\n {split}\n </span>\n )\n }\n })\n return result\n }\n\n return <div className={classes} style={combinedStyle} {...rest}>{renderChildren()}</div>\n}\n"],"names":["gapClasses","alignClasses","justifyClasses","Space","direction","size","align","justify","wrap","split","className","style","children","rest","isNumericSize","gapClass","effectiveAlign","alignClass","justifyClass","classes","combinedStyle","jsx","childArray","React","result","child","index"],"mappings":";;AAYA,MAAMA,IAAa;AAAA,EACjB,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN,GAEMC,IAAe;AAAA,EACnB,OAAO;AAAA,EACP,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,SAAS;AACX,GAEMC,IAAiB;AAAA,EACrB,OAAO;AAAA,EACP,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,QAAQ;AAA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ACMF;AAAA,EACT,GAEiE,EAAe,CAAE;AACpF;"}
1
+ {"version":3,"file":"Space.js","sources":["../../src/components/Space.tsx"],"sourcesContent":["import React from 'react'\n\nexport interface SpaceProps extends React.HTMLAttributes<HTMLDivElement> {\n direction?: 'horizontal' | 'vertical'\n size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | number\n align?: 'start' | 'end' | 'center' | 'baseline' | 'stretch'\n justify?: 'start' | 'end' | 'center' | 'between' | 'around' | 'evenly'\n wrap?: boolean\n split?: React.ReactNode\n children: React.ReactNode\n}\n\nconst gapClasses = {\n xs: 'gap-1',\n sm: 'gap-2',\n md: 'gap-4',\n lg: 'gap-6',\n xl: 'gap-8',\n} as const\n\nconst alignClasses = {\n start: 'items-start',\n end: 'items-end',\n center: 'items-center',\n baseline: 'items-baseline',\n stretch: 'items-stretch',\n} as const\n\nconst justifyClasses = {\n start: 'justify-start',\n end: 'justify-end',\n center: 'justify-center',\n between: 'justify-between',\n around: 'justify-around',\n evenly: 'justify-evenly',\n} as const\n\nexport const Space: React.FC<SpaceProps> = ({\n direction = 'horizontal',\n size = 'sm',\n align,\n justify,\n wrap = false,\n split,\n className = '',\n style,\n children,\n ...rest\n}) => {\n const isNumericSize = typeof size === 'number'\n const gapClass = isNumericSize ? '' : gapClasses[size]\n const effectiveAlign = align ?? (direction === 'vertical' ? 'start' : undefined)\n const alignClass = effectiveAlign ? alignClasses[effectiveAlign] : ''\n const justifyClass = justify ? justifyClasses[justify] : ''\n const wrapClass = wrap ? 'flex-wrap' : ''\n const directionClass = direction === 'horizontal' ? 'flex-row' : 'flex-col'\n\n const classes = [\n 'flex',\n directionClass,\n gapClass,\n alignClass,\n justifyClass,\n wrapClass,\n className\n ].filter(Boolean).join(' ')\n\n const combinedStyle: React.CSSProperties = {\n ...style,\n ...(isNumericSize ? { gap: `${size}px` } : {}),\n }\n\n // If split is provided, interleave separator between children\n const renderChildren = () => {\n if (!split) return children\n\n const childArray = React.Children.toArray(children).filter(Boolean)\n if (childArray.length <= 1) return children\n\n const result: React.ReactNode[] = []\n childArray.forEach((child, index) => {\n result.push(child)\n if (index < childArray.length - 1) {\n result.push(\n <span key={`split-${index}`} className=\"flex-shrink-0\">\n {split}\n </span>\n )\n }\n })\n return result\n }\n\n return <div className={classes} style={combinedStyle} {...rest}>{renderChildren()}</div>\n}\n"],"names":["gapClasses","alignClasses","justifyClasses","Space","direction","size","align","justify","wrap","split","className","style","children","rest","isNumericSize","gapClass","effectiveAlign","alignClass","justifyClass","classes","combinedStyle","jsx","childArray","React","result","child","index"],"mappings":";;AAYA,MAAMA,IAAa;AAAA,EACjB,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN,GAEMC,IAAe;AAAA,EACnB,OAAO;AAAA,EACP,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,SAAS;AACX,GAEMC,IAAiB;AAAA,EACrB,OAAO;AAAA,EACP,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AACV,GAEaC,IAA8B,CAAC;AAAA,EAC1C,WAAAC,IAAY;AAAA,EACZ,MAAAC,IAAO;AAAA,EACP,OAAAC;AAAA,EACA,SAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,OAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,GAAGC;AACL,MAAM;AACJ,QAAMC,IAAgB,OAAOT,KAAS,UAChCU,IAAWD,IAAgB,KAAKd,EAAWK,CAAI,GAC/CW,IAAiBV,MAAUF,MAAc,aAAa,UAAU,SAChEa,IAAaD,IAAiBf,EAAae,CAAc,IAAI,IAC7DE,IAAeX,IAAUL,EAAeK,CAAO,IAAI,IAInDY,IAAU;AAAA,IACd;AAAA,IAHqBf,MAAc,eAAe,aAAa;AAAA,IAK/DW;AAAA,IACAE;AAAA,IACAC;AAAA,IARgBV,IAAO,cAAc;AAAA,IAUrCE;AAAA,EAAA,EACA,OAAO,OAAO,EAAE,KAAK,GAAG,GAEpBU,IAAqC;AAAA,IACzC,GAAGT;AAAA,IACH,GAAIG,IAAgB,EAAE,KAAK,GAAGT,CAAI,SAAS,CAAA;AAAA,EAAC;AAwB9C,SAAO,gBAAAgB,EAAC,SAAI,WAAWF,GAAS,OAAOC,GAAgB,GAAGP,GAAO,WApB1C,MAAM;AAC3B,QAAI,CAACJ,EAAO,QAAOG;AAEnB,UAAMU,IAAaC,EAAM,SAAS,QAAQX,CAAQ,EAAE,OAAO,OAAO;AAClE,QAAIU,EAAW,UAAU,EAAG,QAAOV;AAEnC,UAAMY,IAA4B,CAAA;AAClC,WAAAF,EAAW,QAAQ,CAACG,GAAOC,MAAU;AACnC,MAAAF,EAAO,KAAKC,CAAK,GACbC,IAAQJ,EAAW,SAAS,KAC9BE,EAAO;AAAA,0BACJ,QAAA,EAA4B,WAAU,iBACpC,UAAAf,KADQ,SAASiB,CAAK,EAEzB;AAAA,MAAA;AAAA,IAGN,CAAC,GACMF;AAAA,EACT,GAEiE,EAAe,CAAE;AACpF;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asterui",
3
- "version": "0.12.33",
3
+ "version": "0.12.35",
4
4
  "description": "React UI component library with DaisyUI",
5
5
  "homepage": "https://asterui.com",
6
6
  "repository": {