@btst/stack 1.0.1 → 1.1.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 +156 -709
- package/dist/api/index.cjs +2 -1
- package/dist/api/index.d.cts +4 -3
- package/dist/api/index.d.mts +4 -3
- package/dist/api/index.d.ts +4 -3
- package/dist/api/index.mjs +1 -1
- package/dist/client/components/compose.cjs +68 -0
- package/dist/client/components/compose.mjs +65 -0
- package/dist/client/components/error-boundary.cjs +24 -0
- package/dist/client/components/error-boundary.mjs +22 -0
- package/dist/client/components/index.cjs +10 -0
- package/dist/client/components/index.d.cts +52 -0
- package/dist/client/components/index.d.mts +52 -0
- package/dist/client/components/index.d.ts +52 -0
- package/dist/client/components/index.mjs +2 -0
- package/dist/client/index.cjs +24 -5
- package/dist/client/index.d.cts +125 -8
- package/dist/client/index.d.mts +125 -8
- package/dist/client/index.d.ts +125 -8
- package/dist/client/index.mjs +21 -4
- package/dist/client/meta-utils.cjs +162 -0
- package/dist/client/meta-utils.mjs +160 -0
- package/dist/client/path-utils.cjs +15 -0
- package/dist/client/path-utils.mjs +13 -0
- package/dist/client/sitemap-utils.cjs +14 -0
- package/dist/client/sitemap-utils.mjs +12 -0
- package/dist/context/index.cjs +6 -63
- package/dist/context/index.d.cts +21 -24
- package/dist/context/index.d.mts +21 -24
- package/dist/context/index.d.ts +21 -24
- package/dist/context/index.mjs +1 -61
- package/dist/context/provider.cjs +51 -0
- package/dist/context/provider.mjs +46 -0
- package/dist/index.cjs +2 -3
- package/dist/index.d.cts +3 -2
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.mjs +1 -2
- package/dist/plugins/api/index.cjs +13 -0
- package/dist/plugins/api/index.d.cts +40 -0
- package/dist/plugins/api/index.d.mts +40 -0
- package/dist/plugins/api/index.d.ts +40 -0
- package/dist/plugins/api/index.mjs +8 -0
- package/dist/plugins/blog/api/index.cjs +11 -0
- package/dist/plugins/blog/api/index.d.cts +7 -0
- package/dist/plugins/blog/api/index.d.mts +7 -0
- package/dist/plugins/blog/api/index.d.ts +7 -0
- package/dist/plugins/blog/api/index.mjs +2 -0
- package/dist/plugins/blog/api/plugin.cjs +569 -0
- package/dist/plugins/blog/api/plugin.mjs +565 -0
- package/dist/plugins/blog/client/components/forms/image-field.cjs +133 -0
- package/dist/plugins/blog/client/components/forms/image-field.mjs +131 -0
- package/dist/plugins/blog/client/components/forms/markdown-editor-styles.css +30 -0
- package/dist/plugins/blog/client/components/forms/markdown-editor.cjs +106 -0
- package/dist/plugins/blog/client/components/forms/markdown-editor.mjs +104 -0
- package/dist/plugins/blog/client/components/forms/post-forms.cjs +401 -0
- package/dist/plugins/blog/client/components/forms/post-forms.mjs +398 -0
- package/dist/plugins/blog/client/components/forms/tags-multiselect.cjs +71 -0
- package/dist/plugins/blog/client/components/forms/tags-multiselect.mjs +65 -0
- package/dist/plugins/blog/client/components/index.cjs +17 -0
- package/dist/plugins/blog/client/components/index.d.cts +22 -0
- package/dist/plugins/blog/client/components/index.d.mts +22 -0
- package/dist/plugins/blog/client/components/index.d.ts +22 -0
- package/dist/plugins/blog/client/components/index.mjs +12 -0
- package/dist/plugins/blog/client/components/loading/form-page-skeleton.cjs +62 -0
- package/dist/plugins/blog/client/components/loading/form-page-skeleton.mjs +60 -0
- package/dist/plugins/blog/client/components/loading/index.cjs +20 -0
- package/dist/plugins/blog/client/components/loading/index.mjs +16 -0
- package/dist/plugins/blog/client/components/loading/list-page-skeleton.cjs +26 -0
- package/dist/plugins/blog/client/components/loading/list-page-skeleton.mjs +24 -0
- package/dist/plugins/blog/client/components/loading/page-header-skeleton.cjs +13 -0
- package/dist/plugins/blog/client/components/loading/page-header-skeleton.mjs +11 -0
- package/dist/plugins/blog/client/components/loading/post-card-skeleton.cjs +22 -0
- package/dist/plugins/blog/client/components/loading/post-card-skeleton.mjs +20 -0
- package/dist/plugins/blog/client/components/loading/post-page-skeleton.cjs +56 -0
- package/dist/plugins/blog/client/components/loading/post-page-skeleton.mjs +54 -0
- package/dist/plugins/blog/client/components/pages/404-page.cjs +19 -0
- package/dist/plugins/blog/client/components/pages/404-page.mjs +17 -0
- package/dist/plugins/blog/client/components/pages/edit-post-page.cjs +41 -0
- package/dist/plugins/blog/client/components/pages/edit-post-page.internal.cjs +57 -0
- package/dist/plugins/blog/client/components/pages/edit-post-page.internal.mjs +55 -0
- package/dist/plugins/blog/client/components/pages/edit-post-page.mjs +39 -0
- package/dist/plugins/blog/client/components/pages/home-page.cjs +41 -0
- package/dist/plugins/blog/client/components/pages/home-page.internal.cjs +61 -0
- package/dist/plugins/blog/client/components/pages/home-page.internal.mjs +59 -0
- package/dist/plugins/blog/client/components/pages/home-page.mjs +39 -0
- package/dist/plugins/blog/client/components/pages/new-post-page.cjs +37 -0
- package/dist/plugins/blog/client/components/pages/new-post-page.internal.cjs +53 -0
- package/dist/plugins/blog/client/components/pages/new-post-page.internal.mjs +51 -0
- package/dist/plugins/blog/client/components/pages/new-post-page.mjs +35 -0
- package/dist/plugins/blog/client/components/pages/post-page.cjs +39 -0
- package/dist/plugins/blog/client/components/pages/post-page.internal.cjs +101 -0
- package/dist/plugins/blog/client/components/pages/post-page.internal.mjs +99 -0
- package/dist/plugins/blog/client/components/pages/post-page.mjs +37 -0
- package/dist/plugins/blog/client/components/pages/tag-page.cjs +39 -0
- package/dist/plugins/blog/client/components/pages/tag-page.internal.cjs +61 -0
- package/dist/plugins/blog/client/components/pages/tag-page.internal.mjs +59 -0
- package/dist/plugins/blog/client/components/pages/tag-page.mjs +37 -0
- package/dist/plugins/blog/client/components/shared/better-blog-attribution.cjs +24 -0
- package/dist/plugins/blog/client/components/shared/better-blog-attribution.mjs +22 -0
- package/dist/plugins/blog/client/components/shared/default-error.cjs +18 -0
- package/dist/plugins/blog/client/components/shared/default-error.mjs +16 -0
- package/dist/plugins/blog/client/components/shared/defaults.cjs +13 -0
- package/dist/plugins/blog/client/components/shared/defaults.mjs +10 -0
- package/dist/plugins/blog/client/components/shared/empty-list.cjs +21 -0
- package/dist/plugins/blog/client/components/shared/empty-list.mjs +19 -0
- package/dist/plugins/blog/client/components/shared/error-placeholder.cjs +24 -0
- package/dist/plugins/blog/client/components/shared/error-placeholder.mjs +22 -0
- package/dist/plugins/blog/client/components/shared/highlight-text.cjs +53 -0
- package/dist/plugins/blog/client/components/shared/highlight-text.mjs +51 -0
- package/dist/plugins/blog/client/components/shared/markdown-content-styles.css +328 -0
- package/dist/plugins/blog/client/components/shared/markdown-content.cjs +324 -0
- package/dist/plugins/blog/client/components/shared/markdown-content.mjs +315 -0
- package/dist/plugins/blog/client/components/shared/on-this-page.cjs +161 -0
- package/dist/plugins/blog/client/components/shared/on-this-page.mjs +158 -0
- package/dist/plugins/blog/client/components/shared/page-header.cjs +40 -0
- package/dist/plugins/blog/client/components/shared/page-header.mjs +38 -0
- package/dist/plugins/blog/client/components/shared/page-layout.cjs +24 -0
- package/dist/plugins/blog/client/components/shared/page-layout.mjs +22 -0
- package/dist/plugins/blog/client/components/shared/page-wrapper.cjs +23 -0
- package/dist/plugins/blog/client/components/shared/page-wrapper.mjs +21 -0
- package/dist/plugins/blog/client/components/shared/post-card.cjs +279 -0
- package/dist/plugins/blog/client/components/shared/post-card.mjs +277 -0
- package/dist/plugins/blog/client/components/shared/post-navigation.cjs +74 -0
- package/dist/plugins/blog/client/components/shared/post-navigation.mjs +72 -0
- package/dist/plugins/blog/client/components/shared/posts-list.cjs +48 -0
- package/dist/plugins/blog/client/components/shared/posts-list.mjs +46 -0
- package/dist/plugins/blog/client/components/shared/recent-posts-carousel.cjs +59 -0
- package/dist/plugins/blog/client/components/shared/recent-posts-carousel.mjs +57 -0
- package/dist/plugins/blog/client/components/shared/search-input.cjs +136 -0
- package/dist/plugins/blog/client/components/shared/search-input.mjs +117 -0
- package/dist/plugins/blog/client/components/shared/search-modal.cjs +135 -0
- package/dist/plugins/blog/client/components/shared/search-modal.mjs +116 -0
- package/dist/plugins/blog/client/components/shared/tags-list.cjs +22 -0
- package/dist/plugins/blog/client/components/shared/tags-list.mjs +20 -0
- package/dist/plugins/blog/client/components/shared/use-route-lifecycle.cjs +50 -0
- package/dist/plugins/blog/client/components/shared/use-route-lifecycle.mjs +48 -0
- package/dist/plugins/blog/client/hooks/blog-hooks.cjs +380 -0
- package/dist/plugins/blog/client/hooks/blog-hooks.mjs +368 -0
- package/dist/plugins/blog/client/hooks/index.cjs +17 -0
- package/dist/plugins/blog/client/hooks/index.d.cts +150 -0
- package/dist/plugins/blog/client/hooks/index.d.mts +150 -0
- package/dist/plugins/blog/client/hooks/index.d.ts +150 -0
- package/dist/plugins/blog/client/hooks/index.mjs +1 -0
- package/dist/plugins/blog/client/hooks/use-debounce.cjs +16 -0
- package/dist/plugins/blog/client/hooks/use-debounce.mjs +14 -0
- package/dist/plugins/blog/client/index.cjs +7 -0
- package/dist/plugins/blog/client/index.d.cts +414 -0
- package/dist/plugins/blog/client/index.d.mts +414 -0
- package/dist/plugins/blog/client/index.d.ts +414 -0
- package/dist/plugins/blog/client/index.mjs +1 -0
- package/dist/plugins/blog/client/localization/blog-card.cjs +7 -0
- package/dist/plugins/blog/client/localization/blog-card.mjs +5 -0
- package/dist/plugins/blog/client/localization/blog-common.cjs +10 -0
- package/dist/plugins/blog/client/localization/blog-common.mjs +8 -0
- package/dist/plugins/blog/client/localization/blog-forms.cjs +40 -0
- package/dist/plugins/blog/client/localization/blog-forms.mjs +38 -0
- package/dist/plugins/blog/client/localization/blog-list.cjs +18 -0
- package/dist/plugins/blog/client/localization/blog-list.mjs +16 -0
- package/dist/plugins/blog/client/localization/blog-post.cjs +13 -0
- package/dist/plugins/blog/client/localization/blog-post.mjs +11 -0
- package/dist/plugins/blog/client/localization/index.cjs +17 -0
- package/dist/plugins/blog/client/localization/index.mjs +15 -0
- package/dist/plugins/blog/client/plugin.cjs +462 -0
- package/dist/plugins/blog/client/plugin.mjs +460 -0
- package/dist/plugins/blog/client.css +3 -0
- package/dist/plugins/blog/db.cjs +90 -0
- package/dist/plugins/blog/db.mjs +88 -0
- package/dist/plugins/blog/query-keys.cjs +181 -0
- package/dist/plugins/blog/query-keys.d.cts +530 -0
- package/dist/plugins/blog/query-keys.d.mts +530 -0
- package/dist/plugins/blog/query-keys.d.ts +530 -0
- package/dist/plugins/blog/query-keys.mjs +179 -0
- package/dist/plugins/blog/schemas.cjs +39 -0
- package/dist/plugins/blog/schemas.mjs +35 -0
- package/dist/plugins/blog/style.css +22 -0
- package/dist/plugins/blog/utils.cjs +97 -0
- package/dist/plugins/blog/utils.mjs +87 -0
- package/dist/plugins/client/index.cjs +15 -0
- package/dist/plugins/client/index.d.cts +57 -0
- package/dist/plugins/client/index.d.mts +57 -0
- package/dist/plugins/client/index.d.ts +57 -0
- package/dist/plugins/client/index.mjs +9 -0
- package/dist/{shared/stack.3OUyGp_E.mjs → plugins/utils.mjs} +1 -1
- package/dist/shared/{stack.DORw_1ps.d.cts → stack.ByOugz9d.d.cts} +17 -1
- package/dist/shared/{stack.DORw_1ps.d.mts → stack.ByOugz9d.d.mts} +17 -1
- package/dist/shared/{stack.DORw_1ps.d.ts → stack.ByOugz9d.d.ts} +17 -1
- package/dist/shared/stack.CoPoHVfV.d.cts +76 -0
- package/dist/shared/stack.CoPoHVfV.d.mts +76 -0
- package/dist/shared/stack.CoPoHVfV.d.ts +76 -0
- package/package.json +102 -14
- package/src/__tests__/plugins.test.tsx +539 -0
- package/src/__tests__/sitemap.test.ts +60 -0
- package/src/api/index.ts +75 -0
- package/src/client/components/compose.tsx +116 -0
- package/src/client/components/error-boundary.tsx +30 -0
- package/src/client/components/index.tsx +2 -0
- package/src/client/index.ts +109 -0
- package/src/client/meta-utils.ts +228 -0
- package/src/client/path-utils.ts +38 -0
- package/src/client/sitemap-utils.ts +46 -0
- package/src/context/index.ts +1 -0
- package/src/context/provider.tsx +157 -0
- package/src/index.ts +1 -0
- package/src/plugins/api/index.ts +50 -0
- package/src/plugins/blog/api/index.ts +2 -0
- package/src/plugins/blog/api/plugin.ts +759 -0
- package/src/plugins/blog/client/components/forms/image-field.tsx +165 -0
- package/src/plugins/blog/client/components/forms/markdown-editor-styles.css +30 -0
- package/src/plugins/blog/client/components/forms/markdown-editor.tsx +136 -0
- package/src/plugins/blog/client/components/forms/post-forms.tsx +531 -0
- package/src/plugins/blog/client/components/forms/tags-multiselect.tsx +79 -0
- package/src/plugins/blog/client/components/index.tsx +11 -0
- package/src/plugins/blog/client/components/loading/form-page-skeleton.tsx +75 -0
- package/src/plugins/blog/client/components/loading/index.tsx +27 -0
- package/src/plugins/blog/client/components/loading/list-page-skeleton.tsx +38 -0
- package/src/plugins/blog/client/components/loading/page-header-skeleton.tsx +10 -0
- package/src/plugins/blog/client/components/loading/post-card-skeleton.tsx +30 -0
- package/src/plugins/blog/client/components/loading/post-page-skeleton.tsx +75 -0
- package/src/plugins/blog/client/components/pages/404-page.tsx +23 -0
- package/src/plugins/blog/client/components/pages/edit-post-page.internal.tsx +60 -0
- package/src/plugins/blog/client/components/pages/edit-post-page.tsx +40 -0
- package/src/plugins/blog/client/components/pages/home-page.internal.tsx +71 -0
- package/src/plugins/blog/client/components/pages/home-page.tsx +42 -0
- package/src/plugins/blog/client/components/pages/new-post-page.internal.tsx +59 -0
- package/src/plugins/blog/client/components/pages/new-post-page.tsx +36 -0
- package/src/plugins/blog/client/components/pages/post-page.internal.tsx +142 -0
- package/src/plugins/blog/client/components/pages/post-page.tsx +38 -0
- package/src/plugins/blog/client/components/pages/tag-page.internal.tsx +74 -0
- package/src/plugins/blog/client/components/pages/tag-page.tsx +38 -0
- package/src/plugins/blog/client/components/shared/better-blog-attribution.tsx +19 -0
- package/src/plugins/blog/client/components/shared/default-error.tsx +20 -0
- package/src/plugins/blog/client/components/shared/defaults.tsx +9 -0
- package/src/plugins/blog/client/components/shared/empty-list.tsx +25 -0
- package/src/plugins/blog/client/components/shared/error-placeholder.tsx +20 -0
- package/src/plugins/blog/client/components/shared/highlight-text.tsx +80 -0
- package/src/plugins/blog/client/components/shared/markdown-content-styles.css +328 -0
- package/src/plugins/blog/client/components/shared/markdown-content.tsx +448 -0
- package/src/plugins/blog/client/components/shared/on-this-page.tsx +234 -0
- package/src/plugins/blog/client/components/shared/page-header.tsx +35 -0
- package/src/plugins/blog/client/components/shared/page-layout.tsx +23 -0
- package/src/plugins/blog/client/components/shared/page-wrapper.tsx +32 -0
- package/src/plugins/blog/client/components/shared/post-card.tsx +308 -0
- package/src/plugins/blog/client/components/shared/post-navigation.tsx +98 -0
- package/src/plugins/blog/client/components/shared/posts-list.tsx +67 -0
- package/src/plugins/blog/client/components/shared/recent-posts-carousel.tsx +79 -0
- package/src/plugins/blog/client/components/shared/search-input.tsx +146 -0
- package/src/plugins/blog/client/components/shared/search-modal.tsx +162 -0
- package/src/plugins/blog/client/components/shared/tags-list.tsx +34 -0
- package/src/plugins/blog/client/components/shared/use-route-lifecycle.tsx +68 -0
- package/src/plugins/blog/client/hooks/blog-hooks.tsx +623 -0
- package/src/plugins/blog/client/hooks/index.tsx +1 -0
- package/src/plugins/blog/client/hooks/use-debounce.ts +43 -0
- package/src/plugins/blog/client/index.ts +9 -0
- package/src/plugins/blog/client/localization/blog-card.ts +3 -0
- package/src/plugins/blog/client/localization/blog-common.ts +7 -0
- package/src/plugins/blog/client/localization/blog-forms.ts +45 -0
- package/src/plugins/blog/client/localization/blog-list.ts +14 -0
- package/src/plugins/blog/client/localization/blog-post.ts +9 -0
- package/src/plugins/blog/client/localization/index.ts +15 -0
- package/src/plugins/blog/client/overrides.ts +123 -0
- package/src/plugins/blog/client/plugin.tsx +672 -0
- package/src/plugins/blog/client.css +3 -0
- package/src/plugins/blog/db.ts +90 -0
- package/src/plugins/blog/query-keys.ts +267 -0
- package/src/plugins/blog/schemas.ts +39 -0
- package/src/plugins/blog/style.css +22 -0
- package/src/plugins/blog/types.ts +37 -0
- package/src/plugins/blog/utils.ts +144 -0
- package/src/plugins/client/index.ts +53 -0
- package/src/plugins/index.ts +0 -0
- package/src/plugins/utils.ts +35 -0
- package/src/types.ts +209 -0
- package/dist/plugins/index.cjs +0 -15
- package/dist/plugins/index.d.cts +0 -64
- package/dist/plugins/index.d.mts +0 -64
- package/dist/plugins/index.d.ts +0 -64
- package/dist/plugins/index.mjs +0 -11
- package/dist/shared/stack.DrUAVfIH.d.cts +0 -17
- package/dist/shared/stack.DrUAVfIH.d.mts +0 -17
- package/dist/shared/stack.DrUAVfIH.d.ts +0 -17
- /package/dist/{shared/stack.CktCg4PJ.cjs → plugins/utils.cjs} +0 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
const lucideReact = require('lucide-react');
|
|
8
|
+
const React = require('react');
|
|
9
|
+
const useDebounce = require('../../hooks/use-debounce.cjs');
|
|
10
|
+
const command = require('@workspace/ui/components/command');
|
|
11
|
+
|
|
12
|
+
function _interopNamespaceCompat(e) {
|
|
13
|
+
if (e && typeof e === 'object' && 'default' in e) return e;
|
|
14
|
+
const n = Object.create(null);
|
|
15
|
+
if (e) {
|
|
16
|
+
for (const k in e) {
|
|
17
|
+
n[k] = e[k];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
n.default = e;
|
|
21
|
+
return n;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const React__namespace = /*#__PURE__*/_interopNamespaceCompat(React);
|
|
25
|
+
|
|
26
|
+
function SearchModal({
|
|
27
|
+
placeholder = "Type to search...",
|
|
28
|
+
emptyMessage = "No results found.",
|
|
29
|
+
buttonText = "Search",
|
|
30
|
+
keyboardShortcut = "\u2318K",
|
|
31
|
+
searchFn,
|
|
32
|
+
renderResult,
|
|
33
|
+
results: externalResults,
|
|
34
|
+
isLoading = false,
|
|
35
|
+
className,
|
|
36
|
+
triggerClassName
|
|
37
|
+
}) {
|
|
38
|
+
const [open, setOpen] = React__namespace.useState(false);
|
|
39
|
+
const [query, setQuery] = React__namespace.useState("");
|
|
40
|
+
const [results, setResults] = React__namespace.useState([]);
|
|
41
|
+
const shouldDebounce = externalResults === void 0;
|
|
42
|
+
const debouncedQuery = useDebounce.useDebounce(query, shouldDebounce ? 300 : 0);
|
|
43
|
+
React__namespace.useEffect(() => {
|
|
44
|
+
const down = (e) => {
|
|
45
|
+
const cleanShortcut = keyboardShortcut.replace("\u2318", "").replace("\u21E7", "").toLowerCase();
|
|
46
|
+
if (e.key === cleanShortcut && (e.metaKey || e.ctrlKey)) {
|
|
47
|
+
e.preventDefault();
|
|
48
|
+
setOpen((open2) => !open2);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
document.addEventListener("keydown", down);
|
|
52
|
+
return () => document.removeEventListener("keydown", down);
|
|
53
|
+
}, [keyboardShortcut]);
|
|
54
|
+
React__namespace.useEffect(() => {
|
|
55
|
+
if (!open) {
|
|
56
|
+
setQuery("");
|
|
57
|
+
setResults([]);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
}, [open]);
|
|
61
|
+
React__namespace.useEffect(() => {
|
|
62
|
+
if (!open) return;
|
|
63
|
+
const searchResults = searchFn(debouncedQuery);
|
|
64
|
+
if (externalResults !== void 0) {
|
|
65
|
+
setResults(externalResults);
|
|
66
|
+
} else {
|
|
67
|
+
setResults(searchResults);
|
|
68
|
+
}
|
|
69
|
+
}, [debouncedQuery, open, searchFn, externalResults]);
|
|
70
|
+
const buttonClasses = [
|
|
71
|
+
"border-input bg-background text-foreground",
|
|
72
|
+
"placeholder:text-muted-foreground",
|
|
73
|
+
"focus-visible:border-ring focus-visible:ring-ring/50",
|
|
74
|
+
"inline-flex h-9 w-fit rounded-md border px-3 py-2 text-sm",
|
|
75
|
+
"shadow-xs transition-[color,box-shadow] outline-none",
|
|
76
|
+
"focus-visible:ring-[3px]",
|
|
77
|
+
triggerClassName
|
|
78
|
+
].filter(Boolean).join(" ");
|
|
79
|
+
const showEmpty = debouncedQuery && !isLoading && results.length === 0;
|
|
80
|
+
const currentEmptyMessage = isLoading ? "Searching..." : emptyMessage;
|
|
81
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
82
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
83
|
+
"button",
|
|
84
|
+
{
|
|
85
|
+
"data-testid": "search-button",
|
|
86
|
+
type: "button",
|
|
87
|
+
className: buttonClasses,
|
|
88
|
+
onClick: () => setOpen(true),
|
|
89
|
+
children: [
|
|
90
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex grow items-center", children: [
|
|
91
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
92
|
+
lucideReact.SearchIcon,
|
|
93
|
+
{
|
|
94
|
+
className: "-ms-1 me-3 text-muted-foreground",
|
|
95
|
+
size: 16,
|
|
96
|
+
"aria-hidden": "true"
|
|
97
|
+
}
|
|
98
|
+
),
|
|
99
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-normal text-muted-foreground", children: buttonText })
|
|
100
|
+
] }),
|
|
101
|
+
keyboardShortcut && /* @__PURE__ */ jsxRuntime.jsx("kbd", { className: "-me-1 ms-12 inline-flex h-5 max-h-full items-center rounded border bg-background px-1 font-[inherit] font-medium text-[0.625rem] text-muted-foreground", children: keyboardShortcut })
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
),
|
|
105
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
106
|
+
command.CommandDialog,
|
|
107
|
+
{
|
|
108
|
+
"data-testid": "search-modal",
|
|
109
|
+
open,
|
|
110
|
+
onOpenChange: setOpen,
|
|
111
|
+
className,
|
|
112
|
+
children: [
|
|
113
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
114
|
+
command.CommandInput,
|
|
115
|
+
{
|
|
116
|
+
"data-testid": "search-input",
|
|
117
|
+
placeholder,
|
|
118
|
+
value: query,
|
|
119
|
+
onValueChange: setQuery
|
|
120
|
+
}
|
|
121
|
+
),
|
|
122
|
+
/* @__PURE__ */ jsxRuntime.jsxs(command.CommandList, { className: "max-h-[400px]", children: [
|
|
123
|
+
showEmpty && /* @__PURE__ */ jsxRuntime.jsx(command.CommandEmpty, { children: currentEmptyMessage }),
|
|
124
|
+
results.length > 0 && results.map(
|
|
125
|
+
(item, index) => renderResult(item, index, debouncedQuery)
|
|
126
|
+
)
|
|
127
|
+
] })
|
|
128
|
+
]
|
|
129
|
+
}
|
|
130
|
+
)
|
|
131
|
+
] });
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
exports.SearchModal = SearchModal;
|
|
135
|
+
exports.default = SearchModal;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { SearchIcon } from 'lucide-react';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { useDebounce } from '../../hooks/use-debounce.mjs';
|
|
6
|
+
import { CommandDialog, CommandInput, CommandList, CommandEmpty } from '@workspace/ui/components/command';
|
|
7
|
+
|
|
8
|
+
function SearchModal({
|
|
9
|
+
placeholder = "Type to search...",
|
|
10
|
+
emptyMessage = "No results found.",
|
|
11
|
+
buttonText = "Search",
|
|
12
|
+
keyboardShortcut = "\u2318K",
|
|
13
|
+
searchFn,
|
|
14
|
+
renderResult,
|
|
15
|
+
results: externalResults,
|
|
16
|
+
isLoading = false,
|
|
17
|
+
className,
|
|
18
|
+
triggerClassName
|
|
19
|
+
}) {
|
|
20
|
+
const [open, setOpen] = React.useState(false);
|
|
21
|
+
const [query, setQuery] = React.useState("");
|
|
22
|
+
const [results, setResults] = React.useState([]);
|
|
23
|
+
const shouldDebounce = externalResults === void 0;
|
|
24
|
+
const debouncedQuery = useDebounce(query, shouldDebounce ? 300 : 0);
|
|
25
|
+
React.useEffect(() => {
|
|
26
|
+
const down = (e) => {
|
|
27
|
+
const cleanShortcut = keyboardShortcut.replace("\u2318", "").replace("\u21E7", "").toLowerCase();
|
|
28
|
+
if (e.key === cleanShortcut && (e.metaKey || e.ctrlKey)) {
|
|
29
|
+
e.preventDefault();
|
|
30
|
+
setOpen((open2) => !open2);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
document.addEventListener("keydown", down);
|
|
34
|
+
return () => document.removeEventListener("keydown", down);
|
|
35
|
+
}, [keyboardShortcut]);
|
|
36
|
+
React.useEffect(() => {
|
|
37
|
+
if (!open) {
|
|
38
|
+
setQuery("");
|
|
39
|
+
setResults([]);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
}, [open]);
|
|
43
|
+
React.useEffect(() => {
|
|
44
|
+
if (!open) return;
|
|
45
|
+
const searchResults = searchFn(debouncedQuery);
|
|
46
|
+
if (externalResults !== void 0) {
|
|
47
|
+
setResults(externalResults);
|
|
48
|
+
} else {
|
|
49
|
+
setResults(searchResults);
|
|
50
|
+
}
|
|
51
|
+
}, [debouncedQuery, open, searchFn, externalResults]);
|
|
52
|
+
const buttonClasses = [
|
|
53
|
+
"border-input bg-background text-foreground",
|
|
54
|
+
"placeholder:text-muted-foreground",
|
|
55
|
+
"focus-visible:border-ring focus-visible:ring-ring/50",
|
|
56
|
+
"inline-flex h-9 w-fit rounded-md border px-3 py-2 text-sm",
|
|
57
|
+
"shadow-xs transition-[color,box-shadow] outline-none",
|
|
58
|
+
"focus-visible:ring-[3px]",
|
|
59
|
+
triggerClassName
|
|
60
|
+
].filter(Boolean).join(" ");
|
|
61
|
+
const showEmpty = debouncedQuery && !isLoading && results.length === 0;
|
|
62
|
+
const currentEmptyMessage = isLoading ? "Searching..." : emptyMessage;
|
|
63
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
64
|
+
/* @__PURE__ */ jsxs(
|
|
65
|
+
"button",
|
|
66
|
+
{
|
|
67
|
+
"data-testid": "search-button",
|
|
68
|
+
type: "button",
|
|
69
|
+
className: buttonClasses,
|
|
70
|
+
onClick: () => setOpen(true),
|
|
71
|
+
children: [
|
|
72
|
+
/* @__PURE__ */ jsxs("span", { className: "flex grow items-center", children: [
|
|
73
|
+
/* @__PURE__ */ jsx(
|
|
74
|
+
SearchIcon,
|
|
75
|
+
{
|
|
76
|
+
className: "-ms-1 me-3 text-muted-foreground",
|
|
77
|
+
size: 16,
|
|
78
|
+
"aria-hidden": "true"
|
|
79
|
+
}
|
|
80
|
+
),
|
|
81
|
+
/* @__PURE__ */ jsx("span", { className: "font-normal text-muted-foreground", children: buttonText })
|
|
82
|
+
] }),
|
|
83
|
+
keyboardShortcut && /* @__PURE__ */ jsx("kbd", { className: "-me-1 ms-12 inline-flex h-5 max-h-full items-center rounded border bg-background px-1 font-[inherit] font-medium text-[0.625rem] text-muted-foreground", children: keyboardShortcut })
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
),
|
|
87
|
+
/* @__PURE__ */ jsxs(
|
|
88
|
+
CommandDialog,
|
|
89
|
+
{
|
|
90
|
+
"data-testid": "search-modal",
|
|
91
|
+
open,
|
|
92
|
+
onOpenChange: setOpen,
|
|
93
|
+
className,
|
|
94
|
+
children: [
|
|
95
|
+
/* @__PURE__ */ jsx(
|
|
96
|
+
CommandInput,
|
|
97
|
+
{
|
|
98
|
+
"data-testid": "search-input",
|
|
99
|
+
placeholder,
|
|
100
|
+
value: query,
|
|
101
|
+
onValueChange: setQuery
|
|
102
|
+
}
|
|
103
|
+
),
|
|
104
|
+
/* @__PURE__ */ jsxs(CommandList, { className: "max-h-[400px]", children: [
|
|
105
|
+
showEmpty && /* @__PURE__ */ jsx(CommandEmpty, { children: currentEmptyMessage }),
|
|
106
|
+
results.length > 0 && results.map(
|
|
107
|
+
(item, index) => renderResult(item, index, debouncedQuery)
|
|
108
|
+
)
|
|
109
|
+
] })
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
)
|
|
113
|
+
] });
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export { SearchModal, SearchModal as default };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
const context = require('@btst/stack/context');
|
|
6
|
+
const defaults = require('./defaults.cjs');
|
|
7
|
+
const badge = require('@workspace/ui/components/badge');
|
|
8
|
+
const blogHooks = require('../../hooks/blog-hooks.cjs');
|
|
9
|
+
|
|
10
|
+
function TagsList() {
|
|
11
|
+
const { tags } = blogHooks.useSuspenseTags();
|
|
12
|
+
const { Link } = context.usePluginOverrides("blog", {
|
|
13
|
+
Link: defaults.DefaultLink
|
|
14
|
+
});
|
|
15
|
+
const basePath = context.useBasePath();
|
|
16
|
+
if (!tags || tags.length === 0) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-2 justify-center", children: tags.map((tag) => /* @__PURE__ */ jsxRuntime.jsx(Link, { href: `${basePath}/blog/tag/${tag.slug}`, children: /* @__PURE__ */ jsxRuntime.jsx(badge.Badge, { variant: "secondary", className: "text-xs", children: tag.name }) }, tag.id)) });
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
exports.TagsList = TagsList;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { usePluginOverrides, useBasePath } from '@btst/stack/context';
|
|
4
|
+
import { DefaultLink } from './defaults.mjs';
|
|
5
|
+
import { Badge } from '@workspace/ui/components/badge';
|
|
6
|
+
import { useSuspenseTags } from '../../hooks/blog-hooks.mjs';
|
|
7
|
+
|
|
8
|
+
function TagsList() {
|
|
9
|
+
const { tags } = useSuspenseTags();
|
|
10
|
+
const { Link } = usePluginOverrides("blog", {
|
|
11
|
+
Link: DefaultLink
|
|
12
|
+
});
|
|
13
|
+
const basePath = useBasePath();
|
|
14
|
+
if (!tags || tags.length === 0) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
return /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2 justify-center", children: tags.map((tag) => /* @__PURE__ */ jsx(Link, { href: `${basePath}/blog/tag/${tag.slug}`, children: /* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "text-xs", children: tag.name }) }, tag.id)) });
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { TagsList };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const React = require('react');
|
|
5
|
+
const context = require('@btst/stack/context');
|
|
6
|
+
|
|
7
|
+
function useRouteLifecycle({
|
|
8
|
+
routeName,
|
|
9
|
+
context: context$1,
|
|
10
|
+
beforeRenderHook
|
|
11
|
+
}) {
|
|
12
|
+
const overrides = context.usePluginOverrides("blog");
|
|
13
|
+
if (beforeRenderHook) {
|
|
14
|
+
const canRender = beforeRenderHook(overrides, context$1);
|
|
15
|
+
if (!canRender) {
|
|
16
|
+
const error = new Error(`Unauthorized: Cannot render ${routeName}`);
|
|
17
|
+
if (overrides.onRouteError) {
|
|
18
|
+
try {
|
|
19
|
+
const result = overrides.onRouteError(routeName, error, context$1);
|
|
20
|
+
if (result instanceof Promise) {
|
|
21
|
+
result.catch(() => {
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
} catch {
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
React.useEffect(() => {
|
|
31
|
+
if (overrides.onRouteRender) {
|
|
32
|
+
try {
|
|
33
|
+
const result = overrides.onRouteRender(routeName, context$1);
|
|
34
|
+
if (result instanceof Promise) {
|
|
35
|
+
result.catch((error) => {
|
|
36
|
+
if (overrides.onRouteError) {
|
|
37
|
+
overrides.onRouteError(routeName, error, context$1);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
} catch (error) {
|
|
42
|
+
if (overrides.onRouteError) {
|
|
43
|
+
overrides.onRouteError(routeName, error, context$1);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}, [routeName, overrides, context$1]);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
exports.useRouteLifecycle = useRouteLifecycle;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import { usePluginOverrides } from '@btst/stack/context';
|
|
4
|
+
|
|
5
|
+
function useRouteLifecycle({
|
|
6
|
+
routeName,
|
|
7
|
+
context,
|
|
8
|
+
beforeRenderHook
|
|
9
|
+
}) {
|
|
10
|
+
const overrides = usePluginOverrides("blog");
|
|
11
|
+
if (beforeRenderHook) {
|
|
12
|
+
const canRender = beforeRenderHook(overrides, context);
|
|
13
|
+
if (!canRender) {
|
|
14
|
+
const error = new Error(`Unauthorized: Cannot render ${routeName}`);
|
|
15
|
+
if (overrides.onRouteError) {
|
|
16
|
+
try {
|
|
17
|
+
const result = overrides.onRouteError(routeName, error, context);
|
|
18
|
+
if (result instanceof Promise) {
|
|
19
|
+
result.catch(() => {
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
} catch {
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
throw error;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (overrides.onRouteRender) {
|
|
30
|
+
try {
|
|
31
|
+
const result = overrides.onRouteRender(routeName, context);
|
|
32
|
+
if (result instanceof Promise) {
|
|
33
|
+
result.catch((error) => {
|
|
34
|
+
if (overrides.onRouteError) {
|
|
35
|
+
overrides.onRouteError(routeName, error, context);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
} catch (error) {
|
|
40
|
+
if (overrides.onRouteError) {
|
|
41
|
+
overrides.onRouteError(routeName, error, context);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}, [routeName, overrides, context]);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { useRouteLifecycle };
|