zudoku 0.3.0-dev.66 → 0.3.0-dev.68

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 (62) hide show
  1. package/dist/lib/components/context/ViewportAnchorContext.js +2 -1
  2. package/dist/lib/components/context/ViewportAnchorContext.js.map +1 -1
  3. package/dist/lib/plugins/markdown/Toc.js +2 -1
  4. package/dist/lib/plugins/markdown/Toc.js.map +1 -1
  5. package/dist/lib/plugins/openapi/ColorizedParam.js +2 -2
  6. package/dist/lib/plugins/openapi/ColorizedParam.js.map +1 -1
  7. package/dist/lib/plugins/openapi/StaggeredRender.js +3 -2
  8. package/dist/lib/plugins/openapi/StaggeredRender.js.map +1 -1
  9. package/dist/lib/plugins/openapi/playground/PathParams.js +1 -1
  10. package/dist/lib/plugins/openapi/playground/PathParams.js.map +1 -1
  11. package/dist/lib/plugins/openapi/playground/Playground.js +4 -3
  12. package/dist/lib/plugins/openapi/playground/Playground.js.map +1 -1
  13. package/dist/lib/plugins/openapi/playground/QueryParams.js +1 -1
  14. package/dist/lib/plugins/openapi/playground/QueryParams.js.map +1 -1
  15. package/dist/lib/plugins/openapi/playground/createUrl.js +5 -9
  16. package/dist/lib/plugins/openapi/playground/createUrl.js.map +1 -1
  17. package/dist/lib/util/requestIdle.d.ts +2 -0
  18. package/dist/lib/util/requestIdle.js +3 -0
  19. package/dist/lib/util/requestIdle.js.map +1 -0
  20. package/dist/lib/util/useScrollToAnchor.js +3 -2
  21. package/dist/lib/util/useScrollToAnchor.js.map +1 -1
  22. package/lib/{AnchorLink-C_pYhuZi.js → AnchorLink-61IZfWrS.js} +2 -2
  23. package/lib/{AnchorLink-C_pYhuZi.js.map → AnchorLink-61IZfWrS.js.map} +1 -1
  24. package/lib/{CategoryHeading-D5Q-X6lE.js → CategoryHeading-aW8CL0KA.js} +2 -2
  25. package/lib/{CategoryHeading-D5Q-X6lE.js.map → CategoryHeading-aW8CL0KA.js.map} +1 -1
  26. package/lib/{Combination-Cq0UkOXq.js → Combination-BbWKjDLe.js} +2 -2
  27. package/lib/{Combination-Cq0UkOXq.js.map → Combination-BbWKjDLe.js.map} +1 -1
  28. package/lib/{Input-DdAxw3vC.js → Input-BY0B_0qy.js} +3 -3
  29. package/lib/{Input-DdAxw3vC.js.map → Input-BY0B_0qy.js.map} +1 -1
  30. package/lib/{Markdown-DsCvZnhw.js → Markdown-BO5EsS-C.js} +748 -746
  31. package/lib/Markdown-BO5EsS-C.js.map +1 -0
  32. package/lib/{MdxPage-B_7x36CA.js → MdxPage-DEfyHwSx.js} +28 -28
  33. package/lib/MdxPage-DEfyHwSx.js.map +1 -0
  34. package/lib/{OperationList-Cv0GStt7.js → OperationList-VK1_1rzp.js} +167 -162
  35. package/lib/OperationList-VK1_1rzp.js.map +1 -0
  36. package/lib/{Spinner-DyDcSKPz.js → Spinner-6NfpF1CA.js} +56 -56
  37. package/lib/Spinner-6NfpF1CA.js.map +1 -0
  38. package/lib/{hook-Cz5jddRs.js → hook-gOGk1OUF.js} +4 -4
  39. package/lib/{hook-Cz5jddRs.js.map → hook-gOGk1OUF.js.map} +1 -1
  40. package/lib/{index-NGns0N9q.js → index-7W7DUZbY.js} +4 -4
  41. package/lib/{index-NGns0N9q.js.map → index-7W7DUZbY.js.map} +1 -1
  42. package/lib/zudoku.components.js +351 -351
  43. package/lib/zudoku.components.js.map +1 -1
  44. package/lib/zudoku.plugin-api-keys.js +4 -4
  45. package/lib/zudoku.plugin-custom-page.js +1 -1
  46. package/lib/zudoku.plugin-markdown.js +1 -1
  47. package/lib/zudoku.plugin-openapi.js +2 -2
  48. package/package.json +1 -1
  49. package/src/lib/components/context/ViewportAnchorContext.tsx +2 -1
  50. package/src/lib/plugins/markdown/Toc.tsx +2 -1
  51. package/src/lib/plugins/openapi/ColorizedParam.tsx +2 -2
  52. package/src/lib/plugins/openapi/StaggeredRender.tsx +3 -2
  53. package/src/lib/plugins/openapi/playground/PathParams.tsx +1 -1
  54. package/src/lib/plugins/openapi/playground/Playground.tsx +10 -7
  55. package/src/lib/plugins/openapi/playground/QueryParams.tsx +1 -3
  56. package/src/lib/plugins/openapi/playground/createUrl.ts +11 -14
  57. package/src/lib/util/requestIdle.ts +4 -0
  58. package/src/lib/util/useScrollToAnchor.ts +3 -2
  59. package/lib/Markdown-DsCvZnhw.js.map +0 -1
  60. package/lib/MdxPage-B_7x36CA.js.map +0 -1
  61. package/lib/OperationList-Cv0GStt7.js.map +0 -1
  62. package/lib/Spinner-DyDcSKPz.js.map +0 -1
