docusaurus-theme-openapi-docs 0.0.0-1240 → 0.0.0-1247

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 (30) hide show
  1. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.js +74 -2
  2. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.js +66 -2
  3. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.js +65 -1
  4. package/lib/theme/ApiItem/index.js +47 -33
  5. package/lib/theme/RequestSchema/index.js +58 -56
  6. package/lib/theme/ResponseSchema/index.js +25 -22
  7. package/lib/theme/Schema/index.js +15 -5
  8. package/lib/theme/SchemaExpansion/_SchemaExpansion.scss +113 -0
  9. package/lib/theme/SchemaExpansion/context.d.ts +24 -0
  10. package/lib/theme/SchemaExpansion/context.js +187 -0
  11. package/lib/theme/SchemaExpansion/index.d.ts +4 -0
  12. package/lib/theme/SchemaExpansion/index.js +315 -0
  13. package/lib/theme/styles.scss +1 -0
  14. package/lib/theme/translationIds.d.ts +6 -0
  15. package/lib/theme/translationIds.js +7 -0
  16. package/package.json +3 -3
  17. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.tsx +19 -2
  18. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.tsx +14 -2
  19. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.tsx +11 -1
  20. package/src/theme/ApiItem/index.tsx +31 -21
  21. package/src/theme/RequestSchema/index.tsx +38 -39
  22. package/src/theme/ResponseSchema/index.tsx +15 -15
  23. package/src/theme/Schema/index.tsx +17 -5
  24. package/src/theme/SchemaExpansion/_SchemaExpansion.scss +113 -0
  25. package/src/theme/SchemaExpansion/context.tsx +154 -0
  26. package/src/theme/SchemaExpansion/index.tsx +237 -0
  27. package/src/theme/styles.scss +1 -0
  28. package/src/theme/translationIds.ts +7 -0
  29. package/src/types.d.ts +18 -0
  30. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1,113 @@
