@digi-frontend/dgate-api-documentation 1.0.47 → 1.0.50

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.
Files changed (138) hide show
  1. package/dist/_virtual/core.js +2 -0
  2. package/dist/_virtual/core.js.map +1 -0
  3. package/dist/_virtual/core2.js +2 -0
  4. package/dist/_virtual/core2.js.map +1 -0
  5. package/dist/_virtual/format.js +2 -0
  6. package/dist/_virtual/format.js.map +1 -0
  7. package/dist/_virtual/index3.js +1 -1
  8. package/dist/_virtual/index4.js +1 -1
  9. package/dist/_virtual/index5.js +1 -1
  10. package/dist/_virtual/index6.js +1 -1
  11. package/dist/f4452c3ebcf0d5da.svg +4 -0
  12. package/dist/node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js +2 -0
  13. package/dist/node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js.map +1 -0
  14. package/dist/node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js +2 -0
  15. package/dist/node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js.map +1 -0
  16. package/dist/node_modules/@babel/runtime/helpers/esm/defineProperty.js +2 -0
  17. package/dist/node_modules/@babel/runtime/helpers/esm/defineProperty.js.map +1 -0
  18. package/dist/node_modules/@babel/runtime/helpers/esm/extends.js +2 -0
  19. package/dist/node_modules/@babel/runtime/helpers/esm/extends.js.map +1 -0
  20. package/dist/node_modules/@babel/runtime/helpers/esm/iterableToArray.js +2 -0
  21. package/dist/node_modules/@babel/runtime/helpers/esm/iterableToArray.js.map +1 -0
  22. package/dist/node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js +2 -0
  23. package/dist/node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js.map +1 -0
  24. package/dist/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js +2 -0
  25. package/dist/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js.map +1 -0
  26. package/dist/node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js +2 -0
  27. package/dist/node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js.map +1 -0
  28. package/dist/node_modules/@babel/runtime/helpers/esm/toConsumableArray.js +2 -0
  29. package/dist/node_modules/@babel/runtime/helpers/esm/toConsumableArray.js.map +1 -0
  30. package/dist/node_modules/@babel/runtime/helpers/esm/toPrimitive.js +2 -0
  31. package/dist/node_modules/@babel/runtime/helpers/esm/toPrimitive.js.map +1 -0
  32. package/dist/node_modules/@babel/runtime/helpers/esm/toPropertyKey.js +2 -0
  33. package/dist/node_modules/@babel/runtime/helpers/esm/toPropertyKey.js.map +1 -0
  34. package/dist/node_modules/@babel/runtime/helpers/esm/typeof.js +2 -0
  35. package/dist/node_modules/@babel/runtime/helpers/esm/typeof.js.map +1 -0
  36. package/dist/node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js +2 -0
  37. package/dist/node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js.map +1 -0
  38. package/dist/node_modules/fault/index.js +2 -0
  39. package/dist/node_modules/fault/index.js.map +1 -0
  40. package/dist/node_modules/format/format.js +2 -0
  41. package/dist/node_modules/format/format.js.map +1 -0
  42. package/dist/node_modules/highlight.js/lib/core.js +2 -0
  43. package/dist/node_modules/highlight.js/lib/core.js.map +1 -0
  44. package/dist/node_modules/lowlight/lib/core.js +2 -0
  45. package/dist/node_modules/lowlight/lib/core.js.map +1 -0
  46. package/dist/node_modules/nanoid/index.js +2 -0
  47. package/dist/node_modules/nanoid/index.js.map +1 -0
  48. package/dist/node_modules/nanoid/url-alphabet/index.js +2 -0
  49. package/dist/node_modules/nanoid/url-alphabet/index.js.map +1 -0
  50. package/dist/node_modules/react-syntax-highlighter/dist/esm/checkForListedLanguage.js +2 -0
  51. package/dist/node_modules/react-syntax-highlighter/dist/esm/checkForListedLanguage.js.map +1 -0
  52. package/dist/node_modules/react-syntax-highlighter/dist/esm/create-element.js +2 -0
  53. package/dist/node_modules/react-syntax-highlighter/dist/esm/create-element.js.map +1 -0
  54. package/dist/node_modules/react-syntax-highlighter/dist/esm/highlight.js +2 -0
  55. package/dist/node_modules/react-syntax-highlighter/dist/esm/highlight.js.map +1 -0
  56. package/dist/node_modules/react-syntax-highlighter/dist/esm/light.js +2 -0
  57. package/dist/node_modules/react-syntax-highlighter/dist/esm/light.js.map +1 -0
  58. package/dist/node_modules/react-syntax-highlighter/dist/esm/styles/hljs/stackoverflow-dark.js +2 -0
  59. package/dist/node_modules/react-syntax-highlighter/dist/esm/styles/hljs/stackoverflow-dark.js.map +1 -0
  60. package/dist/node_modules/react-syntax-highlighter/dist/esm/styles/hljs/stackoverflow-light.js +2 -0
  61. package/dist/node_modules/react-syntax-highlighter/dist/esm/styles/hljs/stackoverflow-light.js.map +1 -0
  62. package/dist/node_modules/toposort/index.js +1 -1
  63. package/dist/node_modules/yup/index.esm.js +1 -1
  64. package/dist/src/assets/icons/UpArrow.svg.js +2 -0
  65. package/dist/src/assets/icons/UpArrow.svg.js.map +1 -0
  66. package/dist/src/assets/icons/copy.svg.js +2 -0
  67. package/dist/src/assets/icons/copy.svg.js.map +1 -0
  68. package/dist/src/components/MethodAccordion/MethodAccordion.js +1 -1
  69. package/dist/src/components/MethodAccordion/MethodAccordion.js.map +1 -1
  70. package/dist/src/components/dialog/index.js +1 -1
  71. package/dist/src/components/dialog/index.js.map +1 -1
  72. package/dist/src/components/table/table.js +1 -1
  73. package/dist/src/components/table/table.js.map +1 -1
  74. package/dist/src/constants/methods.constant.js +1 -1
  75. package/dist/src/constants/methods.constant.js.map +1 -1
  76. package/dist/src/helpers/docs.helper.js +2 -0
  77. package/dist/src/helpers/docs.helper.js.map +1 -0
  78. package/dist/src/layout/docsComponents/Codebox/Codebox.js +2 -0
  79. package/dist/src/layout/docsComponents/Codebox/Codebox.js.map +1 -0
  80. package/dist/src/layout/docsComponents/Codebox/style.module.scss.js +2 -0
  81. package/dist/src/layout/docsComponents/Codebox/style.module.scss.js.map +1 -0
  82. package/dist/src/layout/docsComponents/DocsAside/DocsAside.js +1 -1
  83. package/dist/src/layout/docsComponents/DocsAside/DocsAside.js.map +1 -1
  84. package/dist/src/layout/docsComponents/DocsAside/style.module.scss.js +2 -0
  85. package/dist/src/layout/docsComponents/DocsAside/style.module.scss.js.map +1 -0
  86. package/dist/src/layout/docsComponents/DocsContent/DocsContent.js +1 -1
  87. package/dist/src/layout/docsComponents/DocsContent/DocsContent.js.map +1 -1
  88. package/dist/src/layout/docsComponents/DocsContent/TagPage/index.js +2 -0
  89. package/dist/src/layout/docsComponents/DocsContent/TagPage/index.js.map +1 -0
  90. package/dist/src/layout/docsComponents/DocsHeader/DocsHeader.js +1 -1
  91. package/dist/src/layout/docsComponents/DocsHeader/DocsHeader.js.map +1 -1
  92. package/dist/src/layout/docsComponents/DocsSideMenuTree/DocsSideMenuTree.js +1 -1
  93. package/dist/src/layout/docsComponents/DocsSideMenuTree/DocsSideMenuTree.js.map +1 -1
  94. package/dist/src/layout/docsLayout.js +1 -1
  95. package/dist/src/layout/docsLayout.js.map +1 -1
  96. package/dist/src/layout/layout.js +1 -1
  97. package/dist/src/layout/layout.js.map +1 -1
  98. package/dist/src/layout/layout.module.css.js +1 -1
  99. package/dist/src/utils/index.js +2 -0
  100. package/dist/src/utils/index.js.map +1 -0
  101. package/dist/styles.css +659 -429
  102. package/dist/types/assets/icons/index.d.ts +1 -0
  103. package/dist/types/components/dialog/dialog.d.ts +1 -0
  104. package/dist/types/components/dialog/index.d.ts +1 -1
  105. package/dist/types/layout/docsComponents/Codebox/Codebox.d.ts +4 -0
  106. package/dist/types/layout/docsComponents/DocsAside/DocsAside.d.ts +4 -2
  107. package/dist/types/layout/docsComponents/DocsContent/DocsContent.d.ts +4 -1
  108. package/dist/types/layout/docsComponents/DocsContent/EndpointPage/index.d.ts +3 -1
  109. package/dist/types/layout/docsComponents/DocsContent/TagPage/index.d.ts +3 -1
  110. package/dist/types/layout/docsComponents/DocsSideMenuTree/DocsSideMenuTree.d.ts +2 -1
  111. package/dist/types/utils/index.d.ts +1 -0
  112. package/package.json +4 -3
  113. package/rollup.config.js +2 -0
  114. package/src/assets/icons/copy.svg +4 -0
  115. package/src/assets/icons/index.ts +1 -0
  116. package/src/components/MethodAccordion/MethodAccordion.module.scss +20 -11
  117. package/src/components/MethodAccordion/MethodAccordion.tsx +21 -13
  118. package/src/components/dialog/dialog.ts +1 -0
  119. package/src/components/dialog/index.tsx +27 -24
  120. package/src/components/table/table.tsx +5 -1
  121. package/src/constants/methods.constant.ts +1 -1
  122. package/src/layout/docsComponents/Codebox/Codebox.tsx +61 -0
  123. package/src/layout/docsComponents/Codebox/style.module.scss +43 -0
  124. package/src/layout/docsComponents/DocsAside/DocsAside.tsx +90 -4
  125. package/src/layout/docsComponents/DocsAside/style.module.scss +113 -0
  126. package/src/layout/docsComponents/DocsContent/DocsContent.tsx +3 -2
  127. package/src/layout/docsComponents/DocsContent/EndpointPage/index.tsx +2 -1
  128. package/src/layout/docsComponents/DocsContent/TagPage/index.tsx +34 -63
  129. package/src/layout/docsComponents/DocsContent/TagPage/style.scss +42 -5
  130. package/src/layout/docsComponents/DocsHeader/DocsHeader.module.scss +78 -5
  131. package/src/layout/docsComponents/DocsHeader/DocsHeader.tsx +51 -14
  132. package/src/layout/docsComponents/DocsSideMenuTree/DocsSideMenuTree.tsx +17 -12
  133. package/src/layout/docsComponents/index.scss +3 -1
  134. package/src/layout/docsLayout.tsx +15 -12
  135. package/src/layout/layout.module.css +8 -5
  136. package/src/layout/layout.tsx +3 -3
  137. package/src/utils/index.ts +7 -0
  138. package/src/layout/docsComponents/DocsAside/style.scss +0 -3
