@digi-frontend/dgate-api-documentation 2.0.1-test.14 → 2.0.1-test.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,28 +1,31 @@
1
- import { useEffect } from "react";
2
- import { Layout, theme } from "antd";
1
+ 'use client';
2
+
3
+
4
+ import * as React$1 from "react";
5
+ import { useEffect, useMemo, useState } from "react";
6
+ import { Button, Input, Layout, Tag, Tree, Typography, theme } from "antd";
3
7
  import { useStyleRegister } from "@ant-design/cssinjs";
4
8
  import { jsx, jsxs } from "react/jsx-runtime";
5
9
  import { create } from "zustand";
6
10
  import { devtools } from "zustand/middleware";
7
11
  import { immer } from "zustand/middleware/immer";
8
- import { nanoid } from "nanoid";
9
12
  import { AntdRegistry } from "@ant-design/nextjs-registry";
10
13
 
11
14
  //#region src/hooks/useStyle.ts
12
15
  function useStyle(componentName, stylesFn) {
13
- const { token, theme: theme$1, hashId } = theme.useToken();
16
+ const { token: token$1, theme: theme$1, hashId } = theme.useToken();
14
17
  const scope = (className) => `.${hashId}.${componentName}-${className}`;
15
18
  const cx = (...classes) => classes.map((cls) => `${componentName}-${cls} ${hashId}`).join(" ");
16
19
  const wrapSSR = useStyleRegister({
17
20
  theme: theme$1,
18
- token,
21
+ token: token$1,
19
22
  path: [componentName]
20
- }, () => stylesFn(token, scope));
23
+ }, () => stylesFn(token$1, scope));
21
24
  return {
22
25
  wrapSSR,
23
26
  cx,
24
27
  scope,
25
- token,
28
+ token: token$1,
26
29
  hashId
27
30
  };
28
31
  }
