@lukoweb/apitogo 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/cli.js +37 -147
- package/dist/declarations/lib/ui/Command.d.ts +1 -1
- package/dist/declarations/lib/util/MdxComponents.d.ts +1 -1
- package/package.json +1 -1
- package/src/app/main.tsx +150 -150
- package/src/config/loader.ts +245 -245
- package/src/index.ts +33 -33
- package/src/lib/authentication/components/CallbackHandler.tsx +45 -45
- package/src/lib/authentication/components/SignIn.tsx +46 -46
- package/src/lib/authentication/components/SignUp.tsx +48 -48
- package/src/lib/authentication/providers/clerk.tsx +224 -224
- package/src/lib/authentication/ui/AuthCard.tsx +7 -7
- package/src/lib/authentication/ui/EmailLinkCallbackUi.tsx +129 -125
- package/src/lib/authentication/ui/EmailLinkSentUi.tsx +105 -101
- package/src/lib/authentication/ui/EmailLinkSignInUi.tsx +100 -96
- package/src/lib/authentication/ui/EmailVerificationUi.tsx +128 -124
- package/src/lib/authentication/ui/ZudokuAuthUi.tsx +620 -616
- package/src/lib/components/AiAssistantMenuItems.tsx +102 -102
- package/src/lib/components/Autocomplete.tsx +123 -123
- package/src/lib/components/DeveloperHint.tsx +39 -35
- package/src/lib/components/Header.tsx +260 -260
- package/src/lib/components/Layout.tsx +53 -53
- package/src/lib/components/Main.tsx +51 -51
- package/src/lib/components/Mermaid.tsx +74 -70
- package/src/lib/components/MobileTopNavigation.tsx +276 -276
- package/src/lib/components/MultiSelect.tsx +86 -82
- package/src/lib/components/TopNavigation.tsx +103 -103
- package/src/lib/components/index.ts +26 -26
- package/src/lib/components/navigation/NavigationCategory.tsx +157 -157
- package/src/lib/components/navigation/NavigationFilterInput.tsx +35 -35
- package/src/lib/components/navigation/NavigationItem.tsx +181 -177
- package/src/lib/core/RouteGuard.tsx +193 -193
- package/src/lib/errors/ErrorMessage.tsx +50 -46
- package/src/lib/plugins/api-catalog/Catalog.tsx +80 -80
- package/src/lib/plugins/api-keys/CreateApiKey.tsx +128 -124
- package/src/lib/plugins/api-keys/CreateApiKeyDialog.tsx +49 -49
- package/src/lib/plugins/api-keys/SettingsApiKeys.tsx +72 -72
- package/src/lib/plugins/api-keys/settings/ApiKeyItem.tsx +342 -342
- package/src/lib/plugins/api-keys/settings/RevealApiKey.tsx +127 -127
- package/src/lib/plugins/markdown/MdxPage.tsx +285 -285
- package/src/lib/plugins/openapi/ApiHeader.tsx +96 -96
- package/src/lib/plugins/openapi/CollapsibleCode.tsx +88 -88
- package/src/lib/plugins/openapi/DownloadSchemaButton.tsx +94 -94
- package/src/lib/plugins/openapi/GeneratedExampleSidecarBox.tsx +52 -52
- package/src/lib/plugins/openapi/OperationListItem.tsx +183 -183
- package/src/lib/plugins/openapi/RequestBodySidecarBox.tsx +63 -63
- package/src/lib/plugins/openapi/ResponsesSidecarBox.tsx +120 -117
- package/src/lib/plugins/openapi/SchemaInfo.tsx +344 -344
- package/src/lib/plugins/openapi/SchemaList.tsx +113 -113
- package/src/lib/plugins/openapi/Sidecar.tsx +312 -309
- package/src/lib/plugins/openapi/SidecarExamples.tsx +177 -174
- package/src/lib/plugins/openapi/components/EnumValues.tsx +58 -58
- package/src/lib/plugins/openapi/components/ResponseContent.tsx +117 -114
- package/src/lib/plugins/openapi/playground/BodyPanel.tsx +274 -271
- package/src/lib/plugins/openapi/playground/CollapsibleHeader.tsx +51 -51
- package/src/lib/plugins/openapi/playground/ExamplesDropdown.tsx +60 -60
- package/src/lib/plugins/openapi/playground/Headers.tsx +188 -181
- package/src/lib/plugins/openapi/playground/IdentityDialog.tsx +75 -75
- package/src/lib/plugins/openapi/playground/IdentitySelector.tsx +38 -38
- package/src/lib/plugins/openapi/playground/ParamsGrid.tsx +45 -45
- package/src/lib/plugins/openapi/playground/Playground.tsx +602 -599
- package/src/lib/plugins/openapi/playground/PlaygroundDialog.tsx +56 -56
- package/src/lib/plugins/openapi/playground/QueryParams.tsx +151 -148
- package/src/lib/plugins/openapi/playground/RequestLoginDialog.tsx +70 -70
- package/src/lib/plugins/openapi/playground/request-panel/MultipartField.tsx +91 -91
- package/src/lib/plugins/openapi/playground/result-panel/AudioPlayer.tsx +50 -50
- package/src/lib/plugins/openapi/playground/result-panel/ResponseTab.tsx +355 -355
- package/src/lib/plugins/openapi/playground/result-panel/ResultPanel.tsx +106 -102
- package/src/lib/plugins/openapi/schema/SchemaPropertyItem.tsx +189 -184
- package/src/lib/plugins/openapi/schema/SchemaView.tsx +299 -299
- package/src/lib/plugins/search-pagefind/IndexingDialog.tsx +162 -162
- package/src/lib/plugins/search-pagefind/PagefindSearch.tsx +202 -202
- package/src/lib/plugins/search-pagefind/ResultList.tsx +122 -118
- package/src/lib/ui/ActionButton.tsx +21 -21
- package/src/lib/ui/Command.tsx +191 -191
- package/src/lib/util/MdxComponents.tsx +150 -150
- package/src/vite/config.ts +234 -231
- package/src/vite/dev-server.ts +291 -291
- package/src/vite/plugin-api-keys.ts +50 -50
- package/src/vite/plugin-api.ts +320 -318
- package/src/vite/plugin-auth.ts +38 -38
- package/src/vite/plugin-component.ts +45 -39
- package/src/vite/plugin-config.ts +75 -75
- package/src/vite/plugin-custom-pages.ts +36 -36
- package/src/vite/plugin-docs.ts +202 -202
- package/src/vite/plugin-markdown-export.ts +214 -214
- package/src/vite/plugin-mdx.ts +149 -149
- package/src/vite/plugin-navigation.ts +106 -106
- package/src/vite/plugin-search.ts +47 -47
- package/src/vite/plugin.ts +42 -42
- package/src/vite/prerender/prerender.ts +233 -233
|
@@ -1,157 +1,157 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import type { NavigationCategory as NavigationCategoryType } from "../../../config/validators/NavigationSchema.js";
|
|
8
|
-
import { cn } from "../../util/cn.js";
|
|
9
|
-
import { joinUrl } from "../../util/joinUrl.js";
|
|
10
|
-
import { useNavigationFilter } from "./NavigationFilterContext.js";
|
|
11
|
-
import { NavigationItem } from "./NavigationItem.js";
|
|
12
|
-
import { navigationListItem, useIsCategoryOpen } from "./utils.js";
|
|
13
|
-
|
|
14
|
-
const NavigationCategoryInner = ({
|
|
15
|
-
category,
|
|
16
|
-
onRequestClose,
|
|
17
|
-
}: {
|
|
18
|
-
category: NavigationCategoryType;
|
|
19
|
-
onRequestClose?: () => void;
|
|
20
|
-
}) => {
|
|
21
|
-
const isCategoryOpen = useIsCategoryOpen(category);
|
|
22
|
-
const [hasInteracted, setHasInteracted] = useState(false);
|
|
23
|
-
const location = useLocation();
|
|
24
|
-
const { query: filterQuery } = useNavigationFilter();
|
|
25
|
-
|
|
26
|
-
const isCollapsible = category.collapsible ?? true;
|
|
27
|
-
const isCollapsed = category.collapsed ?? true;
|
|
28
|
-
const isDefaultOpen = Boolean(
|
|
29
|
-
!isCollapsible || !isCollapsed || isCategoryOpen,
|
|
30
|
-
);
|
|
31
|
-
const [open, setOpen] = useState(isDefaultOpen);
|
|
32
|
-
const match = useMatch(category.link?.path ?? "");
|
|
33
|
-
const isActive = category.link ? match : false;
|
|
34
|
-
|
|
35
|
-
useEffect(() => {
|
|
36
|
-
// this is triggered when an item from the navigation is clicked
|
|
37
|
-
// and the navigation, enclosing this item, is not opened
|
|
38
|
-
if (isCategoryOpen) {
|
|
39
|
-
setOpen(true);
|
|
40
|
-
}
|
|
41
|
-
}, [isCategoryOpen]);
|
|
42
|
-
|
|
43
|
-
// Auto-expand when there's an active filter query
|
|
44
|
-
useEffect(() => {
|
|
45
|
-
if (filterQuery.trim()) {
|
|
46
|
-
setOpen(true);
|
|
47
|
-
}
|
|
48
|
-
}, [filterQuery]);
|
|
49
|
-
|
|
50
|
-
const ToggleButton = isCollapsible && (
|
|
51
|
-
<Button
|
|
52
|
-
onClick={(e) => {
|
|
53
|
-
e.preventDefault();
|
|
54
|
-
setOpen((prev) => !prev);
|
|
55
|
-
setHasInteracted(true);
|
|
56
|
-
}}
|
|
57
|
-
variant="ghost"
|
|
58
|
-
size="icon"
|
|
59
|
-
className="size-6 hover:bg-[hsl(from_var(--accent)_h_s_calc(l+6*var(--dark)))]"
|
|
60
|
-
>
|
|
61
|
-
<ChevronRightIcon
|
|
62
|
-
size={16}
|
|
63
|
-
className={cn(
|
|
64
|
-
hasInteracted && "transition",
|
|
65
|
-
"shrink-0 group-data-[state=open]:rotate-90 rtl:rotate-180",
|
|
66
|
-
)}
|
|
67
|
-
/>
|
|
68
|
-
</Button>
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
const icon = category.icon && (
|
|
72
|
-
<category.icon
|
|
73
|
-
size={16}
|
|
74
|
-
className={cn("align-[-0.125em] ", isActive && "text-primary")}
|
|
75
|
-
/>
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
const styles = navigationListItem({
|
|
79
|
-
className: [
|
|
80
|
-
"group text-start font-medium",
|
|
81
|
-
isCollapsible || typeof category.link !== "undefined"
|
|
82
|
-
? "cursor-pointer"
|
|
83
|
-
: "cursor-default hover:bg-transparent",
|
|
84
|
-
],
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
return (
|
|
88
|
-
<Collapsible.Root
|
|
89
|
-
className="flex flex-col"
|
|
90
|
-
defaultOpen={isDefaultOpen}
|
|
91
|
-
open={open}
|
|
92
|
-
onOpenChange={() => setOpen(true)}
|
|
93
|
-
>
|
|
94
|
-
<Collapsible.Trigger className="group" asChild disabled={!isCollapsible}>
|
|
95
|
-
{category.link?.type === "doc" ? (
|
|
96
|
-
<NavLink
|
|
97
|
-
to={{
|
|
98
|
-
pathname: joinUrl(category.link.path),
|
|
99
|
-
search: location.search,
|
|
100
|
-
}}
|
|
101
|
-
className={styles}
|
|
102
|
-
onClick={() => {
|
|
103
|
-
// if it is the current path and closed then open it because there's no path change to trigger the open
|
|
104
|
-
if (isActive && !open) {
|
|
105
|
-
setHasInteracted(true);
|
|
106
|
-
setOpen(true);
|
|
107
|
-
}
|
|
108
|
-
}}
|
|
109
|
-
>
|
|
110
|
-
{icon}
|
|
111
|
-
<div className="flex items-center gap-2 justify-between w-full text-foreground/80 group-aria-[current='page']:text-primary">
|
|
112
|
-
<div className="truncate">{category.label}</div>
|
|
113
|
-
{ToggleButton}
|
|
114
|
-
</div>
|
|
115
|
-
</NavLink>
|
|
116
|
-
) : (
|
|
117
|
-
<div className={styles}>
|
|
118
|
-
{icon}
|
|
119
|
-
<div className="flex items-center justify-between w-full">
|
|
120
|
-
<div className="flex gap-2 truncate w-full">{category.label}</div>
|
|
121
|
-
{ToggleButton}
|
|
122
|
-
</div>
|
|
123
|
-
</div>
|
|
124
|
-
)}
|
|
125
|
-
</Collapsible.Trigger>
|
|
126
|
-
<Collapsible.Content
|
|
127
|
-
className={cn(
|
|
128
|
-
// CollapsibleContent class is used to animate and it should only be applied when the user has triggered the toggle
|
|
129
|
-
hasInteracted && "CollapsibleContent",
|
|
130
|
-
category.items.length === 0 && "hidden",
|
|
131
|
-
"ms-6 my-1",
|
|
132
|
-
)}
|
|
133
|
-
onAnimationEnd={() => setHasInteracted(false)}
|
|
134
|
-
>
|
|
135
|
-
<ul className="relative after:absolute after:-inset-s-(--padding-nav-item) after:translate-x-[1.5px] after:top-0 after:bottom-0 after:w-px after:bg-border">
|
|
136
|
-
{category.items.map((item) => (
|
|
137
|
-
<NavigationItem
|
|
138
|
-
key={
|
|
139
|
-
item.type +
|
|
140
|
-
(item.label ?? "") +
|
|
141
|
-
("path" in item ? item.path : "") +
|
|
142
|
-
("file" in item ? item.file : "") +
|
|
143
|
-
("to" in item ? item.to : "")
|
|
144
|
-
}
|
|
145
|
-
onRequestClose={onRequestClose}
|
|
146
|
-
item={item}
|
|
147
|
-
/>
|
|
148
|
-
))}
|
|
149
|
-
</ul>
|
|
150
|
-
</Collapsible.Content>
|
|
151
|
-
</Collapsible.Root>
|
|
152
|
-
);
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
export const NavigationCategory = memo(NavigationCategoryInner, deepEqual);
|
|
156
|
-
|
|
157
|
-
NavigationCategory.displayName = "NavigationCategory";
|
|
1
|
+
import { Button } from "@lukoweb/apitogo/ui/Button.js";
|
|
2
|
+
import * as Collapsible from "@radix-ui/react-collapsible";
|
|
3
|
+
import { deepEqual } from "fast-equals";
|
|
4
|
+
import { ChevronRightIcon } from "lucide-react";
|
|
5
|
+
import { memo, useEffect, useState } from "react";
|
|
6
|
+
import { NavLink, useLocation, useMatch } from "react-router";
|
|
7
|
+
import type { NavigationCategory as NavigationCategoryType } from "../../../config/validators/NavigationSchema.js";
|
|
8
|
+
import { cn } from "../../util/cn.js";
|
|
9
|
+
import { joinUrl } from "../../util/joinUrl.js";
|
|
10
|
+
import { useNavigationFilter } from "./NavigationFilterContext.js";
|
|
11
|
+
import { NavigationItem } from "./NavigationItem.js";
|
|
12
|
+
import { navigationListItem, useIsCategoryOpen } from "./utils.js";
|
|
13
|
+
|
|
14
|
+
const NavigationCategoryInner = ({
|
|
15
|
+
category,
|
|
16
|
+
onRequestClose,
|
|
17
|
+
}: {
|
|
18
|
+
category: NavigationCategoryType;
|
|
19
|
+
onRequestClose?: () => void;
|
|
20
|
+
}) => {
|
|
21
|
+
const isCategoryOpen = useIsCategoryOpen(category);
|
|
22
|
+
const [hasInteracted, setHasInteracted] = useState(false);
|
|
23
|
+
const location = useLocation();
|
|
24
|
+
const { query: filterQuery } = useNavigationFilter();
|
|
25
|
+
|
|
26
|
+
const isCollapsible = category.collapsible ?? true;
|
|
27
|
+
const isCollapsed = category.collapsed ?? true;
|
|
28
|
+
const isDefaultOpen = Boolean(
|
|
29
|
+
!isCollapsible || !isCollapsed || isCategoryOpen,
|
|
30
|
+
);
|
|
31
|
+
const [open, setOpen] = useState(isDefaultOpen);
|
|
32
|
+
const match = useMatch(category.link?.path ?? "");
|
|
33
|
+
const isActive = category.link ? match : false;
|
|
34
|
+
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
// this is triggered when an item from the navigation is clicked
|
|
37
|
+
// and the navigation, enclosing this item, is not opened
|
|
38
|
+
if (isCategoryOpen) {
|
|
39
|
+
setOpen(true);
|
|
40
|
+
}
|
|
41
|
+
}, [isCategoryOpen]);
|
|
42
|
+
|
|
43
|
+
// Auto-expand when there's an active filter query
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (filterQuery.trim()) {
|
|
46
|
+
setOpen(true);
|
|
47
|
+
}
|
|
48
|
+
}, [filterQuery]);
|
|
49
|
+
|
|
50
|
+
const ToggleButton = isCollapsible && (
|
|
51
|
+
<Button
|
|
52
|
+
onClick={(e) => {
|
|
53
|
+
e.preventDefault();
|
|
54
|
+
setOpen((prev) => !prev);
|
|
55
|
+
setHasInteracted(true);
|
|
56
|
+
}}
|
|
57
|
+
variant="ghost"
|
|
58
|
+
size="icon"
|
|
59
|
+
className="size-6 hover:bg-[hsl(from_var(--accent)_h_s_calc(l+6*var(--dark)))]"
|
|
60
|
+
>
|
|
61
|
+
<ChevronRightIcon
|
|
62
|
+
size={16}
|
|
63
|
+
className={cn(
|
|
64
|
+
hasInteracted && "transition",
|
|
65
|
+
"shrink-0 group-data-[state=open]:rotate-90 rtl:rotate-180",
|
|
66
|
+
)}
|
|
67
|
+
/>
|
|
68
|
+
</Button>
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
const icon = category.icon && (
|
|
72
|
+
<category.icon
|
|
73
|
+
size={16}
|
|
74
|
+
className={cn("align-[-0.125em] ", isActive && "text-primary")}
|
|
75
|
+
/>
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
const styles = navigationListItem({
|
|
79
|
+
className: [
|
|
80
|
+
"group text-start font-medium",
|
|
81
|
+
isCollapsible || typeof category.link !== "undefined"
|
|
82
|
+
? "cursor-pointer"
|
|
83
|
+
: "cursor-default hover:bg-transparent",
|
|
84
|
+
],
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<Collapsible.Root
|
|
89
|
+
className="flex flex-col"
|
|
90
|
+
defaultOpen={isDefaultOpen}
|
|
91
|
+
open={open}
|
|
92
|
+
onOpenChange={() => setOpen(true)}
|
|
93
|
+
>
|
|
94
|
+
<Collapsible.Trigger className="group" asChild disabled={!isCollapsible}>
|
|
95
|
+
{category.link?.type === "doc" ? (
|
|
96
|
+
<NavLink
|
|
97
|
+
to={{
|
|
98
|
+
pathname: joinUrl(category.link.path),
|
|
99
|
+
search: location.search,
|
|
100
|
+
}}
|
|
101
|
+
className={styles}
|
|
102
|
+
onClick={() => {
|
|
103
|
+
// if it is the current path and closed then open it because there's no path change to trigger the open
|
|
104
|
+
if (isActive && !open) {
|
|
105
|
+
setHasInteracted(true);
|
|
106
|
+
setOpen(true);
|
|
107
|
+
}
|
|
108
|
+
}}
|
|
109
|
+
>
|
|
110
|
+
{icon}
|
|
111
|
+
<div className="flex items-center gap-2 justify-between w-full text-foreground/80 group-aria-[current='page']:text-primary">
|
|
112
|
+
<div className="truncate">{category.label}</div>
|
|
113
|
+
{ToggleButton}
|
|
114
|
+
</div>
|
|
115
|
+
</NavLink>
|
|
116
|
+
) : (
|
|
117
|
+
<div className={styles}>
|
|
118
|
+
{icon}
|
|
119
|
+
<div className="flex items-center justify-between w-full">
|
|
120
|
+
<div className="flex gap-2 truncate w-full">{category.label}</div>
|
|
121
|
+
{ToggleButton}
|
|
122
|
+
</div>
|
|
123
|
+
</div>
|
|
124
|
+
)}
|
|
125
|
+
</Collapsible.Trigger>
|
|
126
|
+
<Collapsible.Content
|
|
127
|
+
className={cn(
|
|
128
|
+
// CollapsibleContent class is used to animate and it should only be applied when the user has triggered the toggle
|
|
129
|
+
hasInteracted && "CollapsibleContent",
|
|
130
|
+
category.items.length === 0 && "hidden",
|
|
131
|
+
"ms-6 my-1",
|
|
132
|
+
)}
|
|
133
|
+
onAnimationEnd={() => setHasInteracted(false)}
|
|
134
|
+
>
|
|
135
|
+
<ul className="relative after:absolute after:-inset-s-(--padding-nav-item) after:translate-x-[1.5px] after:top-0 after:bottom-0 after:w-px after:bg-border">
|
|
136
|
+
{category.items.map((item) => (
|
|
137
|
+
<NavigationItem
|
|
138
|
+
key={
|
|
139
|
+
item.type +
|
|
140
|
+
(item.label ?? "") +
|
|
141
|
+
("path" in item ? item.path : "") +
|
|
142
|
+
("file" in item ? item.file : "") +
|
|
143
|
+
("to" in item ? item.to : "")
|
|
144
|
+
}
|
|
145
|
+
onRequestClose={onRequestClose}
|
|
146
|
+
item={item}
|
|
147
|
+
/>
|
|
148
|
+
))}
|
|
149
|
+
</ul>
|
|
150
|
+
</Collapsible.Content>
|
|
151
|
+
</Collapsible.Root>
|
|
152
|
+
);
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export const NavigationCategory = memo(NavigationCategoryInner, deepEqual);
|
|
156
|
+
|
|
157
|
+
NavigationCategory.displayName = "NavigationCategory";
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from "
|
|
8
|
-
import { useNavigationFilter } from "./NavigationFilterContext.js";
|
|
9
|
-
|
|
10
|
-
export const NavigationFilterInput = ({
|
|
11
|
-
placeholder,
|
|
12
|
-
}: {
|
|
13
|
-
placeholder?: string;
|
|
14
|
-
}) => {
|
|
15
|
-
const { query, setQuery } = useNavigationFilter();
|
|
16
|
-
|
|
17
|
-
return (
|
|
18
|
-
<InputGroup className="my-2">
|
|
19
|
-
<InputGroupAddon>
|
|
20
|
-
<SearchIcon className="size-3.5" />
|
|
21
|
-
</InputGroupAddon>
|
|
22
|
-
<InputGroupInput
|
|
23
|
-
type="text"
|
|
24
|
-
placeholder={placeholder}
|
|
25
|
-
value={query}
|
|
26
|
-
onChange={(e) => setQuery(e.target.value)}
|
|
27
|
-
/>
|
|
28
|
-
{query && (
|
|
29
|
-
<InputGroupButton onClick={() => setQuery("")}>
|
|
30
|
-
<XIcon className="size-3" />
|
|
31
|
-
</InputGroupButton>
|
|
32
|
-
)}
|
|
33
|
-
</InputGroup>
|
|
34
|
-
);
|
|
35
|
-
};
|
|
1
|
+
import {
|
|
2
|
+
InputGroup,
|
|
3
|
+
InputGroupAddon,
|
|
4
|
+
InputGroupButton,
|
|
5
|
+
InputGroupInput,
|
|
6
|
+
} from "@lukoweb/apitogo/ui/InputGroup.js";
|
|
7
|
+
import { SearchIcon, XIcon } from "lucide-react";
|
|
8
|
+
import { useNavigationFilter } from "./NavigationFilterContext.js";
|
|
9
|
+
|
|
10
|
+
export const NavigationFilterInput = ({
|
|
11
|
+
placeholder,
|
|
12
|
+
}: {
|
|
13
|
+
placeholder?: string;
|
|
14
|
+
}) => {
|
|
15
|
+
const { query, setQuery } = useNavigationFilter();
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<InputGroup className="my-2">
|
|
19
|
+
<InputGroupAddon>
|
|
20
|
+
<SearchIcon className="size-3.5" />
|
|
21
|
+
</InputGroupAddon>
|
|
22
|
+
<InputGroupInput
|
|
23
|
+
type="text"
|
|
24
|
+
placeholder={placeholder}
|
|
25
|
+
value={query}
|
|
26
|
+
onChange={(e) => setQuery(e.target.value)}
|
|
27
|
+
/>
|
|
28
|
+
{query && (
|
|
29
|
+
<InputGroupButton onClick={() => setQuery("")}>
|
|
30
|
+
<XIcon className="size-3" />
|
|
31
|
+
</InputGroupButton>
|
|
32
|
+
)}
|
|
33
|
+
</InputGroup>
|
|
34
|
+
);
|
|
35
|
+
};
|