@gitbook/react-openapi 1.5.5 → 1.5.6

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 (50) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/InteractiveSection.js +52 -30
  3. package/dist/Markdown.js +5 -1
  4. package/dist/OpenAPICodeSample.js +45 -9
  5. package/dist/OpenAPICodeSampleInteractive.js +41 -15
  6. package/dist/OpenAPICodeSampleSelector.js +34 -14
  7. package/dist/OpenAPICopyButton.js +21 -15
  8. package/dist/OpenAPIDisclosure.js +18 -10
  9. package/dist/OpenAPIDisclosureGroup.js +56 -30
  10. package/dist/OpenAPIExample.js +6 -4
  11. package/dist/OpenAPIMediaType.js +38 -17
  12. package/dist/OpenAPIOperation.d.ts +2 -2
  13. package/dist/OpenAPIOperation.js +26 -12
  14. package/dist/OpenAPIOperationContext.d.ts +2 -2
  15. package/dist/OpenAPIOperationContext.js +5 -3
  16. package/dist/OpenAPIPath.js +14 -5
  17. package/dist/OpenAPIPathItem.js +26 -12
  18. package/dist/OpenAPIPathMultipleServers.js +29 -12
  19. package/dist/OpenAPIPrefillContextProvider.d.ts +2 -1
  20. package/dist/OpenAPIPrefillContextProvider.js +5 -3
  21. package/dist/OpenAPIRequestBody.js +20 -10
  22. package/dist/OpenAPIRequestBodyHeaderType.js +5 -3
  23. package/dist/OpenAPIRequiredScopes.js +41 -26
  24. package/dist/OpenAPIResponse.js +34 -19
  25. package/dist/OpenAPIResponseExample.js +25 -8
  26. package/dist/OpenAPIResponseExampleContent.js +39 -18
  27. package/dist/OpenAPIResponses.js +40 -17
  28. package/dist/OpenAPISchema.js +212 -88
  29. package/dist/OpenAPISchemaName.js +44 -24
  30. package/dist/OpenAPISchemaServer.js +10 -2
  31. package/dist/OpenAPISecurities.js +125 -57
  32. package/dist/OpenAPISelect.js +27 -18
  33. package/dist/OpenAPISpec.js +27 -12
  34. package/dist/OpenAPITooltip.js +14 -6
  35. package/dist/OpenAPIWebhook.d.ts +2 -2
  36. package/dist/OpenAPIWebhook.js +23 -11
  37. package/dist/OpenAPIWebhookExample.js +18 -8
  38. package/dist/ScalarApiButton.js +50 -29
  39. package/dist/StaticSection.js +49 -15
  40. package/dist/common/OpenAPIColumnSpec.js +21 -9
  41. package/dist/common/OpenAPIOperationDescription.js +12 -6
  42. package/dist/common/OpenAPIStability.js +6 -3
  43. package/dist/common/OpenAPISummary.js +23 -12
  44. package/dist/formatPath.js +7 -4
  45. package/dist/schemas/OpenAPISchemaItem.js +18 -11
  46. package/dist/schemas/OpenAPISchemas.d.ts +2 -2
  47. package/dist/schemas/OpenAPISchemas.js +55 -31
  48. package/dist/translate.js +4 -6
  49. package/dist/util/example.js +6 -1
  50. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @gitbook/react-openapi
2
2
 
3
+ ## 1.5.6
4
+
5
+ ### Patch Changes
6
+
7
+ - bf63045: Compile JSX
8
+
3
9
  ## 1.5.5
4
10
 
5
11
  ### Patch Changes
@@ -5,6 +5,7 @@ import { Section, SectionBody, SectionHeader, SectionHeaderContent } from "./Sta
5
5
  import { OpenAPISelect, OpenAPISelectItem, useSelectState } from "./OpenAPISelect.js";
6
6
  import clsx from "classnames";
7
7
  import { useRef } from "react";
8
+ import { jsx, jsxs } from "react/jsx-runtime";
8
9
  import { mergeProps, useButton, useDisclosure, useFocusRing } from "react-aria";
9
10
  import { useDisclosureState } from "react-stately";
10
11
 
