zudoku 0.63.1 → 0.64.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/client.d.ts +8 -0
- package/dist/config/config.d.ts +3 -1
- package/dist/config/validators/BuildSchema.d.ts +5 -4
- package/dist/config/validators/BuildSchema.js +5 -2
- package/dist/config/validators/BuildSchema.js.map +1 -1
- package/dist/config/validators/InputNavigationSchema.d.ts +20 -20
- package/dist/config/validators/validate.d.ts +10 -12
- package/dist/config/validators/validate.js +8 -8
- package/dist/config/validators/validate.js.map +1 -1
- package/dist/flat-config.d.ts +6 -1
- package/dist/lib/authentication/authentication.d.ts +14 -9
- package/dist/lib/authentication/components/OAuthErrorPage.js +1 -1
- package/dist/lib/authentication/components/OAuthErrorPage.js.map +1 -1
- package/dist/lib/authentication/components/SignIn.js +6 -5
- package/dist/lib/authentication/components/SignIn.js.map +1 -1
- package/dist/lib/authentication/components/SignOut.js +6 -6
- package/dist/lib/authentication/components/SignOut.js.map +1 -1
- package/dist/lib/authentication/components/SignUp.js +5 -5
- package/dist/lib/authentication/components/SignUp.js.map +1 -1
- package/dist/lib/authentication/hook.d.ts +3 -2
- package/dist/lib/authentication/hook.js +12 -8
- package/dist/lib/authentication/hook.js.map +1 -1
- package/dist/lib/authentication/providers/auth0.js +1 -1
- package/dist/lib/authentication/providers/auth0.js.map +1 -1
- package/dist/lib/authentication/providers/azureb2c.d.ts +4 -4
- package/dist/lib/authentication/providers/azureb2c.js +3 -3
- package/dist/lib/authentication/providers/azureb2c.js.map +1 -1
- package/dist/lib/authentication/providers/clerk.js +2 -2
- package/dist/lib/authentication/providers/clerk.js.map +1 -1
- package/dist/lib/authentication/providers/openid.d.ts +7 -7
- package/dist/lib/authentication/providers/openid.js +5 -3
- package/dist/lib/authentication/providers/openid.js.map +1 -1
- package/dist/lib/authentication/providers/supabase/SupabaseAuthUI.d.ts +8 -0
- package/dist/lib/authentication/providers/supabase/SupabaseAuthUI.js +39 -0
- package/dist/lib/authentication/providers/supabase/SupabaseAuthUI.js.map +1 -0
- package/dist/lib/authentication/providers/supabase.js +35 -31
- package/dist/lib/authentication/providers/supabase.js.map +1 -1
- package/dist/lib/authentication/state.d.ts +1 -5
- package/dist/lib/authentication/state.js +2 -14
- package/dist/lib/authentication/state.js.map +1 -1
- package/dist/lib/components/Zudoku.js +3 -3
- package/dist/lib/components/index.d.ts +2 -2
- package/dist/lib/components/navigation/Toc.js +1 -1
- package/dist/lib/components/navigation/Toc.js.map +1 -1
- package/dist/lib/core/RouteGuard.d.ts +1 -1
- package/dist/lib/core/RouteGuard.js +6 -14
- package/dist/lib/core/RouteGuard.js.map +1 -1
- package/dist/lib/core/__internal.d.ts +1 -1
- package/dist/lib/hooks/index.d.ts +2 -2
- package/dist/lib/plugins/openapi/playground/CollapsibleHeader.js +1 -1
- package/dist/lib/plugins/openapi/playground/CollapsibleHeader.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/Playground.js +12 -2
- package/dist/lib/plugins/openapi/playground/Playground.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/RequestLoginDialog.d.ts +2 -1
- package/dist/lib/plugins/openapi/playground/RequestLoginDialog.js +10 -2
- package/dist/lib/plugins/openapi/playground/RequestLoginDialog.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/result-panel/Highlight.d.ts +1 -1
- package/dist/lib/plugins/openapi/playground/result-panel/ResponseStatusBar.js +1 -1
- package/dist/lib/plugins/openapi/playground/result-panel/ResponseStatusBar.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/result-panel/ResponseTab.js +23 -21
- package/dist/lib/plugins/openapi/playground/result-panel/ResponseTab.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/result-panel/ResultPanel.js +1 -1
- package/dist/lib/plugins/openapi/playground/result-panel/ResultPanel.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/useRememberSkipLoginDialog.js +2 -0
- package/dist/lib/plugins/openapi/playground/useRememberSkipLoginDialog.js.map +1 -1
- package/dist/lib/plugins/openapi/util/generateSchemaExample.js +7 -0
- package/dist/lib/plugins/openapi/util/generateSchemaExample.js.map +1 -1
- package/dist/lib/shiki.d.ts +1 -1
- package/dist/lib/shiki.js +13 -2
- package/dist/lib/shiki.js.map +1 -1
- package/dist/lib/ui/Callout.d.ts +5 -5
- package/dist/lib/ui/Callout.js +5 -5
- package/dist/lib/ui/Callout.js.map +1 -1
- package/dist/lib/ui/EmbeddedCodeBlock.d.ts +3 -1
- package/dist/lib/ui/EmbeddedCodeBlock.js +2 -2
- package/dist/lib/ui/EmbeddedCodeBlock.js.map +1 -1
- package/dist/lib/ui/ReactComponentDoc.d.ts +1 -1
- package/dist/lib/ui/ReactComponentDoc.js +2 -2
- package/dist/lib/ui/ReactComponentDoc.js.map +1 -1
- package/dist/lib/ui/SyntaxHighlight.d.ts +1 -0
- package/dist/lib/ui/SyntaxHighlight.js.map +1 -1
- package/dist/lib/util/MdxComponents.d.ts +2 -1
- package/dist/lib/util/MdxComponents.js +3 -2
- package/dist/lib/util/MdxComponents.js.map +1 -1
- package/dist/lib/util/syncZustandState.d.ts +5 -0
- package/dist/lib/util/syncZustandState.js +14 -0
- package/dist/lib/util/syncZustandState.js.map +1 -0
- package/dist/vite/api/SchemaManager.d.ts +3 -1
- package/dist/vite/api/SchemaManager.js +22 -3
- package/dist/vite/api/SchemaManager.js.map +1 -1
- package/dist/vite/api/SchemaManager.test.js +2 -2
- package/dist/vite/api/SchemaManager.test.js.map +1 -1
- package/dist/vite/plugin-api.js +14 -5
- package/dist/vite/plugin-api.js.map +1 -1
- package/dist/vite/plugin-mdx.js +36 -30
- package/dist/vite/plugin-mdx.js.map +1 -1
- package/lib/{ErrorAlert-VBJ8aHH7.js → ErrorAlert-DE3Sf66a.js} +1711 -1772
- package/lib/ErrorAlert-DE3Sf66a.js.map +1 -0
- package/lib/{MdxPage-1xaNI6q_.js → MdxPage-DZfeC0QY.js} +8 -8
- package/lib/{MdxPage-1xaNI6q_.js.map → MdxPage-DZfeC0QY.js.map} +1 -1
- package/lib/{OAuthErrorPage-Du_4sFER.js → OAuthErrorPage-BycMozgn.js} +8 -8
- package/lib/{OAuthErrorPage-Du_4sFER.js.map → OAuthErrorPage-BycMozgn.js.map} +1 -1
- package/lib/{OasProvider-0xiB5cKH.js → OasProvider-1XEOsIiW.js} +3 -3
- package/lib/{OasProvider-0xiB5cKH.js.map → OasProvider-1XEOsIiW.js.map} +1 -1
- package/lib/{OperationList-BzWKTkNq.js → OperationList-DCJw6wXL.js} +113 -109
- package/lib/OperationList-DCJw6wXL.js.map +1 -0
- package/lib/{Pagination-DOcPyfy_.js → Pagination-CJszmeSA.js} +3 -3
- package/lib/{Pagination-DOcPyfy_.js.map → Pagination-CJszmeSA.js.map} +1 -1
- package/lib/RouteGuard-DhU3LRr1.js +81 -0
- package/lib/RouteGuard-DhU3LRr1.js.map +1 -0
- package/lib/{RouterError-fm21cqlj.js → RouterError-VDLnrFqF.js} +5 -5
- package/lib/{RouterError-fm21cqlj.js.map → RouterError-VDLnrFqF.js.map} +1 -1
- package/lib/{SchemaList-Dea2Skqv.js → SchemaList-qOHkDzSz.js} +7 -7
- package/lib/{SchemaList-Dea2Skqv.js.map → SchemaList-qOHkDzSz.js.map} +1 -1
- package/lib/{SchemaView-H9glU5P7.js → SchemaView-D3hm65cc.js} +3 -3
- package/lib/{SchemaView-H9glU5P7.js.map → SchemaView-D3hm65cc.js.map} +1 -1
- package/lib/{Select-CPoGZU_V.js → Select-C1DeCqKv.js} +3 -3
- package/lib/{Select-CPoGZU_V.js.map → Select-C1DeCqKv.js.map} +1 -1
- package/lib/SignUp-6SGx9Yyq.js +50 -0
- package/lib/SignUp-6SGx9Yyq.js.map +1 -0
- package/lib/{SyntaxHighlight-B0laqAqK.js → SyntaxHighlight-zvlnSnHB.js} +789 -778
- package/lib/{SyntaxHighlight-B0laqAqK.js.map → SyntaxHighlight-zvlnSnHB.js.map} +1 -1
- package/lib/{Toc-KzXCRqrX.js → Toc-Da9yp7lo.js} +5 -5
- package/lib/Toc-Da9yp7lo.js.map +1 -0
- package/lib/{ZudokuContext-BXTZApgy.js → ZudokuContext-BUZ5hkWB.js} +33 -31
- package/lib/ZudokuContext-BUZ5hkWB.js.map +1 -0
- package/lib/{chunk-PVWAREVJ-BO6B-RAk.js → chunk-PVWAREVJ-BMhpCH5D.js} +7 -7
- package/lib/{chunk-PVWAREVJ-BO6B-RAk.js.map → chunk-PVWAREVJ-BMhpCH5D.js.map} +1 -1
- package/lib/{circular-OGtD_zFg.js → circular-CSSuz-LS.js} +2 -2
- package/lib/{circular-OGtD_zFg.js.map → circular-CSSuz-LS.js.map} +1 -1
- package/lib/{createServer-DyUc5BPr.js → createServer-CLbcVLbK.js} +4 -4
- package/lib/{createServer-DyUc5BPr.js.map → createServer-CLbcVLbK.js.map} +1 -1
- package/lib/{errors-7_i0Oyw4.js → errors-CuGgh3hf.js} +2 -2
- package/lib/{errors-7_i0Oyw4.js.map → errors-CuGgh3hf.js.map} +1 -1
- package/lib/hook-CMeoxziF.js +40 -0
- package/lib/hook-CMeoxziF.js.map +1 -0
- package/lib/{index-CLJGtw_S.js → index-B1rmok4X.js} +7 -7
- package/lib/{index-CLJGtw_S.js.map → index-B1rmok4X.js.map} +1 -1
- package/lib/{index-PdgTSEkk.js → index-RNAxx6IF.js} +853 -793
- package/lib/index-RNAxx6IF.js.map +1 -0
- package/lib/{index-C5L4favO.js → index-rYHsvtTo.js} +2 -2
- package/lib/{index-C5L4favO.js.map → index-rYHsvtTo.js.map} +1 -1
- package/lib/{mutation-CdGPxHNX.js → mutation-BSU0xu4m.js} +2 -2
- package/lib/{mutation-CdGPxHNX.js.map → mutation-BSU0xu4m.js.map} +1 -1
- package/lib/ui/Callout.js +18 -18
- package/lib/ui/Callout.js.map +1 -1
- package/lib/ui/CodeBlock.js +217 -7
- package/lib/ui/CodeBlock.js.map +1 -1
- package/lib/ui/EmbeddedCodeBlock.js +22 -19
- package/lib/ui/EmbeddedCodeBlock.js.map +1 -1
- package/lib/ui/ReactComponentDoc.js +13 -13
- package/lib/ui/ReactComponentDoc.js.map +1 -1
- package/lib/ui/SyntaxHighlight.js +3 -3
- package/lib/{useExposedProps-Cd7Yg_uG.js → useExposedProps-U3pmsHaG.js} +2 -2
- package/lib/{useExposedProps-Cd7Yg_uG.js.map → useExposedProps-U3pmsHaG.js.map} +1 -1
- package/lib/zudoku.__internal.js +7 -7
- package/lib/zudoku.auth-auth0.js +13 -13
- package/lib/zudoku.auth-auth0.js.map +1 -1
- package/lib/zudoku.auth-azureb2c.js +28 -28
- package/lib/zudoku.auth-azureb2c.js.map +1 -1
- package/lib/zudoku.auth-clerk.js +40 -40
- package/lib/zudoku.auth-clerk.js.map +1 -1
- package/lib/zudoku.auth-openid.js +53 -56
- package/lib/zudoku.auth-openid.js.map +1 -1
- package/lib/zudoku.auth-supabase.js +111 -52
- package/lib/zudoku.auth-supabase.js.map +1 -1
- package/lib/zudoku.components.js +6 -6
- package/lib/zudoku.hooks.js +4 -4
- package/lib/zudoku.plugin-api-catalog.js +5 -5
- package/lib/zudoku.plugin-api-keys.js +99 -99
- package/lib/zudoku.plugin-custom-pages.js +1 -1
- package/lib/zudoku.plugin-markdown.js +1 -1
- package/lib/zudoku.plugin-openapi.js +3 -3
- package/lib/zudoku.plugin-redirect.js +1 -1
- package/lib/zudoku.plugin-search-pagefind.js +38 -38
- package/lib/zudoku.plugin-search-pagefind.js.map +1 -1
- package/lib/zudoku.router.js +2 -2
- package/package.json +16 -8
- package/src/app/main.css +19 -9
- package/src/lib/authentication/authentication.ts +19 -3
- package/src/lib/authentication/components/OAuthErrorPage.tsx +1 -1
- package/src/lib/authentication/components/SignIn.tsx +7 -5
- package/src/lib/authentication/components/SignOut.tsx +7 -6
- package/src/lib/authentication/components/SignUp.tsx +5 -8
- package/src/lib/authentication/hook.ts +21 -10
- package/src/lib/authentication/providers/auth0.tsx +2 -1
- package/src/lib/authentication/providers/azureb2c.tsx +10 -3
- package/src/lib/authentication/providers/clerk.tsx +9 -2
- package/src/lib/authentication/providers/openid.tsx +20 -15
- package/src/lib/authentication/providers/supabase/SupabaseAuthUI.tsx +75 -0
- package/src/lib/authentication/providers/supabase.tsx +59 -43
- package/src/lib/authentication/state.ts +3 -23
- package/src/lib/components/Zudoku.tsx +3 -3
- package/src/lib/components/navigation/Toc.tsx +3 -3
- package/src/lib/core/RouteGuard.tsx +33 -13
- package/src/lib/plugins/openapi/playground/CollapsibleHeader.tsx +2 -2
- package/src/lib/plugins/openapi/playground/Playground.tsx +13 -2
- package/src/lib/plugins/openapi/playground/RequestLoginDialog.tsx +20 -1
- package/src/lib/plugins/openapi/playground/result-panel/ResponseStatusBar.tsx +2 -2
- package/src/lib/plugins/openapi/playground/result-panel/ResponseTab.tsx +102 -58
- package/src/lib/plugins/openapi/playground/result-panel/ResultPanel.tsx +1 -1
- package/src/lib/plugins/openapi/playground/useRememberSkipLoginDialog.tsx +3 -0
- package/src/lib/plugins/openapi/util/generateSchemaExample.ts +10 -0
- package/src/lib/shiki.ts +16 -2
- package/src/lib/ui/Callout.tsx +10 -5
- package/src/lib/ui/EmbeddedCodeBlock.tsx +6 -3
- package/src/lib/ui/ReactComponentDoc.tsx +17 -17
- package/src/lib/ui/SyntaxHighlight.tsx +6 -1
- package/src/lib/util/MdxComponents.tsx +3 -5
- package/src/lib/util/syncZustandState.ts +22 -0
- package/lib/CodeBlock-CanTUJLl.js +0 -221
- package/lib/CodeBlock-CanTUJLl.js.map +0 -1
- package/lib/ErrorAlert-VBJ8aHH7.js.map +0 -1
- package/lib/OperationList-BzWKTkNq.js.map +0 -1
- package/lib/RouteGuard-Bg0Lu0OU.js +0 -56
- package/lib/RouteGuard-Bg0Lu0OU.js.map +0 -1
- package/lib/SignUp-DUZ4yUmQ.js +0 -56
- package/lib/SignUp-DUZ4yUmQ.js.map +0 -1
- package/lib/Toc-KzXCRqrX.js.map +0 -1
- package/lib/ZudokuContext-BXTZApgy.js.map +0 -1
- package/lib/hook-CAebs2rv.js +0 -31
- package/lib/hook-CAebs2rv.js.map +0 -1
- package/lib/index-PdgTSEkk.js.map +0 -1
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
1
2
|
import { Button } from "zudoku/ui/Button.js";
|
|
3
|
+
import { Checkbox } from "zudoku/ui/Checkbox.js";
|
|
2
4
|
import {
|
|
3
5
|
Dialog,
|
|
4
6
|
DialogContent,
|
|
@@ -6,18 +8,28 @@ import {
|
|
|
6
8
|
DialogFooter,
|
|
7
9
|
DialogTitle,
|
|
8
10
|
} from "zudoku/ui/Dialog.js";
|
|
11
|
+
import { Label } from "zudoku/ui/Label.js";
|
|
9
12
|
|
|
10
13
|
const RequestLoginDialog = ({
|
|
11
14
|
open,
|
|
12
15
|
setOpen,
|
|
13
16
|
onSignUp,
|
|
14
17
|
onLogin,
|
|
18
|
+
onSkip,
|
|
15
19
|
}: {
|
|
16
20
|
open: boolean;
|
|
17
21
|
onSignUp?: () => void;
|
|
18
22
|
onLogin?: () => void;
|
|
19
23
|
setOpen: (open: boolean) => void;
|
|
24
|
+
onSkip?: (rememberSkip: boolean) => void;
|
|
20
25
|
}) => {
|
|
26
|
+
const [rememberSkip, setRememberSkip] = useState(false);
|
|
27
|
+
|
|
28
|
+
const handleSkip = () => {
|
|
29
|
+
onSkip?.(rememberSkip);
|
|
30
|
+
setOpen(false);
|
|
31
|
+
};
|
|
32
|
+
|
|
21
33
|
return (
|
|
22
34
|
<Dialog open={open} onOpenChange={setOpen}>
|
|
23
35
|
<DialogContent>
|
|
@@ -26,8 +38,15 @@ const RequestLoginDialog = ({
|
|
|
26
38
|
The Playground is a tool for developers to test and explore our APIs.
|
|
27
39
|
To use the Playground, you need to login.
|
|
28
40
|
</DialogDescription>
|
|
41
|
+
<Label className="flex items-center gap-2 font-normal">
|
|
42
|
+
<Checkbox
|
|
43
|
+
checked={rememberSkip}
|
|
44
|
+
onCheckedChange={(checked) => setRememberSkip(checked === true)}
|
|
45
|
+
/>
|
|
46
|
+
Don't show this again
|
|
47
|
+
</Label>
|
|
29
48
|
<DialogFooter className="flex gap-2 sm:justify-between">
|
|
30
|
-
<Button type="button" variant="
|
|
49
|
+
<Button type="button" variant="outline" onClick={handleSkip}>
|
|
31
50
|
Skip
|
|
32
51
|
</Button>
|
|
33
52
|
<div className="flex gap-2">
|
|
@@ -84,7 +84,7 @@ export const ResponseStatusBar = ({
|
|
|
84
84
|
};
|
|
85
85
|
|
|
86
86
|
return (
|
|
87
|
-
<div className="relative flex h-10 text-xs gap-4 px-4 items-center justify-between font-mono border-b">
|
|
87
|
+
<div className="relative shrink-0 flex h-10 text-xs gap-4 px-4 items-center justify-between font-mono border-b">
|
|
88
88
|
<div className="flex items-center gap-2">
|
|
89
89
|
<ResponseCodeCircle status={status} /> {status ?? "Sending Request..."}
|
|
90
90
|
{status ? ` ${statusCodeMap[status]}` : ""}
|
|
@@ -104,7 +104,7 @@ export const ResponseStatusBar = ({
|
|
|
104
104
|
</div>
|
|
105
105
|
</div>
|
|
106
106
|
<div
|
|
107
|
-
className="h-full bg-neutral-500/10 absolute left-0
|
|
107
|
+
className="h-full bg-neutral-500/10 absolute left-0 bottom-0 z-10 transition-all duration-200 ease-in-out"
|
|
108
108
|
style={{
|
|
109
109
|
opacity: isFinished ? 0 : 1,
|
|
110
110
|
width: isFinished ? 0 : `${progress * 100}%`,
|
|
@@ -5,7 +5,9 @@ import {
|
|
|
5
5
|
DownloadIcon,
|
|
6
6
|
EyeIcon,
|
|
7
7
|
EyeOffIcon,
|
|
8
|
+
MinusCircleIcon,
|
|
8
9
|
PlusCircleIcon,
|
|
10
|
+
SquareCodeIcon,
|
|
9
11
|
} from "lucide-react";
|
|
10
12
|
import { useState } from "react";
|
|
11
13
|
import { Button } from "zudoku/ui/Button.js";
|
|
@@ -22,6 +24,7 @@ import {
|
|
|
22
24
|
SelectTrigger,
|
|
23
25
|
SelectValue,
|
|
24
26
|
} from "zudoku/ui/Select.js";
|
|
27
|
+
import { SyntaxHighlight } from "zudoku/ui/SyntaxHighlight.js";
|
|
25
28
|
import { cn } from "../../../../util/cn.js";
|
|
26
29
|
import createVariantComponent from "../../../../util/createVariantComponent.js";
|
|
27
30
|
import { humanFileSize } from "../../../../util/humanFileSize.js";
|
|
@@ -30,7 +33,6 @@ import {
|
|
|
30
33
|
CollapsibleHeaderTrigger,
|
|
31
34
|
} from "../CollapsibleHeader.js";
|
|
32
35
|
import { convertToTypes } from "./convertToTypes.js";
|
|
33
|
-
import { Highlight } from "./Highlight.js";
|
|
34
36
|
|
|
35
37
|
const mimeTypeToLanguage = (mimeType: string) => {
|
|
36
38
|
const mimeTypeMapping = {
|
|
@@ -92,28 +94,35 @@ const Row = createVariantComponent(
|
|
|
92
94
|
"grid-cols-subgrid grid border-b col-span-full px-4 py-1.5 font-mono text-xs",
|
|
93
95
|
);
|
|
94
96
|
|
|
95
|
-
const RowContent = createVariantComponent("div", "py-1 break-
|
|
97
|
+
const RowContent = createVariantComponent("div", "py-1 break-words");
|
|
96
98
|
const RowValue = ({ value, header }: { value: string; header: string }) => {
|
|
97
99
|
const secretHeaders = ["authorization", "key", "secret", "token"];
|
|
98
100
|
const isSecret = secretHeaders.includes(header.toLowerCase());
|
|
99
101
|
const [revealed, setRevealed] = useState(!isSecret);
|
|
100
102
|
return (
|
|
101
103
|
<RowContent
|
|
102
|
-
className={cn(
|
|
104
|
+
className={cn(
|
|
105
|
+
"max-h-28 overflow-auto",
|
|
106
|
+
isSecret && "cursor-pointer flex group",
|
|
107
|
+
)}
|
|
103
108
|
onClick={() => {
|
|
104
109
|
if (isSecret) {
|
|
105
110
|
setRevealed((prev) => !prev);
|
|
106
111
|
}
|
|
107
112
|
}}
|
|
108
113
|
>
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
{!isSecret ? (
|
|
115
|
+
value
|
|
116
|
+
) : (
|
|
117
|
+
<>
|
|
118
|
+
<SecretText secret={value} previewChars={0} revealed={revealed} />
|
|
119
|
+
{revealed ? (
|
|
120
|
+
<EyeOffIcon size={14} className={cn("hidden group-hover:block")} />
|
|
121
|
+
) : (
|
|
122
|
+
<EyeIcon size={14} className={cn("hidden group-hover:block")} />
|
|
123
|
+
)}
|
|
124
|
+
</>
|
|
125
|
+
)}
|
|
117
126
|
</RowContent>
|
|
118
127
|
);
|
|
119
128
|
};
|
|
@@ -174,13 +183,13 @@ export const ResponseTab = ({
|
|
|
174
183
|
<>
|
|
175
184
|
<Collapsible defaultOpen>
|
|
176
185
|
<CollapsibleHeaderTrigger>
|
|
177
|
-
<CornerDownRightIcon size={
|
|
186
|
+
<CornerDownRightIcon size={14} />
|
|
178
187
|
<CollapsibleHeader className="col-span-2">
|
|
179
|
-
|
|
188
|
+
Request Headers
|
|
180
189
|
</CollapsibleHeader>
|
|
181
190
|
</CollapsibleHeaderTrigger>
|
|
182
191
|
<CollapsibleContent>
|
|
183
|
-
<div className="grid grid-cols-
|
|
192
|
+
<div className="grid grid-cols-[2fr_3fr] gap-x-6 text-sm">
|
|
184
193
|
{request.headers
|
|
185
194
|
.slice(0, MAX_HEADERS_TO_SHOW)
|
|
186
195
|
.map(([key, value]) => (
|
|
@@ -189,19 +198,45 @@ export const ResponseTab = ({
|
|
|
189
198
|
<RowValue value={value} header={key} />
|
|
190
199
|
</Row>
|
|
191
200
|
))}
|
|
201
|
+
{request.headers.length > MAX_HEADERS_TO_SHOW && (
|
|
202
|
+
<Collapsible className="col-span-full grid-cols-subgrid grid group">
|
|
203
|
+
<CollapsibleTrigger className="data-[state=open]:hidden justify-center col-span-2 text-xs text-muted-foreground hover:text-primary border-b h-8 flex items-center gap-2">
|
|
204
|
+
Show {request.headers.length - MAX_HEADERS_TO_SHOW} more
|
|
205
|
+
headers
|
|
206
|
+
<PlusCircleIcon size={12} className="text-muted-foreground" />
|
|
207
|
+
</CollapsibleTrigger>
|
|
208
|
+
<CollapsibleContent className="col-span-full grid grid-cols-subgrid">
|
|
209
|
+
{request.headers
|
|
210
|
+
.slice(MAX_HEADERS_TO_SHOW)
|
|
211
|
+
.map(([key, value]) => (
|
|
212
|
+
<Row key={key}>
|
|
213
|
+
<RowContent>{key}</RowContent>
|
|
214
|
+
<RowValue value={value} header={key} />
|
|
215
|
+
</Row>
|
|
216
|
+
))}
|
|
217
|
+
<CollapsibleTrigger className="justify-center col-span-2 text-xs text-muted-foreground hover:text-primary border-b h-8 flex items-center gap-2">
|
|
218
|
+
Hide {request.headers.length - MAX_HEADERS_TO_SHOW} headers
|
|
219
|
+
<MinusCircleIcon
|
|
220
|
+
size={12}
|
|
221
|
+
className="text-muted-foreground"
|
|
222
|
+
/>
|
|
223
|
+
</CollapsibleTrigger>
|
|
224
|
+
</CollapsibleContent>
|
|
225
|
+
</Collapsible>
|
|
226
|
+
)}
|
|
192
227
|
</div>
|
|
193
228
|
</CollapsibleContent>
|
|
194
229
|
</Collapsible>
|
|
195
230
|
|
|
196
231
|
<Collapsible defaultOpen>
|
|
197
232
|
<CollapsibleHeaderTrigger>
|
|
198
|
-
<CornerDownLeftIcon size={
|
|
233
|
+
<CornerDownLeftIcon size={14} />
|
|
199
234
|
<CollapsibleHeader className="col-span-2">
|
|
200
|
-
|
|
235
|
+
Response Headers
|
|
201
236
|
</CollapsibleHeader>
|
|
202
237
|
</CollapsibleHeaderTrigger>
|
|
203
238
|
<CollapsibleContent>
|
|
204
|
-
<div className="grid grid-cols-
|
|
239
|
+
<div className="grid grid-cols-[2fr_3fr] gap-x-6 text-sm">
|
|
205
240
|
{sortedHeaders.slice(0, MAX_HEADERS_TO_SHOW).map(([key, value]) => (
|
|
206
241
|
<Row key={key}>
|
|
207
242
|
<RowContent>{key}</RowContent>
|
|
@@ -211,10 +246,7 @@ export const ResponseTab = ({
|
|
|
211
246
|
{sortedHeaders.length > MAX_HEADERS_TO_SHOW && (
|
|
212
247
|
<Collapsible className="col-span-full grid-cols-subgrid grid group">
|
|
213
248
|
<CollapsibleTrigger className="data-[state=open]:hidden justify-center col-span-2 text-xs text-muted-foreground hover:text-primary border-b h-8 flex items-center gap-2">
|
|
214
|
-
|
|
215
|
-
Show {sortedHeaders.length - MAX_HEADERS_TO_SHOW} more
|
|
216
|
-
headers
|
|
217
|
-
</span>
|
|
249
|
+
Show {sortedHeaders.length - MAX_HEADERS_TO_SHOW} more headers
|
|
218
250
|
<PlusCircleIcon size={12} className="text-muted-foreground" />
|
|
219
251
|
</CollapsibleTrigger>
|
|
220
252
|
<CollapsibleContent className="col-span-full grid grid-cols-subgrid">
|
|
@@ -226,6 +258,13 @@ export const ResponseTab = ({
|
|
|
226
258
|
<RowValue value={value} header={key} />
|
|
227
259
|
</Row>
|
|
228
260
|
))}
|
|
261
|
+
<CollapsibleTrigger className="justify-center col-span-2 text-xs text-muted-foreground hover:text-primary border-b h-8 flex items-center gap-2">
|
|
262
|
+
Hide {sortedHeaders.length - MAX_HEADERS_TO_SHOW} headers
|
|
263
|
+
<MinusCircleIcon
|
|
264
|
+
size={12}
|
|
265
|
+
className="text-muted-foreground"
|
|
266
|
+
/>
|
|
267
|
+
</CollapsibleTrigger>
|
|
229
268
|
</CollapsibleContent>
|
|
230
269
|
</Collapsible>
|
|
231
270
|
)}
|
|
@@ -233,26 +272,30 @@ export const ResponseTab = ({
|
|
|
233
272
|
</CollapsibleContent>
|
|
234
273
|
</Collapsible>
|
|
235
274
|
|
|
236
|
-
<div className="flex gap-2 justify-between items-center border-b
|
|
275
|
+
<div className="flex gap-2 justify-between items-center border-b px-2 flex-0">
|
|
276
|
+
<CollapsibleHeader className="flex items-center gap-2">
|
|
277
|
+
<SquareCodeIcon size={14} />
|
|
278
|
+
Response body
|
|
279
|
+
</CollapsibleHeader>
|
|
237
280
|
{jsonContent && !isBinary && (
|
|
238
|
-
<
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
</
|
|
251
|
-
</
|
|
252
|
-
</
|
|
281
|
+
<Select
|
|
282
|
+
value={view}
|
|
283
|
+
onValueChange={(value) =>
|
|
284
|
+
setView(value as "formatted" | "raw" | "types")
|
|
285
|
+
}
|
|
286
|
+
>
|
|
287
|
+
<SelectTrigger className="max-w-32 border-0 bg-transparent">
|
|
288
|
+
<SelectValue placeholder="View" />
|
|
289
|
+
</SelectTrigger>
|
|
290
|
+
<SelectContent>
|
|
291
|
+
<SelectItem value="formatted">Formatted</SelectItem>
|
|
292
|
+
<SelectItem value="raw">Raw</SelectItem>
|
|
293
|
+
<SelectItem value="types">Types</SelectItem>
|
|
294
|
+
</SelectContent>
|
|
295
|
+
</Select>
|
|
253
296
|
)}
|
|
254
297
|
</div>
|
|
255
|
-
<div>
|
|
298
|
+
<div className="flex-1">
|
|
256
299
|
{isBinary ? (
|
|
257
300
|
<div className="p-4 text-center">
|
|
258
301
|
<div className="flex flex-col items-center gap-4">
|
|
@@ -272,26 +315,27 @@ export const ResponseTab = ({
|
|
|
272
315
|
</div>
|
|
273
316
|
</div>
|
|
274
317
|
) : (
|
|
275
|
-
<
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
318
|
+
<SyntaxHighlight
|
|
319
|
+
className="text-xs flex-1"
|
|
320
|
+
embedded
|
|
321
|
+
fullHeight
|
|
322
|
+
language={
|
|
323
|
+
view === "types"
|
|
324
|
+
? "typescript"
|
|
325
|
+
: view === "raw"
|
|
326
|
+
? jsonContent
|
|
327
|
+
? "plain"
|
|
328
|
+
: detectedLanguage
|
|
329
|
+
: "json"
|
|
330
|
+
}
|
|
331
|
+
code={
|
|
332
|
+
(view === "raw"
|
|
333
|
+
? body
|
|
334
|
+
: view === "types"
|
|
335
|
+
? types.data?.lines.join("\n")
|
|
336
|
+
: beautifiedBody) ?? ""
|
|
337
|
+
}
|
|
338
|
+
/>
|
|
295
339
|
)}
|
|
296
340
|
</div>
|
|
297
341
|
</>
|
|
@@ -25,7 +25,7 @@ export const ResultPanel = ({
|
|
|
25
25
|
tip?: React.ReactNode;
|
|
26
26
|
}) => {
|
|
27
27
|
return (
|
|
28
|
-
<div className="overflow-y-auto h-[80vh] bg-muted/50">
|
|
28
|
+
<div className="flex flex-col overflow-y-auto h-[80vh] bg-muted/50">
|
|
29
29
|
{(queryMutation.isPending || queryMutation.data) && (
|
|
30
30
|
<ResponseStatusBar
|
|
31
31
|
status={queryMutation.data?.status}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { create } from "zustand";
|
|
2
2
|
import { createJSONStorage, persist } from "zustand/middleware";
|
|
3
|
+
import { syncZustandState } from "../../../util/syncZustandState.js";
|
|
3
4
|
|
|
4
5
|
type RememberSkipLoginState = {
|
|
5
6
|
skipLogin: boolean;
|
|
@@ -18,3 +19,5 @@ export const useRememberSkipLoginDialog = create<RememberSkipLoginState>()(
|
|
|
18
19
|
},
|
|
19
20
|
),
|
|
20
21
|
);
|
|
22
|
+
|
|
23
|
+
syncZustandState(useRememberSkipLoginDialog);
|
|
@@ -104,6 +104,16 @@ export const generateSchemaExample = (
|
|
|
104
104
|
}, {});
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
+
// Check for property-level examples
|
|
108
|
+
if (
|
|
109
|
+
schema.examples &&
|
|
110
|
+
Array.isArray(schema.examples) &&
|
|
111
|
+
schema.examples.length > 0
|
|
112
|
+
) {
|
|
113
|
+
const randomIndex = Math.floor(Math.random() * schema.examples.length);
|
|
114
|
+
return schema.examples[randomIndex];
|
|
115
|
+
}
|
|
116
|
+
|
|
107
117
|
switch (schema.type) {
|
|
108
118
|
case "string":
|
|
109
119
|
return name || "string";
|
package/src/lib/shiki.ts
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "@shikijs/transformers";
|
|
8
8
|
import type { Root } from "hast";
|
|
9
9
|
import { toJsxRuntime } from "hast-util-to-jsx-runtime";
|
|
10
|
-
import {
|
|
10
|
+
import { createElement, Fragment } from "react";
|
|
11
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
12
|
import type {
|
|
13
13
|
BundledLanguage,
|
|
@@ -21,6 +21,9 @@ import type { Pluggable } from "unified";
|
|
|
21
21
|
import { visit } from "unist-util-visit";
|
|
22
22
|
import { cn } from "./util/cn.js";
|
|
23
23
|
|
|
24
|
+
export const HIGHLIGHT_CODE_BLOCK_CLASS =
|
|
25
|
+
"overflow-x-auto scrollbar not-inline";
|
|
26
|
+
|
|
24
27
|
const engine = createJavaScriptRegexEngine({ forgiving: true });
|
|
25
28
|
export const highlighter = await createHighlighterCore({
|
|
26
29
|
engine,
|
|
@@ -143,5 +146,16 @@ export const highlight = (
|
|
|
143
146
|
themes,
|
|
144
147
|
});
|
|
145
148
|
|
|
146
|
-
return toJsxRuntime(value, {
|
|
149
|
+
return toJsxRuntime(value, {
|
|
150
|
+
Fragment,
|
|
151
|
+
jsx,
|
|
152
|
+
jsxs,
|
|
153
|
+
components: {
|
|
154
|
+
code: (props) =>
|
|
155
|
+
createElement("code", {
|
|
156
|
+
...props,
|
|
157
|
+
className: cn(props.className, HIGHLIGHT_CODE_BLOCK_CLASS),
|
|
158
|
+
}),
|
|
159
|
+
},
|
|
160
|
+
});
|
|
147
161
|
};
|
package/src/lib/ui/Callout.tsx
CHANGED
|
@@ -14,7 +14,8 @@ const stylesMap = {
|
|
|
14
14
|
bg: "bg-gray-100 dark:bg-zinc-800/50",
|
|
15
15
|
iconColor: "text-gray-600 dark:text-zinc-300",
|
|
16
16
|
titleColor: "text-gray-600 dark:text-zinc-300",
|
|
17
|
-
textColor:
|
|
17
|
+
textColor:
|
|
18
|
+
"text-gray-600 dark:text-zinc-300 [&_a]:hover:text-gray-700 [&_a]:dark:hover:text-zinc-400",
|
|
18
19
|
Icon: InfoIcon as LucideIcon,
|
|
19
20
|
},
|
|
20
21
|
tip: {
|
|
@@ -22,7 +23,8 @@ const stylesMap = {
|
|
|
22
23
|
bg: "bg-green-200/25 dark:bg-green-950/70",
|
|
23
24
|
iconColor: "text-green-600 dark:text-green-200",
|
|
24
25
|
titleColor: "text-green-700 dark:text-green-200",
|
|
25
|
-
textColor:
|
|
26
|
+
textColor:
|
|
27
|
+
"text-green-600 dark:text-green-50 [&_a]:hover:text-green-700 [&_a]:dark:hover:text-green-300",
|
|
26
28
|
Icon: LightbulbIcon as LucideIcon,
|
|
27
29
|
},
|
|
28
30
|
info: {
|
|
@@ -30,7 +32,8 @@ const stylesMap = {
|
|
|
30
32
|
bg: "bg-blue-50 dark:bg-blue-950/40",
|
|
31
33
|
iconColor: "text-blue-400 dark:text-blue-200",
|
|
32
34
|
titleColor: "text-blue-700 dark:text-blue-200",
|
|
33
|
-
textColor:
|
|
35
|
+
textColor:
|
|
36
|
+
"text-blue-600 dark:text-blue-100 [&_a]:hover:text-blue-800 [&_a]:dark:hover:text-blue-300",
|
|
34
37
|
Icon: InfoIcon as LucideIcon,
|
|
35
38
|
},
|
|
36
39
|
caution: {
|
|
@@ -38,7 +41,8 @@ const stylesMap = {
|
|
|
38
41
|
bg: "bg-yellow-100/60 dark:bg-yellow-400/10",
|
|
39
42
|
iconColor: "text-yellow-500 dark:text-yellow-300",
|
|
40
43
|
titleColor: "text-yellow-600 dark:text-yellow-300",
|
|
41
|
-
textColor:
|
|
44
|
+
textColor:
|
|
45
|
+
"text-yellow-700 dark:text-yellow-200 [&_a]:hover:text-yellow-800 [&_a]:dark:hover:text-yellow-300",
|
|
42
46
|
Icon: AlertTriangleIcon as LucideIcon,
|
|
43
47
|
},
|
|
44
48
|
danger: {
|
|
@@ -46,7 +50,8 @@ const stylesMap = {
|
|
|
46
50
|
bg: "bg-rose-50 dark:bg-rose-950/40",
|
|
47
51
|
iconColor: "text-rose-400 dark:text-rose-300",
|
|
48
52
|
titleColor: "text-rose-800 dark:text-rose-300",
|
|
49
|
-
textColor:
|
|
53
|
+
textColor:
|
|
54
|
+
"text-rose-700 dark:text-rose-100 [&_a]:hover:text-rose-800 [&_a]:dark:hover:text-rose-300",
|
|
50
55
|
Icon: ShieldAlertIcon as LucideIcon,
|
|
51
56
|
},
|
|
52
57
|
} as const;
|
|
@@ -19,13 +19,14 @@ export type CodeBlockProps = {
|
|
|
19
19
|
|
|
20
20
|
export const EmbeddedCodeBlock = ({
|
|
21
21
|
children,
|
|
22
|
+
fullHeight,
|
|
22
23
|
language,
|
|
23
24
|
showCopy = "hover",
|
|
24
25
|
showCopyText,
|
|
25
26
|
showLanguageIndicator = true,
|
|
26
27
|
showLineNumbers,
|
|
27
28
|
...props
|
|
28
|
-
}: CodeBlockProps) => {
|
|
29
|
+
}: CodeBlockProps & { fullHeight?: boolean }) => {
|
|
29
30
|
const [isCopied, setIsCopied] = useState(false);
|
|
30
31
|
const ref = useRef<HTMLDivElement>(null);
|
|
31
32
|
|
|
@@ -36,11 +37,13 @@ export const EmbeddedCodeBlock = ({
|
|
|
36
37
|
className={cn(
|
|
37
38
|
"code-block-wrapper relative group bg-muted/50",
|
|
38
39
|
showLineNumbers && "line-numbers",
|
|
40
|
+
fullHeight && "h-full",
|
|
39
41
|
)}
|
|
40
42
|
>
|
|
41
43
|
<div
|
|
42
44
|
className={cn(
|
|
43
|
-
"code-block text-sm not-prose scrollbar overflow-x-auto [&>pre]:p-2",
|
|
45
|
+
"code-block text-sm not-prose scrollbar [&>pre]:overflow-x-auto [&>pre]:p-2",
|
|
46
|
+
fullHeight && "h-full [&>pre]:h-full",
|
|
44
47
|
props.className,
|
|
45
48
|
)}
|
|
46
49
|
ref={ref}
|
|
@@ -50,7 +53,7 @@ export const EmbeddedCodeBlock = ({
|
|
|
50
53
|
{showLanguageIndicator && (
|
|
51
54
|
<span
|
|
52
55
|
className={cn(
|
|
53
|
-
"absolute top-1.5 end-3
|
|
56
|
+
"absolute top-1.5 end-3 text-[11px]! font-mono text-muted-foreground transition group-hover:opacity-0",
|
|
54
57
|
showCopy === "always" && "hidden",
|
|
55
58
|
)}
|
|
56
59
|
>
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { Badge } from "./Badge.js";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Card,
|
|
4
|
+
CardContent,
|
|
5
|
+
CardDescription,
|
|
6
|
+
CardHeader,
|
|
7
|
+
CardTitle,
|
|
8
|
+
} from "./Card.js";
|
|
3
9
|
|
|
4
10
|
type PropType =
|
|
5
11
|
| string
|
|
6
|
-
| {
|
|
7
|
-
name: string;
|
|
8
|
-
description: string;
|
|
9
|
-
required: boolean;
|
|
10
|
-
};
|
|
12
|
+
| { name: string; description: string; required: boolean };
|
|
11
13
|
|
|
12
14
|
type ReactComponentDocProps = {
|
|
13
15
|
component: {
|
|
14
|
-
__docgenInfo
|
|
16
|
+
__docgenInfo?: {
|
|
15
17
|
displayName: string;
|
|
16
18
|
description: string;
|
|
17
19
|
props: Record<
|
|
@@ -33,18 +35,16 @@ export const ReactComponentDoc = ({ component }: ReactComponentDocProps) => {
|
|
|
33
35
|
|
|
34
36
|
return (
|
|
35
37
|
<Card className="not-prose">
|
|
36
|
-
<
|
|
37
|
-
<
|
|
38
|
-
<
|
|
39
|
-
<
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
</div>
|
|
43
|
-
<div className="grid grid-cols-[1fr_auto_auto] gap-2 divide-y">
|
|
38
|
+
<CardContent className="p-0">
|
|
39
|
+
<CardHeader className="border-b mb-1 px-4 py-5">
|
|
40
|
+
<CardTitle>Component Properties</CardTitle>
|
|
41
|
+
<CardDescription>The properties of the component.</CardDescription>
|
|
42
|
+
</CardHeader>
|
|
43
|
+
<div className="grid grid-cols-[1fr_auto_auto] gap-2 divide-y -mx-4 px-4">
|
|
44
44
|
{Object.entries(docgen.props).map(([key, value]) => (
|
|
45
45
|
<div
|
|
46
46
|
key={key}
|
|
47
|
-
className="px-
|
|
47
|
+
className="px-4 pb-2 col-span-full grid grid-cols-subgrid"
|
|
48
48
|
>
|
|
49
49
|
<span className="font-medium text-primary">{key}</span>
|
|
50
50
|
<div>
|
|
@@ -62,7 +62,7 @@ export const ReactComponentDoc = ({ component }: ReactComponentDocProps) => {
|
|
|
62
62
|
</div>
|
|
63
63
|
))}
|
|
64
64
|
</div>
|
|
65
|
-
</
|
|
65
|
+
</CardContent>
|
|
66
66
|
</Card>
|
|
67
67
|
);
|
|
68
68
|
};
|
|
@@ -7,7 +7,12 @@ import { EmbeddedCodeBlock } from "./EmbeddedCodeBlock.js";
|
|
|
7
7
|
|
|
8
8
|
type SyntaxHighlightProps = CodeBlockProps &
|
|
9
9
|
(
|
|
10
|
-
| {
|
|
10
|
+
| {
|
|
11
|
+
code: string;
|
|
12
|
+
embedded?: boolean;
|
|
13
|
+
children?: never;
|
|
14
|
+
fullHeight?: boolean;
|
|
15
|
+
}
|
|
11
16
|
| { code?: never; children: string; embedded?: boolean }
|
|
12
17
|
);
|
|
13
18
|
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { MDXComponents } from "mdx/types.js";
|
|
2
|
-
import { CodeBlock } from "zudoku/ui/CodeBlock.js";
|
|
3
2
|
import { AnchorLink } from "../components/AnchorLink.js";
|
|
4
3
|
import { Framed } from "../components/Framed.js";
|
|
5
4
|
import { Heading } from "../components/Heading.js";
|
|
6
5
|
import { InlineCode } from "../components/InlineCode.js";
|
|
6
|
+
import { HIGHLIGHT_CODE_BLOCK_CLASS } from "../shiki.js";
|
|
7
7
|
import { Button } from "../ui/Button.js";
|
|
8
8
|
import { Callout } from "../ui/Callout.js";
|
|
9
|
+
import { CodeBlock } from "../ui/CodeBlock.js";
|
|
9
10
|
import { Stepper } from "../ui/Stepper.js";
|
|
10
11
|
import { SyntaxHighlight } from "../ui/SyntaxHighlight.js";
|
|
11
12
|
import { cn } from "./cn.js";
|
|
@@ -109,10 +110,7 @@ export const MdxComponents = {
|
|
|
109
110
|
showLineNumbers={showLineNumbers}
|
|
110
111
|
title={title}
|
|
111
112
|
>
|
|
112
|
-
<code
|
|
113
|
-
className={cn(className, "overflow-x-auto scrollbar not-inline")}
|
|
114
|
-
{...props}
|
|
115
|
-
>
|
|
113
|
+
<code className={cn(className, HIGHLIGHT_CODE_BLOCK_CLASS)} {...props}>
|
|
116
114
|
{children}
|
|
117
115
|
</code>
|
|
118
116
|
</CodeBlock>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Mutate, StoreApi } from "zustand";
|
|
2
|
+
|
|
3
|
+
export type StoreWithPersist<T> = Mutate<
|
|
4
|
+
StoreApi<T>,
|
|
5
|
+
[["zustand/persist", unknown]]
|
|
6
|
+
>;
|
|
7
|
+
|
|
8
|
+
export const syncZustandState = <T>(store: StoreWithPersist<T>) => {
|
|
9
|
+
const storageEventCallback = (e: StorageEvent) => {
|
|
10
|
+
if (e.key === store.persist.getOptions().name && e.newValue) {
|
|
11
|
+
void store.persist.rehydrate();
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
if (typeof window === "undefined") return;
|
|
16
|
+
|
|
17
|
+
window.addEventListener("storage", storageEventCallback);
|
|
18
|
+
|
|
19
|
+
return () => {
|
|
20
|
+
window.removeEventListener("storage", storageEventCallback);
|
|
21
|
+
};
|
|
22
|
+
};
|