asterui 0.12.61 → 0.12.63
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/Affix.d.ts +2 -0
- package/dist/components/Affix.js.map +1 -1
- package/dist/components/Alert.d.ts +2 -0
- package/dist/components/Alert.js.map +1 -1
- package/dist/components/Anchor.d.ts +2 -0
- package/dist/components/Anchor.js +79 -75
- package/dist/components/Anchor.js.map +1 -1
- package/dist/components/Autocomplete.d.ts +1 -0
- package/dist/components/Autocomplete.js +115 -110
- package/dist/components/Autocomplete.js.map +1 -1
- package/dist/components/Avatar.d.ts +4 -0
- package/dist/components/Avatar.js.map +1 -1
- package/dist/components/Breadcrumb.d.ts +4 -2
- package/dist/components/Breadcrumb.js +54 -29
- package/dist/components/Breadcrumb.js.map +1 -1
- package/dist/components/Browser.d.ts +2 -0
- package/dist/components/Browser.js.map +1 -1
- package/dist/components/Button.d.ts +5 -1
- package/dist/components/Button.js +117 -107
- package/dist/components/Button.js.map +1 -1
- package/dist/components/Chart.d.ts +1 -0
- package/dist/components/Chart.js +31 -30
- package/dist/components/Chart.js.map +1 -1
- package/dist/components/Chat.d.ts +1 -0
- package/dist/components/Chat.js +39 -28
- package/dist/components/Chat.js.map +1 -1
- package/dist/components/Code.d.ts +2 -0
- package/dist/components/Code.js.map +1 -1
- package/dist/components/Command.d.ts +5 -2
- package/dist/components/Command.js +262 -233
- package/dist/components/Command.js.map +1 -1
- package/dist/components/Container.d.ts +2 -0
- package/dist/components/Container.js.map +1 -1
- package/dist/components/ContextMenu.d.ts +4 -0
- package/dist/components/ContextMenu.js +157 -122
- package/dist/components/ContextMenu.js.map +1 -1
- package/dist/components/CopyButton.d.ts +2 -0
- package/dist/components/CopyButton.js +9 -8
- package/dist/components/CopyButton.js.map +1 -1
- package/dist/components/Countdown.d.ts +3 -3
- package/dist/components/Countdown.js +49 -47
- package/dist/components/Countdown.js.map +1 -1
- package/dist/components/Diff.d.ts +3 -3
- package/dist/components/Diff.js +14 -10
- package/dist/components/Diff.js.map +1 -1
- package/dist/components/Divider.d.ts +2 -0
- package/dist/components/Divider.js.map +1 -1
- package/dist/components/Dock.d.ts +6 -0
- package/dist/components/Dock.js +75 -38
- package/dist/components/Dock.js.map +1 -1
- package/dist/components/Dropdown.js +110 -110
- package/dist/components/Dropdown.js.map +1 -1
- package/dist/components/Fieldset.d.ts +2 -0
- package/dist/components/Fieldset.js.map +1 -1
- package/dist/components/FileInput.d.ts +1 -0
- package/dist/components/FileInput.js +26 -26
- package/dist/components/FileInput.js.map +1 -1
- package/dist/components/Filter.d.ts +1 -0
- package/dist/components/Filter.js +43 -40
- package/dist/components/Filter.js.map +1 -1
- package/dist/components/Flex.d.ts +1 -0
- package/dist/components/Flex.js +43 -42
- package/dist/components/Flex.js.map +1 -1
- package/dist/components/FloatButton.d.ts +9 -0
- package/dist/components/FloatButton.js +211 -136
- package/dist/components/FloatButton.js.map +1 -1
- package/dist/components/Footer.d.ts +2 -0
- package/dist/components/Footer.js.map +1 -1
- package/dist/components/Grid.d.ts +4 -0
- package/dist/components/Grid.js.map +1 -1
- package/dist/components/Hero.d.ts +2 -0
- package/dist/components/Hero.js.map +1 -1
- package/dist/components/HoverGallery.d.ts +3 -3
- package/dist/components/HoverGallery.js +12 -10
- package/dist/components/HoverGallery.js.map +1 -1
- package/dist/components/Input.d.ts +1 -0
- package/dist/components/Input.js +201 -184
- package/dist/components/Input.js.map +1 -1
- package/dist/components/Join.d.ts +2 -0
- package/dist/components/Join.js.map +1 -1
- package/dist/components/Kbd.d.ts +2 -0
- package/dist/components/Kbd.js.map +1 -1
- package/dist/components/Loading.d.ts +3 -0
- package/dist/components/Loading.js +58 -35
- package/dist/components/Loading.js.map +1 -1
- package/dist/components/Mask.d.ts +2 -2
- package/dist/components/Mask.js.map +1 -1
- package/dist/components/Masonry.d.ts +1 -0
- package/dist/components/Masonry.js +45 -42
- package/dist/components/Masonry.js.map +1 -1
- package/dist/components/Mention.d.ts +1 -0
- package/dist/components/Mention.js +95 -91
- package/dist/components/Mention.js.map +1 -1
- package/dist/components/MonthCalendar.d.ts +1 -0
- package/dist/components/MonthCalendar.js +104 -97
- package/dist/components/MonthCalendar.js.map +1 -1
- package/dist/components/Navbar.d.ts +2 -0
- package/dist/components/Navbar.js.map +1 -1
- package/dist/components/Notification.js +32 -18
- package/dist/components/Notification.js.map +1 -1
- package/dist/components/Phone.d.ts +3 -2
- package/dist/components/Phone.js +10 -8
- package/dist/components/Phone.js.map +1 -1
- package/dist/components/Popconfirm.js +110 -92
- package/dist/components/Popconfirm.js.map +1 -1
- package/dist/components/Popover.d.ts +2 -0
- package/dist/components/Popover.js.map +1 -1
- package/dist/components/Progress.d.ts +2 -0
- package/dist/components/Progress.js.map +1 -1
- package/dist/components/QRCode.d.ts +1 -0
- package/dist/components/QRCode.js +84 -55
- package/dist/components/QRCode.js.map +1 -1
- package/dist/components/RadialProgress.d.ts +1 -0
- package/dist/components/RadialProgress.js +19 -17
- package/dist/components/RadialProgress.js.map +1 -1
- package/dist/components/Radio.d.ts +6 -3
- package/dist/components/Radio.js +9 -9
- package/dist/components/Radio.js.map +1 -1
- package/dist/components/Range.d.ts +1 -0
- package/dist/components/Range.js +45 -43
- package/dist/components/Range.js.map +1 -1
- package/dist/components/Rating.d.ts +4 -2
- package/dist/components/Rating.js +83 -79
- package/dist/components/Rating.js.map +1 -1
- package/dist/components/Responsive.d.ts +4 -2
- package/dist/components/Responsive.js +10 -9
- package/dist/components/Responsive.js.map +1 -1
- package/dist/components/Result.d.ts +1 -0
- package/dist/components/Result.js +24 -22
- package/dist/components/Result.js.map +1 -1
- package/dist/components/Select.d.ts +1 -0
- package/dist/components/Select.js +72 -62
- package/dist/components/Select.js.map +1 -1
- package/dist/components/Skeleton.d.ts +2 -0
- package/dist/components/Skeleton.js.map +1 -1
- package/dist/components/Space.d.ts +2 -0
- package/dist/components/Space.js.map +1 -1
- package/dist/components/Splitter.d.ts +2 -0
- package/dist/components/Splitter.js +137 -131
- package/dist/components/Splitter.js.map +1 -1
- package/dist/components/Stat.d.ts +4 -2
- package/dist/components/Stat.js +19 -18
- package/dist/components/Stat.js.map +1 -1
- package/dist/components/Status.d.ts +3 -3
- package/dist/components/Status.js +27 -25
- package/dist/components/Status.js.map +1 -1
- package/dist/components/Steps.d.ts +4 -2
- package/dist/components/Steps.js +56 -52
- package/dist/components/Steps.js.map +1 -1
- package/dist/components/TextRotate.d.ts +1 -0
- package/dist/components/TextRotate.js +14 -12
- package/dist/components/TextRotate.js.map +1 -1
- package/dist/components/Textarea.d.ts +1 -0
- package/dist/components/Textarea.js +31 -30
- package/dist/components/Textarea.js.map +1 -1
- package/dist/components/ThemeController.d.ts +6 -3
- package/dist/components/ThemeController.js +101 -92
- package/dist/components/ThemeController.js.map +1 -1
- package/dist/components/Toggle.d.ts +2 -0
- package/dist/components/Toggle.js.map +1 -1
- package/dist/components/Tooltip.d.ts +2 -0
- package/dist/components/Tooltip.js +38 -32
- package/dist/components/Tooltip.js.map +1 -1
- package/dist/components/Typography.d.ts +10 -5
- package/dist/components/Typography.js +84 -81
- package/dist/components/Typography.js.map +1 -1
- package/dist/components/VirtualList.d.ts +2 -1
- package/dist/components/VirtualList.js +40 -36
- package/dist/components/VirtualList.js.map +1 -1
- package/dist/components/Watermark.d.ts +1 -0
- package/dist/components/Watermark.js +74 -71
- package/dist/components/Watermark.js.map +1 -1
- package/dist/components/WeekCalendar.d.ts +1 -0
- package/dist/components/WeekCalendar.js +91 -76
- package/dist/components/WeekCalendar.js.map +1 -1
- package/dist/components/Window.d.ts +3 -2
- package/dist/components/Window.js +9 -7
- package/dist/components/Window.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Browser.js","sources":["../../src/components/Browser.tsx"],"sourcesContent":["import React from 'react'\n\n// DaisyUI classes\nconst dMockupBrowser = 'mockup-browser'\nconst dMockupBrowserToolbar = 'mockup-browser-toolbar'\n\nexport interface BrowserProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode\n url?: string\n contentClassName?: string\n}\n\nexport const Browser: React.FC<BrowserProps> = ({\n children,\n url = 'https://example.com',\n className = '',\n contentClassName = '',\n ...rest\n}) => {\n return (\n <div className={`${dMockupBrowser} border border-base-300 ${className}`} {...rest}>\n <div className={dMockupBrowserToolbar}>\n <div className=\"input\">{url}</div>\n </div>\n <div className={`border-t border-base-300 ${contentClassName}`}>\n {children}\n </div>\n </div>\n )\n}\n"],"names":["dMockupBrowser","dMockupBrowserToolbar","Browser","children","url","className","contentClassName","rest","jsxs","jsx"],"mappings":";AAGA,MAAMA,IAAiB,kBACjBC,IAAwB,
|
|
1
|
+
{"version":3,"file":"Browser.js","sources":["../../src/components/Browser.tsx"],"sourcesContent":["import React from 'react'\n\n// DaisyUI classes\nconst dMockupBrowser = 'mockup-browser'\nconst dMockupBrowserToolbar = 'mockup-browser-toolbar'\n\nexport interface BrowserProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode\n url?: string\n contentClassName?: string\n /** Test ID for testing */\n 'data-testid'?: string\n}\n\nexport const Browser: React.FC<BrowserProps> = ({\n children,\n url = 'https://example.com',\n className = '',\n contentClassName = '',\n ...rest\n}) => {\n return (\n <div className={`${dMockupBrowser} border border-base-300 ${className}`} {...rest}>\n <div className={dMockupBrowserToolbar}>\n <div className=\"input\">{url}</div>\n </div>\n <div className={`border-t border-base-300 ${contentClassName}`}>\n {children}\n </div>\n </div>\n )\n}\n"],"names":["dMockupBrowser","dMockupBrowserToolbar","Browser","children","url","className","contentClassName","rest","jsxs","jsx"],"mappings":";AAGA,MAAMA,IAAiB,kBACjBC,IAAwB,0BAUjBC,IAAkC,CAAC;AAAA,EAC9C,UAAAC;AAAA,EACA,KAAAC,IAAM;AAAA,EACN,WAAAC,IAAY;AAAA,EACZ,kBAAAC,IAAmB;AAAA,EACnB,GAAGC;AACL,MAEI,gBAAAC,EAAC,SAAI,WAAW,GAAGR,CAAc,2BAA2BK,CAAS,IAAK,GAAGE,GAC3E,UAAA;AAAA,EAAA,gBAAAE,EAAC,OAAA,EAAI,WAAWR,GACd,UAAA,gBAAAQ,EAAC,SAAI,WAAU,SAAS,aAAI,EAAA,CAC9B;AAAA,oBACC,OAAA,EAAI,WAAW,4BAA4BH,CAAgB,IACzD,UAAAH,EAAA,CACH;AAAA,GACF;"}
|
|
@@ -17,11 +17,15 @@ type BaseButtonProps = {
|
|
|
17
17
|
/** Icon element to display */
|
|
18
18
|
icon?: React.ReactNode;
|
|
19
19
|
/** Position of the icon */
|
|
20
|
+
iconPlacement?: 'start' | 'end';
|
|
21
|
+
/** @deprecated Use iconPlacement instead */
|
|
20
22
|
iconPosition?: 'start' | 'end';
|
|
21
23
|
/** Applies error/danger styling (shorthand for color="error") */
|
|
22
24
|
danger?: boolean;
|
|
23
25
|
/** Toggle button pressed state (sets aria-pressed) */
|
|
24
26
|
pressed?: boolean;
|
|
27
|
+
/** Test ID for testing */
|
|
28
|
+
'data-testid'?: string;
|
|
25
29
|
};
|
|
26
30
|
type ButtonAsButton = BaseButtonProps & Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'type'> & {
|
|
27
31
|
href?: undefined;
|
|
@@ -34,5 +38,5 @@ type ButtonAsAnchor = BaseButtonProps & Omit<React.AnchorHTMLAttributes<HTMLAnch
|
|
|
34
38
|
disabled?: boolean;
|
|
35
39
|
};
|
|
36
40
|
export type ButtonProps = ButtonAsButton | ButtonAsAnchor;
|
|
37
|
-
export declare const Button: React.
|
|
41
|
+
export declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLAnchorElement | HTMLButtonElement>>;
|
|
38
42
|
export {};
|
|
@@ -1,114 +1,124 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
1
|
+
import { jsx as o, jsxs as W, Fragment as X } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as F } from "react";
|
|
3
|
+
import { SizeProvider as G } from "../contexts/SizeContext.js";
|
|
4
|
+
import { useConfig as M } from "../providers/ConfigProvider.js";
|
|
5
|
+
const O = "btn", R = "btn-primary", H = "btn-secondary", J = "btn-accent", Q = "btn-info", U = "btn-success", V = "btn-warning", Y = "btn-error", Z = "btn-neutral", _ = "btn-outline", tt = "btn-dash", nt = "btn-soft", st = "btn-ghost", et = "btn-link", ot = "btn-xs", ct = "btn-sm", rt = "btn-md", at = "btn-lg", it = "btn-xl", dt = "btn-active", lt = "btn-square", mt = "btn-circle", bt = "btn-wide", ut = "btn-block", ft = "loading", Bt = "loading-spinner", ht = F(
|
|
6
|
+
({
|
|
7
|
+
children: c,
|
|
8
|
+
color: g,
|
|
9
|
+
variant: d,
|
|
10
|
+
size: C,
|
|
11
|
+
active: k = !1,
|
|
12
|
+
loading: t = !1,
|
|
13
|
+
shape: l,
|
|
14
|
+
noAnimation: S = !1,
|
|
15
|
+
icon: r,
|
|
16
|
+
iconPlacement: x,
|
|
17
|
+
iconPosition: v,
|
|
18
|
+
danger: w = !1,
|
|
19
|
+
pressed: m,
|
|
20
|
+
className: D = "",
|
|
21
|
+
"data-testid": b,
|
|
22
|
+
...a
|
|
23
|
+
}, u) => {
|
|
24
|
+
const { componentSize: z } = M(), i = C ?? z ?? "md", f = w ? "error" : g, n = x ?? v ?? "start", N = {
|
|
25
|
+
primary: R,
|
|
26
|
+
secondary: H,
|
|
27
|
+
accent: J,
|
|
28
|
+
info: Q,
|
|
29
|
+
success: U,
|
|
30
|
+
warning: V,
|
|
31
|
+
error: Y,
|
|
32
|
+
neutral: Z
|
|
33
|
+
}, P = {
|
|
34
|
+
solid: "",
|
|
35
|
+
// default, no extra class needed
|
|
36
|
+
outline: _,
|
|
37
|
+
dash: tt,
|
|
38
|
+
soft: nt,
|
|
39
|
+
ghost: st,
|
|
40
|
+
link: et
|
|
41
|
+
}, K = {
|
|
42
|
+
xs: ot,
|
|
43
|
+
sm: ct,
|
|
44
|
+
md: rt,
|
|
45
|
+
lg: at,
|
|
46
|
+
xl: it
|
|
47
|
+
}, L = {
|
|
48
|
+
square: lt,
|
|
49
|
+
circle: mt,
|
|
50
|
+
wide: bt,
|
|
51
|
+
block: ut,
|
|
52
|
+
round: "rounded-full"
|
|
53
|
+
}, B = [
|
|
54
|
+
O,
|
|
55
|
+
f && N[f],
|
|
56
|
+
d && P[d],
|
|
57
|
+
K[i],
|
|
58
|
+
k && dt,
|
|
59
|
+
l && L[l],
|
|
60
|
+
S && "no-animation",
|
|
61
|
+
D
|
|
62
|
+
].filter(Boolean).join(" "), T = c != null && c !== "" ? {
|
|
63
|
+
xs: n === "start" ? "mr-1" : "ml-1",
|
|
64
|
+
sm: n === "start" ? "mr-1" : "ml-1",
|
|
65
|
+
md: n === "start" ? "mr-1.5" : "ml-1.5",
|
|
66
|
+
lg: n === "start" ? "mr-2" : "ml-2",
|
|
67
|
+
xl: n === "start" ? "mr-2" : "ml-2"
|
|
68
|
+
}[i] : "", h = r && /* @__PURE__ */ o(G, { size: i, children: /* @__PURE__ */ o("span", { className: `inline-flex items-center ${T}`, "aria-hidden": "true", children: r }) }), y = /* @__PURE__ */ W(X, { children: [
|
|
69
|
+
t && /* @__PURE__ */ o("span", { className: `${ft} ${Bt}`, "aria-hidden": "true" }),
|
|
70
|
+
!t && r && n === "start" && h,
|
|
71
|
+
c,
|
|
72
|
+
!t && r && n === "end" && h
|
|
73
|
+
] });
|
|
74
|
+
if ("href" in a && a.href !== void 0) {
|
|
75
|
+
const { href: q, disabled: $, onKeyDown: A, onClick: E, ...I } = a, e = $ || t;
|
|
76
|
+
return /* @__PURE__ */ o(
|
|
77
|
+
"a",
|
|
78
|
+
{
|
|
79
|
+
ref: u,
|
|
80
|
+
href: e ? void 0 : q,
|
|
81
|
+
role: "button",
|
|
82
|
+
className: B,
|
|
83
|
+
"aria-disabled": e || void 0,
|
|
84
|
+
"aria-busy": t || void 0,
|
|
85
|
+
"aria-pressed": m,
|
|
86
|
+
tabIndex: e ? -1 : 0,
|
|
87
|
+
onKeyDown: (s) => {
|
|
88
|
+
s.key === " " && !e && (s.preventDefault(), s.currentTarget.click()), A?.(s);
|
|
89
|
+
},
|
|
90
|
+
onClick: (s) => {
|
|
91
|
+
if (e) {
|
|
92
|
+
s.preventDefault();
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
E?.(s);
|
|
96
|
+
},
|
|
97
|
+
"data-testid": b,
|
|
98
|
+
...I,
|
|
99
|
+
children: y
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
const { htmlType: j, ...p } = a;
|
|
104
|
+
return /* @__PURE__ */ o(
|
|
105
|
+
"button",
|
|
74
106
|
{
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
className:
|
|
78
|
-
"aria-
|
|
79
|
-
"aria-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
},
|
|
85
|
-
onClick: (s) => {
|
|
86
|
-
if (e) {
|
|
87
|
-
s.preventDefault();
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
q?.(s);
|
|
91
|
-
},
|
|
92
|
-
...$,
|
|
93
|
-
children: B
|
|
107
|
+
ref: u,
|
|
108
|
+
type: j ?? "button",
|
|
109
|
+
className: B,
|
|
110
|
+
"aria-busy": t || void 0,
|
|
111
|
+
"aria-pressed": m,
|
|
112
|
+
disabled: t || p.disabled,
|
|
113
|
+
"data-testid": b,
|
|
114
|
+
...p,
|
|
115
|
+
children: y
|
|
94
116
|
}
|
|
95
117
|
);
|
|
96
118
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
"button",
|
|
100
|
-
{
|
|
101
|
-
type: K ?? "button",
|
|
102
|
-
className: u,
|
|
103
|
-
"aria-busy": n || void 0,
|
|
104
|
-
"aria-pressed": b,
|
|
105
|
-
disabled: n || h.disabled,
|
|
106
|
-
...h,
|
|
107
|
-
children: B
|
|
108
|
-
}
|
|
109
|
-
);
|
|
110
|
-
};
|
|
119
|
+
);
|
|
120
|
+
ht.displayName = "Button";
|
|
111
121
|
export {
|
|
112
|
-
|
|
122
|
+
ht as Button
|
|
113
123
|
};
|
|
114
124
|
//# sourceMappingURL=Button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sources":["../../src/components/Button.tsx"],"sourcesContent":["import React from 'react'\nimport { SizeProvider } from '../contexts/SizeContext'\nimport { useConfig } from '../providers/ConfigProvider'\n\n// DaisyUI classes\nconst dBtn = 'btn'\nconst dBtnPrimary = 'btn-primary'\nconst dBtnSecondary = 'btn-secondary'\nconst dBtnAccent = 'btn-accent'\nconst dBtnInfo = 'btn-info'\nconst dBtnSuccess = 'btn-success'\nconst dBtnWarning = 'btn-warning'\nconst dBtnError = 'btn-error'\nconst dBtnNeutral = 'btn-neutral'\nconst dBtnOutline = 'btn-outline'\nconst dBtnDash = 'btn-dash'\nconst dBtnSoft = 'btn-soft'\nconst dBtnGhost = 'btn-ghost'\nconst dBtnLink = 'btn-link'\nconst dBtnXs = 'btn-xs'\nconst dBtnSm = 'btn-sm'\nconst dBtnLg = 'btn-lg'\nconst dBtnXl = 'btn-xl'\nconst dBtnActive = 'btn-active'\nconst dBtnSquare = 'btn-square'\nconst dBtnCircle = 'btn-circle'\nconst dBtnWide = 'btn-wide'\nconst dBtnBlock = 'btn-block'\nconst dLoading = 'loading'\nconst dLoadingSpinner = 'loading-spinner'\n\ntype BaseButtonProps = {\n /** Button color */\n color?: 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'error' | 'neutral'\n /** Button style variant */\n variant?: 'solid' | 'outline' | 'dash' | 'soft' | 'ghost' | 'link'\n /** Button size */\n size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'\n /** Active/pressed visual state */\n active?: boolean\n /** Show loading spinner and disable button */\n loading?: boolean\n /** Button shape */\n shape?: 'square' | 'circle' | 'wide' | 'block' | 'round'\n /** Disable click animation */\n noAnimation?: boolean\n /** Icon element to display */\n icon?: React.ReactNode\n /** Position of the icon */\n iconPosition?: 'start' | 'end'\n /** Applies error/danger styling (shorthand for color=\"error\") */\n danger?: boolean\n /** Toggle button pressed state (sets aria-pressed) */\n pressed?: boolean\n}\n\ntype ButtonAsButton = BaseButtonProps &\n Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'type'> & {\n href?: undefined\n htmlType?: 'button' | 'submit' | 'reset'\n }\n\ntype ButtonAsAnchor = BaseButtonProps &\n Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'type'> & {\n href: string\n htmlType?: undefined\n /** Disable the link button */\n disabled?: boolean\n }\n\nexport type ButtonProps = ButtonAsButton | ButtonAsAnchor\n\nexport const Button: React.FC<ButtonProps> = ({\n children,\n color,\n variant,\n size,\n active = false,\n loading = false,\n shape,\n noAnimation = false,\n icon,\n iconPosition = 'start',\n danger = false,\n pressed,\n className = '',\n ...props\n}) => {\n const { componentSize } = useConfig()\n const effectiveSize = size ?? componentSize ?? 'md'\n // danger prop is a shorthand for color=\"error\"\n const effectiveColor = danger ? 'error' : color\n\n const colorClasses = {\n primary: dBtnPrimary,\n secondary: dBtnSecondary,\n accent: dBtnAccent,\n info: dBtnInfo,\n success: dBtnSuccess,\n warning: dBtnWarning,\n error: dBtnError,\n neutral: dBtnNeutral,\n }\n\n const variantClasses = {\n solid: '', // default, no extra class needed\n outline: dBtnOutline,\n dash: dBtnDash,\n soft: dBtnSoft,\n ghost: dBtnGhost,\n link: dBtnLink,\n }\n\n const sizeClasses = {\n xs: dBtnXs,\n sm: dBtnSm,\n md: '',\n lg: dBtnLg,\n xl: dBtnXl,\n }\n\n const shapeClasses = {\n square: dBtnSquare,\n circle: dBtnCircle,\n wide: dBtnWide,\n block: dBtnBlock,\n round: 'rounded-full',\n }\n\n const classes = [\n dBtn,\n effectiveColor && colorClasses[effectiveColor],\n variant && variantClasses[variant],\n sizeClasses[effectiveSize],\n active && dBtnActive,\n shape && shapeClasses[shape],\n noAnimation && 'no-animation',\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n // Determine icon spacing based on whether there's text content and button size\n const hasChildren = children !== undefined && children !== null && children !== ''\n const spacingBySize = {\n xs: iconPosition === 'start' ? 'mr-1' : 'ml-1',\n sm: iconPosition === 'start' ? 'mr-1' : 'ml-1',\n md: iconPosition === 'start' ? 'mr-1.5' : 'ml-1.5',\n lg: iconPosition === 'start' ? 'mr-2' : 'ml-2',\n xl: iconPosition === 'start' ? 'mr-2' : 'ml-2',\n }\n const iconSpacing = hasChildren ? spacingBySize[effectiveSize] : ''\n\n const iconElement = icon && (\n <SizeProvider size={effectiveSize}>\n <span className={`inline-flex items-center ${iconSpacing}`} aria-hidden=\"true\">\n {icon}\n </span>\n </SizeProvider>\n )\n\n const content = (\n <>\n {loading && <span className={`${dLoading} ${dLoadingSpinner}`} aria-hidden=\"true\"></span>}\n {!loading && icon && iconPosition === 'start' && iconElement}\n {children}\n {!loading && icon && iconPosition === 'end' && iconElement}\n </>\n )\n\n if ('href' in props && props.href !== undefined) {\n const { href, disabled, onKeyDown, onClick, ...anchorProps } = props as ButtonAsAnchor & {\n onKeyDown?: React.KeyboardEventHandler<HTMLAnchorElement>\n onClick?: React.MouseEventHandler<HTMLAnchorElement>\n }\n const isDisabled = disabled || loading\n\n // Handle Space key for anchor buttons (links only respond to Enter natively)\n const handleKeyDown = (event: React.KeyboardEvent<HTMLAnchorElement>) => {\n if (event.key === ' ' && !isDisabled) {\n event.preventDefault()\n event.currentTarget.click()\n }\n onKeyDown?.(event)\n }\n\n // Prevent click when disabled\n const handleClick = (event: React.MouseEvent<HTMLAnchorElement>) => {\n if (isDisabled) {\n event.preventDefault()\n return\n }\n onClick?.(event)\n }\n\n return (\n <a\n href={isDisabled ? undefined : href}\n role=\"button\"\n className={classes}\n aria-disabled={isDisabled || undefined}\n aria-busy={loading || undefined}\n aria-pressed={pressed}\n tabIndex={isDisabled ? -1 : 0}\n onKeyDown={handleKeyDown}\n onClick={handleClick}\n {...anchorProps}\n >\n {content}\n </a>\n )\n }\n\n const { htmlType, ...buttonProps } = props as Omit<ButtonAsButton, keyof BaseButtonProps>\n const buttonType: 'button' | 'submit' | 'reset' = htmlType ?? 'button'\n return (\n <button\n type={buttonType}\n className={classes}\n aria-busy={loading || undefined}\n aria-pressed={pressed}\n disabled={loading || buttonProps.disabled}\n {...buttonProps}\n >\n {content}\n </button>\n )\n}\n"],"names":["dBtn","dBtnPrimary","dBtnSecondary","dBtnAccent","dBtnInfo","dBtnSuccess","dBtnWarning","dBtnError","dBtnNeutral","dBtnOutline","dBtnDash","dBtnSoft","dBtnGhost","dBtnLink","dBtnXs","dBtnSm","dBtnLg","dBtnXl","dBtnActive","dBtnSquare","dBtnCircle","dBtnWide","dBtnBlock","dLoading","dLoadingSpinner","Button","children","color","variant","size","active","loading","shape","noAnimation","icon","iconPosition","danger","pressed","className","props","componentSize","useConfig","effectiveSize","effectiveColor","colorClasses","variantClasses","sizeClasses","shapeClasses","classes","iconSpacing","iconElement","jsx","SizeProvider","content","jsxs","Fragment","href","disabled","onKeyDown","onClick","anchorProps","isDisabled","event","htmlType","buttonProps"],"mappings":";;;AAKA,MAAMA,IAAO,OACPC,IAAc,eACdC,IAAgB,iBAChBC,IAAa,cACbC,IAAW,YACXC,IAAc,eACdC,IAAc,eACdC,IAAY,aACZC,IAAc,eACdC,IAAc,eACdC,IAAW,YACXC,IAAW,YACXC,IAAY,aACZC,IAAW,YACXC,IAAS,UACTC,KAAS,UACTC,KAAS,UACTC,KAAS,UACTC,KAAa,cACbC,KAAa,cACbC,KAAa,cACbC,KAAW,YACXC,KAAY,aACZC,KAAW,WACXC,KAAkB,mBA2CXC,KAAgC,CAAC;AAAA,EAC5C,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,SAAAC;AAAA,EACA,MAAAC;AAAA,EACA,QAAAC,IAAS;AAAA,EACT,SAAAC,IAAU;AAAA,EACV,OAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,MAAAC;AAAA,EACA,cAAAC,IAAe;AAAA,EACf,QAAAC,IAAS;AAAA,EACT,SAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,GAAGC;AACL,MAAM;AACJ,QAAM,EAAE,eAAAC,EAAA,IAAkBC,EAAA,GACpBC,IAAgBb,KAAQW,KAAiB,MAEzCG,IAAiBP,IAAS,UAAUT,GAEpCiB,IAAe;AAAA,IACnB,SAAS3C;AAAA,IACT,WAAWC;AAAA,IACX,QAAQC;AAAA,IACR,MAAMC;AAAA,IACN,SAASC;AAAA,IACT,SAASC;AAAA,IACT,OAAOC;AAAA,IACP,SAASC;AAAA,EAAA,GAGLqC,IAAiB;AAAA,IACrB,OAAO;A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AAA,IACA,CAACK,KAAWG,KAAQC,MAAiB,SAASe;AAAA,EAAA,GACjD;AAGF,MAAI,UAAUX,KAASA,EAAM,SAAS,QAAW;AAC/C,UAAM,EAAE,MAAAiB,GAAM,UAAAC,GAAU,WAAAC,GAAW,SAAAC,GAAS,GAAGC,MAAgBrB,GAIzDsB,IAAaJ,KAAY1B;AAoB/B,WACE,gBAAAoB;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,MAAMU,IAAa,SAAYL;AAAA,QAC/B,MAAK;AAAA,QACL,WAAWR;AAAA,QACX,iBAAea,KAAc;AAAA,QAC7B,aAAW9B,KAAW;AAAA,QACtB,gBAAcM;AAAA,QACd,UAAUwB,IAAa,KAAK;AAAA,QAC5B,WA1BkB,CAACC,MAAkD;AACvE,UAAIA,EAAM,QAAQ,OAAO,CAACD,MACxBC,EAAM,eAAA,GACNA,EAAM,cAAc,MAAA,IAEtBJ,IAAYI,CAAK;AAAA,QACnB;AAAA,QAqBI,SAlBgB,CAACA,MAA+C;AAClE,cAAID,GAAY;AACd,YAAAC,EAAM,eAAA;AACN;AAAA,UACF;AACA,UAAAH,IAAUG,CAAK;AAAA,QACjB;AAAA,QAaK,GAAGF;AAAA,QAEH,UAAAP;AAAA,MAAA;AAAA,IAAA;AAAA,EAGP;AAEA,QAAM,EAAE,UAAAU,GAAU,GAAGC,EAAA,IAAgBzB;AAErC,SACE,gBAAAY;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,MAH8CY,KAAY;AAAA,MAI1D,WAAWf;AAAA,MACX,aAAWjB,KAAW;AAAA,MACtB,gBAAcM;AAAA,MACd,UAAUN,KAAWiC,EAAY;AAAA,MAChC,GAAGA;AAAA,MAEH,UAAAX;AAAA,IAAA;AAAA,EAAA;AAGP;"}
|
|
1
|
+
{"version":3,"file":"Button.js","sources":["../../src/components/Button.tsx"],"sourcesContent":["import React, { forwardRef } from 'react'\nimport { SizeProvider } from '../contexts/SizeContext'\nimport { useConfig } from '../providers/ConfigProvider'\n\n// DaisyUI classes\nconst dBtn = 'btn'\nconst dBtnPrimary = 'btn-primary'\nconst dBtnSecondary = 'btn-secondary'\nconst dBtnAccent = 'btn-accent'\nconst dBtnInfo = 'btn-info'\nconst dBtnSuccess = 'btn-success'\nconst dBtnWarning = 'btn-warning'\nconst dBtnError = 'btn-error'\nconst dBtnNeutral = 'btn-neutral'\nconst dBtnOutline = 'btn-outline'\nconst dBtnDash = 'btn-dash'\nconst dBtnSoft = 'btn-soft'\nconst dBtnGhost = 'btn-ghost'\nconst dBtnLink = 'btn-link'\nconst dBtnXs = 'btn-xs'\nconst dBtnSm = 'btn-sm'\nconst dBtnMd = 'btn-md'\nconst dBtnLg = 'btn-lg'\nconst dBtnXl = 'btn-xl'\nconst dBtnActive = 'btn-active'\nconst dBtnSquare = 'btn-square'\nconst dBtnCircle = 'btn-circle'\nconst dBtnWide = 'btn-wide'\nconst dBtnBlock = 'btn-block'\nconst dLoading = 'loading'\nconst dLoadingSpinner = 'loading-spinner'\n\ntype BaseButtonProps = {\n /** Button color */\n color?: 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'error' | 'neutral'\n /** Button style variant */\n variant?: 'solid' | 'outline' | 'dash' | 'soft' | 'ghost' | 'link'\n /** Button size */\n size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'\n /** Active/pressed visual state */\n active?: boolean\n /** Show loading spinner and disable button */\n loading?: boolean\n /** Button shape */\n shape?: 'square' | 'circle' | 'wide' | 'block' | 'round'\n /** Disable click animation */\n noAnimation?: boolean\n /** Icon element to display */\n icon?: React.ReactNode\n /** Position of the icon */\n iconPlacement?: 'start' | 'end'\n /** @deprecated Use iconPlacement instead */\n iconPosition?: 'start' | 'end'\n /** Applies error/danger styling (shorthand for color=\"error\") */\n danger?: boolean\n /** Toggle button pressed state (sets aria-pressed) */\n pressed?: boolean\n /** Test ID for testing */\n 'data-testid'?: string\n}\n\ntype ButtonAsButton = BaseButtonProps &\n Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'type'> & {\n href?: undefined\n htmlType?: 'button' | 'submit' | 'reset'\n }\n\ntype ButtonAsAnchor = BaseButtonProps &\n Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'type'> & {\n href: string\n htmlType?: undefined\n /** Disable the link button */\n disabled?: boolean\n }\n\nexport type ButtonProps = ButtonAsButton | ButtonAsAnchor\n\nexport const Button = forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProps>(\n (\n {\n children,\n color,\n variant,\n size,\n active = false,\n loading = false,\n shape,\n noAnimation = false,\n icon,\n iconPlacement,\n iconPosition,\n danger = false,\n pressed,\n className = '',\n 'data-testid': testId,\n ...props\n },\n ref\n ) => {\n const { componentSize } = useConfig()\n const effectiveSize = size ?? componentSize ?? 'md'\n // danger prop is a shorthand for color=\"error\"\n const effectiveColor = danger ? 'error' : color\n // iconPlacement takes precedence over deprecated iconPosition\n const effectiveIconPlacement = iconPlacement ?? iconPosition ?? 'start'\n\n const colorClasses = {\n primary: dBtnPrimary,\n secondary: dBtnSecondary,\n accent: dBtnAccent,\n info: dBtnInfo,\n success: dBtnSuccess,\n warning: dBtnWarning,\n error: dBtnError,\n neutral: dBtnNeutral,\n }\n\n const variantClasses = {\n solid: '', // default, no extra class needed\n outline: dBtnOutline,\n dash: dBtnDash,\n soft: dBtnSoft,\n ghost: dBtnGhost,\n link: dBtnLink,\n }\n\n const sizeClasses = {\n xs: dBtnXs,\n sm: dBtnSm,\n md: dBtnMd,\n lg: dBtnLg,\n xl: dBtnXl,\n }\n\n const shapeClasses = {\n square: dBtnSquare,\n circle: dBtnCircle,\n wide: dBtnWide,\n block: dBtnBlock,\n round: 'rounded-full',\n }\n\n const classes = [\n dBtn,\n effectiveColor && colorClasses[effectiveColor],\n variant && variantClasses[variant],\n sizeClasses[effectiveSize],\n active && dBtnActive,\n shape && shapeClasses[shape],\n noAnimation && 'no-animation',\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n // Determine icon spacing based on whether there's text content and button size\n const hasChildren = children !== undefined && children !== null && children !== ''\n const spacingBySize = {\n xs: effectiveIconPlacement === 'start' ? 'mr-1' : 'ml-1',\n sm: effectiveIconPlacement === 'start' ? 'mr-1' : 'ml-1',\n md: effectiveIconPlacement === 'start' ? 'mr-1.5' : 'ml-1.5',\n lg: effectiveIconPlacement === 'start' ? 'mr-2' : 'ml-2',\n xl: effectiveIconPlacement === 'start' ? 'mr-2' : 'ml-2',\n }\n const iconSpacing = hasChildren ? spacingBySize[effectiveSize] : ''\n\n const iconElement = icon && (\n <SizeProvider size={effectiveSize}>\n <span className={`inline-flex items-center ${iconSpacing}`} aria-hidden=\"true\">\n {icon}\n </span>\n </SizeProvider>\n )\n\n const content = (\n <>\n {loading && <span className={`${dLoading} ${dLoadingSpinner}`} aria-hidden=\"true\"></span>}\n {!loading && icon && effectiveIconPlacement === 'start' && iconElement}\n {children}\n {!loading && icon && effectiveIconPlacement === 'end' && iconElement}\n </>\n )\n\n if ('href' in props && props.href !== undefined) {\n const { href, disabled, onKeyDown, onClick, ...anchorProps } = props as ButtonAsAnchor & {\n onKeyDown?: React.KeyboardEventHandler<HTMLAnchorElement>\n onClick?: React.MouseEventHandler<HTMLAnchorElement>\n }\n const isDisabled = disabled || loading\n\n // Handle Space key for anchor buttons (links only respond to Enter natively)\n const handleKeyDown = (event: React.KeyboardEvent<HTMLAnchorElement>) => {\n if (event.key === ' ' && !isDisabled) {\n event.preventDefault()\n event.currentTarget.click()\n }\n onKeyDown?.(event)\n }\n\n // Prevent click when disabled\n const handleClick = (event: React.MouseEvent<HTMLAnchorElement>) => {\n if (isDisabled) {\n event.preventDefault()\n return\n }\n onClick?.(event)\n }\n\n return (\n <a\n ref={ref as React.Ref<HTMLAnchorElement>}\n href={isDisabled ? undefined : href}\n role=\"button\"\n className={classes}\n aria-disabled={isDisabled || undefined}\n aria-busy={loading || undefined}\n aria-pressed={pressed}\n tabIndex={isDisabled ? -1 : 0}\n onKeyDown={handleKeyDown}\n onClick={handleClick}\n data-testid={testId}\n {...anchorProps}\n >\n {content}\n </a>\n )\n }\n\n const { htmlType, ...buttonProps } = props as Omit<ButtonAsButton, keyof BaseButtonProps>\n const buttonType: 'button' | 'submit' | 'reset' = htmlType ?? 'button'\n return (\n <button\n ref={ref as React.Ref<HTMLButtonElement>}\n type={buttonType}\n className={classes}\n aria-busy={loading || undefined}\n aria-pressed={pressed}\n disabled={loading || buttonProps.disabled}\n data-testid={testId}\n {...buttonProps}\n >\n {content}\n </button>\n )\n }\n)\n\nButton.displayName = 'Button'\n"],"names":["dBtn","dBtnPrimary","dBtnSecondary","dBtnAccent","dBtnInfo","dBtnSuccess","dBtnWarning","dBtnError","dBtnNeutral","dBtnOutline","dBtnDash","dBtnSoft","dBtnGhost","dBtnLink","dBtnXs","dBtnSm","dBtnMd","dBtnLg","dBtnXl","dBtnActive","dBtnSquare","dBtnCircle","dBtnWide","dBtnBlock","dLoading","dLoadingSpinner","Button","forwardRef","children","color","variant","size","active","loading","shape","noAnimation","icon","iconPlacement","iconPosition","danger","pressed","className","testId","props","ref","componentSize","useConfig","effectiveSize","effectiveColor","effectiveIconPlacement","colorClasses","variantClasses","sizeClasses","shapeClasses","classes","iconSpacing","iconElement","jsx","SizeProvider","content","jsxs","Fragment","href","disabled","onKeyDown","onClick","anchorProps","isDisabled","event","htmlType","buttonProps"],"mappings":";;;;AAKA,MAAMA,IAAO,OACPC,IAAc,eACdC,IAAgB,iBAChBC,IAAa,cACbC,IAAW,YACXC,IAAc,eACdC,IAAc,eACdC,IAAY,aACZC,IAAc,eACdC,IAAc,eACdC,KAAW,YACXC,KAAW,YACXC,KAAY,aACZC,KAAW,YACXC,KAAS,UACTC,KAAS,UACTC,KAAS,UACTC,KAAS,UACTC,KAAS,UACTC,KAAa,cACbC,KAAa,cACbC,KAAa,cACbC,KAAW,YACXC,KAAY,aACZC,KAAW,WACXC,KAAkB,mBA+CXC,KAASC;AAAA,EACpB,CACE;AAAA,IACE,UAAAC;AAAA,IACA,OAAAC;AAA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,IAAYI,CAAK;AAAA,UACnB;AAAA,UAsBI,SAnBgB,CAACA,MAA+C;AAClE,gBAAID,GAAY;AACd,cAAAC,EAAM,eAAA;AACN;AAAA,YACF;AACA,YAAAH,IAAUG,CAAK;AAAA,UACjB;AAAA,UAcI,eAAa1B;AAAA,UACZ,GAAGwB;AAAA,UAEH,UAAAP;AAAA,QAAA;AAAA,MAAA;AAAA,IAGP;AAEA,UAAM,EAAE,UAAAU,GAAU,GAAGC,EAAA,IAAgB3B;AAErC,WACE,gBAAAc;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,KAAAb;AAAA,QACA,MAJ8CyB,KAAY;AAAA,QAK1D,WAAWf;AAAA,QACX,aAAWrB,KAAW;AAAA,QACtB,gBAAcO;AAAA,QACd,UAAUP,KAAWqC,EAAY;AAAA,QACjC,eAAa5B;AAAA,QACZ,GAAG4B;AAAA,QAEH,UAAAX;AAAA,MAAA;AAAA,IAAA;AAAA,EAGP;AACF;AAEAjC,GAAO,cAAc;"}
|
package/dist/components/Chart.js
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as x } from "react/jsx-runtime";
|
|
2
2
|
import { useRef as p, useEffect as m } from "react";
|
|
3
|
-
import
|
|
4
|
-
import { useTheme as
|
|
5
|
-
function
|
|
3
|
+
import k from "apexcharts";
|
|
4
|
+
import { useTheme as A } from "../hooks/useTheme.js";
|
|
5
|
+
function a(t, o) {
|
|
6
6
|
const l = { ...t };
|
|
7
|
-
for (const
|
|
8
|
-
e
|
|
9
|
-
t[
|
|
10
|
-
e
|
|
11
|
-
) : l[
|
|
7
|
+
for (const e in o)
|
|
8
|
+
o[e] !== void 0 && (typeof o[e] == "object" && o[e] !== null && !Array.isArray(o[e]) && typeof t[e] == "object" && t[e] !== null && !Array.isArray(t[e]) ? l[e] = a(
|
|
9
|
+
t[e],
|
|
10
|
+
o[e]
|
|
11
|
+
) : l[e] = o[e]);
|
|
12
12
|
return l;
|
|
13
13
|
}
|
|
14
|
-
const
|
|
14
|
+
const T = ({
|
|
15
15
|
type: t,
|
|
16
|
-
series:
|
|
16
|
+
series: o,
|
|
17
17
|
width: l = "100%",
|
|
18
|
-
height:
|
|
19
|
-
options:
|
|
20
|
-
themed:
|
|
21
|
-
className: y = ""
|
|
18
|
+
height: e = 350,
|
|
19
|
+
options: c = {},
|
|
20
|
+
themed: f = !0,
|
|
21
|
+
className: y = "",
|
|
22
|
+
"data-testid": h
|
|
22
23
|
}) => {
|
|
23
|
-
const u = p(null), n = p(null), { isDark:
|
|
24
|
+
const u = p(null), n = p(null), { isDark: d, colors: r } = A(), b = () => ({
|
|
24
25
|
colors: [
|
|
25
26
|
r.primary,
|
|
26
27
|
r.secondary,
|
|
@@ -31,7 +32,7 @@ const j = ({
|
|
|
31
32
|
r.error
|
|
32
33
|
],
|
|
33
34
|
theme: {
|
|
34
|
-
mode:
|
|
35
|
+
mode: d ? "dark" : "light"
|
|
35
36
|
},
|
|
36
37
|
chart: {
|
|
37
38
|
background: "transparent",
|
|
@@ -67,7 +68,7 @@ const j = ({
|
|
|
67
68
|
}
|
|
68
69
|
},
|
|
69
70
|
tooltip: {
|
|
70
|
-
theme:
|
|
71
|
+
theme: d ? "dark" : "light",
|
|
71
72
|
style: {
|
|
72
73
|
fontSize: "12px"
|
|
73
74
|
},
|
|
@@ -89,34 +90,34 @@ const j = ({
|
|
|
89
90
|
enabled: !1
|
|
90
91
|
}
|
|
91
92
|
}
|
|
92
|
-
}),
|
|
93
|
+
}), i = () => {
|
|
93
94
|
const s = {
|
|
94
95
|
chart: {
|
|
95
96
|
type: t,
|
|
96
97
|
width: l,
|
|
97
|
-
height:
|
|
98
|
+
height: e
|
|
98
99
|
},
|
|
99
|
-
series:
|
|
100
|
+
series: o
|
|
100
101
|
};
|
|
101
|
-
if (
|
|
102
|
-
const
|
|
103
|
-
return
|
|
102
|
+
if (f) {
|
|
103
|
+
const g = b();
|
|
104
|
+
return a(a(s, g), c);
|
|
104
105
|
}
|
|
105
|
-
return
|
|
106
|
+
return a(s, c);
|
|
106
107
|
};
|
|
107
108
|
return m(() => {
|
|
108
109
|
if (!u.current) return;
|
|
109
|
-
const s =
|
|
110
|
-
return n.current = new
|
|
110
|
+
const s = i();
|
|
111
|
+
return n.current = new k(u.current, s), n.current.render(), () => {
|
|
111
112
|
n.current && (n.current.destroy(), n.current = null);
|
|
112
113
|
};
|
|
113
114
|
}, []), m(() => {
|
|
114
115
|
if (!n.current) return;
|
|
115
|
-
const s =
|
|
116
|
+
const s = i();
|
|
116
117
|
n.current.updateOptions(s, !0, !0);
|
|
117
|
-
}, [t,
|
|
118
|
+
}, [t, o, l, e, c, f, d, r]), /* @__PURE__ */ x("div", { ref: u, className: y, "data-testid": h });
|
|
118
119
|
};
|
|
119
120
|
export {
|
|
120
|
-
|
|
121
|
+
T as Chart
|
|
121
122
|
};
|
|
122
123
|
//# sourceMappingURL=Chart.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chart.js","sources":["../../src/components/Chart.tsx"],"sourcesContent":["import React, { useEffect, useRef } from 'react'\nimport ApexCharts from 'apexcharts'\nimport type { ApexOptions } from 'apexcharts'\nimport { useTheme } from '../hooks/useTheme'\n\nexport interface ChartProps {\n /** Chart type */\n type: 'line' | 'area' | 'bar' | 'pie' | 'donut' | 'radialBar' | 'scatter' | 'bubble' | 'heatmap' | 'candlestick' | 'boxPlot' | 'radar' | 'polarArea' | 'rangeBar' | 'rangeArea' | 'treemap'\n /** Chart series data */\n series: ApexAxisChartSeries | ApexNonAxisChartSeries\n /** Chart width */\n width?: string | number\n /** Chart height */\n height?: string | number\n /** ApexCharts options (merged with theme defaults) */\n options?: ApexOptions\n /** Use daisyUI theme colors */\n themed?: boolean\n /** Additional CSS classes */\n className?: string\n}\n\n// Deep merge objects\nfunction deepMerge<T extends Record<string, unknown>>(target: T, source: Partial<T>): T {\n const result = { ...target }\n\n for (const key in source) {\n if (source[key] !== undefined) {\n if (\n typeof source[key] === 'object' &&\n source[key] !== null &&\n !Array.isArray(source[key]) &&\n typeof target[key] === 'object' &&\n target[key] !== null &&\n !Array.isArray(target[key])\n ) {\n result[key] = deepMerge(\n target[key] as Record<string, unknown>,\n source[key] as Record<string, unknown>\n ) as T[Extract<keyof T, string>]\n } else {\n result[key] = source[key] as T[Extract<keyof T, string>]\n }\n }\n }\n\n return result\n}\n\nexport const Chart: React.FC<ChartProps> = ({\n type,\n series,\n width = '100%',\n height = 350,\n options = {},\n themed = true,\n className = '',\n}) => {\n const chartRef = useRef<HTMLDivElement>(null)\n const chartInstance = useRef<ApexCharts | null>(null)\n const { isDark, colors } = useTheme()\n\n // Build theme-aware chart options\n const getThemedOptions = (): Partial<ApexOptions> => {\n const chartColors = [\n colors.primary,\n colors.secondary,\n colors.accent,\n colors.info,\n colors.success,\n colors.warning,\n colors.error,\n ]\n\n return {\n colors: chartColors,\n theme: {\n mode: isDark ? 'dark' : 'light',\n },\n chart: {\n background: 'transparent',\n foreColor: colors.foreground,\n },\n grid: {\n borderColor: colors.foreground + '20', // 12.5% opacity\n },\n xaxis: {\n labels: {\n style: {\n colors: colors.foreground,\n },\n },\n axisBorder: {\n color: colors.foreground + '20',\n },\n axisTicks: {\n color: colors.foreground + '20',\n },\n },\n yaxis: {\n labels: {\n style: {\n colors: colors.foreground,\n },\n },\n },\n legend: {\n labels: {\n colors: colors.foreground,\n },\n },\n tooltip: {\n theme: isDark ? 'dark' : 'light',\n style: {\n fontSize: '12px',\n },\n x: {\n show: true,\n },\n marker: {\n show: true,\n },\n },\n dataLabels: {\n style: {\n colors: Array(7).fill(colors.foreground),\n },\n background: {\n enabled: false,\n },\n dropShadow: {\n enabled: false,\n },\n },\n }\n }\n\n // Build final options\n const buildOptions = (): ApexOptions => {\n const baseOptions: ApexOptions = {\n chart: {\n type,\n width,\n height,\n },\n series,\n }\n\n if (themed) {\n const themedOpts = getThemedOptions()\n return deepMerge(deepMerge(baseOptions as unknown as Record<string, unknown>, themedOpts as unknown as Record<string, unknown>), options as unknown as Record<string, unknown>) as ApexOptions\n }\n\n return deepMerge(baseOptions as unknown as Record<string, unknown>, options as unknown as Record<string, unknown>) as ApexOptions\n }\n\n // Initialize chart\n useEffect(() => {\n if (!chartRef.current) return\n\n const opts = buildOptions()\n chartInstance.current = new ApexCharts(chartRef.current, opts)\n chartInstance.current.render()\n\n return () => {\n if (chartInstance.current) {\n chartInstance.current.destroy()\n chartInstance.current = null\n }\n }\n }, []) // eslint-disable-line react-hooks/exhaustive-deps\n\n // Update chart when props or theme change\n useEffect(() => {\n if (!chartInstance.current) return\n\n const opts = buildOptions()\n chartInstance.current.updateOptions(opts, true, true)\n }, [type, series, width, height, options, themed, isDark, colors]) // eslint-disable-line react-hooks/exhaustive-deps\n\n return <div ref={chartRef} className={className} />\n}\n"],"names":["deepMerge","target","source","result","key","Chart","type","series","width","height","options","themed","className","chartRef","useRef","chartInstance","isDark","colors","useTheme","getThemedOptions","buildOptions","baseOptions","themedOpts","useEffect","opts","ApexCharts"
|
|
1
|
+
{"version":3,"file":"Chart.js","sources":["../../src/components/Chart.tsx"],"sourcesContent":["import React, { useEffect, useRef } from 'react'\nimport ApexCharts from 'apexcharts'\nimport type { ApexOptions } from 'apexcharts'\nimport { useTheme } from '../hooks/useTheme'\n\nexport interface ChartProps {\n /** Chart type */\n type: 'line' | 'area' | 'bar' | 'pie' | 'donut' | 'radialBar' | 'scatter' | 'bubble' | 'heatmap' | 'candlestick' | 'boxPlot' | 'radar' | 'polarArea' | 'rangeBar' | 'rangeArea' | 'treemap'\n /** Chart series data */\n series: ApexAxisChartSeries | ApexNonAxisChartSeries\n /** Chart width */\n width?: string | number\n /** Chart height */\n height?: string | number\n /** ApexCharts options (merged with theme defaults) */\n options?: ApexOptions\n /** Use daisyUI theme colors */\n themed?: boolean\n /** Additional CSS classes */\n className?: string\n 'data-testid'?: string\n}\n\n// Deep merge objects\nfunction deepMerge<T extends Record<string, unknown>>(target: T, source: Partial<T>): T {\n const result = { ...target }\n\n for (const key in source) {\n if (source[key] !== undefined) {\n if (\n typeof source[key] === 'object' &&\n source[key] !== null &&\n !Array.isArray(source[key]) &&\n typeof target[key] === 'object' &&\n target[key] !== null &&\n !Array.isArray(target[key])\n ) {\n result[key] = deepMerge(\n target[key] as Record<string, unknown>,\n source[key] as Record<string, unknown>\n ) as T[Extract<keyof T, string>]\n } else {\n result[key] = source[key] as T[Extract<keyof T, string>]\n }\n }\n }\n\n return result\n}\n\nexport const Chart: React.FC<ChartProps> = ({\n type,\n series,\n width = '100%',\n height = 350,\n options = {},\n themed = true,\n className = '',\n 'data-testid': testId,\n}) => {\n const chartRef = useRef<HTMLDivElement>(null)\n const chartInstance = useRef<ApexCharts | null>(null)\n const { isDark, colors } = useTheme()\n\n // Build theme-aware chart options\n const getThemedOptions = (): Partial<ApexOptions> => {\n const chartColors = [\n colors.primary,\n colors.secondary,\n colors.accent,\n colors.info,\n colors.success,\n colors.warning,\n colors.error,\n ]\n\n return {\n colors: chartColors,\n theme: {\n mode: isDark ? 'dark' : 'light',\n },\n chart: {\n background: 'transparent',\n foreColor: colors.foreground,\n },\n grid: {\n borderColor: colors.foreground + '20', // 12.5% opacity\n },\n xaxis: {\n labels: {\n style: {\n colors: colors.foreground,\n },\n },\n axisBorder: {\n color: colors.foreground + '20',\n },\n axisTicks: {\n color: colors.foreground + '20',\n },\n },\n yaxis: {\n labels: {\n style: {\n colors: colors.foreground,\n },\n },\n },\n legend: {\n labels: {\n colors: colors.foreground,\n },\n },\n tooltip: {\n theme: isDark ? 'dark' : 'light',\n style: {\n fontSize: '12px',\n },\n x: {\n show: true,\n },\n marker: {\n show: true,\n },\n },\n dataLabels: {\n style: {\n colors: Array(7).fill(colors.foreground),\n },\n background: {\n enabled: false,\n },\n dropShadow: {\n enabled: false,\n },\n },\n }\n }\n\n // Build final options\n const buildOptions = (): ApexOptions => {\n const baseOptions: ApexOptions = {\n chart: {\n type,\n width,\n height,\n },\n series,\n }\n\n if (themed) {\n const themedOpts = getThemedOptions()\n return deepMerge(deepMerge(baseOptions as unknown as Record<string, unknown>, themedOpts as unknown as Record<string, unknown>), options as unknown as Record<string, unknown>) as ApexOptions\n }\n\n return deepMerge(baseOptions as unknown as Record<string, unknown>, options as unknown as Record<string, unknown>) as ApexOptions\n }\n\n // Initialize chart\n useEffect(() => {\n if (!chartRef.current) return\n\n const opts = buildOptions()\n chartInstance.current = new ApexCharts(chartRef.current, opts)\n chartInstance.current.render()\n\n return () => {\n if (chartInstance.current) {\n chartInstance.current.destroy()\n chartInstance.current = null\n }\n }\n }, []) // eslint-disable-line react-hooks/exhaustive-deps\n\n // Update chart when props or theme change\n useEffect(() => {\n if (!chartInstance.current) return\n\n const opts = buildOptions()\n chartInstance.current.updateOptions(opts, true, true)\n }, [type, series, width, height, options, themed, isDark, colors]) // eslint-disable-line react-hooks/exhaustive-deps\n\n return <div ref={chartRef} className={className} data-testid={testId} />\n}\n"],"names":["deepMerge","target","source","result","key","Chart","type","series","width","height","options","themed","className","testId","chartRef","useRef","chartInstance","isDark","colors","useTheme","getThemedOptions","buildOptions","baseOptions","themedOpts","useEffect","opts","ApexCharts"],"mappings":";;;;AAwBA,SAASA,EAA6CC,GAAWC,GAAuB;AACtF,QAAMC,IAAS,EAAE,GAAGF,EAAA;AAEpB,aAAWG,KAAOF;AAChB,IAAIA,EAAOE,CAAG,MAAM,WAEhB,OAAOF,EAAOE,CAAG,KAAM,YACvBF,EAAOE,CAAG,MAAM,QAChB,CAAC,MAAM,QAAQF,EAAOE,CAAG,CAAC,KAC1B,OAAOH,EAAOG,CAAG,KAAM,YACvBH,EAAOG,CAAG,MAAM,QAChB,CAAC,MAAM,QAAQH,EAAOG,CAAG,CAAC,IAE1BD,EAAOC,CAAG,IAAIJ;AAAA,MACZC,EAAOG,CAAG;AAAA,MACVF,EAAOE,CAAG;AAAA,IAAA,IAGZD,EAAOC,CAAG,IAAIF,EAAOE,CAAG;AAK9B,SAAOD;AACT;AAEO,MAAME,IAA8B,CAAC;A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 +7,6 @@ export interface ChatProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
7
7
|
header?: React.ReactNode;
|
|
8
8
|
footer?: React.ReactNode;
|
|
9
9
|
color?: 'primary' | 'secondary' | 'accent' | 'neutral' | 'info' | 'success' | 'warning' | 'error';
|
|
10
|
+
'data-testid'?: string;
|
|
10
11
|
}
|
|
11
12
|
export declare const Chat: React.FC<ChatProps>;
|
package/dist/components/Chat.js
CHANGED
|
@@ -1,33 +1,44 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { jsxs as B, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useId as f } from "react";
|
|
3
|
+
const g = "chat", p = "chat-start", y = "chat-end", N = "chat-image", $ = "chat-header", j = "chat-bubble", w = "chat-bubble-primary", x = "chat-bubble-secondary", I = "chat-bubble-accent", S = "chat-bubble-neutral", A = "chat-bubble-info", E = "chat-bubble-success", F = "chat-bubble-warning", H = "chat-bubble-error", P = "chat-footer", T = "avatar", q = ({
|
|
4
|
+
message: o,
|
|
5
|
+
position: h = "start",
|
|
6
|
+
avatar: b,
|
|
7
|
+
avatarAlt: i = "",
|
|
8
|
+
header: e,
|
|
9
|
+
footer: d,
|
|
10
|
+
color: s,
|
|
11
|
+
className: u = "",
|
|
12
|
+
"data-testid": c,
|
|
13
|
+
...C
|
|
12
14
|
}) => {
|
|
13
|
-
const
|
|
14
|
-
primary:
|
|
15
|
-
secondary:
|
|
16
|
-
accent:
|
|
17
|
-
neutral:
|
|
18
|
-
info:
|
|
19
|
-
success:
|
|
20
|
-
warning:
|
|
21
|
-
error:
|
|
22
|
-
},
|
|
23
|
-
return
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
15
|
+
const n = f(), m = h === "start" ? p : y, a = (v) => c ? `${c}-${v}` : void 0, r = {
|
|
16
|
+
primary: w,
|
|
17
|
+
secondary: x,
|
|
18
|
+
accent: I,
|
|
19
|
+
neutral: S,
|
|
20
|
+
info: A,
|
|
21
|
+
success: E,
|
|
22
|
+
warning: F,
|
|
23
|
+
error: H
|
|
24
|
+
}, l = [j];
|
|
25
|
+
return s && r[s] && l.push(r[s]), /* @__PURE__ */ B(
|
|
26
|
+
"article",
|
|
27
|
+
{
|
|
28
|
+
className: `${g} ${m} ${u}`,
|
|
29
|
+
"aria-labelledby": e ? n : void 0,
|
|
30
|
+
"data-testid": c,
|
|
31
|
+
...C,
|
|
32
|
+
children: [
|
|
33
|
+
b && /* @__PURE__ */ t("div", { className: `${N} ${T}`, "data-testid": a("avatar"), children: /* @__PURE__ */ t("div", { className: "w-10 rounded-full", children: /* @__PURE__ */ t("img", { alt: i, src: b }) }) }),
|
|
34
|
+
e && /* @__PURE__ */ t("div", { id: n, className: $, "data-testid": a("header"), children: e }),
|
|
35
|
+
/* @__PURE__ */ t("div", { className: l.join(" "), "data-testid": a("bubble"), children: o }),
|
|
36
|
+
d && /* @__PURE__ */ t("div", { className: P, "data-testid": a("footer"), children: d })
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
);
|
|
29
40
|
};
|
|
30
41
|
export {
|
|
31
|
-
|
|
42
|
+
q as Chat
|
|
32
43
|
};
|
|
33
44
|
//# sourceMappingURL=Chat.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chat.js","sources":["../../src/components/Chat.tsx"],"sourcesContent":["import React from 'react'\n\n// DaisyUI classes\nconst dChat = 'chat'\nconst dChatStart = 'chat-start'\nconst dChatEnd = 'chat-end'\nconst dChatImage = 'chat-image'\nconst dChatHeader = 'chat-header'\nconst dChatBubble = 'chat-bubble'\nconst dChatBubblePrimary = 'chat-bubble-primary'\nconst dChatBubbleSecondary = 'chat-bubble-secondary'\nconst dChatBubbleAccent = 'chat-bubble-accent'\nconst dChatBubbleNeutral = 'chat-bubble-neutral'\nconst dChatBubbleInfo = 'chat-bubble-info'\nconst dChatBubbleSuccess = 'chat-bubble-success'\nconst dChatBubbleWarning = 'chat-bubble-warning'\nconst dChatBubbleError = 'chat-bubble-error'\nconst dChatFooter = 'chat-footer'\nconst dAvatar = 'avatar'\n\nexport interface ChatProps extends React.HTMLAttributes<HTMLDivElement> {\n message: React.ReactNode\n position?: 'start' | 'end'\n avatar?: string\n avatarAlt?: string\n header?: React.ReactNode\n footer?: React.ReactNode\n color?: 'primary' | 'secondary' | 'accent' | 'neutral' | 'info' | 'success' | 'warning' | 'error'\n}\n\nexport const Chat: React.FC<ChatProps> = ({\n message,\n position = 'start',\n avatar,\n avatarAlt = '',\n header,\n footer,\n color,\n className = '',\n ...rest\n}) => {\n const positionClass = position === 'start' ? dChatStart : dChatEnd\n\n const colorClasses: Record<string, string> = {\n primary: dChatBubblePrimary,\n secondary: dChatBubbleSecondary,\n accent: dChatBubbleAccent,\n neutral: dChatBubbleNeutral,\n info: dChatBubbleInfo,\n success: dChatBubbleSuccess,\n warning: dChatBubbleWarning,\n error: dChatBubbleError,\n }\n\n const bubbleClasses = [dChatBubble]\n if (color && colorClasses[color]) {\n bubbleClasses.push(colorClasses[color])\n }\n\n return (\n <
|
|
1
|
+
{"version":3,"file":"Chat.js","sources":["../../src/components/Chat.tsx"],"sourcesContent":["import React, { useId } from 'react'\n\n// DaisyUI classes\nconst dChat = 'chat'\nconst dChatStart = 'chat-start'\nconst dChatEnd = 'chat-end'\nconst dChatImage = 'chat-image'\nconst dChatHeader = 'chat-header'\nconst dChatBubble = 'chat-bubble'\nconst dChatBubblePrimary = 'chat-bubble-primary'\nconst dChatBubbleSecondary = 'chat-bubble-secondary'\nconst dChatBubbleAccent = 'chat-bubble-accent'\nconst dChatBubbleNeutral = 'chat-bubble-neutral'\nconst dChatBubbleInfo = 'chat-bubble-info'\nconst dChatBubbleSuccess = 'chat-bubble-success'\nconst dChatBubbleWarning = 'chat-bubble-warning'\nconst dChatBubbleError = 'chat-bubble-error'\nconst dChatFooter = 'chat-footer'\nconst dAvatar = 'avatar'\n\nexport interface ChatProps extends React.HTMLAttributes<HTMLDivElement> {\n message: React.ReactNode\n position?: 'start' | 'end'\n avatar?: string\n avatarAlt?: string\n header?: React.ReactNode\n footer?: React.ReactNode\n color?: 'primary' | 'secondary' | 'accent' | 'neutral' | 'info' | 'success' | 'warning' | 'error'\n 'data-testid'?: string\n}\n\nexport const Chat: React.FC<ChatProps> = ({\n message,\n position = 'start',\n avatar,\n avatarAlt = '',\n header,\n footer,\n color,\n className = '',\n 'data-testid': testId,\n ...rest\n}) => {\n const headerId = useId()\n const positionClass = position === 'start' ? dChatStart : dChatEnd\n const getTestId = (suffix: string) => (testId ? `${testId}-${suffix}` : undefined)\n\n const colorClasses: Record<string, string> = {\n primary: dChatBubblePrimary,\n secondary: dChatBubbleSecondary,\n accent: dChatBubbleAccent,\n neutral: dChatBubbleNeutral,\n info: dChatBubbleInfo,\n success: dChatBubbleSuccess,\n warning: dChatBubbleWarning,\n error: dChatBubbleError,\n }\n\n const bubbleClasses = [dChatBubble]\n if (color && colorClasses[color]) {\n bubbleClasses.push(colorClasses[color])\n }\n\n return (\n <article\n className={`${dChat} ${positionClass} ${className}`}\n aria-labelledby={header ? headerId : undefined}\n data-testid={testId}\n {...rest}\n >\n {avatar && (\n <div className={`${dChatImage} ${dAvatar}`} data-testid={getTestId('avatar')}>\n <div className=\"w-10 rounded-full\">\n <img alt={avatarAlt} src={avatar} />\n </div>\n </div>\n )}\n {header && <div id={headerId} className={dChatHeader} data-testid={getTestId('header')}>{header}</div>}\n <div className={bubbleClasses.join(' ')} data-testid={getTestId('bubble')}>{message}</div>\n {footer && <div className={dChatFooter} data-testid={getTestId('footer')}>{footer}</div>}\n </article>\n )\n}\n"],"names":["dChat","dChatStart","dChatEnd","dChatImage","dChatHeader","dChatBubble","dChatBubblePrimary","dChatBubbleSecondary","dChatBubbleAccent","dChatBubbleNeutral","dChatBubbleInfo","dChatBubbleSuccess","dChatBubbleWarning","dChatBubbleError","dChatFooter","dAvatar","Chat","message","position","avatar","avatarAlt","header","footer","color","className","testId","rest","headerId","useId","positionClass","getTestId","suffix","colorClasses","bubbleClasses","jsxs","jsx"],"mappings":";;AAGA,MAAMA,IAAQ,QACRC,IAAa,cACbC,IAAW,YACXC,IAAa,cACbC,IAAc,eACdC,IAAc,eACdC,IAAqB,uBACrBC,IAAuB,yBACvBC,IAAoB,sBACpBC,IAAqB,uBACrBC,IAAkB,oBAClBC,IAAqB,uBACrBC,IAAqB,uBACrBC,IAAmB,qBACnBC,IAAc,eACdC,IAAU,UAaHC,IAA4B,CAAC;AAAA,EACxC,SAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,QAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,QAAAC;AAAA,EACA,QAAAC;AAAA,EACA,OAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,eAAeC;AAAA,EACf,GAAGC;AACL,MAAM;AACJ,QAAMC,IAAWC,EAAA,GACXC,IAAgBX,MAAa,UAAUjB,IAAaC,GACpD4B,IAAY,CAACC,MAAoBN,IAAS,GAAGA,CAAM,IAAIM,CAAM,KAAK,QAElEC,IAAuC;AAAA,IAC3C,SAAS1B;AAAA,IACT,WAAWC;AAAA,IACX,QAAQC;AAAA,IACR,SAASC;AAAA,IACT,MAAMC;AAAA,IACN,SAASC;AAAA,IACT,SAASC;AAAA,IACT,OAAOC;AAAA,EAAA,GAGHoB,IAAgB,CAAC5B,CAAW;AAClC,SAAIkB,KAASS,EAAaT,CAAK,KAC7BU,EAAc,KAAKD,EAAaT,CAAK,CAAC,GAItC,gBAAAW;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW,GAAGlC,CAAK,IAAI6B,CAAa,IAAIL,CAAS;AAAA,MACjD,mBAAiBH,IAASM,IAAW;AAAA,MACrC,eAAaF;AAAA,MACZ,GAAGC;AAAA,MAEH,UAAA;AAAA,QAAAP,KACC,gBAAAgB,EAAC,SAAI,WAAW,GAAGhC,CAAU,IAAIY,CAAO,IAAI,eAAae,EAAU,QAAQ,GACzE,UAAA,gBAAAK,EAAC,OAAA,EAAI,WAAU,qBACb,UAAA,gBAAAA,EAAC,OAAA,EAAI,KAAKf,GAAW,KAAKD,EAAA,CAAQ,EAAA,CACpC,EAAA,CACF;AAAA,QAEDE,KAAU,gBAAAc,EAAC,OAAA,EAAI,IAAIR,GAAU,WAAWvB,GAAa,eAAa0B,EAAU,QAAQ,GAAI,UAAAT,EAAA,CAAO;AAAA,QAChG,gBAAAc,EAAC,OAAA,EAAI,WAAWF,EAAc,KAAK,GAAG,GAAG,eAAaH,EAAU,QAAQ,GAAI,UAAAb,EAAA,CAAQ;AAAA,QACnFK,uBAAW,OAAA,EAAI,WAAWR,GAAa,eAAagB,EAAU,QAAQ,GAAI,UAAAR,EAAA,CAAO;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGxF;"}
|
|
@@ -9,6 +9,8 @@ export interface CodeProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
9
9
|
children: React.ReactNode;
|
|
10
10
|
/** Show copy button. Pass true to auto-extract text, or a string to specify custom copy text */
|
|
11
11
|
copyable?: boolean | string;
|
|
12
|
+
/** Test ID for testing */
|
|
13
|
+
'data-testid'?: string;
|
|
12
14
|
}
|
|
13
15
|
export declare const Code: React.FC<CodeProps> & {
|
|
14
16
|
Line: typeof Line;
|