@@ -17,6 +17,7 @@ export { default as BookIcon } from './BookIcon.svg';
17
17
  export { default as Closecircle } from './close-circle.svg';
18
18
  export { default as InfoIcon } from './infoIcon.svg';
19
19
  export { default as SearchIcon } from './searchIcon.svg';
20
+ export { default as Copy } from './copy.svg';
20
21
  export { default as PlusIcon } from './Plus.svg';
21
22
  export { default as PlusSquare } from './PlusSquare.svg';
22
23
  export { default as RequestOption } from './RequestOption.svg';
@@ -41,4 +41,5 @@ export interface CommonDialogProps {
41
41
  isSubmitDisabled?: boolean;
42
42
  submitBtnComponent?: JSX.Element | null;
43
43
  withClose?: boolean;
44
+ noActions?: boolean;
44
45
  }
@@ -1,4 +1,4 @@
1
1
  import './style.scss';
2
2
  import { CommonDialogProps } from './dialog';
3
- declare const CommonDialog: ({ status, content, onSubmit, onCancel, onClose, open, size, icon, }: CommonDialogProps) => import("react/jsx-runtime").JSX.Element;
3
+ declare const CommonDialog: ({ status, content, onSubmit, onCancel, onClose, open, size, icon, noActions, }: CommonDialogProps) => import("react/jsx-runtime").JSX.Element;
4
4
  export default CommonDialog;