1
+ /* ============================================================================
2
+ * Copyright (c) Palo Alto Networks
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ * ========================================================================== */
7
+
8
+ .openapi-schema-expansion {
9
+ position: relative;
10
+ display: inline-flex;
11
+ align-items: center;
12
+ margin-left: auto;
13
+ }
14
+
15
+ .openapi-schema-expansion__trigger {
16
+ appearance: none;
17
+ background: transparent;
18
+ border: none;
19
+ border-radius: var(--ifm-global-radius);
20
+ padding: 0;
21
+ width: 22px;
22
+ height: 22px;
23
+ flex: 0 0 22px;
24
+ display: inline-flex;
25
+ align-items: center;
26
+ justify-content: center;
27
+ color: var(--ifm-color-emphasis-600);
28
+ line-height: 0;
29
+ opacity: 0.7;
30
+ transition:
31
+ opacity 0.12s ease,
32
+ background-color 0.12s ease,
33
+ color 0.12s ease;
34
+
35
+ &:hover {
36
+ opacity: 1;
37
+ background-color: var(--ifm-color-emphasis-200);
38
+ color: var(--ifm-color-emphasis-900);
39
+ }
40
+
41
+ &:focus-visible {
42
+ outline: 2px solid var(--ifm-color-primary);
43
+ outline-offset: 2px;
44
+ opacity: 1;
45
+ }
46
+
47
+ &[aria-expanded="true"] {
48
+ opacity: 1;
49
+ background-color: var(--ifm-color-emphasis-200);
50
+ color: var(--ifm-color-emphasis-900);
51
+ }
52
+ }
53
+
54
+ .openapi-schema-expansion__popover {
55
+ position: fixed;
56
+ z-index: 1000;
57
+ display: inline-flex;
58
+ align-items: center;
59
+ gap: 2px;
60
+ padding: 3px;
61
+ background-color: var(--ifm-background-surface-color);
62
+ border: 1px solid var(--ifm-color-emphasis-300);
63
+ border-radius: var(--ifm-global-radius);
64
+ box-shadow: var(--ifm-global-shadow-md);
65
+ white-space: nowrap;
66
+ }
67
+
68
+ .openapi-schema-expansion__option {
69
+ appearance: none;
70
+ background: transparent;
71
+ border: none;
72
+ border-radius: calc(var(--ifm-global-radius) - 2px);
73
+ padding: 2px 8px;
74
+ font-size: 0.8rem;
75
+ line-height: 1.4;
76
+ color: var(--ifm-color-emphasis-800);
77
+ transition:
78
+ background-color 0.12s ease,
79
+ color 0.12s ease;
80
+
81
+ &:hover {
82
+ background-color: var(--ifm-color-emphasis-200);
83
+ }
84
+
85
+ &:focus-visible {
86
+ outline: 2px solid var(--ifm-color-primary);
87
+ outline-offset: 1px;
88
+ }
89
+ }
90
+
91
+ .openapi-schema-expansion__option--active {
92
+ background-color: var(--ifm-color-primary);
93
+ color: var(--ifm-color-white);
94
+
95
+ &:hover {
96
+ background-color: var(--ifm-color-primary-dark);
97
+ }
98
+ }
99
+
100
+ .openapi-markdown__details-summary--with-control {
101
+ display: flex !important;
102
+ align-items: center;
103
+ gap: 0.5rem;
104
+
105
+ > h3,
106
+ > strong {
107
+ margin-bottom: 0;
108
+ display: inline-flex;
109
+ align-items: center;
110
+ flex-wrap: wrap;
111
+ gap: 0.4rem;
112
+ }
113
+ }
@@ -0,0 +1,24 @@
1
+ import React from "react";
2
+ export declare const SCHEMA_EXPANSION_STORAGE_KEY = "docusaurus-openapi-schema-expansion-level";
3
+ export interface SchemaExpansionConfig {
4
+ enabled: boolean;
5
+ defaultLevel: number;
6
+ max: number;
7
+ persist: boolean;
8
+ }
9
+ interface SchemaExpansionContextValue {
10
+ config: SchemaExpansionConfig;
11
+ level: number;
12
+ setLevel: (next: number) => void;
13
+ }
14
+ export declare function normalizeLevel(value: number | "all" | undefined): number;
15
+ export declare const SchemaExpansionProvider: React.FC<{
16
+ children: React.ReactNode;
17
+ }>;
18
+ export declare const SchemaDepthProvider: React.FC<{
19
+ depth: number;
20
+ children: React.ReactNode;
21
+ }>;
22
+ export declare function useSchemaExpansion(): SchemaExpansionContextValue;
23
+ export declare function useSchemaDepth(): number;
24
+ export {};
@@ -0,0 +1,187 @@
1
+ "use strict";
2
+ /* ============================================================================
3
+ * Copyright (c) Palo Alto Networks
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ * ========================================================================== */
8
+ var __createBinding =
9
+ (this && this.__createBinding) ||
10
+ (Object.create
11
+ ? function (o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ var desc = Object.getOwnPropertyDescriptor(m, k);
14
+ if (
15
+ !desc ||
16
+ ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)
17
+ ) {
18
+ desc = {
19
+ enumerable: true,
20
+ get: function () {
21
+ return m[k];
22
+ },
23
+ };
24
+ }
25
+ Object.defineProperty(o, k2, desc);
26
+ }
27
+ : function (o, m, k, k2) {
28
+ if (k2 === undefined) k2 = k;
29
+ o[k2] = m[k];
30
+ });
31
+ var __setModuleDefault =
32
+ (this && this.__setModuleDefault) ||
33
+ (Object.create
34
+ ? function (o, v) {
35
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
36
+ }
37
+ : function (o, v) {
38
+ o["default"] = v;
39
+ });
40
+ var __importStar =
41
+ (this && this.__importStar) ||
42
+ (function () {
43
+ var ownKeys = function (o) {
44
+ ownKeys =
45
+ Object.getOwnPropertyNames ||
46
+ function (o) {
47
+ var ar = [];
48
+ for (var k in o)
49
+ if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
50
+ return ar;
51
+ };
52
+ return ownKeys(o);
53
+ };
54
+ return function (mod) {
55
+ if (mod && mod.__esModule) return mod;
56
+ var result = {};
57
+ if (mod != null)
58
+ for (var k = ownKeys(mod), i = 0; i < k.length; i++)
59
+ if (k[i] !== "default") __createBinding(result, mod, k[i]);
60
+ __setModuleDefault(result, mod);
61
+ return result;
62
+ };
63
+ })();
64
+ var __importDefault =
65
+ (this && this.__importDefault) ||
66
+ function (mod) {
67
+ return mod && mod.__esModule ? mod : { default: mod };
68
+ };
69
+ Object.defineProperty(exports, "__esModule", { value: true });
70
+ exports.SchemaDepthProvider =
71
+ exports.SchemaExpansionProvider =
72
+ exports.SCHEMA_EXPANSION_STORAGE_KEY =
73
+ void 0;
74
+ exports.normalizeLevel = normalizeLevel;
75
+ exports.useSchemaExpansion = useSchemaExpansion;
76
+ exports.useSchemaDepth = useSchemaDepth;
77
+ const react_1 = __importStar(require("react"));
78
+ const useDocusaurusContext_1 = __importDefault(
79
+ require("@docusaurus/useDocusaurusContext")
80
+ );
81
+ exports.SCHEMA_EXPANSION_STORAGE_KEY =
82
+ "docusaurus-openapi-schema-expansion-level";
83
+ const DEFAULT_CONFIG = {
84
+ enabled: false,
85
+ defaultLevel: 0,
86
+ max: 4,
87
+ persist: true,
88
+ };
89
+ const SchemaExpansionContext = (0, react_1.createContext)({
90
+ config: DEFAULT_CONFIG,
91
+ level: 0,
92
+ setLevel: () => {},
93
+ });
94
+ const SchemaDepthContext = (0, react_1.createContext)(0);
95
+ function normalizeLevel(value) {
96
+ if (value === "all") return Infinity;
97
+ if (typeof value === "number" && Number.isFinite(value) && value >= 0) {
98
+ return Math.floor(value);
99
+ }
100
+ return 0;
101
+ }
102
+ function readConfig(themeConfig) {
103
+ const raw = themeConfig?.api?.schemaExpansion;
104
+ if (!raw) return DEFAULT_CONFIG;
105
+ const enabled = raw.enabled ?? false;
106
+ return {
107
+ enabled,
108
+ defaultLevel: normalizeLevel(raw.default),
109
+ max: typeof raw.max === "number" && raw.max > 0 ? Math.floor(raw.max) : 4,
110
+ // Persistence only matters when the reader can change the level via the
111
+ // UI control. When the control is hidden, fall back to the configured
112
+ // default on every visit so it isn't shadowed by a stale localStorage
113
+ // value from a session where the control used to be enabled.
114
+ persist: enabled ? (raw.persist ?? true) : false,
115
+ };
116
+ }
117
+ function readPersistedLevel() {
118
+ if (typeof window === "undefined") return undefined;
119
+ try {
120
+ const stored = window.localStorage.getItem(
121
+ exports.SCHEMA_EXPANSION_STORAGE_KEY
122
+ );
123
+ if (stored === null) return undefined;
124
+ if (stored === "all") return Infinity;
125
+ const parsed = parseInt(stored, 10);
126
+ return Number.isFinite(parsed) && parsed >= 0 ? parsed : undefined;
127
+ } catch {
128
+ return undefined;
129
+ }
130
+ }
131
+ function writePersistedLevel(level) {
132
+ if (typeof window === "undefined") return;
133
+ try {
134
+ const value = level === Infinity ? "all" : String(level);
135
+ window.localStorage.setItem(exports.SCHEMA_EXPANSION_STORAGE_KEY, value);
136
+ } catch {
137
+ // ignore quota / disabled storage
138
+ }
139
+ }
140
+ const SchemaExpansionProvider = ({ children }) => {
141
+ const { siteConfig } = (0, useDocusaurusContext_1.default)();
142
+ const themeConfig = siteConfig.themeConfig;
143
+ const config = (0, react_1.useMemo)(
144
+ () => readConfig(themeConfig),
145
+ [themeConfig]
146
+ );
147
+ const [level, setLevelState] = (0, react_1.useState)(config.defaultLevel);
148
+ (0, react_1.useEffect)(() => {
149
+ if (!config.persist) return;
150
+ const persisted = readPersistedLevel();
151
+ if (persisted !== undefined) {
152
+ setLevelState(persisted);
153
+ }
154
+ }, [config.persist]);
155
+ const setLevel = (0, react_1.useCallback)(
156
+ (next) => {
157
+ setLevelState(next);
158
+ if (config.persist) {
159
+ writePersistedLevel(next);
160
+ }
161
+ },
162
+ [config.persist]
163
+ );
164
+ const value = (0, react_1.useMemo)(
165
+ () => ({ config, level, setLevel }),
166
+ [config, level, setLevel]
167
+ );
168
+ return react_1.default.createElement(
169
+ SchemaExpansionContext.Provider,
170
+ { value: value },
171
+ children
172
+ );
173
+ };
174
+ exports.SchemaExpansionProvider = SchemaExpansionProvider;
175
+ const SchemaDepthProvider = ({ depth, children }) =>
176
+ react_1.default.createElement(
177
+ SchemaDepthContext.Provider,
178
+ { value: depth },
179
+ children
180
+ );
181
+ exports.SchemaDepthProvider = SchemaDepthProvider;
182
+ function useSchemaExpansion() {
183
+ return (0, react_1.useContext)(SchemaExpansionContext);
184
+ }
185
+ function useSchemaDepth() {
186
+ return (0, react_1.useContext)(SchemaDepthContext);
187
+ }
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ export { SchemaExpansionProvider, SchemaDepthProvider, useSchemaExpansion, useSchemaDepth, normalizeLevel, SCHEMA_EXPANSION_STORAGE_KEY, } from "./context";
3
+ declare const SchemaExpansionControl: React.FC;
4
+ export default SchemaExpansionControl;
@@ -0,0 +1,315 @@
1
+ "use strict";
2
+ /* ============================================================================
3
+ * Copyright (c) Palo Alto Networks
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ * ========================================================================== */
8
+ var __createBinding =
9
+ (this && this.__createBinding) ||
10
+ (Object.create
11
+ ? function (o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ var desc = Object.getOwnPropertyDescriptor(m, k);
14
+ if (
15
+ !desc ||
16
+ ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)
17
+ ) {
18
+ desc = {
19
+ enumerable: true,
20
+ get: function () {
21
+ return m[k];
22
+ },
23
+ };
24
+ }
25
+ Object.defineProperty(o, k2, desc);
26
+ }
27
+ : function (o, m, k, k2) {
28
+ if (k2 === undefined) k2 = k;
29
+ o[k2] = m[k];
30
+ });
31
+ var __setModuleDefault =
32
+ (this && this.__setModuleDefault) ||
33
+ (Object.create
34
+ ? function (o, v) {
35
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
36
+ }
37
+ : function (o, v) {
38
+ o["default"] = v;
39
+ });
40
+ var __importStar =
41
+ (this && this.__importStar) ||
42
+ (function () {
43
+ var ownKeys = function (o) {
44
+ ownKeys =
45
+ Object.getOwnPropertyNames ||
46
+ function (o) {
47
+ var ar = [];
48
+ for (var k in o)
49
+ if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
50
+ return ar;
51
+ };
52
+ return ownKeys(o);
53
+ };
54
+ return function (mod) {
55
+ if (mod && mod.__esModule) return mod;
56
+ var result = {};
57
+ if (mod != null)
58
+ for (var k = ownKeys(mod), i = 0; i < k.length; i++)
59
+ if (k[i] !== "default") __createBinding(result, mod, k[i]);
60
+ __setModuleDefault(result, mod);
61
+ return result;
62
+ };
63
+ })();
64
+ var __importDefault =
65
+ (this && this.__importDefault) ||
66
+ function (mod) {
67
+ return mod && mod.__esModule ? mod : { default: mod };
68
+ };
69
+ Object.defineProperty(exports, "__esModule", { value: true });
70
+ exports.SCHEMA_EXPANSION_STORAGE_KEY =
71
+ exports.normalizeLevel =
72
+ exports.useSchemaDepth =
73
+ exports.useSchemaExpansion =
74
+ exports.SchemaDepthProvider =
75
+ exports.SchemaExpansionProvider =
76
+ void 0;
77
+ const react_1 = __importStar(require("react"));
78
+ const Translate_1 = require("@docusaurus/Translate");
79
+ const translationIds_1 = require("@theme/translationIds");
80
+ const clsx_1 = __importDefault(require("clsx"));
81
+ const context_1 = require("./context");
82
+ var context_2 = require("./context");
83
+ Object.defineProperty(exports, "SchemaExpansionProvider", {
84
+ enumerable: true,
85
+ get: function () {
86
+ return context_2.SchemaExpansionProvider;
87
+ },
88
+ });
89
+ Object.defineProperty(exports, "SchemaDepthProvider", {
90
+ enumerable: true,
91
+ get: function () {
92
+ return context_2.SchemaDepthProvider;
93
+ },
94
+ });
95
+ Object.defineProperty(exports, "useSchemaExpansion", {
96
+ enumerable: true,
97
+ get: function () {
98
+ return context_2.useSchemaExpansion;
99
+ },
100
+ });
101
+ Object.defineProperty(exports, "useSchemaDepth", {
102
+ enumerable: true,
103
+ get: function () {
104
+ return context_2.useSchemaDepth;
105
+ },
106
+ });
107
+ Object.defineProperty(exports, "normalizeLevel", {
108
+ enumerable: true,
109
+ get: function () {
110
+ return context_2.normalizeLevel;
111
+ },
112
+ });
113
+ Object.defineProperty(exports, "SCHEMA_EXPANSION_STORAGE_KEY", {
114
+ enumerable: true,
115
+ get: function () {
116
+ return context_2.SCHEMA_EXPANSION_STORAGE_KEY;
117
+ },
118
+ });
119
+ const ALL_VALUE = Number.POSITIVE_INFINITY;
120
+ const ExpandIcon = () =>
121
+ react_1.default.createElement(
122
+ "svg",
123
+ {
124
+ "aria-hidden": "true",
125
+ focusable: "false",
126
+ width: "14",
127
+ height: "14",
128
+ viewBox: "0 0 16 16",
129
+ fill: "none",
130
+ stroke: "currentColor",
131
+ strokeWidth: "1.6",
132
+ strokeLinecap: "round",
133
+ strokeLinejoin: "round",
134
+ },
135
+ react_1.default.createElement("polyline", { points: "4 6 8 2 12 6" }),
136
+ react_1.default.createElement("polyline", { points: "4 10 8 14 12 10" })
137
+ );
138
+ const SchemaExpansionControl = () => {
139
+ const { config, level, setLevel } = (0, context_1.useSchemaExpansion)();
140
+ const [open, setOpen] = (0, react_1.useState)(false);
141
+ const [coords, setCoords] = (0, react_1.useState)(null);
142
+ const buttonRef = (0, react_1.useRef)(null);
143
+ const popoverRef = (0, react_1.useRef)(null);
144
+ const optionRefs = (0, react_1.useRef)([]);
145
+ const popoverId = (0, react_1.useId)();
146
+ const options = (0, react_1.useMemo)(() => {
147
+ const numbers = Array.from({ length: config.max + 1 }, (_, i) => i);
148
+ return [...numbers, ALL_VALUE];
149
+ }, [config.max]);
150
+ const activeIndex = (0, react_1.useMemo)(() => {
151
+ const idx = options.indexOf(level);
152
+ return idx >= 0 ? idx : 0;
153
+ }, [options, level]);
154
+ const updatePosition = (0, react_1.useCallback)(() => {
155
+ if (!buttonRef.current || typeof window === "undefined") return;
156
+ const rect = buttonRef.current.getBoundingClientRect();
157
+ setCoords({
158
+ top: rect.bottom + 4,
159
+ right: window.innerWidth - rect.right,
160
+ });
161
+ }, []);
162
+ (0, react_1.useLayoutEffect)(() => {
163
+ if (!open) return;
164
+ updatePosition();
165
+ const handleScroll = () => setOpen(false);
166
+ window.addEventListener("scroll", handleScroll, true);
167
+ window.addEventListener("resize", updatePosition);
168
+ return () => {
169
+ window.removeEventListener("scroll", handleScroll, true);
170
+ window.removeEventListener("resize", updatePosition);
171
+ };
172
+ }, [open, updatePosition]);
173
+ (0, react_1.useEffect)(() => {
174
+ if (!open) return;
175
+ optionRefs.current[activeIndex]?.focus();
176
+ }, [open, activeIndex]);
177
+ (0, react_1.useEffect)(() => {
178
+ if (!open) return;
179
+ const handlePointer = (event) => {
180
+ const target = event.target;
181
+ if (buttonRef.current?.contains(target)) return;
182
+ if (popoverRef.current?.contains(target)) return;
183
+ setOpen(false);
184
+ };
185
+ const handleKey = (event) => {
186
+ if (event.key === "Escape") {
187
+ event.stopPropagation();
188
+ setOpen(false);
189
+ buttonRef.current?.focus();
190
+ }
191
+ };
192
+ document.addEventListener("mousedown", handlePointer);
193
+ document.addEventListener("keydown", handleKey);
194
+ return () => {
195
+ document.removeEventListener("mousedown", handlePointer);
196
+ document.removeEventListener("keydown", handleKey);
197
+ };
198
+ }, [open]);
199
+ const choose = (0, react_1.useCallback)(
200
+ (next) => {
201
+ setLevel(next);
202
+ setOpen(false);
203
+ buttonRef.current?.focus();
204
+ },
205
+ [setLevel]
206
+ );
207
+ const onMenuKeyDown = (event) => {
208
+ if (event.key !== "ArrowRight" && event.key !== "ArrowLeft") return;
209
+ event.preventDefault();
210
+ const current = optionRefs.current.findIndex(
211
+ (el) => el === document.activeElement
212
+ );
213
+ if (current < 0) return;
214
+ const next =
215
+ event.key === "ArrowRight"
216
+ ? (current + 1) % options.length
217
+ : (current - 1 + options.length) % options.length;
218
+ optionRefs.current[next]?.focus();
219
+ };
220
+ if (!config.enabled) return null;
221
+ const buttonLabel = (0, Translate_1.translate)({
222
+ id: translationIds_1.OPENAPI_SCHEMA_EXPANSION.BUTTON_LABEL,
223
+ message: "Schema expansion depth",
224
+ description: "Aria/title tooltip for the schema expansion icon button",
225
+ });
226
+ const menuLabel = (0, Translate_1.translate)({
227
+ id: translationIds_1.OPENAPI_SCHEMA_EXPANSION.MENU_LABEL,
228
+ message: "Schema expansion depth options",
229
+ description: "Accessible label for the expansion options menu",
230
+ });
231
+ const allLabel = (0, Translate_1.translate)({
232
+ id: translationIds_1.OPENAPI_SCHEMA_EXPANSION.ALL,
233
+ message: "All",
234
+ description: "Label for the expand-all option",
235
+ });
236
+ return react_1.default.createElement(
237
+ "span",
238
+ { className: "openapi-schema-expansion" },
239
+ react_1.default.createElement(
240
+ "button",
241
+ {
242
+ ref: buttonRef,
243
+ type: "button",
244
+ className: "openapi-schema-expansion__trigger",
245
+ "aria-haspopup": "menu",
246
+ "aria-expanded": open,
247
+ "aria-controls": open ? popoverId : undefined,
248
+ "aria-label": buttonLabel,
249
+ title: buttonLabel,
250
+ onClick: (event) => {
251
+ event.preventDefault();
252
+ event.stopPropagation();
253
+ setOpen((prev) => !prev);
254
+ },
255
+ },
256
+ react_1.default.createElement(ExpandIcon, null)
257
+ ),
258
+ open &&
259
+ coords &&
260
+ react_1.default.createElement(
261
+ "div",
262
+ {
263
+ ref: popoverRef,
264
+ id: popoverId,
265
+ role: "menu",
266
+ "aria-label": menuLabel,
267
+ className: "openapi-schema-expansion__popover",
268
+ style: { top: coords.top, right: coords.right },
269
+ onKeyDown: onMenuKeyDown,
270
+ onClick: (event) => {
271
+ event.preventDefault();
272
+ event.stopPropagation();
273
+ },
274
+ },
275
+ options.map((value, index) => {
276
+ const isAll = value === ALL_VALUE;
277
+ const label = isAll ? allLabel : String(value);
278
+ const optionAriaLabel = isAll
279
+ ? allLabel
280
+ : (0, Translate_1.translate)(
281
+ {
282
+ id: translationIds_1.OPENAPI_SCHEMA_EXPANSION.DEPTH_OPTION,
283
+ message: "Expand to depth {depth}",
284
+ description: "Accessible label for a depth option",
285
+ },
286
+ { depth: value }
287
+ );
288
+ const isActive = level === value;
289
+ return react_1.default.createElement(
290
+ "button",
291
+ {
292
+ key: isAll ? "all" : value,
293
+ ref: (el) => {
294
+ optionRefs.current[index] = el;
295
+ },
296
+ type: "button",
297
+ role: "menuitemradio",
298
+ "aria-checked": isActive,
299
+ "aria-label": optionAriaLabel,
300
+ tabIndex: index === activeIndex ? 0 : -1,
301
+ className: (0, clsx_1.default)(
302
+ "openapi-schema-expansion__option",
303
+ {
304
+ "openapi-schema-expansion__option--active": isActive,
305
+ }
306
+ ),
307
+ onClick: () => choose(value),
308
+ },
309
+ label
310
+ );
311
+ })
312
+ )
313
+ );
314
+ };
315
+ exports.default = SchemaExpansionControl;
@@ -32,6 +32,7 @@
32
32
  /* Schema Styling */