@@ -23,36 +24,57 @@ function InteractiveSection(props) {
23
24
  const { isFocusVisible, focusProps } = useFocusRing();
24
25
  const store = useSelectState(stateKey, defaultTab);
25
26
  const selectedTab = tabs.find((tab) => tab.key === store.key) ?? tabs[0];
26
- return <Section id={id} className={clsx("openapi-section", toggeable ? "openapi-section-toggeable" : null, className, toggeable ? `${className}-${state.isExpanded ? "opened" : "closed"}` : null)}>
27
- {header ? <SectionHeader onClick={() => {
28
- if (toggeable) state.toggle();
29
- }} className={className}>
30
- <SectionHeaderContent className={className}>
31
- {selectedTab?.body && toggeable ? <button {...mergeProps(buttonProps, focusProps)} ref={triggerRef} className={clsx("openapi-section-toggle", `${className}-toggle`)} style={{ outline: isFocusVisible ? "2px solid rgb(var(--primary-color-500) / 0.4)" : "none" }}>
32
- {toggleIcon}
33
- </button> : null}
34
- {header}
35
- </SectionHeaderContent>
36
- {}
37
- <div className={clsx("openapi-section-header-controls", `${className}-header-controls`)} onClick={(event) => {
38
- event.stopPropagation();
39
- }}>
40
- {tabs.length > 0 ? <OpenAPISelect stateKey={stateKey} items={tabs} onChange={() => {
41
- state.expand();
42
- }} icon={selectIcon} placement="bottom end">
43
- {tabs.map((tab) => <OpenAPISelectItem key={tab.key} id={tab.key} value={tab}>
44
- {tab.label}
45
- </OpenAPISelectItem>)}
46
- </OpenAPISelect> : null}
47
- </div>
48
- </SectionHeader> : null}
49
- {(!toggeable || state.isExpanded) && selectedTab?.body ? <SectionBody ref={panelRef} {...panelProps} className={className}>
50
- {selectedTab?.body}
51
- </SectionBody> : null}
52
- {overlay ? <div className={clsx("openapi-section-overlay", `${className}-overlay`)}>
53
- {overlay}
54
- </div> : null}
55
- </Section>;
27
+ return /* @__PURE__ */ jsxs(Section, {
28
+ id,
29
+ className: clsx("openapi-section", toggeable ? "openapi-section-toggeable" : null, className, toggeable ? `${className}-${state.isExpanded ? "opened" : "closed"}` : null),
30
+ children: [
31
+ header ? /* @__PURE__ */ jsxs(SectionHeader, {
32
+ onClick: () => {
33
+ if (toggeable) state.toggle();
34
+ },
35
+ className,
36
+ children: [/* @__PURE__ */ jsxs(SectionHeaderContent, {
37
+ className,
38
+ children: [selectedTab?.body && toggeable ? /* @__PURE__ */ jsx("button", {
39
+ ...mergeProps(buttonProps, focusProps),
40
+ ref: triggerRef,
41
+ className: clsx("openapi-section-toggle", `${className}-toggle`),
42
+ style: { outline: isFocusVisible ? "2px solid rgb(var(--primary-color-500) / 0.4)" : "none" },
43
+ children: toggleIcon
44
+ }) : null, header]
45
+ }), /* @__PURE__ */ jsx("div", {
46
+ className: clsx("openapi-section-header-controls", `${className}-header-controls`),
47
+ onClick: (event) => {
48
+ event.stopPropagation();
49
+ },
50
+ children: tabs.length > 0 ? /* @__PURE__ */ jsx(OpenAPISelect, {
51
+ stateKey,
52
+ items: tabs,
53
+ onChange: () => {
54
+ state.expand();
55
+ },
56
+ icon: selectIcon,
57
+ placement: "bottom end",
58
+ children: tabs.map((tab) => /* @__PURE__ */ jsx(OpenAPISelectItem, {
59
+ id: tab.key,
60
+ value: tab,
61
+ children: tab.label
62
+ }, tab.key))
63
+ }) : null
64
+ })]
65
+ }) : null,
66
+ (!toggeable || state.isExpanded) && selectedTab?.body ? /* @__PURE__ */ jsx(SectionBody, {
67
+ ref: panelRef,
68
+ ...panelProps,
69
+ className,
70
+ children: selectedTab?.body
71
+ }) : null,
72
+ overlay ? /* @__PURE__ */ jsx("div", {
73
+ className: clsx("openapi-section-overlay", `${className}-overlay`),
74
+ children: overlay
75
+ }) : null
76
+ ]
77
+ });
56
78
  }
57
79
 
58
80
  //#endregion