@@ -0,0 +1,4 @@
1
+ declare const Codebox: ({ code }: {
2
+ code: string;
3
+ }) => import("react/jsx-runtime").JSX.Element;
4
+ export default Codebox;
@@ -1,3 +1,5 @@
1
- import './style.scss';
2
- declare const DocsAside: () => import("react/jsx-runtime").JSX.Element;
1
+ import { EndpointData } from 'src/layout/docsLayout';
2
+ declare const DocsAside: ({ data }: {
3
+ data: EndpointData;
4
+ }) => import("react/jsx-runtime").JSX.Element;
3
5
  export default DocsAside;
@@ -1,3 +1,6 @@
1
1
  import './style.scss';
2
- declare const DocsContent: () => import("react/jsx-runtime").JSX.Element;
2
+ import { EndpointData, OverviewData } from 'src/layout/docsLayout';
3
+ declare const DocsContent: ({ data }: {
4
+ data: OverviewData | EndpointData;
5
+ }) => import("react/jsx-runtime").JSX.Element;
3
6
  export default DocsContent;
@@ -1,2 +1,4 @@
1
1
  import './style.scss';
2
- export declare const EndpointPage: () => import("react/jsx-runtime").JSX.Element;
2
+ export declare const EndpointPage: ({ data }: {
3
+ data: any;
4
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,4 @@
1
1
  import './style.scss';
2
- export declare const TagPage: () => import("react/jsx-runtime").JSX.Element;
2
+ export declare const TagPage: ({ data }: {
3
+ data: any;
4
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -1,8 +1,9 @@
1
1
  import './style.scss';
2
- declare const DocsSideMenuTree: ({ apis, setActiveItemData, isFirstApiExpanded, setIsFirstApiExpanded, }: {
2
+ declare const DocsSideMenuTree: ({ apis, setActiveItemData, isFirstApiExpanded, setIsFirstApiExpanded, setActiveType, }: {
3
3
  apis: any;
4
4
  setActiveItemData: any;
5
5
  isFirstApiExpanded: any;
6
6
  setIsFirstApiExpanded: any;
7
+ setActiveType: any;
7
8
  }) => import("react/jsx-runtime").JSX.Element;
8
9
  export default DocsSideMenuTree;
@@ -0,0 +1 @@
1
+ export declare const copyToClipboard: (text: string) => Promise<any>;
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@digi-frontend/dgate-api-documentation",
3
- "version": "1.0.47",
3
+ "version": "1.0.50",
4
4
  "main": "dist/src/index.js",
5
5
  "module": "dist/src/index.js",
6
6
  "types": "dist/types/index.d.ts",
7
7
  "scripts": {
8
8
  "test": "echo \"Error: no test specified\" && exit 1",
9
- "build": "tsc --noEmit --skipLibCheck || true && rollup -c"
9
+ "build": "tsc --noEmit --skipLibCheck || true && rollup -c || true"
10
10
  },
11
11
  "exports": {
12
12
  ".": "./src/index.ts"
@@ -23,12 +23,13 @@
23
23
  "nanoid": "^5.1.5",
24
24
  "react": "^18.0.0",
25
25
  "react-dom": "^18.0.0",
26
- "react-inlinesvg": "^4.2.0",
26
+ "react-syntax-highlighter": "^15.6.1",
27
27
  "tslib": "^2.8.1",
28
28
  "yup": "^1.6.1"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@rollup/plugin-commonjs": "^28.0.2",
32
+ "@rollup/plugin-json": "^6.1.0",
32
33
  "@rollup/plugin-node-resolve": "^16.0.0",
33
34
  "@rollup/plugin-typescript": "^12.1.2",
34
35
  "@rollup/plugin-url": "^8.0.2",
package/rollup.config.js CHANGED
@@ -5,6 +5,7 @@ import postcss from 'rollup-plugin-postcss'
5
5
  import { terser } from 'rollup-plugin-terser'
6
6
  import url from '@rollup/plugin-url'
7
7
  import sass from 'rollup-plugin-sass'
8
+ import json from '@rollup/plugin-json';
8
9
 
9
10
  export default {
10
11
  input: 'src/index.ts',
@@ -30,6 +31,7 @@ export default {
30
31
  sass({
31
32
  output: 'dist/styles.css',
32
33
  }),
34
+ json()
33
35
  ],
34
36
  external: ['react', 'react-dom'],
35
37
  }
@@ -0,0 +1,4 @@
1
+ <svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M8 6.45V8.55C8 10.3 7.3 11 5.55 11H3.45C1.7 11 1 10.3 1 8.55V6.45C1 4.7 1.7 4 3.45 4H5.55C7.3 4 8 4.7 8 6.45Z" stroke="#6B7280" stroke-width="0.6" stroke-linecap="round" stroke-linejoin="round"/>
3
+ <path d="M11 3.45V5.55C11 7.3 10.3 8 8.55 8H8V6.45C8 4.7 7.3 4 5.55 4H4V3.45C4 1.7 4.7 1 6.45 1H8.55C10.3 1 11 1.7 11 3.45Z" stroke="#6B7280" stroke-width="0.6" stroke-linecap="round" stroke-linejoin="round"/>
4
+ </svg>
@@ -17,6 +17,7 @@ export { default as BookIcon } from './BookIcon.svg'
17
17
  export { default as Closecircle } from './close-circle.svg'
18
18
  export { default as InfoIcon } from './infoIcon.svg'
19
19
  export { default as SearchIcon } from './searchIcon.svg'
20
+ export { default as Copy } from './copy.svg'
20
21
  export { default as PlusIcon } from './Plus.svg'
21
22
  export { default as PlusSquare } from './PlusSquare.svg'
22
23
  export { default as RequestOption } from './RequestOption.svg'
@@ -20,6 +20,15 @@
20
20
  padding: 0 !important;
21
21
  }
22
22
 
23
+ :global(.enumText) {
24
+ font-family: 'Cairo';
25
+ font-weight: 400;
26
+ font-size: 0.875rem;
27
+ line-height: 1.25rem;
28
+ max-width: 5.5625rem;
29
+ white-space: normal;
30
+ }
31
+
23
32
  .methodSummaryContainer {
24
33
  display: flex;
25
34
  align-items: center;
@@ -92,7 +101,7 @@
92
101
  margin: 0;
93
102
  margin-bottom: 1.25rem;
94
103
  }
95
- .responseHeader{
104
+ .responseHeader {
96
105
  display: flex;
97
106
  flex-direction: row;
98
107
  justify-content: space-between;
@@ -118,18 +127,18 @@
118
127
  }
119
128
 
120
129
  .statusCodeOptionContainer {
121
- display: grid;
122
- grid-template-columns: min-content min-content;
123
- align-items: center;
124
- gap: 0.625rem;
125
-
126
- .statusCodeOptionCircle {
127
- width: 0.625rem;
128
- aspect-ratio: 1 / 1;
129
- border-radius: 100%;
130
+ display: grid;
131
+ grid-template-columns: min-content min-content;
132
+ align-items: center;
133
+ gap: 0.625rem;
134
+
135
+ .statusCodeOptionCircle {
136
+ width: 0.625rem;
137
+ aspect-ratio: 1 / 1;
138
+ border-radius: 100%;
139
+ }
130
140
  }
131
141
  }
132
- }
133
142
  .paramDescContainer {
134
143
  display: flex;
135
144
 
@@ -229,7 +229,7 @@ const MethodsAccordion = ({
229
229
  enum: (
230
230
  <>
231
231
  {readOnly ? (
232
- item?.schema?.enum?.join(' / ')
232
+ <span className="enumText">{item?.schema?.enum?.join('/\u200B')}</span>
233
233
  ) : (
234
234
  <div data-id="TEXT_DESCRIPTION" className="tableData">
235
235
  {method.parameters[index]?.schema &&
@@ -294,7 +294,8 @@ const MethodsAccordion = ({
294
294
  enumFields?.filter((item) => !item).length) ||
295
295
  (method?.parameters[index]?.schema?.enum &&
296
296
  method?.parameters[index]?.schema?.enum?.length > 0 &&
297
- method?.parameters[index]?.schema?.enum?.filter((item) => !item).length)
297
+ method?.parameters[index]?.schema?.enum?.filter((item) => !item)
298
+ .length)
298
299
  }
299
300
  >
300
301
  Apply
@@ -303,17 +304,24 @@ const MethodsAccordion = ({
303
304
  </div>
304
305
  }
305
306
  >
306
- <Button
307
- className={styles.editDescBtn}
308
- id="EnumButton"
309
- variant="link"
310
- color="action"
311
- endIcon={
312
- <SVGLoader id="enumIcon" src={PlusIcon} width="1.5rem" height="1.5rem" />
313
- }
314
- >
315
- Add
316
- </Button>
307
+ {method.parameters[index]?.schema?.enum &&
308
+ method.parameters[index]?.schema?.enum?.length > 0 ? (
309
+ <span className={'enumText'}>
310
+ {method.parameters[index]?.schema?.enum?.join('/\u200B')}
311
+ </span>
312
+ ) : (
313
+ <Button
314
+ className={styles.editDescBtn}
315
+ id="EnumButton"
316
+ variant="link"
317
+ color="action"
318
+ endIcon={
319
+ <SVGLoader id="enumIcon" src={PlusIcon} width="1.5rem" height="1.5rem" />
320
+ }
321
+ >
322
+ Add
323
+ </Button>
324
+ )}
317
325
  </Tooltip>
318
326
  ) : (
319
327
  '-'
@@ -54,4 +54,5 @@ export interface CommonDialogProps {
54
54
  isSubmitDisabled?: boolean
55
55
  submitBtnComponent?: JSX.Element | null
56
56
  withClose?: boolean
57
+ noActions?: boolean
57
58
  }
@@ -19,6 +19,7 @@ const CommonDialog = ({
19
19
  <SVGLoader src={InfoIcon} width="4.0625rem" height="4.0625rem" />
20
20
  </>
21
21
  ),
22
+ noActions = false,
22
23
  }: CommonDialogProps) => {
23
24
  const handleClose = () => {
24
25
  onClose() // Always close the dialog first
@@ -44,30 +45,32 @@ const CommonDialog = ({
44
45
  />
45
46
 
46
47
  {content}
47
- <div
48
- className="confirmation-dialog-footer"
49
- style={{ marginBottom: onCancel || onSubmit ? '1.5rem' : '1rem' }}
50
- >
51
- {onCancel && (
52
- <Button
53
- {...onCancel}
54
- onClick={handleClose}
55
- variant={onCancel.variant || 'outlined'}
56
- color={onCancel.color || 'normal'}
57
- >
58
- {onCancel.text}
59
- </Button>
60
- )}
61
- {onSubmit && (
62
- <Button
63
- {...onSubmit}
64
- variant={onSubmit.variant || 'contained'}
65
- color={onSubmit.color || 'secondary'}
66
- >
67
- {onSubmit.text}
68
- </Button>
69
- )}
70
- </div>
48
+ {!!noActions ? null : (
49
+ <div
50
+ className="confirmation-dialog-footer"
51
+ style={{ marginBottom: onCancel || onSubmit ? '1.5rem' : '1rem' }}
52
+ >
53
+ {onCancel && (
54
+ <Button
55
+ {...onCancel}
56
+ onClick={handleClose}
57
+ variant={onCancel.variant || 'outlined'}
58
+ color={onCancel.color || 'normal'}
59
+ >
60
+ {onCancel.text}
61
+ </Button>
62
+ )}
63
+ {onSubmit && (
64
+ <Button
65
+ {...onSubmit}
66
+ variant={onSubmit.variant || 'contained'}
67
+ color={onSubmit.color || 'secondary'}
68
+ >
69
+ {onSubmit.text}
70
+ </Button>
71
+ )}
72
+ </div>
73
+ )}
71
74
  </div>
72
75
  )
73
76
 
@@ -51,7 +51,11 @@ const ParamterTable = ({
51
51
  type: yup.string().optional(),
52
52
  }),
53
53
  }),
54
- required: yup.boolean().optional(),
54
+ required: yup.boolean().when('in', {
55
+ is: 'path',
56
+ then: (schema) => schema.oneOf([true], 'Path parameters must be required.'),
57
+ otherwise: (schema) => schema.optional(),
58
+ }),
55
59
  description: yup.string().default('').trim().optional(),
56
60
  }),
57
61
  onSubmit: (values) => {
@@ -9,7 +9,7 @@ export const METHOD_OPTIONS: MethodOption[] = [
9
9
  { label: 'GET', value: 'GET', color: '#3b82f6' },
10
10
  { label: 'Delete', value: 'DELETE', color: '#ef4444' },
11
11
  { label: 'Put', value: 'PUT', color: '#f59e0b' },
12
- { label: 'PATCH', value: 'PATCH', color: '#8b5cf6' },
12
+ { label: 'PATCH', value: 'PATCH', color: '#C0F4E8' },
13
13
  { label: 'OPTIONS', value: 'OPTIONS', color: '#6b7280' },
14
14
  { label: 'HEAD', value: 'HEAD', color: '#8b5cf6' },
15
15
  { label: 'TRACE', value: 'TRACE', color: '#ec4899' },
@@ -0,0 +1,61 @@
1
+ import React, { useState } from 'react'
2
+ import { Light as SyntaxHighlighter } from 'react-syntax-highlighter'
3
+ import {
4
+ stackoverflowDark,
5
+ stackoverflowLight,
6
+ } from 'react-syntax-highlighter/dist/esm/styles/hljs'
7
+ import styles from './style.module.scss'
8
+ import SVGLoader from '../../../components/SVGLoader/SVGLoader'
9
+ import { Copy } from '../../../assets/icons'
10
+ import { copyToClipboard } from '../../../utils'
11
+
12
+ const Codebox = ({ code }: { code: string }) => {
13
+ const [theme, setTheme] = useState<'LIGHT' | 'DARK'>('DARK')
14
+
15
+ return (
16
+ <div className={styles.codebox}>
17
+ <div className={styles.codebox_header}>
18
+ <div
19
+ role="button"
20
+ tabIndex={-1}
21
+ onClick={() => theme !== 'LIGHT' && setTheme('LIGHT')}
22
+ className={`${styles.codebox_header_themeToggle} ${styles.codebox_header_themeToggle_light}`}
23
+ title="Light theme"
24
+ ></div>
25
+ <div
26
+ role="button"
27
+ tabIndex={-1}
28
+ onClick={() => theme !== 'DARK' && setTheme('DARK')}
29
+ className={`${styles.codebox_header_themeToggle} ${styles.codebox_header_themeToggle_dark}`}
30
+ title="Dark theme"
31
+ ></div>
32
+ <SVGLoader
33
+ src={Copy}
34
+ width="0.75rem"
35
+ height="0.75rem"
36
+ className={styles.codebox_header_copyIcon}
37
+ onClick={() => copyToClipboard(code)}
38
+ />
39
+ </div>
40
+ <SyntaxHighlighter
41
+ language="json"
42
+ style={theme === 'LIGHT' ? stackoverflowLight : stackoverflowDark}
43
+ showLineNumbers
44
+ wrapLines
45
+ customStyle={{
46
+ margin: 0,
47
+ height: '13.75rem',
48
+ overflowY: 'auto',
49
+ padding: '0.75rem 1rem 0 1.5rem',
50
+ backgroundColor: theme === 'DARK' ? '#455162' : '#F7F7F7',
51
+ fontSize: '0.75rem',
52
+ }}
53
+ lineProps={{ className: 'custom-code-line' }}
54
+ >
55
+ {code}
56
+ </SyntaxHighlighter>
57
+ </div>
58
+ )
59
+ }
60
+
61
+ export default Codebox
@@ -0,0 +1,43 @@
1
+ .codebox {
2
+ border-radius: 0.25rem;
3
+ overflow: hidden;
4
+
5
+ &_header {
6
+ display: flex;
7
+ align-items: center;
8
+ gap: 0.25rem;
9
+ padding-left: 0.5rem;
10
+ height: 1.75rem;
11
+ border: 1px solid #bbbec5;
12
+ border-top-right-radius: 0.25rem;
13
+ border-top-left-radius: 0.25rem;
14
+
15
+ &_themeToggle {
16
+ width: 0.75rem;
17
+ min-width: 0.75rem;
18
+ aspect-ratio: 1 / 1;
19
+ border: 1px solid transparent;
20
+ border-radius: 100%;
21
+ cursor: pointer;
22
+
23
+ &_dark {
24
+ background-color: #455162;
25
+ border-color: #6b7280;
26
+ }
27
+
28
+ &_light {
29
+ background-color: #edf1fb;
30
+ border-color: #6b7280;
31
+ }
32
+ }
33
+
34
+ &_copyIcon {
35
+ cursor: pointer;
36
+ }
37
+ }
38
+
39
+ :global(.custom-code-line),
40
+ :global(.custom-code-line span) {
41
+ font-family: 'Cascadia Code', sans-serif;
42
+ }
43
+ }
@@ -1,8 +1,94 @@
1
- import React from 'react'
2
- import './style.scss'
1
+ import React, { useState } from 'react'
2
+ import { EndpointData } from 'src/layout/docsLayout'
3
+ import Codebox from '../Codebox/Codebox'
4
+ import { SelectGroup } from 'digitinary-ui'
5
+ import { httpStatusCodes } from '../../../constants/index'
6
+ import { handleStatusColor } from '../../../helpers/methodAccordion.helper'
7
+ import styles from './style.module.scss'
3
8
 
4
- const DocsAside = () => {
5
- return <aside className="api-docs-aside"></aside>
9
+ const httpStatusCodeOptions = httpStatusCodes.map((code) => ({
10
+ label: (
11
+ <div className={styles.statusCodeOptionContainer}>
12
+ <div
13
+ className={styles.statusCodeOptionCircle}
14
+ style={{ backgroundColor: handleStatusColor(code) }}
15
+ ></div>
16
+ <span>{code}</span>
17
+ </div>
18
+ ),
19
+ value: code,
20
+ }))
21
+
22
+ const DocsAside = ({ data }: { data: EndpointData }) => {
23
+ const [selectedResStatusCode, setSelectedResStatusCode] = useState(httpStatusCodeOptions[4])
24
+ const currentResponse =
25
+ Object.entries(data.responses)
26
+ .map(([code, data]) => ({ code, data }))
27
+ .find((res) => Number(res.code) === selectedResStatusCode.value) || '{}'
28
+
29
+ const stringifyRequestBody = () => {
30
+ if (data?.requestBody?.content) {
31
+ const contentKey = Object.keys(data?.requestBody?.content)[0]
32
+ return JSON.stringify(data?.requestBody?.content[contentKey], null, 2)
33
+ } else {
34
+ return '{}'
35
+ }
36
+ }
37
+
38
+ const stringifyResponseBody = () => {
39
+ if (currentResponse?.data) {
40
+ const contentKey = Object.keys(currentResponse.data?.content)[0]
41
+ return JSON.stringify(currentResponse.data?.content[contentKey], null, 2)
42
+ } else {
43
+ return '{}'
44
+ }
45
+ }
46
+
47
+ return (
48
+ <aside className={styles.apiDocsAside}>
49
+ <h2 className={styles.apiDocsAside_title}>{data.summary}</h2>
50
+ <h4 className={styles.apiDocsAside_subtitle}>
51
+ <span className={styles.apiDocsAside_subtitle_method} data-method={data.method}>
52
+ {data.method}
53
+ </span>{' '}
54
+ <span>{data.path}</span>
55
+ </h4>
56
+ {data?.requestBody?.content && (
57
+ <div className={styles.codeboxSection}>
58
+ <div className={styles.codeboxHeader}>
59
+ <h6 className={styles.codeboxTitle}>Request</h6>
60
+ </div>
61
+
62
+ <Codebox code={stringifyRequestBody()} />
63
+ </div>
64
+ )}
65
+ {Object.keys(data?.responses || {})?.length > 0 && (
66
+ <div className={styles.codeboxSection}>
67
+ <div className={`${styles.codeboxHeader}`}>
68
+ <h6 className={styles.codeboxTitle}>Response</h6>
69
+ <SelectGroup
70
+ size="small"
71
+ withSearch={false}
72
+ isMultiple={false}
73
+ clearable={false}
74
+ placeholder="200"
75
+ options={[
76
+ {
77
+ list: httpStatusCodeOptions,
78
+ },
79
+ ]}
80
+ value={selectedResStatusCode}
81
+ onChange={(value) => {
82
+ setSelectedResStatusCode(value)
83
+ }}
84
+ />
85
+ </div>
86
+
87
+ <Codebox code={stringifyResponseBody()} />
88
+ </div>
89
+ )}
90
+ </aside>
91
+ )
6
92
  }
7
93
 
8
94
  export default DocsAside
@@ -0,0 +1,113 @@
1
+ .apiDocsAside {
2
+ width: 22.5rem;
3
+ padding: 3rem 1.5rem;
4
+ background-color: #f0f1f2;
5
+
6
+ &_title {
7
+ font-size: 1.5rem;
8
+ line-height: 2rem;
9
+ font-weight: 600;
10
+ color: #12131a;
11
+ margin-bottom: 0.5rem;
12
+ }
13
+
14
+ &_subtitle {
15
+ margin-bottom: 2rem;
16
+
17
+ > span {
18
+ font-size: 1.25rem;
19
+ line-height: 1.75rem;
20
+ font-weight: 400;
21
+ }
22
+
23
+ &_method {
24
+ &[data-method='get'] {
25
+ color: #3a6cd1;
26
+ }
27
+
28
+ &[data-method='post'] {
29
+ color: #3aaa35;
30
+ }
31
+
32
+ &[data-method='put'] {
33
+ color: #faad14;
34
+ }
35
+
36
+ &[data-method='delete'] {
37
+ color: #da3f3f;
38
+ }
39
+
40
+ &[data-method='option'] {
41
+ color: #495d97;
42
+ }
43
+
44
+ &[data-method='head'] {
45
+ color: #9461c9;
46
+ }
47
+
48
+ &[data-method='patch'] {
49
+ color: #58e2c2;
50
+ }
51
+ }
52
+ }
53
+
54
+ .codeboxSection {
55
+ .codeboxHeader {
56
+ height: 2rem;
57
+ display: flex;
58
+ justify-content: space-between;
59
+ margin-bottom: 0.25rem;
60
+
61
+ h6 {
62
+ font-size: 1rem;
63
+ line-height: 1.25rem;
64
+ font-weight: 500;
65
+ color: #616874;
66
+ }
67
+ }
68
+
69
+ &:nth-of-type(2) {
70
+ margin-top: 3rem;
71
+ }
72
+
73
+ :global(.multiSelectGroup) {
74
+ :global(.selectDisplay) {
75
+ padding: 0;
76
+
77
+ :global(.select-label-container) {
78
+ min-width: 100%;
79
+ padding: 0;
80
+ }
81
+ }
82
+
83
+ :global(.optionsList .option) {
84
+ height: 1.5rem;
85
+ padding: 0;
86
+ }
87
+
88
+ .statusCodeOptionContainer {
89
+ display: flex;
90
+ align-items: center;
91
+ gap: 0.625rem;
92
+ padding-left: 0.75rem;
93
+
94
+ .statusCodeOptionCircle {
95
+ width: 0.625rem;
96
+ min-width: 0.625rem;
97
+ aspect-ratio: 1 / 1;
98
+ border-radius: 100%;
99
+ }
100
+ }
101
+ }
102
+ }
103
+
104
+ :global(.multiSelectGroup .selectDisplay),
105
+ :global(.multiSelectGroup) {
106
+ width: 6.25rem;
107
+ height: 1.5rem;
108
+ }
109
+
110
+ :global(.multiSelectGroup .selectDisplay .displayValueContainer .iconsContainer) {
111
+ padding-right: 0.75rem;
112
+ }
113
+ }