@publish.os/nextjs 0.0.1-alpha.4 → 0.0.1-alpha.6
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 +1 -1
- package/dist/config/createNextConfig.js +3 -3
- package/dist/index.js +7 -5
- package/dist/kernel/components/blocks/color-palette.js +35 -4
- package/dist/kernel/components/blocks/design-system-preview.js +18 -17
- package/dist/kernel/components/blocks/link-playground.js +3 -3
- package/dist/kernel/components/blocks/logo-block.js +1 -1
- package/dist/kernel/components/blocks/nav-breadcrumb.js +2 -12
- package/dist/kernel/components/blocks/navbar.js +1 -1
- package/dist/kernel/components/blocks/navigation-progress-playground.js +2 -2
- package/dist/kernel/components/mdx/components/image.js +1 -1
- package/dist/kernel/components/ui/breadcrumb-trail.d.ts +3 -1
- package/dist/kernel/components/ui/breadcrumb-trail.js +1 -0
- package/dist/kernel/components/ui/breadcrumb.d.ts +1 -5
- package/dist/kernel/components/ui/breadcrumb.js +1 -16
- package/dist/kernel/components/ui/button-group.d.ts +2 -2
- package/dist/kernel/components/ui/button-group.js +2 -3
- package/dist/kernel/components/ui/button.d.ts +3 -4
- package/dist/kernel/components/ui/button.js +4 -12
- package/dist/kernel/components/ui/card.d.ts +1 -1
- package/dist/kernel/components/ui/menu.js +5 -5
- package/dist/kernel/components/ui/navigation-menu.js +2 -2
- package/dist/kernel/components/ui/popover.js +5 -11
- package/dist/kernel/components/ui/select.js +5 -5
- package/dist/kernel/components/ui/tag.d.ts +14 -0
- package/dist/kernel/components/ui/tag.js +76 -0
- package/dist/kernel/components/ui/text.d.ts +1 -1
- package/dist/kernel/components/ui/text.js +109 -106
- package/dist/kernel/components/ui/theme-toggle.js +1 -1
- package/dist/kernel/components/ui/tooltip.js +2 -2
- package/dist/kernel/defaults.registry.d.ts +63 -72
- package/dist/kernel/defaults.registry.js +62 -70
- package/dist/kernel/routes/agent/markdown.js +2 -2
- package/dist/kernel/routes/metadata/feed.js +2 -2
- package/dist/kernel/routes/metadata/llms.js +4 -2
- package/dist/kernel/routes/metadata/og-image.d.ts +1 -1
- package/dist/kernel/routes/metadata/robots.js +2 -2
- package/dist/kernel/routes/metadata/sitemap.js +2 -2
- package/dist/utils/cn.d.ts +1 -1
- package/package.json +4 -9
- package/release/package.json +4 -3
- package/release/release.json +5 -5
- package/release/{pnpm-lock.yaml → runtime-pnpm-lock.yaml} +348 -224
- package/dist/cache/tags.cjs +0 -79
- package/dist/cache/tags.d.cts +0 -13
- package/dist/config/createNextConfig.cjs +0 -52
- package/dist/config/createNextConfig.d.cts +0 -8
- package/dist/config.cjs +0 -78
- package/dist/config.d.cts +0 -101
- package/dist/config.d.ts +0 -101
- package/dist/config.js +0 -48
- package/dist/index.cjs +0 -1266
- package/dist/index.d.cts +0 -18
- package/dist/kernel/components/blocks/AgentActions.cjs +0 -425
- package/dist/kernel/components/blocks/AgentActions.d.cts +0 -52
- package/dist/kernel/components/blocks/animated-icon-swap.cjs +0 -101
- package/dist/kernel/components/blocks/animated-icon-swap.d.cts +0 -16
- package/dist/kernel/components/blocks/color-palette.cjs +0 -413
- package/dist/kernel/components/blocks/color-palette.d.cts +0 -7
- package/dist/kernel/components/blocks/design-system-preview.cjs +0 -592
- package/dist/kernel/components/blocks/design-system-preview.d.cts +0 -29
- package/dist/kernel/components/blocks/link-playground.cjs +0 -816
- package/dist/kernel/components/blocks/link-playground.d.cts +0 -5
- package/dist/kernel/components/blocks/logo-block.cjs +0 -156
- package/dist/kernel/components/blocks/logo-block.d.cts +0 -21
- package/dist/kernel/components/blocks/nav-breadcrumb.cjs +0 -122
- package/dist/kernel/components/blocks/nav-breadcrumb.d.cts +0 -11
- package/dist/kernel/components/blocks/navbar.cjs +0 -154
- package/dist/kernel/components/blocks/navbar.d.cts +0 -16
- package/dist/kernel/components/blocks/navigation-progress-playground.cjs +0 -735
- package/dist/kernel/components/blocks/navigation-progress-playground.d.cts +0 -5
- package/dist/kernel/components/blocks/navigation-progress.cjs +0 -270
- package/dist/kernel/components/blocks/navigation-progress.d.cts +0 -16
- package/dist/kernel/components/blocks/next-prev.cjs +0 -142
- package/dist/kernel/components/blocks/next-prev.d.cts +0 -11
- package/dist/kernel/components/blocks/page-list.cjs +0 -59
- package/dist/kernel/components/blocks/page-list.d.cts +0 -11
- package/dist/kernel/components/blocks/search.cjs +0 -717
- package/dist/kernel/components/blocks/search.d.cts +0 -77
- package/dist/kernel/components/blocks/sidebar-node.cjs +0 -309
- package/dist/kernel/components/blocks/sidebar-node.d.cts +0 -8
- package/dist/kernel/components/blocks/sidebar.cjs +0 -317
- package/dist/kernel/components/blocks/sidebar.d.cts +0 -33
- package/dist/kernel/components/blocks/theme-toggle.cjs +0 -31
- package/dist/kernel/components/blocks/theme-toggle.d.cts +0 -6
- package/dist/kernel/components/blocks/toc.cjs +0 -356
- package/dist/kernel/components/blocks/toc.d.cts +0 -10
- package/dist/kernel/components/mdx/components/blockquote.cjs +0 -66
- package/dist/kernel/components/mdx/components/blockquote.d.cts +0 -6
- package/dist/kernel/components/mdx/components/callout.cjs +0 -137
- package/dist/kernel/components/mdx/components/callout.d.cts +0 -18
- package/dist/kernel/components/mdx/components/code-block.cjs +0 -39
- package/dist/kernel/components/mdx/components/code-block.d.cts +0 -9
- package/dist/kernel/components/mdx/components/figure-caption.cjs +0 -63
- package/dist/kernel/components/mdx/components/figure-caption.d.cts +0 -6
- package/dist/kernel/components/mdx/components/figure.cjs +0 -78
- package/dist/kernel/components/mdx/components/figure.d.cts +0 -10
- package/dist/kernel/components/mdx/components/footnotes.cjs +0 -66
- package/dist/kernel/components/mdx/components/footnotes.d.cts +0 -6
- package/dist/kernel/components/mdx/components/heading-copy-link.cjs +0 -108
- package/dist/kernel/components/mdx/components/heading-copy-link.d.cts +0 -23
- package/dist/kernel/components/mdx/components/heading.cjs +0 -166
- package/dist/kernel/components/mdx/components/heading.d.cts +0 -8
- package/dist/kernel/components/mdx/components/hr.cjs +0 -34
- package/dist/kernel/components/mdx/components/hr.d.cts +0 -9
- package/dist/kernel/components/mdx/components/image-zoom.cjs +0 -49
- package/dist/kernel/components/mdx/components/image-zoom.d.cts +0 -10
- package/dist/kernel/components/mdx/components/image.cjs +0 -192
- package/dist/kernel/components/mdx/components/image.d.cts +0 -21
- package/dist/kernel/components/mdx/components/inline-code.cjs +0 -66
- package/dist/kernel/components/mdx/components/inline-code.d.cts +0 -6
- package/dist/kernel/components/mdx/components/kbd.cjs +0 -34
- package/dist/kernel/components/mdx/components/kbd.d.cts +0 -10
- package/dist/kernel/components/mdx/components/link.cjs +0 -49
- package/dist/kernel/components/mdx/components/link.d.cts +0 -11
- package/dist/kernel/components/mdx/components/paragraph.cjs +0 -87
- package/dist/kernel/components/mdx/components/paragraph.d.cts +0 -5
- package/dist/kernel/components/mdx/components/pre.cjs +0 -66
- package/dist/kernel/components/mdx/components/pre.d.cts +0 -6
- package/dist/kernel/components/mdx/components/strikethrough.cjs +0 -63
- package/dist/kernel/components/mdx/components/strikethrough.d.cts +0 -6
- package/dist/kernel/components/mdx/components/table.cjs +0 -59
- package/dist/kernel/components/mdx/components/table.d.cts +0 -10
- package/dist/kernel/components/mdx/components/task-list.cjs +0 -88
- package/dist/kernel/components/mdx/components/task-list.d.cts +0 -8
- package/dist/kernel/components/mdx/components/video-player.cjs +0 -173
- package/dist/kernel/components/mdx/components/video-player.d.cts +0 -18
- package/dist/kernel/components/mdx/components/video.cjs +0 -185
- package/dist/kernel/components/mdx/components/video.d.cts +0 -15
- package/dist/kernel/components/mdx/error-boundary.cjs +0 -62
- package/dist/kernel/components/mdx/error-boundary.d.cts +0 -8
- package/dist/kernel/components/mdx/error-fallback.cjs +0 -58
- package/dist/kernel/components/mdx/error-fallback.d.cts +0 -9
- package/dist/kernel/components/mdx/mdx.cjs +0 -141
- package/dist/kernel/components/mdx/mdx.d.cts +0 -22
- package/dist/kernel/components/mdx/rehype-heading-ids.cjs +0 -113
- package/dist/kernel/components/mdx/rehype-heading-ids.d.cts +0 -10
- package/dist/kernel/components/mdx/types.cjs +0 -18
- package/dist/kernel/components/mdx/types.d.cts +0 -18
- package/dist/kernel/components/ui/accordion.cjs +0 -104
- package/dist/kernel/components/ui/accordion.d.cts +0 -16
- package/dist/kernel/components/ui/badge.cjs +0 -75
- package/dist/kernel/components/ui/badge.d.cts +0 -12
- package/dist/kernel/components/ui/badge.d.ts +0 -12
- package/dist/kernel/components/ui/badge.js +0 -47
- package/dist/kernel/components/ui/breadcrumb-trail.cjs +0 -238
- package/dist/kernel/components/ui/breadcrumb-trail.d.cts +0 -13
- package/dist/kernel/components/ui/breadcrumb.cjs +0 -399
- package/dist/kernel/components/ui/breadcrumb.d.cts +0 -52
- package/dist/kernel/components/ui/button-group.cjs +0 -144
- package/dist/kernel/components/ui/button-group.d.cts +0 -19
- package/dist/kernel/components/ui/button.cjs +0 -147
- package/dist/kernel/components/ui/button.d.cts +0 -23
- package/dist/kernel/components/ui/card.cjs +0 -133
- package/dist/kernel/components/ui/card.d.cts +0 -17
- package/dist/kernel/components/ui/dialog.cjs +0 -149
- package/dist/kernel/components/ui/dialog.d.cts +0 -22
- package/dist/kernel/components/ui/drawer.cjs +0 -163
- package/dist/kernel/components/ui/drawer.d.cts +0 -24
- package/dist/kernel/components/ui/input.cjs +0 -96
- package/dist/kernel/components/ui/input.d.cts +0 -18
- package/dist/kernel/components/ui/kbd.cjs +0 -105
- package/dist/kernel/components/ui/kbd.d.cts +0 -13
- package/dist/kernel/components/ui/link.cjs +0 -253
- package/dist/kernel/components/ui/link.d.cts +0 -31
- package/dist/kernel/components/ui/menu.cjs +0 -301
- package/dist/kernel/components/ui/menu.d.cts +0 -70
- package/dist/kernel/components/ui/meta-key.cjs +0 -34
- package/dist/kernel/components/ui/meta-key.d.cts +0 -12
- package/dist/kernel/components/ui/navigation-menu.cjs +0 -253
- package/dist/kernel/components/ui/navigation-menu.d.cts +0 -47
- package/dist/kernel/components/ui/popover.cjs +0 -168
- package/dist/kernel/components/ui/popover.d.cts +0 -24
- package/dist/kernel/components/ui/progress.cjs +0 -112
- package/dist/kernel/components/ui/progress.d.cts +0 -16
- package/dist/kernel/components/ui/scroll-area.cjs +0 -413
- package/dist/kernel/components/ui/scroll-area.d.cts +0 -58
- package/dist/kernel/components/ui/select.cjs +0 -244
- package/dist/kernel/components/ui/select.d.cts +0 -40
- package/dist/kernel/components/ui/separator.cjs +0 -73
- package/dist/kernel/components/ui/separator.d.cts +0 -8
- package/dist/kernel/components/ui/table.cjs +0 -131
- package/dist/kernel/components/ui/table.d.cts +0 -11
- package/dist/kernel/components/ui/tabs.cjs +0 -450
- package/dist/kernel/components/ui/tabs.d.cts +0 -82
- package/dist/kernel/components/ui/text.cjs +0 -184
- package/dist/kernel/components/ui/text.d.cts +0 -17
- package/dist/kernel/components/ui/theme-toggle.cjs +0 -108
- package/dist/kernel/components/ui/theme-toggle.d.cts +0 -10
- package/dist/kernel/components/ui/toast.cjs +0 -154
- package/dist/kernel/components/ui/toast.d.cts +0 -26
- package/dist/kernel/components/ui/tooltip.cjs +0 -127
- package/dist/kernel/components/ui/tooltip.d.cts +0 -20
- package/dist/kernel/defaults.registry.cjs +0 -541
- package/dist/kernel/defaults.registry.d.cts +0 -469
- package/dist/kernel/routes/agent/markdown.cjs +0 -202
- package/dist/kernel/routes/agent/markdown.d.cts +0 -58
- package/dist/kernel/routes/layouts/group.cjs +0 -181
- package/dist/kernel/routes/layouts/group.d.cts +0 -20
- package/dist/kernel/routes/metadata/feed.cjs +0 -293
- package/dist/kernel/routes/metadata/feed.d.cts +0 -20
- package/dist/kernel/routes/metadata/llms.cjs +0 -239
- package/dist/kernel/routes/metadata/llms.d.cts +0 -26
- package/dist/kernel/routes/metadata/og-image.cjs +0 -630
- package/dist/kernel/routes/metadata/og-image.d.cts +0 -62
- package/dist/kernel/routes/metadata/robots.cjs +0 -148
- package/dist/kernel/routes/metadata/robots.d.cts +0 -6
- package/dist/kernel/routes/metadata/sitemap.cjs +0 -192
- package/dist/kernel/routes/metadata/sitemap.d.cts +0 -8
- package/dist/kernel/routes/pages/group.cjs +0 -263
- package/dist/kernel/routes/pages/group.d.cts +0 -17
- package/dist/kernel/routes/pages/leaf.cjs +0 -421
- package/dist/kernel/routes/pages/leaf.d.cts +0 -36
- package/dist/kernel/routes/pages/root.cjs +0 -229
- package/dist/kernel/routes/pages/root.d.cts +0 -16
- package/dist/keyboard-shortcuts.cjs +0 -345
- package/dist/keyboard-shortcuts.d.cts +0 -34
- package/dist/resolvers/manifest-resolver.cjs +0 -111
- package/dist/resolvers/manifest-resolver.d.cts +0 -13
- package/dist/search.cjs +0 -411
- package/dist/search.d.cts +0 -20
- package/dist/types.cjs +0 -30
- package/dist/types.d.cts +0 -269
- package/dist/utils/cn.cjs +0 -49
- package/dist/utils/cn.d.cts +0 -15
- package/dist/utils/heading-ids.cjs +0 -119
- package/dist/utils/heading-ids.d.cts +0 -15
- package/dist/utils/pretty-date.cjs +0 -55
- package/dist/utils/pretty-date.d.cts +0 -6
|
@@ -1,717 +0,0 @@
|
|
|
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/kernel/components/blocks/search.tsx
|
|
32
|
-
var search_exports = {};
|
|
33
|
-
__export(search_exports, {
|
|
34
|
-
Command: () => Command,
|
|
35
|
-
DefaultDesktop: () => DefaultDesktop,
|
|
36
|
-
DefaultMobile: () => DefaultMobile,
|
|
37
|
-
Dialog: () => DialogContent,
|
|
38
|
-
Input: () => SearchInputField,
|
|
39
|
-
Progress: () => SearchProgressBar,
|
|
40
|
-
Results: () => SearchResults,
|
|
41
|
-
Root: () => Root,
|
|
42
|
-
Search: () => Search,
|
|
43
|
-
Trigger: () => Trigger
|
|
44
|
-
});
|
|
45
|
-
module.exports = __toCommonJS(search_exports);
|
|
46
|
-
var import_button = require("../ui/button.js");
|
|
47
|
-
var import_dialog = require("../ui/dialog.js");
|
|
48
|
-
var import_input = require("../ui/input.js");
|
|
49
|
-
var import_kbd = require("../ui/kbd.js");
|
|
50
|
-
var import_progress = require("../ui/progress.js");
|
|
51
|
-
var import_scroll_area = require("../ui/scroll-area.js");
|
|
52
|
-
var import_keyboard_shortcuts = require("@publish.os/nextjs/keyboard-shortcuts");
|
|
53
|
-
var import_search = require("@publish.os/nextjs/search");
|
|
54
|
-
|
|
55
|
-
// src/utils/cn.ts
|
|
56
|
-
var import_clsx = require("clsx");
|
|
57
|
-
var import_tailwind_merge = require("tailwind-merge");
|
|
58
|
-
var twMerge = (0, import_tailwind_merge.extendTailwindMerge)({
|
|
59
|
-
extend: {
|
|
60
|
-
classGroups: {
|
|
61
|
-
z: [
|
|
62
|
-
"z-content",
|
|
63
|
-
"z-nav",
|
|
64
|
-
"z-overlay",
|
|
65
|
-
"z-modal",
|
|
66
|
-
"z-search",
|
|
67
|
-
"z-toast",
|
|
68
|
-
"z-progress"
|
|
69
|
-
]
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
function cn(...inputs) {
|
|
74
|
-
return twMerge((0, import_clsx.clsx)(inputs));
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// src/kernel/components/blocks/search.tsx
|
|
78
|
-
var import_lucide_react = require("lucide-react");
|
|
79
|
-
var import_link = __toESM(require("next/link"), 1);
|
|
80
|
-
var import_react = require("react");
|
|
81
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
82
|
-
var SEARCH_ROW_HEIGHT = 58;
|
|
83
|
-
var SEARCH_ROW_WITH_DESCRIPTION_HEIGHT = 72;
|
|
84
|
-
var SEARCH_RESULTS_PADDING = 16;
|
|
85
|
-
var SEARCH_RESULTS_MAX_HEIGHT = 360;
|
|
86
|
-
var SEARCH_RESULT_SNIPPET_LENGTH = 180;
|
|
87
|
-
var searchProgressConfig = {
|
|
88
|
-
completeDelay: 100,
|
|
89
|
-
exitDuration: 150,
|
|
90
|
-
fastPhaseEnd: 25,
|
|
91
|
-
initialProgress: 5,
|
|
92
|
-
maxDuration: 5e3,
|
|
93
|
-
minDuration: 50,
|
|
94
|
-
targetProgress: 95
|
|
95
|
-
};
|
|
96
|
-
function SearchProgressBar({ className }) {
|
|
97
|
-
const {
|
|
98
|
-
state: { isTyping, loading, status }
|
|
99
|
-
} = (0, import_search.useSearchBlock)();
|
|
100
|
-
const [progress, setProgress] = (0, import_react.useState)(0);
|
|
101
|
-
const [isExiting, setIsExiting] = (0, import_react.useState)(false);
|
|
102
|
-
const animationFrame = (0, import_react.useRef)(null);
|
|
103
|
-
const cleanupTimer = (0, import_react.useRef)(null);
|
|
104
|
-
const progressRef = (0, import_react.useRef)(0);
|
|
105
|
-
const active = loading || status === "building" || status === "stale";
|
|
106
|
-
const setProgressValue = (0, import_react.useCallback)((value) => {
|
|
107
|
-
progressRef.current = value;
|
|
108
|
-
setProgress(value);
|
|
109
|
-
}, []);
|
|
110
|
-
const cleanup = (0, import_react.useCallback)(() => {
|
|
111
|
-
if (animationFrame.current !== null) {
|
|
112
|
-
window.cancelAnimationFrame(animationFrame.current);
|
|
113
|
-
animationFrame.current = null;
|
|
114
|
-
}
|
|
115
|
-
if (cleanupTimer.current) {
|
|
116
|
-
window.clearTimeout(cleanupTimer.current);
|
|
117
|
-
cleanupTimer.current = null;
|
|
118
|
-
}
|
|
119
|
-
}, []);
|
|
120
|
-
(0, import_react.useEffect)(() => {
|
|
121
|
-
if (isTyping) {
|
|
122
|
-
cleanup();
|
|
123
|
-
setProgressValue(0);
|
|
124
|
-
setIsExiting(false);
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
if (!active) {
|
|
128
|
-
if (progressRef.current > 0) {
|
|
129
|
-
cleanup();
|
|
130
|
-
setProgressValue(100);
|
|
131
|
-
cleanupTimer.current = window.setTimeout(() => {
|
|
132
|
-
setIsExiting(true);
|
|
133
|
-
cleanupTimer.current = window.setTimeout(() => {
|
|
134
|
-
setProgressValue(0);
|
|
135
|
-
setIsExiting(false);
|
|
136
|
-
cleanupTimer.current = null;
|
|
137
|
-
}, searchProgressConfig.exitDuration);
|
|
138
|
-
}, searchProgressConfig.completeDelay);
|
|
139
|
-
}
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
cleanup();
|
|
143
|
-
setIsExiting(false);
|
|
144
|
-
setProgressValue(searchProgressConfig.initialProgress);
|
|
145
|
-
const start = performance.now();
|
|
146
|
-
const animate = (now) => {
|
|
147
|
-
const elapsed = now - start;
|
|
148
|
-
let progressValue;
|
|
149
|
-
if (elapsed < searchProgressConfig.minDuration) {
|
|
150
|
-
progressValue = searchProgressConfig.initialProgress + elapsed / searchProgressConfig.minDuration * (searchProgressConfig.fastPhaseEnd - searchProgressConfig.initialProgress);
|
|
151
|
-
} else {
|
|
152
|
-
const remainingProgress = searchProgressConfig.targetProgress - searchProgressConfig.fastPhaseEnd;
|
|
153
|
-
const normalizedTime = Math.min(
|
|
154
|
-
1,
|
|
155
|
-
(elapsed - searchProgressConfig.minDuration) / (searchProgressConfig.maxDuration - searchProgressConfig.minDuration)
|
|
156
|
-
);
|
|
157
|
-
const easedTime = 1 - (1 - normalizedTime) ** 3;
|
|
158
|
-
progressValue = searchProgressConfig.fastPhaseEnd + easedTime * remainingProgress;
|
|
159
|
-
}
|
|
160
|
-
setProgressValue(
|
|
161
|
-
Math.min(searchProgressConfig.targetProgress, progressValue)
|
|
162
|
-
);
|
|
163
|
-
animationFrame.current = window.requestAnimationFrame(animate);
|
|
164
|
-
};
|
|
165
|
-
animationFrame.current = window.requestAnimationFrame(animate);
|
|
166
|
-
return cleanup;
|
|
167
|
-
}, [active, cleanup, isTyping, setProgressValue]);
|
|
168
|
-
const isVisible = progress > 0;
|
|
169
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
170
|
-
import_progress.Progress,
|
|
171
|
-
{
|
|
172
|
-
"aria-hidden": !isVisible,
|
|
173
|
-
className: cn(
|
|
174
|
-
"pointer-events-none h-[1.5px] overflow-hidden opacity-75 transition-opacity duration-300",
|
|
175
|
-
isVisible ? "opacity-100" : "opacity-0",
|
|
176
|
-
className
|
|
177
|
-
),
|
|
178
|
-
value: isVisible ? progress : null,
|
|
179
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_progress.ProgressTrack, { className: "h-full rounded-none bg-transparent", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
180
|
-
import_progress.ProgressIndicator,
|
|
181
|
-
{
|
|
182
|
-
className: "h-full w-full rounded-none bg-accent-1",
|
|
183
|
-
style: {
|
|
184
|
-
transform: isExiting ? "scaleX(0)" : `scaleX(${Math.max(0, Math.min(100, progress)) / 100})`,
|
|
185
|
-
transformOrigin: isExiting ? "right" : "left",
|
|
186
|
-
transition: isExiting ? `transform ${searchProgressConfig.exitDuration}ms cubic-bezier(.18,.66,.89,.35)` : "transform 200ms cubic-bezier(.04,.06,0,.61)"
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
) })
|
|
190
|
-
}
|
|
191
|
-
);
|
|
192
|
-
}
|
|
193
|
-
function RootDialogFrame({
|
|
194
|
-
children,
|
|
195
|
-
className
|
|
196
|
-
}) {
|
|
197
|
-
const {
|
|
198
|
-
actions: { setOpen },
|
|
199
|
-
meta: { variant },
|
|
200
|
-
state: { open }
|
|
201
|
-
} = (0, import_search.useSearchBlock)();
|
|
202
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.Dialog, { onOpenChange: setOpen, open, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className, "data-search-root": "", "data-variant": variant, children }) });
|
|
203
|
-
}
|
|
204
|
-
function Root({ children, className, ...providerProps }) {
|
|
205
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_search.SearchProvider, { ...providerProps, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RootDialogFrame, { className, children }) });
|
|
206
|
-
}
|
|
207
|
-
function Trigger({
|
|
208
|
-
asChild = false,
|
|
209
|
-
children,
|
|
210
|
-
className,
|
|
211
|
-
icon,
|
|
212
|
-
placeholder = "Search...",
|
|
213
|
-
shortcut,
|
|
214
|
-
shortcutClassName,
|
|
215
|
-
showIcon = true,
|
|
216
|
-
showShortcut = true,
|
|
217
|
-
size = "sm",
|
|
218
|
-
variant = "outline"
|
|
219
|
-
}) {
|
|
220
|
-
const {
|
|
221
|
-
meta: { inputId, shortcut: registeredShortcut },
|
|
222
|
-
state: { open }
|
|
223
|
-
} = (0, import_search.useSearchBlock)();
|
|
224
|
-
const visibleShortcut = shortcut ?? registeredShortcut;
|
|
225
|
-
const shortcutTokens = (0, import_react.useMemo)(
|
|
226
|
-
() => (0, import_keyboard_shortcuts.formatShortcut)(visibleShortcut),
|
|
227
|
-
[visibleShortcut]
|
|
228
|
-
);
|
|
229
|
-
if (asChild && children) {
|
|
230
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
231
|
-
import_dialog.DialogTrigger,
|
|
232
|
-
{
|
|
233
|
-
render: (0, import_react.cloneElement)(children, {
|
|
234
|
-
"aria-controls": inputId,
|
|
235
|
-
"aria-expanded": open,
|
|
236
|
-
className: cn(children.props.className, className)
|
|
237
|
-
})
|
|
238
|
-
}
|
|
239
|
-
);
|
|
240
|
-
}
|
|
241
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
242
|
-
import_dialog.DialogTrigger,
|
|
243
|
-
{
|
|
244
|
-
"aria-controls": inputId,
|
|
245
|
-
"aria-expanded": open,
|
|
246
|
-
"aria-label": "Open search",
|
|
247
|
-
className: cn(
|
|
248
|
-
(0, import_button.buttonVariants)({ size, variant }),
|
|
249
|
-
"justify-start gap-2 px-2.5 text-foreground-3",
|
|
250
|
-
"hover:text-foreground-1",
|
|
251
|
-
className
|
|
252
|
-
),
|
|
253
|
-
children: [
|
|
254
|
-
showIcon ? icon ?? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Search, { "aria-hidden": "true", size: 16 }) : null,
|
|
255
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "min-w-0 flex-1 truncate text-left", children: placeholder }),
|
|
256
|
-
showShortcut ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
257
|
-
"span",
|
|
258
|
-
{
|
|
259
|
-
"aria-hidden": "true",
|
|
260
|
-
className: cn(
|
|
261
|
-
"hidden shrink-0 items-center gap-1 md:inline-flex",
|
|
262
|
-
shortcutClassName
|
|
263
|
-
),
|
|
264
|
-
children: shortcutTokens.map((token) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_kbd.Kbd, { size: "xs", children: token }, token))
|
|
265
|
-
}
|
|
266
|
-
) : null
|
|
267
|
-
]
|
|
268
|
-
}
|
|
269
|
-
);
|
|
270
|
-
}
|
|
271
|
-
function DialogContent({
|
|
272
|
-
children,
|
|
273
|
-
className,
|
|
274
|
-
description = "Search this site and navigate to a result.",
|
|
275
|
-
title = "Search"
|
|
276
|
-
}) {
|
|
277
|
-
const {
|
|
278
|
-
meta: { variant }
|
|
279
|
-
} = (0, import_search.useSearchBlock)();
|
|
280
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_dialog.DialogPortal, { children: [
|
|
281
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.DialogBackdrop, { className: "bg-overlay-background backdrop-blur-[2px]" }),
|
|
282
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
283
|
-
import_dialog.DialogPopup,
|
|
284
|
-
{
|
|
285
|
-
className: cn(
|
|
286
|
-
"top-[12dvh] flex max-h-[min(42rem,82dvh)] w-[min(92vw,575px)] translate-y-0 flex-col overflow-hidden p-0 shadow-xl",
|
|
287
|
-
variant === "mobile" && "bottom-auto left-1/2 top-[8dvh] h-auto max-h-[86dvh] w-[min(94vw,575px)] max-w-none -translate-x-1/2 translate-y-0",
|
|
288
|
-
className
|
|
289
|
-
),
|
|
290
|
-
children: [
|
|
291
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.DialogTitle, { className: "sr-only", children: title }),
|
|
292
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.DialogDescription, { className: "sr-only", children: description }),
|
|
293
|
-
children
|
|
294
|
-
]
|
|
295
|
-
}
|
|
296
|
-
)
|
|
297
|
-
] });
|
|
298
|
-
}
|
|
299
|
-
function SearchInputField({
|
|
300
|
-
className,
|
|
301
|
-
closeClassName,
|
|
302
|
-
closeLabel = "ESC",
|
|
303
|
-
placeholder = "Search docs...",
|
|
304
|
-
rootClassName,
|
|
305
|
-
showCloseShortcut = true
|
|
306
|
-
}) {
|
|
307
|
-
const {
|
|
308
|
-
actions: { handleInputChange, navigateToResult, setOpen, setSelectedValue },
|
|
309
|
-
meta: { inputId, inputRef, listId },
|
|
310
|
-
state: { displayResults, query, selectedValue }
|
|
311
|
-
} = (0, import_search.useSearchBlock)();
|
|
312
|
-
const closeDisplayLabel = typeof closeLabel === "string" ? closeLabel.toUpperCase() : closeLabel;
|
|
313
|
-
const selectedIndex2 = Math.max(
|
|
314
|
-
0,
|
|
315
|
-
displayResults.findIndex((result) => result.id === selectedValue)
|
|
316
|
-
);
|
|
317
|
-
const selectedOptionId = displayResults.length > 0 ? resultOptionId(listId, selectedIndex2) : void 0;
|
|
318
|
-
const handleKeyDown = (event) => {
|
|
319
|
-
if (event.key === "Escape") {
|
|
320
|
-
event.preventDefault();
|
|
321
|
-
setOpen(false);
|
|
322
|
-
return;
|
|
323
|
-
}
|
|
324
|
-
if (event.key === "ArrowDown") {
|
|
325
|
-
event.preventDefault();
|
|
326
|
-
const next = displayResults[Math.min(selectedIndex2 + 1, displayResults.length - 1)];
|
|
327
|
-
if (next) setSelectedValue(next.id);
|
|
328
|
-
return;
|
|
329
|
-
}
|
|
330
|
-
if (event.key === "ArrowUp") {
|
|
331
|
-
event.preventDefault();
|
|
332
|
-
const next = displayResults[Math.max(selectedIndex2 - 1, 0)];
|
|
333
|
-
if (next) setSelectedValue(next.id);
|
|
334
|
-
return;
|
|
335
|
-
}
|
|
336
|
-
if (event.key === "Enter") {
|
|
337
|
-
const selected = displayResults[selectedIndex2];
|
|
338
|
-
if (!selected) return;
|
|
339
|
-
event.preventDefault();
|
|
340
|
-
navigateToResult(selected);
|
|
341
|
-
}
|
|
342
|
-
};
|
|
343
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
344
|
-
"div",
|
|
345
|
-
{
|
|
346
|
-
className: cn("relative rounded-t-[inherit] bg-surface-1", rootClassName),
|
|
347
|
-
children: [
|
|
348
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
349
|
-
import_input.Input,
|
|
350
|
-
{
|
|
351
|
-
"aria-activedescendant": selectedOptionId,
|
|
352
|
-
"aria-autocomplete": "list",
|
|
353
|
-
"aria-controls": listId,
|
|
354
|
-
"aria-expanded": displayResults.length > 0,
|
|
355
|
-
autoComplete: "off",
|
|
356
|
-
className: cn(
|
|
357
|
-
"supports-[caret-color:var(--accent-1)]:caret-(--accent-1)",
|
|
358
|
-
"h-12 rounded-none border-0 bg-transparent px-4 pr-16 text-sm shadow-none outline-none focus:border-transparent focus-visible:outline-0",
|
|
359
|
-
className
|
|
360
|
-
),
|
|
361
|
-
id: inputId,
|
|
362
|
-
onChange: (event) => handleInputChange(event.currentTarget.value),
|
|
363
|
-
onKeyDown: handleKeyDown,
|
|
364
|
-
placeholder,
|
|
365
|
-
ref: inputRef,
|
|
366
|
-
role: "combobox",
|
|
367
|
-
spellCheck: false,
|
|
368
|
-
type: "text",
|
|
369
|
-
value: query
|
|
370
|
-
}
|
|
371
|
-
),
|
|
372
|
-
showCloseShortcut ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
373
|
-
import_dialog.DialogClose,
|
|
374
|
-
{
|
|
375
|
-
"aria-label": "Close search",
|
|
376
|
-
className: cn(
|
|
377
|
-
"absolute right-3 top-1/2 size-auto -translate-y-1/2 bg-transparent p-0 text-foreground-3 hover:bg-transparent hover:text-foreground-1",
|
|
378
|
-
closeClassName
|
|
379
|
-
),
|
|
380
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_kbd.Kbd, { className: "text-foreground-2", size: "sm", children: closeDisplayLabel })
|
|
381
|
-
}
|
|
382
|
-
) : null
|
|
383
|
-
]
|
|
384
|
-
}
|
|
385
|
-
);
|
|
386
|
-
}
|
|
387
|
-
function SearchResults({
|
|
388
|
-
className,
|
|
389
|
-
emptyText = "No results found."
|
|
390
|
-
}) {
|
|
391
|
-
const {
|
|
392
|
-
actions: { navigateToResult, setOpen, setSelectedValue },
|
|
393
|
-
meta: { listId, listRef },
|
|
394
|
-
state: {
|
|
395
|
-
displayResults,
|
|
396
|
-
isTyping,
|
|
397
|
-
loading,
|
|
398
|
-
message,
|
|
399
|
-
query,
|
|
400
|
-
selectedValue,
|
|
401
|
-
status
|
|
402
|
-
}
|
|
403
|
-
} = (0, import_search.useSearchBlock)();
|
|
404
|
-
const hasQuery = query.trim().length > 0;
|
|
405
|
-
const showResults = displayResults.length > 0;
|
|
406
|
-
const statusMessage = message ?? statusLabel(status);
|
|
407
|
-
const showStatusPanel = hasQuery && !isTyping && !loading && !showResults && (status === "building" || status === "stale" || status === "error");
|
|
408
|
-
const showEmptyPanel = hasQuery && !isTyping && !loading && !showResults && !showStatusPanel && status === "ready";
|
|
409
|
-
const showPanel = showResults || showStatusPanel || showEmptyPanel;
|
|
410
|
-
const resultRowHeight = displayResults.some(
|
|
411
|
-
(result) => resultSnippet({ query, result })
|
|
412
|
-
) ? SEARCH_ROW_WITH_DESCRIPTION_HEIGHT : SEARCH_ROW_HEIGHT;
|
|
413
|
-
const fullResultsHeight = displayResults.length * resultRowHeight + SEARCH_RESULTS_PADDING;
|
|
414
|
-
const resultsAreScrollable = fullResultsHeight > SEARCH_RESULTS_MAX_HEIGHT;
|
|
415
|
-
const resultsHeight = Math.min(fullResultsHeight, SEARCH_RESULTS_MAX_HEIGHT);
|
|
416
|
-
const panelHeight = showResults ? resultsHeight : showStatusPanel || showEmptyPanel ? 144 : 0;
|
|
417
|
-
const containerDuration = showResults ? Math.min(320, 150 + displayResults.length * 18) : 180;
|
|
418
|
-
(0, import_react.useEffect)(() => {
|
|
419
|
-
if (!selectedValue || !showResults) return;
|
|
420
|
-
const frame = window.requestAnimationFrame(() => {
|
|
421
|
-
const index = selectedIndex(displayResults, selectedValue);
|
|
422
|
-
document.getElementById(resultOptionId(listId, index))?.scrollIntoView({ block: "nearest" });
|
|
423
|
-
});
|
|
424
|
-
return () => window.cancelAnimationFrame(frame);
|
|
425
|
-
}, [displayResults, listId, selectedValue, showResults]);
|
|
426
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
427
|
-
"div",
|
|
428
|
-
{
|
|
429
|
-
className: cn(
|
|
430
|
-
"relative grid rounded-b-[inherit] bg-surface-1 transition-[grid-template-rows,opacity] ease-[cubic-bezier(0.4,0,0.2,1)] before:pointer-events-none before:absolute before:inset-x-0 before:top-0 before:z-10 before:h-px before:bg-stroke-3 before:transition-opacity motion-reduce:transition-none",
|
|
431
|
-
showPanel ? "opacity-100" : "opacity-0",
|
|
432
|
-
showPanel ? "before:opacity-100" : "before:opacity-0",
|
|
433
|
-
className
|
|
434
|
-
),
|
|
435
|
-
style: {
|
|
436
|
-
gridTemplateRows: `${panelHeight}px`,
|
|
437
|
-
transitionDuration: `${containerDuration}ms`
|
|
438
|
-
},
|
|
439
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "min-h-0 overflow-hidden", children: [
|
|
440
|
-
showStatusPanel ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
441
|
-
"div",
|
|
442
|
-
{
|
|
443
|
-
"aria-live": "polite",
|
|
444
|
-
className: "flex h-full items-center justify-center px-6 py-10 text-center text-sm",
|
|
445
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "max-w-full text-foreground-2", children: statusMessage })
|
|
446
|
-
}
|
|
447
|
-
) : null,
|
|
448
|
-
showEmptyPanel ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
449
|
-
"div",
|
|
450
|
-
{
|
|
451
|
-
"aria-live": "polite",
|
|
452
|
-
className: "flex h-full items-center justify-center px-6 py-10 text-center text-sm",
|
|
453
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "max-w-full text-base text-foreground-2", children: [
|
|
454
|
-
emptyText.replace(/\.$/, ""),
|
|
455
|
-
" for",
|
|
456
|
-
" ",
|
|
457
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "inline-block max-w-full truncate align-bottom font-medium text-foreground-1", children: [
|
|
458
|
-
'"',
|
|
459
|
-
query.trim(),
|
|
460
|
-
'"'
|
|
461
|
-
] })
|
|
462
|
-
] })
|
|
463
|
-
}
|
|
464
|
-
) : null,
|
|
465
|
-
showResults ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "h-full", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
466
|
-
import_scroll_area.ScrollArea,
|
|
467
|
-
{
|
|
468
|
-
className: "h-full",
|
|
469
|
-
mask: resultsAreScrollable ? { height: 40, triggerSize: 32 } : false,
|
|
470
|
-
scrollbar: resultsAreScrollable,
|
|
471
|
-
variant: "gradient",
|
|
472
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
473
|
-
"div",
|
|
474
|
-
{
|
|
475
|
-
"aria-label": "Search results",
|
|
476
|
-
className: "p-2",
|
|
477
|
-
id: listId,
|
|
478
|
-
ref: listRef,
|
|
479
|
-
role: "listbox",
|
|
480
|
-
children: displayResults.map((result, index) => {
|
|
481
|
-
const snippet = resultSnippet({ query, result });
|
|
482
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
483
|
-
import_link.default,
|
|
484
|
-
{
|
|
485
|
-
"aria-selected": result.id === selectedValue,
|
|
486
|
-
className: cn(
|
|
487
|
-
"block min-h-[58px] min-w-0 overflow-hidden rounded-[max(calc(var(--radius-dialog)_-_0.25rem),0px)] px-3 py-2 text-left transition-colors",
|
|
488
|
-
"focus-visible:outline-2 focus-visible:outline-offset-0 focus-visible:outline-focus-ring",
|
|
489
|
-
result.id === selectedValue ? "bg-surface-active text-foreground-1" : "text-foreground-2"
|
|
490
|
-
),
|
|
491
|
-
href: result.url,
|
|
492
|
-
id: resultOptionId(listId, index),
|
|
493
|
-
onClick: () => setOpen(false),
|
|
494
|
-
onKeyDown: (event) => {
|
|
495
|
-
if (event.key !== "Enter") return;
|
|
496
|
-
event.preventDefault();
|
|
497
|
-
navigateToResult(result);
|
|
498
|
-
},
|
|
499
|
-
onMouseEnter: () => setSelectedValue(result.id),
|
|
500
|
-
onMouseMove: () => setSelectedValue(result.id),
|
|
501
|
-
role: "option",
|
|
502
|
-
children: [
|
|
503
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "block truncate break-all text-xs leading-4 text-foreground-3", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
504
|
-
HighlightedText,
|
|
505
|
-
{
|
|
506
|
-
text: resultSubtitle(result),
|
|
507
|
-
query
|
|
508
|
-
}
|
|
509
|
-
) }),
|
|
510
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "line-clamp-1 break-all text-sm font-medium", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(HighlightedText, { text: result.title, query }) }),
|
|
511
|
-
snippet ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "mt-1 line-clamp-2 break-words text-xs leading-4 text-foreground-3", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(HighlightedText, { text: snippet, query }) }) : null
|
|
512
|
-
]
|
|
513
|
-
},
|
|
514
|
-
result.id
|
|
515
|
-
);
|
|
516
|
-
})
|
|
517
|
-
}
|
|
518
|
-
)
|
|
519
|
-
}
|
|
520
|
-
) }) : null
|
|
521
|
-
] })
|
|
522
|
-
}
|
|
523
|
-
);
|
|
524
|
-
}
|
|
525
|
-
function statusLabel(status) {
|
|
526
|
-
if (status === "building") return "Building search index...";
|
|
527
|
-
if (status === "stale") return "Updating search index...";
|
|
528
|
-
if (status === "error") return "Search is temporarily unavailable";
|
|
529
|
-
return "Searching...";
|
|
530
|
-
}
|
|
531
|
-
function resultOptionId(listId, index) {
|
|
532
|
-
return `${listId}-result-${index}`;
|
|
533
|
-
}
|
|
534
|
-
function selectedIndex(results, selectedValue) {
|
|
535
|
-
return Math.max(
|
|
536
|
-
0,
|
|
537
|
-
results.findIndex((result) => result.id === selectedValue)
|
|
538
|
-
);
|
|
539
|
-
}
|
|
540
|
-
function cleanResultPath(url) {
|
|
541
|
-
const path = url.split("#")[0]?.replace(/^\/+|\/+$/g, "") ?? "";
|
|
542
|
-
return path || "/";
|
|
543
|
-
}
|
|
544
|
-
function resultSubtitle(result) {
|
|
545
|
-
const section = result.meta.section ?? result.meta.group;
|
|
546
|
-
const path = cleanResultPath(result.meta.path ?? result.url);
|
|
547
|
-
if (section && path && !path.startsWith(section)) {
|
|
548
|
-
return `${section} / ${path}`;
|
|
549
|
-
}
|
|
550
|
-
return path || section || result.url;
|
|
551
|
-
}
|
|
552
|
-
function normalizedSnippetText(text) {
|
|
553
|
-
return (text ?? "").replace(/\s+/g, " ").trim();
|
|
554
|
-
}
|
|
555
|
-
function queryMatches(text, query) {
|
|
556
|
-
const normalizedQuery = query.trim().toLowerCase();
|
|
557
|
-
if (!normalizedQuery) return false;
|
|
558
|
-
const lower = text.toLowerCase();
|
|
559
|
-
if (lower.includes(normalizedQuery)) return true;
|
|
560
|
-
return normalizedQuery.split(/\s+/).filter((term) => term.length > 1).some((term) => lower.includes(term));
|
|
561
|
-
}
|
|
562
|
-
function firstMatchIndex(text, query) {
|
|
563
|
-
const normalizedQuery = query.trim().toLowerCase();
|
|
564
|
-
if (!normalizedQuery) return -1;
|
|
565
|
-
const lower = text.toLowerCase();
|
|
566
|
-
const phraseIndex = lower.indexOf(normalizedQuery);
|
|
567
|
-
if (phraseIndex >= 0) return phraseIndex;
|
|
568
|
-
return normalizedQuery.split(/\s+/).filter((term) => term.length > 1).map((term) => lower.indexOf(term)).filter((index) => index >= 0).sort((left, right) => left - right)[0] ?? -1;
|
|
569
|
-
}
|
|
570
|
-
function contextualSnippet({
|
|
571
|
-
length = SEARCH_RESULT_SNIPPET_LENGTH,
|
|
572
|
-
query,
|
|
573
|
-
text
|
|
574
|
-
}) {
|
|
575
|
-
const normalizedText = normalizedSnippetText(text);
|
|
576
|
-
if (normalizedText.length <= length) return normalizedText;
|
|
577
|
-
const matchIndex = firstMatchIndex(normalizedText, query);
|
|
578
|
-
if (matchIndex < 0) return `${normalizedText.slice(0, length).trimEnd()}...`;
|
|
579
|
-
const halfLength = Math.floor(length / 2);
|
|
580
|
-
let start = Math.max(0, matchIndex - halfLength);
|
|
581
|
-
let end = Math.min(normalizedText.length, start + length);
|
|
582
|
-
if (end - start < length) {
|
|
583
|
-
start = Math.max(0, end - length);
|
|
584
|
-
}
|
|
585
|
-
if (start > 0) {
|
|
586
|
-
const nextSpace = normalizedText.indexOf(" ", start);
|
|
587
|
-
if (nextSpace > start && nextSpace < matchIndex) {
|
|
588
|
-
start = nextSpace + 1;
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
if (end < normalizedText.length) {
|
|
592
|
-
const previousSpace = normalizedText.lastIndexOf(" ", end);
|
|
593
|
-
if (previousSpace > matchIndex) {
|
|
594
|
-
end = previousSpace;
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
const prefix = start > 0 ? "... " : "";
|
|
598
|
-
const suffix = end < normalizedText.length ? " ..." : "";
|
|
599
|
-
return `${prefix}${normalizedText.slice(start, end).trim()}${suffix}`;
|
|
600
|
-
}
|
|
601
|
-
function resultSnippet({
|
|
602
|
-
query,
|
|
603
|
-
result
|
|
604
|
-
}) {
|
|
605
|
-
const description = normalizedSnippetText(result.meta.description);
|
|
606
|
-
if (description && queryMatches(description, query)) {
|
|
607
|
-
return contextualSnippet({ query, text: description });
|
|
608
|
-
}
|
|
609
|
-
const excerpt = normalizedSnippetText(result.plainExcerpt);
|
|
610
|
-
if (excerpt) {
|
|
611
|
-
return contextualSnippet({ query, text: excerpt });
|
|
612
|
-
}
|
|
613
|
-
return description ? contextualSnippet({ query, text: description }) : "";
|
|
614
|
-
}
|
|
615
|
-
function HighlightedText({ query, text }) {
|
|
616
|
-
const normalizedQuery = query.trim().toLowerCase();
|
|
617
|
-
if (!normalizedQuery) return text;
|
|
618
|
-
const lower = text.toLowerCase();
|
|
619
|
-
const phraseStart = lower.indexOf(normalizedQuery);
|
|
620
|
-
const terms = phraseStart >= 0 ? [normalizedQuery] : normalizedQuery.split(/\s+/).filter((term) => term.length > 1);
|
|
621
|
-
if (terms.length === 0) return text;
|
|
622
|
-
const ranges = terms.flatMap((term) => {
|
|
623
|
-
const termRanges = [];
|
|
624
|
-
let start = lower.indexOf(term);
|
|
625
|
-
while (start >= 0) {
|
|
626
|
-
termRanges.push({ end: start + term.length, start });
|
|
627
|
-
start = lower.indexOf(term, start + term.length);
|
|
628
|
-
}
|
|
629
|
-
return termRanges;
|
|
630
|
-
}).sort((left, right) => left.start - right.start);
|
|
631
|
-
const mergedRanges = [];
|
|
632
|
-
for (const range of ranges) {
|
|
633
|
-
const previous = mergedRanges.at(-1);
|
|
634
|
-
if (previous && range.start <= previous.end) {
|
|
635
|
-
previous.end = Math.max(previous.end, range.end);
|
|
636
|
-
} else {
|
|
637
|
-
mergedRanges.push({ ...range });
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
if (mergedRanges.length === 0) return text;
|
|
641
|
-
const parts = [];
|
|
642
|
-
let cursor = 0;
|
|
643
|
-
for (const range of mergedRanges) {
|
|
644
|
-
if (range.start > cursor) {
|
|
645
|
-
parts.push(text.slice(cursor, range.start));
|
|
646
|
-
}
|
|
647
|
-
parts.push(
|
|
648
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
649
|
-
"mark",
|
|
650
|
-
{
|
|
651
|
-
className: "rounded-[1px] bg-accent-soft text-accent-1",
|
|
652
|
-
children: text.slice(range.start, range.end)
|
|
653
|
-
},
|
|
654
|
-
`${range.start}-${range.end}`
|
|
655
|
-
)
|
|
656
|
-
);
|
|
657
|
-
cursor = range.end;
|
|
658
|
-
}
|
|
659
|
-
if (cursor < text.length) {
|
|
660
|
-
parts.push(text.slice(cursor));
|
|
661
|
-
}
|
|
662
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: parts });
|
|
663
|
-
}
|
|
664
|
-
function Command({ children, className } = {}) {
|
|
665
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
666
|
-
"div",
|
|
667
|
-
{
|
|
668
|
-
className: cn(
|
|
669
|
-
"relative overflow-hidden rounded-dialog bg-surface-1 text-foreground-1",
|
|
670
|
-
className
|
|
671
|
-
),
|
|
672
|
-
children: children ?? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
673
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SearchInputField, {}),
|
|
674
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SearchProgressBar, { className: "absolute inset-x-0 top-12 z-10" }),
|
|
675
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SearchResults, {})
|
|
676
|
-
] })
|
|
677
|
-
}
|
|
678
|
-
);
|
|
679
|
-
}
|
|
680
|
-
function DefaultDesktop({ children, ...rootProps }) {
|
|
681
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Root, { variant: "desktop", ...rootProps, children: children ?? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
682
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trigger, {}),
|
|
683
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogContent, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Command, {}) })
|
|
684
|
-
] }) });
|
|
685
|
-
}
|
|
686
|
-
function DefaultMobile({ children, ...rootProps }) {
|
|
687
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Root, { variant: "mobile", ...rootProps, children: children ?? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
688
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trigger, { showShortcut: false }),
|
|
689
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogContent, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Command, {}) })
|
|
690
|
-
] }) });
|
|
691
|
-
}
|
|
692
|
-
var Search = {
|
|
693
|
-
Command,
|
|
694
|
-
DefaultDesktop,
|
|
695
|
-
DefaultMobile,
|
|
696
|
-
DesktopDialog: DialogContent,
|
|
697
|
-
Dialog: DialogContent,
|
|
698
|
-
Input: SearchInputField,
|
|
699
|
-
MobileDialog: DialogContent,
|
|
700
|
-
Progress: SearchProgressBar,
|
|
701
|
-
Results: SearchResults,
|
|
702
|
-
Root,
|
|
703
|
-
Trigger
|
|
704
|
-
};
|
|
705
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
706
|
-
0 && (module.exports = {
|
|
707
|
-
Command,
|
|
708
|
-
DefaultDesktop,
|
|
709
|
-
DefaultMobile,
|
|
710
|
-
Dialog,
|
|
711
|
-
Input,
|
|
712
|
-
Progress,
|
|
713
|
-
Results,
|
|
714
|
-
Root,
|
|
715
|
-
Search,
|
|
716
|
-
Trigger
|
|
717
|
-
});
|