package/dist/Markdown.js CHANGED
@@ -1,9 +1,13 @@
1
1
  import clsx from "classnames";
2
+ import { jsx } from "react/jsx-runtime";
2
3
 
3
4
  //#region src/Markdown.tsx
4
5
  function Markdown(props) {
5
6
  const { source, className } = props;
6
- return <div className={clsx("openapi-markdown", className)} dangerouslySetInnerHTML={{ __html: source }} />;
7
+ return /* @__PURE__ */ jsx("div", {
8
+ className: clsx("openapi-markdown", className),
9
+ dangerouslySetInnerHTML: { __html: source }
10
+ });
7
11
  }
8
12
 
9
13
  //#endregion
@@ -8,6 +8,7 @@ import { OpenAPICodeSampleBody } from "./OpenAPICodeSampleSelector.js";
8
8
  import { resolvePrefillCodePlaceholderFromSecurityScheme, resolveURLWithPrefillCodePlaceholdersFromServer } from "./util/tryit-prefill.js";
9
9
  import { ScalarApiButton } from "./ScalarApiButton.js";
10
10
  import { codeSampleGenerators, parseHostAndPath } from "./code-samples.js";
11
+ import { jsx, jsxs } from "react/jsx-runtime";
11
12
 
12
13
  //#region src/OpenAPICodeSample.tsx
13
14
  const CUSTOM_CODE_SAMPLES_KEYS = [
@@ -26,7 +27,12 @@ function OpenAPICodeSample(props) {
26
27
  if (data["x-codeSamples"] === false && !customCodeSamples) return null;
27
28
  const samples = customCodeSamples ?? generateCodeSamples(props);
28
29
  if (samples.length === 0) return null;
29
- return <OpenAPICodeSampleBody context={getOpenAPIClientContext(context)} data={data} items={samples} selectIcon={context.icons.chevronDown} />;
30
+ return /* @__PURE__ */ jsx(OpenAPICodeSampleBody, {
31
+ context: getOpenAPIClientContext(context),
32
+ data,
33
+ items: samples,
34
+ selectIcon: context.icons.chevronDown
35
+ });
30
36
  }
31
37
  /**
32
38
  * Generate code samples for the operation.
@@ -102,8 +108,17 @@ function generateCodeSamples(props) {
102
108
  return {
103
109
  key: `default-${generator.id}`,
104
110
  label: generator.label,
105
- body: <OpenAPIMediaTypeExamplesBody method={data.method} path={data.path} renderers={renderers} blockKey={context.blockKey} />,
106
- footer: <OpenAPICodeSampleFooter renderers={renderers} data={data} context={context} />
111
+ body: /* @__PURE__ */ jsx(OpenAPIMediaTypeExamplesBody, {
112
+ method: data.method,
113
+ path: data.path,
114
+ renderers,
115
+ blockKey: context.blockKey
116
+ }),
117
+ footer: /* @__PURE__ */ jsx(OpenAPICodeSampleFooter, {
118
+ renderers,
119
+ data,
120
+ context
121
+ })
107
122
  };
108
123
  }
109
124
  return {
@@ -121,7 +136,11 @@ function generateCodeSamples(props) {
121
136
  }),
122
137
  syntax: generator.syntax
123
138
  }),
124
- footer: <OpenAPICodeSampleFooter data={data} renderers={[]} context={context} />
139
+ footer: /* @__PURE__ */ jsx(OpenAPICodeSampleFooter, {
140
+ data,
141
+ renderers: [],
142
+ context
143
+ })
125
144
  };
126
145
  });
127
146
  }
