@snowztech/ui 0.1.0 → 0.3.0
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/client.cjs +18 -76
- package/dist/client.cjs.map +1 -1
- package/dist/client.js +19 -54
- package/dist/client.js.map +1 -1
- package/dist/index.cjs +139 -133
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +58 -18
- package/dist/index.d.ts +58 -18
- package/dist/index.js +308 -135
- package/dist/index.js.map +1 -1
- package/package.json +6 -1
- package/src/styles.css +1 -0
- package/src/tokens.css +1 -252
- package/dist/chunk-XYNFF4B5.js +0 -178
- package/dist/chunk-XYNFF4B5.js.map +0 -1
package/dist/client.cjs
CHANGED
|
@@ -25,6 +25,7 @@ function _interopNamespace(e) {
|
|
|
25
25
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
26
26
|
|
|
27
27
|
// src/theme-toggle.tsx
|
|
28
|
+
var cx = (...parts) => parts.filter(Boolean).join(" ");
|
|
28
29
|
function ThemeToggle({
|
|
29
30
|
size = 12,
|
|
30
31
|
storageKey = "theme",
|
|
@@ -46,108 +47,49 @@ function ThemeToggle({
|
|
|
46
47
|
if (next === "light") document.documentElement.setAttribute("data-theme", "light");
|
|
47
48
|
else document.documentElement.removeAttribute("data-theme");
|
|
48
49
|
};
|
|
49
|
-
const filled = theme === "dark";
|
|
50
50
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
51
51
|
"button",
|
|
52
52
|
{
|
|
53
53
|
type: "button",
|
|
54
54
|
onClick: toggle,
|
|
55
|
-
"aria-label": `switch to ${
|
|
56
|
-
className,
|
|
55
|
+
"aria-label": `switch to ${theme === "dark" ? "light" : "dark"} mode`,
|
|
56
|
+
className: cx("sn-theme-toggle", className),
|
|
57
57
|
style: {
|
|
58
|
-
|
|
59
|
-
border: "none",
|
|
60
|
-
background: "transparent",
|
|
61
|
-
padding: 6,
|
|
62
|
-
cursor: "pointer",
|
|
63
|
-
display: "inline-flex",
|
|
64
|
-
alignItems: "center",
|
|
65
|
-
justifyContent: "center",
|
|
58
|
+
["--sn-theme-toggle-size"]: `${size}px`,
|
|
66
59
|
opacity: mounted ? 1 : 0,
|
|
67
|
-
transition: "opacity 200ms",
|
|
68
60
|
...style
|
|
69
61
|
},
|
|
70
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
71
|
-
"span",
|
|
72
|
-
{
|
|
73
|
-
style: {
|
|
74
|
-
display: "inline-block",
|
|
75
|
-
width: size,
|
|
76
|
-
height: size,
|
|
77
|
-
borderRadius: "50%",
|
|
78
|
-
border: `1px solid var(--sn-fg-muted)`,
|
|
79
|
-
background: filled ? "var(--sn-fg)" : "transparent",
|
|
80
|
-
transition: "background 160ms ease"
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
)
|
|
62
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sn-theme-toggle__indicator" })
|
|
84
63
|
}
|
|
85
64
|
);
|
|
86
65
|
}
|
|
87
|
-
var
|
|
88
|
-
size = 16,
|
|
89
|
-
stroke = 1.5,
|
|
90
|
-
color = "currentColor",
|
|
91
|
-
style,
|
|
92
|
-
children
|
|
93
|
-
}) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
94
|
-
"svg",
|
|
95
|
-
{
|
|
96
|
-
width: size,
|
|
97
|
-
height: size,
|
|
98
|
-
viewBox: "0 0 24 24",
|
|
99
|
-
fill: "none",
|
|
100
|
-
stroke: color,
|
|
101
|
-
strokeWidth: stroke,
|
|
102
|
-
strokeLinecap: "round",
|
|
103
|
-
strokeLinejoin: "round",
|
|
104
|
-
style: { display: "inline-block", verticalAlign: "middle", ...style },
|
|
105
|
-
"aria-hidden": "true",
|
|
106
|
-
children
|
|
107
|
-
}
|
|
108
|
-
);
|
|
109
|
-
var CheckIcon = (p) => /* @__PURE__ */ jsxRuntime.jsx(Icon, { ...p, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m4 12 5 5L20 6" }) });
|
|
66
|
+
var cx2 = (...parts) => parts.filter(Boolean).join(" ");
|
|
110
67
|
function CopyButton({ value, size = 14, className, style }) {
|
|
111
68
|
const [copied, setCopied] = React__namespace.useState(false);
|
|
112
69
|
const onCopy = async () => {
|
|
113
70
|
try {
|
|
114
71
|
await navigator.clipboard.writeText(value);
|
|
115
72
|
setCopied(true);
|
|
116
|
-
setTimeout(() => setCopied(false), 1200);
|
|
73
|
+
window.setTimeout(() => setCopied(false), 1200);
|
|
117
74
|
} catch {
|
|
118
75
|
}
|
|
119
76
|
};
|
|
120
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
77
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
121
78
|
"button",
|
|
122
79
|
{
|
|
123
80
|
type: "button",
|
|
124
81
|
onClick: onCopy,
|
|
125
82
|
"aria-label": copied ? "copied" : "copy",
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
justifyContent: "center",
|
|
137
|
-
borderRadius: "var(--sn-r-xs)",
|
|
138
|
-
transition: "color 120ms ease, border-color 120ms ease",
|
|
139
|
-
...style
|
|
140
|
-
},
|
|
141
|
-
onMouseEnter: (e) => {
|
|
142
|
-
if (!copied) e.currentTarget.style.color = "var(--sn-fg)";
|
|
143
|
-
},
|
|
144
|
-
onMouseLeave: (e) => {
|
|
145
|
-
if (!copied) e.currentTarget.style.color = "var(--sn-fg-muted)";
|
|
146
|
-
},
|
|
147
|
-
children: copied ? /* @__PURE__ */ jsxRuntime.jsx(CheckIcon, { size }) : /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
148
|
-
/* @__PURE__ */ jsxRuntime.jsx("rect", { x: "9", y: "9", width: "11", height: "11", rx: "1.5" }),
|
|
149
|
-
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M5 15V5a1 1 0 0 1 1-1h10" })
|
|
150
|
-
] })
|
|
83
|
+
"data-copied": copied || void 0,
|
|
84
|
+
className: cx2("sn-copy-btn", className),
|
|
85
|
+
style,
|
|
86
|
+
children: [
|
|
87
|
+
/* @__PURE__ */ jsxRuntime.jsxs("svg", { className: "sn-copy-btn__idle", width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
88
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { x: "9", y: "9", width: "11", height: "11", rx: "1.5" }),
|
|
89
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M5 15V5a1 1 0 0 1 1-1h10" })
|
|
90
|
+
] }),
|
|
91
|
+
/* @__PURE__ */ jsxRuntime.jsx("svg", { className: "sn-copy-btn__copied", width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m4 12 5 5L20 6" }) })
|
|
92
|
+
]
|
|
151
93
|
}
|
|
152
94
|
);
|
|
153
95
|
}
|
package/dist/client.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/theme-toggle.tsx","../src/icons.tsx","../src/copy-button.tsx"],"names":["React","jsx","React2","jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAYO,SAAS,WAAA,CAAY;AAAA,EAC1B,IAAA,GAAO,EAAA;AAAA,EACP,UAAA,GAAa,OAAA;AAAA,EACb,YAAA,GAAe,MAAA;AAAA,EACf,SAAA;AAAA,EACA;AACF,CAAA,EAAqB;AACnB,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAUA,0BA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E,aAAA,CAAc,MAAM,KAAA,GAAQ,oBAAA;AAAA,MAC7C,CAAA;AAAA,MAEC,QAAA,EAAA,MAAA,mBACCA,cAAAA,CAAC,SAAA,EAAA,EAAU,IAAA,EAAY,CAAA,mBAEvBE,eAAAA,CAAC,KAAA,EAAA,EAAI,KAAA,EAAO,IAAA,EAAM,MAAA,EAAQ,IAAA,EAAM,SAAQ,WAAA,EAAY,IAAA,EAAK,MAAA,EAAO,MAAA,EAAO,cAAA,EAAe,WAAA,EAAY,KAAA,EAAM,aAAA,EAAc,OAAA,EAAQ,cAAA,EAAe,OAAA,EAAQ,aAAA,EAAY,MAAA,EAC/J,QAAA,EAAA;AAAA,wBAAAF,cAAAA,CAAC,MAAA,EAAA,EAAK,CAAA,EAAE,GAAA,EAAI,CAAA,EAAE,GAAA,EAAI,KAAA,EAAM,IAAA,EAAK,MAAA,EAAO,IAAA,EAAK,EAAA,EAAG,KAAA,EAAM,CAAA;AAAA,wBAClDA,cAAAA,CAAC,MAAA,EAAA,EAAK,CAAA,EAAE,0BAAA,EAA2B;AAAA,OAAA,EACrC;AAAA;AAAA,GAEJ;AAEJ","file":"client.cjs","sourcesContent":["import * as React from \"react\";\n\nexport type Theme = \"light\" | \"dark\";\n\nexport interface ThemeToggleProps {\n size?: number;\n storageKey?: string;\n defaultTheme?: Theme;\n className?: string;\n style?: React.CSSProperties;\n}\n\nexport function ThemeToggle({\n size = 12,\n storageKey = \"theme\",\n defaultTheme = \"dark\",\n className,\n style,\n}: ThemeToggleProps) {\n const [theme, setTheme] = React.useState<Theme>(defaultTheme);\n const [mounted, setMounted] = React.useState(false);\n\n React.useEffect(() => {\n const stored = (localStorage.getItem(storageKey) as Theme | null) ?? defaultTheme;\n setTheme(stored);\n setMounted(true);\n }, [storageKey, defaultTheme]);\n\n const toggle = () => {\n const next: Theme = theme === \"dark\" ? \"light\" : \"dark\";\n setTheme(next);\n localStorage.setItem(storageKey, next);\n if (next === \"light\") document.documentElement.setAttribute(\"data-theme\", \"light\");\n else document.documentElement.removeAttribute(\"data-theme\");\n };\n\n const filled = theme === \"dark\";\n\n return (\n <button\n type=\"button\"\n onClick={toggle}\n aria-label={`switch to ${filled ? \"light\" : \"dark\"} mode`}\n className={className}\n style={{\n appearance: \"none\",\n border: \"none\",\n background: \"transparent\",\n padding: 6,\n cursor: \"pointer\",\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n opacity: mounted ? 1 : 0,\n transition: \"opacity 200ms\",\n ...style,\n }}\n >\n <span\n style={{\n display: \"inline-block\",\n width: size,\n height: size,\n borderRadius: \"50%\",\n border: `1px solid var(--sn-fg-muted)`,\n background: filled ? \"var(--sn-fg)\" : \"transparent\",\n transition: \"background 160ms ease\",\n }}\n />\n </button>\n );\n}\n","import * as React from \"react\";\n\nexport interface IconProps {\n size?: number;\n stroke?: number;\n color?: string;\n style?: React.CSSProperties;\n children?: React.ReactNode;\n}\n\nexport const Icon = ({\n size = 16,\n stroke = 1.5,\n color = \"currentColor\",\n style,\n children,\n}: IconProps) => (\n <svg\n width={size}\n height={size}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={color}\n strokeWidth={stroke}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n style={{ display: \"inline-block\", verticalAlign: \"middle\", ...style }}\n aria-hidden=\"true\"\n >\n {children}\n </svg>\n);\n\ntype P = Omit<IconProps, \"children\">;\n\nexport const SearchIcon = (p: P) => <Icon {...p}><circle cx=\"11\" cy=\"11\" r=\"6\" /><path d=\"m20 20-3.5-3.5\" /></Icon>;\nexport const TerminalIcon = (p: P) => <Icon {...p}><path d=\"m5 8 4 4-4 4\" /><path d=\"M13 16h6\" /><rect x=\"2.5\" y=\"4\" width=\"19\" height=\"16\" rx=\"1.5\" /></Icon>;\nexport const CodeIcon = (p: P) => <Icon {...p}><path d=\"m8 7-5 5 5 5\" /><path d=\"m16 7 5 5-5 5\" /><path d=\"m14 4-4 16\" /></Icon>;\nexport const GitIcon = (p: P) => <Icon {...p}><circle cx=\"6\" cy=\"6\" r=\"2.5\" /><circle cx=\"18\" cy=\"18\" r=\"2.5\" /><circle cx=\"6\" cy=\"18\" r=\"2.5\" /><path d=\"M6 8.5v7\" /><path d=\"M8.5 6h6.5a2.5 2.5 0 0 1 2.5 2.5v7\" /></Icon>;\nexport const PlusIcon = (p: P) => <Icon {...p}><path d=\"M12 5v14\" /><path d=\"M5 12h14\" /></Icon>;\nexport const MinusIcon = (p: P) => <Icon {...p}><path d=\"M5 12h14\" /></Icon>;\nexport const CheckIcon = (p: P) => <Icon {...p}><path d=\"m4 12 5 5L20 6\" /></Icon>;\nexport const XIcon = (p: P) => <Icon {...p}><path d=\"M6 6 18 18\" /><path d=\"m18 6-12 12\" /></Icon>;\nexport const ChevronDownIcon = (p: P) => <Icon {...p}><path d=\"m6 9 6 6 6-6\" /></Icon>;\nexport const ChevronRightIcon = (p: P) => <Icon {...p}><path d=\"m9 6 6 6-6 6\" /></Icon>;\nexport const ChevronLeftIcon = (p: P) => <Icon {...p}><path d=\"m15 6-6 6 6 6\" /></Icon>;\nexport const ArrowRightIcon = (p: P) => <Icon {...p}><path d=\"M5 12h14\" /><path d=\"m13 6 6 6-6 6\" /></Icon>;\nexport const ArrowUpRightIcon = (p: P) => <Icon {...p}><path d=\"M7 17 17 7\" /><path d=\"M8 7h9v9\" /></Icon>;\nexport const ExternalLinkIcon = (p: P) => <Icon {...p}><path d=\"M14 4h6v6\" /><path d=\"M20 4 10 14\" /><path d=\"M19 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h5\" /></Icon>;\nexport const SettingsIcon = (p: P) => <Icon {...p}><circle cx=\"12\" cy=\"12\" r=\"3\" /><path d=\"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 1 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33h0a1.65 1.65 0 0 0 1-1.51V3a2 2 0 1 1 4 0v.09a1.65 1.65 0 0 0 1 1.51h0a1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82h0a1.65 1.65 0 0 0 1.51 1H21a2 2 0 1 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z\" /></Icon>;\nexport const UserIcon = (p: P) => <Icon {...p}><circle cx=\"12\" cy=\"8\" r=\"4\" /><path d=\"M4 21v-1a6 6 0 0 1 6-6h4a6 6 0 0 1 6 6v1\" /></Icon>;\nexport const FolderIcon = (p: P) => <Icon {...p}><path d=\"M3 6.5A1.5 1.5 0 0 1 4.5 5h4l2 2.5h9A1.5 1.5 0 0 1 21 9v9.5A1.5 1.5 0 0 1 19.5 20h-15A1.5 1.5 0 0 1 3 18.5z\" /></Icon>;\nexport const FileIcon = (p: P) => <Icon {...p}><path d=\"M14 3H6a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V8z\" /><path d=\"M14 3v5h5\" /></Icon>;\nexport const BellIcon = (p: P) => <Icon {...p}><path d=\"M6 9a6 6 0 1 1 12 0v4l1.5 3h-15L6 13z\" /><path d=\"M10 19a2 2 0 0 0 4 0\" /></Icon>;\nexport const ActivityIcon = (p: P) => <Icon {...p}><path d=\"M3 12h4l3-8 4 16 3-8h4\" /></Icon>;\nexport const PulseIcon = (p: P) => <Icon {...p}><path d=\"M3 12h3l2-4 4 8 2-4h7\" /></Icon>;\nexport const CubeIcon = (p: P) => <Icon {...p}><path d=\"m12 2 9 5v10l-9 5-9-5V7z\" /><path d=\"m3 7 9 5 9-5\" /><path d=\"M12 22V12\" /></Icon>;\nexport const LayersIcon = (p: P) => <Icon {...p}><path d=\"m12 3 9 5-9 5-9-5z\" /><path d=\"m3 13 9 5 9-5\" /><path d=\"m3 18 9 5 9-5\" /></Icon>;\nexport const DatabaseIcon = (p: P) => <Icon {...p}><ellipse cx=\"12\" cy=\"5\" rx=\"8\" ry=\"3\" /><path d=\"M4 5v6c0 1.7 3.6 3 8 3s8-1.3 8-3V5\" /><path d=\"M4 11v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6\" /></Icon>;\nexport const CloudIcon = (p: P) => <Icon {...p}><path d=\"M7 18a5 5 0 1 1 1-9.9A6 6 0 0 1 19.5 11 4 4 0 0 1 18 18z\" /></Icon>;\nexport const SunIcon = (p: P) => <Icon {...p}><circle cx=\"12\" cy=\"12\" r=\"4\" /><path d=\"M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4\" /></Icon>;\nexport const MoonIcon = (p: P) => <Icon {...p}><path d=\"M20 14a8 8 0 1 1-9.9-9.9 7 7 0 0 0 9.9 9.9z\" /></Icon>;\nexport const GithubIcon = (p: P) => <Icon {...p}><path d=\"M9 19c-4 1-4-2-6-2.5M15 22v-4a3 3 0 0 0-1-2.5c3 0 6-2 6-5.5a5 5 0 0 0-1.4-3.5 4.7 4.7 0 0 0-.1-3.5s-1.1-.4-3.5 1.3a12 12 0 0 0-6 0C6.6 1.6 5.5 2 5.5 2a4.7 4.7 0 0 0-.1 3.5A5 5 0 0 0 4 9c0 3.5 3 5.5 6 5.5a3 3 0 0 0-1 2.5v4\" /></Icon>;\nexport const MailIcon = (p: P) => <Icon {...p}><rect x=\"3\" y=\"5\" width=\"18\" height=\"14\" rx=\"1.5\" /><path d=\"m3.5 6.5 8.5 7 8.5-7\" /></Icon>;\nexport const EyeIcon = (p: P) => <Icon {...p}><path d=\"M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7z\" /><circle cx=\"12\" cy=\"12\" r=\"3\" /></Icon>;\nexport const LockIcon = (p: P) => <Icon {...p}><rect x=\"4\" y=\"11\" width=\"16\" height=\"10\" rx=\"1.5\" /><path d=\"M8 11V7a4 4 0 0 1 8 0v4\" /></Icon>;\nexport const BoltIcon = (p: P) => <Icon {...p}><path d=\"M13 2 4 14h7l-2 8 9-12h-7z\" /></Icon>;\nexport const StarIcon = (p: P) => <Icon {...p}><path d=\"m12 3 2.7 6 6.3.6-4.7 4.4 1.4 6.5L12 17l-5.7 3.5 1.4-6.5L3 9.6l6.3-.6z\" /></Icon>;\nexport const HeartIcon = (p: P) => <Icon {...p}><path d=\"M12 20s-7-4.5-7-10a4 4 0 0 1 7-2.6A4 4 0 0 1 19 10c0 5.5-7 10-7 10z\" /></Icon>;\nexport const TrashIcon = (p: P) => <Icon {...p}><path d=\"M3 6h18\" /><path d=\"M8 6V4a1 1 0 0 1 1-1h6a1 1 0 0 1 1 1v2\" /><path d=\"M5 6v14a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V6\" /><path d=\"M10 11v6M14 11v6\" /></Icon>;\nexport const EditIcon = (p: P) => <Icon {...p}><path d=\"M11 4H5a1 1 0 0 0-1 1v14a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1v-6\" /><path d=\"m18.5 2.5 3 3L12 15l-4 1 1-4z\" /></Icon>;\nexport const FilterIcon = (p: P) => <Icon {...p}><path d=\"M3 5h18l-7 9v6l-4-2v-4z\" /></Icon>;\nexport const MenuIcon = (p: P) => <Icon {...p}><path d=\"M4 7h16M4 12h16M4 17h16\" /></Icon>;\nexport const GridIcon = (p: P) => <Icon {...p}><rect x=\"3\" y=\"3\" width=\"7\" height=\"7\" rx=\"1\" /><rect x=\"14\" y=\"3\" width=\"7\" height=\"7\" rx=\"1\" /><rect x=\"3\" y=\"14\" width=\"7\" height=\"7\" rx=\"1\" /><rect x=\"14\" y=\"14\" width=\"7\" height=\"7\" rx=\"1\" /></Icon>;\nexport const InboxIcon = (p: P) => <Icon {...p}><path d=\"M3 13h5l1.5 2.5h5L16 13h5\" /><path d=\"M5 4h14l2 9v6a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1v-6z\" /></Icon>;\nexport const CalendarIcon = (p: P) => <Icon {...p}><rect x=\"3\" y=\"5\" width=\"18\" height=\"16\" rx=\"1.5\" /><path d=\"M3 10h18M8 3v4M16 3v4\" /></Icon>;\nexport const ClockIcon = (p: P) => <Icon {...p}><circle cx=\"12\" cy=\"12\" r=\"9\" /><path d=\"M12 7v5l3 2\" /></Icon>;\nexport const InfoIcon = (p: P) => <Icon {...p}><circle cx=\"12\" cy=\"12\" r=\"9\" /><path d=\"M12 11v6\" /><circle cx=\"12\" cy=\"8\" r=\"0.5\" fill=\"currentColor\" /></Icon>;\nexport const WarningIcon = (p: P) => <Icon {...p}><path d=\"M11 3 2 19a1 1 0 0 0 .9 1.5h18.2A1 1 0 0 0 22 19L13 3a1 1 0 0 0-2 0z\" /><path d=\"M12 9v5\" /><circle cx=\"12\" cy=\"17\" r=\"0.5\" fill=\"currentColor\" /></Icon>;\nexport const ZapIcon = (p: P) => <Icon {...p}><path d=\"M13 2 4 14h7l-2 8 9-12h-7z\" /></Icon>;\nexport const DiscordIcon = (p: P) => <Icon {...p}><path d=\"M19 6s-2.5-2-5-2l-.3.5c2.3.5 3.3 1.5 3.3 1.5s-2-1-4-1c-1 0-2 .1-3 .3-1-.2-2-.3-3-.3-2 0-4 1-4 1S4 5 6.3 4.5L6 4C3.5 4 1 6 1 6s-2.5 4-2 11c1.5 2 3.5 2 3.5 2L4 17c-1-.5-2-1.5-2-1.5 2 1.5 4 2 4 2l1-2.5s4 1.5 6 1.5 6-1.5 6-1.5l1 2.5s2-.5 4-2c0 0-1 1-2 1.5l1.5 2s2 0 3.5-2c.5-7-2-11-2-11z\" /><circle cx=\"9\" cy=\"11.5\" r=\"1.5\" fill=\"currentColor\" stroke=\"none\" /><circle cx=\"15\" cy=\"11.5\" r=\"1.5\" fill=\"currentColor\" stroke=\"none\" /></Icon>;\n","import * as React from \"react\";\nimport { CheckIcon } from \"./icons\";\n\nexport interface CopyButtonProps {\n value: string;\n size?: number;\n className?: string;\n style?: React.CSSProperties;\n}\n\nexport function CopyButton({ value, size = 14, className, style }: CopyButtonProps) {\n const [copied, setCopied] = React.useState(false);\n\n const onCopy = async () => {\n try {\n await navigator.clipboard.writeText(value);\n setCopied(true);\n setTimeout(() => setCopied(false), 1200);\n } catch {\n // ignored\n }\n };\n\n return (\n <button\n type=\"button\"\n onClick={onCopy}\n aria-label={copied ? \"copied\" : \"copy\"}\n className={className}\n style={{\n appearance: \"none\",\n border: \"1px solid transparent\",\n background: \"transparent\",\n color: copied ? \"var(--sn-success)\" : \"var(--sn-fg-muted)\",\n padding: 6,\n cursor: \"pointer\",\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n borderRadius: \"var(--sn-r-xs)\",\n transition: \"color 120ms ease, border-color 120ms ease\",\n ...style,\n }}\n onMouseEnter={(e) => {\n if (!copied) e.currentTarget.style.color = \"var(--sn-fg)\";\n }}\n onMouseLeave={(e) => {\n if (!copied) e.currentTarget.style.color = \"var(--sn-fg-muted)\";\n }}\n >\n {copied ? (\n <CheckIcon size={size} />\n ) : (\n <svg width={size} height={size} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n <rect x=\"9\" y=\"9\" width=\"11\" height=\"11\" rx=\"1.5\" />\n <path d=\"M5 15V5a1 1 0 0 1 1-1h10\" />\n </svg>\n )}\n </button>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/theme-toggle.tsx","../src/copy-button.tsx"],"names":["React","jsx","cx","React2","jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;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BAAA,EAAoB,KAAA,EAAO,MAAM,MAAA,EAAQ,IAAA,EAAM,SAAQ,WAAA,EAAY,IAAA,EAAK,QAAO,MAAA,EAAO,cAAA,EAAe,aAAY,KAAA,EAAM,aAAA,EAAc,SAAQ,cAAA,EAAe,OAAA,EAAQ,eAAY,MAAA,EAC7L,QAAA,EAAA;AAAA,0BAAAH,cAAAA,CAAC,MAAA,EAAA,EAAK,CAAA,EAAE,GAAA,EAAI,CAAA,EAAE,GAAA,EAAI,KAAA,EAAM,IAAA,EAAK,MAAA,EAAO,IAAA,EAAK,EAAA,EAAG,KAAA,EAAM,CAAA;AAAA,0BAClDA,cAAAA,CAAC,MAAA,EAAA,EAAK,CAAA,EAAE,0BAAA,EAA2B;AAAA,SAAA,EACrC,CAAA;AAAA,wBACAA,cAAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,qBAAA,EAAsB,KAAA,EAAO,IAAA,EAAM,MAAA,EAAQ,IAAA,EAAM,OAAA,EAAQ,WAAA,EAAY,IAAA,EAAK,MAAA,EAAO,MAAA,EAAO,cAAA,EAAe,WAAA,EAAY,KAAA,EAAM,aAAA,EAAc,OAAA,EAAQ,cAAA,EAAe,OAAA,EAAQ,aAAA,EAAY,MAAA,EAC/L,QAAA,kBAAAA,cAAAA,CAAC,MAAA,EAAA,EAAK,CAAA,EAAE,gBAAA,EAAiB,CAAA,EAC3B;AAAA;AAAA;AAAA,GACF;AAEJ","file":"client.cjs","sourcesContent":["import * as React from \"react\";\n\nconst cx = (...parts: Array<string | undefined | false>) => parts.filter(Boolean).join(\" \");\n\nexport type Theme = \"light\" | \"dark\";\n\nexport interface ThemeToggleProps {\n size?: number;\n storageKey?: string;\n defaultTheme?: Theme;\n className?: string;\n style?: React.CSSProperties;\n}\n\nexport function ThemeToggle({\n size = 12,\n storageKey = \"theme\",\n defaultTheme = \"dark\",\n className,\n style,\n}: ThemeToggleProps) {\n const [theme, setTheme] = React.useState<Theme>(defaultTheme);\n const [mounted, setMounted] = React.useState(false);\n\n React.useEffect(() => {\n const stored = (localStorage.getItem(storageKey) as Theme | null) ?? defaultTheme;\n setTheme(stored);\n setMounted(true);\n }, [storageKey, defaultTheme]);\n\n const toggle = () => {\n const next: Theme = theme === \"dark\" ? \"light\" : \"dark\";\n setTheme(next);\n localStorage.setItem(storageKey, next);\n if (next === \"light\") document.documentElement.setAttribute(\"data-theme\", \"light\");\n else document.documentElement.removeAttribute(\"data-theme\");\n };\n\n return (\n <button\n type=\"button\"\n onClick={toggle}\n aria-label={`switch to ${theme === \"dark\" ? \"light\" : \"dark\"} mode`}\n className={cx(\"sn-theme-toggle\", className)}\n style={{\n [\"--sn-theme-toggle-size\" as string]: `${size}px`,\n opacity: mounted ? 1 : 0,\n ...style,\n }}\n >\n <span className=\"sn-theme-toggle__indicator\" />\n </button>\n );\n}\n","import * as React from \"react\";\n\nconst cx = (...parts: Array<string | undefined | false>) => parts.filter(Boolean).join(\" \");\n\nexport interface CopyButtonProps {\n value: string;\n size?: number;\n className?: string;\n style?: React.CSSProperties;\n}\n\nexport function CopyButton({ value, size = 14, className, style }: CopyButtonProps) {\n const [copied, setCopied] = React.useState(false);\n\n const onCopy = async () => {\n try {\n await navigator.clipboard.writeText(value);\n setCopied(true);\n window.setTimeout(() => setCopied(false), 1200);\n } catch {\n // ignored\n }\n };\n\n return (\n <button\n type=\"button\"\n onClick={onCopy}\n aria-label={copied ? \"copied\" : \"copy\"}\n data-copied={copied || undefined}\n className={cx(\"sn-copy-btn\", className)}\n style={style}\n >\n <svg className=\"sn-copy-btn__idle\" width={size} height={size} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n <rect x=\"9\" y=\"9\" width=\"11\" height=\"11\" rx=\"1.5\" />\n <path d=\"M5 15V5a1 1 0 0 1 1-1h10\" />\n </svg>\n <svg className=\"sn-copy-btn__copied\" width={size} height={size} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n <path d=\"m4 12 5 5L20 6\" />\n </svg>\n </button>\n );\n}\n"]}
|
package/dist/client.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { CheckIcon } from './chunk-XYNFF4B5.js';
|
|
3
2
|
import * as React from 'react';
|
|
4
3
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
5
4
|
|
|
5
|
+
// src/theme-toggle.tsx
|
|
6
|
+
var cx = (...parts) => parts.filter(Boolean).join(" ");
|
|
6
7
|
function ThemeToggle({
|
|
7
8
|
size = 12,
|
|
8
9
|
storageKey = "theme",
|
|
@@ -24,85 +25,49 @@ function ThemeToggle({
|
|
|
24
25
|
if (next === "light") document.documentElement.setAttribute("data-theme", "light");
|
|
25
26
|
else document.documentElement.removeAttribute("data-theme");
|
|
26
27
|
};
|
|
27
|
-
const filled = theme === "dark";
|
|
28
28
|
return /* @__PURE__ */ jsx(
|
|
29
29
|
"button",
|
|
30
30
|
{
|
|
31
31
|
type: "button",
|
|
32
32
|
onClick: toggle,
|
|
33
|
-
"aria-label": `switch to ${
|
|
34
|
-
className,
|
|
33
|
+
"aria-label": `switch to ${theme === "dark" ? "light" : "dark"} mode`,
|
|
34
|
+
className: cx("sn-theme-toggle", className),
|
|
35
35
|
style: {
|
|
36
|
-
|
|
37
|
-
border: "none",
|
|
38
|
-
background: "transparent",
|
|
39
|
-
padding: 6,
|
|
40
|
-
cursor: "pointer",
|
|
41
|
-
display: "inline-flex",
|
|
42
|
-
alignItems: "center",
|
|
43
|
-
justifyContent: "center",
|
|
36
|
+
["--sn-theme-toggle-size"]: `${size}px`,
|
|
44
37
|
opacity: mounted ? 1 : 0,
|
|
45
|
-
transition: "opacity 200ms",
|
|
46
38
|
...style
|
|
47
39
|
},
|
|
48
|
-
children: /* @__PURE__ */ jsx(
|
|
49
|
-
"span",
|
|
50
|
-
{
|
|
51
|
-
style: {
|
|
52
|
-
display: "inline-block",
|
|
53
|
-
width: size,
|
|
54
|
-
height: size,
|
|
55
|
-
borderRadius: "50%",
|
|
56
|
-
border: `1px solid var(--sn-fg-muted)`,
|
|
57
|
-
background: filled ? "var(--sn-fg)" : "transparent",
|
|
58
|
-
transition: "background 160ms ease"
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
)
|
|
40
|
+
children: /* @__PURE__ */ jsx("span", { className: "sn-theme-toggle__indicator" })
|
|
62
41
|
}
|
|
63
42
|
);
|
|
64
43
|
}
|
|
44
|
+
var cx2 = (...parts) => parts.filter(Boolean).join(" ");
|
|
65
45
|
function CopyButton({ value, size = 14, className, style }) {
|
|
66
46
|
const [copied, setCopied] = React.useState(false);
|
|
67
47
|
const onCopy = async () => {
|
|
68
48
|
try {
|
|
69
49
|
await navigator.clipboard.writeText(value);
|
|
70
50
|
setCopied(true);
|
|
71
|
-
setTimeout(() => setCopied(false), 1200);
|
|
51
|
+
window.setTimeout(() => setCopied(false), 1200);
|
|
72
52
|
} catch {
|
|
73
53
|
}
|
|
74
54
|
};
|
|
75
|
-
return /* @__PURE__ */
|
|
55
|
+
return /* @__PURE__ */ jsxs(
|
|
76
56
|
"button",
|
|
77
57
|
{
|
|
78
58
|
type: "button",
|
|
79
59
|
onClick: onCopy,
|
|
80
60
|
"aria-label": copied ? "copied" : "copy",
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
justifyContent: "center",
|
|
92
|
-
borderRadius: "var(--sn-r-xs)",
|
|
93
|
-
transition: "color 120ms ease, border-color 120ms ease",
|
|
94
|
-
...style
|
|
95
|
-
},
|
|
96
|
-
onMouseEnter: (e) => {
|
|
97
|
-
if (!copied) e.currentTarget.style.color = "var(--sn-fg)";
|
|
98
|
-
},
|
|
99
|
-
onMouseLeave: (e) => {
|
|
100
|
-
if (!copied) e.currentTarget.style.color = "var(--sn-fg-muted)";
|
|
101
|
-
},
|
|
102
|
-
children: copied ? /* @__PURE__ */ jsx(CheckIcon, { size }) : /* @__PURE__ */ jsxs("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
103
|
-
/* @__PURE__ */ jsx("rect", { x: "9", y: "9", width: "11", height: "11", rx: "1.5" }),
|
|
104
|
-
/* @__PURE__ */ jsx("path", { d: "M5 15V5a1 1 0 0 1 1-1h10" })
|
|
105
|
-
] })
|
|
61
|
+
"data-copied": copied || void 0,
|
|
62
|
+
className: cx2("sn-copy-btn", className),
|
|
63
|
+
style,
|
|
64
|
+
children: [
|
|
65
|
+
/* @__PURE__ */ jsxs("svg", { className: "sn-copy-btn__idle", width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
66
|
+
/* @__PURE__ */ jsx("rect", { x: "9", y: "9", width: "11", height: "11", rx: "1.5" }),
|
|
67
|
+
/* @__PURE__ */ jsx("path", { d: "M5 15V5a1 1 0 0 1 1-1h10" })
|
|
68
|
+
] }),
|
|
69
|
+
/* @__PURE__ */ jsx("svg", { className: "sn-copy-btn__copied", width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "m4 12 5 5L20 6" }) })
|
|
70
|
+
]
|
|
106
71
|
}
|
|
107
72
|
);
|
|
108
73
|
}
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/theme-toggle.tsx","../src/copy-button.tsx"],"names":["React2","jsx"],"mappings":";;;;
|
|
1
|
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A,QAAA,EAAA;AAAA,wBAAA,IAAA,CAAC,KAAA,EAAA,EAAI,WAAU,mBAAA,EAAoB,KAAA,EAAO,MAAM,MAAA,EAAQ,IAAA,EAAM,SAAQ,WAAA,EAAY,IAAA,EAAK,QAAO,MAAA,EAAO,cAAA,EAAe,aAAY,KAAA,EAAM,aAAA,EAAc,SAAQ,cAAA,EAAe,OAAA,EAAQ,eAAY,MAAA,EAC7L,QAAA,EAAA;AAAA,0BAAAE,GAAAA,CAAC,MAAA,EAAA,EAAK,CAAA,EAAE,GAAA,EAAI,CAAA,EAAE,GAAA,EAAI,KAAA,EAAM,IAAA,EAAK,MAAA,EAAO,IAAA,EAAK,EAAA,EAAG,KAAA,EAAM,CAAA;AAAA,0BAClDA,GAAAA,CAAC,MAAA,EAAA,EAAK,CAAA,EAAE,0BAAA,EAA2B;AAAA,SAAA,EACrC,CAAA;AAAA,wBACAA,GAAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,qBAAA,EAAsB,KAAA,EAAO,IAAA,EAAM,MAAA,EAAQ,IAAA,EAAM,OAAA,EAAQ,WAAA,EAAY,IAAA,EAAK,MAAA,EAAO,MAAA,EAAO,cAAA,EAAe,WAAA,EAAY,KAAA,EAAM,aAAA,EAAc,OAAA,EAAQ,cAAA,EAAe,OAAA,EAAQ,aAAA,EAAY,MAAA,EAC/L,QAAA,kBAAAA,GAAAA,CAAC,MAAA,EAAA,EAAK,CAAA,EAAE,gBAAA,EAAiB,CAAA,EAC3B;AAAA;AAAA;AAAA,GACF;AAEJ","file":"client.js","sourcesContent":["import * as React from \"react\";\n\nconst cx = (...parts: Array<string | undefined | false>) => parts.filter(Boolean).join(\" \");\n\nexport type Theme = \"light\" | \"dark\";\n\nexport interface ThemeToggleProps {\n size?: number;\n storageKey?: string;\n defaultTheme?: Theme;\n className?: string;\n style?: React.CSSProperties;\n}\n\nexport function ThemeToggle({\n size = 12,\n storageKey = \"theme\",\n defaultTheme = \"dark\",\n className,\n style,\n}: ThemeToggleProps) {\n const [theme, setTheme] = React.useState<Theme>(defaultTheme);\n const [mounted, setMounted] = React.useState(false);\n\n React.useEffect(() => {\n const stored = (localStorage.getItem(storageKey) as Theme | null) ?? defaultTheme;\n setTheme(stored);\n setMounted(true);\n }, [storageKey, defaultTheme]);\n\n const toggle = () => {\n const next: Theme = theme === \"dark\" ? \"light\" : \"dark\";\n setTheme(next);\n localStorage.setItem(storageKey, next);\n if (next === \"light\") document.documentElement.setAttribute(\"data-theme\", \"light\");\n else document.documentElement.removeAttribute(\"data-theme\");\n };\n\n return (\n <button\n type=\"button\"\n onClick={toggle}\n aria-label={`switch to ${theme === \"dark\" ? \"light\" : \"dark\"} mode`}\n className={cx(\"sn-theme-toggle\", className)}\n style={{\n [\"--sn-theme-toggle-size\" as string]: `${size}px`,\n opacity: mounted ? 1 : 0,\n ...style,\n }}\n >\n <span className=\"sn-theme-toggle__indicator\" />\n </button>\n );\n}\n","import * as React from \"react\";\n\nconst cx = (...parts: Array<string | undefined | false>) => parts.filter(Boolean).join(\" \");\n\nexport interface CopyButtonProps {\n value: string;\n size?: number;\n className?: string;\n style?: React.CSSProperties;\n}\n\nexport function CopyButton({ value, size = 14, className, style }: CopyButtonProps) {\n const [copied, setCopied] = React.useState(false);\n\n const onCopy = async () => {\n try {\n await navigator.clipboard.writeText(value);\n setCopied(true);\n window.setTimeout(() => setCopied(false), 1200);\n } catch {\n // ignored\n }\n };\n\n return (\n <button\n type=\"button\"\n onClick={onCopy}\n aria-label={copied ? \"copied\" : \"copy\"}\n data-copied={copied || undefined}\n className={cx(\"sn-copy-btn\", className)}\n style={style}\n >\n <svg className=\"sn-copy-btn__idle\" width={size} height={size} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n <rect x=\"9\" y=\"9\" width=\"11\" height=\"11\" rx=\"1.5\" />\n <path d=\"M5 15V5a1 1 0 0 1 1-1h10\" />\n </svg>\n <svg className=\"sn-copy-btn__copied\" width={size} height={size} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n <path d=\"m4 12 5 5L20 6\" />\n </svg>\n </button>\n );\n}\n"]}
|