@digi-frontend/dgate-api-documentation 2.0.1-test.11 → 2.0.1-test.13

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,40 +1,44 @@
1
- import "node:module";
2
- import { create } from "zustand";
3
- import { devtools } from "zustand/middleware";
4
- import { immer } from "zustand/middleware/immer";
5
1
  import * as React$1 from "react";
6
2
  import { useEffect, useMemo, useState } from "react";
7
3
  import { Button, Input, Layout, Tag, Tree, Typography, theme } from "antd";
8
4
  import { useStyleRegister } from "@ant-design/cssinjs";
9
5
  import { jsx, jsxs } from "react/jsx-runtime";
6
+ import { create } from "zustand";
7
+ import { devtools } from "zustand/middleware";
8
+ import { immer } from "zustand/middleware/immer";
10
9
  import { nanoid } from "nanoid";
11
10
  import { AntdRegistry } from "@ant-design/nextjs-registry";
12
11
 
13
- //#region rolldown:runtime
14
- var __defProp = Object.defineProperty;
15
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
16
- var __getOwnPropNames = Object.getOwnPropertyNames;
17
- var __hasOwnProp = Object.prototype.hasOwnProperty;
18
- var __esm = (fn, res) => function() {
19
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
20
- };
21
- var __export = (target, all) => {
22
- for (var name in all) __defProp(target, name, {
23
- get: all[name],
24
- enumerable: true
25
- });
26
- };
27
- var __copyProps = (to, from, except, desc) => {
28
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
29
- key = keys[i];
30
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
31
- get: ((k) => from[k]).bind(null, key),
32
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
33
- });
34
- }
35
- return to;
12
+ //#region src/hooks/useStyle.ts
13
+ function useStyle(componentName, stylesFn) {
14
+ const { token: token$1, theme: theme$1, hashId } = theme.useToken();
15
+ const scope = (className) => `.${hashId}.${componentName}-${className}`;
16
+ const cx = (...classes) => classes.map((cls) => `${componentName}-${cls} ${hashId}`).join(" ");
17
+ const wrapSSR = useStyleRegister({
18
+ theme: theme$1,
19
+ token: token$1,
20
+ path: [componentName]
21
+ }, () => stylesFn(token$1, scope));
22
+ return {
23
+ wrapSSR,
24
+ cx,
25
+ scope,
26
+ token: token$1,
27
+ hashId
28
+ };
29
+ }
30
+
31
+ //#endregion
32
+ //#region src/view/components/Header.tsx
33
+ const { Header: AntHeader } = Layout;
34
+ const Header = () => {
35
+ const { wrapSSR, cx } = useStyle("Header", (token$1, scope) => ({ [scope("header")]: {
36
+ width: "100%",
37
+ height: "4rem",
38
+ backgroundColor: token$1.colorBgContainer
39
+ } }));
40
+ return wrapSSR(/* @__PURE__ */ jsx(AntHeader, { className: cx("header") }));
36
41
  };
37
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
38
42
 
39
43
  //#endregion
40
44
  //#region src/store/slices/view.ts