@@ -133,10 +152,23 @@ function OpenAPICodeSampleFooter(props) {
133
152
  const hasMultipleMediaTypes = renderers.length > 1 || renderers.some((renderer) => renderer.examples.length > 0);
134
153
  if (hideTryItPanel && !hasMultipleMediaTypes) return null;
135
154
  if (!validateHttpMethod(method) || !hasMultipleMediaTypes && servers.length === 0) return null;
136
- return <div className="openapi-codesample-footer">
137
- {hasMultipleMediaTypes ? <OpenAPIMediaTypeExamplesSelector method={data.method} path={data.path} renderers={renderers} selectIcon={context.icons.chevronDown} blockKey={context.blockKey} /> : <span />}
138
- {!hideTryItPanel && servers.length > 0 && <ScalarApiButton context={getOpenAPIClientContext(context)} method={method} path={path} securities={securities} servers={servers} specUrl={specUrl} />}
139
- </div>;
155
+ return /* @__PURE__ */ jsxs("div", {
156
+ className: "openapi-codesample-footer",
157
+ children: [hasMultipleMediaTypes ? /* @__PURE__ */ jsx(OpenAPIMediaTypeExamplesSelector, {
158
+ method: data.method,
159
+ path: data.path,
160
+ renderers,
161
+ selectIcon: context.icons.chevronDown,
162
+ blockKey: context.blockKey
163
+ }) : /* @__PURE__ */ jsx("span", {}), !hideTryItPanel && servers.length > 0 && /* @__PURE__ */ jsx(ScalarApiButton, {
164
+ context: getOpenAPIClientContext(context),
165
+ method,
166
+ path,
167
+ securities,
168
+ servers,
169
+ specUrl
170
+ })]
171
+ });
140
172
  }
141
173
  /**
142
174
  * Get custom code samples for the operation.
@@ -155,7 +187,11 @@ function getCustomCodeSamples(props) {
155
187
  code: sample.source,
156
188
  syntax: sample.lang
157
189
  }),
158
- footer: <OpenAPICodeSampleFooter renderers={[]} data={data} context={context} />
190
+ footer: /* @__PURE__ */ jsx(OpenAPICodeSampleFooter, {
191
+ renderers: [],
192
+ data,
193
+ context
194
+ })
159
195
  }));
160
196
  });
161
197
  return customCodeSamples;
@@ -3,6 +3,7 @@
3
3
 
4
4
  import { createStateKey } from "./utils.js";
5
5
  import { OpenAPISelect, OpenAPISelectItem, useSelectState } from "./OpenAPISelect.js";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
6
7
 
7
8
  //#region src/OpenAPICodeSampleInteractive.tsx
8
9
  function OpenAPIMediaTypeExamplesSelector(props) {
@@ -11,10 +12,19 @@ function OpenAPIMediaTypeExamplesSelector(props) {
11
12
  const stateKey = createStateKey("request-body-media-type", blockKey);
12
13
  const state = useSelectState(stateKey, renderers[0].mediaType);
13
14
  const selected = renderers.find((r) => r.mediaType === state.key) || renderers[0];
14
- return <div className="openapi-codesample-selectors">
15
- <MediaTypeSelector selectIcon={selectIcon} stateKey={stateKey} renderers={renderers} />
16
- <ExamplesSelector selectIcon={selectIcon} method={method} path={path} renderer={selected} />
17
- </div>;
15
+ return /* @__PURE__ */ jsxs("div", {
16
+ className: "openapi-codesample-selectors",
17
+ children: [/* @__PURE__ */ jsx(MediaTypeSelector, {
18
+ selectIcon,
19
+ stateKey,
20
+ renderers
21
+ }), /* @__PURE__ */ jsx(ExamplesSelector, {
22
+ selectIcon,
23
+ method,
24
+ path,
25
+ renderer: selected
26
+ })]
27
+ });
18
28
  }
19
29
  function MediaTypeSelector(props) {
20
30
  const { renderers, stateKey, selectIcon } = props;
@@ -23,11 +33,17 @@ function MediaTypeSelector(props) {
23
33
  key: renderer.mediaType,
24
34
  label: renderer.mediaType
25
35
  }));
26
- return <OpenAPISelect items={items} icon={selectIcon} stateKey={stateKey} placement="bottom start">
27
- {items.map((item) => <OpenAPISelectItem key={item.key} id={item.key} value={item}>
28
- {item.label}
29
- </OpenAPISelectItem>)}
30
- </OpenAPISelect>;
36
+ return /* @__PURE__ */ jsx(OpenAPISelect, {
37
+ items,
38
+ icon: selectIcon,
39
+ stateKey,
40
+ placement: "bottom start",
41
+ children: items.map((item) => /* @__PURE__ */ jsx(OpenAPISelectItem, {
42
+ id: item.key,
43
+ value: item,
44
+ children: item.label
45
+ }, item.key))
46
+ });
31
47
  }
32
48
  function ExamplesSelector(props) {
33
49
  const { method, path, renderer, selectIcon } = props;
@@ -36,11 +52,17 @@ function ExamplesSelector(props) {
36
52
  key: index,
37
53
  label: example.example.summary || `Example ${index + 1}`
38
54
  }));