@@ -1,9 +1,9 @@
1
1
  import { b as f, j as e, O as j } from "./jsx-runtime-BIr0WBt_.js";
2
- import { u as g, R as v } from "./hook-Cz5jddRs.js";
3
- import { u as w, a as p, I as b, S as k, b as K, c as N, d as E, e as A, f as h } from "./Input-DdAxw3vC.js";
4
- import { c as l, L as x, a as P } from "./Markdown-DsCvZnhw.js";
2
+ import { u as g, R as v } from "./hook-gOGk1OUF.js";
3
+ import { u as w, a as p, I as b, S as k, b as K, c as N, d as E, e as A, f as h } from "./Input-BY0B_0qy.js";
4
+ import { c as l, L as x, a as P } from "./Markdown-BO5EsS-C.js";
5
5
  import { u as m, x as S, y as I } from "./DevPortalProvider-BBhQ8kgI.js";
6
- import { B as c, p as C } from "./Combination-Cq0UkOXq.js";
6
+ import { B as c, p as C } from "./Combination-BbWKjDLe.js";
7
7
  import { useState as D } from "react";
8
8
  /**
9
9
  * @license lucide-react v0.378.0 - ISC
@@ -1,5 +1,5 @@
1
1
  import { j as m } from "./jsx-runtime-BIr0WBt_.js";
2
- import { P as o } from "./Markdown-DsCvZnhw.js";
2
+ import { P as o } from "./Markdown-BO5EsS-C.js";
3
3
  const l = (s) => ({
4
4
  getRoutes: () => s.map(({ path: e, element: t }) => ({
5
5
  path: e,
@@ -9,7 +9,7 @@ const f = (t, e) => {
9
9
  return {
10
10
  path: i.at(-1) === "index" ? i.slice(0, -1).join("/") : s,
11
11
  lazy: async () => {
12
- const { MdxPage: u } = await import("./MdxPage-B_7x36CA.js"), { default: c, ...l } = await m();
12
+ const { MdxPage: u } = await import("./MdxPage-DEfyHwSx.js"), { default: c, ...l } = await m();
13
13
  return {
14
14
  element: /* @__PURE__ */ o.jsx(
15
15
  u,
@@ -1,8 +1,8 @@
1
1
  import "./jsx-runtime-BIr0WBt_.js";
2
- import { o as n } from "./index-NGns0N9q.js";
2
+ import { o as n } from "./index-7W7DUZbY.js";
3
3
  import "./urql-DMlBWUKL.js";
4
4
  import "zudoku/openapi-worker";
5
- import "./Markdown-DsCvZnhw.js";
5
+ import "./Markdown-BO5EsS-C.js";
6
6
  import "./router-BiRCp01d.js";
7
7
  export {
8
8
  n as openApiPlugin
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zudoku",
3
- "version": "0.3.0-dev.66",
3
+ "version": "0.3.0-dev.68",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -8,6 +8,7 @@ import {
8
8
  useRef,
9
9
  useState,
10
10
  } from "react";
11
+ import { requestIdle } from "../../util/requestIdle.js";
11
12
 
12
13
  type AnchorContextType = {
13
14
  activeAnchor?: string;
@@ -95,7 +96,7 @@ export const ViewportAnchorProvider = ({
95
96
  // reset the active anchor when we reach the top
96
97
  setActiveAnchor("");
97
98
  } else if (hasReachedBottom) {
98
- requestIdleCallback(() => {
99
+ requestIdle(() => {
99
100
  // set the last anchor when we reach the bottom
100
101
  const lastItem = Array.from(elements).pop();
101
102
  setActiveAnchor(lastItem?.id ?? "");
@@ -10,6 +10,7 @@ import {
10
10
  import { AnchorLink } from "../../components/AnchorLink.js";
11
11
  import { useViewportAnchor } from "../../components/context/ViewportAnchorContext.js";
12
12
  import { cn } from "../../util/cn.js";
13
+ import { requestIdle } from "../../util/requestIdle.js";
13
14
 
14
15
  const DATA_ANCHOR_ATTR = "data-active";
15
16
 
@@ -83,7 +84,7 @@ export const Toc = ({ entries }: { entries: TocEntry[] }) => {
83
84
  if (paintedOnce.current) return;
84
85
 
85
86
  // after all is painted, the indicator should animate
86
- requestIdleCallback(() => {
87
+ requestIdle(() => {
87
88
  paintedOnce.current = true;
88
89
  });
89
90
  }, [activeAnchor]);
@@ -31,8 +31,8 @@ export const ColorizedParam = ({
31
31
  onClick?: () => void;
32
32
  }) => {
33
33
  const ref = useRef<HTMLSpanElement>(null);
34
- const normalized = name.replace("{", "").replace("}", "");
35
- const normalizedSlug = slug?.replace("{", "").replace("}", "");
34
+ const normalized = name.replace(/[{}]/g, "");
35
+ const normalizedSlug = slug?.replace(/[{}]/g, "");
36
36
  const color = usePastellizedColor(normalized);
37
37
 
38
38
  const borderColor = `hsl(${color} / ${borderOpacity})`;
@@ -6,6 +6,7 @@ import {
6
6
  useEffect,
7
7
  useState,
8
8
  } from "react";
9
+ import { cancelIdle, requestIdle } from "../../util/requestIdle.js";
9
10
 
10
11
  export const StaggeredRenderContext = createContext({ stagger: false });
11
12
 
@@ -18,11 +19,11 @@ const StaggeredRender = ({ children }: { children: ReactNode[] }) => {
18
19
  return;
19
20
  }
20
21
 
21
- const x = window.requestIdleCallback(() => {
22
+ const idle = requestIdle(() => {
22
23
  setRenderAll(true);
23
24
  });
24
25
 
25
- return () => window.cancelIdleCallback(x);
26
+ return () => cancelIdle(idle);
26
27
  }, [renderAll]);
27
28
 
28
29
  return !renderAll ? Children.toArray(children).slice(0, 3) : children;
@@ -38,7 +38,7 @@ export const PathParams = ({
38
38
  <ColorizedParam
39
39
  slug={part.name}
40
40
  name={part.name}
41
- backgroundOpacity="0"
41
+ backgroundOpacity="25%"
42
42
  borderOpacity={field.value ? "100%" : "0"}
43
43
  className={cn(
44
44
  "font-mono text-xs m-2",
@@ -154,16 +154,18 @@ export const Playground = ({
154
154
 
155
155
  const path = url.split("/").map((part, i, arr) => {
156
156
  const isPathParam = part.startsWith("{") && part.endsWith("}");
157
- const value = formState.pathParams.find(
158
- (p) => p.name === part.slice(1, -1),
159
- )?.value;
157
+ const replaced = part.replace(/[{}]/g, "");
158
+ const value = formState.pathParams.find((p) => p.name === replaced)?.value;
160
159
 
161
160
  const pathParamValue = value ? (
162
- <ColorizedParam backgroundOpacity="0%" name={part} slug={part}>
161
+ <ColorizedParam backgroundOpacity="25%" name={part} slug={part}>
163
162
  {value}
164
163
  </ColorizedParam>
165
164
  ) : (
166
- <span className="underline decoration-wavy decoration-red-500">
165
+ <span
166
+ className="underline decoration-wavy decoration-red-500"
167
+ title={`Missing value for path parameter \`${replaced}\``}
168
+ >
167
169
  {part}
168
170
  </span>
169
171
  );
@@ -186,9 +188,10 @@ export const Playground = ({
186
188
 
187
189
  const urlQueryParams = formState.queryParams
188
190
  .filter((p) => p.active)
189
- .map((p) => (
191
+ .map((p, i, arr) => (
190
192
  <Fragment key={p.name}>
191
- {p.name}={p.value}
193
+ {p.name}={encodeURIComponent(p.value).replaceAll("%20", "+")}
194
+ {i < arr.length - 1 && "&"}
192
195
  <wbr />
193
196
  </Fragment>
194
197
  ));
@@ -57,9 +57,7 @@ export const QueryParams = ({
57
57
  title={requiredFields[i] ? "Required field" : undefined}
58
58
  >
59
59
  {field.value}
60
- {requiredFields[i] && (
61
- <sup className="text-destructive">*</sup>
62
- )}
60
+ {requiredFields[i] && <sup>&nbsp;*</sup>}
63
61
  </label>
64
62
  </InlineInput>
65
63
  )}
@@ -1,22 +1,19 @@
1
1
  import type { PlaygroundForm } from "./Playground.js";
2
2
 
3
3
  export const createUrl = (host: string, path: string, data: PlaygroundForm) => {
4
- const url = new URL(
5
- host +
6
- path
7
- .split("/")
8
- .map((v) =>
9
- v.startsWith("{") && v.endsWith("}")
10
- ? data.pathParams.find((part) => part.name === v.slice(1, -1))
11
- ?.value ?? v
12
- : v,
13
- )
14
- .join("/"),
4
+ const filledPath = path.replace(
5
+ /\{(\w+)}/g,
6
+ (_, key) =>
7
+ data.pathParams.find((part) => part.name === key)?.value || `{${key}}`,
15
8
  );
16
9
 
17
- data.queryParams.forEach((param) => {
18
- url.searchParams.set(param.name, param.value);
19
- });
10
+ const url = new URL(filledPath, host);
11
+
12
+ data.queryParams
13
+ .filter((param) => param.active)
14
+ .forEach((param) => {
15
+ url.searchParams.set(param.name, param.value);
16
+ });
20
17
 
21
18
  return url;
22
19
  };
@@ -0,0 +1,4 @@
1
+ export const requestIdle =
2
+ requestIdleCallback ?? ((cb: IdleRequestCallback) => setTimeout(cb, 1));
3
+
4
+ export const cancelIdle = cancelIdleCallback ?? clearTimeout;
@@ -1,6 +1,7 @@
1
1
  import { useEffect } from "react";
2
2
  import { useLocation } from "react-router-dom";
3
3
  import { useViewportAnchor } from "../components/context/ViewportAnchorContext.js";
4
+ import { requestIdle } from "./requestIdle.js";
4
5
 
5
6
  export const useScrollToAnchor = () => {
6
7
  const location = useLocation();
@@ -16,7 +17,7 @@ export const useScrollToAnchor = () => {
16
17
  // on page navigation element might be in DOM but not yet scrollable, so wait for a frame
17
18
  requestAnimationFrame(() => {
18
19
  element.scrollIntoView();
19
- requestIdleCallback(() => setActiveAnchor(hash));
20
+ requestIdle(() => setActiveAnchor(hash));
20
21
  });
21
22
  return;
22
23
  }
@@ -27,7 +28,7 @@ export const useScrollToAnchor = () => {
27
28
  if (!element) return;
28
29
 
29
30
  element.scrollIntoView();
30
- requestIdleCallback(() => setActiveAnchor(hash));
31
+ requestIdle(() => setActiveAnchor(hash));
31
32
  obs.disconnect();
32
33
  });
33
34