zudoku 0.46.1 → 0.46.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.
Files changed (168) hide show
  1. package/dist/config/validators/validate.d.ts +12 -12
  2. package/dist/config/validators/validate.js +3 -1
  3. package/dist/config/validators/validate.js.map +1 -1
  4. package/dist/lib/authentication/AuthenticationPlugin.d.ts +0 -5
  5. package/dist/lib/authentication/AuthenticationPlugin.js +0 -12
  6. package/dist/lib/authentication/AuthenticationPlugin.js.map +1 -1
  7. package/dist/lib/plugins/api-keys/SettingsApiKeys.js +110 -15
  8. package/dist/lib/plugins/api-keys/SettingsApiKeys.js.map +1 -1
  9. package/dist/lib/plugins/api-keys/index.d.ts +3 -3
  10. package/dist/lib/plugins/api-keys/index.js +14 -14
  11. package/dist/lib/plugins/api-keys/index.js.map +1 -1
  12. package/dist/lib/plugins/openapi/Sidecar.js +11 -91
  13. package/dist/lib/plugins/openapi/Sidecar.js.map +1 -1
  14. package/dist/lib/plugins/openapi/playground/BodyPanel.d.ts +5 -0
  15. package/dist/lib/plugins/openapi/playground/BodyPanel.js +22 -0
  16. package/dist/lib/plugins/openapi/playground/BodyPanel.js.map +1 -0
  17. package/dist/lib/plugins/openapi/playground/ExamplesDropdown.js +2 -1
  18. package/dist/lib/plugins/openapi/playground/ExamplesDropdown.js.map +1 -1
  19. package/dist/lib/plugins/openapi/playground/Headers.js +25 -25
  20. package/dist/lib/plugins/openapi/playground/Headers.js.map +1 -1
  21. package/dist/lib/plugins/openapi/playground/IdentitySelector.js +1 -1
  22. package/dist/lib/plugins/openapi/playground/IdentitySelector.js.map +1 -1
  23. package/dist/lib/plugins/openapi/playground/ParamsGrid.js +2 -2
  24. package/dist/lib/plugins/openapi/playground/ParamsGrid.js.map +1 -1
  25. package/dist/lib/plugins/openapi/playground/PathParams.js +1 -1
  26. package/dist/lib/plugins/openapi/playground/PathParams.js.map +1 -1
  27. package/dist/lib/plugins/openapi/playground/Playground.d.ts +3 -8
  28. package/dist/lib/plugins/openapi/playground/Playground.js +70 -65
  29. package/dist/lib/plugins/openapi/playground/Playground.js.map +1 -1
  30. package/dist/lib/plugins/openapi/playground/PlaygroundDialog.js +1 -1
  31. package/dist/lib/plugins/openapi/playground/PlaygroundDialog.js.map +1 -1
  32. package/dist/lib/plugins/openapi/playground/QueryParams.js +1 -1
  33. package/dist/lib/plugins/openapi/playground/QueryParams.js.map +1 -1
  34. package/dist/lib/plugins/openapi/playground/fileUtils.d.ts +2 -0
  35. package/dist/lib/plugins/openapi/playground/fileUtils.js +22 -0
  36. package/dist/lib/plugins/openapi/playground/fileUtils.js.map +1 -0
  37. package/dist/lib/plugins/openapi/playground/result-panel/ResponseTab.d.ts +4 -1
  38. package/dist/lib/plugins/openapi/playground/result-panel/ResponseTab.js +29 -20
  39. package/dist/lib/plugins/openapi/playground/result-panel/ResponseTab.js.map +1 -1
  40. package/dist/lib/plugins/openapi/playground/result-panel/ResultPanel.js +2 -2
  41. package/dist/lib/plugins/openapi/playground/result-panel/ResultPanel.js.map +1 -1
  42. package/dist/lib/plugins/openapi/playground/useRememberSkipLoginDialog.d.ts +16 -0
  43. package/dist/lib/plugins/openapi/playground/useRememberSkipLoginDialog.js +10 -0
  44. package/dist/lib/plugins/openapi/playground/useRememberSkipLoginDialog.js.map +1 -0
  45. package/dist/lib/plugins/openapi/util/createHttpSnippet.d.ts +11 -0
  46. package/dist/lib/plugins/openapi/util/createHttpSnippet.js +89 -0
  47. package/dist/lib/plugins/openapi/util/createHttpSnippet.js.map +1 -0
  48. package/dist/lib/shiki.d.ts +8 -12
  49. package/dist/lib/shiki.js +11 -13
  50. package/dist/lib/shiki.js.map +1 -1
  51. package/dist/lib/ui/CodeBlock.js +1 -1
  52. package/dist/lib/ui/CodeBlock.js.map +1 -1
  53. package/dist/lib/ui/Dialog.d.ts +3 -1
  54. package/dist/lib/ui/Dialog.js +2 -2
  55. package/dist/lib/ui/Dialog.js.map +1 -1
  56. package/dist/lib/util/humanFileSize.d.ts +6 -0
  57. package/dist/lib/util/humanFileSize.js +14 -0
  58. package/dist/lib/util/humanFileSize.js.map +1 -0
  59. package/dist/lib/util/humanFileSize.test.d.ts +1 -0
  60. package/dist/lib/util/humanFileSize.test.js +22 -0
  61. package/dist/lib/util/humanFileSize.test.js.map +1 -0
  62. package/lib/{Callout-BkgOUkoZ.js → Callout-CoVxYafP.js} +2 -2
  63. package/lib/{Callout-BkgOUkoZ.js.map → Callout-CoVxYafP.js.map} +1 -1
  64. package/lib/{Dialog-Du6WMcIA.js → Dialog-BxpuVLh9.js} +25 -25
  65. package/lib/Dialog-BxpuVLh9.js.map +1 -0
  66. package/lib/{Markdown-BRAyzyUJ.js → Markdown-Cm4kj26S.js} +6 -5
  67. package/lib/{Markdown-BRAyzyUJ.js.map → Markdown-Cm4kj26S.js.map} +1 -1
  68. package/lib/{MdxPage-B3v1BSKr.js → MdxPage-fDGQtB5w.js} +5 -5
  69. package/lib/{MdxPage-B3v1BSKr.js.map → MdxPage-fDGQtB5w.js.map} +1 -1
  70. package/lib/{OasProvider-5jrFuhVk.js → OasProvider-CFBvfR3r.js} +3 -3
  71. package/lib/{OasProvider-5jrFuhVk.js.map → OasProvider-CFBvfR3r.js.map} +1 -1
  72. package/lib/{OperationList-BmoMLQPO.js → OperationList-Xs4KWmsh.js} +1139 -1131
  73. package/lib/OperationList-Xs4KWmsh.js.map +1 -0
  74. package/lib/{Pagination-Cr0fWZS3.js → Pagination-CCxhL836.js} +2 -2
  75. package/lib/{Pagination-Cr0fWZS3.js.map → Pagination-CCxhL836.js.map} +1 -1
  76. package/lib/{RouteGuard-PrSVLbSr.js → RouteGuard-CZ_uLv3g.js} +6 -6
  77. package/lib/{RouteGuard-PrSVLbSr.js.map → RouteGuard-CZ_uLv3g.js.map} +1 -1
  78. package/lib/{SchemaList-B4riYLoP.js → SchemaList-BWaNlmUJ.js} +6 -6
  79. package/lib/{SchemaList-B4riYLoP.js.map → SchemaList-BWaNlmUJ.js.map} +1 -1
  80. package/lib/{SchemaView-CPZ6RgsF.js → SchemaView-DdKJt2ln.js} +3 -3
  81. package/lib/{SchemaView-CPZ6RgsF.js.map → SchemaView-DdKJt2ln.js.map} +1 -1
  82. package/lib/{SignUp-CWaiH0tY.js → SignUp-B-1Pvc-8.js} +3 -3
  83. package/lib/{SignUp-CWaiH0tY.js.map → SignUp-B-1Pvc-8.js.map} +1 -1
  84. package/lib/{Slot-Bo6K4tnb.js → Slot-B99cbD-q.js} +11 -11
  85. package/lib/{Slot-Bo6K4tnb.js.map → Slot-B99cbD-q.js.map} +1 -1
  86. package/lib/{SyntaxHighlight-DedRjJNr.js → SyntaxHighlight-Cz6Me7-F.js} +4474 -3323
  87. package/lib/SyntaxHighlight-Cz6Me7-F.js.map +1 -0
  88. package/lib/{Toc-lL3fzNkl.js → Toc-Qe7A4uj_.js} +2 -2
  89. package/lib/{Toc-lL3fzNkl.js.map → Toc-Qe7A4uj_.js.map} +1 -1
  90. package/lib/{chunk-BAXFHI7N-C9WnHsLV.js → chunk-DQRVZFIR-BblmKnHy.js} +697 -697
  91. package/lib/chunk-DQRVZFIR-BblmKnHy.js.map +1 -0
  92. package/lib/{circular-oB4auIIg.js → circular-w5eL5J8a.js} +1812 -1807
  93. package/lib/circular-w5eL5J8a.js.map +1 -0
  94. package/lib/{createServer-DCB82j2t.js → createServer-p3yUA8Bu.js} +3648 -3493
  95. package/lib/createServer-p3yUA8Bu.js.map +1 -0
  96. package/lib/{hook-DawSLaZr.js → hook-k7PfUIsj.js} +10 -10
  97. package/lib/{hook-DawSLaZr.js.map → hook-k7PfUIsj.js.map} +1 -1
  98. package/lib/{index-BXYvD5-7.js → index-yqBxBqxF.js} +1053 -1095
  99. package/lib/index-yqBxBqxF.js.map +1 -0
  100. package/lib/index.esm-Cp4wkyud.js +1236 -0
  101. package/lib/index.esm-Cp4wkyud.js.map +1 -0
  102. package/lib/{mutation-oxMvODNQ.js → mutation-BSeQ8pEK.js} +2 -2
  103. package/lib/{mutation-oxMvODNQ.js.map → mutation-BSeQ8pEK.js.map} +1 -1
  104. package/lib/react-nprogress.esm-C2MPXjiJ.js +389 -0
  105. package/lib/react-nprogress.esm-C2MPXjiJ.js.map +1 -0
  106. package/lib/ui/CodeBlock.js +17 -16
  107. package/lib/ui/CodeBlock.js.map +1 -1
  108. package/lib/ui/Command.js +1 -1
  109. package/lib/ui/Dialog.js +25 -25
  110. package/lib/ui/Dialog.js.map +1 -1
  111. package/lib/ui/Form.js +1 -1
  112. package/lib/ui/SyntaxHighlight.js +2 -2
  113. package/lib/{useExposedProps-DG8J6ewJ.js → useExposedProps-BZQkZneR.js} +2 -2
  114. package/lib/{useExposedProps-DG8J6ewJ.js.map → useExposedProps-BZQkZneR.js.map} +1 -1
  115. package/lib/{useMutation-C_j3dA_L.js → useMutation-CZSmsIGW.js} +3 -3
  116. package/lib/{useMutation-C_j3dA_L.js.map → useMutation-CZSmsIGW.js.map} +1 -1
  117. package/lib/zudoku.auth-auth0.js +1 -1
  118. package/lib/zudoku.auth-clerk.js +2 -2
  119. package/lib/zudoku.auth-openid.js +57 -66
  120. package/lib/zudoku.auth-openid.js.map +1 -1
  121. package/lib/zudoku.components.js +1698 -2082
  122. package/lib/zudoku.components.js.map +1 -1
  123. package/lib/zudoku.hooks.js +11 -11
  124. package/lib/zudoku.plugin-api-catalog.js +5 -5
  125. package/lib/zudoku.plugin-api-keys.js +473 -4970
  126. package/lib/zudoku.plugin-api-keys.js.map +1 -1
  127. package/lib/zudoku.plugin-custom-pages.js +2 -2
  128. package/lib/zudoku.plugin-markdown.js +1 -1
  129. package/lib/zudoku.plugin-openapi.js +3 -3
  130. package/lib/zudoku.plugin-redirect.js +1 -1
  131. package/lib/zudoku.plugin-search-pagefind.js +5 -5
  132. package/package.json +33 -34
  133. package/src/lib/authentication/AuthenticationPlugin.tsx +0 -14
  134. package/src/lib/plugins/api-keys/SettingsApiKeys.tsx +193 -48
  135. package/src/lib/plugins/api-keys/index.tsx +25 -18
  136. package/src/lib/plugins/openapi/Sidecar.tsx +11 -97
  137. package/src/lib/plugins/openapi/playground/BodyPanel.tsx +46 -0
  138. package/src/lib/plugins/openapi/playground/ExamplesDropdown.tsx +4 -1
  139. package/src/lib/plugins/openapi/playground/Headers.tsx +110 -106
  140. package/src/lib/plugins/openapi/playground/IdentitySelector.tsx +13 -11
  141. package/src/lib/plugins/openapi/playground/ParamsGrid.tsx +2 -2
  142. package/src/lib/plugins/openapi/playground/PathParams.tsx +1 -1
  143. package/src/lib/plugins/openapi/playground/Playground.tsx +127 -211
  144. package/src/lib/plugins/openapi/playground/PlaygroundDialog.tsx +2 -1
  145. package/src/lib/plugins/openapi/playground/QueryParams.tsx +1 -1
  146. package/src/lib/plugins/openapi/playground/fileUtils.ts +32 -0
  147. package/src/lib/plugins/openapi/playground/result-panel/ResponseTab.tsx +74 -39
  148. package/src/lib/plugins/openapi/playground/result-panel/ResultPanel.tsx +4 -1
  149. package/src/lib/plugins/openapi/playground/useRememberSkipLoginDialog.tsx +20 -0
  150. package/src/lib/plugins/openapi/util/createHttpSnippet.ts +107 -0
  151. package/src/lib/shiki.ts +21 -22
  152. package/src/lib/ui/CodeBlock.tsx +1 -0
  153. package/src/lib/ui/Dialog.tsx +11 -7
  154. package/src/lib/util/humanFileSize.test.ts +24 -0
  155. package/src/lib/util/humanFileSize.ts +16 -0
  156. package/dist/lib/plugins/openapi/playground/SubmitButton.d.ts +0 -7
  157. package/dist/lib/plugins/openapi/playground/SubmitButton.js +0 -19
  158. package/dist/lib/plugins/openapi/playground/SubmitButton.js.map +0 -1
  159. package/lib/Dialog-Du6WMcIA.js.map +0 -1
  160. package/lib/OperationList-BmoMLQPO.js.map +0 -1
  161. package/lib/SyntaxHighlight-DedRjJNr.js.map +0 -1
  162. package/lib/chunk-BAXFHI7N-C9WnHsLV.js.map +0 -1
  163. package/lib/circular-oB4auIIg.js.map +0 -1
  164. package/lib/createServer-DCB82j2t.js.map +0 -1
  165. package/lib/index-BXYvD5-7.js.map +0 -1
  166. package/lib/index.esm-DSfX_eMP.js +0 -1216
  167. package/lib/index.esm-DSfX_eMP.js.map +0 -1
  168. package/src/lib/plugins/openapi/playground/SubmitButton.tsx +0 -70
