@aster-ui/prefixed 0.12.52 → 0.12.55
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/Button.js +22 -22
- package/dist/components/Button.js.map +1 -1
- package/dist/components/Card.d.ts +1 -3
- package/dist/components/Card.js +74 -75
- package/dist/components/Card.js.map +1 -1
- package/dist/components/Chart.js +57 -88
- package/dist/components/Chart.js.map +1 -1
- package/dist/components/CopyButton.js +76 -77
- package/dist/components/CopyButton.js.map +1 -1
- package/dist/components/Drawer.js +9 -9
- package/dist/components/Drawer.js.map +1 -1
- package/dist/components/QRCode.js +38 -37
- package/dist/components/QRCode.js.map +1 -1
- package/dist/components/ThemeProvider.d.ts +50 -0
- package/dist/components/ThemeProvider.js +128 -0
- package/dist/components/ThemeProvider.js.map +1 -0
- package/dist/components/Watermark.js +86 -94
- package/dist/components/Watermark.js.map +1 -1
- package/dist/contexts/SizeContext.d.ts +22 -0
- package/dist/contexts/SizeContext.js +15 -0
- package/dist/contexts/SizeContext.js.map +1 -0
- package/dist/hooks/useTheme.d.ts +39 -0
- package/dist/hooks/useTheme.js +117 -0
- package/dist/hooks/useTheme.js.map +1 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.js +237 -229
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/contexts/IconSizeContext.d.ts +0 -2
- package/dist/contexts/IconSizeContext.js +0 -6
- package/dist/contexts/IconSizeContext.js.map +0 -1
package/dist/components/Chart.js
CHANGED
|
@@ -1,72 +1,73 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { jsx as g } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as p, useEffect as m } from "react";
|
|
3
|
+
import x from "apexcharts";
|
|
4
|
+
import { useTheme as k } from "../hooks/useTheme.js";
|
|
5
|
+
function c(t, e) {
|
|
6
|
+
const l = { ...t };
|
|
7
|
+
for (const o in e)
|
|
8
|
+
e[o] !== void 0 && (typeof e[o] == "object" && e[o] !== null && !Array.isArray(e[o]) && typeof t[o] == "object" && t[o] !== null && !Array.isArray(t[o]) ? l[o] = c(
|
|
9
|
+
t[o],
|
|
10
|
+
e[o]
|
|
11
|
+
) : l[o] = e[o]);
|
|
12
|
+
return l;
|
|
6
13
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return t.includes("oklch") ? x(t) : t;
|
|
27
|
-
}).filter(Boolean);
|
|
28
|
-
}
|
|
29
|
-
function A() {
|
|
30
|
-
const o = V(), e = S("--color-base-content"), t = e.includes("oklch") ? x(e) : e || "#888888", r = S("--color-base-300"), a = r.includes("oklch") ? x(r) : r || "#e0e0e0", c = t.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i), l = c ? (parseInt(c[1], 16) + parseInt(c[2], 16) + parseInt(c[3], 16)) / 3 > 128 : !1;
|
|
31
|
-
return {
|
|
32
|
-
colors: o.length > 0 ? o : void 0,
|
|
14
|
+
const j = ({
|
|
15
|
+
type: t,
|
|
16
|
+
series: e,
|
|
17
|
+
width: l = "100%",
|
|
18
|
+
height: o = 350,
|
|
19
|
+
options: a = {},
|
|
20
|
+
themed: i = !0,
|
|
21
|
+
className: y = ""
|
|
22
|
+
}) => {
|
|
23
|
+
const u = p(null), n = p(null), { isDark: f, colors: r } = k(), h = () => ({
|
|
24
|
+
colors: [
|
|
25
|
+
r.primary,
|
|
26
|
+
r.secondary,
|
|
27
|
+
r.accent,
|
|
28
|
+
r.info,
|
|
29
|
+
r.success,
|
|
30
|
+
r.warning,
|
|
31
|
+
r.error
|
|
32
|
+
],
|
|
33
33
|
theme: {
|
|
34
|
-
mode:
|
|
34
|
+
mode: f ? "dark" : "light"
|
|
35
35
|
},
|
|
36
36
|
chart: {
|
|
37
37
|
background: "transparent",
|
|
38
|
-
foreColor:
|
|
38
|
+
foreColor: r.foreground
|
|
39
39
|
},
|
|
40
40
|
grid: {
|
|
41
|
-
borderColor:
|
|
41
|
+
borderColor: r.foreground + "20"
|
|
42
|
+
// 12.5% opacity
|
|
42
43
|
},
|
|
43
44
|
xaxis: {
|
|
44
45
|
labels: {
|
|
45
46
|
style: {
|
|
46
|
-
colors:
|
|
47
|
+
colors: r.foreground
|
|
47
48
|
}
|
|
48
49
|
},
|
|
49
50
|
axisBorder: {
|
|
50
|
-
color:
|
|
51
|
+
color: r.foreground + "20"
|
|
51
52
|
},
|
|
52
53
|
axisTicks: {
|
|
53
|
-
color:
|
|
54
|
+
color: r.foreground + "20"
|
|
54
55
|
}
|
|
55
56
|
},
|
|
56
57
|
yaxis: {
|
|
57
58
|
labels: {
|
|
58
59
|
style: {
|
|
59
|
-
colors:
|
|
60
|
+
colors: r.foreground
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
63
|
},
|
|
63
64
|
legend: {
|
|
64
65
|
labels: {
|
|
65
|
-
colors:
|
|
66
|
+
colors: r.foreground
|
|
66
67
|
}
|
|
67
68
|
},
|
|
68
69
|
tooltip: {
|
|
69
|
-
theme:
|
|
70
|
+
theme: f ? "dark" : "light",
|
|
70
71
|
style: {
|
|
71
72
|
fontSize: "12px"
|
|
72
73
|
},
|
|
@@ -79,7 +80,7 @@ function A() {
|
|
|
79
80
|
},
|
|
80
81
|
dataLabels: {
|
|
81
82
|
style: {
|
|
82
|
-
colors:
|
|
83
|
+
colors: Array(7).fill(r.foreground)
|
|
83
84
|
},
|
|
84
85
|
background: {
|
|
85
86
|
enabled: !1
|
|
@@ -88,66 +89,34 @@ function A() {
|
|
|
88
89
|
enabled: !1
|
|
89
90
|
}
|
|
90
91
|
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
function h(o, e) {
|
|
94
|
-
const t = { ...o };
|
|
95
|
-
for (const r in e)
|
|
96
|
-
e[r] !== void 0 && (typeof e[r] == "object" && e[r] !== null && !Array.isArray(e[r]) && typeof o[r] == "object" && o[r] !== null && !Array.isArray(o[r]) ? t[r] = h(
|
|
97
|
-
o[r],
|
|
98
|
-
e[r]
|
|
99
|
-
) : t[r] = e[r]);
|
|
100
|
-
return t;
|
|
101
|
-
}
|
|
102
|
-
const $ = ({
|
|
103
|
-
type: o,
|
|
104
|
-
series: e,
|
|
105
|
-
width: t = "100%",
|
|
106
|
-
height: r = 350,
|
|
107
|
-
options: a = {},
|
|
108
|
-
themed: c = !0,
|
|
109
|
-
className: l = ""
|
|
110
|
-
}) => {
|
|
111
|
-
const u = C(null), n = C(null), [, f] = v(!1), i = () => {
|
|
92
|
+
}), d = () => {
|
|
112
93
|
const s = {
|
|
113
94
|
chart: {
|
|
114
|
-
type:
|
|
115
|
-
width:
|
|
116
|
-
height:
|
|
95
|
+
type: t,
|
|
96
|
+
width: l,
|
|
97
|
+
height: o
|
|
117
98
|
},
|
|
118
99
|
series: e
|
|
119
100
|
};
|
|
120
|
-
if (
|
|
121
|
-
const
|
|
122
|
-
return
|
|
101
|
+
if (i) {
|
|
102
|
+
const b = h();
|
|
103
|
+
return c(c(s, b), a);
|
|
123
104
|
}
|
|
124
|
-
return
|
|
105
|
+
return c(s, a);
|
|
125
106
|
};
|
|
126
|
-
return
|
|
107
|
+
return m(() => {
|
|
127
108
|
if (!u.current) return;
|
|
128
|
-
const s =
|
|
129
|
-
return n.current = new
|
|
109
|
+
const s = d();
|
|
110
|
+
return n.current = new x(u.current, s), n.current.render(), () => {
|
|
130
111
|
n.current && (n.current.destroy(), n.current = null);
|
|
131
112
|
};
|
|
132
|
-
}, []),
|
|
113
|
+
}, []), m(() => {
|
|
133
114
|
if (!n.current) return;
|
|
134
|
-
const s =
|
|
115
|
+
const s = d();
|
|
135
116
|
n.current.updateOptions(s, !0, !0);
|
|
136
|
-
}, [
|
|
137
|
-
if (!c || typeof window > "u") return;
|
|
138
|
-
const s = new MutationObserver(() => {
|
|
139
|
-
if (n.current) {
|
|
140
|
-
const d = i();
|
|
141
|
-
n.current.updateOptions(d, !0, !0);
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
return s.observe(document.documentElement, {
|
|
145
|
-
attributes: !0,
|
|
146
|
-
attributeFilter: ["data-theme", "class"]
|
|
147
|
-
}), () => s.disconnect();
|
|
148
|
-
}, [c]), /* @__PURE__ */ w("div", { ref: u, className: l });
|
|
117
|
+
}, [t, e, l, o, a, i, f, r]), /* @__PURE__ */ g("div", { ref: u, className: y });
|
|
149
118
|
};
|
|
150
119
|
export {
|
|
151
|
-
|
|
120
|
+
j as Chart
|
|
152
121
|
};
|
|
153
122
|
//# sourceMappingURL=Chart.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chart.js","sources":["../../src/components/Chart.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react'\nimport ApexCharts from 'apexcharts'\nimport type { ApexOptions } from 'apexcharts'\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// Get CSS variable value from root\nfunction getCssVar(varName: string): string {\n if (typeof document === 'undefined') return ''\n return getComputedStyle(document.documentElement).getPropertyValue(varName).trim()\n}\n\n// Convert oklch to hex (approximate)\nfunction oklchToHex(oklch: string): string {\n // Parse oklch(L C H) format\n const match = oklch.match(/oklch\\(\\s*([\\d.]+)%?\\s+([\\d.]+)\\s+([\\d.]+)/)\n if (!match) return ''\n\n const l = parseFloat(match[1]) / 100 // Lightness 0-1\n const c = parseFloat(match[2]) // Chroma\n const h = parseFloat(match[3]) // Hue in degrees\n\n // Simplified oklch to sRGB conversion\n // This is an approximation - full conversion is complex\n const hRad = (h * Math.PI) / 180\n const a = c * Math.cos(hRad)\n const b = c * Math.sin(hRad)\n\n // Approximate conversion to linear RGB\n const l_ = l + 0.3963377774 * a + 0.2158037573 * b\n const m_ = l - 0.1055613458 * a - 0.0638541728 * b\n const s_ = l - 0.0894841775 * a - 1.2914855480 * b\n\n const l3 = l_ * l_ * l_\n const m3 = m_ * m_ * m_\n const s3 = s_ * s_ * s_\n\n let r = 4.0767416621 * l3 - 3.3077115913 * m3 + 0.2309699292 * s3\n let g = -1.2684380046 * l3 + 2.6097574011 * m3 - 0.3413193965 * s3\n let bl = -0.0041960863 * l3 - 0.7034186147 * m3 + 1.7076147010 * s3\n\n // Clamp and convert to sRGB\n const toSrgb = (x: number) => {\n x = Math.max(0, Math.min(1, x))\n return x <= 0.0031308 ? 12.92 * x : 1.055 * Math.pow(x, 1/2.4) - 0.055\n }\n\n r = Math.round(toSrgb(r) * 255)\n g = Math.round(toSrgb(g) * 255)\n bl = Math.round(toSrgb(bl) * 255)\n\n return `#${r.toString(16).padStart(2, '0')}${g.toString(16).padStart(2, '0')}${bl.toString(16).padStart(2, '0')}`\n}\n\n// Get daisyUI theme colors from CSS variables\nfunction getThemeColors(): string[] {\n if (typeof document === 'undefined') return []\n\n const colorVars = [\n '--color-primary',\n '--color-secondary',\n '--color-accent',\n '--color-info',\n '--color-success',\n '--color-warning',\n '--color-error',\n ]\n\n return colorVars\n .map(varName => {\n const value = getCssVar(varName)\n if (value.includes('oklch')) {\n return oklchToHex(value)\n }\n return value\n })\n .filter(Boolean)\n}\n\n// Get theme-aware chart options\nfunction getThemedOptions(): Partial<ApexOptions> {\n const colors = getThemeColors()\n\n // Get text color from CSS variable\n const baseContentVar = getCssVar('--color-base-content')\n const textColor = baseContentVar.includes('oklch')\n ? oklchToHex(baseContentVar)\n : (baseContentVar || '#888888')\n\n // Get grid color from CSS variable\n const base300Var = getCssVar('--color-base-300')\n const gridColor = base300Var.includes('oklch')\n ? oklchToHex(base300Var)\n : (base300Var || '#e0e0e0')\n\n // Determine if dark theme by checking luminance of text color\n // If text is light, we're on dark theme\n const textMatch = textColor.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i)\n const isDark = textMatch\n ? (parseInt(textMatch[1], 16) + parseInt(textMatch[2], 16) + parseInt(textMatch[3], 16)) / 3 > 128\n : false\n\n return {\n colors: colors.length > 0 ? colors : undefined,\n theme: {\n mode: isDark ? 'dark' : 'light',\n },\n chart: {\n background: 'transparent',\n foreColor: textColor,\n },\n grid: {\n borderColor: gridColor,\n },\n xaxis: {\n labels: {\n style: {\n colors: textColor,\n },\n },\n axisBorder: {\n color: gridColor,\n },\n axisTicks: {\n color: gridColor,\n },\n },\n yaxis: {\n labels: {\n style: {\n colors: textColor,\n },\n },\n },\n legend: {\n labels: {\n colors: textColor,\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: [textColor, textColor, textColor, textColor, textColor, textColor, textColor],\n },\n background: {\n enabled: false,\n },\n dropShadow: {\n enabled: false,\n },\n },\n }\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 [, setMounted] = useState(false)\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 setMounted(true)\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 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]) // eslint-disable-line react-hooks/exhaustive-deps\n\n // Listen for theme changes\n useEffect(() => {\n if (!themed || typeof window === 'undefined') return\n\n const observer = new MutationObserver(() => {\n if (chartInstance.current) {\n const opts = buildOptions()\n chartInstance.current.updateOptions(opts, true, true)\n }\n })\n\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: ['data-theme', 'class'],\n })\n\n return () => observer.disconnect()\n }, [themed]) // eslint-disable-line react-hooks/exhaustive-deps\n\n return <div ref={chartRef} className={className} />\n}\n"],"names":["getCssVar","varName","oklchToHex","oklch","match","l","c","hRad","a","b","l_","m_","s_","l3","m3","s3","r","g","bl","toSrgb","x","getThemeColors","value","getThemedOptions","colors","baseContentVar","textColor","base300Var","gridColor","textMatch","isDark","deepMerge","target","source","result","key","Chart","type","series","width","height","options","themed","className","chartRef","useRef","chartInstance","setMounted","useState","buildOptions","baseOptions","themedOpts","useEffect","opts","ApexCharts","observer","jsx"],"mappings":";;;AAsBA,SAASA,EAAUC,GAAyB;AAC1C,SAAI,OAAO,WAAa,MAAoB,KACrC,iBAAiB,SAAS,eAAe,EAAE,iBAAiBA,CAAO,EAAE,KAAA;AAC9E;AAGA,SAASC,EAAWC,GAAuB;AAEzC,QAAMC,IAAQD,EAAM,MAAM,4CAA4C;AACtE,MAAI,CAACC,EAAO,QAAO;AAEnB,QAAMC,IAAI,WAAWD,EAAM,CAAC,CAAC,IAAI,KAC3BE,IAAI,WAAWF,EAAM,CAAC,CAAC,GAKvBG,IAJI,WAAWH,EAAM,CAAC,CAAC,IAIX,KAAK,KAAM,KACvBI,IAAIF,IAAI,KAAK,IAAIC,CAAI,GACrBE,IAAIH,IAAI,KAAK,IAAIC,CAAI,GAGrBG,IAAKL,IAAI,eAAeG,IAAI,eAAeC,GAC3CE,IAAKN,IAAI,eAAeG,IAAI,eAAeC,GAC3CG,IAAKP,IAAI,eAAeG,IAAI,cAAeC,GAE3CI,IAAKH,IAAKA,IAAKA,GACfI,IAAKH,IAAKA,IAAKA,GACfI,IAAKH,IAAKA,IAAKA;AAErB,MAAII,IAAI,eAAeH,IAAK,eAAeC,IAAK,eAAeC,GAC3DE,IAAI,gBAAgBJ,IAAK,eAAeC,IAAK,eAAeC,GAC5DG,IAAK,gBAAgBL,IAAK,eAAeC,IAAK,cAAeC;AAGjE,QAAMI,IAAS,CAACC,OACdA,IAAI,KAAK,IAAI,GAAG,KAAK,IAAI,GAAGA,CAAC,CAAC,GACvBA,KAAK,WAAY,QAAQA,IAAI,QAAQ,KAAK,IAAIA,GAAG,IAAE,GAAG,IAAI;AAGnE,SAAAJ,IAAI,KAAK,MAAMG,EAAOH,C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AAOC,GAAQC,GAASC,CAAM,CAAC,GAGjDU,EAAU,MAAM;AACd,QAAI,CAACV,KAAU,OAAO,SAAW,IAAa;AAE9C,UAAMa,IAAW,IAAI,iBAAiB,MAAM;AAC1C,UAAIT,EAAc,SAAS;AACzB,cAAMO,IAAOJ,EAAA;AACb,QAAAH,EAAc,QAAQ,cAAcO,GAAM,IAAM,EAAI;AAAA,MACtD;AAAA,IACF,CAAC;AAED,WAAAE,EAAS,QAAQ,SAAS,iBAAiB;AAAA,MACzC,YAAY;AAAA,MACZ,iBAAiB,CAAC,cAAc,OAAO;AAAA,IAAA,CACxC,GAEM,MAAMA,EAAS,WAAA;AAAA,EACxB,GAAG,CAACb,CAAM,CAAC,GAEJ,gBAAAc,EAAC,OAAA,EAAI,KAAKZ,GAAU,WAAAD,EAAA,CAAsB;AACnD;"}
|
|
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","jsx"],"mappings":";;;;AAuBA,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;AAAA,EAC1C,MAAAC;AAAA,EACA,QAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,QAAAC,IAAS;AAAA,EACT,SAAAC,IAAU,CAAA;AAAA,EACV,QAAAC,IAAS;AAAA,E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btn-accent", K = "d-btn-info", h = "d-btn-success", Q = "d-btn-warning", R = "d-btn-error", U = "d-btn-neutral", Y = "d-btn-outline", Z = "d-btn-dash", _ = "d-btn-soft", $ = "d-btn-ghost", T = "d-btn-link", tt = "d-btn-xs", nt = "d-btn-sm", ot = "d-btn-lg", st = "d-btn-xl", et = "d-btn-square", ct = "d-btn-circle", rt = "d-tooltip", C = {
|
|
2
|
+
import { useClipboard as D } from "../hooks/useClipboard.js";
|
|
3
|
+
import { SizeProvider as F, useSize as p } from "../contexts/SizeContext.js";
|
|
4
|
+
import { useConfig as G } from "./ConfigProvider.js";
|
|
5
|
+
const H = "d-btn", M = "d-btn-primary", O = "d-btn-secondary", V = "d-btn-accent", J = "d-btn-info", h = "d-btn-success", K = "d-btn-warning", Q = "d-btn-error", R = "d-btn-neutral", U = "d-btn-outline", Y = "d-btn-dash", Z = "d-btn-soft", _ = "d-btn-ghost", $ = "d-btn-link", T = "d-btn-xs", tt = "d-btn-sm", nt = "d-btn-lg", ot = "d-btn-xl", st = "d-btn-square", et = "d-btn-circle", ct = "d-tooltip", B = {
|
|
7
6
|
xs: "w-3.5 h-3.5",
|
|
8
7
|
sm: "w-3.5 h-3.5",
|
|
9
8
|
md: "w-4 h-4",
|
|
10
9
|
lg: "w-5 h-5",
|
|
11
10
|
xl: "w-6 h-6"
|
|
12
|
-
},
|
|
13
|
-
const n =
|
|
11
|
+
}, rt = () => {
|
|
12
|
+
const n = p() ?? "md";
|
|
14
13
|
return /* @__PURE__ */ t(
|
|
15
14
|
"svg",
|
|
16
15
|
{
|
|
17
|
-
className:
|
|
16
|
+
className: B[n],
|
|
18
17
|
fill: "none",
|
|
19
18
|
viewBox: "0 0 24 24",
|
|
20
19
|
stroke: "currentColor",
|
|
21
20
|
children: /* @__PURE__ */ t("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z" })
|
|
22
21
|
}
|
|
23
22
|
);
|
|
24
|
-
},
|
|
25
|
-
const n =
|
|
23
|
+
}, dt = () => {
|
|
24
|
+
const n = p() ?? "md";
|
|
26
25
|
return /* @__PURE__ */ t(
|
|
27
26
|
"svg",
|
|
28
27
|
{
|
|
29
|
-
className:
|
|
28
|
+
className: B[n],
|
|
30
29
|
fill: "none",
|
|
31
30
|
viewBox: "0 0 24 24",
|
|
32
31
|
stroke: "currentColor",
|
|
33
32
|
children: /* @__PURE__ */ t("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "m4.5 12.75 6 6 9-13.5" })
|
|
34
33
|
}
|
|
35
34
|
);
|
|
36
|
-
},
|
|
35
|
+
}, f = {
|
|
37
36
|
"top-right": "absolute top-2 right-2",
|
|
38
37
|
"top-left": "absolute top-2 left-2",
|
|
39
38
|
"bottom-right": "absolute bottom-2 right-2",
|
|
40
39
|
"bottom-left": "absolute bottom-2 left-2"
|
|
41
|
-
},
|
|
40
|
+
}, at = ({
|
|
42
41
|
text: n,
|
|
43
|
-
timeout:
|
|
44
|
-
color:
|
|
45
|
-
variant:
|
|
46
|
-
size:
|
|
47
|
-
shape:
|
|
42
|
+
timeout: C = 2e3,
|
|
43
|
+
color: c,
|
|
44
|
+
variant: r,
|
|
45
|
+
size: g,
|
|
46
|
+
shape: d,
|
|
48
47
|
position: o,
|
|
49
|
-
icon:
|
|
50
|
-
copiedIcon:
|
|
51
|
-
children:
|
|
52
|
-
copiedChildren:
|
|
53
|
-
onCopy:
|
|
54
|
-
onError:
|
|
55
|
-
showTooltip:
|
|
56
|
-
tooltipText:
|
|
57
|
-
copiedTooltipText:
|
|
58
|
-
className:
|
|
59
|
-
disabled:
|
|
60
|
-
onClick:
|
|
61
|
-
...
|
|
48
|
+
icon: y,
|
|
49
|
+
copiedIcon: k,
|
|
50
|
+
children: v,
|
|
51
|
+
copiedChildren: w,
|
|
52
|
+
onCopy: z,
|
|
53
|
+
onError: S,
|
|
54
|
+
showTooltip: a = !1,
|
|
55
|
+
tooltipText: i = "Copy",
|
|
56
|
+
copiedTooltipText: l = "Copied!",
|
|
57
|
+
className: x = "",
|
|
58
|
+
disabled: u,
|
|
59
|
+
onClick: I,
|
|
60
|
+
...L
|
|
62
61
|
}) => {
|
|
63
|
-
const { componentSize:
|
|
64
|
-
if (
|
|
65
|
-
await
|
|
66
|
-
},
|
|
67
|
-
primary:
|
|
68
|
-
secondary:
|
|
69
|
-
accent:
|
|
70
|
-
info:
|
|
62
|
+
const { componentSize: N } = G(), b = g ?? N ?? "md", { copy: j, copied: s } = D(C), q = async (e) => {
|
|
63
|
+
if (I?.(e), u) return;
|
|
64
|
+
await j(n) ? z?.() : S?.(new Error("Failed to copy to clipboard"));
|
|
65
|
+
}, W = {
|
|
66
|
+
primary: M,
|
|
67
|
+
secondary: O,
|
|
68
|
+
accent: V,
|
|
69
|
+
info: J,
|
|
71
70
|
success: h,
|
|
72
|
-
warning:
|
|
73
|
-
error:
|
|
74
|
-
neutral:
|
|
75
|
-
},
|
|
71
|
+
warning: K,
|
|
72
|
+
error: Q,
|
|
73
|
+
neutral: R
|
|
74
|
+
}, E = {
|
|
76
75
|
solid: "",
|
|
77
|
-
outline:
|
|
78
|
-
dash:
|
|
79
|
-
soft:
|
|
80
|
-
ghost:
|
|
81
|
-
link:
|
|
82
|
-
},
|
|
83
|
-
xs:
|
|
84
|
-
sm:
|
|
76
|
+
outline: U,
|
|
77
|
+
dash: Y,
|
|
78
|
+
soft: Z,
|
|
79
|
+
ghost: _,
|
|
80
|
+
link: $
|
|
81
|
+
}, P = {
|
|
82
|
+
xs: T,
|
|
83
|
+
sm: tt,
|
|
85
84
|
md: "",
|
|
86
|
-
lg:
|
|
87
|
-
xl:
|
|
88
|
-
},
|
|
89
|
-
square:
|
|
90
|
-
circle:
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
|
|
85
|
+
lg: nt,
|
|
86
|
+
xl: ot
|
|
87
|
+
}, X = {
|
|
88
|
+
square: st,
|
|
89
|
+
circle: et
|
|
90
|
+
}, A = [
|
|
91
|
+
H,
|
|
92
|
+
c && W[c],
|
|
94
93
|
s && h,
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
94
|
+
r && E[r],
|
|
95
|
+
P[b],
|
|
96
|
+
d && X[d],
|
|
98
97
|
// Only add position classes if not using tooltip (tooltip wrapper gets them instead)
|
|
99
|
-
!
|
|
100
|
-
|
|
101
|
-
].filter(Boolean).join(" "),
|
|
98
|
+
!a && o && f[o],
|
|
99
|
+
x
|
|
100
|
+
].filter(Boolean).join(" "), m = /* @__PURE__ */ t(
|
|
102
101
|
"button",
|
|
103
102
|
{
|
|
104
103
|
type: "button",
|
|
105
|
-
className:
|
|
106
|
-
onClick:
|
|
107
|
-
disabled:
|
|
108
|
-
"aria-label": s ?
|
|
109
|
-
...
|
|
110
|
-
children: /* @__PURE__ */ t(
|
|
104
|
+
className: A,
|
|
105
|
+
onClick: q,
|
|
106
|
+
disabled: u,
|
|
107
|
+
"aria-label": s ? l : i,
|
|
108
|
+
...L,
|
|
109
|
+
children: /* @__PURE__ */ t(F, { size: b, children: s ? w ?? (k ?? /* @__PURE__ */ t(dt, {})) : v ?? (y ?? /* @__PURE__ */ t(rt, {})) })
|
|
111
110
|
}
|
|
112
111
|
);
|
|
113
|
-
if (
|
|
114
|
-
const e = [
|
|
115
|
-
return /* @__PURE__ */ t("div", { className: e, "data-tip": s ?
|
|
112
|
+
if (a) {
|
|
113
|
+
const e = [ct, o && f[o]].filter(Boolean).join(" ");
|
|
114
|
+
return /* @__PURE__ */ t("div", { className: e, "data-tip": s ? l : i, children: m });
|
|
116
115
|
}
|
|
117
|
-
return
|
|
116
|
+
return m;
|
|
118
117
|
};
|
|
119
|
-
|
|
118
|
+
at.displayName = "CopyButton";
|
|
120
119
|
export {
|
|
121
|
-
|
|
120
|
+
at as CopyButton
|
|
122
121
|
};
|
|
123
122
|
//# sourceMappingURL=CopyButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CopyButton.js","sources":["../../src/components/CopyButton.tsx"],"sourcesContent":["import React, { useContext } from 'react'\nimport { useClipboard } from '../hooks/useClipboard'\nimport { IconSizeContext } from '../contexts/IconSizeContext'\nimport { useConfig } from './ConfigProvider'\n\n// DaisyUI classes\nconst dBtn = 'd-btn'\nconst dBtnPrimary = 'd-btn-primary'\nconst dBtnSecondary = 'd-btn-secondary'\nconst dBtnAccent = 'd-btn-accent'\nconst dBtnInfo = 'd-btn-info'\nconst dBtnSuccess = 'd-btn-success'\nconst dBtnWarning = 'd-btn-warning'\nconst dBtnError = 'd-btn-error'\nconst dBtnNeutral = 'd-btn-neutral'\nconst dBtnOutline = 'd-btn-outline'\nconst dBtnDash = 'd-btn-dash'\nconst dBtnSoft = 'd-btn-soft'\nconst dBtnGhost = 'd-btn-ghost'\nconst dBtnLink = 'd-btn-link'\nconst dBtnXs = 'd-btn-xs'\nconst dBtnSm = 'd-btn-sm'\nconst dBtnLg = 'd-btn-lg'\nconst dBtnXl = 'd-btn-xl'\nconst dBtnSquare = 'd-btn-square'\nconst dBtnCircle = 'd-btn-circle'\nconst dTooltip = 'd-tooltip'\n\nconst iconSizeClasses = {\n xs: 'w-3.5 h-3.5',\n sm: 'w-3.5 h-3.5',\n md: 'w-4 h-4',\n lg: 'w-5 h-5',\n xl: 'w-6 h-6',\n}\n\nexport type CopyButtonPosition = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left'\n\nexport interface CopyButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'children' | 'onError'> {\n /** Text to copy to clipboard */\n text: string\n /** Duration in ms to show copied state */\n timeout?: number\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 /** Button shape */\n shape?: 'square' | 'circle'\n /** Absolute position within parent (parent must have position: relative) */\n position?: CopyButtonPosition\n /** Custom icon for default state */\n icon?: React.ReactNode\n /** Custom icon for copied state */\n copiedIcon?: React.ReactNode\n /** Custom content for default state (overrides icon) */\n children?: React.ReactNode\n /** Custom content for copied state */\n copiedChildren?: React.ReactNode\n /** Callback when copy succeeds */\n onCopy?: () => void\n /** Callback when copy fails */\n onError?: (error: Error) => void\n /** Show tooltip with copy status */\n showTooltip?: boolean\n /** Tooltip text for default state */\n tooltipText?: string\n /** Tooltip text for copied state */\n copiedTooltipText?: string\n}\n\nconst CopyIcon: React.FC = () => {\n const size = useContext(IconSizeContext) ?? 'md'\n return (\n <svg\n className={iconSizeClasses[size]}\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\" />\n </svg>\n )\n}\n\nconst CheckIcon: React.FC = () => {\n const size = useContext(IconSizeContext) ?? 'md'\n return (\n <svg\n className={iconSizeClasses[size]}\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"m4.5 12.75 6 6 9-13.5\" />\n </svg>\n )\n}\n\nconst positionClasses: Record<CopyButtonPosition, string> = {\n 'top-right': 'absolute top-2 right-2',\n 'top-left': 'absolute top-2 left-2',\n 'bottom-right': 'absolute bottom-2 right-2',\n 'bottom-left': 'absolute bottom-2 left-2',\n}\n\nexport const CopyButton: React.FC<CopyButtonProps> = ({\n text,\n timeout = 2000,\n color,\n variant,\n size,\n shape,\n position,\n icon,\n copiedIcon,\n children,\n copiedChildren,\n onCopy,\n onError,\n showTooltip = false,\n tooltipText = 'Copy',\n copiedTooltipText = 'Copied!',\n className = '',\n disabled,\n onClick,\n ...rest\n}) => {\n const { componentSize } = useConfig()\n const effectiveSize = size ?? componentSize ?? 'md'\n const { copy, copied } = useClipboard(timeout)\n\n const handleClick = async (e: React.MouseEvent<HTMLButtonElement>) => {\n onClick?.(e)\n if (disabled) return\n\n const success = await copy(text)\n if (success) {\n onCopy?.()\n } else {\n onError?.(new Error('Failed to copy to clipboard'))\n }\n }\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: '',\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 }\n\n const classes = [\n dBtn,\n color && colorClasses[color],\n copied && dBtnSuccess,\n variant && variantClasses[variant],\n sizeClasses[effectiveSize],\n shape && shapeClasses[shape],\n // Only add position classes if not using tooltip (tooltip wrapper gets them instead)\n !showTooltip && position && positionClasses[position],\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n const defaultIcon = icon ?? <CopyIcon />\n const successIcon = copiedIcon ?? <CheckIcon />\n\n const content = copied\n ? (copiedChildren ?? successIcon)\n : (children ?? defaultIcon)\n\n const button = (\n <button\n type=\"button\"\n className={classes}\n onClick={handleClick}\n disabled={disabled}\n aria-label={copied ? copiedTooltipText : tooltipText}\n {...rest}\n >\n <IconSizeContext.Provider value={effectiveSize}>\n {content}\n </IconSizeContext.Provider>\n </button>\n )\n\n if (showTooltip) {\n const tooltipClasses = [dTooltip, position && positionClasses[position]].filter(Boolean).join(' ')\n return (\n <div className={tooltipClasses} data-tip={copied ? copiedTooltipText : tooltipText}>\n {button}\n </div>\n )\n }\n\n return button\n}\n\nCopyButton.displayName = 'CopyButton'\n"],"names":["dBtn","dBtnPrimary","dBtnSecondary","dBtnAccent","dBtnInfo","dBtnSuccess","dBtnWarning","dBtnError","dBtnNeutral","dBtnOutline","dBtnDash","dBtnSoft","dBtnGhost","dBtnLink","dBtnXs","dBtnSm","dBtnLg","dBtnXl","dBtnSquare","dBtnCircle","dTooltip","iconSizeClasses","CopyIcon","size","useContext","IconSizeContext","jsx","CheckIcon","positionClasses","CopyButton","text","timeout","color","variant","shape","position","icon","copiedIcon","children","copiedChildren","onCopy","onError","showTooltip","tooltipText","copiedTooltipText","className","disabled","onClick","rest","componentSize","useConfig","effectiveSize","copy","copied","useClipboard","handleClick","colorClasses","variantClasses","sizeClasses","shapeClasses","classes","content","button","tooltipClasses"],"mappings":";;;;;AAMA,MAAMA,IAAO,SACPC,IAAc,iBACdC,IAAgB,mBAChBC,IAAa,gBACbC,IAAW,cACXC,IAAc,iBACdC,IAAc,iBACdC,IAAY,eACZC,IAAc,iBACdC,IAAc,iBACdC,IAAW,cACXC,IAAW,cACXC,IAAY,eACZC,IAAW,cACXC,KAAS,YACTC,KAAS,YACTC,KAAS,YACTC,KAAS,YACTC,KAAa,gBACbC,KAAa,gBACbC,KAAW,aAEXC,IAAkB;AAAA,EACtB,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN,GAuCMC,KAAqB,MAAM;AAC/B,QAAMC,IAAOC,EAAWC,CAAe,KAAK;AAC5C,SACE,gBAAAC;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWL,EAAgBE,CAAI;AAAA,MAC/B,MAAK;AAAA,MACL,SAAQ;AAAA,MACR,QAAO;AAAA,MAEP,UAAA,gBAAAG,EAAC,UAAK,eAAc,SAAQ,gBAAe,SAAQ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gBO,CAAQ,CAAC,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AACjG,WACE,gBAAAT,EAAC,SAAI,WAAWqC,GAAgB,YAAUV,IAAST,IAAoBD,GACpE,UAAAmB,EAAA,CACH;AAAA,EAEJ;AAEA,SAAOA;AACT;AAEAjC,GAAW,cAAc;"}
|
|
1
|
+
{"version":3,"file":"CopyButton.js","sources":["../../src/components/CopyButton.tsx"],"sourcesContent":["import React from 'react'\nimport { useClipboard } from '../hooks/useClipboard'\nimport { SizeProvider, useSize } from '../contexts/SizeContext'\nimport { useConfig } from './ConfigProvider'\n\n// DaisyUI classes\nconst dBtn = 'd-btn'\nconst dBtnPrimary = 'd-btn-primary'\nconst dBtnSecondary = 'd-btn-secondary'\nconst dBtnAccent = 'd-btn-accent'\nconst dBtnInfo = 'd-btn-info'\nconst dBtnSuccess = 'd-btn-success'\nconst dBtnWarning = 'd-btn-warning'\nconst dBtnError = 'd-btn-error'\nconst dBtnNeutral = 'd-btn-neutral'\nconst dBtnOutline = 'd-btn-outline'\nconst dBtnDash = 'd-btn-dash'\nconst dBtnSoft = 'd-btn-soft'\nconst dBtnGhost = 'd-btn-ghost'\nconst dBtnLink = 'd-btn-link'\nconst dBtnXs = 'd-btn-xs'\nconst dBtnSm = 'd-btn-sm'\nconst dBtnLg = 'd-btn-lg'\nconst dBtnXl = 'd-btn-xl'\nconst dBtnSquare = 'd-btn-square'\nconst dBtnCircle = 'd-btn-circle'\nconst dTooltip = 'd-tooltip'\n\nconst iconSizeClasses = {\n xs: 'w-3.5 h-3.5',\n sm: 'w-3.5 h-3.5',\n md: 'w-4 h-4',\n lg: 'w-5 h-5',\n xl: 'w-6 h-6',\n}\n\nexport type CopyButtonPosition = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left'\n\nexport interface CopyButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'children' | 'onError'> {\n /** Text to copy to clipboard */\n text: string\n /** Duration in ms to show copied state */\n timeout?: number\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 /** Button shape */\n shape?: 'square' | 'circle'\n /** Absolute position within parent (parent must have position: relative) */\n position?: CopyButtonPosition\n /** Custom icon for default state */\n icon?: React.ReactNode\n /** Custom icon for copied state */\n copiedIcon?: React.ReactNode\n /** Custom content for default state (overrides icon) */\n children?: React.ReactNode\n /** Custom content for copied state */\n copiedChildren?: React.ReactNode\n /** Callback when copy succeeds */\n onCopy?: () => void\n /** Callback when copy fails */\n onError?: (error: Error) => void\n /** Show tooltip with copy status */\n showTooltip?: boolean\n /** Tooltip text for default state */\n tooltipText?: string\n /** Tooltip text for copied state */\n copiedTooltipText?: string\n}\n\nconst CopyIcon: React.FC = () => {\n const size = useSize() ?? 'md'\n return (\n <svg\n className={iconSizeClasses[size]}\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z\" />\n </svg>\n )\n}\n\nconst CheckIcon: React.FC = () => {\n const size = useSize() ?? 'md'\n return (\n <svg\n className={iconSizeClasses[size]}\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"m4.5 12.75 6 6 9-13.5\" />\n </svg>\n )\n}\n\nconst positionClasses: Record<CopyButtonPosition, string> = {\n 'top-right': 'absolute top-2 right-2',\n 'top-left': 'absolute top-2 left-2',\n 'bottom-right': 'absolute bottom-2 right-2',\n 'bottom-left': 'absolute bottom-2 left-2',\n}\n\nexport const CopyButton: React.FC<CopyButtonProps> = ({\n text,\n timeout = 2000,\n color,\n variant,\n size,\n shape,\n position,\n icon,\n copiedIcon,\n children,\n copiedChildren,\n onCopy,\n onError,\n showTooltip = false,\n tooltipText = 'Copy',\n copiedTooltipText = 'Copied!',\n className = '',\n disabled,\n onClick,\n ...rest\n}) => {\n const { componentSize } = useConfig()\n const effectiveSize = size ?? componentSize ?? 'md'\n const { copy, copied } = useClipboard(timeout)\n\n const handleClick = async (e: React.MouseEvent<HTMLButtonElement>) => {\n onClick?.(e)\n if (disabled) return\n\n const success = await copy(text)\n if (success) {\n onCopy?.()\n } else {\n onError?.(new Error('Failed to copy to clipboard'))\n }\n }\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: '',\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 }\n\n const classes = [\n dBtn,\n color && colorClasses[color],\n copied && dBtnSuccess,\n variant && variantClasses[variant],\n sizeClasses[effectiveSize],\n shape && shapeClasses[shape],\n // Only add position classes if not using tooltip (tooltip wrapper gets them instead)\n !showTooltip && position && positionClasses[position],\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n const defaultIcon = icon ?? <CopyIcon />\n const successIcon = copiedIcon ?? <CheckIcon />\n\n const content = copied\n ? (copiedChildren ?? successIcon)\n : (children ?? defaultIcon)\n\n const button = (\n <button\n type=\"button\"\n className={classes}\n onClick={handleClick}\n disabled={disabled}\n aria-label={copied ? copiedTooltipText : tooltipText}\n {...rest}\n >\n <SizeProvider size={effectiveSize}>\n {content}\n </SizeProvider>\n </button>\n )\n\n if (showTooltip) {\n const tooltipClasses = [dTooltip, position && positionClasses[position]].filter(Boolean).join(' ')\n return (\n <div className={tooltipClasses} data-tip={copied ? copiedTooltipText : tooltipText}>\n {button}\n </div>\n )\n }\n\n return button\n}\n\nCopyButton.displayName = 'CopyButton'\n"],"names":["dBtn","dBtnPrimary","dBtnSecondary","dBtnAccent","dBtnInfo","dBtnSuccess","dBtnWarning","dBtnError","dBtnNeutral","dBtnOutline","dBtnDash","dBtnSoft","dBtnGhost","dBtnLink","dBtnXs","dBtnSm","dBtnLg","dBtnXl","dBtnSquare","dBtnCircle","dTooltip","iconSizeClasses","CopyIcon","size","useSize","jsx","CheckIcon","positionClasses","CopyButton","text","timeout","color","variant","shape","position","icon","copiedIcon","children","copiedChildren","onCopy","onError","showTooltip","tooltipText","copiedTooltipText","className","disabled","onClick","rest","componentSize","useConfig","effectiveSize","copy","copied","useClipboard","handleClick","colorClasses","variantClasses","sizeClasses","shapeClasses","classes","button","SizeProvider","tooltipClasses"],"mappings":";;;;AAMA,MAAMA,IAAO,SACPC,IAAc,iBACdC,IAAgB,mBAChBC,IAAa,gBACbC,IAAW,cACXC,IAAc,iBACdC,IAAc,iBACdC,IAAY,eACZC,IAAc,iBACdC,IAAc,iBACdC,IAAW,cACXC,IAAW,cACXC,IAAY,eACZC,IAAW,cACXC,IAAS,YACTC,KAAS,YACTC,KAAS,YACTC,KAAS,YACTC,KAAa,gBACbC,KAAa,gBACbC,KAAW,aAEXC,IAAkB;AAAA,EACtB,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN,GAuCMC,KAAqB,MAAM;AAC/B,QAAMC,IAAOC,OAAa;AAC1B,SACE,gBAAAC;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWJ,EAAgBE,CAAI;AAAA,MAC/B,MAAK;AAAA,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AAIJ,MAAImB,GAAa;AACf,UAAMqB,IAAiB,CAAC1C,IAAUc,KAAYP,EAAgBO,CAAQ,CAAC,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AACjG,WACE,gBAAAT,EAAC,SAAI,WAAWqC,GAAgB,YAAUV,IAAST,IAAoBD,GACpE,UAAAkB,EAAA,CACH;AAAA,EAEJ;AAEA,SAAOA;AACT;AAEAhC,GAAW,cAAc;"}
|
|
@@ -41,7 +41,7 @@ const Te = ve(
|
|
|
41
41
|
"data-testid": y,
|
|
42
42
|
...se
|
|
43
43
|
}, ae) => {
|
|
44
|
-
const m = h(null), p = h(null), v = h(null), j = h(null), q = P(),
|
|
44
|
+
const m = h(null), p = h(null), v = h(null), j = h(null), q = P(), I = P(), [oe, ie] = k(!1), [le, M] = k(r || B), [, w] = k(!1), X = Se();
|
|
45
45
|
we(ae, () => ({
|
|
46
46
|
nativeElement: m.current
|
|
47
47
|
})), C(() => {
|
|
@@ -68,12 +68,12 @@ const Te = ve(
|
|
|
68
68
|
},
|
|
69
69
|
[D, o]
|
|
70
70
|
), fe = E(() => {
|
|
71
|
-
w(!1), N?.(r), !r && L &&
|
|
71
|
+
w(!1), N?.(r), !r && L && M(!1);
|
|
72
72
|
}, [r, N, L]);
|
|
73
73
|
C(() => {
|
|
74
74
|
if (!(typeof document > "u"))
|
|
75
75
|
if (r) {
|
|
76
|
-
|
|
76
|
+
M(!0), w(!0), j.current = document.activeElement, document.body.style.overflow = "hidden";
|
|
77
77
|
const e = setTimeout(() => {
|
|
78
78
|
R === "close" && p.current ? p.current.focus() : v.current && v.current.querySelector(
|
|
79
79
|
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
|
|
@@ -96,7 +96,7 @@ const Te = ve(
|
|
|
96
96
|
bottom: "inset-x-0 bottom-0",
|
|
97
97
|
left: "inset-y-0 left-0"
|
|
98
98
|
}, be = (e) => {
|
|
99
|
-
const t =
|
|
99
|
+
const t = X && r ? X.pushDistance : 0;
|
|
100
100
|
if (e) {
|
|
101
101
|
if (t === 0) return "translate(0, 0)";
|
|
102
102
|
switch (i) {
|
|
@@ -120,7 +120,7 @@ const Te = ve(
|
|
|
120
120
|
case "left":
|
|
121
121
|
return "translateX(-100%)";
|
|
122
122
|
}
|
|
123
|
-
}, ye = de(), pe = () => l === !1 ? null : typeof l == "function" ? l() : l || (typeof document < "u" ? document.body : null), a = (e) => y ? `${y}-${e}` : void 0,
|
|
123
|
+
}, ye = de(), pe = () => l === !1 ? null : typeof l == "function" ? l() : l || (typeof document < "u" ? document.body : null), a = (e) => y ? `${y}-${e}` : void 0, Y = /* @__PURE__ */ n(F.Provider, { value: { push: c, pushDistance: ue() }, children: /* @__PURE__ */ d(
|
|
124
124
|
"div",
|
|
125
125
|
{
|
|
126
126
|
className: `fixed inset-0 ${r ? "" : "pointer-events-none"} ${Q}`,
|
|
@@ -147,7 +147,7 @@ const Te = ve(
|
|
|
147
147
|
role: "dialog",
|
|
148
148
|
"aria-modal": "true",
|
|
149
149
|
"aria-labelledby": f ? q : void 0,
|
|
150
|
-
"aria-describedby":
|
|
150
|
+
"aria-describedby": I,
|
|
151
151
|
className: `fixed flex flex-col bg-base-100 shadow-xl transition-transform duration-300 ease-in-out ${he[i]} ${J}`,
|
|
152
152
|
style: {
|
|
153
153
|
...ye,
|
|
@@ -206,7 +206,7 @@ const Te = ve(
|
|
|
206
206
|
"div",
|
|
207
207
|
{
|
|
208
208
|
ref: v,
|
|
209
|
-
id:
|
|
209
|
+
id: I,
|
|
210
210
|
className: "flex-1 overflow-auto p-6",
|
|
211
211
|
style: _,
|
|
212
212
|
"data-testid": a("body"),
|
|
@@ -235,8 +235,8 @@ const Te = ve(
|
|
|
235
235
|
}
|
|
236
236
|
) });
|
|
237
237
|
if (!oe || !le && !r && !B) return null;
|
|
238
|
-
const
|
|
239
|
-
return
|
|
238
|
+
const A = pe();
|
|
239
|
+
return A === null ? Y : ke(Y, A);
|
|
240
240
|
}
|
|
241
241
|
);
|
|
242
242
|
Te.displayName = "Drawer";
|