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,37 +1,43 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { jsxs as m, jsx as f } from "react/jsx-runtime";
|
|
2
|
+
import n, { useId as u } from "react";
|
|
3
|
+
const y = "tooltip", g = "tooltip-top", h = "tooltip-bottom", b = "tooltip-left", j = "tooltip-right", x = "tooltip-neutral", E = "tooltip-primary", I = "tooltip-secondary", N = "tooltip-accent", v = "tooltip-info", w = "tooltip-success", A = "tooltip-warning", B = "tooltip-error", C = "tooltip-open", W = ({
|
|
4
|
+
children: o,
|
|
5
|
+
tip: t,
|
|
6
|
+
className: p = "",
|
|
7
|
+
position: c = "top",
|
|
8
|
+
color: i,
|
|
9
|
+
open: s = !1,
|
|
10
|
+
...e
|
|
10
11
|
}) => {
|
|
11
|
-
const
|
|
12
|
-
top:
|
|
13
|
-
bottom:
|
|
14
|
-
left:
|
|
15
|
-
right:
|
|
16
|
-
},
|
|
17
|
-
neutral:
|
|
18
|
-
primary:
|
|
19
|
-
secondary:
|
|
20
|
-
accent:
|
|
21
|
-
info:
|
|
22
|
-
success:
|
|
23
|
-
warning:
|
|
24
|
-
error:
|
|
25
|
-
}[
|
|
26
|
-
|
|
27
|
-
c
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
].filter(Boolean).join(" ")
|
|
32
|
-
|
|
12
|
+
const l = u(), r = {
|
|
13
|
+
top: g,
|
|
14
|
+
bottom: h,
|
|
15
|
+
left: b,
|
|
16
|
+
right: j
|
|
17
|
+
}, a = i ? {
|
|
18
|
+
neutral: x,
|
|
19
|
+
primary: E,
|
|
20
|
+
secondary: I,
|
|
21
|
+
accent: N,
|
|
22
|
+
info: v,
|
|
23
|
+
success: w,
|
|
24
|
+
warning: A,
|
|
25
|
+
error: B
|
|
26
|
+
}[i] : void 0, d = [
|
|
27
|
+
y,
|
|
28
|
+
r[c],
|
|
29
|
+
a,
|
|
30
|
+
s && C,
|
|
31
|
+
p
|
|
32
|
+
].filter(Boolean).join(" "), T = n.isValidElement(o) ? n.cloneElement(o, {
|
|
33
|
+
"aria-describedby": l
|
|
34
|
+
}) : o;
|
|
35
|
+
return /* @__PURE__ */ m("div", { className: d, "data-tip": t, "data-state": s ? "open" : "closed", ...e, children: [
|
|
36
|
+
T,
|
|
37
|
+
/* @__PURE__ */ f("span", { id: l, role: "tooltip", className: "sr-only", children: t })
|
|
38
|
+
] });
|
|
33
39
|
};
|
|
34
40
|
export {
|
|
35
|
-
|
|
41
|
+
W as Tooltip
|
|
36
42
|
};
|
|
37
43
|
//# sourceMappingURL=Tooltip.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.js","sources":["../../src/components/Tooltip.tsx"],"sourcesContent":["import React from 'react'\n\n// DaisyUI classes\nconst dTooltip = 'tooltip'\nconst dTooltipTop = 'tooltip-top'\nconst dTooltipBottom = 'tooltip-bottom'\nconst dTooltipLeft = 'tooltip-left'\nconst dTooltipRight = 'tooltip-right'\nconst dTooltipNeutral = 'tooltip-neutral'\nconst dTooltipPrimary = 'tooltip-primary'\nconst dTooltipSecondary = 'tooltip-secondary'\nconst dTooltipAccent = 'tooltip-accent'\nconst dTooltipInfo = 'tooltip-info'\nconst dTooltipSuccess = 'tooltip-success'\nconst dTooltipWarning = 'tooltip-warning'\nconst dTooltipError = 'tooltip-error'\nconst dTooltipOpen = 'tooltip-open'\n\nexport interface TooltipProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode\n tip: string\n position?: 'top' | 'bottom' | 'left' | 'right'\n color?: 'neutral' | 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'error'\n open?: boolean\n}\n\nexport const Tooltip: React.FC<TooltipProps> = ({\n children,\n tip,\n className = '',\n position = 'top',\n color,\n open = false,\n ...rest\n}) => {\n const positionClasses = {\n top: dTooltipTop,\n bottom: dTooltipBottom,\n left: dTooltipLeft,\n right: dTooltipRight,\n }\n\n const colorClasses = color\n ? {\n neutral: dTooltipNeutral,\n primary: dTooltipPrimary,\n secondary: dTooltipSecondary,\n accent: dTooltipAccent,\n info: dTooltipInfo,\n success: dTooltipSuccess,\n warning: dTooltipWarning,\n error: dTooltipError,\n }[color]\n : undefined\n\n const classes = [\n dTooltip,\n positionClasses[position],\n colorClasses,\n open && dTooltipOpen,\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n return (\n <div className={classes} data-tip={tip} data-state={open ? 'open' : 'closed'} {...rest}>\n {
|
|
1
|
+
{"version":3,"file":"Tooltip.js","sources":["../../src/components/Tooltip.tsx"],"sourcesContent":["import React, { useId } from 'react'\n\n// DaisyUI classes\nconst dTooltip = 'tooltip'\nconst dTooltipTop = 'tooltip-top'\nconst dTooltipBottom = 'tooltip-bottom'\nconst dTooltipLeft = 'tooltip-left'\nconst dTooltipRight = 'tooltip-right'\nconst dTooltipNeutral = 'tooltip-neutral'\nconst dTooltipPrimary = 'tooltip-primary'\nconst dTooltipSecondary = 'tooltip-secondary'\nconst dTooltipAccent = 'tooltip-accent'\nconst dTooltipInfo = 'tooltip-info'\nconst dTooltipSuccess = 'tooltip-success'\nconst dTooltipWarning = 'tooltip-warning'\nconst dTooltipError = 'tooltip-error'\nconst dTooltipOpen = 'tooltip-open'\n\nexport interface TooltipProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode\n tip: string\n position?: 'top' | 'bottom' | 'left' | 'right'\n color?: 'neutral' | 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'error'\n open?: boolean\n /** Test ID for testing */\n 'data-testid'?: string\n}\n\nexport const Tooltip: React.FC<TooltipProps> = ({\n children,\n tip,\n className = '',\n position = 'top',\n color,\n open = false,\n ...rest\n}) => {\n const tooltipId = useId()\n\n const positionClasses = {\n top: dTooltipTop,\n bottom: dTooltipBottom,\n left: dTooltipLeft,\n right: dTooltipRight,\n }\n\n const colorClasses = color\n ? {\n neutral: dTooltipNeutral,\n primary: dTooltipPrimary,\n secondary: dTooltipSecondary,\n accent: dTooltipAccent,\n info: dTooltipInfo,\n success: dTooltipSuccess,\n warning: dTooltipWarning,\n error: dTooltipError,\n }[color]\n : undefined\n\n const classes = [\n dTooltip,\n positionClasses[position],\n colorClasses,\n open && dTooltipOpen,\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n // Clone children to add aria-describedby\n const childWithAria = React.isValidElement(children)\n ? React.cloneElement(children as React.ReactElement<{ 'aria-describedby'?: string }>, {\n 'aria-describedby': tooltipId,\n })\n : children\n\n return (\n <div className={classes} data-tip={tip} data-state={open ? 'open' : 'closed'} {...rest}>\n {childWithAria}\n {/* Screen reader accessible tooltip text */}\n <span id={tooltipId} role=\"tooltip\" className=\"sr-only\">\n {tip}\n </span>\n </div>\n )\n}\n"],"names":["dTooltip","dTooltipTop","dTooltipBottom","dTooltipLeft","dTooltipRight","dTooltipNeutral","dTooltipPrimary","dTooltipSecondary","dTooltipAccent","dTooltipInfo","dTooltipSuccess","dTooltipWarning","dTooltipError","dTooltipOpen","Tooltip","children","tip","className","position","color","open","rest","tooltipId","useId","positionClasses","colorClasses","classes","childWithAria","React","jsxs","jsx"],"mappings":";;AAGA,MAAMA,IAAW,WACXC,IAAc,eACdC,IAAiB,kBACjBC,IAAe,gBACfC,IAAgB,iBAChBC,IAAkB,mBAClBC,IAAkB,mBAClBC,IAAoB,qBACpBC,IAAiB,kBACjBC,IAAe,gBACfC,IAAkB,mBAClBC,IAAkB,mBAClBC,IAAgB,iBAChBC,IAAe,gBAYRC,IAAkC,CAAC;AAAA,EAC9C,UAAAC;AAAA,EACA,KAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,UAAAC,IAAW;AAAA,EACX,OAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,GAAGC;AACL,MAAM;AACJ,QAAMC,IAAYC,EAAA,GAEZC,IAAkB;AAAA,IACtB,KAAKvB;AAAA,IACL,QAAQC;AAAA,IACR,MAAMC;AAAA,IACN,OAAOC;AAAA,EAAA,GAGHqB,IAAeN,IACjB;AAAA,IACE,SAASd;AAAA,IACT,SAASC;AAAA,IACT,WAAWC;AAAA,IACX,QAAQC;AAAA,IACR,MAAMC;AAAA,IACN,SAASC;AAAA,IACT,SAASC;AAAA,IACT,OAAOC;AAAA,EAAA,EACPO,CAAK,IACP,QAEEO,IAAU;AAAA,IACd1B;AAAA,IACAwB,EAAgBN,CAAQ;AAAA,IACxBO;AAAA,IACAL,KAAQP;AAAA,IACRI;AAAA,EAAA,EAEC,OAAO,OAAO,EACd,KAAK,GAAG,GAGLU,IAAgBC,EAAM,eAAeb,CAAQ,IAC/Ca,EAAM,aAAab,GAAiE;AAAA,IAClF,oBAAoBO;AAAA,EAAA,CACrB,IACDP;AAEJ,SACE,gBAAAc,EAAC,OAAA,EAAI,WAAWH,GAAS,YAAUV,GAAK,cAAYI,IAAO,SAAS,UAAW,GAAGC,GAC/E,UAAA;AAAA,IAAAM;AAAA,IAED,gBAAAG,EAAC,UAAK,IAAIR,GAAW,MAAK,WAAU,WAAU,WAC3C,UAAAN,EAAA,CACH;AAAA,EAAA,GACF;AAEJ;"}
|
|
@@ -4,12 +4,14 @@ export type TitleLevel = 1 | 2 | 3 | 4 | 5;
|
|
|
4
4
|
export interface TypographyProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
5
5
|
children: React.ReactNode;
|
|
6
6
|
size?: TypographySize;
|
|
7
|
+
'data-testid'?: string;
|
|
7
8
|
}
|
|
8
9
|
export interface TitleProps extends Omit<React.HTMLAttributes<HTMLHeadingElement>, 'title'> {
|
|
9
10
|
level?: TitleLevel;
|
|
10
11
|
children: React.ReactNode;
|
|
11
12
|
copyable?: boolean;
|
|
12
13
|
ellipsis?: boolean;
|
|
14
|
+
'data-testid'?: string;
|
|
13
15
|
}
|
|
14
16
|
export interface ParagraphProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
15
17
|
children: React.ReactNode;
|
|
@@ -21,6 +23,7 @@ export interface ParagraphProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
21
23
|
copyable?: boolean;
|
|
22
24
|
size?: TypographySize;
|
|
23
25
|
align?: 'left' | 'center' | 'right';
|
|
26
|
+
'data-testid'?: string;
|
|
24
27
|
}
|
|
25
28
|
export interface TextProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
26
29
|
children: React.ReactNode;
|
|
@@ -32,18 +35,20 @@ export interface TextProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
|
32
35
|
delete?: boolean;
|
|
33
36
|
type?: 'default' | 'secondary' | 'success' | 'warning' | 'error';
|
|
34
37
|
copyable?: boolean;
|
|
38
|
+
'data-testid'?: string;
|
|
35
39
|
}
|
|
36
40
|
export interface TypographyLinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
37
41
|
href?: string;
|
|
38
42
|
children: React.ReactNode;
|
|
39
43
|
external?: boolean;
|
|
40
44
|
size?: TypographySize;
|
|
45
|
+
'data-testid'?: string;
|
|
41
46
|
}
|
|
42
|
-
declare function TypographyRoot({ children, size, className, ...rest }: TypographyProps): import("react/jsx-runtime").JSX.Element;
|
|
43
|
-
declare function Title({ level, children, copyable, ellipsis, className, id, ...rest }: TitleProps): import("react/jsx-runtime").JSX.Element;
|
|
44
|
-
declare function Paragraph({ children, ellipsis, copyable, size, align, className, ...rest }: ParagraphProps): import("react/jsx-runtime").JSX.Element;
|
|
45
|
-
declare function Text({ children, code, mark, strong, italic, underline, delete: del, type, copyable, className, ...rest }: TextProps): import("react/jsx-runtime").JSX.Element;
|
|
46
|
-
declare function Link({ href, children, target, external, size, className, ...rest }: TypographyLinkProps): import("react/jsx-runtime").JSX.Element;
|
|
47
|
+
declare function TypographyRoot({ children, size, className, 'data-testid': testId, ...rest }: TypographyProps): import("react/jsx-runtime").JSX.Element;
|
|
48
|
+
declare function Title({ level, children, copyable, ellipsis, className, id, 'data-testid': testId, ...rest }: TitleProps): import("react/jsx-runtime").JSX.Element;
|
|
49
|
+
declare function Paragraph({ children, ellipsis, copyable, size, align, className, 'data-testid': testId, ...rest }: ParagraphProps): import("react/jsx-runtime").JSX.Element;
|
|
50
|
+
declare function Text({ children, code, mark, strong, italic, underline, delete: del, type, copyable, className, 'data-testid': testId, ...rest }: TextProps): import("react/jsx-runtime").JSX.Element;
|
|
51
|
+
declare function Link({ href, children, target, external, size, className, 'data-testid': testId, ...rest }: TypographyLinkProps): import("react/jsx-runtime").JSX.Element;
|
|
47
52
|
export declare const Typography: typeof TypographyRoot & {
|
|
48
53
|
Title: typeof Title;
|
|
49
54
|
Paragraph: typeof Paragraph;
|
|
@@ -1,36 +1,37 @@
|
|
|
1
|
-
import { jsx as t, jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
const
|
|
4
|
-
function
|
|
5
|
-
const [
|
|
1
|
+
import { jsx as t, jsxs as g, Fragment as w } from "react/jsx-runtime";
|
|
2
|
+
import { useState as C } from "react";
|
|
3
|
+
const $ = "btn", k = "btn-ghost", B = "btn-xs", T = "link", j = "link-primary";
|
|
4
|
+
function y({ text: a, "data-testid": e }) {
|
|
5
|
+
const [d, o] = C(!1);
|
|
6
6
|
return /* @__PURE__ */ t(
|
|
7
7
|
"button",
|
|
8
8
|
{
|
|
9
9
|
onClick: async () => {
|
|
10
10
|
try {
|
|
11
|
-
await navigator.clipboard.writeText(
|
|
12
|
-
} catch (
|
|
13
|
-
console.error("Failed to copy:",
|
|
11
|
+
await navigator.clipboard.writeText(a), o(!0), setTimeout(() => o(!1), 2e3);
|
|
12
|
+
} catch (x) {
|
|
13
|
+
console.error("Failed to copy:", x);
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
|
-
className: `${
|
|
16
|
+
className: `${$} ${k} ${B} ml-2 opacity-0 group-hover:opacity-100 transition-opacity`,
|
|
17
17
|
title: "Copy to clipboard",
|
|
18
|
-
|
|
18
|
+
"data-testid": e,
|
|
19
|
+
children: d ? /* @__PURE__ */ t("svg", { className: "w-4 h-4", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ t(
|
|
19
20
|
"path",
|
|
20
21
|
{
|
|
21
22
|
fillRule: "evenodd",
|
|
22
23
|
d: "M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",
|
|
23
24
|
clipRule: "evenodd"
|
|
24
25
|
}
|
|
25
|
-
) }) : /* @__PURE__ */
|
|
26
|
+
) }) : /* @__PURE__ */ g("svg", { className: "w-4 h-4", fill: "currentColor", viewBox: "0 0 20 20", children: [
|
|
26
27
|
/* @__PURE__ */ t("path", { d: "M8 3a1 1 0 011-1h2a1 1 0 110 2H9a1 1 0 01-1-1z" }),
|
|
27
28
|
/* @__PURE__ */ t("path", { d: "M6 3a2 2 0 00-2 2v11a2 2 0 002 2h8a2 2 0 002-2V5a2 2 0 00-2-2 3 3 0 01-3 3H9a3 3 0 01-3-3z" })
|
|
28
29
|
] })
|
|
29
30
|
}
|
|
30
31
|
);
|
|
31
32
|
}
|
|
32
|
-
function
|
|
33
|
-
const
|
|
33
|
+
function M({ children: a, size: e = "base", className: d = "", "data-testid": o, ...l }) {
|
|
34
|
+
const s = [
|
|
34
35
|
// Prose classes (only apply if @tailwindcss/typography is installed)
|
|
35
36
|
"prose dark:prose-invert max-w-none",
|
|
36
37
|
// Fallback styles (always apply)
|
|
@@ -42,37 +43,37 @@ function j({ children: n, size: e = "base", className: c = "", ...o }) {
|
|
|
42
43
|
xl: "prose-xl text-xl",
|
|
43
44
|
"2xl": "prose-2xl text-2xl"
|
|
44
45
|
}[e],
|
|
45
|
-
|
|
46
|
+
d
|
|
46
47
|
].filter(Boolean).join(" ");
|
|
47
|
-
return /* @__PURE__ */ t("div", { className:
|
|
48
|
+
return /* @__PURE__ */ t("div", { className: s, "data-testid": o, ...l, children: a });
|
|
48
49
|
}
|
|
49
|
-
function
|
|
50
|
-
const
|
|
50
|
+
function L({ level: a = 1, children: e, copyable: d, ellipsis: o, className: l = "", id: x, "data-testid": s, ...i }) {
|
|
51
|
+
const c = typeof e == "string" ? e : "", r = x || (c ? c.toLowerCase().replace(/\s+/g, "-") : void 0), h = (n) => s ? `${s}-${n}` : void 0, u = {
|
|
51
52
|
1: "text-4xl font-bold mb-4",
|
|
52
53
|
2: "text-3xl font-bold mb-3",
|
|
53
54
|
3: "text-2xl font-semibold mb-3",
|
|
54
55
|
4: "text-xl font-semibold mb-2",
|
|
55
56
|
5: "text-lg font-semibold mb-2"
|
|
56
|
-
},
|
|
57
|
+
}, f = o ? "truncate" : "", p = `group ${u[a]} ${f} ${l}`.trim(), m = /* @__PURE__ */ g(w, { children: [
|
|
57
58
|
e,
|
|
58
|
-
|
|
59
|
+
d && /* @__PURE__ */ t(y, { text: c, "data-testid": h("copy") })
|
|
59
60
|
] });
|
|
60
|
-
switch (
|
|
61
|
+
switch (a) {
|
|
61
62
|
case 1:
|
|
62
|
-
return /* @__PURE__ */ t("h1", { id:
|
|
63
|
+
return /* @__PURE__ */ t("h1", { id: r, className: p, "data-testid": s, ...i, children: m });
|
|
63
64
|
case 2:
|
|
64
|
-
return /* @__PURE__ */ t("h2", { id:
|
|
65
|
+
return /* @__PURE__ */ t("h2", { id: r, className: p, "data-testid": s, ...i, children: m });
|
|
65
66
|
case 3:
|
|
66
|
-
return /* @__PURE__ */ t("h3", { id:
|
|
67
|
+
return /* @__PURE__ */ t("h3", { id: r, className: p, "data-testid": s, ...i, children: m });
|
|
67
68
|
case 4:
|
|
68
|
-
return /* @__PURE__ */ t("h4", { id:
|
|
69
|
+
return /* @__PURE__ */ t("h4", { id: r, className: p, "data-testid": s, ...i, children: m });
|
|
69
70
|
case 5:
|
|
70
|
-
return /* @__PURE__ */ t("h5", { id:
|
|
71
|
+
return /* @__PURE__ */ t("h5", { id: r, className: p, "data-testid": s, ...i, children: m });
|
|
71
72
|
default:
|
|
72
|
-
return /* @__PURE__ */ t("h1", { id:
|
|
73
|
+
return /* @__PURE__ */ t("h1", { id: r, className: p, "data-testid": s, ...i, children: m });
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
|
-
const
|
|
76
|
+
const E = {
|
|
76
77
|
1: "line-clamp-1",
|
|
77
78
|
2: "line-clamp-2",
|
|
78
79
|
3: "line-clamp-3",
|
|
@@ -80,88 +81,90 @@ const M = {
|
|
|
80
81
|
5: "line-clamp-5",
|
|
81
82
|
6: "line-clamp-6"
|
|
82
83
|
};
|
|
83
|
-
function
|
|
84
|
-
const [
|
|
84
|
+
function H({ children: a, ellipsis: e, copyable: d, size: o, align: l, className: x = "", "data-testid": s, ...i }) {
|
|
85
|
+
const [c, r] = C(!1), h = typeof a == "string" ? a : "", u = (N) => s ? `${s}-${N}` : void 0, f = typeof e == "object", p = f && e.rows || 3, m = f ? e.expandable : !1, n = Math.min(Math.max(p, 1), 6), b = [
|
|
85
86
|
"group",
|
|
86
87
|
"mb-4",
|
|
87
|
-
e && !
|
|
88
|
+
e && !c ? E[n] : "",
|
|
88
89
|
o === "sm" && "text-sm",
|
|
89
90
|
o === "base" && "text-base",
|
|
90
91
|
o === "lg" && "text-lg",
|
|
91
92
|
o === "xl" && "text-xl",
|
|
92
93
|
o === "2xl" && "text-2xl",
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
l === "left" && "text-left",
|
|
95
|
+
l === "center" && "text-center",
|
|
96
|
+
l === "right" && "text-right",
|
|
97
|
+
x
|
|
97
98
|
].filter(Boolean).join(" ");
|
|
98
|
-
return /* @__PURE__ */
|
|
99
|
-
/* @__PURE__ */
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
return /* @__PURE__ */ g("div", { "data-testid": s, ...i, children: [
|
|
100
|
+
/* @__PURE__ */ g("p", { className: b, "data-testid": u("text"), children: [
|
|
101
|
+
a,
|
|
102
|
+
d && /* @__PURE__ */ t(y, { text: h, "data-testid": u("copy") })
|
|
102
103
|
] }),
|
|
103
|
-
|
|
104
|
+
m && e && /* @__PURE__ */ t(
|
|
104
105
|
"button",
|
|
105
106
|
{
|
|
106
107
|
onClick: () => {
|
|
107
|
-
|
|
108
|
+
r(!c), f && e.onExpand && e.onExpand();
|
|
108
109
|
},
|
|
109
110
|
className: "text-primary text-sm hover:underline",
|
|
110
|
-
children:
|
|
111
|
+
children: c ? "Show less" : "Show more"
|
|
111
112
|
}
|
|
112
113
|
)
|
|
113
114
|
] });
|
|
114
115
|
}
|
|
115
|
-
function
|
|
116
|
-
children:
|
|
116
|
+
function R({
|
|
117
|
+
children: a,
|
|
117
118
|
code: e,
|
|
118
|
-
mark:
|
|
119
|
+
mark: d,
|
|
119
120
|
strong: o,
|
|
120
|
-
italic:
|
|
121
|
-
underline:
|
|
122
|
-
delete:
|
|
123
|
-
type:
|
|
124
|
-
copyable:
|
|
125
|
-
className:
|
|
126
|
-
|
|
121
|
+
italic: l,
|
|
122
|
+
underline: x,
|
|
123
|
+
delete: s,
|
|
124
|
+
type: i = "default",
|
|
125
|
+
copyable: c,
|
|
126
|
+
className: r = "",
|
|
127
|
+
"data-testid": h,
|
|
128
|
+
...u
|
|
127
129
|
}) {
|
|
128
|
-
const
|
|
130
|
+
const f = typeof a == "string" ? a : "", p = (b) => h ? `${h}-${b}` : void 0, m = {
|
|
129
131
|
default: "",
|
|
130
132
|
secondary: "text-base-content/70",
|
|
131
133
|
success: "text-success",
|
|
132
134
|
warning: "text-warning",
|
|
133
135
|
error: "text-error"
|
|
134
136
|
};
|
|
135
|
-
let
|
|
136
|
-
e && (
|
|
137
|
-
const
|
|
138
|
-
return /* @__PURE__ */
|
|
139
|
-
|
|
140
|
-
|
|
137
|
+
let n = a;
|
|
138
|
+
e && (n = /* @__PURE__ */ t("code", { className: "px-1.5 py-0.5 bg-base-200 rounded text-sm font-mono", children: n })), d && (n = /* @__PURE__ */ t("mark", { className: "bg-warning/30 px-1", children: n })), o && (n = /* @__PURE__ */ t("strong", { className: "font-bold", children: n })), l && (n = /* @__PURE__ */ t("em", { className: "italic", children: n })), x && (n = /* @__PURE__ */ t("u", { className: "underline", children: n })), s && (n = /* @__PURE__ */ t("del", { className: "line-through opacity-70", children: n }));
|
|
139
|
+
const v = `group inline ${m[i]} ${r}`.trim();
|
|
140
|
+
return /* @__PURE__ */ g("span", { className: v, "data-testid": h, ...u, children: [
|
|
141
|
+
n,
|
|
142
|
+
c && /* @__PURE__ */ t(y, { text: f, "data-testid": p("copy") })
|
|
141
143
|
] });
|
|
142
144
|
}
|
|
143
|
-
function
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
145
|
+
function V({ href: a = "#", children: e, target: d, external: o, size: l, className: x = "", "data-testid": s, ...i }) {
|
|
146
|
+
const c = o || a && a.startsWith("http"), r = d || (c ? "_blank" : void 0), h = c ? "noopener noreferrer" : void 0, u = [
|
|
147
|
+
T,
|
|
148
|
+
j,
|
|
149
|
+
l === "sm" && "text-sm",
|
|
150
|
+
l === "base" && "text-base",
|
|
151
|
+
l === "lg" && "text-lg",
|
|
152
|
+
l === "xl" && "text-xl",
|
|
153
|
+
l === "2xl" && "text-2xl",
|
|
154
|
+
x
|
|
153
155
|
].filter(Boolean).join(" ");
|
|
154
|
-
return /* @__PURE__ */
|
|
156
|
+
return /* @__PURE__ */ g(
|
|
155
157
|
"a",
|
|
156
158
|
{
|
|
157
|
-
href:
|
|
158
|
-
target:
|
|
159
|
+
href: a,
|
|
160
|
+
target: r,
|
|
159
161
|
rel: h,
|
|
160
|
-
className:
|
|
161
|
-
|
|
162
|
+
className: u,
|
|
163
|
+
"data-testid": s,
|
|
164
|
+
...i,
|
|
162
165
|
children: [
|
|
163
166
|
e,
|
|
164
|
-
|
|
167
|
+
c && /* @__PURE__ */ g("svg", { className: "w-3 h-3 inline-block ml-1", fill: "currentColor", viewBox: "0 0 20 20", children: [
|
|
165
168
|
/* @__PURE__ */ t("path", { d: "M11 3a1 1 0 100 2h2.586l-6.293 6.293a1 1 0 101.414 1.414L15 6.414V9a1 1 0 102 0V4a1 1 0 00-1-1h-5z" }),
|
|
166
169
|
/* @__PURE__ */ t("path", { d: "M5 5a2 2 0 00-2 2v8a2 2 0 002 2h8a2 2 0 002-2v-3a1 1 0 10-2 0v3H5V7h3a1 1 0 000-2H5z" })
|
|
167
170
|
] })
|
|
@@ -169,14 +172,14 @@ function E({ href: n = "#", children: e, target: c, external: o, size: s, classN
|
|
|
169
172
|
}
|
|
170
173
|
);
|
|
171
174
|
}
|
|
172
|
-
const
|
|
173
|
-
Title:
|
|
174
|
-
Paragraph:
|
|
175
|
-
Text:
|
|
176
|
-
Link:
|
|
175
|
+
const O = Object.assign(M, {
|
|
176
|
+
Title: L,
|
|
177
|
+
Paragraph: H,
|
|
178
|
+
Text: R,
|
|
179
|
+
Link: V
|
|
177
180
|
});
|
|
178
181
|
export {
|
|
179
|
-
|
|
180
|
-
|
|
182
|
+
O as Typography,
|
|
183
|
+
O as default
|
|
181
184
|
};
|
|
182
185
|
//# sourceMappingURL=Typography.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Typography.js","sources":["../../src/components/Typography.tsx"],"sourcesContent":["import React, { useState } from 'react'\n\n// DaisyUI classes\nconst dBtn = 'btn'\nconst dBtnGhost = 'btn-ghost'\nconst dBtnXs = 'btn-xs'\nconst dLink = 'link'\nconst dLinkPrimary = 'link-primary'\n\nexport type TypographySize = 'sm' | 'base' | 'lg' | 'xl' | '2xl'\nexport type TitleLevel = 1 | 2 | 3 | 4 | 5\n\nexport interface TypographyProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode\n size?: TypographySize\n}\n\nexport interface TitleProps extends Omit<React.HTMLAttributes<HTMLHeadingElement>, 'title'> {\n level?: TitleLevel\n children: React.ReactNode\n copyable?: boolean\n ellipsis?: boolean\n}\n\nexport interface ParagraphProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode\n ellipsis?: boolean | { rows?: number; expandable?: boolean; onExpand?: () => void }\n copyable?: boolean\n size?: TypographySize\n align?: 'left' | 'center' | 'right'\n}\n\nexport interface TextProps extends React.HTMLAttributes<HTMLSpanElement> {\n children: React.ReactNode\n code?: boolean\n mark?: boolean\n strong?: boolean\n italic?: boolean\n underline?: boolean\n delete?: boolean\n type?: 'default' | 'secondary' | 'success' | 'warning' | 'error'\n copyable?: boolean\n}\n\nexport interface TypographyLinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {\n href?: string\n children: React.ReactNode\n external?: boolean\n size?: TypographySize\n}\n\nfunction CopyButton({ text }: { text: string }) {\n const [copied, setCopied] = useState(false)\n\n const handleCopy = async () => {\n try {\n await navigator.clipboard.writeText(text)\n setCopied(true)\n setTimeout(() => setCopied(false), 2000)\n } catch (err) {\n console.error('Failed to copy:', err)\n }\n }\n\n return (\n <button\n onClick={handleCopy}\n className={`${dBtn} ${dBtnGhost} ${dBtnXs} ml-2 opacity-0 group-hover:opacity-100 transition-opacity`}\n title=\"Copy to clipboard\"\n >\n {copied ? (\n <svg className=\"w-4 h-4\" fill=\"currentColor\" viewBox=\"0 0 20 20\">\n <path\n fillRule=\"evenodd\"\n d=\"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z\"\n clipRule=\"evenodd\"\n />\n </svg>\n ) : (\n <svg className=\"w-4 h-4\" fill=\"currentColor\" viewBox=\"0 0 20 20\">\n <path d=\"M8 3a1 1 0 011-1h2a1 1 0 110 2H9a1 1 0 01-1-1z\" />\n <path d=\"M6 3a2 2 0 00-2 2v11a2 2 0 002 2h8a2 2 0 002-2V5a2 2 0 00-2-2 3 3 0 01-3 3H9a3 3 0 01-3-3z\" />\n </svg>\n )}\n </button>\n )\n}\n\nfunction TypographyRoot({ children, size = 'base', className = '', ...rest }: TypographyProps) {\n const sizeClasses = {\n sm: 'prose-sm text-sm',\n base: 'prose-base text-base',\n lg: 'prose-lg text-lg',\n xl: 'prose-xl text-xl',\n '2xl': 'prose-2xl text-2xl',\n }\n\n const classes = [\n // Prose classes (only apply if @tailwindcss/typography is installed)\n 'prose dark:prose-invert max-w-none',\n // Fallback styles (always apply)\n 'text-base-content leading-relaxed',\n sizeClasses[size],\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n return <div className={classes} {...rest}>{children}</div>\n}\n\nfunction Title({ level = 1, children, copyable, ellipsis, className = '', id, ...rest }: TitleProps) {\n const textContent = typeof children === 'string' ? children : ''\n const generatedId = id || (textContent ? textContent.toLowerCase().replace(/\\s+/g, '-') : undefined)\n\n const levelClasses = {\n 1: 'text-4xl font-bold mb-4',\n 2: 'text-3xl font-bold mb-3',\n 3: 'text-2xl font-semibold mb-3',\n 4: 'text-xl font-semibold mb-2',\n 5: 'text-lg font-semibold mb-2',\n }\n\n const ellipsisClass = ellipsis ? 'truncate' : ''\n const classes = `group ${levelClasses[level]} ${ellipsisClass} ${className}`.trim()\n\n const content = (\n <>\n {children}\n {copyable && <CopyButton text={textContent} />}\n </>\n )\n\n switch (level) {\n case 1:\n return <h1 id={generatedId} className={classes} {...rest}>{content}</h1>\n case 2:\n return <h2 id={generatedId} className={classes} {...rest}>{content}</h2>\n case 3:\n return <h3 id={generatedId} className={classes} {...rest}>{content}</h3>\n case 4:\n return <h4 id={generatedId} className={classes} {...rest}>{content}</h4>\n case 5:\n return <h5 id={generatedId} className={classes} {...rest}>{content}</h5>\n default:\n return <h1 id={generatedId} className={classes} {...rest}>{content}</h1>\n }\n}\n\nconst lineClampClasses = {\n 1: 'line-clamp-1',\n 2: 'line-clamp-2',\n 3: 'line-clamp-3',\n 4: 'line-clamp-4',\n 5: 'line-clamp-5',\n 6: 'line-clamp-6',\n} as const\n\nfunction Paragraph({ children, ellipsis, copyable, size, align, className = '', ...rest }: ParagraphProps) {\n const [expanded, setExpanded] = useState(false)\n const textContent = typeof children === 'string' ? children : ''\n\n const isEllipsisObject = typeof ellipsis === 'object'\n const rows = isEllipsisObject ? ellipsis.rows || 3 : 3\n const expandable = isEllipsisObject ? ellipsis.expandable : false\n\n const clampedRows = Math.min(Math.max(rows, 1), 6) as 1 | 2 | 3 | 4 | 5 | 6\n const ellipsisClass =\n ellipsis && !expanded ? lineClampClasses[clampedRows] : ''\n\n const classes = [\n 'group',\n 'mb-4',\n ellipsisClass,\n size === 'sm' && 'text-sm',\n size === 'base' && 'text-base',\n size === 'lg' && 'text-lg',\n size === 'xl' && 'text-xl',\n size === '2xl' && 'text-2xl',\n align === 'left' && 'text-left',\n align === 'center' && 'text-center',\n align === 'right' && 'text-right',\n className,\n ].filter(Boolean).join(' ')\n\n return (\n <div {...rest}>\n <p className={classes}>\n {children}\n {copyable && <CopyButton text={textContent} />}\n </p>\n {expandable && ellipsis && (\n <button\n onClick={() => {\n setExpanded(!expanded)\n if (isEllipsisObject && ellipsis.onExpand) {\n ellipsis.onExpand()\n }\n }}\n className=\"text-primary text-sm hover:underline\"\n >\n {expanded ? 'Show less' : 'Show more'}\n </button>\n )}\n </div>\n )\n}\n\nfunction Text({\n children,\n code,\n mark,\n strong,\n italic,\n underline,\n delete: del,\n type = 'default',\n copyable,\n className = '',\n ...rest\n}: TextProps) {\n const textContent = typeof children === 'string' ? children : ''\n\n const typeClasses = {\n default: '',\n secondary: 'text-base-content/70',\n success: 'text-success',\n warning: 'text-warning',\n error: 'text-error',\n }\n\n let content = children\n\n if (code) {\n content = (\n <code className=\"px-1.5 py-0.5 bg-base-200 rounded text-sm font-mono\">{content}</code>\n )\n }\n\n if (mark) {\n content = <mark className=\"bg-warning/30 px-1\">{content}</mark>\n }\n\n if (strong) {\n content = <strong className=\"font-bold\">{content}</strong>\n }\n\n if (italic) {\n content = <em className=\"italic\">{content}</em>\n }\n\n if (underline) {\n content = <u className=\"underline\">{content}</u>\n }\n\n if (del) {\n content = <del className=\"line-through opacity-70\">{content}</del>\n }\n\n const classes = `group inline ${typeClasses[type]} ${className}`.trim()\n\n return (\n <span className={classes} {...rest}>\n {content}\n {copyable && <CopyButton text={textContent} />}\n </span>\n )\n}\n\nfunction Link({ href = '#', children, target, external, size, className = '', ...rest }: TypographyLinkProps) {\n const isExternal = external || (href && href.startsWith('http'))\n const linkTarget = target || (isExternal ? '_blank' : undefined)\n const rel = isExternal ? 'noopener noreferrer' : undefined\n\n const classes = [\n dLink,\n dLinkPrimary,\n size === 'sm' && 'text-sm',\n size === 'base' && 'text-base',\n size === 'lg' && 'text-lg',\n size === 'xl' && 'text-xl',\n size === '2xl' && 'text-2xl',\n className,\n ].filter(Boolean).join(' ')\n\n return (\n <a\n href={href}\n target={linkTarget}\n rel={rel}\n className={classes}\n {...rest}\n >\n {children}\n {isExternal && (\n <svg className=\"w-3 h-3 inline-block ml-1\" fill=\"currentColor\" viewBox=\"0 0 20 20\">\n <path d=\"M11 3a1 1 0 100 2h2.586l-6.293 6.293a1 1 0 101.414 1.414L15 6.414V9a1 1 0 102 0V4a1 1 0 00-1-1h-5z\" />\n <path d=\"M5 5a2 2 0 00-2 2v8a2 2 0 002 2h8a2 2 0 002-2v-3a1 1 0 10-2 0v3H5V7h3a1 1 0 000-2H5z\" />\n </svg>\n )}\n </a>\n )\n}\n\nexport const Typography = Object.assign(TypographyRoot, {\n Title,\n Paragraph,\n Text,\n Link,\n})\n\nexport default Typography\n"],"names":["dBtn","dBtnGhost","dBtnXs","dLink","dLinkPrimary","CopyButton","text","copied","setCopied","useState","jsx","err","jsxs","TypographyRoot","children","size","className","rest","classes","Title","level","copyable","ellipsis","id","textContent","generatedId","levelClasses","ellipsisClass","content","Fragment","lineClampClasses","Paragraph","align","expanded","setExpanded","isEllipsisObject","rows","expandable","clampedRows","Text","code","mark","strong","italic","underline","del","type","typeClasses","Link","href","target","external","isExternal","linkTarget","rel","Typography"],"mappings":";;AAGA,MAAMA,IAAO,OACPC,IAAY,aACZC,IAAS,UACTC,IAAQ,QACRC,IAAe;AA4CrB,SAASC,EAAW,EAAE,MAAAC,KAA0B;AAC9C,QAAM,CAACC,GAAQC,CAAS,IAAIC,EAAS,EAAK;AAY1C,SACE,gBAAAC;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,SAZe,YAAY;AAC7B,YAAI;AACF,gBAAM,UAAU,UAAU,UAAUJ,CAAI,GACxCE,EAAU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nC,GAAU,QAAAoC,GAAQ,UAAAC,GAAU,MAAApC,GAAM,WAAAC,IAAY,IAAI,GAAGC,EAAA,GAA6B;AAC5G,QAAMmC,IAAaD,KAAaF,KAAQA,EAAK,WAAW,MAAM,GACxDI,IAAaH,MAAWE,IAAa,WAAW,SAChDE,IAAMF,IAAa,wBAAwB,QAE3ClC,IAAU;AAAA,IACdf;AAAA,IACAC;AAAA,IACAW,MAAS,QAAQ;AAAA,IACjBA,MAAS,UAAU;AAAA,IACnBA,MAAS,QAAQ;AAAA,IACjBA,MAAS,QAAQ;AAAA,IACjBA,MAAS,SAAS;AAAA,IAClBC;AAAA,EAAA,EACA,OAAO,OAAO,EAAE,KAAK,GAAG;AAE1B,SACE,gBAAAJ;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,MAAAqC;AAAA,MACA,QAAQI;AAAA,MACR,KAAAC;AAAA,MACA,WAAWpC;AAAA,MACV,GAAGD;AAAA,MAEH,UAAA;AAAA,QAAAH;AAAA,QACAsC,uBACE,OAAA,EAAI,WAAU,6BAA4B,MAAK,gBAAe,SAAQ,aACrE,UAAA;AAAA,UAAA,gBAAA1C,EAAC,QAAA,EAAK,GAAE,qGAAA,CAAqG;AAAA,UAC7G,gBAAAA,EAAC,QAAA,EAAK,GAAE,uFAAA,CAAuF;AAAA,QAAA,EAAA,CACjG;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIR;AAEO,MAAM6C,IAAa,OAAO,OAAO1C,GAAgB;AAAA,EACtD,OAAAM;AAAA,EACA,WAAAY;AAAA,EACA,MAAAQ;AAAA,EACA,MAAAS;AACF,CAAC;"}
|
|
1
|
+
{"version":3,"file":"Typography.js","sources":["../../src/components/Typography.tsx"],"sourcesContent":["import React, { useState } from 'react'\n\n// DaisyUI classes\nconst dBtn = 'btn'\nconst dBtnGhost = 'btn-ghost'\nconst dBtnXs = 'btn-xs'\nconst dLink = 'link'\nconst dLinkPrimary = 'link-primary'\n\nexport type TypographySize = 'sm' | 'base' | 'lg' | 'xl' | '2xl'\nexport type TitleLevel = 1 | 2 | 3 | 4 | 5\n\nexport interface TypographyProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode\n size?: TypographySize\n 'data-testid'?: string\n}\n\nexport interface TitleProps extends Omit<React.HTMLAttributes<HTMLHeadingElement>, 'title'> {\n level?: TitleLevel\n children: React.ReactNode\n copyable?: boolean\n ellipsis?: boolean\n 'data-testid'?: string\n}\n\nexport interface ParagraphProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode\n ellipsis?: boolean | { rows?: number; expandable?: boolean; onExpand?: () => void }\n copyable?: boolean\n size?: TypographySize\n align?: 'left' | 'center' | 'right'\n 'data-testid'?: string\n}\n\nexport interface TextProps extends React.HTMLAttributes<HTMLSpanElement> {\n children: React.ReactNode\n code?: boolean\n mark?: boolean\n strong?: boolean\n italic?: boolean\n underline?: boolean\n delete?: boolean\n type?: 'default' | 'secondary' | 'success' | 'warning' | 'error'\n copyable?: boolean\n 'data-testid'?: string\n}\n\nexport interface TypographyLinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {\n href?: string\n children: React.ReactNode\n external?: boolean\n size?: TypographySize\n 'data-testid'?: string\n}\n\nfunction CopyButton({ text, 'data-testid': testId }: { text: string; 'data-testid'?: string }) {\n const [copied, setCopied] = useState(false)\n\n const handleCopy = async () => {\n try {\n await navigator.clipboard.writeText(text)\n setCopied(true)\n setTimeout(() => setCopied(false), 2000)\n } catch (err) {\n console.error('Failed to copy:', err)\n }\n }\n\n return (\n <button\n onClick={handleCopy}\n className={`${dBtn} ${dBtnGhost} ${dBtnXs} ml-2 opacity-0 group-hover:opacity-100 transition-opacity`}\n title=\"Copy to clipboard\"\n data-testid={testId}\n >\n {copied ? (\n <svg className=\"w-4 h-4\" fill=\"currentColor\" viewBox=\"0 0 20 20\">\n <path\n fillRule=\"evenodd\"\n d=\"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z\"\n clipRule=\"evenodd\"\n />\n </svg>\n ) : (\n <svg className=\"w-4 h-4\" fill=\"currentColor\" viewBox=\"0 0 20 20\">\n <path d=\"M8 3a1 1 0 011-1h2a1 1 0 110 2H9a1 1 0 01-1-1z\" />\n <path d=\"M6 3a2 2 0 00-2 2v11a2 2 0 002 2h8a2 2 0 002-2V5a2 2 0 00-2-2 3 3 0 01-3 3H9a3 3 0 01-3-3z\" />\n </svg>\n )}\n </button>\n )\n}\n\nfunction TypographyRoot({ children, size = 'base', className = '', 'data-testid': testId, ...rest }: TypographyProps) {\n const sizeClasses = {\n sm: 'prose-sm text-sm',\n base: 'prose-base text-base',\n lg: 'prose-lg text-lg',\n xl: 'prose-xl text-xl',\n '2xl': 'prose-2xl text-2xl',\n }\n\n const classes = [\n // Prose classes (only apply if @tailwindcss/typography is installed)\n 'prose dark:prose-invert max-w-none',\n // Fallback styles (always apply)\n 'text-base-content leading-relaxed',\n sizeClasses[size],\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n return <div className={classes} data-testid={testId} {...rest}>{children}</div>\n}\n\nfunction Title({ level = 1, children, copyable, ellipsis, className = '', id, 'data-testid': testId, ...rest }: TitleProps) {\n const textContent = typeof children === 'string' ? children : ''\n const generatedId = id || (textContent ? textContent.toLowerCase().replace(/\\s+/g, '-') : undefined)\n const getTestId = (suffix: string) => (testId ? `${testId}-${suffix}` : undefined)\n\n const levelClasses = {\n 1: 'text-4xl font-bold mb-4',\n 2: 'text-3xl font-bold mb-3',\n 3: 'text-2xl font-semibold mb-3',\n 4: 'text-xl font-semibold mb-2',\n 5: 'text-lg font-semibold mb-2',\n }\n\n const ellipsisClass = ellipsis ? 'truncate' : ''\n const classes = `group ${levelClasses[level]} ${ellipsisClass} ${className}`.trim()\n\n const content = (\n <>\n {children}\n {copyable && <CopyButton text={textContent} data-testid={getTestId('copy')} />}\n </>\n )\n\n switch (level) {\n case 1:\n return <h1 id={generatedId} className={classes} data-testid={testId} {...rest}>{content}</h1>\n case 2:\n return <h2 id={generatedId} className={classes} data-testid={testId} {...rest}>{content}</h2>\n case 3:\n return <h3 id={generatedId} className={classes} data-testid={testId} {...rest}>{content}</h3>\n case 4:\n return <h4 id={generatedId} className={classes} data-testid={testId} {...rest}>{content}</h4>\n case 5:\n return <h5 id={generatedId} className={classes} data-testid={testId} {...rest}>{content}</h5>\n default:\n return <h1 id={generatedId} className={classes} data-testid={testId} {...rest}>{content}</h1>\n }\n}\n\nconst lineClampClasses = {\n 1: 'line-clamp-1',\n 2: 'line-clamp-2',\n 3: 'line-clamp-3',\n 4: 'line-clamp-4',\n 5: 'line-clamp-5',\n 6: 'line-clamp-6',\n} as const\n\nfunction Paragraph({ children, ellipsis, copyable, size, align, className = '', 'data-testid': testId, ...rest }: ParagraphProps) {\n const [expanded, setExpanded] = useState(false)\n const textContent = typeof children === 'string' ? children : ''\n const getTestId = (suffix: string) => (testId ? `${testId}-${suffix}` : undefined)\n\n const isEllipsisObject = typeof ellipsis === 'object'\n const rows = isEllipsisObject ? ellipsis.rows || 3 : 3\n const expandable = isEllipsisObject ? ellipsis.expandable : false\n\n const clampedRows = Math.min(Math.max(rows, 1), 6) as 1 | 2 | 3 | 4 | 5 | 6\n const ellipsisClass =\n ellipsis && !expanded ? lineClampClasses[clampedRows] : ''\n\n const classes = [\n 'group',\n 'mb-4',\n ellipsisClass,\n size === 'sm' && 'text-sm',\n size === 'base' && 'text-base',\n size === 'lg' && 'text-lg',\n size === 'xl' && 'text-xl',\n size === '2xl' && 'text-2xl',\n align === 'left' && 'text-left',\n align === 'center' && 'text-center',\n align === 'right' && 'text-right',\n className,\n ].filter(Boolean).join(' ')\n\n return (\n <div data-testid={testId} {...rest}>\n <p className={classes} data-testid={getTestId('text')}>\n {children}\n {copyable && <CopyButton text={textContent} data-testid={getTestId('copy')} />}\n </p>\n {expandable && ellipsis && (\n <button\n onClick={() => {\n setExpanded(!expanded)\n if (isEllipsisObject && ellipsis.onExpand) {\n ellipsis.onExpand()\n }\n }}\n className=\"text-primary text-sm hover:underline\"\n >\n {expanded ? 'Show less' : 'Show more'}\n </button>\n )}\n </div>\n )\n}\n\nfunction Text({\n children,\n code,\n mark,\n strong,\n italic,\n underline,\n delete: del,\n type = 'default',\n copyable,\n className = '',\n 'data-testid': testId,\n ...rest\n}: TextProps) {\n const textContent = typeof children === 'string' ? children : ''\n const getTestId = (suffix: string) => (testId ? `${testId}-${suffix}` : undefined)\n\n const typeClasses = {\n default: '',\n secondary: 'text-base-content/70',\n success: 'text-success',\n warning: 'text-warning',\n error: 'text-error',\n }\n\n let content = children\n\n if (code) {\n content = (\n <code className=\"px-1.5 py-0.5 bg-base-200 rounded text-sm font-mono\">{content}</code>\n )\n }\n\n if (mark) {\n content = <mark className=\"bg-warning/30 px-1\">{content}</mark>\n }\n\n if (strong) {\n content = <strong className=\"font-bold\">{content}</strong>\n }\n\n if (italic) {\n content = <em className=\"italic\">{content}</em>\n }\n\n if (underline) {\n content = <u className=\"underline\">{content}</u>\n }\n\n if (del) {\n content = <del className=\"line-through opacity-70\">{content}</del>\n }\n\n const classes = `group inline ${typeClasses[type]} ${className}`.trim()\n\n return (\n <span className={classes} data-testid={testId} {...rest}>\n {content}\n {copyable && <CopyButton text={textContent} data-testid={getTestId('copy')} />}\n </span>\n )\n}\n\nfunction Link({ href = '#', children, target, external, size, className = '', 'data-testid': testId, ...rest }: TypographyLinkProps) {\n const isExternal = external || (href && href.startsWith('http'))\n const linkTarget = target || (isExternal ? '_blank' : undefined)\n const rel = isExternal ? 'noopener noreferrer' : undefined\n\n const classes = [\n dLink,\n dLinkPrimary,\n size === 'sm' && 'text-sm',\n size === 'base' && 'text-base',\n size === 'lg' && 'text-lg',\n size === 'xl' && 'text-xl',\n size === '2xl' && 'text-2xl',\n className,\n ].filter(Boolean).join(' ')\n\n return (\n <a\n href={href}\n target={linkTarget}\n rel={rel}\n className={classes}\n data-testid={testId}\n {...rest}\n >\n {children}\n {isExternal && (\n <svg className=\"w-3 h-3 inline-block ml-1\" fill=\"currentColor\" viewBox=\"0 0 20 20\">\n <path d=\"M11 3a1 1 0 100 2h2.586l-6.293 6.293a1 1 0 101.414 1.414L15 6.414V9a1 1 0 102 0V4a1 1 0 00-1-1h-5z\" />\n <path d=\"M5 5a2 2 0 00-2 2v8a2 2 0 002 2h8a2 2 0 002-2v-3a1 1 0 10-2 0v3H5V7h3a1 1 0 000-2H5z\" />\n </svg>\n )}\n </a>\n )\n}\n\nexport const Typography = Object.assign(TypographyRoot, {\n Title,\n Paragraph,\n Text,\n Link,\n})\n\nexport default Typography\n"],"names":["dBtn","dBtnGhost","dBtnXs","dLink","dLinkPrimary","CopyButton","text","testId","copied","setCopied","useState","jsx","err","jsxs","TypographyRoot","children","size","className","rest","classes","Title","level","copyable","ellipsis","id","textContent","generatedId","getTestId","suffix","levelClasses","ellipsisClass","content","Fragment","lineClampClasses","Paragraph","align","expanded","setExpanded","isEllipsisObject","rows","expandable","clampedRows","Text","code","mark","strong","italic","underline","del","type","typeClasses","Link","href","target","external","isExternal","linkTarget","rel","Typography"],"mappings":";;AAGA,MAAMA,IAAO,OACPC,IAAY,aACZC,IAAS,UACTC,IAAQ,QACRC,IAAe;AAiDrB,SAASC,EAAW,EAAE,MAAAC,GAAM,eAAeC,KAAoD;AAC7F,QAAM,CAACC,GAAQC,CAAS,IAAIC,EAAS,EAAK;AAY1C,SACE,gBAAAC;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,SAZe,YAAY;AAC7B,YAAI;AACF,gBAAM,UAAU,UAAU,UAAUL,CAAI,GACxCG,EAAU,EAAI,GACd,WAAW,MAAMA,EAAU,EAAK,GAAG,GAAI;AAAA,QACzC,SAASG,GAAK;AACZ,kBAAQ,MAAM,mBAAmBA,CAAG;AAAA,QACtC;AAAA,MACF;AAAA,MAKI,WAAW,GAAGZ,CAAI,IAAIC,CAAS,IAAIC,CAAM;AAAA,MACzC,OAAM;AAAA,MACN,eAAaK;AAAA,MA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A,WAAAc;AAAA,EACA,MAAAQ;AAAA,EACA,MAAAS;AACF,CAAC;"}
|
|
@@ -22,8 +22,9 @@ export interface VirtualListProps<T> {
|
|
|
22
22
|
gap?: number;
|
|
23
23
|
/** Callback when scroll position changes */
|
|
24
24
|
onScroll?: (scrollTop: number) => void;
|
|
25
|
+
'data-testid'?: string;
|
|
25
26
|
}
|
|
26
|
-
export declare function VirtualList<T>({ items, height, itemHeight, renderItem, overscan, className, innerClassName, itemClassName, width, gap, onScroll, }: VirtualListProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
export declare function VirtualList<T>({ items, height, itemHeight, renderItem, overscan, className, innerClassName, itemClassName, width, gap, onScroll, 'data-testid': testId, }: VirtualListProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
27
28
|
export declare namespace VirtualList {
|
|
28
29
|
var displayName: string;
|
|
29
30
|
}
|
|
@@ -1,59 +1,63 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
2
2
|
import { useRef as o } from "react";
|
|
3
|
-
import { useVirtualizer as
|
|
4
|
-
function
|
|
3
|
+
import { useVirtualizer as N } from "@tanstack/react-virtual";
|
|
4
|
+
function R({
|
|
5
5
|
items: e,
|
|
6
|
-
height:
|
|
7
|
-
itemHeight:
|
|
8
|
-
renderItem:
|
|
9
|
-
overscan:
|
|
10
|
-
className:
|
|
11
|
-
innerClassName:
|
|
12
|
-
itemClassName:
|
|
13
|
-
width:
|
|
14
|
-
gap:
|
|
15
|
-
onScroll:
|
|
6
|
+
height: f,
|
|
7
|
+
itemHeight: s,
|
|
8
|
+
renderItem: h,
|
|
9
|
+
overscan: p = 5,
|
|
10
|
+
className: m = "",
|
|
11
|
+
innerClassName: g = "",
|
|
12
|
+
itemClassName: x = "",
|
|
13
|
+
width: y,
|
|
14
|
+
gap: a = 0,
|
|
15
|
+
onScroll: z,
|
|
16
|
+
"data-testid": n
|
|
16
17
|
}) {
|
|
17
|
-
const
|
|
18
|
-
r.current =
|
|
19
|
-
const
|
|
18
|
+
const c = o(null), r = o(s), l = o(e);
|
|
19
|
+
r.current = s, l.current = e;
|
|
20
|
+
const d = N({
|
|
20
21
|
count: e.length,
|
|
21
|
-
getScrollElement: () =>
|
|
22
|
-
estimateSize: (t) => (typeof r.current == "function" ? r.current(
|
|
23
|
-
overscan:
|
|
24
|
-
}),
|
|
25
|
-
|
|
26
|
-
};
|
|
27
|
-
return /* @__PURE__ */
|
|
22
|
+
getScrollElement: () => c.current,
|
|
23
|
+
estimateSize: (t) => (typeof r.current == "function" ? r.current(l.current[t], t) : r.current) + a,
|
|
24
|
+
overscan: p
|
|
25
|
+
}), S = d.getVirtualItems(), $ = (t) => {
|
|
26
|
+
z?.(t.currentTarget.scrollTop);
|
|
27
|
+
}, u = (t) => n ? `${n}-${t}` : void 0;
|
|
28
|
+
return /* @__PURE__ */ i(
|
|
28
29
|
"div",
|
|
29
30
|
{
|
|
30
|
-
ref:
|
|
31
|
-
className: `overflow-auto ${
|
|
32
|
-
style: { height:
|
|
33
|
-
onScroll:
|
|
34
|
-
|
|
31
|
+
ref: c,
|
|
32
|
+
className: `overflow-auto ${m}`,
|
|
33
|
+
style: { height: f, width: y },
|
|
34
|
+
onScroll: $,
|
|
35
|
+
"data-testid": n,
|
|
36
|
+
children: /* @__PURE__ */ i(
|
|
35
37
|
"div",
|
|
36
38
|
{
|
|
37
|
-
className:
|
|
39
|
+
className: g,
|
|
38
40
|
style: {
|
|
39
|
-
height:
|
|
41
|
+
height: d.getTotalSize(),
|
|
40
42
|
width: "100%",
|
|
41
43
|
position: "relative"
|
|
42
44
|
},
|
|
43
|
-
|
|
45
|
+
"data-testid": u("inner"),
|
|
46
|
+
children: S.map((t) => /* @__PURE__ */ i(
|
|
44
47
|
"div",
|
|
45
48
|
{
|
|
46
|
-
className:
|
|
49
|
+
className: x,
|
|
47
50
|
"data-index": t.index,
|
|
48
51
|
style: {
|
|
49
52
|
position: "absolute",
|
|
50
53
|
top: 0,
|
|
51
54
|
left: 0,
|
|
52
55
|
width: "100%",
|
|
53
|
-
height: t.size -
|
|
56
|
+
height: t.size - a,
|
|
54
57
|
transform: `translateY(${t.start}px)`
|
|
55
58
|
},
|
|
56
|
-
|
|
59
|
+
"data-testid": u(`item-${t.index}`),
|
|
60
|
+
children: h(e[t.index], t.index)
|
|
57
61
|
},
|
|
58
62
|
t.key
|
|
59
63
|
))
|
|
@@ -62,8 +66,8 @@ function N({
|
|
|
62
66
|
}
|
|
63
67
|
);
|
|
64
68
|
}
|
|
65
|
-
|
|
69
|
+
R.displayName = "VirtualList";
|
|
66
70
|
export {
|
|
67
|
-
|
|
71
|
+
R as VirtualList
|
|
68
72
|
};
|
|
69
73
|
//# sourceMappingURL=VirtualList.js.map
|