asterui 0.12.19 → 0.12.20
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/Code.d.ts +2 -0
- package/dist/components/CopyButton.d.ts +34 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +205 -203
- package/dist/index.js.map +1 -1
- package/dist/index10.js +91 -121
- package/dist/index10.js.map +1 -1
- package/dist/index100.js +5 -13
- package/dist/index100.js.map +1 -1
- package/dist/index101.js +11 -43
- package/dist/index101.js.map +1 -1
- package/dist/index102.js +44 -11
- package/dist/index102.js.map +1 -1
- package/dist/index103.js +10 -12
- package/dist/index103.js.map +1 -1
- package/dist/index104.js +14 -7
- package/dist/index104.js.map +1 -1
- package/dist/index105.js +7 -12
- package/dist/index105.js.map +1 -1
- package/dist/index106.js +11 -29
- package/dist/index106.js.map +1 -1
- package/dist/index107.js +29 -16
- package/dist/index107.js.map +1 -1
- package/dist/index108.js +21 -0
- package/dist/index108.js.map +1 -0
- package/dist/index11.js +123 -30
- package/dist/index11.js.map +1 -1
- package/dist/index12.js +28 -263
- package/dist/index12.js.map +1 -1
- package/dist/index13.js +257 -105
- package/dist/index13.js.map +1 -1
- package/dist/index14.js +108 -153
- package/dist/index14.js.map +1 -1
- package/dist/index15.js +154 -146
- package/dist/index15.js.map +1 -1
- package/dist/index16.js +150 -5
- package/dist/index16.js.map +1 -1
- package/dist/index17.js +5 -71
- package/dist/index17.js.map +1 -1
- package/dist/index18.js +70 -24
- package/dist/index18.js.map +1 -1
- package/dist/index19.js +23 -194
- package/dist/index19.js.map +1 -1
- package/dist/index20.js +188 -106
- package/dist/index20.js.map +1 -1
- package/dist/index21.js +107 -177
- package/dist/index21.js.map +1 -1
- package/dist/index22.js +181 -107
- package/dist/index22.js.map +1 -1
- package/dist/index23.js +110 -19
- package/dist/index23.js.map +1 -1
- package/dist/index24.js +17 -41
- package/dist/index24.js.map +1 -1
- package/dist/index25.js +43 -32
- package/dist/index25.js.map +1 -1
- package/dist/index26.js +30 -170
- package/dist/index26.js.map +1 -1
- package/dist/index27.js +171 -40
- package/dist/index27.js.map +1 -1
- package/dist/index28.js +41 -17
- package/dist/index28.js.map +1 -1
- package/dist/index29.js +17 -33
- package/dist/index29.js.map +1 -1
- package/dist/index30.js +33 -52
- package/dist/index30.js.map +1 -1
- package/dist/index31.js +50 -61
- package/dist/index31.js.map +1 -1
- package/dist/index32.js +60 -181
- package/dist/index32.js.map +1 -1
- package/dist/index33.js +184 -18
- package/dist/index33.js.map +1 -1
- package/dist/index34.js +15 -271
- package/dist/index34.js.map +1 -1
- package/dist/index35.js +270 -1083
- package/dist/index35.js.map +1 -1
- package/dist/index36.js +1086 -16
- package/dist/index36.js.map +1 -1
- package/dist/index37.js +17 -17
- package/dist/index37.js.map +1 -1
- package/dist/index38.js +15 -120
- package/dist/index38.js.map +1 -1
- package/dist/index39.js +119 -37
- package/dist/index39.js.map +1 -1
- package/dist/index40.js +40 -398
- package/dist/index40.js.map +1 -1
- package/dist/index41.js +390 -89
- package/dist/index41.js.map +1 -1
- package/dist/index42.js +91 -253
- package/dist/index42.js.map +1 -1
- package/dist/index43.js +249 -145
- package/dist/index43.js.map +1 -1
- package/dist/index44.js +155 -15
- package/dist/index44.js.map +1 -1
- package/dist/index45.js +15 -17
- package/dist/index45.js.map +1 -1
- package/dist/index46.js +16 -136
- package/dist/index46.js.map +1 -1
- package/dist/index47.js +134 -10
- package/dist/index47.js.map +1 -1
- package/dist/index48.js +13 -35
- package/dist/index48.js.map +1 -1
- package/dist/index49.js +35 -34
- package/dist/index49.js.map +1 -1
- package/dist/index50.js +34 -81
- package/dist/index50.js.map +1 -1
- package/dist/index51.js +71 -166
- package/dist/index51.js.map +1 -1
- package/dist/index52.js +167 -144
- package/dist/index52.js.map +1 -1
- package/dist/index53.js +152 -11
- package/dist/index53.js.map +1 -1
- package/dist/index54.js +10 -20
- package/dist/index54.js.map +1 -1
- package/dist/index55.js +55 -12
- package/dist/index55.js.map +1 -1
- package/dist/index56.js +14 -7
- package/dist/index56.js.map +1 -1
- package/dist/index57.js +6 -333
- package/dist/index57.js.map +1 -1
- package/dist/index58.js +334 -47
- package/dist/index58.js.map +1 -1
- package/dist/index59.js +47 -122
- package/dist/index59.js.map +1 -1
- package/dist/index60.js +120 -108
- package/dist/index60.js.map +1 -1
- package/dist/index61.js +107 -167
- package/dist/index61.js.map +1 -1
- package/dist/index62.js +167 -29
- package/dist/index62.js.map +1 -1
- package/dist/index63.js +30 -120
- package/dist/index63.js.map +1 -1
- package/dist/index64.js +116 -80
- package/dist/index64.js.map +1 -1
- package/dist/index65.js +85 -19
- package/dist/index65.js.map +1 -1
- package/dist/index66.js +19 -73
- package/dist/index66.js.map +1 -1
- package/dist/index67.js +71 -54
- package/dist/index67.js.map +1 -1
- package/dist/index68.js +56 -44
- package/dist/index68.js.map +1 -1
- package/dist/index69.js +42 -49
- package/dist/index69.js.map +1 -1
- package/dist/index70.js +50 -121
- package/dist/index70.js.map +1 -1
- package/dist/index71.js +118 -102
- package/dist/index71.js.map +1 -1
- package/dist/index72.js +105 -72
- package/dist/index72.js.map +1 -1
- package/dist/index73.js +73 -67
- package/dist/index73.js.map +1 -1
- package/dist/index74.js +66 -19
- package/dist/index74.js.map +1 -1
- package/dist/index75.js +18 -55
- package/dist/index75.js.map +1 -1
- package/dist/index76.js +55 -251
- package/dist/index76.js.map +1 -1
- package/dist/index77.js +254 -22
- package/dist/index77.js.map +1 -1
- package/dist/index78.js +22 -31
- package/dist/index78.js.map +1 -1
- package/dist/index79.js +30 -93
- package/dist/index79.js.map +1 -1
- package/dist/index80.js +89 -324
- package/dist/index80.js.map +1 -1
- package/dist/index81.js +322 -73
- package/dist/index81.js.map +1 -1
- package/dist/index82.js +79 -39
- package/dist/index82.js.map +1 -1
- package/dist/index83.js +40 -23
- package/dist/index83.js.map +1 -1
- package/dist/index84.js +21 -93
- package/dist/index84.js.map +1 -1
- package/dist/index85.js +87 -148
- package/dist/index85.js.map +1 -1
- package/dist/index86.js +147 -152
- package/dist/index86.js.map +1 -1
- package/dist/index87.js +159 -63
- package/dist/index87.js.map +1 -1
- package/dist/index88.js +65 -35
- package/dist/index88.js.map +1 -1
- package/dist/index89.js +35 -234
- package/dist/index89.js.map +1 -1
- package/dist/index90.js +231 -31
- package/dist/index90.js.map +1 -1
- package/dist/index91.js +34 -210
- package/dist/index91.js.map +1 -1
- package/dist/index92.js +195 -198
- package/dist/index92.js.map +1 -1
- package/dist/index93.js +159 -241
- package/dist/index93.js.map +1 -1
- package/dist/index94.js +283 -166
- package/dist/index94.js.map +1 -1
- package/dist/index95.js +173 -253
- package/dist/index95.js.map +1 -1
- package/dist/index96.js +253 -121
- package/dist/index96.js.map +1 -1
- package/dist/index97.js +126 -14
- package/dist/index97.js.map +1 -1
- package/dist/index98.js +12 -31
- package/dist/index98.js.map +1 -1
- package/dist/index99.js +32 -5
- package/dist/index99.js.map +1 -1
- package/package.json +1 -1
package/dist/index10.js
CHANGED
|
@@ -1,126 +1,96 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
direction: a = "vertical",
|
|
12
|
-
className: u = ""
|
|
13
|
-
}) {
|
|
14
|
-
const [C, g] = R.useState(x || []), r = o !== void 0 ? o : C, t = {
|
|
15
|
-
value: r,
|
|
16
|
-
onChange: (i, e) => {
|
|
17
|
-
const k = e ? [...r, i] : r.filter((b) => b !== i);
|
|
18
|
-
o === void 0 && g(k), h?.(k);
|
|
19
|
-
},
|
|
20
|
-
disabled: n
|
|
21
|
-
};
|
|
22
|
-
if (d) {
|
|
23
|
-
const i = a === "horizontal" ? "flex flex-row flex-wrap gap-4" : "flex flex-col";
|
|
24
|
-
return /* @__PURE__ */ c(y.Provider, { value: t, children: /* @__PURE__ */ c("div", { className: `${i} ${u}`.trim(), children: d.map((e) => typeof e == "string" || typeof e == "number" ? /* @__PURE__ */ p("label", { className: "label cursor-pointer justify-start gap-2", children: [
|
|
25
|
-
/* @__PURE__ */ c(m, { value: e }),
|
|
26
|
-
/* @__PURE__ */ c("span", { className: "label-text", children: e })
|
|
27
|
-
] }, e) : /* @__PURE__ */ p("label", { className: "label cursor-pointer justify-start gap-2", children: [
|
|
28
|
-
/* @__PURE__ */ c(m, { value: e.value, disabled: e.disabled }),
|
|
29
|
-
/* @__PURE__ */ c("span", { className: "label-text", children: e.label })
|
|
30
|
-
] }, e.value)) }) });
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { useClipboard as z } from "./index101.js";
|
|
3
|
+
const W = () => /* @__PURE__ */ n(
|
|
4
|
+
"svg",
|
|
5
|
+
{
|
|
6
|
+
className: "w-4 h-4",
|
|
7
|
+
fill: "none",
|
|
8
|
+
viewBox: "0 0 24 24",
|
|
9
|
+
stroke: "currentColor",
|
|
10
|
+
children: /* @__PURE__ */ 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" })
|
|
31
11
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
swap: n,
|
|
41
|
-
className: d = "",
|
|
42
|
-
value: a,
|
|
43
|
-
checked: u,
|
|
44
|
-
onChange: C,
|
|
45
|
-
disabled: g,
|
|
46
|
-
...r
|
|
47
|
-
}, l) => {
|
|
48
|
-
const t = $(y), i = {
|
|
49
|
-
xs: "checkbox-xs",
|
|
50
|
-
sm: "checkbox-sm",
|
|
51
|
-
md: "checkbox-md",
|
|
52
|
-
lg: "checkbox-lg",
|
|
53
|
-
xl: "checkbox-xl"
|
|
54
|
-
}, e = {
|
|
55
|
-
primary: "checkbox-primary",
|
|
56
|
-
secondary: "checkbox-secondary",
|
|
57
|
-
accent: "checkbox-accent",
|
|
58
|
-
neutral: "checkbox-neutral",
|
|
59
|
-
success: "checkbox-success",
|
|
60
|
-
warning: "checkbox-warning",
|
|
61
|
-
info: "checkbox-info",
|
|
62
|
-
error: "checkbox-error"
|
|
63
|
-
}, k = [
|
|
64
|
-
"checkbox",
|
|
65
|
-
o && i[o],
|
|
66
|
-
x && e[x]
|
|
67
|
-
].filter(Boolean).join(" "), b = t && a !== void 0 && (typeof a == "string" || typeof a == "number") ? t.value?.includes(a) ?? !1 : u, N = t?.disabled || g, v = (s) => {
|
|
68
|
-
t && a !== void 0 && (typeof a == "string" || typeof a == "number") && t.onChange?.(a, s.target.checked), C?.(s);
|
|
69
|
-
}, V = R.useCallback(
|
|
70
|
-
(s) => {
|
|
71
|
-
s && (s.indeterminate = h), typeof l == "function" ? l(s) : l && (l.current = s);
|
|
72
|
-
},
|
|
73
|
-
[h, l]
|
|
74
|
-
), j = h ? "indeterminate" : b ? "checked" : "unchecked";
|
|
75
|
-
if (n) {
|
|
76
|
-
const s = [
|
|
77
|
-
"swap",
|
|
78
|
-
n.effect === "rotate" && "swap-rotate",
|
|
79
|
-
n.effect === "flip" && "swap-flip",
|
|
80
|
-
d
|
|
81
|
-
].filter(Boolean).join(" ");
|
|
82
|
-
return /* @__PURE__ */ p("label", { className: s, children: [
|
|
83
|
-
/* @__PURE__ */ c(
|
|
84
|
-
"input",
|
|
85
|
-
{
|
|
86
|
-
ref: l,
|
|
87
|
-
type: "checkbox",
|
|
88
|
-
checked: b,
|
|
89
|
-
onChange: v,
|
|
90
|
-
disabled: N,
|
|
91
|
-
"data-state": j,
|
|
92
|
-
...r
|
|
93
|
-
}
|
|
94
|
-
),
|
|
95
|
-
/* @__PURE__ */ c("div", { className: "swap-on", children: n.on }),
|
|
96
|
-
/* @__PURE__ */ c("div", { className: "swap-off", children: n.off })
|
|
97
|
-
] });
|
|
98
|
-
}
|
|
99
|
-
const w = /* @__PURE__ */ c(
|
|
100
|
-
"input",
|
|
101
|
-
{
|
|
102
|
-
ref: V,
|
|
103
|
-
type: "checkbox",
|
|
104
|
-
className: k,
|
|
105
|
-
value: a,
|
|
106
|
-
checked: b,
|
|
107
|
-
onChange: v,
|
|
108
|
-
disabled: N,
|
|
109
|
-
"data-state": j,
|
|
110
|
-
...r
|
|
111
|
-
}
|
|
112
|
-
);
|
|
113
|
-
return f ? /* @__PURE__ */ p("label", { className: `label cursor-pointer justify-start gap-2 ${d}`, children: [
|
|
114
|
-
w,
|
|
115
|
-
/* @__PURE__ */ c("span", { className: "label-text", children: f })
|
|
116
|
-
] }) : w;
|
|
12
|
+
), E = () => /* @__PURE__ */ n(
|
|
13
|
+
"svg",
|
|
14
|
+
{
|
|
15
|
+
className: "w-4 h-4",
|
|
16
|
+
fill: "none",
|
|
17
|
+
viewBox: "0 0 24 24",
|
|
18
|
+
stroke: "currentColor",
|
|
19
|
+
children: /* @__PURE__ */ n("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "m4.5 12.75 6 6 9-13.5" })
|
|
117
20
|
}
|
|
118
|
-
)
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
21
|
+
), F = ({
|
|
22
|
+
text: l,
|
|
23
|
+
timeout: u = 2e3,
|
|
24
|
+
color: t,
|
|
25
|
+
variant: o,
|
|
26
|
+
size: d = "md",
|
|
27
|
+
shape: e,
|
|
28
|
+
icon: b,
|
|
29
|
+
copiedIcon: p,
|
|
30
|
+
children: h,
|
|
31
|
+
copiedChildren: m,
|
|
32
|
+
onCopy: f,
|
|
33
|
+
onError: C,
|
|
34
|
+
showTooltip: k = !1,
|
|
35
|
+
tooltipText: c = "Copy",
|
|
36
|
+
copiedTooltipText: r = "Copied!",
|
|
37
|
+
className: y = "",
|
|
38
|
+
disabled: a,
|
|
39
|
+
onClick: g,
|
|
40
|
+
...v
|
|
41
|
+
}) => {
|
|
42
|
+
const { copy: w, copied: s } = z(u), x = async (q) => {
|
|
43
|
+
if (g?.(q), a) return;
|
|
44
|
+
await w(l) ? f?.() : C?.(new Error("Failed to copy to clipboard"));
|
|
45
|
+
}, I = {
|
|
46
|
+
primary: "btn-primary",
|
|
47
|
+
secondary: "btn-secondary",
|
|
48
|
+
accent: "btn-accent",
|
|
49
|
+
info: "btn-info",
|
|
50
|
+
success: "btn-success",
|
|
51
|
+
warning: "btn-warning",
|
|
52
|
+
error: "btn-error",
|
|
53
|
+
neutral: "btn-neutral"
|
|
54
|
+
}, B = {
|
|
55
|
+
solid: "",
|
|
56
|
+
outline: "btn-outline",
|
|
57
|
+
dash: "btn-dash",
|
|
58
|
+
soft: "btn-soft",
|
|
59
|
+
ghost: "btn-ghost",
|
|
60
|
+
link: "btn-link"
|
|
61
|
+
}, N = {
|
|
62
|
+
xs: "btn-xs",
|
|
63
|
+
sm: "btn-sm",
|
|
64
|
+
md: "",
|
|
65
|
+
lg: "btn-lg",
|
|
66
|
+
xl: "btn-xl"
|
|
67
|
+
}, j = {
|
|
68
|
+
square: "btn-square",
|
|
69
|
+
circle: "btn-circle"
|
|
70
|
+
}, L = [
|
|
71
|
+
"btn",
|
|
72
|
+
t && I[t],
|
|
73
|
+
s && "btn-success",
|
|
74
|
+
o && B[o],
|
|
75
|
+
N[d],
|
|
76
|
+
e && j[e],
|
|
77
|
+
y
|
|
78
|
+
].filter(Boolean).join(" "), i = /* @__PURE__ */ n(
|
|
79
|
+
"button",
|
|
80
|
+
{
|
|
81
|
+
type: "button",
|
|
82
|
+
className: L,
|
|
83
|
+
onClick: x,
|
|
84
|
+
disabled: a,
|
|
85
|
+
"aria-label": s ? r : c,
|
|
86
|
+
...v,
|
|
87
|
+
children: s ? m ?? (p ?? /* @__PURE__ */ n(E, {})) : h ?? (b ?? /* @__PURE__ */ n(W, {}))
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
return k ? /* @__PURE__ */ n("div", { className: "tooltip", "data-tip": s ? r : c, children: i }) : i;
|
|
91
|
+
};
|
|
92
|
+
F.displayName = "CopyButton";
|
|
123
93
|
export {
|
|
124
|
-
|
|
94
|
+
F as CopyButton
|
|
125
95
|
};
|
|
126
96
|
//# sourceMappingURL=index10.js.map
|
package/dist/index10.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index10.js","sources":["../src/components/Checkbox.tsx"],"sourcesContent":["import React, { forwardRef, createContext, useContext } from 'react'\n\nexport interface CheckboxSwapConfig {\n /** Content shown when checked */\n on: React.ReactNode\n /** Content shown when unchecked */\n off: React.ReactNode\n /** Animation effect for the swap transition */\n effect?: 'rotate' | 'flip'\n}\n\nexport interface CheckboxProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size' | 'type'> {\n children?: React.ReactNode\n size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'\n color?: 'primary' | 'secondary' | 'accent' | 'neutral' | 'success' | 'warning' | 'info' | 'error'\n indeterminate?: boolean\n /** Swap mode: toggle between two visual states instead of showing a checkbox */\n swap?: CheckboxSwapConfig\n className?: string\n}\n\nexport interface CheckboxOptionType {\n label: React.ReactNode\n value: string | number\n disabled?: boolean\n}\n\nexport interface CheckboxGroupProps {\n children?: React.ReactNode\n value?: (string | number)[]\n defaultValue?: (string | number)[]\n onChange?: (values: (string | number)[]) => void\n disabled?: boolean\n options?: (string | number | CheckboxOptionType)[]\n /** Layout direction for options */\n direction?: 'horizontal' | 'vertical'\n className?: string\n}\n\ninterface CheckboxGroupContextValue {\n value?: (string | number)[]\n onChange?: (checkedValue: string | number, checked: boolean) => void\n disabled?: boolean\n}\n\nconst CheckboxGroupContext = createContext<CheckboxGroupContextValue | null>(null)\n\nfunction CheckboxGroup({\n children,\n value,\n defaultValue,\n onChange,\n disabled = false,\n options,\n direction = 'vertical',\n className = ''\n}: CheckboxGroupProps) {\n const [internalValue, setInternalValue] = React.useState<(string | number)[]>(defaultValue || [])\n const currentValue = value !== undefined ? value : internalValue\n\n const handleChange = (checkedValue: string | number, checked: boolean) => {\n const newValue = checked\n ? [...currentValue, checkedValue]\n : currentValue.filter((v) => v !== checkedValue)\n\n if (value === undefined) {\n setInternalValue(newValue)\n }\n onChange?.(newValue)\n }\n\n const contextValue: CheckboxGroupContextValue = {\n value: currentValue,\n onChange: handleChange,\n disabled,\n }\n\n // If options are provided, render checkboxes automatically\n if (options) {\n const directionClasses = direction === 'horizontal' ? 'flex flex-row flex-wrap gap-4' : 'flex flex-col'\n return (\n <CheckboxGroupContext.Provider value={contextValue}>\n <div className={`${directionClasses} ${className}`.trim()}>\n {options.map((option) => {\n if (typeof option === 'string' || typeof option === 'number') {\n return (\n <label key={option} className=\"label cursor-pointer justify-start gap-2\">\n <CheckboxRoot value={option} />\n <span className=\"label-text\">{option}</span>\n </label>\n )\n } else {\n return (\n <label key={option.value} className=\"label cursor-pointer justify-start gap-2\">\n <CheckboxRoot value={option.value} disabled={option.disabled} />\n <span className=\"label-text\">{option.label}</span>\n </label>\n )\n }\n })}\n </div>\n </CheckboxGroupContext.Provider>\n )\n }\n\n return (\n <CheckboxGroupContext.Provider value={contextValue}>\n <div className={className}>{children}</div>\n </CheckboxGroupContext.Provider>\n )\n}\n\nconst CheckboxRoot = forwardRef<HTMLInputElement, CheckboxProps>(\n (\n {\n children,\n size,\n color,\n indeterminate = false,\n swap,\n className = '',\n value,\n checked,\n onChange,\n disabled: disabledProp,\n ...props\n },\n ref\n ) => {\n const groupContext = useContext(CheckboxGroupContext)\n\n const sizeClasses = {\n xs: 'checkbox-xs',\n sm: 'checkbox-sm',\n md: 'checkbox-md',\n lg: 'checkbox-lg',\n xl: 'checkbox-xl',\n }\n\n const colorClasses = {\n primary: 'checkbox-primary',\n secondary: 'checkbox-secondary',\n accent: 'checkbox-accent',\n neutral: 'checkbox-neutral',\n success: 'checkbox-success',\n warning: 'checkbox-warning',\n info: 'checkbox-info',\n error: 'checkbox-error',\n }\n\n const checkboxClasses = [\n 'checkbox',\n size && sizeClasses[size],\n color && colorClasses[color],\n ]\n .filter(Boolean)\n .join(' ')\n\n // If in a group, use group's value to determine checked state\n const isChecked = groupContext && value !== undefined && (typeof value === 'string' || typeof value === 'number')\n ? groupContext.value?.includes(value) ?? false\n : checked\n\n const isDisabled = groupContext?.disabled || disabledProp\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n if (groupContext && value !== undefined && (typeof value === 'string' || typeof value === 'number')) {\n groupContext.onChange?.(value, e.target.checked)\n }\n onChange?.(e)\n }\n\n // Handle indeterminate state\n const checkboxRef = React.useCallback(\n (node: HTMLInputElement | null) => {\n if (node) {\n node.indeterminate = indeterminate\n }\n if (typeof ref === 'function') {\n ref(node)\n } else if (ref) {\n ref.current = node\n }\n },\n [indeterminate, ref]\n )\n\n const dataState = indeterminate ? 'indeterminate' : isChecked ? 'checked' : 'unchecked'\n\n // Swap mode: render as a swap toggle instead of checkbox\n if (swap) {\n const swapClasses = [\n 'swap',\n swap.effect === 'rotate' && 'swap-rotate',\n swap.effect === 'flip' && 'swap-flip',\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n return (\n <label className={swapClasses}>\n <input\n ref={ref}\n type=\"checkbox\"\n checked={isChecked}\n onChange={handleChange}\n disabled={isDisabled}\n data-state={dataState}\n {...props}\n />\n <div className=\"swap-on\">{swap.on}</div>\n <div className=\"swap-off\">{swap.off}</div>\n </label>\n )\n }\n\n const checkboxInput = (\n <input\n ref={checkboxRef}\n type=\"checkbox\"\n className={checkboxClasses}\n value={value}\n checked={isChecked}\n onChange={handleChange}\n disabled={isDisabled}\n data-state={dataState}\n {...props}\n />\n )\n\n // If children provided, wrap in label\n if (children) {\n return (\n <label className={`label cursor-pointer justify-start gap-2 ${className}`}>\n {checkboxInput}\n <span className=\"label-text\">{children}</span>\n </label>\n )\n }\n\n return checkboxInput\n }\n)\n\nCheckboxRoot.displayName = 'Checkbox'\n\nexport const Checkbox = Object.assign(CheckboxRoot, {\n Group: CheckboxGroup,\n})\n"],"names":["CheckboxGroupContext","createContext","CheckboxGroup","children","value","defaultValue","onChange","disabled","options","direction","className","internalValue","setInternalValue","React","currentValue","contextValue","checkedValue","checked","newValue","v","directionClasses","option","jsxs","jsx","CheckboxRoot","forwardRef","size","color","indeterminate","swap","disabledProp","props","ref","groupContext","useContext","sizeClasses","colorClasses","checkboxClasses","isChecked","isDisabled","handleChange","e","checkboxRef","node","dataState","swapClasses","checkboxInput","Checkbox"],"mappings":";;AA6CA,MAAMA,IAAuBC,EAAgD,IAAI;AAEjF,SAASC,EAAc;AAAA,EACrB,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,cAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,SAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,WAAAC,IAAY;AACd,GAAuB;AACrB,QAAM,CAACC,GAAeC,CAAgB,IAAIC,EAAM,SAA8BR,KAAgB,EAAE,GAC1FS,IAAeV,MAAU,SAAYA,IAAQO,GAa7CI,IAA0C;AAAA,IAC9C,OAAOD;AAAA,IACP,UAbmB,CAACE,GAA+BC,MAAqB;AACxE,YAAMC,IAAWD,IACb,CAAC,GAAGH,GAAcE,CAAY,IAC9BF,EAAa,OAAO,CAACK,MAAMA,MAAMH,CAAY;AAEjD,MAAIZ,MAAU,UACZQ,EAAiBM,CAAQ,GAE3BZ,IAAWY,CAAQ;AAAA,IACrB;AAAA,IAKE,UAAAX;AAAA,EAAA;AAIF,MAAIC,GAAS;AACX,UAAMY,IAAmBX,MAAc,eAAe,kCAAkC;AACxF,6BACGT,EAAqB,UAArB,EAA8B,OAAOe,GACpC,4BAAC,OAAA,EAAI,WAAW,GAAGK,CAAgB,IAAIV,CAAS,GAAG,QAChD,UAAAF,EAAQ,IAAI,CAACa,MACR,OAAOA,KAAW,YAAY,OAAOA,KAAW,WAEhD,gBAAAC,EAAC,SAAA,EAAmB,WAAU,4CAC5B,UAAA;AAAA,MAAA,gBAAAC,EAACC,GA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J,gBAAAvB;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,KAAKmB;AAAA,QACL,MAAK;AAAA,QACL,WAAWL;AAAA,QACX,OAAAjC;AAAA,QACA,SAASkC;AAAA,QACT,UAAUE;AAAA,QACV,UAAUD;AAAA,QACV,cAAYK;AAAA,QACX,GAAGb;AAAA,MAAA;AAAA,IAAA;AAKR,WAAI5B,IAEA,gBAAAmB,EAAC,SAAA,EAAM,WAAW,4CAA4CZ,CAAS,IACpE,UAAA;AAAA,MAAAoC;AAAA,MACD,gBAAAvB,EAAC,QAAA,EAAK,WAAU,cAAc,UAAApB,EAAA,CAAS;AAAA,IAAA,GACzC,IAIG2C;AAAA,EACT;AACF;AAEAtB,EAAa,cAAc;AAEpB,MAAMuB,IAAW,OAAO,OAAOvB,GAAc;AAAA,EAClD,OAAOtB;AACT,CAAC;"}
|
|
1
|
+
{"version":3,"file":"index10.js","sources":["../src/components/CopyButton.tsx"],"sourcesContent":["import React from 'react'\nimport { useClipboard } from '../hooks/useClipboard'\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 /** 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 <svg\n className=\"w-4 h-4\"\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\nconst CheckIcon: React.FC = () => (\n <svg\n className=\"w-4 h-4\"\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\nexport const CopyButton: React.FC<CopyButtonProps> = ({\n text,\n timeout = 2000,\n color,\n variant,\n size = 'md',\n shape,\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 { 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: 'btn-primary',\n secondary: 'btn-secondary',\n accent: 'btn-accent',\n info: 'btn-info',\n success: 'btn-success',\n warning: 'btn-warning',\n error: 'btn-error',\n neutral: 'btn-neutral',\n }\n\n const variantClasses = {\n solid: '',\n outline: 'btn-outline',\n dash: 'btn-dash',\n soft: 'btn-soft',\n ghost: 'btn-ghost',\n link: 'btn-link',\n }\n\n const sizeClasses = {\n xs: 'btn-xs',\n sm: 'btn-sm',\n md: '',\n lg: 'btn-lg',\n xl: 'btn-xl',\n }\n\n const shapeClasses = {\n square: 'btn-square',\n circle: 'btn-circle',\n }\n\n const classes = [\n 'btn',\n color && colorClasses[color],\n copied && 'btn-success',\n variant && variantClasses[variant],\n sizeClasses[size],\n shape && shapeClasses[shape],\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 {content}\n </button>\n )\n\n if (showTooltip) {\n return (\n <div className=\"tooltip\" data-tip={copied ? copiedTooltipText : tooltipText}>\n {button}\n </div>\n )\n }\n\n return button\n}\n\nCopyButton.displayName = 'CopyButton'\n"],"names":["CopyIcon","jsx","CheckIcon","CopyButton","text","timeout","color","variant","size","shape","icon","copiedIcon","children","copiedChildren","onCopy","onError","showTooltip","tooltipText","copiedTooltipText","className","disabled","onClick","rest","copy","copied","useClipboard","handleClick","e","colorClasses","variantClasses","sizeClasses","shapeClasses","classes","button"],"mappings":";;AAoCA,MAAMA,IAAqB,MACzB,gBAAAC;AAAA,EAAC;AAAA,EAAA;AAAA,IACC,WAAU;AAAA,IACV,MAAK;AAAA,IACL,SAAQ;AAAA,IACR,QAAO;AAAA,IAEP,UAAA,gBAAAA,EAAC,UAAK,eAAc,SAAQ,gBAAe,SAAQ,aAAY,KAAI,GAAE,wHAAA,CAAwH;AAAA,EAAA;AAC/L,GAGIC,IAAsB,MAC1B,gBAAAD;AAAA,EAAC;AAAA,EAAA;AAAA,IACC,WAAU;AAAA,IACV,MAAK;AAAA,IACL,SAAQ;AAAA,IACR,QAAO;AAAA,IAEP,UAAA,gBAAAA,EAAC,UAAK,eAAc,SAAQ,gBAAe,SAAQ,aAAY,KAAI,GAAE,wBAAA,CAAwB;AAAA,EAA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,CAAO;AAAA,IACjCuB,EAAYtB,CAAI;AAAA,IAChBC,KAASsB,EAAatB,CAAK;AAAA,IAC3BU;AAAA,EAAA,EAEC,OAAO,OAAO,EACd,KAAK,GAAG,GASLc,IACJ,gBAAAhC;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,MAAK;AAAA,MACL,WAAW+B;AAAA,MACX,SAASN;AAAA,MACT,UAAAN;AAAA,MACA,cAAYI,IAASN,IAAoBD;AAAA,MACxC,GAAGK;AAAA,MAEH,UAbWE,IACXX,MAHeF,KAAc,gBAAAV,EAACC,GAAA,CAAA,CAAU,KAIxCU,MALeF,KAAQ,gBAAAT,EAACD,GAAA,CAAA,CAAS;AAAA,IAgBjC;AAAA,EAAA;AAIL,SAAIgB,IAEA,gBAAAf,EAAC,SAAI,WAAU,WAAU,YAAUuB,IAASN,IAAoBD,GAC7D,UAAAgB,EAAA,CACH,IAIGA;AACT;AAEA9B,EAAW,cAAc;"}
|
package/dist/index100.js
CHANGED
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
function p(
|
|
3
|
-
const [n,
|
|
4
|
-
|
|
5
|
-
return await navigator.clipboard.writeText(i), r(!0), e(null), setTimeout(() => r(!1), t), !0;
|
|
6
|
-
} catch (o) {
|
|
7
|
-
return e(o instanceof Error ? o : new Error("Failed to copy")), r(!1), !1;
|
|
8
|
-
}
|
|
9
|
-
}, [t]), u = s(() => {
|
|
10
|
-
r(!1), e(null);
|
|
11
|
-
}, []);
|
|
12
|
-
return { copy: c, copied: n, error: l, reset: u };
|
|
1
|
+
import { useState as u, useCallback as s } from "react";
|
|
2
|
+
function p(o = !1) {
|
|
3
|
+
const [n, e] = u(o), t = s(() => e(!0), []), c = s(() => e(!1), []), l = s(() => e((r) => !r), []);
|
|
4
|
+
return { isOpen: n, onOpen: t, onClose: c, onToggle: l, setIsOpen: e };
|
|
13
5
|
}
|
|
14
6
|
export {
|
|
15
|
-
p as
|
|
7
|
+
p as useDisclosure
|
|
16
8
|
};
|
|
17
9
|
//# sourceMappingURL=index100.js.map
|
package/dist/index100.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index100.js","sources":["../src/hooks/
|
|
1
|
+
{"version":3,"file":"index100.js","sources":["../src/hooks/useDisclosure.ts"],"sourcesContent":["import { useState, useCallback } from 'react'\n\nexport interface UseDisclosureReturn {\n isOpen: boolean\n onOpen: () => void\n onClose: () => void\n onToggle: () => void\n setIsOpen: (value: boolean) => void\n}\n\n/**\n * Hook for managing open/close state of modals, drawers, dropdowns, etc.\n *\n * @param defaultIsOpen - Initial open state (default: false)\n * @returns Object with isOpen state and control functions\n *\n * @example\n * const { isOpen, onOpen, onClose } = useDisclosure()\n *\n * <Button onClick={onOpen}>Open Modal</Button>\n * <Modal open={isOpen} onClose={onClose}>Content</Modal>\n */\nexport function useDisclosure(defaultIsOpen = false): UseDisclosureReturn {\n const [isOpen, setIsOpen] = useState(defaultIsOpen)\n\n const onOpen = useCallback(() => setIsOpen(true), [])\n const onClose = useCallback(() => setIsOpen(false), [])\n const onToggle = useCallback(() => setIsOpen(prev => !prev), [])\n\n return { isOpen, onOpen, onClose, onToggle, setIsOpen }\n}\n"],"names":["useDisclosure","defaultIsOpen","isOpen","setIsOpen","useState","onOpen","useCallback","onClose","onToggle","prev"],"mappings":";AAsBO,SAASA,EAAcC,IAAgB,IAA4B;AACxE,QAAM,CAACC,GAAQC,CAAS,IAAIC,EAASH,CAAa,GAE5CI,IAASC,EAAY,MAAMH,EAAU,EAAI,GAAG,CAAA,CAAE,GAC9CI,IAAUD,EAAY,MAAMH,EAAU,EAAK,GAAG,CAAA,CAAE,GAChDK,IAAWF,EAAY,MAAMH,EAAU,OAAQ,CAACM,CAAI,GAAG,EAAE;AAE/D,SAAO,EAAE,QAAAP,GAAQ,QAAAG,GAAQ,SAAAE,GAAS,UAAAC,GAAU,WAAAL,EAAA;AAC9C;"}
|
package/dist/index101.js
CHANGED
|
@@ -1,49 +1,17 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
function
|
|
3
|
-
const [
|
|
4
|
-
if (typeof window > "u")
|
|
5
|
-
return t;
|
|
1
|
+
import { useState as a, useCallback as s } from "react";
|
|
2
|
+
function p(t = 2e3) {
|
|
3
|
+
const [n, r] = a(!1), [l, e] = a(null), c = s(async (i) => {
|
|
6
4
|
try {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return t;
|
|
5
|
+
return await navigator.clipboard.writeText(i), r(!0), e(null), setTimeout(() => r(!1), t), !0;
|
|
6
|
+
} catch (o) {
|
|
7
|
+
return e(o instanceof Error ? o : new Error("Failed to copy")), r(!1), !1;
|
|
11
8
|
}
|
|
12
|
-
}),
|
|
13
|
-
(e)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (typeof window < "u")
|
|
17
|
-
try {
|
|
18
|
-
window.localStorage.setItem(o, JSON.stringify(a));
|
|
19
|
-
} catch (l) {
|
|
20
|
-
console.warn(`Failed to save to localStorage key "${o}":`, l);
|
|
21
|
-
}
|
|
22
|
-
return a;
|
|
23
|
-
});
|
|
24
|
-
},
|
|
25
|
-
[o]
|
|
26
|
-
), w = c(() => {
|
|
27
|
-
if (typeof window < "u")
|
|
28
|
-
try {
|
|
29
|
-
window.localStorage.removeItem(o);
|
|
30
|
-
} catch (e) {
|
|
31
|
-
console.warn(`Failed to remove localStorage key "${o}":`, e);
|
|
32
|
-
}
|
|
33
|
-
n(t);
|
|
34
|
-
}, [o, t]);
|
|
35
|
-
return f(() => {
|
|
36
|
-
const e = (r) => {
|
|
37
|
-
if (r.key === o && r.newValue !== null)
|
|
38
|
-
try {
|
|
39
|
-
n(JSON.parse(r.newValue));
|
|
40
|
-
} catch {
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
return window.addEventListener("storage", e), () => window.removeEventListener("storage", e);
|
|
44
|
-
}, [o]), [s, d, w];
|
|
9
|
+
}, [t]), u = s(() => {
|
|
10
|
+
r(!1), e(null);
|
|
11
|
+
}, []);
|
|
12
|
+
return { copy: c, copied: n, error: l, reset: u };
|
|
45
13
|
}
|
|
46
14
|
export {
|
|
47
|
-
|
|
15
|
+
p as useClipboard
|
|
48
16
|
};
|
|
49
17
|
//# sourceMappingURL=index101.js.map
|
package/dist/index101.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index101.js","sources":["../src/hooks/
|
|
1
|
+
{"version":3,"file":"index101.js","sources":["../src/hooks/useClipboard.ts"],"sourcesContent":["import { useState, useCallback } from 'react'\n\nexport interface UseClipboardReturn {\n copy: (text: string) => Promise<boolean>\n copied: boolean\n error: Error | null\n reset: () => void\n}\n\n/**\n * Hook for copying text to clipboard with success/error state.\n *\n * @param timeout - Duration in ms to show copied state (default: 2000)\n * @returns Object with copy function and state\n *\n * @example\n * const { copy, copied } = useClipboard()\n *\n * <Button onClick={() => copy('Hello!')}>\n * {copied ? 'Copied!' : 'Copy'}\n * </Button>\n */\nexport function useClipboard(timeout = 2000): UseClipboardReturn {\n const [copied, setCopied] = useState(false)\n const [error, setError] = useState<Error | null>(null)\n\n const copy = useCallback(async (text: string): Promise<boolean> => {\n try {\n await navigator.clipboard.writeText(text)\n setCopied(true)\n setError(null)\n\n setTimeout(() => setCopied(false), timeout)\n return true\n } catch (err) {\n setError(err instanceof Error ? err : new Error('Failed to copy'))\n setCopied(false)\n return false\n }\n }, [timeout])\n\n const reset = useCallback(() => {\n setCopied(false)\n setError(null)\n }, [])\n\n return { copy, copied, error, reset }\n}\n"],"names":["useClipboard","timeout","copied","setCopied","useState","error","setError","copy","useCallback","text","err","reset"],"mappings":";AAsBO,SAASA,EAAaC,IAAU,KAA0B;AAC/D,QAAM,CAACC,GAAQC,CAAS,IAAIC,EAAS,EAAK,GACpC,CAACC,GAAOC,CAAQ,IAAIF,EAAuB,IAAI,GAE/CG,IAAOC,EAAY,OAAOC,MAAmC;AACjE,QAAI;AACF,mBAAM,UAAU,UAAU,UAAUA,CAAI,GACxCN,EAAU,EAAI,GACdG,EAAS,IAAI,GAEb,WAAW,MAAMH,EAAU,EAAK,GAAGF,CAAO,GACnC;AAAA,IACT,SAASS,GAAK;AACZ,aAAAJ,EAASI,aAAe,QAAQA,IAAM,IAAI,MAAM,gBAAgB,CAAC,GACjEP,EAAU,EAAK,GACR;AAAA,IACT;AAAA,EACF,GAAG,CAACF,CAAO,CAAC,GAENU,IAAQH,EAAY,MAAM;AAC9B,IAAAL,EAAU,EAAK,GACfG,EAAS,IAAI;AAAA,EACf,GAAG,CAAA,CAAE;AAEL,SAAO,EAAE,MAAAC,GAAM,QAAAL,GAAQ,OAAAG,GAAO,OAAAM,EAAA;AAChC;"}
|
package/dist/index102.js
CHANGED
|
@@ -1,16 +1,49 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
function
|
|
3
|
-
const [
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { useState as u, useCallback as c, useEffect as f } from "react";
|
|
2
|
+
function S(o, t) {
|
|
3
|
+
const [s, n] = u(() => {
|
|
4
|
+
if (typeof window > "u")
|
|
5
|
+
return t;
|
|
6
|
+
try {
|
|
7
|
+
const e = window.localStorage.getItem(o);
|
|
8
|
+
return e ? JSON.parse(e) : t;
|
|
9
|
+
} catch {
|
|
10
|
+
return t;
|
|
11
|
+
}
|
|
12
|
+
}), d = c(
|
|
13
|
+
(e) => {
|
|
14
|
+
n((r) => {
|
|
15
|
+
const a = e instanceof Function ? e(r) : e;
|
|
16
|
+
if (typeof window < "u")
|
|
17
|
+
try {
|
|
18
|
+
window.localStorage.setItem(o, JSON.stringify(a));
|
|
19
|
+
} catch (l) {
|
|
20
|
+
console.warn(`Failed to save to localStorage key "${o}":`, l);
|
|
21
|
+
}
|
|
22
|
+
return a;
|
|
23
|
+
});
|
|
24
|
+
},
|
|
25
|
+
[o]
|
|
26
|
+
), w = c(() => {
|
|
27
|
+
if (typeof window < "u")
|
|
28
|
+
try {
|
|
29
|
+
window.localStorage.removeItem(o);
|
|
30
|
+
} catch (e) {
|
|
31
|
+
console.warn(`Failed to remove localStorage key "${o}":`, e);
|
|
32
|
+
}
|
|
33
|
+
n(t);
|
|
34
|
+
}, [o, t]);
|
|
35
|
+
return f(() => {
|
|
36
|
+
const e = (r) => {
|
|
37
|
+
if (r.key === o && r.newValue !== null)
|
|
38
|
+
try {
|
|
39
|
+
n(JSON.parse(r.newValue));
|
|
40
|
+
} catch {
|
|
41
|
+
}
|
|
10
42
|
};
|
|
11
|
-
|
|
43
|
+
return window.addEventListener("storage", e), () => window.removeEventListener("storage", e);
|
|
44
|
+
}, [o]), [s, d, w];
|
|
12
45
|
}
|
|
13
46
|
export {
|
|
14
|
-
|
|
47
|
+
S as useLocalStorage
|
|
15
48
|
};
|
|
16
49
|
//# sourceMappingURL=index102.js.map
|
package/dist/index102.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index102.js","sources":["../src/hooks/
|
|
1
|
+
{"version":3,"file":"index102.js","sources":["../src/hooks/useLocalStorage.ts"],"sourcesContent":["import { useState, useCallback, useEffect } from 'react'\n\n/**\n * Hook for persisting state to localStorage.\n *\n * @param key - localStorage key\n * @param initialValue - Initial value if key doesn't exist\n * @returns [value, setValue, removeValue] tuple\n *\n * @example\n * const [theme, setTheme] = useLocalStorage('theme', 'light')\n * const [user, setUser, removeUser] = useLocalStorage('user', null)\n */\nexport function useLocalStorage<T>(\n key: string,\n initialValue: T\n): [T, (value: T | ((prev: T) => T)) => void, () => void] {\n // Get initial value from localStorage or use default\n const [storedValue, setStoredValue] = useState<T>(() => {\n if (typeof window === 'undefined') {\n return initialValue\n }\n\n try {\n const item = window.localStorage.getItem(key)\n return item ? (JSON.parse(item) as T) : initialValue\n } catch {\n return initialValue\n }\n })\n\n // Update localStorage when value changes\n const setValue = useCallback(\n (value: T | ((prev: T) => T)) => {\n setStoredValue(prev => {\n const valueToStore = value instanceof Function ? value(prev) : value\n\n if (typeof window !== 'undefined') {\n try {\n window.localStorage.setItem(key, JSON.stringify(valueToStore))\n } catch (error) {\n console.warn(`Failed to save to localStorage key \"${key}\":`, error)\n }\n }\n\n return valueToStore\n })\n },\n [key]\n )\n\n // Remove from localStorage\n const removeValue = useCallback(() => {\n if (typeof window !== 'undefined') {\n try {\n window.localStorage.removeItem(key)\n } catch (error) {\n console.warn(`Failed to remove localStorage key \"${key}\":`, error)\n }\n }\n setStoredValue(initialValue)\n }, [key, initialValue])\n\n // Sync with other tabs/windows\n useEffect(() => {\n const handleStorageChange = (e: StorageEvent) => {\n if (e.key === key && e.newValue !== null) {\n try {\n setStoredValue(JSON.parse(e.newValue) as T)\n } catch {\n // Ignore parse errors\n }\n }\n }\n\n window.addEventListener('storage', handleStorageChange)\n return () => window.removeEventListener('storage', handleStorageChange)\n }, [key])\n\n return [storedValue, setValue, removeValue]\n}\n"],"names":["useLocalStorage","key","initialValue","storedValue","setStoredValue","useState","item","setValue","useCallback","value","prev","valueToStore","error","removeValue","useEffect","handleStorageChange","e"],"mappings":";AAaO,SAASA,EACdC,GACAC,GACwD;AAExD,QAAM,CAACC,GAAaC,CAAc,IAAIC,EAAY,MAAM;AACtD,QAAI,OAAO,SAAW;AACpB,aAAOH;AAGT,QAAI;AACF,YAAMI,IAAO,OAAO,aAAa,QAAQL,CAAG;AAC5C,aAAOK,IAAQ,KAAK,MAAMA,CAAI,IAAUJ;AAAA,IAC1C,QAAQ;AACN,aAAOA;AAAA,IACT;AAAA,EACF,CAAC,GAGKK,IAAWC;AAAA,IACf,CAACC,MAAgC;AAC/B,MAAAL,EAAe,CAAAM,MAAQ;AACrB,cAAMC,IAAeF,aAAiB,WAAWA,EAAMC,CAAI,IAAID;AAE/D,YAAI,OAAO,SAAW;AACpB,cAAI;AACF,mBAAO,aAAa,QAAQR,GAAK,KAAK,UAAUU,CAAY,CAAC;AAAA,UAC/D,SAASC,GAAO;AACd,oBAAQ,KAAK,uCAAuCX,CAAG,MAAMW,CAAK;AAAA,UACpE;AAGF,eAAOD;AAAA,MACT,CAAC;AAAA,IACH;AAAA,IACA,CAACV,CAAG;AAAA,EAAA,GAIAY,IAAcL,EAAY,MAAM;AACpC,QAAI,OAAO,SAAW;AACpB,UAAI;AACF,eAAO,aAAa,WAAWP,CAAG;AAAA,MACpC,SAASW,GAAO;AACd,gBAAQ,KAAK,sCAAsCX,CAAG,MAAMW,CAAK;AAAA,MACnE;AAEF,IAAAR,EAAeF,CAAY;AAAA,EAC7B,GAAG,CAACD,GAAKC,CAAY,CAAC;AAGtB,SAAAY,EAAU,MAAM;AACd,UAAMC,IAAsB,CAACC,MAAoB;AAC/C,UAAIA,EAAE,QAAQf,KAAOe,EAAE,aAAa;AAClC,YAAI;AACF,UAAAZ,EAAe,KAAK,MAAMY,EAAE,QAAQ,CAAM;AAAA,QAC5C,QAAQ;AAAA,QAER;AAAA,IAEJ;AAEA,kBAAO,iBAAiB,WAAWD,CAAmB,GAC/C,MAAM,OAAO,oBAAoB,WAAWA,CAAmB;AAAA,EACxE,GAAG,CAACd,CAAG,CAAC,GAED,CAACE,GAAaI,GAAUM,CAAW;AAC5C;"}
|
package/dist/index103.js
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
function
|
|
3
|
-
const
|
|
1
|
+
import { useState as r, useEffect as c } from "react";
|
|
2
|
+
function i(e, t = 300) {
|
|
3
|
+
const [o, u] = r(e);
|
|
4
4
|
return c(() => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
const n = setTimeout(() => {
|
|
6
|
+
u(e);
|
|
7
|
+
}, t);
|
|
8
|
+
return () => {
|
|
9
|
+
clearTimeout(n);
|
|
9
10
|
};
|
|
10
|
-
|
|
11
|
-
document.removeEventListener("mousedown", e), document.removeEventListener("touchstart", e);
|
|
12
|
-
};
|
|
13
|
-
}, [t, n]), r;
|
|
11
|
+
}, [e, t]), o;
|
|
14
12
|
}
|
|
15
13
|
export {
|
|
16
|
-
|
|
14
|
+
i as useDebounce
|
|
17
15
|
};
|
|
18
16
|
//# sourceMappingURL=index103.js.map
|
package/dist/index103.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index103.js","sources":["../src/hooks/
|
|
1
|
+
{"version":3,"file":"index103.js","sources":["../src/hooks/useDebounce.ts"],"sourcesContent":["import { useState, useEffect } from 'react'\n\n/**\n * Hook that delays updating a value until after a specified delay.\n * Useful for search inputs to avoid excessive API calls.\n *\n * @param value - Value to debounce\n * @param delay - Delay in milliseconds (default: 300)\n * @returns Debounced value\n *\n * @example\n * const [search, setSearch] = useState('')\n * const debouncedSearch = useDebounce(search, 500)\n *\n * useEffect(() => {\n * // This runs 500ms after user stops typing\n * fetchResults(debouncedSearch)\n * }, [debouncedSearch])\n */\nexport function useDebounce<T>(value: T, delay = 300): T {\n const [debouncedValue, setDebouncedValue] = useState<T>(value)\n\n useEffect(() => {\n const timer = setTimeout(() => {\n setDebouncedValue(value)\n }, delay)\n\n return () => {\n clearTimeout(timer)\n }\n }, [value, delay])\n\n return debouncedValue\n}\n"],"names":["useDebounce","value","delay","debouncedValue","setDebouncedValue","useState","useEffect","timer"],"mappings":";AAmBO,SAASA,EAAeC,GAAUC,IAAQ,KAAQ;AACvD,QAAM,CAACC,GAAgBC,CAAiB,IAAIC,EAAYJ,CAAK;AAE7D,SAAAK,EAAU,MAAM;AACd,UAAMC,IAAQ,WAAW,MAAM;AAC7B,MAAAH,EAAkBH,CAAK;AAAA,IACzB,GAAGC,CAAK;AAER,WAAO,MAAM;AACX,mBAAaK,CAAK;AAAA,IACpB;AAAA,EACF,GAAG,CAACN,GAAOC,CAAK,CAAC,GAEVC;AACT;"}
|
package/dist/index104.js
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
import { useRef as
|
|
2
|
-
function
|
|
3
|
-
const
|
|
4
|
-
return
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { useRef as s, useEffect as c } from "react";
|
|
2
|
+
function m(t, n = !0) {
|
|
3
|
+
const r = s(null);
|
|
4
|
+
return c(() => {
|
|
5
|
+
if (!n) return;
|
|
6
|
+
const e = (o) => {
|
|
7
|
+
const u = r.current;
|
|
8
|
+
!u || u.contains(o.target) || t(o);
|
|
9
|
+
};
|
|
10
|
+
return document.addEventListener("mousedown", e), document.addEventListener("touchstart", e), () => {
|
|
11
|
+
document.removeEventListener("mousedown", e), document.removeEventListener("touchstart", e);
|
|
12
|
+
};
|
|
13
|
+
}, [t, n]), r;
|
|
7
14
|
}
|
|
8
15
|
export {
|
|
9
|
-
|
|
16
|
+
m as useClickOutside
|
|
10
17
|
};
|
|
11
18
|
//# sourceMappingURL=index104.js.map
|
package/dist/index104.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index104.js","sources":["../src/hooks/
|
|
1
|
+
{"version":3,"file":"index104.js","sources":["../src/hooks/useClickOutside.ts"],"sourcesContent":["import { useEffect, useRef, type RefObject } from 'react'\n\n/**\n * Hook that detects clicks outside of a referenced element.\n * Useful for closing dropdowns, modals, or menus.\n *\n * @param handler - Callback when click outside is detected\n * @param enabled - Whether the listener is active (default: true)\n * @returns Ref to attach to the element\n *\n * @example\n * const ref = useClickOutside(() => setIsOpen(false))\n *\n * <div ref={ref}>\n * <Dropdown>...</Dropdown>\n * </div>\n */\nexport function useClickOutside<T extends HTMLElement = HTMLElement>(\n handler: (event: MouseEvent | TouchEvent) => void,\n enabled = true\n): RefObject<T | null> {\n const ref = useRef<T>(null)\n\n useEffect(() => {\n if (!enabled) return\n\n const listener = (event: MouseEvent | TouchEvent) => {\n const el = ref.current\n if (!el || el.contains(event.target as Node)) {\n return\n }\n handler(event)\n }\n\n document.addEventListener('mousedown', listener)\n document.addEventListener('touchstart', listener)\n\n return () => {\n document.removeEventListener('mousedown', listener)\n document.removeEventListener('touchstart', listener)\n }\n }, [handler, enabled])\n\n return ref\n}\n"],"names":["useClickOutside","handler","enabled","ref","useRef","useEffect","listener","event","el"],"mappings":";AAiBO,SAASA,EACdC,GACAC,IAAU,IACW;AACrB,QAAMC,IAAMC,EAAU,IAAI;AAE1B,SAAAC,EAAU,MAAM;AACd,QAAI,CAACH,EAAS;AAEd,UAAMI,IAAW,CAACC,MAAmC;AACnD,YAAMC,IAAKL,EAAI;AACf,MAAI,CAACK,KAAMA,EAAG,SAASD,EAAM,MAAc,KAG3CN,EAAQM,CAAK;AAAA,IACf;AAEA,oBAAS,iBAAiB,aAAaD,CAAQ,GAC/C,SAAS,iBAAiB,cAAcA,CAAQ,GAEzC,MAAM;AACX,eAAS,oBAAoB,aAAaA,CAAQ,GAClD,SAAS,oBAAoB,cAAcA,CAAQ;AAAA,IACrD;AAAA,EACF,GAAG,CAACL,GAASC,CAAO,CAAC,GAEdC;AACT;"}
|
package/dist/index105.js
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
function f() {
|
|
3
|
-
const
|
|
4
|
-
return
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const r = () => t(!0), s = () => t(!1);
|
|
8
|
-
return e.addEventListener("mouseenter", r), e.addEventListener("mouseleave", s), () => {
|
|
9
|
-
e.removeEventListener("mouseenter", r), e.removeEventListener("mouseleave", s);
|
|
10
|
-
};
|
|
11
|
-
}, []), { ref: n, isHovered: o };
|
|
1
|
+
import { useRef as t, useEffect as o } from "react";
|
|
2
|
+
function f(r) {
|
|
3
|
+
const e = t(void 0);
|
|
4
|
+
return o(() => {
|
|
5
|
+
e.current = r;
|
|
6
|
+
}, [r]), e.current;
|
|
12
7
|
}
|
|
13
8
|
export {
|
|
14
|
-
f as
|
|
9
|
+
f as usePrevious
|
|
15
10
|
};
|
|
16
11
|
//# sourceMappingURL=index105.js.map
|
package/dist/index105.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index105.js","sources":["../src/hooks/
|
|
1
|
+
{"version":3,"file":"index105.js","sources":["../src/hooks/usePrevious.ts"],"sourcesContent":["import { useRef, useEffect } from 'react'\n\n/**\n * Hook that returns the previous value of a variable.\n * Useful for comparing current and previous values in effects.\n *\n * @param value - Current value\n * @returns Previous value (undefined on first render)\n *\n * @example\n * const [count, setCount] = useState(0)\n * const prevCount = usePrevious(count)\n *\n * // prevCount is the value from previous render\n * console.log(`Changed from ${prevCount} to ${count}`)\n */\nexport function usePrevious<T>(value: T): T | undefined {\n const ref = useRef<T | undefined>(undefined)\n\n useEffect(() => {\n ref.current = value\n }, [value])\n\n return ref.current\n}\n"],"names":["usePrevious","value","ref","useRef","useEffect"],"mappings":";AAgBO,SAASA,EAAeC,GAAyB;AACtD,QAAMC,IAAMC,EAAsB,MAAS;AAE3C,SAAAC,EAAU,MAAM;AACd,IAAAF,EAAI,UAAUD;AAAA,EAChB,GAAG,CAACA,CAAK,CAAC,GAEHC,EAAI;AACb;"}
|