@@ -32,7 +32,7 @@ export const ResultPanel = ({
32
32
  }) => {
33
33
  const status = ((queryMutation.data?.status ?? 0) / 100).toFixed(0);
34
34
  return (
35
- <div className="min-w-0 p-4 py-8 bg-muted/50">
35
+ <div className="min-w-0 p-4 py-4 bg-muted/50">
36
36
  {queryMutation.error ? (
37
37
  <div className="flex flex-col gap-2">
38
38
  {showPathParamsWarning && (
@@ -83,6 +83,9 @@ export const ResultPanel = ({
83
83
  headers={queryMutation.data.headers}
84
84
  body={queryMutation.data.body}
85
85
  url={queryMutation.data.request.url}
86
+ isBinary={queryMutation.data.isBinary}
87
+ fileName={queryMutation.data.fileName}
88
+ blob={queryMutation.data.blob}
86
89
  />
87
90
  </TabsContent>
88
91
  </Tabs>
@@ -0,0 +1,20 @@
1
+ import { create } from "zustand";
2
+ import { createJSONStorage, persist } from "zustand/middleware";
3
+
4
+ type RememberSkipLoginState = {
5
+ skipLogin: boolean;
6
+ setSkipLogin: (skipLogin: boolean) => void;
7
+ };
8
+
9
+ export const useRememberSkipLoginDialog = create<RememberSkipLoginState>()(
10
+ persist(
11
+ (set) => ({
12
+ skipLogin: false,
13
+ setSkipLogin: (skipLogin: boolean) => set({ skipLogin }),
14
+ }),
15
+ {
16
+ name: "remember-skip-login",
17
+ storage: createJSONStorage(() => sessionStorage),
18
+ },
19
+ ),
20
+ );
@@ -0,0 +1,107 @@
1
+ import { HTTPSnippet } from "@zudoku/httpsnippet";
2
+ import type { OperationsFragmentFragment } from "../graphql/graphql.js";
3
+
4
+ export const createHttpSnippet = ({
5
+ operation,
6
+ selectedServer,
7
+ exampleBody,
8
+ }: {
9
+ operation: OperationsFragmentFragment;
10
+ selectedServer: string;
11
+ exampleBody: {
12
+ mimeType: string;
13
+ text?: string;
14
+ };
15
+ }) => {
16
+ return new HTTPSnippet({
17
+ method: operation.method.toUpperCase(),
18
+ url:
19
+ selectedServer + operation.path.replaceAll("{", ":").replaceAll("}", ""),
20
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
+ postData: exampleBody,
22
+ headers: [
23
+ ...(exampleBody.text
24
+ ? [{ name: "Content-Type", value: exampleBody.mimeType }]
25
+ : []),
26
+ ...(operation.parameters
27
+ ?.filter((p) => p.in === "header" && p.required === true)
28
+ .map((p) => ({
29
+ name: p.name,
30
+ value:
31
+ p.schema?.default ??
32
+ p.examples?.find((x) => x.value)?.value ??
33
+ (p.schema?.type === "string"
34
+ ? "<string>"
35
+ : p.schema?.type === "number" || p.schema?.type === "integer"
36
+ ? "<number>"
37
+ : p.schema?.type === "boolean"
38
+ ? "<bool>"
39
+ : "<value>"),
40
+ })) ?? []),
41
+ ],
42
+ queryString:
43
+ operation.parameters
44
+ ?.filter((p) => p.in === "query" && p.required === true)
45
+ .map((p) => ({
46
+ name: p.name,
47
+ value:
48
+ p.schema?.default ??
49
+ p.examples?.find((x) => x.value)?.value ??
50
+ (p.schema?.type === "string"
51
+ ? "<string>"
52
+ : p.schema?.type === "number" || p.schema?.type === "integer"
53
+ ? "<number>"
54
+ : p.schema?.type === "boolean"
55
+ ? "<bool>"
56
+ : "<value>"),
57
+ })) ?? [],
58
+ httpVersion: "",
59
+ cookies: [],
60
+ headersSize: 0,
61
+ bodySize: 0,
62
+ });
63
+ };
64
+
65
+ export const getConverted = (snippet: HTTPSnippet, option: string) => {
66
+ let converted;
67
+ switch (option) {
68
+ case "shell":
69
+ converted = snippet.convert("shell", "curl");
70
+ break;
71
+ case "js":
72
+ converted = snippet.convert("javascript", "fetch");
73
+ break;
74
+ case "python":
75
+ converted = snippet.convert("python", "requests");
76
+ break;
77
+ case "java":
78
+ converted = snippet.convert("java", "okhttp");
79
+ break;
80
+ case "go":
81
+ converted = snippet.convert("go", "native");
82
+ break;
83
+ case "csharp":
84
+ converted = snippet.convert("csharp", "httpclient");
85
+ break;
86
+ case "kotlin":
87
+ converted = snippet.convert("kotlin", "okhttp");
88
+ break;
89
+ case "objc":
90
+ converted = snippet.convert("objc", "nsurlsession");
91
+ break;
92
+ case "php":
93
+ converted = snippet.convert("php", "http2");
94
+ break;
95
+ case "ruby":
96
+ converted = snippet.convert("ruby");
97
+ break;
98
+ case "swift":
99
+ converted = snippet.convert("swift");
100
+ break;
101
+ default:
102
+ converted = snippet.convert("shell");
103
+ break;
104
+ }
105
+
106
+ return converted ? converted[0] : "";
107
+ };
package/src/lib/shiki.ts CHANGED
@@ -9,7 +9,12 @@ import type { Root } from "hast";
9
9
  import { toJsxRuntime } from "hast-util-to-jsx-runtime";
10
10
  import { Fragment, type JSX } from "react";
11
11
  import { jsx, jsxs } from "react/jsx-runtime";
12
- import type { BundledLanguage, BundledTheme, HighlighterCore } from "shiki";
12
+ import type {
13
+ BundledLanguage,
14
+ BundledTheme,
15
+ CodeOptionsMultipleThemes,
16
+ HighlighterCore,
17
+ } from "shiki";
13
18
  import { createHighlighterCore } from "shiki/core";
14
19
  import { createJavaScriptRegexEngine } from "shiki/engine/javascript";
15
20
  import type { Pluggable } from "unified";
@@ -30,11 +35,13 @@ export const highlighter = await createHighlighterCore({
30
35
  },
31
36
  });
32
37
 
38
+ type ThemesRecord = CodeOptionsMultipleThemes<BundledTheme>["themes"];
39
+
33
40
  export const defaultHighlightOptions = {
34
41
  themes: {
35
42
  light: "github-light",
36
43
  dark: "github-dark",
37
- } satisfies { light: BundledTheme; dark: BundledTheme },
44
+ },
38
45
  defaultColor: false,
39
46
  inline: "tailing-curly-colon",
40
47
  addLanguageClass: true,
@@ -97,31 +104,23 @@ const rehypeCodeBlockPlugin = () => (tree: Root) => {
97
104
  });
98
105
  };
99
106
 
100
- export const createConfiguredShikiRehypePlugins = (themes?: {
101
- light: BundledTheme;
102
- dark: BundledTheme;
103
- }) => {
104
- return [
105
- [
106
- rehypeShikiFromHighlighter,
107
- highlighter,
108
- {
109
- ...defaultHighlightOptions,
110
- themes: themes ?? defaultHighlightOptions.themes,
111
- } satisfies RehypeShikiCoreOptions,
112
- ] satisfies Pluggable,
113
- rehypeCodeBlockPlugin,
114
- ];
115
- };
107
+ export const createConfiguredShikiRehypePlugins = (themes?: ThemesRecord) => [
108
+ [
109
+ rehypeShikiFromHighlighter,
110
+ highlighter,
111
+ {
112
+ ...defaultHighlightOptions,
113
+ themes: themes ?? defaultHighlightOptions.themes,
114
+ },
115
+ ] satisfies Pluggable,
116
+ rehypeCodeBlockPlugin,
117
+ ];
116
118
 
117
119
  export const highlight = (
118
120
  highlighter: HighlighterCore,
119
121
  code: string,
120
122
  lang = "text",
121
- themes: {
122
- light: BundledTheme;
123
- dark: BundledTheme;
124
- } = defaultHighlightOptions.themes,
123
+ themes: ThemesRecord = defaultHighlightOptions.themes,
125
124
  ) => {
126
125
  const value = highlighter.codeToHast(code, {
127
126
  lang,
@@ -59,6 +59,7 @@ export const CodeBlock = ({
59
59
  className={cn(
60
60
  "absolute top-1.5 end-3 !text-[11px] font-mono text-muted-foreground transition group-hover:opacity-0",
61
61
  title && "top-12",
62
+ showCopy === "always" && "hidden",
62
63
  )}
63
64
  >
64
65
  {language}
@@ -1,7 +1,7 @@
1
1
  import * as DialogPrimitive from "@radix-ui/react-dialog";
2
- import { X } from "lucide-react";
3
2
  import * as React from "react";
4
3
 
4
+ import { XIcon } from "lucide-react";
5
5
  import { cn } from "../util/cn.js";
6
6
 
7
7
  const Dialog = DialogPrimitive.Root;
@@ -29,8 +29,10 @@ DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
29
29
 
30
30
  const DialogContent = React.forwardRef<
31
31
  React.ElementRef<typeof DialogPrimitive.Content>,
32
- React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
33
- >(({ className, children, ...props }, ref) => (
32
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> & {
33
+ showCloseButton?: boolean;
34
+ }
35
+ >(({ className, children, showCloseButton = true, ...props }, ref) => (
34
36
  <DialogPortal>
35
37
  <DialogOverlay />
36
38
  <DialogPrimitive.Content
@@ -42,10 +44,12 @@ const DialogContent = React.forwardRef<
42
44
  {...props}
43
45
  >
44
46
  {children}
45
- <DialogPrimitive.Close className="absolute right-4 top-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
46
- <X className="h-4 w-4" />
47
- <span className="sr-only">Close</span>
48
- </DialogPrimitive.Close>
47
+ {showCloseButton && (
48
+ <DialogPrimitive.Close className="absolute right-4 top-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
49
+ <XIcon className="h-4 w-4" />
50
+ <span className="sr-only">Close</span>
51
+ </DialogPrimitive.Close>
52
+ )}
49
53
  </DialogPrimitive.Content>
50
54
  </DialogPortal>
51
55
  ));
@@ -0,0 +1,24 @@
1
+ import { humanFileSize } from "./humanFileSize.js";
2
+
3
+ describe("humanFileSize", () => {
4
+ it("should handle zero bytes", () => {
5
+ expect(humanFileSize(0)).toBe("0 B");
6
+ expect(humanFileSize()).toBe("0 B");
7
+ });
8
+
9
+ it("should handle undefined bytes", () => {
10
+ expect(humanFileSize(undefined)).toBe("0 B");
11
+ });
12
+
13
+ it("should handle positive bytes", () => {
14
+ expect(humanFileSize(200)).toBe("200 B");
15
+ expect(humanFileSize(1000)).toBe("1.00 kB");
16
+ expect(humanFileSize(1000000)).toBe("1.00 MB");
17
+ expect(humanFileSize(1000000000)).toBe("1.00 GB");
18
+ expect(humanFileSize(1000000000000)).toBe("1.00 TB");
19
+ expect(humanFileSize(1000000000000000)).toBe("1.00 PB");
20
+ expect(humanFileSize(1000000000000000000)).toBe("1.00 EB");
21
+ expect(humanFileSize(1000000000000000000000)).toBe("1.00 ZB");
22
+ expect(humanFileSize(1000000000000000000000000)).toBe("1.00 YB");
23
+ });
24
+ });
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Converts a number of bytes to a human-readable file size string
3
+ * @param bytes - The number of bytes (defaults to 0)
4
+ * @returns A formatted string like "1.23 MB" or "456 B"
5
+ */
6
+ export const humanFileSize = (bytes = 0) => {
7
+ if (bytes === 0) {
8
+ return "0 B";
9
+ }
10
+
11
+ const exponent = Math.floor(Math.log(bytes) / Math.log(1000.0));
12
+ const decimal = (bytes / Math.pow(1000.0, exponent)).toFixed(
13
+ exponent ? 2 : 0,
14
+ );
15
+ return `${decimal} ${exponent ? `${"kMGTPEZY"[exponent - 1]}B` : "B"}`;
16
+ };
@@ -1,7 +0,0 @@
1
- import { type ApiIdentity } from "../../../core/ZudokuContext.js";
2
- declare const SubmitButton: ({ identities, formRef, disabled, }: {
3
- identities: ApiIdentity[];
4
- formRef?: React.RefObject<HTMLFormElement | null>;
5
- disabled?: boolean;
6
- }) => import("react/jsx-runtime").JSX.Element;
7
- export default SubmitButton;
@@ -1,19 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { CheckIcon, ChevronDownIcon } from "lucide-react";
3
- import { useFormContext } from "react-hook-form";
4
- import { Button } from "zudoku/ui/Button.js";
5
- import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "zudoku/ui/DropdownMenu.js";
6
- import { NO_IDENTITY } from "./Playground.js";
7
- const SubmitButton = ({ identities, formRef, disabled, }) => {
8
- const { setValue, watch } = useFormContext();
9
- const formIdentity = watch("identity");
10
- if (identities.length === 0) {
11
- return _jsx(Button, { disabled: disabled, children: "Send" });
12
- }
13
- return (_jsxs("div", { className: "flex", children: [_jsx(Button, { className: "rounded-r-none inset-shadow-xs", disabled: disabled, onClick: () => formRef?.current?.requestSubmit(), children: "Send" }), _jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(Button, { disabled: disabled, className: "rounded-l-none border-l border-border/40 inset-shadow-xs w-6", size: "icon", children: _jsx(ChevronDownIcon, { className: "w-4 h-4" }) }) }), _jsx(DropdownMenuContent, { className: "w-56", align: "end", alignOffset: -150, children: [{ id: NO_IDENTITY, label: "None" }, ...identities].map((identity) => (_jsxs(DropdownMenuItem, { onClick: () => {
14
- setValue("identity", identity.id);
15
- formRef?.current?.requestSubmit();
16
- }, children: [identity.label, formIdentity === identity.id && (_jsx(CheckIcon, { className: "ms-2", size: 16 }))] }, identity.id))) })] })] }));
17
- };
18
- export default SubmitButton;
19
- //# sourceMappingURL=SubmitButton.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SubmitButton.js","sourceRoot":"","sources":["../../../../../src/lib/plugins/openapi/playground/SubmitButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,MAAM,YAAY,GAAG,CAAC,EACpB,UAAU,EACV,OAAO,EACP,QAAQ,GAKT,EAAE,EAAE;IACH,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,cAAc,EAAE,CAAC;IAC7C,MAAM,YAAY,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;IAEvC,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5B,OAAO,KAAC,MAAM,IAAC,QAAQ,EAAE,QAAQ,qBAAe,CAAC;IACnD,CAAC;IACD,OAAO,CACL,eAAK,SAAS,EAAC,MAAM,aACnB,KAAC,MAAM,IACL,SAAS,EAAC,gCAAgC,EAC1C,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,qBAGzC,EACT,MAAC,YAAY,eACX,KAAC,mBAAmB,IAAC,OAAO,kBAC1B,KAAC,MAAM,IACL,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAC,8DAA8D,EACxE,IAAI,EAAC,MAAM,YAEX,KAAC,eAAe,IAAC,SAAS,EAAC,SAAS,GAAG,GAChC,GACW,EACtB,KAAC,mBAAmB,IAAC,SAAS,EAAC,MAAM,EAAC,KAAK,EAAC,KAAK,EAAC,WAAW,EAAE,CAAC,GAAG,YAChE,CAAC,EAAE,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,GAAG,UAAU,CAAC,CAAC,GAAG,CACtD,CAAC,QAAQ,EAAE,EAAE,CAAC,CACZ,MAAC,gBAAgB,IAEf,OAAO,EAAE,GAAG,EAAE;gCACZ,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC;gCAClC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC;4BACpC,CAAC,aAEA,QAAQ,CAAC,KAAK,EACd,YAAY,KAAK,QAAQ,CAAC,EAAE,IAAI,CAC/B,KAAC,SAAS,IAAC,SAAS,EAAC,MAAM,EAAC,IAAI,EAAE,EAAE,GAAI,CACzC,KATI,QAAQ,CAAC,EAAE,CAUC,CACpB,CACF,GACmB,IACT,IACX,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Dialog-Du6WMcIA.js","sources":["../src/lib/ui/Dialog.tsx"],"sourcesContent":["import * as DialogPrimitive from \"@radix-ui/react-dialog\";\nimport { X } from \"lucide-react\";\nimport * as React from \"react\";\n\nimport { cn } from \"../util/cn.js\";\n\nconst Dialog = DialogPrimitive.Root;\n\nconst DialogTrigger = DialogPrimitive.Trigger;\n\nconst DialogPortal = DialogPrimitive.Portal;\n\nconst DialogClose = DialogPrimitive.Close;\n\nconst DialogOverlay = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Overlay>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Overlay\n ref={ref}\n className={cn(\n \"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0\",\n className,\n )}\n {...props}\n />\n));\nDialogOverlay.displayName = DialogPrimitive.Overlay.displayName;\n\nconst DialogContent = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>\n>(({ className, children, ...props }, ref) => (\n <DialogPortal>\n <DialogOverlay />\n <DialogPrimitive.Content\n ref={ref}\n className={cn(\n \"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg\",\n className,\n )}\n {...props}\n >\n {children}\n <DialogPrimitive.Close className=\"absolute right-4 top-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground\">\n <X className=\"h-4 w-4\" />\n <span className=\"sr-only\">Close</span>\n </DialogPrimitive.Close>\n </DialogPrimitive.Content>\n </DialogPortal>\n));\nDialogContent.displayName = DialogPrimitive.Content.displayName;\n\nconst DialogHeader = ({\n className,\n ...props\n}: React.HTMLAttributes<HTMLDivElement>) => (\n <div\n className={cn(\n \"flex flex-col space-y-1.5 text-center sm:text-left\",\n className,\n )}\n {...props}\n />\n);\nDialogHeader.displayName = \"DialogHeader\";\n\nconst DialogFooter = ({\n className,\n ...props\n}: React.HTMLAttributes<HTMLDivElement>) => (\n <div\n className={cn(\n \"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2\",\n className,\n )}\n {...props}\n />\n);\nDialogFooter.displayName = \"DialogFooter\";\n\nconst DialogTitle = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Title>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Title\n ref={ref}\n className={cn(\n \"text-lg font-semibold leading-none tracking-tight\",\n className,\n )}\n {...props}\n />\n));\nDialogTitle.displayName = DialogPrimitive.Title.displayName;\n\nconst DialogDescription = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Description>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Description\n ref={ref}\n className={cn(\"text-sm text-muted-foreground\", className)}\n {...props}\n />\n));\nDialogDescription.displayName = DialogPrimitive.Description.displayName;\n\nexport {\n Dialog,\n DialogClose,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogOverlay,\n DialogPortal,\n DialogTitle,\n DialogTrigger,\n};\n"],"names":["Dialog","DialogPrimitive","DialogTrigger","DialogPortal","DialogClose","DialogOverlay","React","className","props","ref","jsx","cn","DialogContent","children","jsxs","X","DialogHeader","DialogFooter","DialogTitle","DialogDescription"],"mappings":";;;;;AAMA,MAAMA,IAASC,EAAgB,MAEzBC,IAAgBD,EAAgB,SAEhCE,IAAeF,EAAgB,QAE/BG,IAAcH,EAAgB,OAE9BI,IAAgBC,EAAM,WAG1B,CAAC,EAAE,WAAAC,GAAW,GAAGC,EAAM,GAAGC,MAC1BC,gBAAAA,EAAA;AAAA,EAACT,EAAgB;AAAA,EAAhB;AAAA,IACC,KAAAQ;AAAA,IACA,WAAWE;AAAA,MACT;AAAA,MACAJ;AAAA,IACF;AAAA,IACC,GAAGC;AAAA,EAAA;AACN,CACD;AACDH,EAAc,cAAcJ,EAAgB,QAAQ;AAEpD,MAAMW,IAAgBN,EAAM,WAG1B,CAAC,EAAE,WAAAC,GAAW,UAAAM,GAAU,GAAGL,EAAM,GAAGC,MACpCK,gBAAAA,EAAAA,KAACX,GACC,EAAA,UAAA;AAAA,EAAAO,gBAAAA,EAAA,IAACL,GAAc,EAAA;AAAA,EACfS,gBAAAA,EAAA;AAAA,IAACb,EAAgB;AAAA,IAAhB;AAAA,MACC,KAAAQ;AAAA,MACA,WAAWE;AAAA,QACT;AAAA,QACAJ;AAAA,MACF;AAAA,MACC,GAAGC;AAAA,MAEH,UAAA;AAAA,QAAAK;AAAA,QACAC,gBAAAA,EAAA,KAAAb,EAAgB,OAAhB,EAAsB,WAAU,mRAC/B,UAAA;AAAA,UAACS,gBAAAA,EAAAA,IAAAK,GAAA,EAAE,WAAU,UAAU,CAAA;AAAA,UACtBL,gBAAAA,EAAA,IAAA,QAAA,EAAK,WAAU,WAAU,UAAK,QAAA,CAAA;AAAA,QAAA,EACjC,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AACF,GACF,CACD;AACDE,EAAc,cAAcX,EAAgB,QAAQ;AAEpD,MAAMe,IAAe,CAAC;AAAA,EACpB,WAAAT;AAAA,EACA,GAAGC;AACL,MACEE,gBAAAA,EAAA;AAAA,EAAC;AAAA,EAAA;AAAA,IACC,WAAWC;AAAA,MACT;AAAA,MACAJ;AAAA,IACF;AAAA,IACC,GAAGC;AAAA,EAAA;AACN;AAEFQ,EAAa,cAAc;AAE3B,MAAMC,IAAe,CAAC;AAAA,EACpB,WAAAV;AAAA,EACA,GAAGC;AACL,MACEE,gBAAAA,EAAA;AAAA,EAAC;AAAA,EAAA;AAAA,IACC,WAAWC;AAAA,MACT;AAAA,MACAJ;AAAA,IACF;AAAA,IACC,GAAGC;AAAA,EAAA;AACN;AAEFS,EAAa,cAAc;AAErB,MAAAC,IAAcZ,EAAM,WAGxB,CAAC,EAAE,WAAAC,GAAW,GAAGC,EAAM,GAAGC,MAC1BC,gBAAAA,EAAA;AAAA,EAACT,EAAgB;AAAA,EAAhB;AAAA,IACC,KAAAQ;AAAA,IACA,WAAWE;AAAA,MACT;AAAA,MACAJ;AAAA,IACF;AAAA,IACC,GAAGC;AAAA,EAAA;AACN,CACD;AACDU,EAAY,cAAcjB,EAAgB,MAAM;AAE1C,MAAAkB,IAAoBb,EAAM,WAG9B,CAAC,EAAE,WAAAC,GAAW,GAAGC,EAAM,GAAGC,MAC1BC,gBAAAA,EAAA;AAAA,EAACT,EAAgB;AAAA,EAAhB;AAAA,IACC,KAAAQ;AAAA,IACA,WAAWE,EAAG,iCAAiCJ,CAAS;AAAA,IACvD,GAAGC;AAAA,EAAA;AACN,CACD;AACDW,EAAkB,cAAclB,EAAgB,YAAY;"}