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