@publish.os/nextjs 0.0.1-alpha.1
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/README.md +7 -0
- package/dist/cache/tags.cjs +76 -0
- package/dist/cache/tags.d.cts +12 -0
- package/dist/cache/tags.d.ts +12 -0
- package/dist/cache/tags.js +51 -0
- package/dist/components/color-palette.cjs +408 -0
- package/dist/components/color-palette.d.cts +5 -0
- package/dist/components/color-palette.d.ts +5 -0
- package/dist/components/color-palette.js +388 -0
- package/dist/components/nav-breadcrumb.cjs +141 -0
- package/dist/components/nav-breadcrumb.d.cts +9 -0
- package/dist/components/nav-breadcrumb.d.ts +9 -0
- package/dist/components/nav-breadcrumb.js +107 -0
- package/dist/components/page-list.cjs +68 -0
- package/dist/components/page-list.d.cts +11 -0
- package/dist/components/page-list.d.ts +11 -0
- package/dist/components/page-list.js +33 -0
- package/dist/components/providers.cjs +44 -0
- package/dist/components/providers.d.cts +8 -0
- package/dist/components/providers.d.ts +8 -0
- package/dist/components/providers.js +20 -0
- package/dist/components/site-header.cjs +302 -0
- package/dist/components/site-header.d.cts +12 -0
- package/dist/components/site-header.d.ts +12 -0
- package/dist/components/site-header.js +268 -0
- package/dist/components/theme-toggle.cjs +147 -0
- package/dist/components/theme-toggle.d.cts +5 -0
- package/dist/components/theme-toggle.d.ts +5 -0
- package/dist/components/theme-toggle.js +123 -0
- package/dist/config/createNextConfig.cjs +52 -0
- package/dist/config/createNextConfig.d.cts +8 -0
- package/dist/config/createNextConfig.d.ts +8 -0
- package/dist/config/createNextConfig.js +27 -0
- package/dist/index.cjs +347 -0
- package/dist/index.d.cts +14 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +299 -0
- package/dist/layouts/group.cjs +157 -0
- package/dist/layouts/group.d.cts +15 -0
- package/dist/layouts/group.d.ts +15 -0
- package/dist/layouts/group.js +132 -0
- package/dist/mdx/error-boundary.cjs +94 -0
- package/dist/mdx/error-boundary.d.cts +13 -0
- package/dist/mdx/error-boundary.d.ts +13 -0
- package/dist/mdx/error-boundary.js +70 -0
- package/dist/mdx/error-fallback.cjs +58 -0
- package/dist/mdx/error-fallback.d.cts +9 -0
- package/dist/mdx/error-fallback.d.ts +9 -0
- package/dist/mdx/error-fallback.js +33 -0
- package/dist/mdx/mdx.cjs +182 -0
- package/dist/mdx/mdx.d.cts +10 -0
- package/dist/mdx/mdx.d.ts +10 -0
- package/dist/mdx/mdx.js +147 -0
- package/dist/pages/group.cjs +162 -0
- package/dist/pages/group.d.cts +15 -0
- package/dist/pages/group.d.ts +15 -0
- package/dist/pages/group.js +136 -0
- package/dist/pages/leaf.cjs +203 -0
- package/dist/pages/leaf.d.cts +23 -0
- package/dist/pages/leaf.d.ts +23 -0
- package/dist/pages/leaf.js +176 -0
- package/dist/pages/root.cjs +127 -0
- package/dist/pages/root.d.cts +14 -0
- package/dist/pages/root.d.ts +14 -0
- package/dist/pages/root.js +101 -0
- package/dist/resolvers/manifest-resolver.cjs +107 -0
- package/dist/resolvers/manifest-resolver.d.cts +13 -0
- package/dist/resolvers/manifest-resolver.d.ts +13 -0
- package/dist/resolvers/manifest-resolver.js +79 -0
- package/dist/routes/llms.cjs +101 -0
- package/dist/routes/llms.d.cts +7 -0
- package/dist/routes/llms.d.ts +7 -0
- package/dist/routes/llms.js +76 -0
- package/dist/routes/robots.cjs +94 -0
- package/dist/routes/robots.d.cts +5 -0
- package/dist/routes/robots.d.ts +5 -0
- package/dist/routes/robots.js +69 -0
- package/dist/routes/sitemap.cjs +108 -0
- package/dist/routes/sitemap.d.cts +5 -0
- package/dist/routes/sitemap.d.ts +5 -0
- package/dist/routes/sitemap.js +83 -0
- package/dist/types.cjs +18 -0
- package/dist/types.d.cts +144 -0
- package/dist/types.d.ts +144 -0
- package/dist/types.js +0 -0
- package/dist/utils/cn.cjs +49 -0
- package/dist/utils/cn.d.cts +15 -0
- package/dist/utils/cn.d.ts +15 -0
- package/dist/utils/cn.js +24 -0
- package/dist/utils/pretty-date.cjs +55 -0
- package/dist/utils/pretty-date.d.cts +6 -0
- package/dist/utils/pretty-date.d.ts +6 -0
- package/dist/utils/pretty-date.js +30 -0
- package/package.json +100 -0
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/components/color-palette.tsx
|
|
4
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
var GLOBALS_CSS = `
|
|
7
|
+
:root {
|
|
8
|
+
--foreground-1: #100f0f;
|
|
9
|
+
--foreground-2: #403e3c;
|
|
10
|
+
--foreground-3: #6f6e69;
|
|
11
|
+
--foreground-4: #878580;
|
|
12
|
+
--surface-background: #fffcf0;
|
|
13
|
+
--surface-1: #fffcf0;
|
|
14
|
+
--surface-2: #fff8e3;
|
|
15
|
+
--surface-3: #f2ecd8;
|
|
16
|
+
--surface-4: #e6ddc8;
|
|
17
|
+
--surface-hover: var(--surface-3);
|
|
18
|
+
--surface-active: var(--surface-4);
|
|
19
|
+
--surface-overlay: var(--surface-3);
|
|
20
|
+
--surface-menu: #100f0f;
|
|
21
|
+
--surface-menu-foreground: #fffcf0;
|
|
22
|
+
--accent-1: #d84200;
|
|
23
|
+
--accent-2: #ff6b35;
|
|
24
|
+
--accent-3: #ff9f40;
|
|
25
|
+
--accent-4: #ffe7d6;
|
|
26
|
+
--stroke-1: #878580;
|
|
27
|
+
--stroke-2: #b7ad99;
|
|
28
|
+
--stroke-3: #d9cfba;
|
|
29
|
+
--stroke-4: #e6ddc8;
|
|
30
|
+
--focus-ring: var(--accent-2);
|
|
31
|
+
--typography-links: var(--accent-1);
|
|
32
|
+
--typography-variable: var(--accent-1);
|
|
33
|
+
--typography-pre-bg: #f2ecd8;
|
|
34
|
+
--typography-pre-border: #d9cfba;
|
|
35
|
+
--my-custom-variable: rgb(102, 128, 11);
|
|
36
|
+
/*--my-custom-variable: oklch(
|
|
37
|
+
from var(--accent-1) calc(l + 0.5) calc(c + 0.15) h / calc(alpha - 0.1)
|
|
38
|
+
);*/
|
|
39
|
+
--my-custom-extended-variable: oklch(
|
|
40
|
+
from var(--my-custom-variable) l c h /
|
|
41
|
+
calc(alpha - 0.1)
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
.dark {
|
|
45
|
+
--foreground-1: #fffcf0;
|
|
46
|
+
--foreground-2: #cecdc3;
|
|
47
|
+
--foreground-3: #878580;
|
|
48
|
+
--foreground-4: #6f6e69;
|
|
49
|
+
--surface-background: #100f0f;
|
|
50
|
+
--surface-1: #100f0f;
|
|
51
|
+
--surface-2: #1c1b1a;
|
|
52
|
+
--surface-3: #282726;
|
|
53
|
+
--surface-4: #343331;
|
|
54
|
+
--surface-hover: var(--surface-3);
|
|
55
|
+
--surface-active: var(--surface-4);
|
|
56
|
+
--surface-overlay: var(--surface-3);
|
|
57
|
+
--surface-menu: #fffcf0;
|
|
58
|
+
--surface-menu-foreground: #100f0f;
|
|
59
|
+
--accent-1: #ff9f40;
|
|
60
|
+
--accent-2: #ff8c1a;
|
|
61
|
+
--accent-3: #b54d00;
|
|
62
|
+
--accent-4: #3d1e00;
|
|
63
|
+
--stroke-1: #878580;
|
|
64
|
+
--stroke-2: #575653;
|
|
65
|
+
--stroke-3: #403e3c;
|
|
66
|
+
--stroke-4: #343331;
|
|
67
|
+
--focus-ring: var(--accent-1);
|
|
68
|
+
--typography-links: var(--accent-1);
|
|
69
|
+
--typography-variable: var(--accent-1);
|
|
70
|
+
--typography-pre-bg: #1c1b1a;
|
|
71
|
+
--typography-pre-border: #403e3c;
|
|
72
|
+
}
|
|
73
|
+
`;
|
|
74
|
+
function parseTokenNames(css) {
|
|
75
|
+
const stripped = css.replace(/\/\*[\s\S]*?\*\//g, "");
|
|
76
|
+
const seen = /* @__PURE__ */ new Set();
|
|
77
|
+
const names = [];
|
|
78
|
+
for (const m of stripped.matchAll(/--([a-zA-Z0-9_-]+)\s*:/g)) {
|
|
79
|
+
const name = m[1];
|
|
80
|
+
if (name && !seen.has(name)) {
|
|
81
|
+
seen.add(name);
|
|
82
|
+
names.push(name);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return names;
|
|
86
|
+
}
|
|
87
|
+
var TOKEN_NAMES = parseTokenNames(GLOBALS_CSS);
|
|
88
|
+
function deriveGroup(name) {
|
|
89
|
+
const p = name.split("-");
|
|
90
|
+
if (p.length === 1) return "base";
|
|
91
|
+
const last = p[p.length - 1];
|
|
92
|
+
if (last && /^\d+$/.test(last)) return p.slice(0, -1).join("-");
|
|
93
|
+
return p[0] ?? "base";
|
|
94
|
+
}
|
|
95
|
+
function parseRgbString(s) {
|
|
96
|
+
const m = s.match(/rgba?\(\s*([\d.]+)[,\s]\s*([\d.]+)[,\s]\s*([\d.]+)/);
|
|
97
|
+
if (!m) return null;
|
|
98
|
+
const [, r, g, b] = m;
|
|
99
|
+
if (!r || !g || !b) return null;
|
|
100
|
+
return [Math.round(+r), Math.round(+g), Math.round(+b)];
|
|
101
|
+
}
|
|
102
|
+
function toHex(r, g, b) {
|
|
103
|
+
return "#" + [r, g, b].map((x) => x.toString(16).padStart(2, "0")).join("").toUpperCase();
|
|
104
|
+
}
|
|
105
|
+
function toHsl(r, g, b) {
|
|
106
|
+
r /= 255;
|
|
107
|
+
g /= 255;
|
|
108
|
+
b /= 255;
|
|
109
|
+
const mx = Math.max(r, g, b), mn = Math.min(r, g, b);
|
|
110
|
+
let h = 0, s = 0;
|
|
111
|
+
const l = (mx + mn) / 2;
|
|
112
|
+
if (mx !== mn) {
|
|
113
|
+
const d = mx - mn;
|
|
114
|
+
s = l > 0.5 ? d / (2 - mx - mn) : d / (mx + mn);
|
|
115
|
+
if (mx === r) h = ((g - b) / d + (g < b ? 6 : 0)) / 6;
|
|
116
|
+
else if (mx === g) h = ((b - r) / d + 2) / 6;
|
|
117
|
+
else h = ((r - g) / d + 4) / 6;
|
|
118
|
+
}
|
|
119
|
+
return `hsl(${Math.round(h * 360)}, ${Math.round(s * 100)}%, ${Math.round(l * 100)}%)`;
|
|
120
|
+
}
|
|
121
|
+
function toOklch(r, g, b) {
|
|
122
|
+
const tl = (c) => {
|
|
123
|
+
c /= 255;
|
|
124
|
+
return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
|
|
125
|
+
};
|
|
126
|
+
const [lr, lg, lb] = [tl(r), tl(g), tl(b)];
|
|
127
|
+
const l = 0.4122214708 * lr + 0.5363325363 * lg + 0.0514459929 * lb;
|
|
128
|
+
const m = 0.2119034982 * lr + 0.6806995451 * lg + 0.1073969566 * lb;
|
|
129
|
+
const s = 0.0883024619 * lr + 0.2817188376 * lg + 0.6299787005 * lb;
|
|
130
|
+
const [l_, m_, s_] = [Math.cbrt(l), Math.cbrt(m), Math.cbrt(s)];
|
|
131
|
+
const L = 0.2104542553 * l_ + 0.793617785 * m_ - 4072047e-9 * s_;
|
|
132
|
+
const a = 1.9779984951 * l_ - 2.428592205 * m_ + 0.4505937099 * s_;
|
|
133
|
+
const bv = 0.0259040371 * l_ + 0.7827717662 * m_ - 0.808675766 * s_;
|
|
134
|
+
const C = Math.sqrt(a * a + bv * bv);
|
|
135
|
+
let H = Math.atan2(bv, a) * (180 / Math.PI);
|
|
136
|
+
if (H < 0) H += 360;
|
|
137
|
+
return `oklch(${L.toFixed(3)} ${C.toFixed(3)} ${H.toFixed(1)})`;
|
|
138
|
+
}
|
|
139
|
+
function formatColor(r, g, b, fmt) {
|
|
140
|
+
switch (fmt) {
|
|
141
|
+
case "hex":
|
|
142
|
+
return toHex(r, g, b);
|
|
143
|
+
case "rgb":
|
|
144
|
+
return `rgb(${r}, ${g}, ${b})`;
|
|
145
|
+
case "hsl":
|
|
146
|
+
return toHsl(r, g, b);
|
|
147
|
+
case "oklch":
|
|
148
|
+
return toOklch(r, g, b);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
function isLight(r, g, b) {
|
|
152
|
+
return (0.299 * r + 0.587 * g + 0.114 * b) / 255 > 0.52;
|
|
153
|
+
}
|
|
154
|
+
function readToken(name, container) {
|
|
155
|
+
const probe = document.createElement("div");
|
|
156
|
+
probe.style.cssText = `position:absolute;width:1px;height:1px;pointer-events:none;background:var(--${name})`;
|
|
157
|
+
container.appendChild(probe);
|
|
158
|
+
const computed = getComputedStyle(probe).backgroundColor;
|
|
159
|
+
container.removeChild(probe);
|
|
160
|
+
return parseRgbString(computed);
|
|
161
|
+
}
|
|
162
|
+
var FORMAT_OPTIONS = [
|
|
163
|
+
{ label: "HEX", value: "hex" },
|
|
164
|
+
{ label: "RGB", value: "rgb" },
|
|
165
|
+
{ label: "HSL", value: "hsl" },
|
|
166
|
+
{ label: "OKLCH", value: "oklch" }
|
|
167
|
+
];
|
|
168
|
+
function Swatch({
|
|
169
|
+
name,
|
|
170
|
+
rgb,
|
|
171
|
+
format,
|
|
172
|
+
onFormatChange,
|
|
173
|
+
onCopy
|
|
174
|
+
}) {
|
|
175
|
+
const [menuOpen, setMenuOpen] = useState(false);
|
|
176
|
+
const menuRef = useRef(null);
|
|
177
|
+
useEffect(() => {
|
|
178
|
+
if (!menuOpen) return;
|
|
179
|
+
const h = (e) => {
|
|
180
|
+
if (!menuRef.current?.contains(e.target)) setMenuOpen(false);
|
|
181
|
+
};
|
|
182
|
+
document.addEventListener("mousedown", h);
|
|
183
|
+
return () => document.removeEventListener("mousedown", h);
|
|
184
|
+
}, [menuOpen]);
|
|
185
|
+
const displayVal = rgb ? formatColor(...rgb, format) : null;
|
|
186
|
+
const light = rgb ? isLight(...rgb) : true;
|
|
187
|
+
const bg = rgb ? toHex(...rgb) : void 0;
|
|
188
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col shrink-0 w-24", children: [
|
|
189
|
+
/* @__PURE__ */ jsx(
|
|
190
|
+
"button",
|
|
191
|
+
{
|
|
192
|
+
type: "button",
|
|
193
|
+
disabled: !rgb,
|
|
194
|
+
onClick: () => displayVal && onCopy(displayVal),
|
|
195
|
+
title: displayVal ?? "Unresolvable",
|
|
196
|
+
className: "relative overflow-hidden shrink-0 rounded-xl group transition-transform duration-150 hover:scale-105 active:scale-95 disabled:cursor-default disabled:hover:scale-100",
|
|
197
|
+
style: {
|
|
198
|
+
width: 96,
|
|
199
|
+
height: 80,
|
|
200
|
+
border: "0.5px solid rgba(128,128,128,0.2)",
|
|
201
|
+
background: bg ?? "color-mix(in srgb, currentColor 8%, transparent)"
|
|
202
|
+
},
|
|
203
|
+
children: rgb ? /* @__PURE__ */ jsx(
|
|
204
|
+
"span",
|
|
205
|
+
{
|
|
206
|
+
className: "absolute inset-0 flex items-center justify-center text-[10px] font-bold tracking-widest uppercase opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none",
|
|
207
|
+
style: {
|
|
208
|
+
color: light ? "rgba(0,0,0,0.45)" : "rgba(255,255,255,0.65)"
|
|
209
|
+
},
|
|
210
|
+
children: "copy"
|
|
211
|
+
}
|
|
212
|
+
) : /* @__PURE__ */ jsx(
|
|
213
|
+
"span",
|
|
214
|
+
{
|
|
215
|
+
className: "absolute inset-0 rounded-xl pointer-events-none",
|
|
216
|
+
style: {
|
|
217
|
+
backgroundImage: "repeating-conic-gradient(#aaa 0% 25%, transparent 0% 50%)",
|
|
218
|
+
backgroundSize: "12px 12px",
|
|
219
|
+
opacity: 0.2
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
)
|
|
223
|
+
}
|
|
224
|
+
),
|
|
225
|
+
/* @__PURE__ */ jsx(
|
|
226
|
+
"p",
|
|
227
|
+
{
|
|
228
|
+
className: "mt-1.5 truncate font-bold leading-tight text-[10px]",
|
|
229
|
+
title: name,
|
|
230
|
+
children: name
|
|
231
|
+
}
|
|
232
|
+
),
|
|
233
|
+
/* @__PURE__ */ jsxs("div", { ref: menuRef, className: "relative w-24", children: [
|
|
234
|
+
rgb ? /* @__PURE__ */ jsx(
|
|
235
|
+
"button",
|
|
236
|
+
{
|
|
237
|
+
type: "button",
|
|
238
|
+
onClick: () => setMenuOpen((o) => !o),
|
|
239
|
+
className: "truncate text-left leading-normal mt-0.5 text-[9px] text-gray-500 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-100 transition-colors w-24",
|
|
240
|
+
style: {
|
|
241
|
+
fontFamily: "inherit",
|
|
242
|
+
background: "none",
|
|
243
|
+
border: "none",
|
|
244
|
+
padding: 0,
|
|
245
|
+
cursor: "pointer"
|
|
246
|
+
},
|
|
247
|
+
children: displayVal
|
|
248
|
+
}
|
|
249
|
+
) : /* @__PURE__ */ jsx("span", { className: "block mt-0.5 text-[9px] italic text-gray-400 dark:text-gray-600", children: "unresolved" }),
|
|
250
|
+
menuOpen && rgb && /* @__PURE__ */ jsx(
|
|
251
|
+
"div",
|
|
252
|
+
{
|
|
253
|
+
className: "absolute left-0 z-50 overflow-hidden rounded-xl border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900 shadow-xl",
|
|
254
|
+
style: { top: "100%", marginTop: 4, minWidth: 176 },
|
|
255
|
+
children: FORMAT_OPTIONS.map((opt) => /* @__PURE__ */ jsxs(
|
|
256
|
+
"button",
|
|
257
|
+
{
|
|
258
|
+
type: "button",
|
|
259
|
+
onClick: () => {
|
|
260
|
+
onFormatChange(opt.value);
|
|
261
|
+
setMenuOpen(false);
|
|
262
|
+
},
|
|
263
|
+
className: `flex items-center gap-2 w-full text-left px-3 py-1.5 text-[10px] transition-colors ${format === opt.value ? "bg-gray-900 text-white dark:bg-white dark:text-gray-900" : "text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-800"}`,
|
|
264
|
+
style: {
|
|
265
|
+
fontFamily: "inherit",
|
|
266
|
+
border: "none",
|
|
267
|
+
cursor: "pointer"
|
|
268
|
+
},
|
|
269
|
+
children: [
|
|
270
|
+
/* @__PURE__ */ jsx("span", { className: "font-bold w-11 shrink-0", children: opt.label }),
|
|
271
|
+
/* @__PURE__ */ jsx("span", { className: "text-[9px] opacity-55 truncate", children: formatColor(...rgb, opt.value) })
|
|
272
|
+
]
|
|
273
|
+
},
|
|
274
|
+
opt.value
|
|
275
|
+
))
|
|
276
|
+
}
|
|
277
|
+
)
|
|
278
|
+
] })
|
|
279
|
+
] });
|
|
280
|
+
}
|
|
281
|
+
function ColorPalette() {
|
|
282
|
+
const [format, setFormat] = useState("hex");
|
|
283
|
+
const [notice, setNotice] = useState("");
|
|
284
|
+
const [resolved, setResolved] = useState({});
|
|
285
|
+
const probeRef = useRef(null);
|
|
286
|
+
const noticeTimer = useRef(null);
|
|
287
|
+
const readAll = useCallback(() => {
|
|
288
|
+
const container = probeRef.current;
|
|
289
|
+
if (!container) return;
|
|
290
|
+
const next = {};
|
|
291
|
+
TOKEN_NAMES.forEach((name) => {
|
|
292
|
+
next[name] = readToken(name, container);
|
|
293
|
+
});
|
|
294
|
+
setResolved(next);
|
|
295
|
+
}, []);
|
|
296
|
+
useEffect(() => {
|
|
297
|
+
readAll();
|
|
298
|
+
const obs = new MutationObserver(readAll);
|
|
299
|
+
obs.observe(document.documentElement, {
|
|
300
|
+
attributes: true,
|
|
301
|
+
attributeFilter: ["class", "data-theme"]
|
|
302
|
+
});
|
|
303
|
+
return () => obs.disconnect();
|
|
304
|
+
}, [readAll]);
|
|
305
|
+
useEffect(() => {
|
|
306
|
+
return () => {
|
|
307
|
+
if (noticeTimer.current) clearTimeout(noticeTimer.current);
|
|
308
|
+
};
|
|
309
|
+
}, []);
|
|
310
|
+
const handleCopy = useCallback((txt) => {
|
|
311
|
+
navigator.clipboard.writeText(txt).catch(() => {
|
|
312
|
+
});
|
|
313
|
+
setNotice(`Copied ${txt}`);
|
|
314
|
+
if (noticeTimer.current) clearTimeout(noticeTimer.current);
|
|
315
|
+
noticeTimer.current = setTimeout(() => setNotice(""), 1800);
|
|
316
|
+
}, []);
|
|
317
|
+
const groups = {};
|
|
318
|
+
const groupOrder = [];
|
|
319
|
+
TOKEN_NAMES.forEach((name) => {
|
|
320
|
+
const g = deriveGroup(name);
|
|
321
|
+
if (!groups[g]) {
|
|
322
|
+
groups[g] = [];
|
|
323
|
+
groupOrder.push(g);
|
|
324
|
+
}
|
|
325
|
+
groups[g].push(name);
|
|
326
|
+
});
|
|
327
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
328
|
+
/* @__PURE__ */ jsx(
|
|
329
|
+
"div",
|
|
330
|
+
{
|
|
331
|
+
ref: probeRef,
|
|
332
|
+
"aria-hidden": true,
|
|
333
|
+
style: {
|
|
334
|
+
position: "absolute",
|
|
335
|
+
width: 0,
|
|
336
|
+
height: 0,
|
|
337
|
+
overflow: "hidden",
|
|
338
|
+
pointerEvents: "none"
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
),
|
|
342
|
+
/* @__PURE__ */ jsxs(
|
|
343
|
+
"div",
|
|
344
|
+
{
|
|
345
|
+
style: {
|
|
346
|
+
fontFamily: "var(--font-mono, ui-monospace, 'Fira Code', monospace)"
|
|
347
|
+
},
|
|
348
|
+
children: [
|
|
349
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 mb-5 flex-wrap", children: [
|
|
350
|
+
/* @__PURE__ */ jsx("div", { className: "flex gap-1 rounded-lg p-0.5 bg-gray-100 dark:bg-gray-800", children: FORMAT_OPTIONS.map((f) => /* @__PURE__ */ jsx(
|
|
351
|
+
"button",
|
|
352
|
+
{
|
|
353
|
+
type: "button",
|
|
354
|
+
onClick: () => setFormat(f.value),
|
|
355
|
+
className: `px-3 py-1 rounded-md text-[11px] font-bold transition-all ${format === f.value ? "bg-gray-900 text-white dark:bg-white dark:text-gray-900" : "text-gray-500 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200"}`,
|
|
356
|
+
style: {
|
|
357
|
+
fontFamily: "inherit",
|
|
358
|
+
border: "none",
|
|
359
|
+
cursor: "pointer"
|
|
360
|
+
},
|
|
361
|
+
children: f.label
|
|
362
|
+
},
|
|
363
|
+
f.value
|
|
364
|
+
)) }),
|
|
365
|
+
notice && /* @__PURE__ */ jsx("span", { className: "text-[11px] text-gray-400", children: notice })
|
|
366
|
+
] }),
|
|
367
|
+
groupOrder.map((g) => /* @__PURE__ */ jsxs("section", { className: "mb-7", children: [
|
|
368
|
+
/* @__PURE__ */ jsx("h3", { className: "text-[10px] font-bold uppercase tracking-[.18em] text-gray-400 dark:text-gray-600 pb-2 border-b border-gray-100 dark:border-gray-800 mb-3", children: g }),
|
|
369
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-4", children: (groups[g] ?? []).map((name) => /* @__PURE__ */ jsx(
|
|
370
|
+
Swatch,
|
|
371
|
+
{
|
|
372
|
+
name,
|
|
373
|
+
rgb: resolved[name] ?? null,
|
|
374
|
+
format,
|
|
375
|
+
onFormatChange: setFormat,
|
|
376
|
+
onCopy: handleCopy
|
|
377
|
+
},
|
|
378
|
+
name
|
|
379
|
+
)) })
|
|
380
|
+
] }, g))
|
|
381
|
+
]
|
|
382
|
+
}
|
|
383
|
+
)
|
|
384
|
+
] });
|
|
385
|
+
}
|
|
386
|
+
export {
|
|
387
|
+
ColorPalette as default
|
|
388
|
+
};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// src/components/nav-breadcrumb.tsx
|
|
32
|
+
var nav_breadcrumb_exports = {};
|
|
33
|
+
__export(nav_breadcrumb_exports, {
|
|
34
|
+
NavBreadcrumb: () => NavBreadcrumb
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(nav_breadcrumb_exports);
|
|
37
|
+
var import_link = __toESM(require("next/link"), 1);
|
|
38
|
+
var import_navigation = require("next/navigation");
|
|
39
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
40
|
+
function titleFor(node) {
|
|
41
|
+
return node.title;
|
|
42
|
+
}
|
|
43
|
+
function pathFor(node) {
|
|
44
|
+
if (node.type === "page") return node.path;
|
|
45
|
+
if (node.type === "link") return node.href;
|
|
46
|
+
if (node.type === "section") return node.path;
|
|
47
|
+
return void 0;
|
|
48
|
+
}
|
|
49
|
+
function rankFor(node) {
|
|
50
|
+
if (node.type === "page" || node.type === "section") return 2;
|
|
51
|
+
if (node.type === "folder") return 1;
|
|
52
|
+
return 0;
|
|
53
|
+
}
|
|
54
|
+
function findCrumbs(nodes, pathname, parents = []) {
|
|
55
|
+
const matches = [];
|
|
56
|
+
for (const node of nodes) {
|
|
57
|
+
const path = pathFor(node);
|
|
58
|
+
const nextParents = path ? [...parents, { title: titleFor(node), path }] : parents;
|
|
59
|
+
if (path === pathname) {
|
|
60
|
+
matches.push({
|
|
61
|
+
crumbs: nextParents.map((crumb, index) => ({
|
|
62
|
+
...crumb,
|
|
63
|
+
current: index === nextParents.length - 1
|
|
64
|
+
})),
|
|
65
|
+
pathLength: path.length,
|
|
66
|
+
rank: rankFor(node)
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
if (node.type === "section" || node.type === "folder") {
|
|
70
|
+
const childMatch = findCrumbs(node.children, pathname, nextParents);
|
|
71
|
+
if (childMatch) matches.push(childMatch);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return matches.sort(
|
|
75
|
+
(a, b) => b.rank - a.rank || b.pathLength - a.pathLength || b.crumbs.length - a.crumbs.length
|
|
76
|
+
)[0] ?? null;
|
|
77
|
+
}
|
|
78
|
+
function groupFallback(tree, pathname) {
|
|
79
|
+
const groups = tree.map((group) => ({ group, path: pathFor(group) })).filter(
|
|
80
|
+
(entry) => typeof entry.path === "string"
|
|
81
|
+
).sort((a, b) => b.path.length - a.path.length);
|
|
82
|
+
for (const { group, path } of groups) {
|
|
83
|
+
if (pathname.startsWith(`${path}/`)) {
|
|
84
|
+
return [{ title: titleFor(group), path }];
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return [];
|
|
88
|
+
}
|
|
89
|
+
function buildCrumbs(site, tree, pathname) {
|
|
90
|
+
const root = {
|
|
91
|
+
title: site.title,
|
|
92
|
+
path: "/",
|
|
93
|
+
current: pathname === "/"
|
|
94
|
+
};
|
|
95
|
+
if (pathname === "/") return [root];
|
|
96
|
+
const treeMatch = findCrumbs(tree, pathname);
|
|
97
|
+
if (treeMatch) return [root, ...treeMatch.crumbs];
|
|
98
|
+
return [
|
|
99
|
+
root,
|
|
100
|
+
...groupFallback(tree, pathname).map((crumb) => ({
|
|
101
|
+
...crumb,
|
|
102
|
+
current: false
|
|
103
|
+
}))
|
|
104
|
+
];
|
|
105
|
+
}
|
|
106
|
+
function NavBreadcrumb({
|
|
107
|
+
site,
|
|
108
|
+
tree
|
|
109
|
+
}) {
|
|
110
|
+
const pathname = (0, import_navigation.usePathname)() || "/";
|
|
111
|
+
const crumbs = buildCrumbs(site, tree, pathname);
|
|
112
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
113
|
+
"nav",
|
|
114
|
+
{
|
|
115
|
+
"aria-label": "Breadcrumb",
|
|
116
|
+
className: "flex min-w-0 items-center gap-1.5 text-sm",
|
|
117
|
+
children: crumbs.map((crumb, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "flex min-w-0 items-center gap-1.5", children: [
|
|
118
|
+
index > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { "aria-hidden": "true", className: "text-stroke-3", children: "/" }),
|
|
119
|
+
crumb.current ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
120
|
+
"span",
|
|
121
|
+
{
|
|
122
|
+
"aria-current": "page",
|
|
123
|
+
className: "truncate font-medium text-foreground-1",
|
|
124
|
+
children: crumb.title
|
|
125
|
+
}
|
|
126
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
127
|
+
import_link.default,
|
|
128
|
+
{
|
|
129
|
+
className: "truncate text-foreground-3 no-underline hover:text-accent-1",
|
|
130
|
+
href: crumb.path,
|
|
131
|
+
children: crumb.title
|
|
132
|
+
}
|
|
133
|
+
)
|
|
134
|
+
] }, crumb.path))
|
|
135
|
+
}
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
139
|
+
0 && (module.exports = {
|
|
140
|
+
NavBreadcrumb
|
|
141
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { SiteData, TreeNode } from '../types.cjs';
|
|
3
|
+
|
|
4
|
+
declare function NavBreadcrumb({ site, tree, }: {
|
|
5
|
+
site: SiteData;
|
|
6
|
+
tree: TreeNode[];
|
|
7
|
+
}): react_jsx_runtime.JSX.Element;
|
|
8
|
+
|
|
9
|
+
export { NavBreadcrumb };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { SiteData, TreeNode } from '../types.js';
|
|
3
|
+
|
|
4
|
+
declare function NavBreadcrumb({ site, tree, }: {
|
|
5
|
+
site: SiteData;
|
|
6
|
+
tree: TreeNode[];
|
|
7
|
+
}): react_jsx_runtime.JSX.Element;
|
|
8
|
+
|
|
9
|
+
export { NavBreadcrumb };
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/components/nav-breadcrumb.tsx
|
|
4
|
+
import Link from "next/link";
|
|
5
|
+
import { usePathname } from "next/navigation";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
function titleFor(node) {
|
|
8
|
+
return node.title;
|
|
9
|
+
}
|
|
10
|
+
function pathFor(node) {
|
|
11
|
+
if (node.type === "page") return node.path;
|
|
12
|
+
if (node.type === "link") return node.href;
|
|
13
|
+
if (node.type === "section") return node.path;
|
|
14
|
+
return void 0;
|
|
15
|
+
}
|
|
16
|
+
function rankFor(node) {
|
|
17
|
+
if (node.type === "page" || node.type === "section") return 2;
|
|
18
|
+
if (node.type === "folder") return 1;
|
|
19
|
+
return 0;
|
|
20
|
+
}
|
|
21
|
+
function findCrumbs(nodes, pathname, parents = []) {
|
|
22
|
+
const matches = [];
|
|
23
|
+
for (const node of nodes) {
|
|
24
|
+
const path = pathFor(node);
|
|
25
|
+
const nextParents = path ? [...parents, { title: titleFor(node), path }] : parents;
|
|
26
|
+
if (path === pathname) {
|
|
27
|
+
matches.push({
|
|
28
|
+
crumbs: nextParents.map((crumb, index) => ({
|
|
29
|
+
...crumb,
|
|
30
|
+
current: index === nextParents.length - 1
|
|
31
|
+
})),
|
|
32
|
+
pathLength: path.length,
|
|
33
|
+
rank: rankFor(node)
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
if (node.type === "section" || node.type === "folder") {
|
|
37
|
+
const childMatch = findCrumbs(node.children, pathname, nextParents);
|
|
38
|
+
if (childMatch) matches.push(childMatch);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return matches.sort(
|
|
42
|
+
(a, b) => b.rank - a.rank || b.pathLength - a.pathLength || b.crumbs.length - a.crumbs.length
|
|
43
|
+
)[0] ?? null;
|
|
44
|
+
}
|
|
45
|
+
function groupFallback(tree, pathname) {
|
|
46
|
+
const groups = tree.map((group) => ({ group, path: pathFor(group) })).filter(
|
|
47
|
+
(entry) => typeof entry.path === "string"
|
|
48
|
+
).sort((a, b) => b.path.length - a.path.length);
|
|
49
|
+
for (const { group, path } of groups) {
|
|
50
|
+
if (pathname.startsWith(`${path}/`)) {
|
|
51
|
+
return [{ title: titleFor(group), path }];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return [];
|
|
55
|
+
}
|
|
56
|
+
function buildCrumbs(site, tree, pathname) {
|
|
57
|
+
const root = {
|
|
58
|
+
title: site.title,
|
|
59
|
+
path: "/",
|
|
60
|
+
current: pathname === "/"
|
|
61
|
+
};
|
|
62
|
+
if (pathname === "/") return [root];
|
|
63
|
+
const treeMatch = findCrumbs(tree, pathname);
|
|
64
|
+
if (treeMatch) return [root, ...treeMatch.crumbs];
|
|
65
|
+
return [
|
|
66
|
+
root,
|
|
67
|
+
...groupFallback(tree, pathname).map((crumb) => ({
|
|
68
|
+
...crumb,
|
|
69
|
+
current: false
|
|
70
|
+
}))
|
|
71
|
+
];
|
|
72
|
+
}
|
|
73
|
+
function NavBreadcrumb({
|
|
74
|
+
site,
|
|
75
|
+
tree
|
|
76
|
+
}) {
|
|
77
|
+
const pathname = usePathname() || "/";
|
|
78
|
+
const crumbs = buildCrumbs(site, tree, pathname);
|
|
79
|
+
return /* @__PURE__ */ jsx(
|
|
80
|
+
"nav",
|
|
81
|
+
{
|
|
82
|
+
"aria-label": "Breadcrumb",
|
|
83
|
+
className: "flex min-w-0 items-center gap-1.5 text-sm",
|
|
84
|
+
children: crumbs.map((crumb, index) => /* @__PURE__ */ jsxs("span", { className: "flex min-w-0 items-center gap-1.5", children: [
|
|
85
|
+
index > 0 && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "text-stroke-3", children: "/" }),
|
|
86
|
+
crumb.current ? /* @__PURE__ */ jsx(
|
|
87
|
+
"span",
|
|
88
|
+
{
|
|
89
|
+
"aria-current": "page",
|
|
90
|
+
className: "truncate font-medium text-foreground-1",
|
|
91
|
+
children: crumb.title
|
|
92
|
+
}
|
|
93
|
+
) : /* @__PURE__ */ jsx(
|
|
94
|
+
Link,
|
|
95
|
+
{
|
|
96
|
+
className: "truncate text-foreground-3 no-underline hover:text-accent-1",
|
|
97
|
+
href: crumb.path,
|
|
98
|
+
children: crumb.title
|
|
99
|
+
}
|
|
100
|
+
)
|
|
101
|
+
] }, crumb.path))
|
|
102
|
+
}
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
export {
|
|
106
|
+
NavBreadcrumb
|
|
107
|
+
};
|