39
- return <OpenAPISelect items={items} icon={selectIcon} stateKey={`media-type-sample-${renderer.mediaType}-${method}-${path}`} placement="bottom start">
40
- {items.map((item) => <OpenAPISelectItem key={item.key} id={item.key} value={item}>
41
- {item.label}
42
- </OpenAPISelectItem>)}
43
- </OpenAPISelect>;
55
+ return /* @__PURE__ */ jsx(OpenAPISelect, {
56
+ items,
57
+ icon: selectIcon,
58
+ stateKey: `media-type-sample-${renderer.mediaType}-${method}-${path}`,
59
+ placement: "bottom start",
60
+ children: items.map((item) => /* @__PURE__ */ jsx(OpenAPISelectItem, {
61
+ id: item.key,
62
+ value: item,
63
+ children: item.label
64
+ }, item.key))
65
+ });
44
66
  }
45
67
  function OpenAPIMediaTypeExamplesBody(props) {
46
68
  const { renderers, method, path, blockKey } = props;
@@ -48,7 +70,11 @@ function OpenAPIMediaTypeExamplesBody(props) {
48
70
  const mediaTypeState = useSelectState(createStateKey("request-body-media-type", blockKey), renderers[0].mediaType);
49
71
  const selected = renderers.find((r) => r.mediaType === mediaTypeState.key) ?? renderers[0];
50
72
  if (selected.examples.length === 0) return selected.element;
51
- return <ExamplesBody method={method} path={path} renderer={selected} />;
73
+ return /* @__PURE__ */ jsx(ExamplesBody, {
74
+ method,
75
+ path,
76
+ renderer: selected
77
+ });
52
78
  }
53
79
  function ExamplesBody(props) {
54
80
  const { method, path, renderer } = props;
@@ -6,6 +6,7 @@ import { getOrCreateStoreByKey } from "./getOrCreateStoreByKey.js";
6
6
  import { OpenAPISelect, OpenAPISelectItem } from "./OpenAPISelect.js";
7
7
  import { OpenAPIPath } from "./OpenAPIPath.js";
8
8
  import { useCallback } from "react";
9
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
9
10
  import { useStore } from "zustand";
10
11
 
11
12
  //#region src/OpenAPICodeSampleSelector.tsx
@@ -18,14 +19,25 @@ function useCodeSampleState(initialKey = "default") {
18
19
  }
19
20
  function OpenAPICodeSampleHeader(props) {
20
21
  const { data, items, selectIcon, context } = props;
21
- return <>
22
- <OpenAPIPath context={context} canCopy={false} withServer={false} data={data} />
23
- {items.length > 1 ? <OpenAPISelect icon={selectIcon} items={items} stateKey="codesample" placement="bottom end">
24
- {items.map((item) => <OpenAPISelectItem key={item.key} id={item.key} value={item}>
25
- {item.label}
26
- </OpenAPISelectItem>)}
27
- </OpenAPISelect> : items[0] ? <span className="openapi-codesample-label">{items[0].label}</span> : null}
28
- </>;
22
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(OpenAPIPath, {
23
+ context,
24
+ canCopy: false,
25
+ withServer: false,
26
+ data
27
+ }), items.length > 1 ? /* @__PURE__ */ jsx(OpenAPISelect, {
28
+ icon: selectIcon,
29
+ items,
30
+ stateKey: "codesample",
31
+ placement: "bottom end",
32
+ children: items.map((item) => /* @__PURE__ */ jsx(OpenAPISelectItem, {
33
+ id: item.key,
34
+ value: item,
35
+ children: item.label
36
+ }, item.key))
37
+ }) : items[0] ? /* @__PURE__ */ jsx("span", {
38
+ className: "openapi-codesample-label",
39
+ children: items[0].label
40
+ }) : null] });
29
41
  }
