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