33
33
  @use "./ParamsItem/ParamsItem";
34
34
  @use "./SchemaItem/SchemaItem";
35
+ @use "./SchemaExpansion/SchemaExpansion";
35
36
  /* Tabs Styling */
36
37
  @use "./ApiTabs/ApiTabs";
37
38
  @use "./DiscriminatorTabs/DiscriminatorTabs";
@@ -59,6 +59,12 @@ export declare const OPENAPI_STATUS_CODES: {
59
59
  export declare const OPENAPI_SCHEMA: {
60
60
  NO_SCHEMA: string;
61
61
  };
62
+ export declare const OPENAPI_SCHEMA_EXPANSION: {
63
+ BUTTON_LABEL: string;
64
+ MENU_LABEL: string;
65
+ ALL: string;
66
+ DEPTH_OPTION: string;
67
+ };
62
68
  export declare const OPENAPI_SCHEMA_ITEM: {
63
69
  CHARACTERS: string;
64
70
  NON_EMPTY: string;
@@ -9,6 +9,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.OPENAPI_SECURITY_SCHEMES =
10
10
  exports.OPENAPI_PARAMS_DETAILS =
11
11
  exports.OPENAPI_SCHEMA_ITEM =
12
+ exports.OPENAPI_SCHEMA_EXPANSION =
12
13
  exports.OPENAPI_SCHEMA =
13
14
  exports.OPENAPI_STATUS_CODES =
14
15
  exports.OPENAPI_BODY =
@@ -83,6 +84,12 @@ exports.OPENAPI_STATUS_CODES = {
83
84
  exports.OPENAPI_SCHEMA = {
84
85
  NO_SCHEMA: "theme.openapi.schema.noSchema",
85
86
  };
87
+ exports.OPENAPI_SCHEMA_EXPANSION = {
88
+ BUTTON_LABEL: "theme.openapi.schema.expansion.button",
89
+ MENU_LABEL: "theme.openapi.schema.expansion.menu",
90
+ ALL: "theme.openapi.schema.expansion.all",
91
+ DEPTH_OPTION: "theme.openapi.schema.expansion.depthOption",
92
+ };
86
93
  exports.OPENAPI_SCHEMA_ITEM = {
87
94
  CHARACTERS: "theme.openapi.schemaItem.characters",
88
95
  NON_EMPTY: "theme.openapi.schemaItem.nonEmpty",