30
42
  function OpenAPICodeSampleBody(props) {
31
43
  const { items, data, selectIcon, context } = props;
@@ -33,12 +45,20 @@ function OpenAPICodeSampleBody(props) {
33
45
  const state = useCodeSampleState(items[0]?.key);
34
46
  const selected = items.find((item) => item.key === state.key) || items[0];
35
47
  if (!selected) return null;
36
- return <StaticSection header={<OpenAPICodeSampleHeader context={context} selectIcon={selectIcon} data={data} items={items} />} className="openapi-codesample">
37
- <div id={selected.key} className="openapi-codesample-panel">
38
- {selected.body ? selected.body : null}
39
- {selected.footer ? selected.footer : null}
40
- </div>
41
- </StaticSection>;
48
+ return /* @__PURE__ */ jsx(StaticSection, {
49
+ header: /* @__PURE__ */ jsx(OpenAPICodeSampleHeader, {
50
+ context,
51
+ selectIcon,
52
+ data,
53
+ items
54
+ }),
55
+ className: "openapi-codesample",
56
+ children: /* @__PURE__ */ jsxs("div", {
57
+ id: selected.key,
58
+ className: "openapi-codesample-panel",
59
+ children: [selected.body ? selected.body : null, selected.footer ? selected.footer : null]
60
+ })
61
+ });
42
62
  }
43
63
 
44
64
  //#endregion
@@ -5,6 +5,7 @@ import { t } from "./translate.js";
5
5
  import { OpenAPITooltip } from "./OpenAPITooltip.js";
6
6
  import clsx from "classnames";
7
7
  import { useState } from "react";
8
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
8
9
  import { Button } from "react-aria-components";
9
10
 
10
11
  //#region src/OpenAPICopyButton.tsx
@@ -23,21 +24,26 @@ function OpenAPICopyButton(props) {
23
24
  }, 2e3);
24
25
  });
25
26
  };
26
- return <OpenAPITooltip isDisabled={!withTooltip} isOpen={isOpen} onOpenChange={setIsOpen}>
27
- <Button type="button" preventFocusOnPress onPress={(e) => {
28
- handleCopy();
29
- onPress?.(e);
30
- }} className={clsx("openapi-copy-button", className)} {...props}>
31
- {children}
32
- </Button>
33
-
34
- <OpenAPITooltip.Content isOpen={isOpen} onOpenChange={setIsOpen}>
35
- {copied ? <>
36
- {context.icons.check}
37
- {t(context.translation, "copied")}
38
- </> : label || t(context.translation, "copy_to_clipboard")}
39
- </OpenAPITooltip.Content>
40
- </OpenAPITooltip>;
27
+ return /* @__PURE__ */ jsxs(OpenAPITooltip, {
28
+ isDisabled: !withTooltip,
29
+ isOpen,
30
+ onOpenChange: setIsOpen,
31
+ children: [/* @__PURE__ */ jsx(Button, {
32
+ type: "button",
33
+ preventFocusOnPress: true,
34
+ onPress: (e) => {
35
+ handleCopy();
36
+ onPress?.(e);
37
+ },
38
+ className: clsx("openapi-copy-button", className),
39
+ ...props,
40
+ children
41
+ }), /* @__PURE__ */ jsx(OpenAPITooltip.Content, {
42
+ isOpen,
43
+ onOpenChange: setIsOpen,
44
+ children: copied ? /* @__PURE__ */ jsxs(Fragment$1, { children: [context.icons.check, t(context.translation, "copied")] }) : label || t(context.translation, "copy_to_clipboard")
45
+ })]
46
+ });
41
47
  }
42
48
 
43
49
  //#endregion
@@ -3,6 +3,7 @@
3
3
 
4
4
  import clsx from "classnames";
5
5
  import { useState } from "react";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
6
7
  import { Button, Disclosure, DisclosurePanel } from "react-aria-components";
7
8
 
8
9
  //#region src/OpenAPIDisclosure.tsx