@@ -31,10 +34,10 @@ function useStyle(componentName, stylesFn) {
31
34
  //#region src/view/components/Header.tsx
32
35
  const { Header: AntHeader } = Layout;
33
36
  const Header = () => {
34
- const { wrapSSR, cx } = useStyle("Header", (token, scope) => ({ [scope("header")]: {
37
+ const { wrapSSR, cx } = useStyle("Header", (token$1, scope) => ({ [scope("header")]: {
35
38
  width: "100%",
36
39
  height: "4rem",
37
- backgroundColor: token.colorBgContainer
40
+ backgroundColor: token$1.colorBgContainer
38
41
  } }));
39
42
  return wrapSSR(/* @__PURE__ */ jsx(AntHeader, { className: cx("header") }));
40
43
  };
@@ -123,17 +126,762 @@ const createStore = (set) => ({
123
126
  const useStore = create()(devtools(immer(createStore), { name: "dgate-docs-store" }));
124
127
  var store_default = useStore;
125
128
 
129
+ //#endregion
130
+ //#region src/assets/Minify.svg
131
+ var _path;
132
+ function _extends() {
133
+ return _extends = Object.assign ? Object.assign.bind() : function(n) {
134
+ for (var e = 1; e < arguments.length; e++) {
135
+ var t = arguments[e];
136
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
137
+ }
138
+ return n;
139
+ }, _extends.apply(null, arguments);
140
+ }
141
+ var SvgMinify = function SvgMinify$1(props) {
142
+ return /* @__PURE__ */ React$1.createElement("svg", _extends({
143
+ xmlns: "http://www.w3.org/2000/svg",
144
+ width: 16,
145
+ height: 16,
146
+ fill: "none"
147
+ }, props), _path || (_path = /* @__PURE__ */ React$1.createElement("path", {
148
+ stroke: "currentcolor",
149
+ d: "m6 11.334 2-2 2 2M6 4.666l2 2 2-2"
150
+ })));
151
+ };
152
+ var Minify_default = SvgMinify;
153
+
154
+ //#endregion
155
+ //#region src/theme/light.json
156
+ var token = {
157
+ "brnadColor.1": "#f1f5fd",
158
+ "brnadColor.2": "#e0e9f9",
159
+ "brnadColor.3": "#c8d8f5",
160
+ "brnadColor.4": "#a2bfee",
161
+ "brnadColor.5": "#769de4",
162
+ "brnadColor.6": "#4d75d9",
163
+ "brnadColor.7": "#4261ce",
164
+ "brnadColor.8": "#384fbd",
165
+ "brnadColor.9": "#33419a",
166
+ "brnadColor.10": "#20264b",
167
+ "cyan.1": "#e6fffb",
168
+ "cyan.2": "#b5f5ec",
169
+ "cyan.3": "#87e8de",
170
+ "cyan.4": "#5cdbd3",
171
+ "cyan.5": "#36cfc9",
172
+ "cyan.6": "#13c2c2",
173
+ "cyan.7": "#08979c",
174
+ "cyan.8": "#006d75",
175
+ "cyan.9": "#00474f",
176
+ "cyan.10": "#002329",
177
+ "geekblue.1": "#f0f5ff",
178
+ "geekblue.2": "#d6e4ff",
179
+ "geekblue.3": "#adc6ff",
180
+ "geekblue.4": "#85a5ff",
181
+ "geekblue.5": "#597ef7",
182
+ "geekblue.6": "#2f54eb",
183
+ "geekblue.7": "#1d39c4",
184
+ "geekblue.8": "#10239e",
185
+ "geekblue.9": "#061178",
186
+ "geekblue.10": "#030852",
187
+ "gold.1": "#fffbe6",
188
+ "gold.2": "#fff1b8",
189
+ "gold.3": "#ffe58f",
190
+ "gold.4": "#ffd666",
191
+ "gold.5": "#ffc53d",
192
+ "gold.6": "#faad14",
193
+ "gold.7": "#d48806",
194
+ "gold.8": "#ad6800",
195
+ "gold.9": "#874d00",
196
+ "gold.10": "#613400",
197
+ "green.1": "#f6ffed",
198
+ "green.2": "#d9f7be",
199
+ "green.3": "#b7eb8f",
200
+ "green.4": "#95de64",
201
+ "green.5": "#73d13d",
202
+ "green.6": "#52c41a",
203
+ "green.7": "#389e0d",
204
+ "green.8": "#237804",
205
+ "green.9": "#135200",
206
+ "green.10": "#092b00",
207
+ "lime.1": "#fcffe6",
208
+ "lime.2": "#f4ffb8",
209
+ "lime.3": "#eaff8f",
210
+ "lime.4": "#d3f261",
211
+ "lime.5": "#bae637",
212
+ "lime.6": "#a0d911",
213
+ "lime.7": "#7cb305",
214
+ "lime.8": "#5b8c00",
215
+ "lime.9": "#3f6600",
216
+ "lime.10": "#254000",
217
+ "magenta.1": "#fff0f6",
218
+ "magenta.2": "#ffd6e7",
219
+ "magenta.3": "#ffadd2",
220
+ "magenta.4": "#ff85c0",
221
+ "magenta.5": "#f759ab",
222
+ "magenta.6": "#eb2f96",
223
+ "magenta.7": "#c41d7f",
224
+ "magenta.8": "#9e1068",
225
+ "magenta.9": "#780650",
226
+ "magenta.10": "#520339",
227
+ "orange.1": "#fff7e6",
228
+ "orange.2": "#ffe7ba",
229
+ "orange.3": "#ffd591",
230
+ "orange.4": "#ffc069",
231
+ "colorText": "rgba(0, 0, 0, 0.88)",
232
+ "colorTextSecondary": "rgba(0, 0, 0, 0.65)",
233
+ "orange.5": "#ffa940",
234
+ "colorTextTertiary": "rgba(0, 0, 0, 0.45)",
235
+ "colorTextQuaternary": "rgba(0, 0, 0, 0.25)",
236
+ "orange.6": "#fa8c16",
237
+ "orange.7": "#d46b08",
238
+ "colorTextLightSolid": "#ffffff",
239
+ "colorTextHeading": "rgba(0, 0, 0, 0.88)",
240
+ "colorTextLabel": "rgba(0, 0, 0, 0.65)",
241
+ "orange.8": "#ad4e00",
242
+ "colorTextDescription": "rgba(0, 0, 0, 0.45)",
243
+ "orange.9": "#873800",
244
+ "colorTextDisabled": "rgba(0, 0, 0, 0.25)",
245
+ "orange.10": "#612500",
246
+ "purple.1": "#f9f0ff",
247
+ "purple.2": "#efdbff",
248
+ "purple.3": "#d3adf7",
249
+ "colorTextPlaceholder": "rgba(0, 0, 0, 0.25)",
250
+ "colorIcon": "rgba(0, 0, 0, 0.45)",
251
+ "purple.4": "#b37feb",
252
+ "colorIconHover": "rgba(0, 0, 0, 0.88)",
253
+ "colorBgContainer": "#ffffff",
254
+ "purple.5": "#9254de",
255
+ "colorBgElevated": "#ffffff",
256
+ "purple.6": "#722ed1",
257
+ "colorBgLayout": "#f5f5f5",
258
+ "purple.7": "#531dab",
259
+ "colorBgMask": "rgba(0, 0, 0, 0.45)",
260
+ "purple.8": "#391085",
261
+ "colorBgSpotlight": "rgba(0, 0, 0, 0.85)",
262
+ "purple.9": "#22075e",
263
+ "colorBorder": "#d9d9d9",
264
+ "purple.10": "#120338",
265
+ "colorBorderSecondary": "#f0f0f0",
266
+ "red.1": "#fff1f0",
267
+ "colorFill": "rgba(0, 0, 0, 0.15)",
268
+ "red.2": "#ffccc7",
269
+ "colorFillSecondary": "rgba(0, 0, 0, 0.06)",
270
+ "colorFillTertiary": "rgba(0, 0, 0, 0.04)",
271
+ "colorFillQuaternary": "rgba(0, 0, 0, 0.02)",
272
+ "red.3": "#ffa39e",
273
+ "red.4": "#ff7875",
274
+ "colorWhite": "#ffffff",
275
+ "red.5": "#ff4d4f",
276
+ "colorBgBase": "#ffffff",
277
+ "red.6": "#f5222d",
278
+ "colorTextBase": "#000000",
279
+ "red.7": "#cf1322",
280
+ "red.8": "#a8071a",
281
+ "colorBgContainerDisabled": "rgba(0, 0, 0, 0.04)",
282
+ "red.9": "#820014",
283
+ "colorBgTextActive": "rgba(0, 0, 0, 0.15)",
284
+ "red.10": "#5c0011",
285
+ "colorBgTextHover": "rgba(0, 0, 0, 0.06)",
286
+ "volcano.1": "#fff2e8",
287
+ "colorBorderBg": "#ffffff",
288
+ "volcano.2": "#ffd8bf",
289
+ "colorFillContent": "rgba(0, 0, 0, 0.06)",
290
+ "volcano.3": "#ffbb96",
291
+ "colorFillContentHover": "rgba(0, 0, 0, 0.15)",
292
+ "volcano.4": "#ff9c6e",
293
+ "colorFillAlter": "rgba(0, 0, 0, 0.02)",
294
+ "volcano.5": "#ff7a45",
295
+ "volcano.6": "#fa541c",
296
+ "volcano.7": "#d4380d",
297
+ "transparent": "rgba(0, 0, 0, 0)",
298
+ "colorSplit": "rgba(0, 0, 0, 0.06)",
299
+ "yellow.1": "#feffe6",
300
+ "volcano.8": "#ad2102",
301
+ "yellow.2": "#ffffb8",
302
+ "yellow.3": "#fffb8f",
303
+ "volcano.9": "#871400",
304
+ "yellow.4": "#fff566",
305
+ "volcano.10": "#610b00",
306
+ "yellow.5": "#ffec3d",
307
+ "yellow.6": "#fadb14",
308
+ "yellow.7": "#d4b106",
309
+ "yellow.8": "#ad8b00",
310
+ "yellow.9": "#876800",
311
+ "yellow.10": "#614700",
312
+ "colorPrimary": "#4d75d9",
313
+ "colorSuccess": "#52c41a",
314
+ "colorWarning": "#faad14",
315
+ "colorInfo": "#4d75d9",
316
+ "colorError": "#ff4d4f",
317
+ "colorLink": "#4d75d9",
318
+ "colorErrorBg": "#fff2f0",
319
+ "colorErrorBgHover": "#fff1f0",
320
+ "colorErrorBorder": "#ffccc7",
321
+ "colorErrorBorderHover": "#ffa39e",
322
+ "colorErrorHover": "#ff7875",
323
+ "colorErrorActive": "#d9363e",
324
+ "colorErrorTextHover": "#ff7875",
325
+ "colorErrorText": "#ff4d4f",
326
+ "colorErrorTextActive": "#d9363e",
327
+ "colorLinkHover": "#769de4",
328
+ "colorInfoBg": "#f1f5fd",
329
+ "colorInfoBgHover": "#e0e9f9",
330
+ "colorInfoBorder": "#c8d8f5",
331
+ "colorInfoBorderHover": "#a2bfee",
332
+ "colorInfoHover": "#769de4",
333
+ "colorInfoActive": "#4261ce",
334
+ "colorInfoTextHover": "#769de4",
335
+ "colorInfoText": "#4d75d9",
336
+ "colorInfoTextActive": "#4261ce",
337
+ "colorLinkActive": "#4261ce",
338
+ "colorPrimaryBg": "#f1f5fd",
339
+ "colorPrimaryBgHover": "#e0e9f9",
340
+ "colorPrimaryBorder": "#c8d8f5",
341
+ "colorPrimaryBorderHover": "#a2bfee",
342
+ "colorPrimaryHover": "#769de4",
343
+ "colorPrimaryActive": "#4261ce",
344
+ "colorPrimaryTextHover": "#769de4",
345
+ "colorPrimaryText": "#4d75d9",
346
+ "colorPrimaryTextActive": "#4261ce",
347
+ "colorSuccessBg": "#f6ffed",
348
+ "colorSuccessBgHover": "#d9f7be",
349
+ "colorSuccessBorder": "#b7eb8f",
350
+ "colorSuccessBorderHover": "#95de64",
351
+ "colorSuccessHover": "#95de64",
352
+ "colorSuccessActive": "#389e0d",
353
+ "colorSuccessTextHover": "#73d13d",
354
+ "colorSuccessText": "#52c41a",
355
+ "colorSuccessTextActive": "#389e0d",
356
+ "colorWarningBg": "#fffbe6",
357
+ "colorWarningBgHover": "#fff1b8",
358
+ "colorWarningBorder": "#ffe58f",
359
+ "colorWarningBorderHover": "#ffd666",
360
+ "colorWarningHover": "#ffd666",
361
+ "colorWarningActive": "#d48806",
362
+ "colorWarningTextHover": "#ffc53d",
363
+ "colorWarningText": "#faad14",
364
+ "colorWarningTextActive": "#d48806",
365
+ "colorErrorOutline": "rgba(255, 38, 6, 0.06)",
366
+ "colorWarningOutline": "rgba(255, 215, 5, 0.1)",
367
+ "controlItemBgActive": "#f1f5fd",
368
+ "controlItemBgActiveDisabled": "rgba(0, 0, 0, 0.15)",
369
+ "controlItemBgActiveHover": "#e0e9f9",
370
+ "controlItemBgHover": "rgba(0, 0, 0, 0.04)",
371
+ "controlOutline": "rgba(5, 145, 255, 0.1)",
372
+ "controlTmpOutline": "rgba(0, 0, 0, 0.02)",
373
+ "borderRadius": 6,
374
+ "borderRadiusLG": 8,
375
+ "borderRadiusSM": 4,
376
+ "borderRadiusXS": 2,
377
+ "sizeStep": 4,
378
+ "sizeUnit": 4,
379
+ "controlInteractiveSize": 16,
380
+ "size": 16,
381
+ "sizeLG": 24,
382
+ "sizeMD": 20,
383
+ "sizeMS": 16,
384
+ "sizeSM": 12,
385
+ "sizeXL": 32,
386
+ "sizeXS": 8,
387
+ "sizeXXL": 48,
388
+ "controlHeight": 32,
389
+ "sizeXXS": 4,
390
+ "controlHeightLG": 40,
391
+ "controlHeightSM": 24,
392
+ "controlHeightXS": 16,
393
+ "lineWidth": 1,
394
+ "lineWidthBold": 2,
395
+ "lineWidthFocus": 4,
396
+ "controlOutlineWidth": 2,
397
+ "screenLG": 992,
398
+ "screenLGMax": 1199,
399
+ "screenLGMin": 992,
400
+ "screenMD": 768,
401
+ "screenMDMax": 991,
402
+ "screenMDMin": 768,
403
+ "screenSM": 576,
404
+ "screenSMMax": 767,
405
+ "screenSMMin": 576,
406
+ "screenXL": 1200,
407
+ "screenXLMax": 1599,
408
+ "screenXLMin": 1200,
409
+ "screenXS": 480,
410
+ "screenXSMax": 575,
411
+ "screenXSMin": 480,
412
+ "screenXXL": 1600,
413
+ "screenXXLMin": 1600,
414
+ "sizePopupArrow": 16,
415
+ "margin": 16,
416
+ "marginLG": 24,
417
+ "marginMD": 20,
418
+ "marginSM": 12,
419
+ "marginXL": 32,
420
+ "marginXS": 8,
421
+ "marginXXL": 48,
422
+ "marginXXS": 4,
423
+ "padding": 16,
424
+ "paddingLG": 24,
425
+ "paddingMD": 20,
426
+ "paddingSM": 12,
427
+ "paddingXL": 32,
428
+ "paddingXS": 8,
429
+ "paddingXXS": 4,
430
+ "paddingContentHorizontal": 16,
431
+ "paddingContentHorizontalLG": 24,
432
+ "paddingContentHorizontalSM": 16,
433
+ "paddingContentVertical": 12,
434
+ "paddingContentVerticalLG": 16,
435
+ "paddingContentVerticalSM": 8,
436
+ "controlPaddingHorizontal": 12,
437
+ "controlPaddingHorizontalSM": 8,
438
+ "fontFamily": "SF Pro",
439
+ "fontFamilyCode": "Courier Prime",
440
+ "fontSize": 14,
441
+ "fontSizeLG": 16,
442
+ "fontSizeSM": 12,
443
+ "fontSizeXL": 20,
444
+ "fontSizeHeading1": 38,
445
+ "fontSizeHeading2": 30,
446
+ "fontSizeHeading3": 24,
447
+ "fontSizeHeading4": 20,
448
+ "fontSizeHeading5": 16,
449
+ "lineHeight": 1.5714285714285714,
450
+ "lineHeightHeading1": 1.2105263157894737,
451
+ "lineHeightHeading2": 1.2666666666666666,
452
+ "lineHeightHeading3": 1.3333333333333333,
453
+ "lineHeightHeading4": 1.4,
454
+ "lineHeightHeading5": 1.5,
455
+ "lineHeightLG": 1.5,
456
+ "lineHeightSM": 1.6666666666666667,
457
+ "fontSizeIcon": 12,
458
+ "fontWeightStrong": 600,
459
+ "colorFillAlterSolid": "#fafafa",
460
+ "fontWeightNormal": 400,
461
+ "colorFilledHandleBg": "#f0f0f0",
462
+ "colorBgSolid": "#000000",
463
+ "colorBgSolidActive": "rgba(0, 0, 0, 0.95)",
464
+ "colorBgSolidHover": "rgba(0, 0, 0, 0.75)",
465
+ "solidTextColor": "#ffffff",
466
+ "pink.1": "#fff0f6",
467
+ "pink.2": "#ffd6e7",
468
+ "pink.3": "#ffadd2",
469
+ "pink.4": "#ff85c0",
470
+ "pink.5": "#f759ab",
471
+ "pink.6": "#eb2f96",
472
+ "pink.7": "#c41d7f",
473
+ "pink.8": "#9e1068",
474
+ "pink.9": "#780650",
475
+ "pink.10": "#520339",
476
+ "sizeXXXL": 60,
477
+ "sizeXXXXL": 72,
478
+ "paddingXXL": 48,
479
+ "paddingXXXL": 60,
480
+ "paddingXXXXL": 72,
481
+ "marginXXXL": 60,
482
+ "marginXXXXL": 72
483
+ };
484
+
485
+ //#endregion
486
+ //#region src/view/helper/sidebar.utils.ts
487
+ const methodColors = {
488
+ GET: {
489
+ bg: token.colorPrimaryBgHover,
490
+ color: token.colorPrimary
491
+ },
492
+ POST: {
493
+ bg: token["green.1"],
494
+ color: token.colorSuccess
495
+ },
496
+ DELETE: {
497
+ bg: token.colorErrorBg,
498
+ color: token.colorError
499
+ },
500
+ PUT: {
501
+ bg: token.colorWarningBg,
502
+ color: token.colorWarning
503
+ },
504
+ PATCH: {
505
+ bg: token["volcano.5"],
506
+ color: token.colorWhite
507
+ },
508
+ OPTIONS: {
509
+ bg: token["geekblue.2"],
510
+ color: token["geekblue.6"]
511
+ },
512
+ HEAD: {
513
+ bg: token["purple.1"],
514
+ color: token["purple.5"]
515
+ },
516
+ TRACE: {
517
+ bg: token["cyan.1"],
518
+ color: token["cyan.5"]
519
+ }
520
+ };
521
+ const buildTreeDataStructure = (data) => {
522
+ if (!data) return [];
523
+ return data.map((api) => {
524
+ return {
525
+ title: api.title,
526
+ key: api.id,
527
+ selectable: true,
528
+ data: api,
529
+ children: Object.entries(api.tags).map(([tag, endpoints]) => {
530
+ const tagId = `tag-${tag}`;
531
+ return {
532
+ title: tag,
533
+ key: tagId,
534
+ selectable: false,
535
+ data: {
536
+ tagName: tag,
537
+ apiData: api
538
+ },
539
+ children: endpoints.map((endpoint) => {
540
+ return {
541
+ title: endpoint.summary,
542
+ key: endpoint.id,
543
+ isLeaf: true,
544
+ selectable: true,
545
+ method: endpoint.method,
546
+ data: {
547
+ endpoint,
548
+ api,
549
+ tagName: tag
550
+ }
551
+ };
552
+ })
553
+ };
554
+ })
555
+ };
556
+ });
557
+ };
558
+ const findNodeByKey = (nodes, targetKey) => {
559
+ for (const node of nodes) {
560
+ if (node.key === targetKey) return node;
561
+ if (node.children && node.children.length > 0) {
562
+ const found = findNodeByKey(node.children, targetKey);
563
+ if (found) return found;
564
+ }
565
+ }
566
+ return null;
567
+ };
568
+ const isApiSectionHighlighted = (apiKey, selectedNode, treeDataStructure) => {
569
+ if (!selectedNode || selectedNode.length === 0) return false;
570
+ const selectedKey = selectedNode[0];
571
+ if (selectedKey === apiKey) return false;
572
+ const findNodeParentApi = (nodes, targetKey) => {
573
+ for (const node of nodes) if (node.data && "id" in node.data && "tags" in node.data && !("endpoint" in node.data) && !("tagName" in node.data)) {
574
+ const apiId = node.key;
575
+ if (node.children) for (const child of node.children) {
576
+ if (child.key === targetKey) return apiId;
577
+ if (child.children) {
578
+ for (const grandChild of child.children) if (grandChild.key === targetKey) return apiId;
579
+ }
580
+ }
581
+ }
582
+ return null;
583
+ };
584
+ const parentApiKey = findNodeParentApi(treeDataStructure, selectedKey);
585
+ return parentApiKey === apiKey;
586
+ };
587
+ const getAllTreeKeys = (data) => {
588
+ const keys = [];
589
+ const traverse = (nodes) => {
590
+ nodes.forEach((node) => {
591
+ keys.push(node.key);
592
+ if (node.children && node.children.length > 0) traverse(node.children);
593
+ });
594
+ };
595
+ traverse(data);
596
+ return keys;
597
+ };
598
+ const filterTreeData = (data, searchText) => {
599
+ if (!searchText) return data;
600
+ const findOriginalNode = (nodes, key) => {
601
+ for (const node of nodes) {
602
+ if (node.key === key) return node;
603
+ if (node.children) {
604
+ const found = findOriginalNode(node.children, key);
605
+ if (found) return found;
606
+ }
607
+ }
608
+ return null;
609
+ };
610
+ const filterNode = (node) => {
611
+ let titleText = "";
612
+ const originalNode = findOriginalNode(data, node.key);
613
+ if (originalNode && typeof originalNode.title === "string") titleText = originalNode.title;
614
+ else if (typeof node.title === "string") titleText = node.title;
615
+ let searchableText = titleText;
616
+ if (node.isLeaf && node.method) searchableText = `${node.method} ${titleText}`.toLowerCase();
617
+ else searchableText = titleText.toLowerCase();
618
+ const searchLower = searchText.toLowerCase();
619
+ const matchesSearch = searchableText.includes(searchLower);
620
+ if (node.children) {
621
+ const filteredChildren = node.children.map((child) => filterNode(child)).filter((child) => child !== null);
622
+ if (matchesSearch || filteredChildren.length > 0) return {
623
+ ...node,
624
+ children: filteredChildren
625
+ };
626
+ } else if (matchesSearch) return node;
627
+ return null;
628
+ };
629
+ return data.map((node) => filterNode(node)).filter((node) => node !== null);
630
+ };
631
+ const getSidebarStyles = (token$1, scope) => ({
632
+ [scope("sider")]: {
633
+ backgroundColor: token$1.colorBgContainer,
634
+ maxWidth: "17.5rem",
635
+ overflowY: "auto",
636
+ overflowX: "clip"
637
+ },
638
+ [scope("content")]: { padding: token$1.padding },
639
+ [scope("controls")]: {
640
+ display: "flex",
641
+ gap: token$1.marginXS,
642
+ marginBottom: token$1.marginSM
643
+ },
644
+ [scope("search-input")]: { flex: 1 },
645
+ [scope("tree")]: {
646
+ backgroundColor: "transparent",
647
+ "& .ant-tree-node-content-wrapper": {
648
+ overflow: "hidden",
649
+ width: "100%",
650
+ display: "flex",
651
+ alignItems: "center"
652
+ },
653
+ "& .ant-tree-title": {
654
+ width: "100%",
655
+ overflow: "hidden",
656
+ display: "flex",
657
+ alignItems: "center",
658
+ marginBlock: "auto"
659
+ },
660
+ "& .ant-tree-treenode": {
661
+ width: "100%",
662
+ padding: 0
663
+ },
664
+ "& .ant-tree-node-content-wrapper:hover": { backgroundColor: token$1.colorFillTertiary }
665
+ },
666
+ [scope("endpoint-item")]: {
667
+ display: "flex",
668
+ alignItems: "center",
669
+ gap: token$1.marginXS,
670
+ width: "100%",
671
+ maxWidth: "100%",
672
+ minWidth: "100%"
673
+ },
674
+ [scope("method-tag")]: {
675
+ minWidth: "3.75rem",
676
+ textAlign: "center",
677
+ border: "none"
678
+ },
679
+ [scope("endpoint-text")]: {
680
+ flex: 1,
681
+ maxWidth: "100%"
682
+ },
683
+ [scope("tag-title")]: {
684
+ color: token$1.colorText,
685
+ maxWidth: "100%",
686
+ display: "block"
687
+ },
688
+ [scope("api-title")]: {
689
+ color: token$1.colorText,
690
+ maxWidth: "100%",
691
+ display: "block",
692
+ padding: 0,
693
+ margin: 0,
694
+ "&.highlighted": { color: token$1.colorPrimary }
695
+ },
696
+ [scope("create-text")]: { color: token$1.colorTextSecondary }
697
+ });
698
+
699
+ //#endregion
700
+ //#region src/view/helper/sidebar.components.tsx
701
+ const { Text } = Typography;
702
+ const EndpointItem = ({ method, title, cx }) => {
703
+ const methodStyle = methodColors[method];
704
+ return /* @__PURE__ */ jsxs("div", {
705
+ className: cx("endpoint-item"),
706
+ children: [/* @__PURE__ */ jsx(Tag, {
707
+ className: cx("method-tag"),
708
+ style: {
709
+ backgroundColor: methodStyle?.bg,
710
+ color: methodStyle?.color,
711
+ border: "none"
712
+ },
713
+ children: method
714
+ }), /* @__PURE__ */ jsx(Text, {
715
+ className: cx("endpoint-text"),
716
+ ellipsis: { tooltip: title },
717
+ style: { flex: 1 },
718
+ children: title
719
+ })]
720
+ });
721
+ };
722
+ const convertToRenderableTreeData = (treeDataStructure, selectedNode, cx) => {
723
+ const renderNode = (node) => {
724
+ let title;
725
+ if (node.isLeaf && node.method) title = /* @__PURE__ */ jsx(EndpointItem, {
726
+ method: node.method,
727
+ title: typeof node.title === "string" ? node.title.replace(`${node.method} `, "") : "",
728
+ cx
729
+ });
730
+ else if (node.data && "id" in node.data && "tags" in node.data && !("endpoint" in node.data) && !("tagName" in node.data)) {
731
+ const isHighlighted = isApiSectionHighlighted(node.key, selectedNode, treeDataStructure);
732
+ title = /* @__PURE__ */ jsx(Text, {
733
+ className: cx("api-title") + (isHighlighted ? " highlighted" : ""),
734
+ ellipsis: { tooltip: typeof node.title === "string" ? node.title : "" },
735
+ children: node.title
736
+ });
737
+ } else title = /* @__PURE__ */ jsx(Text, {
738
+ className: cx("tag-title"),
739
+ ellipsis: { tooltip: typeof node.title === "string" ? node.title : "" },
740
+ children: node.title
741
+ });
742
+ return {
743
+ ...node,
744
+ title,
745
+ children: node.children ? node.children.map(renderNode) : void 0
746
+ };
747
+ };
748
+ return treeDataStructure.map(renderNode);
749
+ };
750
+
751
+ //#endregion
752
+ //#region src/view/components/Sidebar.tsx
753
+ const { Sider } = Layout;
754
+ const Sidebar = () => {
755
+ const expandedKeys = useStore((state) => state.view.expandedKeys);
756
+ const setExpandedKeys = useStore((state) => state.view.setExpandedKeys);
757
+ const setSelectedApi = useStore((state) => state.view.setSelectedApi);
758
+ const setSelectedEndpoint = useStore((state) => state.view.setSelectedEndpoint);
759
+ const [selectedNode, setSelectedNodeState] = useState();
760
+ const transformedData = useStore((state) => state.view.transformedData);
761
+ const builtTreeData = useMemo(() => buildTreeDataStructure(transformedData), [transformedData]);
762
+ const [searchValue, setSearchValue] = useState("");
763
+ const [autoExpandParent, setAutoExpandParent] = useState(true);
764
+ const { wrapSSR, cx } = useStyle("Sidebar", getSidebarStyles);
765
+ const handleSearch = (value) => {
766
+ if (value) {
767
+ const allKeys = getAllTreeKeys(builtTreeData);
768
+ setExpandedKeys(allKeys);
769
+ setSearchValue(value);
770
+ setAutoExpandParent(true);
771
+ } else {
772
+ setSearchValue(value);
773
+ setAutoExpandParent(false);
774
+ }
775
+ };
776
+ const renderTreeData = useMemo(() => {
777
+ return convertToRenderableTreeData(builtTreeData, selectedNode, cx);
778
+ }, [
779
+ builtTreeData,
780
+ selectedNode,
781
+ cx
782
+ ]);
783
+ const filteredTreeData = useMemo(() => {
784
+ if (!searchValue) return renderTreeData;
785
+ const filteredOriginal = filterTreeData(builtTreeData, searchValue);
786
+ return convertToRenderableTreeData(filteredOriginal, selectedNode, cx);
787
+ }, [
788
+ builtTreeData,
789
+ searchValue,
790
+ selectedNode,
791
+ cx
792
+ ]);
793
+ const collapseAll = () => {
794
+ setExpandedKeys([]);
795
+ };
796
+ const handleNodeSelection = (nodeData, nodeKey) => {
797
+ if (!nodeData) return null;
798
+ if (nodeKey.startsWith("endpoint-")) {
799
+ const endpointNodeData = nodeData;
800
+ setSelectedEndpoint(endpointNodeData.endpoint);
801
+ setSelectedApi(endpointNodeData.api);
802
+ return {
803
+ type: "endpoint",
804
+ endpoint: endpointNodeData.endpoint,
805
+ api: endpointNodeData.api,
806
+ tag: endpointNodeData.tagName
807
+ };
808
+ } else if (nodeKey.startsWith("api-") || nodeKey === "custom-auth") {
809
+ const apiData = nodeData;
810
+ setSelectedApi(apiData);
811
+ setSelectedEndpoint(null);
812
+ return {
813
+ type: "api",
814
+ api: apiData
815
+ };
816
+ } else {
817
+ const tagData = nodeData;
818
+ return {
819
+ type: "tag",
820
+ tag: tagData.tagName,
821
+ api: tagData.apiData
822
+ };
823
+ }
824
+ };
825
+ const onTreeNodeSelect = (selectedKeys) => {
826
+ const stringKeys = selectedKeys.map((key) => String(key));
827
+ if (stringKeys.length === 0) {
828
+ setSelectedNodeState([]);
829
+ setSelectedApi(null);
830
+ setSelectedEndpoint(null);
831
+ return;
832
+ }
833
+ const selectedKey = stringKeys[0];
834
+ const selectedNode$1 = findNodeByKey(builtTreeData, selectedKey);
835
+ if (selectedNode$1) handleNodeSelection(selectedNode$1.data, selectedKey);
836
+ setSelectedNodeState(stringKeys);
837
+ };
838
+ return wrapSSR(/* @__PURE__ */ jsx(Sider, {
839
+ width: 280,
840
+ className: cx("sider"),
841
+ children: /* @__PURE__ */ jsxs("div", {
842
+ className: cx("content"),
843
+ children: [/* @__PURE__ */ jsxs("div", {
844
+ className: cx("controls"),
845
+ children: [/* @__PURE__ */ jsx(Input, {
846
+ placeholder: "Search by APIs or Endpoints",
847
+ value: searchValue,
848
+ onChange: (e) => handleSearch(e.target.value),
849
+ allowClear: true,
850
+ className: cx("search-input")
851
+ }), /* @__PURE__ */ jsx(Button, {
852
+ onClick: collapseAll,
853
+ title: "Collapse All",
854
+ icon: /* @__PURE__ */ jsx(Minify_default, {})
855
+ })]
856
+ }), /* @__PURE__ */ jsx(Tree, {
857
+ showLine: { showLeafIcon: false },
858
+ showIcon: false,
859
+ expandedKeys,
860
+ autoExpandParent,
861
+ selectedKeys: selectedNode,
862
+ onSelect: onTreeNodeSelect,
863
+ onExpand: (expandedKeysValue) => {
864
+ setExpandedKeys(expandedKeysValue);
865
+ setAutoExpandParent(false);
866
+ },
867
+ treeData: filteredTreeData,
868
+ className: cx("tree")
869
+ })]
870
+ })
871
+ }));
872
+ };
873
+
126
874
  //#endregion
127
875
  //#region src/view/components/MainContent.tsx
128
876
  const MainContent = () => {
129
- const { wrapSSR, cx } = useStyle("MainContent", (token, scope) => ({ [scope("container")]: {
130
- backgroundColor: token.colorBgContainer,
877
+ const { wrapSSR, cx } = useStyle("MainContent", (token$1, scope) => ({ [scope("container")]: {
878
+ backgroundColor: token$1.colorBgContainer,
131
879
  height: "100%",
132
880
  width: "100%",
133
881
  maxHeight: "100%",
134
882
  overflow: "auto",
135
- borderRadius: token.borderRadius,
136
- padding: token.paddingXL
883
+ borderRadius: token$1.borderRadius,
884
+ padding: token$1.paddingXL
137
885
  } }));
138
886
  return wrapSSR(/* @__PURE__ */ jsx("div", { className: cx("container") }));
139
887
  };
@@ -156,17 +904,17 @@ const transformOpenApiToDocs = (api) => {
156
904
  if (!groupedPathsByTags[tag]) groupedPathsByTags[tag] = [];
157
905
  groupedPathsByTags[tag].push({
158
906
  ...entry,
159
- id: `endpoint-${nanoid(8)}`
907
+ id: `endpoint-${entry.summary}`
160
908
  });
161
909
  });
162
910
  else groupedPathsByTags.default.push({
163
911
  ...entry,
164
- id: `endpoint-${nanoid(8)}`
912
+ id: `endpoint-${entry.summary}`
165
913
  });
166
914
  }
167
915
  return {
168
916
  ...api.info,
169
- id: `api-${nanoid(8)}`,
917
+ id: `api-${api.info.title}`,
170
918
  contextPath,
171
919
  tags: groupedPathsByTags,
172
920
  servers: api.servers
@@ -177,18 +925,17 @@ const transformOpenApiToDocs = (api) => {
177
925
  //#region src/view/layout.tsx
178
926
  const DocumentationLayout = ({ data }) => {
179
927
  const { setOriginalData } = store_default(({ view }) => view);
180
- const { setTransformedData, transformedData } = store_default(({ view }) => view);
181
- console.log({ transformedData });
928
+ const { setTransformedData } = store_default(({ view }) => view);
182
929
  useEffect(() => {
183
930
  setOriginalData(data);
184
- const transformedData$1 = data.map(transformOpenApiToDocs);
185
- setTransformedData(transformedData$1);
931
+ const transformedData = data.map(transformOpenApiToDocs);
932
+ setTransformedData(transformedData);
186
933
  }, [data]);
187
- const { cx } = useStyle("DocumentationLayout", (token, scope) => ({
934
+ const { cx } = useStyle("DocumentationLayout", (token$1, scope) => ({
188
935
  [scope("container")]: {
189
936
  display: "flex",
190
937
  flexDirection: "column",
191
- gap: token.marginLG,
938
+ gap: token$1.marginLG,
192
939
  height: "100%",
193
940
  maxHeight: "100%",
194
941
  overflow: "hidden"
@@ -198,14 +945,14 @@ const DocumentationLayout = ({ data }) => {
198
945
  height: "100%",
199
946
  maxHeight: "100%",
200
947
  overflow: "hidden",
201
- gap: token.marginLG
948
+ gap: token$1.marginLG
202
949
  }
203
950
  }));
204
951
  return /* @__PURE__ */ jsx(AntdRegistry, { children: /* @__PURE__ */ jsxs("div", {
205
952
  className: cx("container"),
206
- children: [/* @__PURE__ */ jsx(Header, {}), /* @__PURE__ */ jsx("div", {
953
+ children: [/* @__PURE__ */ jsx(Header, {}), /* @__PURE__ */ jsxs("div", {
207
954
  className: cx("layout"),
208
- children: /* @__PURE__ */ jsx(MainContent, {})
955
+ children: [/* @__PURE__ */ jsx(Sidebar, {}), /* @__PURE__ */ jsx(MainContent, {})]
209
956
  })]
210
957
  }) });
211
958
  };