@publish.os/nextjs 0.0.1-alpha.6 → 0.0.1-alpha.7
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 +3 -5
- package/compiler-assets/nextjs/defaults/app/globals.css +6 -0
- package/compiler-assets/nextjs/defaults/group/layout.tsx +23 -0
- package/compiler-assets/nextjs/defaults/group/leaf.tsx +48 -0
- package/compiler-assets/nextjs/defaults/group/page.tsx +50 -0
- package/compiler-assets/nextjs/defaults/project/next.config.mjs +45 -0
- package/compiler-assets/nextjs/defaults/project/postcss.config.mjs +5 -0
- package/compiler-assets/nextjs/defaults/project/tsconfig.json.template +41 -0
- package/compiler-assets/nextjs/defaults/root/css/animation.css +90 -0
- package/compiler-assets/nextjs/defaults/root/css/components/dialog.css +21 -0
- package/compiler-assets/nextjs/defaults/root/css/components/drawer.css +21 -0
- package/compiler-assets/nextjs/defaults/root/css/components/menu.css +23 -0
- package/compiler-assets/nextjs/defaults/root/css/components/navigation-menu.css +25 -0
- package/compiler-assets/nextjs/defaults/root/css/components/popover.css +17 -0
- package/compiler-assets/nextjs/defaults/root/css/components/select.css +23 -0
- package/compiler-assets/nextjs/defaults/root/css/components/toast.css +19 -0
- package/compiler-assets/nextjs/defaults/root/css/components/tooltip.css +15 -0
- package/compiler-assets/nextjs/defaults/root/css/layout.css +22 -0
- package/compiler-assets/nextjs/defaults/root/css/media.css +81 -0
- package/compiler-assets/nextjs/defaults/root/css/radius.css +49 -0
- package/compiler-assets/nextjs/defaults/root/css/scrollbar.css +43 -0
- package/compiler-assets/nextjs/defaults/root/css/shadow.css +145 -0
- package/compiler-assets/nextjs/defaults/root/css/typography.css +607 -0
- package/compiler-assets/nextjs/defaults/root/css/zindex.css +39 -0
- package/compiler-assets/nextjs/defaults/root/globals.css +191 -0
- package/compiler-assets/nextjs/defaults/root/layout.tsx +19 -0
- package/compiler-assets/nextjs/defaults/root/page.tsx +61 -0
- package/compiler-assets/nextjs/defaults/root/theme.css +50 -0
- package/compiler-assets/nextjs/defaults/source/_internal/logger.ts +21 -0
- package/compiler-assets/nextjs/shims/generated-group-layout.tsx +19 -0
- package/compiler-assets/nextjs/shims/generated-group-page.tsx +18 -0
- package/compiler-assets/nextjs/shims/generated-leaf-page.tsx +21 -0
- package/compiler-assets/nextjs/shims/global-layout.tsx +134 -0
- package/compiler-assets/nextjs/shims/markdown-route.ts +29 -0
- package/compiler-assets/nextjs/shims/og-image-route.ts +18 -0
- package/compiler-assets/nextjs/shims/powered-by-footer.tsx +40 -0
- package/compiler-assets/nextjs/shims/providers.tsx +13 -0
- package/compiler-assets/nextjs/shims/proxy.ts +317 -0
- package/compiler-assets/nextjs/shims/publish-os-theme-provider.tsx +77 -0
- package/compiler-assets/nextjs/shims/root-page.tsx +13 -0
- package/compiler-assets/nextjs/shims/theme-defaults.css +177 -0
- package/dist/button-CFdx-ohV.d.ts +20 -0
- package/dist/cache/tags.js +6 -14
- package/dist/compiler.d.ts +100 -0
- package/dist/compiler.js +13379 -0
- package/dist/config/createNextConfig.d.ts +2 -1
- package/dist/config/createNextConfig.js +16 -12
- package/dist/icons.d.ts +1 -0
- package/dist/icons.js +2 -0
- package/dist/index.d.ts +303 -15
- package/dist/index.js +30 -1198
- package/dist/kernel/components/blocks/AgentActions.d.ts +9 -3
- package/dist/kernel/components/blocks/AgentActions.js +114 -200
- package/dist/kernel/components/blocks/animated-icon-swap.js +4 -25
- package/dist/kernel/components/blocks/color-palette.js +88 -169
- package/dist/kernel/components/blocks/design-system-preview.d.ts +38 -6
- package/dist/kernel/components/blocks/design-system-preview.js +44 -52
- package/dist/kernel/components/blocks/link-playground.js +23 -71
- package/dist/kernel/components/blocks/logo-block.js +18 -47
- package/dist/kernel/components/blocks/nav-breadcrumb.d.ts +1 -1
- package/dist/kernel/components/blocks/nav-breadcrumb.js +28 -42
- package/dist/kernel/components/blocks/navbar.d.ts +1 -1
- package/dist/kernel/components/blocks/navbar.js +14 -41
- package/dist/kernel/components/blocks/navigation-progress-playground.js +56 -149
- package/dist/kernel/components/blocks/navigation-progress.js +53 -157
- package/dist/kernel/components/blocks/next-prev.d.ts +1 -1
- package/dist/kernel/components/blocks/next-prev.js +16 -42
- package/dist/kernel/components/blocks/page-list.d.ts +1 -1
- package/dist/kernel/components/blocks/page-list.js +11 -16
- package/dist/kernel/components/blocks/search.d.ts +13 -2
- package/dist/kernel/components/blocks/search.js +116 -247
- package/dist/kernel/components/blocks/sidebar-node.d.ts +2 -2
- package/dist/kernel/components/blocks/sidebar-node.js +56 -95
- package/dist/kernel/components/blocks/sidebar.d.ts +5 -23
- package/dist/kernel/components/blocks/sidebar.js +35 -103
- package/dist/kernel/components/blocks/theme-toggle.d.ts +7 -3
- package/dist/kernel/components/blocks/theme-toggle.js +2 -2
- package/dist/kernel/components/blocks/toc.js +42 -178
- package/dist/kernel/components/mdx/components/blockquote.js +3 -24
- package/dist/kernel/components/mdx/components/callout.d.ts +1 -1
- package/dist/kernel/components/mdx/components/callout.js +15 -47
- package/dist/kernel/components/mdx/components/code-block.js +2 -2
- package/dist/kernel/components/mdx/components/figure-caption.js +6 -24
- package/dist/kernel/components/mdx/components/figure.js +9 -36
- package/dist/kernel/components/mdx/components/footnotes.js +3 -24
- package/dist/kernel/components/mdx/components/heading-copy-link.js +13 -37
- package/dist/kernel/components/mdx/components/heading.d.ts +8 -3
- package/dist/kernel/components/mdx/components/heading.js +32 -116
- package/dist/kernel/components/mdx/components/hr.d.ts +5 -3
- package/dist/kernel/components/mdx/components/hr.js +2 -2
- package/dist/kernel/components/mdx/components/image-zoom.js +2 -3
- package/dist/kernel/components/mdx/components/image.js +22 -62
- package/dist/kernel/components/mdx/components/inline-code.js +3 -24
- package/dist/kernel/components/mdx/components/kbd.d.ts +9 -4
- package/dist/kernel/components/mdx/components/kbd.js +2 -2
- package/dist/kernel/components/mdx/components/link.d.ts +1 -2
- package/dist/kernel/components/mdx/components/link.js +2 -2
- package/dist/kernel/components/mdx/components/paragraph.js +13 -41
- package/dist/kernel/components/mdx/components/pre.js +3 -24
- package/dist/kernel/components/mdx/components/strikethrough.js +6 -24
- package/dist/kernel/components/mdx/components/table.js +2 -2
- package/dist/kernel/components/mdx/components/task-list.js +6 -28
- package/dist/kernel/components/mdx/components/video-player.js +53 -88
- package/dist/kernel/components/mdx/components/video.js +27 -75
- package/dist/kernel/components/mdx/error-boundary.d.ts +1 -1
- package/dist/kernel/components/mdx/error-boundary.js +12 -15
- package/dist/kernel/components/mdx/error-fallback.js +4 -4
- package/dist/kernel/components/mdx/mdx.d.ts +68 -11
- package/dist/kernel/components/mdx/mdx.js +29 -29
- package/dist/kernel/components/mdx/rehype-heading-ids.js +11 -67
- package/dist/kernel/components/mdx/types.d.ts +1 -1
- package/dist/kernel/components/ui/accordion.js +3 -26
- package/dist/kernel/components/ui/breadcrumb-trail.d.ts +23 -7
- package/dist/kernel/components/ui/breadcrumb-trail.js +32 -80
- package/dist/kernel/components/ui/breadcrumb.d.ts +1 -1
- package/dist/kernel/components/ui/breadcrumb.js +20 -54
- package/dist/kernel/components/ui/button-group.d.ts +4 -3
- package/dist/kernel/components/ui/button-group.js +7 -30
- package/dist/kernel/components/ui/button.js +13 -36
- package/dist/kernel/components/ui/card.d.ts +2 -2
- package/dist/kernel/components/ui/card.js +2 -23
- package/dist/kernel/components/ui/dialog.d.ts +9 -9
- package/dist/kernel/components/ui/dialog.js +15 -33
- package/dist/kernel/components/ui/drawer.d.ts +10 -10
- package/dist/kernel/components/ui/drawer.js +15 -33
- package/dist/kernel/components/ui/input.js +6 -30
- package/dist/kernel/components/ui/kbd.js +10 -31
- package/dist/kernel/components/ui/link.d.ts +1 -1
- package/dist/kernel/components/ui/link.js +53 -104
- package/dist/kernel/components/ui/menu.d.ts +21 -21
- package/dist/kernel/components/ui/menu.js +10 -32
- package/dist/kernel/components/ui/meta-key.d.ts +9 -4
- package/dist/kernel/components/ui/meta-key.js +2 -2
- package/dist/kernel/components/ui/navigation-menu.d.ts +14 -14
- package/dist/kernel/components/ui/navigation-menu.js +9 -30
- package/dist/kernel/components/ui/popover.d.ts +10 -10
- package/dist/kernel/components/ui/popover.js +19 -34
- package/dist/kernel/components/ui/progress.js +2 -25
- package/dist/kernel/components/ui/scroll-area.js +39 -118
- package/dist/kernel/components/ui/select.d.ts +15 -15
- package/dist/kernel/components/ui/select.js +19 -35
- package/dist/kernel/components/ui/separator.js +2 -25
- package/dist/kernel/components/ui/table.js +2 -23
- package/dist/kernel/components/ui/tabs.js +39 -99
- package/dist/kernel/components/ui/tag.d.ts +2 -2
- package/dist/kernel/components/ui/tag.js +4 -25
- package/dist/kernel/components/ui/text.d.ts +2 -2
- package/dist/kernel/components/ui/text.js +3 -25
- package/dist/kernel/components/ui/theme-toggle.d.ts +18 -4
- package/dist/kernel/components/ui/theme-toggle.js +18 -44
- package/dist/kernel/components/ui/toast.d.ts +10 -10
- package/dist/kernel/components/ui/toast.js +13 -35
- package/dist/kernel/components/ui/tooltip.d.ts +8 -8
- package/dist/kernel/components/ui/tooltip.js +8 -29
- package/dist/kernel/defaults.registry.d.ts +1 -1
- package/dist/kernel/defaults.registry.js +2 -2
- package/dist/kernel/framework-icons.d.ts +1 -0
- package/dist/kernel/framework-icons.js +39 -0
- package/dist/kernel/routes/agent/markdown.js +36 -65
- package/dist/kernel/routes/layouts/group.d.ts +1 -1
- package/dist/kernel/routes/layouts/group.js +20 -109
- package/dist/kernel/routes/metadata/feed.d.ts +1 -2
- package/dist/kernel/routes/metadata/feed.js +46 -127
- package/dist/kernel/routes/metadata/llms.d.ts +1 -2
- package/dist/kernel/routes/metadata/llms.js +40 -120
- package/dist/kernel/routes/metadata/og-image.d.ts +10 -0
- package/dist/kernel/routes/metadata/og-image.js +264 -198
- package/dist/kernel/routes/metadata/robots.d.ts +1 -2
- package/dist/kernel/routes/metadata/robots.js +21 -90
- package/dist/kernel/routes/metadata/sitemap.d.ts +1 -2
- package/dist/kernel/routes/metadata/sitemap.js +36 -102
- package/dist/kernel/routes/pages/group.d.ts +1 -1
- package/dist/kernel/routes/pages/group.js +42 -137
- package/dist/kernel/routes/pages/leaf.d.ts +1 -1
- package/dist/kernel/routes/pages/leaf.js +74 -213
- package/dist/kernel/routes/pages/root.d.ts +1 -1
- package/dist/kernel/routes/pages/root.js +37 -108
- package/dist/keyboard-shortcuts.js +69 -141
- package/dist/link-CYaCRDb6.d.ts +35 -0
- package/dist/resolvers/manifest-resolver.d.ts +3 -3
- package/dist/resolvers/manifest-resolver.js +15 -21
- package/dist/route-metadata-og-image-BeKKFHg7.d.ts +58 -0
- package/dist/search.d.ts +81 -4
- package/dist/search.js +124 -195
- package/dist/sidebar-types-Bgchdfd6.d.ts +25 -0
- package/dist/theme-scope.d.ts +15 -0
- package/dist/theme-scope.js +23 -0
- package/dist/types-B_b3C0U6.d.ts +63 -0
- package/dist/types-CIwwieNw.d.ts +127 -0
- package/dist/types-DHBm7-j6.d.ts +57 -0
- package/dist/types-sM2g9nW0.d.ts +12 -0
- package/dist/types.d.ts +0 -1
- package/dist/types.js +1 -1
- package/dist/utils/cn.d.ts +5 -9
- package/dist/utils/cn.js +13 -7
- package/dist/utils/heading-ids.js +20 -47
- package/dist/utils/pretty-date.js +7 -13
- package/init/seed/minimal/publish.os/assets/logo/publish-dev-logo.dark.png +0 -0
- package/init/seed/minimal/publish.os/assets/logo/publish-dev-logo.png +0 -0
- package/init/seed/minimal/publish.os/docs/content/get-started.mdx +54 -0
- package/init/seed/minimal/publish.os/docs/content/groups.mdx +31 -0
- package/init/seed/minimal/publish.os/docs/content/theme.mdx +64 -0
- package/init/seed/minimal/publish.os/publish.os.config.json +21 -0
- package/init/seed/minimal/publish.os/theme.css +47 -0
- package/init/seed/minimal/seed.json +13 -0
- package/package.json +469 -35
- package/release/{package.json → app/lucide/package.json} +11 -5
- package/release/app/lucide/pnpm-lock.yaml.template +2905 -0
- package/release/app/lucide/pnpm-workspace.yaml +11 -0
- package/release/app/phosphor/package.json +30 -0
- package/release/app/phosphor/pnpm-lock.yaml.template +2908 -0
- package/release/app/phosphor/pnpm-workspace.yaml +11 -0
- package/release/app/tabler/package.json +30 -0
- package/release/app/tabler/pnpm-lock.yaml.template +2911 -0
- package/release/app/tabler/pnpm-workspace.yaml +11 -0
- package/release/compiler/package.json +20 -0
- package/release/compiler/pnpm-lock.yaml.template +2432 -0
- package/release/compiler/pnpm-workspace.yaml +11 -0
- package/release/release.json +29 -5
- package/release/runtime-pnpm-lock.yaml +0 -1316
|
@@ -1,32 +1,10 @@
|
|
|
1
|
-
// src/
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
var twMerge = extendTailwindMerge({
|
|
5
|
-
extend: {
|
|
6
|
-
classGroups: {
|
|
7
|
-
z: [
|
|
8
|
-
"z-content",
|
|
9
|
-
"z-nav",
|
|
10
|
-
"z-overlay",
|
|
11
|
-
"z-modal",
|
|
12
|
-
"z-search",
|
|
13
|
-
"z-toast",
|
|
14
|
-
"z-progress"
|
|
15
|
-
]
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
function cn(...inputs) {
|
|
20
|
-
return twMerge(clsx(inputs));
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// src/kernel/components/blocks/sidebar-node.tsx
|
|
1
|
+
// src/components/block/navigation/sidebar-node.tsx
|
|
2
|
+
import { FrameworkChevronRightIcon as ChevronRight } from "@publish.os/nextjs/kernel/framework-icons";
|
|
3
|
+
import { cn } from "@publish.os/nextjs/utils/cn";
|
|
24
4
|
import { cva } from "class-variance-authority";
|
|
25
|
-
import { ChevronRight } from "lucide-react";
|
|
26
5
|
import NextLink from "next/link";
|
|
27
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
28
|
-
var SIDEBAR_NODE_VARIANT = "base"
|
|
29
|
-
var depthClassByDepth = {
|
|
7
|
+
var SIDEBAR_NODE_VARIANT = "base", depthClassByDepth = {
|
|
30
8
|
0: "pl-2",
|
|
31
9
|
1: "pl-5",
|
|
32
10
|
2: "pl-8",
|
|
@@ -40,8 +18,7 @@ var depthClassByDepth = {
|
|
|
40
18
|
10: "pl-32",
|
|
41
19
|
11: "pl-[140px]",
|
|
42
20
|
12: "pl-[152px]"
|
|
43
|
-
}
|
|
44
|
-
var sidebarSectionVariants = cva(
|
|
21
|
+
}, sidebarSectionVariants = cva(
|
|
45
22
|
"mb-2 mt-6 flex min-h-5 items-center gap-2 pr-2 text-[11px] font-semibold uppercase leading-4 tracking-wide text-foreground-3 first:mt-0",
|
|
46
23
|
{
|
|
47
24
|
variants: {
|
|
@@ -51,8 +28,7 @@ var sidebarSectionVariants = cva(
|
|
|
51
28
|
}
|
|
52
29
|
}
|
|
53
30
|
}
|
|
54
|
-
)
|
|
55
|
-
var sidebarNodeVariants = cva(
|
|
31
|
+
), sidebarNodeVariants = cva(
|
|
56
32
|
[
|
|
57
33
|
"group/sidebar-row relative flex min-h-8 w-full min-w-0 items-center gap-2 rounded-button py-1.5 pr-2 text-left text-[13px] leading-5",
|
|
58
34
|
"transition-[background-color,color,box-shadow] duration-200 ease-out"
|
|
@@ -77,7 +53,7 @@ var sidebarNodeVariants = cva(
|
|
|
77
53
|
}
|
|
78
54
|
},
|
|
79
55
|
defaultVariants: {
|
|
80
|
-
interactive:
|
|
56
|
+
interactive: !1,
|
|
81
57
|
variant: "base"
|
|
82
58
|
}
|
|
83
59
|
}
|
|
@@ -86,10 +62,8 @@ function isExternalHref(href) {
|
|
|
86
62
|
return /^[a-z][a-z0-9+.-]*:/i.test(href) && !href.startsWith("mailto:") && !href.startsWith("tel:") || href.startsWith("//");
|
|
87
63
|
}
|
|
88
64
|
function mergeRel(rel) {
|
|
89
|
-
|
|
90
|
-
values.add("noopener");
|
|
91
|
-
values.add("noreferrer");
|
|
92
|
-
return Array.from(values).join(" ");
|
|
65
|
+
let values = new Set((rel ?? "").split(/\s+/).filter(Boolean));
|
|
66
|
+
return values.add("noopener"), values.add("noreferrer"), Array.from(values).join(" ");
|
|
93
67
|
}
|
|
94
68
|
function Caret({ active, expanded }) {
|
|
95
69
|
return /* @__PURE__ */ jsx(
|
|
@@ -159,20 +133,17 @@ function SidebarLink({
|
|
|
159
133
|
parentExpanded,
|
|
160
134
|
...props
|
|
161
135
|
}) {
|
|
162
|
-
|
|
136
|
+
let commonProps = {
|
|
163
137
|
"aria-current": active ? "page" : void 0,
|
|
164
138
|
className: cn(
|
|
165
|
-
"block rounded-button focus-visible:outline-2 focus-visible:outline-offset-0 focus-visible:outline-focus-
|
|
139
|
+
"block rounded-button focus-visible:outline-2 focus-visible:outline-offset-0 focus-visible:outline-focus-stroke",
|
|
166
140
|
className
|
|
167
141
|
),
|
|
168
142
|
onClick,
|
|
169
143
|
tabIndex: parentExpanded ? void 0 : -1,
|
|
170
144
|
...props
|
|
171
145
|
};
|
|
172
|
-
|
|
173
|
-
return /* @__PURE__ */ jsx("a", { href, rel: mergeRel(void 0), target: "_blank", ...commonProps, children });
|
|
174
|
-
}
|
|
175
|
-
return /* @__PURE__ */ jsx(NextLink, { href, ...commonProps, children });
|
|
146
|
+
return isExternalHref(href) ? /* @__PURE__ */ jsx("a", { href, rel: mergeRel(void 0), target: "_blank", ...commonProps, children }) : /* @__PURE__ */ jsx(NextLink, { href, ...commonProps, children });
|
|
176
147
|
}
|
|
177
148
|
function SidebarNode({
|
|
178
149
|
activeState,
|
|
@@ -180,65 +151,55 @@ function SidebarNode({
|
|
|
180
151
|
children,
|
|
181
152
|
contentId,
|
|
182
153
|
depth,
|
|
183
|
-
expanded =
|
|
154
|
+
expanded = !1,
|
|
184
155
|
href,
|
|
185
|
-
isExpandable =
|
|
156
|
+
isExpandable = !1,
|
|
186
157
|
node,
|
|
187
158
|
onLinkClick,
|
|
188
159
|
onToggle,
|
|
189
160
|
parentExpanded,
|
|
190
161
|
title
|
|
191
162
|
}) {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
"button",
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
]
|
|
233
|
-
}
|
|
234
|
-
)
|
|
235
|
-
}
|
|
236
|
-
),
|
|
237
|
-
children
|
|
238
|
-
] });
|
|
239
|
-
}
|
|
240
|
-
if (!href) return null;
|
|
241
|
-
return /* @__PURE__ */ jsxs("li", { className: "select-none", children: [
|
|
163
|
+
let isActive = activeState === "path-active", active = isActive || activeState === "child-path-active", isExternalLinkNode = node.type === "link" && href ? isExternalHref(href) : !1;
|
|
164
|
+
return node.type === "section" ? /* @__PURE__ */ jsxs("li", { children: [
|
|
165
|
+
/* @__PURE__ */ jsx(
|
|
166
|
+
"div",
|
|
167
|
+
{
|
|
168
|
+
className: cn(
|
|
169
|
+
sidebarSectionVariants({ variant: SIDEBAR_NODE_VARIANT }),
|
|
170
|
+
depthClassByDepth[depth]
|
|
171
|
+
),
|
|
172
|
+
children: title
|
|
173
|
+
}
|
|
174
|
+
),
|
|
175
|
+
children
|
|
176
|
+
] }) : node.type === "folder" ? /* @__PURE__ */ jsxs("li", { className: "select-none", children: [
|
|
177
|
+
/* @__PURE__ */ jsx(
|
|
178
|
+
"button",
|
|
179
|
+
{
|
|
180
|
+
"aria-controls": contentId,
|
|
181
|
+
"aria-expanded": expanded,
|
|
182
|
+
className: "block w-full rounded-button focus-visible:outline-2 focus-visible:outline-offset-0 focus-visible:outline-focus-stroke",
|
|
183
|
+
onClick: onToggle,
|
|
184
|
+
tabIndex: parentExpanded ? void 0 : -1,
|
|
185
|
+
type: "button",
|
|
186
|
+
children: /* @__PURE__ */ jsxs(
|
|
187
|
+
RowInner,
|
|
188
|
+
{
|
|
189
|
+
activeItemRef,
|
|
190
|
+
activeState,
|
|
191
|
+
depth,
|
|
192
|
+
interactive: !0,
|
|
193
|
+
children: [
|
|
194
|
+
/* @__PURE__ */ jsx(RowText, { title }),
|
|
195
|
+
isExpandable ? /* @__PURE__ */ jsx(Caret, { active, expanded }) : null
|
|
196
|
+
]
|
|
197
|
+
}
|
|
198
|
+
)
|
|
199
|
+
}
|
|
200
|
+
),
|
|
201
|
+
children
|
|
202
|
+
] }) : href ? /* @__PURE__ */ jsxs("li", { className: "select-none", children: [
|
|
242
203
|
/* @__PURE__ */ jsx(
|
|
243
204
|
SidebarLink,
|
|
244
205
|
{
|
|
@@ -254,7 +215,7 @@ function SidebarNode({
|
|
|
254
215
|
activeItemRef,
|
|
255
216
|
activeState,
|
|
256
217
|
depth,
|
|
257
|
-
interactive:
|
|
218
|
+
interactive: !1,
|
|
258
219
|
children: [
|
|
259
220
|
/* @__PURE__ */ jsx(RowText, { title }),
|
|
260
221
|
isExpandable ? /* @__PURE__ */ jsx(Caret, { active, expanded }) : null,
|
|
@@ -265,7 +226,7 @@ function SidebarNode({
|
|
|
265
226
|
}
|
|
266
227
|
),
|
|
267
228
|
children
|
|
268
|
-
] });
|
|
229
|
+
] }) : null;
|
|
269
230
|
}
|
|
270
231
|
export {
|
|
271
232
|
SidebarNode
|
|
@@ -1,27 +1,9 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { a as SidebarTreeNode } from '../../../sidebar-types-Bgchdfd6.js';
|
|
4
|
+
export { b as SidebarActiveState, c as SidebarDepth, S as SidebarNodePrimitiveProps } from '../../../sidebar-types-Bgchdfd6.js';
|
|
5
|
+
import '../../../types-DHBm7-j6.js';
|
|
4
6
|
|
|
5
|
-
type SidebarTreeNode = TreeNode & {
|
|
6
|
-
children?: SidebarTreeNode[];
|
|
7
|
-
};
|
|
8
|
-
type SidebarActiveState = "path-active" | "child-path-active";
|
|
9
|
-
type SidebarDepth = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
|
|
10
|
-
type SidebarNodePrimitiveProps = {
|
|
11
|
-
activeState?: SidebarActiveState;
|
|
12
|
-
activeItemRef?: Ref<HTMLDivElement>;
|
|
13
|
-
children?: ReactNode;
|
|
14
|
-
contentId?: string;
|
|
15
|
-
depth: SidebarDepth;
|
|
16
|
-
expanded?: boolean;
|
|
17
|
-
href?: string;
|
|
18
|
-
isExpandable?: boolean;
|
|
19
|
-
node: SidebarTreeNode;
|
|
20
|
-
onLinkClick?: (event: MouseEvent<HTMLAnchorElement>) => void;
|
|
21
|
-
onToggle?: () => void;
|
|
22
|
-
parentExpanded: boolean;
|
|
23
|
-
title: string;
|
|
24
|
-
};
|
|
25
7
|
type SidebarProps = {
|
|
26
8
|
className?: string;
|
|
27
9
|
currentPath?: string;
|
|
@@ -30,4 +12,4 @@ type SidebarProps = {
|
|
|
30
12
|
};
|
|
31
13
|
declare function Sidebar({ className, currentPath, title, tree }: SidebarProps): react_jsx_runtime.JSX.Element;
|
|
32
14
|
|
|
33
|
-
export { Sidebar, type
|
|
15
|
+
export { Sidebar, type SidebarProps, SidebarTreeNode };
|
|
@@ -1,32 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
// src/
|
|
4
|
-
import { SidebarNode } from "
|
|
5
|
-
import { ScrollArea } from "
|
|
6
|
-
|
|
7
|
-
// src/utils/cn.ts
|
|
8
|
-
import { clsx } from "clsx";
|
|
9
|
-
import { extendTailwindMerge } from "tailwind-merge";
|
|
10
|
-
var twMerge = extendTailwindMerge({
|
|
11
|
-
extend: {
|
|
12
|
-
classGroups: {
|
|
13
|
-
z: [
|
|
14
|
-
"z-content",
|
|
15
|
-
"z-nav",
|
|
16
|
-
"z-overlay",
|
|
17
|
-
"z-modal",
|
|
18
|
-
"z-search",
|
|
19
|
-
"z-toast",
|
|
20
|
-
"z-progress"
|
|
21
|
-
]
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
function cn(...inputs) {
|
|
26
|
-
return twMerge(clsx(inputs));
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// src/kernel/components/blocks/sidebar.tsx
|
|
3
|
+
// src/components/block/navigation/sidebar.tsx
|
|
4
|
+
import { SidebarNode } from "@publish.os/nextjs/kernel/components/blocks/sidebar-node";
|
|
5
|
+
import { ScrollArea } from "@publish.os/nextjs/kernel/components/ui/scroll-area";
|
|
6
|
+
import { cn } from "@publish.os/nextjs/utils/cn";
|
|
30
7
|
import { usePathname } from "next/navigation";
|
|
31
8
|
import {
|
|
32
9
|
memo,
|
|
@@ -41,58 +18,45 @@ import {
|
|
|
41
18
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
42
19
|
function normalizePath(path) {
|
|
43
20
|
if (!path) return "";
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return withoutQuery.replace(/\/+$/g, "");
|
|
21
|
+
let [withoutQuery = ""] = path.split(/[?#]/);
|
|
22
|
+
return withoutQuery === "/" ? "/" : withoutQuery.replace(/\/+$/g, "");
|
|
47
23
|
}
|
|
48
24
|
function isExternalHref(href) {
|
|
49
25
|
return /^[a-z][a-z0-9+.-]*:/i.test(href) || href.startsWith("//");
|
|
50
26
|
}
|
|
51
27
|
function nodeHref(node) {
|
|
52
28
|
if (node.type === "link") return node.href;
|
|
53
|
-
if ("path" in node && typeof node.path
|
|
54
|
-
return void 0;
|
|
29
|
+
if ("path" in node && typeof node.path == "string") return node.path;
|
|
55
30
|
}
|
|
56
31
|
function nodeChildren(node) {
|
|
57
32
|
return Array.isArray(node.children) ? node.children : [];
|
|
58
33
|
}
|
|
59
34
|
function nodeKey(node, parentKey) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if (node.type === "link") return `${prefix}link:${node.id}`;
|
|
63
|
-
return `${prefix}${node.type}:${node.id}`;
|
|
35
|
+
let prefix = parentKey ? `${parentKey}/` : "";
|
|
36
|
+
return node.type === "page" ? `${prefix}page:${node.fileID}` : node.type === "link" ? `${prefix}link:${node.id}` : `${prefix}${node.type}:${node.id}`;
|
|
64
37
|
}
|
|
65
38
|
function isActivePath(path, currentPath) {
|
|
66
|
-
if (!path || isExternalHref(path)) return
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (!normalizedPath) return false;
|
|
70
|
-
return normalizedCurrentPath === normalizedPath || normalizedCurrentPath.startsWith(`${normalizedPath}/`);
|
|
39
|
+
if (!path || isExternalHref(path)) return !1;
|
|
40
|
+
let normalizedPath = normalizePath(path), normalizedCurrentPath = normalizePath(currentPath);
|
|
41
|
+
return normalizedPath ? normalizedCurrentPath === normalizedPath || normalizedCurrentPath.startsWith(`${normalizedPath}/`) : !1;
|
|
71
42
|
}
|
|
72
43
|
function isExactActivePath(path, currentPath) {
|
|
73
|
-
|
|
74
|
-
return normalizePath(path) === normalizePath(currentPath);
|
|
44
|
+
return !path || isExternalHref(path) ? !1 : normalizePath(path) === normalizePath(currentPath);
|
|
75
45
|
}
|
|
76
46
|
function createActiveIndex({
|
|
77
47
|
currentPath,
|
|
78
48
|
tree
|
|
79
49
|
}) {
|
|
80
|
-
|
|
50
|
+
let activeIndex = /* @__PURE__ */ new Map();
|
|
81
51
|
function visit(node) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const pathActive = node.type === "page" && isActivePath(href, currentPath);
|
|
85
|
-
const childActive = nodeChildren(node).some(visit);
|
|
86
|
-
const activeState = exactActive ? "path-active" : childActive || pathActive ? "child-path-active" : void 0;
|
|
87
|
-
activeIndex.set(node, {
|
|
52
|
+
let href = nodeHref(node), exactActive = isExactActivePath(href, currentPath), pathActive = node.type === "page" && isActivePath(href, currentPath), childActive = nodeChildren(node).some(visit), activeState = exactActive ? "path-active" : childActive || pathActive ? "child-path-active" : void 0;
|
|
53
|
+
return activeIndex.set(node, {
|
|
88
54
|
activeState,
|
|
89
55
|
initiallyExpanded: exactActive || pathActive || childActive
|
|
90
|
-
});
|
|
91
|
-
return exactActive || pathActive || childActive;
|
|
56
|
+
}), exactActive || pathActive || childActive;
|
|
92
57
|
}
|
|
93
|
-
for (
|
|
58
|
+
for (let node of tree)
|
|
94
59
|
visit(node);
|
|
95
|
-
}
|
|
96
60
|
return activeIndex;
|
|
97
61
|
}
|
|
98
62
|
function safeIdPart(value) {
|
|
@@ -102,7 +66,7 @@ function nodeContentId({
|
|
|
102
66
|
instanceId,
|
|
103
67
|
node
|
|
104
68
|
}) {
|
|
105
|
-
|
|
69
|
+
let key = "path" in node && node.path ? node.path : node.type === "page" ? node.fileID : node.id;
|
|
106
70
|
return `sidebar-${safeIdPart(instanceId)}-${safeIdPart(key)}`;
|
|
107
71
|
}
|
|
108
72
|
function clampDepth(depth) {
|
|
@@ -120,7 +84,7 @@ function ExpandableChildren({
|
|
|
120
84
|
parentExpanded,
|
|
121
85
|
renderChildren
|
|
122
86
|
}) {
|
|
123
|
-
|
|
87
|
+
let childFocusable = parentExpanded && expanded;
|
|
124
88
|
return /* @__PURE__ */ jsx(
|
|
125
89
|
"div",
|
|
126
90
|
{
|
|
@@ -158,41 +122,16 @@ var SidebarTreeItem = memo(function SidebarTreeItem2({
|
|
|
158
122
|
node,
|
|
159
123
|
parentExpanded
|
|
160
124
|
}) {
|
|
161
|
-
|
|
162
|
-
const href = nodeHref(node);
|
|
163
|
-
const activeInfo = activeIndex.get(node);
|
|
164
|
-
const activeState = activeInfo?.activeState;
|
|
165
|
-
const initiallyExpanded = Boolean(activeInfo?.initiallyExpanded);
|
|
166
|
-
const isExpandable = nodes.length > 0 && (node.type === "folder" || node.type === "page");
|
|
167
|
-
const [expanded, setExpanded] = useState(initiallyExpanded);
|
|
168
|
-
const [renderChildren, setRenderChildren] = useState(initiallyExpanded);
|
|
169
|
-
const interactedRef = useRef(false);
|
|
170
|
-
const lastPathRef = useRef(normalizePath(currentPath));
|
|
171
|
-
const contentId = nodeContentId({ instanceId, node });
|
|
125
|
+
let nodes = nodeChildren(node), href = nodeHref(node), activeInfo = activeIndex.get(node), activeState = activeInfo?.activeState, initiallyExpanded = !!activeInfo?.initiallyExpanded, isExpandable = nodes.length > 0 && (node.type === "folder" || node.type === "page"), [expanded, setExpanded] = useState(initiallyExpanded), [renderChildren, setRenderChildren] = useState(initiallyExpanded), interactedRef = useRef(!1), lastPathRef = useRef(normalizePath(currentPath)), contentId = nodeContentId({ instanceId, node });
|
|
172
126
|
useEffect(() => {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
if (pathChanged) {
|
|
176
|
-
interactedRef.current = false;
|
|
177
|
-
lastPathRef.current = normalizedCurrentPath;
|
|
178
|
-
}
|
|
179
|
-
if (initiallyExpanded && !expanded && !interactedRef.current) {
|
|
180
|
-
setRenderChildren(true);
|
|
181
|
-
startTransition(() => setExpanded(true));
|
|
182
|
-
}
|
|
127
|
+
let normalizedCurrentPath = normalizePath(currentPath);
|
|
128
|
+
lastPathRef.current !== normalizedCurrentPath && (interactedRef.current = !1, lastPathRef.current = normalizedCurrentPath), initiallyExpanded && !expanded && !interactedRef.current && (setRenderChildren(!0), startTransition(() => setExpanded(!0)));
|
|
183
129
|
}, [currentPath, expanded, initiallyExpanded]);
|
|
184
|
-
|
|
185
|
-
interactedRef.current =
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}, [])
|
|
189
|
-
const expandOnNavigate = useCallback(() => {
|
|
190
|
-
interactedRef.current = true;
|
|
191
|
-
setRenderChildren(true);
|
|
192
|
-
setExpanded(true);
|
|
193
|
-
}, []);
|
|
194
|
-
const pageWithChildrenLinkClick = node.type === "page" && nodes.length > 0 ? expandOnNavigate : void 0;
|
|
195
|
-
const children = isExpandable && nodes.length > 0 ? /* @__PURE__ */ jsx(
|
|
130
|
+
let toggleExpanded = useCallback(() => {
|
|
131
|
+
interactedRef.current = !0, setRenderChildren(!0), setExpanded((value) => !value);
|
|
132
|
+
}, []), expandOnNavigate = useCallback(() => {
|
|
133
|
+
interactedRef.current = !0, setRenderChildren(!0), setExpanded(!0);
|
|
134
|
+
}, []), pageWithChildrenLinkClick = node.type === "page" && nodes.length > 0 ? expandOnNavigate : void 0, children = isExpandable && nodes.length > 0 ? /* @__PURE__ */ jsx(
|
|
196
135
|
ExpandableChildren,
|
|
197
136
|
{
|
|
198
137
|
activeIndex,
|
|
@@ -240,26 +179,19 @@ var SidebarTreeItem = memo(function SidebarTreeItem2({
|
|
|
240
179
|
);
|
|
241
180
|
});
|
|
242
181
|
function Sidebar({ className, currentPath, title, tree }) {
|
|
243
|
-
|
|
244
|
-
const resolvedCurrentPath = pathname ?? currentPath ?? "";
|
|
245
|
-
const instanceId = useId();
|
|
246
|
-
const activeItemRef = useRef(null);
|
|
247
|
-
const activeIndex = useMemo(
|
|
182
|
+
let resolvedCurrentPath = usePathname() ?? currentPath ?? "", instanceId = useId(), activeItemRef = useRef(null), activeIndex = useMemo(
|
|
248
183
|
() => createActiveIndex({ currentPath: resolvedCurrentPath, tree }),
|
|
249
184
|
[resolvedCurrentPath, tree]
|
|
250
185
|
);
|
|
251
|
-
useEffect(() => {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
if (!scrollPath) return;
|
|
255
|
-
activeItemRef.current?.scrollIntoView({
|
|
186
|
+
return useEffect(() => {
|
|
187
|
+
let scrollPath = resolvedCurrentPath, frame = window.requestAnimationFrame(() => {
|
|
188
|
+
scrollPath && activeItemRef.current?.scrollIntoView({
|
|
256
189
|
block: "nearest",
|
|
257
190
|
inline: "nearest"
|
|
258
191
|
});
|
|
259
192
|
});
|
|
260
193
|
return () => window.cancelAnimationFrame(frame);
|
|
261
|
-
}, [resolvedCurrentPath])
|
|
262
|
-
return /* @__PURE__ */ jsxs(
|
|
194
|
+
}, [resolvedCurrentPath]), /* @__PURE__ */ jsxs(
|
|
263
195
|
"nav",
|
|
264
196
|
{
|
|
265
197
|
"aria-label": "Documentation navigation",
|
|
@@ -273,7 +205,7 @@ function Sidebar({ className, currentPath, title, tree }) {
|
|
|
273
205
|
ScrollArea,
|
|
274
206
|
{
|
|
275
207
|
className: "min-h-0 flex-1",
|
|
276
|
-
corner:
|
|
208
|
+
corner: !0,
|
|
277
209
|
mask: { height: 24 },
|
|
278
210
|
scrollbarClassName: "opacity-0 transition-opacity data-[hovering]:opacity-100 data-[scrolling]:opacity-100",
|
|
279
211
|
variant: "gradient",
|
|
@@ -287,7 +219,7 @@ function Sidebar({ className, currentPath, title, tree }) {
|
|
|
287
219
|
instanceId,
|
|
288
220
|
itemKey: nodeKey(node, ""),
|
|
289
221
|
node,
|
|
290
|
-
parentExpanded:
|
|
222
|
+
parentExpanded: !0
|
|
291
223
|
},
|
|
292
224
|
nodeKey(node, "")
|
|
293
225
|
)) })
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
import '
|
|
3
|
-
import '../ui/button.js';
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { a as ButtonProps } from '../../../button-CFdx-ohV.js';
|
|
4
3
|
import 'class-variance-authority/types';
|
|
5
4
|
import 'class-variance-authority';
|
|
6
5
|
import 'react';
|
|
6
|
+
|
|
7
|
+
type ThemeToggleProps = Omit<ButtonProps, "children" | "iconOnly" | "leftIcon" | "loading" | "rightIcon">;
|
|
8
|
+
declare function ThemeToggle({ className, onClick, size, title, type, variant, ...props }: ThemeToggleProps): react_jsx_runtime.JSX.Element;
|
|
9
|
+
|
|
10
|
+
export { ThemeToggle };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
// src/
|
|
4
|
-
import { ThemeToggle } from "
|
|
3
|
+
// src/components/block/theme-toggle.tsx
|
|
4
|
+
import { ThemeToggle } from "@publish.os/nextjs/kernel/components/ui/theme-toggle";
|
|
5
5
|
export {
|
|
6
6
|
ThemeToggle
|
|
7
7
|
};
|