@@ -12,16 +13,23 @@ import { Button, Disclosure, DisclosurePanel } from "react-aria-components";
12
13
  function OpenAPIDisclosure(props) {
13
14
  const { icon, header, label, children, className, defaultExpanded = false } = props;
14
15
  const [isExpanded, setIsExpanded] = useState(defaultExpanded);
15
- return <Disclosure className={clsx("openapi-disclosure", className)} isExpanded={isExpanded} onExpandedChange={setIsExpanded}>
16
- <Button slot="trigger" className="openapi-disclosure-trigger" style={({ isFocusVisible }) => ({ outline: isFocusVisible ? "2px solid rgb(var(--primary-color-500) / 0.4)" : "none" })}>
17
- {header}
18
- <div className="openapi-disclosure-trigger-label">
19
- {label ? <span>{typeof label === "function" ? label(isExpanded) : label}</span> : null}
20
- {icon}
21
- </div>
22
- </Button>
23
- {isExpanded ? <DisclosurePanel className="openapi-disclosure-panel">{children}</DisclosurePanel> : null}
24
- </Disclosure>;
16
+ return /* @__PURE__ */ jsxs(Disclosure, {
17
+ className: clsx("openapi-disclosure", className),
18
+ isExpanded,
19
+ onExpandedChange: setIsExpanded,
20
+ children: [/* @__PURE__ */ jsxs(Button, {
21
+ slot: "trigger",
22
+ className: "openapi-disclosure-trigger",
23
+ style: ({ isFocusVisible }) => ({ outline: isFocusVisible ? "2px solid rgb(var(--primary-color-500) / 0.4)" : "none" }),
24
+ children: [header, /* @__PURE__ */ jsxs("div", {
25
+ className: "openapi-disclosure-trigger-label",
26
+ children: [label ? /* @__PURE__ */ jsx("span", { children: typeof label === "function" ? label(isExpanded) : label }) : null, icon]
27
+ })]
28
+ }), isExpanded ? /* @__PURE__ */ jsx(DisclosurePanel, {
29
+ className: "openapi-disclosure-panel",
30
+ children
31
+ }) : null]
32
+ });
25
33
  }
26
34
 
27
35
  //#endregion
@@ -5,6 +5,7 @@ import { OpenAPISelect, OpenAPISelectItem, useSelectState } from "./OpenAPISelec
5
5
  import { getOrCreateDisclosureStoreByKey } from "./getOrCreateDisclosureStoreByKey.js";
6
6
  import clsx from "classnames";
7
7
  import { createContext, useContext, useRef } from "react";
8
+ import { jsx, jsxs } from "react/jsx-runtime";
8
9
  import { useStore } from "zustand";
9
10
  import { mergeProps, useButton, useDisclosure, useFocusRing, useId as useId$1 } from "react-aria";
10
11
  import { useDisclosureGroupState, useDisclosureState } from "react-stately";
@@ -28,9 +29,16 @@ function OpenAPIDisclosureGroup(props) {
28
29
  onExpandedChange?.(keys);
29
30
  }
30
31
  });
31
- return <DisclosureGroupStateContext.Provider value={state}>
32
- {groups.map((group) => <DisclosureItem className={className} selectStateKey={selectStateKey} selectIcon={selectIcon} icon={icon} key={group.key} group={group} />)}
33
- </DisclosureGroupStateContext.Provider>;
32
+ return /* @__PURE__ */ jsx(DisclosureGroupStateContext.Provider, {
33
+ value: state,
34
+ children: groups.map((group) => /* @__PURE__ */ jsx(DisclosureItem, {
35
+ className,
36
+ selectStateKey,
37
+ selectIcon,
38
+ icon,
39
+ group
40
+ }, group.key))
41
+ });
34
42
  }