@@ -120,38 +124,6 @@ const createStore = (set) => ({
120
124
  const useStore = create()(devtools(immer(createStore), { name: "dgate-docs-store" }));
121
125
  var store_default = useStore;
122
126
 
123
- //#endregion
124
- //#region src/hooks/useStyle.ts
125
- function useStyle(componentName, stylesFn) {
126
- const { token: token$1, theme: theme$1, hashId } = theme.useToken();
127
- const scope = (className) => `.${hashId}.${componentName}-${className}`;
128
- const cx = (...classes) => classes.map((cls) => `${componentName}-${cls} ${hashId}`).join(" ");
129
- const wrapSSR = useStyleRegister({
130
- theme: theme$1,
131
- token: token$1,
132
- path: [componentName]
133
- }, () => stylesFn(token$1, scope));
134
- return {
135
- wrapSSR,
136
- cx,
137
- scope,
138
- token: token$1,
139
- hashId
140
- };
141
- }
142
-
143
- //#endregion
144
- //#region src/view/components/Header.tsx
145
- const { Header: AntHeader } = Layout;
146
- const Header = () => {
147
- const { wrapSSR, cx } = useStyle("Header", (token$1, scope) => ({ [scope("header")]: {
148
- width: "100%",
149
- height: "4rem",
150
- backgroundColor: token$1.colorBgContainer
151
- } }));
152
- return wrapSSR(/* @__PURE__ */ jsx(AntHeader, { className: cx("header") }));
153
- };
154
-
155
127
  //#endregion
156
128
  //#region src/assets/Minify.svg
157
129
  var _path;
@@ -510,563 +482,391 @@ var token = {
510
482
 
511
483
  //#endregion
512
484
  //#region src/view/helper/sidebar.utils.ts
513
- var methodColors, buildTreeDataStructure, findNodeByKey, isApiSectionHighlighted, getAllTreeKeys, filterTreeData, getParentKey, getSidebarStyles;
514
- var init_sidebar_utils = __esm({ "src/view/helper/sidebar.utils.ts": (() => {
515
- methodColors = {
516
- GET: {
517
- bg: token.colorPrimaryBgHover,
518
- color: token.colorPrimary
519
- },
520
- POST: {
521
- bg: token["green.1"],
522
- color: token.colorSuccess
523
- },
524
- DELETE: {
525
- bg: token.colorErrorBg,
526
- color: token.colorError
527
- },
528
- PUT: {
529
- bg: token.colorWarningBg,
530
- color: token.colorWarning
531
- },
532
- PATCH: {
533
- bg: token["volcano.5"],
534
- color: token.colorWhite
535
- },
536
- OPTIONS: {
537
- bg: token["geekblue.2"],
538
- color: token["geekblue.6"]
539
- },
540
- HEAD: {
541
- bg: token["purple.1"],
542
- color: token["purple.5"]
543
- },
544
- TRACE: {
545
- bg: token["cyan.1"],
546
- color: token["cyan.5"]
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-${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;
547
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;
548
581
  };
549
- buildTreeDataStructure = (data) => {
550
- if (!data) return [];
551
- return data.map((api) => {
552
- return {
553
- title: api.title,
554
- key: api.id,
555
- selectable: true,
556
- data: api,
557
- children: Object.entries(api.tags).map(([tag, endpoints]) => {
558
- const tagId = `tag-${nanoid(8)}`;
559
- return {
560
- title: tag,
561
- key: tagId,
562
- selectable: false,
563
- data: {
564
- tagName: tag,
565
- apiData: api
566
- },
567
- children: endpoints.map((endpoint) => {
568
- return {
569
- title: endpoint.summary,
570
- key: endpoint.id,
571
- isLeaf: true,
572
- selectable: true,
573
- method: endpoint.method,
574
- data: {
575
- endpoint,
576
- api,
577
- tagName: tag
578
- }
579
- };
580
- })
581
- };
582
- })
583
- };
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);
584
591
  });
585
592
  };
586
- findNodeByKey = (nodes, targetKey) => {
593
+ traverse(data);
594
+ return keys;
595
+ };
596
+ const filterTreeData = (data, searchText) => {
597
+ if (!searchText) return data;
598
+ const findOriginalNode = (nodes, key) => {
587
599
  for (const node of nodes) {
588
- if (node.key === targetKey) return node;
589
- if (node.children && node.children.length > 0) {
590
- const found = findNodeByKey(node.children, targetKey);
600
+ if (node.key === key) return node;
601
+ if (node.children) {
602
+ const found = findOriginalNode(node.children, key);
591
603
  if (found) return found;
592
604
  }
593
605
  }
594
606
  return null;
595
607
  };
596
- isApiSectionHighlighted = (apiKey, selectedNode, treeDataStructure) => {
597
- if (!selectedNode || selectedNode.length === 0) return false;
598
- const selectedKey = selectedNode[0];
599
- if (selectedKey === apiKey) return false;
600
- const findNodeParentApi = (nodes, targetKey) => {
601
- for (const node of nodes) if (node.data && "id" in node.data && "tags" in node.data && !("endpoint" in node.data) && !("tagName" in node.data)) {
602
- const apiId = node.key;
603
- if (node.children) for (const child of node.children) {
604
- if (child.key === targetKey) return apiId;
605
- if (child.children) {
606
- for (const grandChild of child.children) if (grandChild.key === targetKey) return apiId;
607
- }
608
- }
609
- }
610
- return null;
611
- };
612
- const parentApiKey = findNodeParentApi(treeDataStructure, selectedKey);
613
- return parentApiKey === apiKey;
614
- };
615
- getAllTreeKeys = (data) => {
616
- const keys = [];
617
- const traverse = (nodes) => {
618
- nodes.forEach((node) => {
619
- keys.push(node.key);
620
- if (node.children && node.children.length > 0) traverse(node.children);
621
- });
622
- };
623
- traverse(data);
624
- return keys;
625
- };
626
- filterTreeData = (data, searchText) => {
627
- if (!searchText) return data;
628
- const findOriginalNode = (nodes, key) => {
629
- for (const node of nodes) {
630
- if (node.key === key) return node;
631
- if (node.children) {
632
- const found = findOriginalNode(node.children, key);
633
- if (found) return found;
634
- }
635
- }
636
- return null;
637
- };
638
- const filterNode = (node) => {
639
- let titleText = "";
640
- const originalNode = findOriginalNode(data, node.key);
641
- if (originalNode && typeof originalNode.title === "string") titleText = originalNode.title;
642
- else if (typeof node.title === "string") titleText = node.title;
643
- let searchableText = titleText;
644
- if (node.isLeaf && node.method) searchableText = `${node.method} ${titleText}`.toLowerCase();
645
- else searchableText = titleText.toLowerCase();
646
- const searchLower = searchText.toLowerCase();
647
- const matchesSearch = searchableText.includes(searchLower);
648
- if (node.children) {
649
- const filteredChildren = node.children.map((child) => filterNode(child)).filter((child) => child !== null);
650
- if (matchesSearch || filteredChildren.length > 0) return {
651
- ...node,
652
- children: filteredChildren
653
- };
654
- } else if (matchesSearch) return node;
655
- return null;
656
- };
657
- return data.map((node) => filterNode(node)).filter((node) => node !== null);
658
- };
659
- getParentKey = (key, tree) => {
660
- for (let i = 0; i < tree.length; i++) {
661
- const node = tree[i];
662
- if (node.children) {
663
- if (node.children.some((item) => item.key === key)) return node.key;
664
- const parent = getParentKey(key, node.children);
665
- if (parent) return parent;
666
- }
667
- }
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;
668
625
  return null;
669
626
  };
670
- getSidebarStyles = (token$1, scope) => ({
671
- [scope("sider")]: {
672
- backgroundColor: token$1.colorBgContainer,
673
- maxWidth: "17.5rem",
674
- overflowY: "auto",
675
- overflowX: "clip"
676
- },
677
- [scope("content")]: { padding: token$1.padding },
678
- [scope("controls")]: {
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%",
679
648
  display: "flex",
680
- gap: token$1.marginXS,
681
- marginBottom: token$1.marginSM
649
+ alignItems: "center"
682
650
  },
683
- [scope("search-input")]: { flex: 1 },
684
- [scope("tree")]: {
685
- backgroundColor: "transparent",
686
- "& .ant-tree-node-content-wrapper": {
687
- overflow: "hidden",
688
- width: "100%",
689
- display: "flex",
690
- alignItems: "center"
691
- },
692
- "& .ant-tree-title": {
693
- width: "100%",
694
- overflow: "hidden",
695
- display: "flex",
696
- alignItems: "center",
697
- marginBlock: "auto"
698
- },
699
- "& .ant-tree-treenode": {
700
- width: "100%",
701
- padding: 0
702
- },
703
- "& .ant-tree-node-content-wrapper:hover": { backgroundColor: token$1.colorFillTertiary }
704
- },
705
- [scope("endpoint-item")]: {
651
+ "& .ant-tree-title": {
652
+ width: "100%",
653
+ overflow: "hidden",
706
654
  display: "flex",
707
655
  alignItems: "center",
708
- gap: token$1.marginXS,
709
- width: "100%",
710
- maxWidth: "100%",
711
- minWidth: "100%"
712
- },
713
- [scope("method-tag")]: {
714
- minWidth: "3.75rem",
715
- textAlign: "center",
716
- border: "none"
717
- },
718
- [scope("endpoint-text")]: {
719
- flex: 1,
720
- maxWidth: "100%"
656
+ marginBlock: "auto"
721
657
  },
722
- [scope("tag-title")]: {
723
- color: token$1.colorText,
724
- maxWidth: "100%",
725
- display: "block"
726
- },
727
- [scope("api-title")]: {
728
- color: token$1.colorText,
729
- maxWidth: "100%",
730
- display: "block",
731
- padding: 0,
732
- margin: 0,
733
- "&.highlighted": { color: token$1.colorPrimary }
658
+ "& .ant-tree-treenode": {
659
+ width: "100%",
660
+ padding: 0
734
661
  },
735
- [scope("create-text")]: { color: token$1.colorTextSecondary }
736
- });
737
- }) });
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
+ });
738
696
 
739
697
  //#endregion
740
698
  //#region src/view/helper/sidebar.components.tsx
741
- var Text, EndpointItem, convertToRenderableTreeData;
742
- var init_sidebar_components = __esm({ "src/view/helper/sidebar.components.tsx": (() => {
743
- init_sidebar_utils();
744
- ({Text} = Typography);
745
- EndpointItem = ({ method, title, cx }) => {
746
- const methodStyle = methodColors[method];
747
- return /* @__PURE__ */ jsxs("div", {
748
- className: cx("endpoint-item"),
749
- children: [/* @__PURE__ */ jsx(Tag, {
750
- className: cx("method-tag"),
751
- style: {
752
- backgroundColor: methodStyle?.bg,
753
- color: methodStyle?.color,
754
- border: "none"
755
- },
756
- children: method
757
- }), /* @__PURE__ */ jsx(Text, {
758
- className: cx("endpoint-text"),
759
- ellipsis: { tooltip: title },
760
- style: { flex: 1 },
761
- children: title
762
- })]
699
+ const { Text } = Typography;
700
+ const EndpointItem = ({ method, title, cx }) => {
701
+ const methodStyle = methodColors[method];
702
+ return /* @__PURE__ */ jsxs("div", {
703
+ className: cx("endpoint-item"),
704
+ children: [/* @__PURE__ */ jsx(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__ */ 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__ */ jsx(EndpointItem, {
724
+ method: node.method,
725
+ title: typeof node.title === "string" ? node.title.replace(`${node.method} `, "") : "",
726
+ cx
763
727
  });
764
- };
765
- convertToRenderableTreeData = (treeDataStructure, selectedNode, cx) => {
766
- const renderNode = (node) => {
767
- let title;
768
- if (node.isLeaf && node.method) title = /* @__PURE__ */ jsx(EndpointItem, {
769
- method: node.method,
770
- title: typeof node.title === "string" ? node.title.replace(`${node.method} `, "") : "",
771
- cx
772
- });
773
- else if (node.data && "id" in node.data && "tags" in node.data && !("endpoint" in node.data) && !("tagName" in node.data)) {
774
- const isHighlighted = isApiSectionHighlighted(node.key, selectedNode, treeDataStructure);
775
- title = /* @__PURE__ */ jsx(Text, {
776
- className: cx("api-title") + (isHighlighted ? " highlighted" : ""),
777
- ellipsis: { tooltip: typeof node.title === "string" ? node.title : "" },
778
- children: node.title
779
- });
780
- } else title = /* @__PURE__ */ jsx(Text, {
781
- className: cx("tag-title"),
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__ */ jsx(Text, {
731
+ className: cx("api-title") + (isHighlighted ? " highlighted" : ""),
782
732
  ellipsis: { tooltip: typeof node.title === "string" ? node.title : "" },
783
733
  children: node.title
784
734
  });
785
- return {
786
- ...node,
787
- title,
788
- children: node.children ? node.children.map(renderNode) : void 0
789
- };
735
+ } else title = /* @__PURE__ */ 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
790
744
  };
791
- return treeDataStructure.map(renderNode);
792
745
  };
793
- }) });
794
-
795
- //#endregion
796
- //#region src/view/helper/index.ts
797
- var helper_exports = {};
798
- __export(helper_exports, {
799
- EndpointItem: () => EndpointItem,
800
- buildTreeDataStructure: () => buildTreeDataStructure,
801
- convertToRenderableTreeData: () => convertToRenderableTreeData,
802
- filterTreeData: () => filterTreeData,
803
- findNodeByKey: () => findNodeByKey,
804
- getAllTreeKeys: () => getAllTreeKeys,
805
- getParentKey: () => getParentKey,
806
- getSidebarStyles: () => getSidebarStyles,
807
- isApiSectionHighlighted: () => isApiSectionHighlighted,
808
- methodColors: () => methodColors
809
- });
810
- var init_helper = __esm({ "src/view/helper/index.ts": (() => {
811
- init_sidebar_utils();
812
- init_sidebar_components();
813
- }) });
746
+ return treeDataStructure.map(renderNode);
747
+ };
814
748
 
815
749
  //#endregion
816
750
  //#region src/view/components/Sidebar.tsx
817
751
  const { Sider } = Layout;
818
- const safeHelperCall = (fn, args, functionName) => {
819
- try {
820
- if (!fn) {
821
- console.error(`[Sidebar] Function ${functionName} is not available`);
822
- return null;
823
- }
824
- const result = fn(...args);
825
- console.log(`[Sidebar] ${functionName} executed successfully`);
826
- return result;
827
- } catch (error) {
828
- console.error(`[Sidebar] Error in ${functionName}:`, error);
829
- return null;
830
- }
831
- };
832
752
  const Sidebar = () => {
833
- try {
834
- let getAllTreeKeys$1, filterTreeData$1, getSidebarStyles$1, convertToRenderableTreeData$1, buildTreeDataStructure$1, findNodeByKey$1;
835
- try {
836
- const helperImports = (init_helper(), __toCommonJS(helper_exports));
837
- getAllTreeKeys$1 = helperImports.getAllTreeKeys;
838
- filterTreeData$1 = helperImports.filterTreeData;
839
- getSidebarStyles$1 = helperImports.getSidebarStyles;
840
- convertToRenderableTreeData$1 = helperImports.convertToRenderableTreeData;
841
- buildTreeDataStructure$1 = helperImports.buildTreeDataStructure;
842
- findNodeByKey$1 = helperImports.findNodeByKey;
843
- console.log("[Sidebar] Helper functions imported successfully");
844
- } catch (error) {
845
- console.error("[Sidebar] Error importing helper functions:", error);
846
- return /* @__PURE__ */ jsx(Sider, {
847
- width: 280,
848
- style: {
849
- backgroundColor: "#f5f5f5",
850
- border: "1px solid orange"
851
- },
852
- children: /* @__PURE__ */ jsxs("div", {
853
- style: { padding: 16 },
854
- children: [/* @__PURE__ */ jsx("h4", {
855
- style: {
856
- color: "#fa8c16",
857
- margin: 0
858
- },
859
- children: "Import Error"
860
- }), /* @__PURE__ */ jsx("p", {
861
- style: {
862
- fontSize: "12px",
863
- color: "#666",
864
- margin: "8px 0 0 0"
865
- },
866
- children: "Could not import helper functions. Check console."
867
- })]
868
- })
869
- });
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] = useState();
758
+ const transformedData = useStore((state) => state.view.transformedData);
759
+ const builtTreeData = useMemo(() => buildTreeDataStructure(transformedData), [transformedData]);
760
+ const [searchValue, setSearchValue] = useState("");
761
+ const [autoExpandParent, setAutoExpandParent] = 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);
870
772
  }
871
- const expandedKeys = useStore((state) => state.view.expandedKeys);
872
- const setExpandedKeys = useStore((state) => state.view.setExpandedKeys);
873
- const setSelectedApi = useStore((state) => state.view.setSelectedApi);
874
- const setSelectedEndpoint = useStore((state) => state.view.setSelectedEndpoint);
875
- const [selectedNode, setSelectedNodeState] = useState();
876
- const transformedData = useStore((state) => state.view.transformedData);
877
- console.log("[Sidebar] Store access successful, transformedData:", transformedData);
878
- const builtTreeData = useMemo(() => {
879
- console.log("[Sidebar] Building tree data...");
880
- return safeHelperCall(buildTreeDataStructure$1, [transformedData], "buildTreeDataStructure") || [];
881
- }, [transformedData, buildTreeDataStructure$1]);
882
- const [searchValue, setSearchValue] = useState("");
883
- const [autoExpandParent, setAutoExpandParent] = useState(true);
884
- let wrapSSR, cx;
885
- try {
886
- const styleResult = useStyle("Sidebar", getSidebarStyles$1);
887
- wrapSSR = styleResult.wrapSSR;
888
- cx = styleResult.cx;
889
- console.log("[Sidebar] useStyle executed successfully");
890
- } catch (error) {
891
- console.error("[Sidebar] Error in useStyle:", error);
892
- wrapSSR = (children) => children;
893
- cx = (className) => className;
773
+ };
774
+ const renderTreeData = useMemo(() => {
775
+ return convertToRenderableTreeData(builtTreeData, selectedNode, cx);
776
+ }, [
777
+ builtTreeData,
778
+ selectedNode,
779
+ cx
780
+ ]);
781
+ const filteredTreeData = 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
+ };
894
821
  }
895
- const handleSearch = (value) => {
896
- try {
897
- if (value) {
898
- const allKeys = safeHelperCall(getAllTreeKeys$1, [builtTreeData], "getAllTreeKeys") || [];
899
- setExpandedKeys(allKeys);
900
- setSearchValue(value);
901
- setAutoExpandParent(true);
902
- } else {
903
- setSearchValue(value);
904
- setAutoExpandParent(false);
905
- }
906
- } catch (error) {
907
- console.error("[Sidebar] Error in handleSearch:", error);
908
- }
909
- };
910
- const renderTreeData = useMemo(() => {
911
- console.log("[Sidebar] Converting to renderable tree data...");
912
- return safeHelperCall(convertToRenderableTreeData$1, [
913
- builtTreeData,
914
- selectedNode,
915
- cx
916
- ], "convertToRenderableTreeData") || [];
917
- }, [
918
- builtTreeData,
919
- selectedNode,
920
- cx,
921
- convertToRenderableTreeData$1
922
- ]);
923
- const filteredTreeData = useMemo(() => {
924
- try {
925
- if (!searchValue) return renderTreeData;
926
- console.log("[Sidebar] Filtering tree data...");
927
- const filteredOriginal = safeHelperCall(filterTreeData$1, [builtTreeData, searchValue], "filterTreeData") || [];
928
- return safeHelperCall(convertToRenderableTreeData$1, [
929
- filteredOriginal,
930
- selectedNode,
931
- cx
932
- ], "convertToRenderableTreeData for filtered") || [];
933
- } catch (error) {
934
- console.error("[Sidebar] Error in filteredTreeData:", error);
935
- return [];
936
- }
937
- }, [
938
- builtTreeData,
939
- searchValue,
940
- selectedNode,
941
- cx,
942
- renderTreeData,
943
- filterTreeData$1,
944
- convertToRenderableTreeData$1
945
- ]);
946
- const collapseAll = () => {
947
- try {
948
- setExpandedKeys([]);
949
- } catch (error) {
950
- console.error("[Sidebar] Error in collapseAll:", error);
951
- }
952
- };
953
- const handleNodeSelection = (nodeData, nodeKey) => {
954
- try {
955
- if (!nodeData) return null;
956
- if (nodeKey.startsWith("endpoint-")) {
957
- const endpointNodeData = nodeData;
958
- setSelectedEndpoint(endpointNodeData.endpoint);
959
- setSelectedApi(endpointNodeData.api);
960
- return {
961
- type: "endpoint",
962
- endpoint: endpointNodeData.endpoint,
963
- api: endpointNodeData.api,
964
- tag: endpointNodeData.tagName
965
- };
966
- } else if (nodeKey.startsWith("api-") || nodeKey === "custom-auth") {
967
- const apiData = nodeData;
968
- setSelectedApi(apiData);
969
- setSelectedEndpoint(null);
970
- return {
971
- type: "api",
972
- api: apiData
973
- };
974
- } else {
975
- const tagData = nodeData;
976
- return {
977
- type: "tag",
978
- tag: tagData.tagName,
979
- api: tagData.apiData
980
- };
981
- }
982
- } catch (error) {
983
- console.error("[Sidebar] Error in handleNodeSelection:", error);
984
- return null;
985
- }
986
- };
987
- const onTreeNodeSelect = (selectedKeys) => {
988
- try {
989
- const stringKeys = selectedKeys.map((key) => String(key));
990
- console.log("[Sidebar] onTreeNodeSelect called with:", stringKeys);
991
- if (stringKeys.length === 0) {
992
- setSelectedNodeState([]);
993
- setSelectedApi(null);
994
- setSelectedEndpoint(null);
995
- return;
996
- }
997
- const selectedKey = stringKeys[0];
998
- const selectedNode$1 = safeHelperCall(findNodeByKey$1, [builtTreeData, selectedKey], "findNodeByKey");
999
- if (selectedNode$1) handleNodeSelection(selectedNode$1.data, selectedKey);
1000
- setSelectedNodeState(stringKeys);
1001
- } catch (error) {
1002
- console.error("[Sidebar] Error in onTreeNodeSelect:", error);
1003
- }
1004
- };
1005
- return wrapSSR(/* @__PURE__ */ jsx(Sider, {
1006
- width: 280,
1007
- className: cx("sider"),
1008
- children: /* @__PURE__ */ jsxs("div", {
1009
- className: cx("content"),
1010
- children: [/* @__PURE__ */ jsxs("div", {
1011
- className: cx("controls"),
1012
- children: [/* @__PURE__ */ jsx(Input, {
1013
- placeholder: "Search by APIs or Endpoints",
1014
- value: searchValue,
1015
- onChange: (e) => handleSearch(e.target.value),
1016
- allowClear: true,
1017
- className: cx("search-input")
1018
- }), /* @__PURE__ */ jsx(Button, {
1019
- onClick: collapseAll,
1020
- title: "Collapse All",
1021
- icon: /* @__PURE__ */ jsx(Minify_default, {})
1022
- })]
1023
- }), /* @__PURE__ */ jsx(Tree, {
1024
- showLine: { showLeafIcon: false },
1025
- showIcon: false,
1026
- expandedKeys,
1027
- autoExpandParent,
1028
- selectedKeys: selectedNode,
1029
- onSelect: onTreeNodeSelect,
1030
- onExpand: (expandedKeysValue) => {
1031
- try {
1032
- setExpandedKeys(expandedKeysValue);
1033
- setAutoExpandParent(false);
1034
- } catch (error) {
1035
- console.error("[Sidebar] Error in onExpand:", error);
1036
- }
1037
- },
1038
- treeData: filteredTreeData,
1039
- className: cx("tree")
1040
- })]
1041
- })
1042
- }));
1043
- } catch (error) {
1044
- console.error("[Sidebar] Critical error in Sidebar component:", error);
1045
- return /* @__PURE__ */ jsx(Sider, {
1046
- width: 280,
1047
- style: {
1048
- backgroundColor: "#f5f5f5",
1049
- border: "1px solid red"
1050
- },
1051
- children: /* @__PURE__ */ jsxs("div", {
1052
- style: { padding: 16 },
1053
- children: [/* @__PURE__ */ jsx("h4", {
1054
- style: {
1055
- color: "#ff4d4f",
1056
- margin: 0
1057
- },
1058
- children: "Sidebar Error"
1059
- }), /* @__PURE__ */ jsx("p", {
1060
- style: {
1061
- fontSize: "12px",
1062
- color: "#666",
1063
- margin: "8px 0 0 0"
1064
- },
1065
- children: "Critical error occurred. Check console."
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__ */ jsx(Sider, {
837
+ width: 280,
838
+ className: cx("sider"),
839
+ children: /* @__PURE__ */ jsxs("div", {
840
+ className: cx("content"),
841
+ children: [/* @__PURE__ */ jsxs("div", {
842
+ className: cx("controls"),
843
+ children: [/* @__PURE__ */ jsx(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__ */ jsx(Button, {
850
+ onClick: collapseAll,
851
+ title: "Collapse All",
852
+ icon: /* @__PURE__ */ jsx(Minify_default, {})
1066
853
  })]
1067
- })
1068
- });
1069
- }
854
+ }), /* @__PURE__ */ jsx(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
+ }));
1070
870
  };
1071
871
 
1072
872
  //#endregion
@@ -1156,5 +956,5 @@ const DocumentationLayout = ({ data }) => {
1156
956
  };
1157
957
 
1158
958
  //#endregion
1159
- export { DocumentationLayout, useStore };
959
+ export { DocumentationLayout };
1160
960
  //# sourceMappingURL=index.js.map