@digi-frontend/dgate-api-documentation 2.0.1-test.15 → 2.0.1-test.2

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