35
43
  function DisclosureItem(props) {
36
44
  const { icon, group, selectStateKey, selectIcon, className } = props;
@@ -56,33 +64,51 @@ function DisclosureItem(props) {
56
64
  const { isFocusVisible, focusProps } = useFocusRing();
57
65
  const store = useSelectState(selectStateKey, group.tabs?.[0]?.key || "");
58
66
  const selectedTab = group.tabs?.find((tab) => tab.key === store.key) || group.tabs?.[0];
59
- return <div className={clsx("openapi-disclosure-group", className)} aria-expanded={state.isExpanded}>
60
- <div slot="trigger" ref={triggerRef} {...mergeProps(buttonProps, focusProps)} aria-disabled={isDisabled} style={{ outline: isFocusVisible ? "2px solid rgb(var(--primary-color-500)/0.4)" : "none" }} className="openapi-disclosure-group-trigger">
61
- <div className="openapi-disclosure-group-icon">
62
- {icon || <svg viewBox="0 0 24 24" className="openapi-disclosure-group-icon">
63
- <path d="m8.25 4.5 7.5 7.5-7.5 7.5" />
64
- </svg>}
65
- </div>
66
-
67
- <div className="openapi-disclosure-group-label">
68
- {group.label}
69
-
70
- {group.tabs ? <div className="openapi-disclosure-group-mediatype" onClick={(e) => e.stopPropagation()}>
71
- {group.tabs?.length > 1 ? <OpenAPISelect icon={selectIcon} stateKey={selectStateKey} onChange={() => {
72
- state.expand();
73
- }} items={group.tabs} placement="bottom end">
74
- {group.tabs.map((tab) => <OpenAPISelectItem key={tab.key} id={tab.key} value={tab}>
75
- {tab.label}
76
- </OpenAPISelectItem>)}
77
- </OpenAPISelect> : group.tabs[0]?.label ? <span>{group.tabs[0].label}</span> : null}
78
- </div> : null}
79
- </div>
80
- </div>
81
-
82
- {state.isExpanded && selectedTab && <div className="openapi-disclosure-group-panel" ref={panelRef} {...panelProps}>
83
- {selectedTab.body}
84
- </div>}
85
- </div>;
67
+ return /* @__PURE__ */ jsxs("div", {
68
+ className: clsx("openapi-disclosure-group", className),
69
+ "aria-expanded": state.isExpanded,
70
+ children: [/* @__PURE__ */ jsxs("div", {
71
+ slot: "trigger",
72
+ ref: triggerRef,
73
+ ...mergeProps(buttonProps, focusProps),
74
+ "aria-disabled": isDisabled,
75
+ style: { outline: isFocusVisible ? "2px solid rgb(var(--primary-color-500)/0.4)" : "none" },
76
+ className: "openapi-disclosure-group-trigger",
77
+ children: [/* @__PURE__ */ jsx("div", {
78
+ className: "openapi-disclosure-group-icon",
79
+ children: icon || /* @__PURE__ */ jsx("svg", {
80
+ viewBox: "0 0 24 24",
81
+ className: "openapi-disclosure-group-icon",
82
+ children: /* @__PURE__ */ jsx("path", { d: "m8.25 4.5 7.5 7.5-7.5 7.5" })
83
+ })
84
+ }), /* @__PURE__ */ jsxs("div", {
85
+ className: "openapi-disclosure-group-label",
86
+ children: [group.label, group.tabs ? /* @__PURE__ */ jsx("div", {
87
+ className: "openapi-disclosure-group-mediatype",
88
+ onClick: (e) => e.stopPropagation(),
89
+ children: group.tabs?.length > 1 ? /* @__PURE__ */ jsx(OpenAPISelect, {
90
+ icon: selectIcon,
91
+ stateKey: selectStateKey,
92
+ onChange: () => {
93
+ state.expand();
94
+ },
95
+ items: group.tabs,
96
+ placement: "bottom end",
97
+ children: group.tabs.map((tab) => /* @__PURE__ */ jsx(OpenAPISelectItem, {
98
+ id: tab.key,
99
+ value: tab,
100
+ children: tab.label
101
+ }, tab.key))
102
+ }) : group.tabs[0]?.label ? /* @__PURE__ */ jsx("span", { children: group.tabs[0].label }) : null
103
+ }) : null]
104
+ })]
105
+ }), state.isExpanded && selectedTab && /* @__PURE__ */ jsx("div", {
106
+ className: "openapi-disclosure-group-panel",
107
+ ref: panelRef,
108
+ ...panelProps,
109
+ children: selectedTab.body
110
+ })]
111
+ });
86
112
  }
87
113
 
88
114
  //#endregion
@@ -2,6 +2,7 @@ import { json2xml } from "./json2xml.js";
2
2
  import { stringifyOpenAPI } from "./stringifyOpenAPI.js";
3
3
  import { t } from "./translate.js";
4
4
  import yaml from "js-yaml";
5
+ import { jsx } from "react/jsx-runtime";
5
6
 
6
7
  //#region src/OpenAPIExample.tsx
7
8
  /**
@@ -13,7 +14,7 @@ function OpenAPIExample(props) {
13
14
  example,
14
15
  syntax
15
16
  });
16
- if (code === null) return <OpenAPIEmptyExample context={context} />;
17
+ if (code === null) return /* @__PURE__ */ jsx(OpenAPIEmptyExample, { context });
17
18
  return context.renderCodeBlock({
18
19
  code,
19
20
  syntax
@@ -32,9 +33,10 @@ function stringifyExample(args) {
32
33
  */
33
34
  function OpenAPIEmptyExample(props) {
34
35
  const { context } = props;
35
- return <pre className="openapi-example-empty">
36
- <p>{t(context.translation, "no_content")}</p>
37
- </pre>;
36
+ return /* @__PURE__ */ jsx("pre", {
37
+ className: "openapi-example-empty",
38
+ children: /* @__PURE__ */ jsx("p", { children: t(context.translation, "no_content") })
39
+ });
38
40
  }
39
41
 
40
42
  //#endregion