@digi-frontend/dgate-api-documentation 1.0.55 → 1.0.57

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 (74) hide show
  1. package/dist/_virtual/index10.js +1 -1
  2. package/dist/_virtual/index20.js +2 -0
  3. package/dist/_virtual/index20.js.map +1 -0
  4. package/dist/_virtual/index3.js +1 -1
  5. package/dist/_virtual/index4.js +1 -1
  6. package/dist/_virtual/index5.js +1 -1
  7. package/dist/_virtual/index6.js +1 -1
  8. package/dist/_virtual/index7.js +1 -1
  9. package/dist/_virtual/index8.js +1 -1
  10. package/dist/_virtual/index9.js +1 -1
  11. package/dist/node_modules/dom-serializer/lib/index.js +1 -1
  12. package/dist/node_modules/dom-serializer/node_modules/entities/lib/index.js +1 -1
  13. package/dist/node_modules/domelementtype/lib/index.js +1 -1
  14. package/dist/node_modules/domhandler/lib/index.js +1 -1
  15. package/dist/node_modules/domutils/lib/index.js +1 -1
  16. package/dist/node_modules/fast-json-stable-stringify/index.js +2 -0
  17. package/dist/node_modules/fast-json-stable-stringify/index.js.map +1 -0
  18. package/dist/node_modules/formik/dist/formik.esm.js +1 -1
  19. package/dist/node_modules/html-dom-parser/lib/index.js +1 -1
  20. package/dist/node_modules/html-react-parser/esm/index.mjs.js +1 -1
  21. package/dist/node_modules/html-react-parser/esm/index.mjs.js.map +1 -1
  22. package/dist/node_modules/html-react-parser/lib/index.js +1 -1
  23. package/dist/node_modules/htmlparser2/dist/commonjs/index.js +1 -1
  24. package/dist/node_modules/react-is/index.js +1 -1
  25. package/dist/node_modules/react-property/lib/index.js +1 -1
  26. package/dist/node_modules/style-to-object/cjs/index.js +1 -1
  27. package/dist/node_modules/toposort/index.js +1 -1
  28. package/dist/node_modules/yup/index.esm.js +1 -1
  29. package/dist/src/assets/icons/CloseIcon.svg.js +2 -0
  30. package/dist/src/assets/icons/CloseIcon.svg.js.map +1 -0
  31. package/dist/src/components/InfoForm/InfoForm.js +1 -1
  32. package/dist/src/components/InfoForm/InfoForm.js.map +1 -1
  33. package/dist/src/components/LivePreview/LivePreview.js +1 -1
  34. package/dist/src/components/LivePreview/LivePreview.js.map +1 -1
  35. package/dist/src/components/MethodAccordion/MethodAccordion.js +1 -1
  36. package/dist/src/components/MethodAccordion/MethodAccordion.js.map +1 -1
  37. package/dist/src/components/dialog/index.js +1 -1
  38. package/dist/src/components/dialog/index.js.map +1 -1
  39. package/dist/src/components/table/table.js +1 -1
  40. package/dist/src/components/table/table.js.map +1 -1
  41. package/dist/src/components/table/tags-table.js +1 -1
  42. package/dist/src/components/table/tags-table.js.map +1 -1
  43. package/dist/src/layout/docsComponents/DocsContent/DocsContent.js +1 -1
  44. package/dist/src/layout/docsComponents/DocsContent/DocsContent.js.map +1 -1
  45. package/dist/src/layout/docsComponents/DocsContent/OverviewPage/index.js +2 -0
  46. package/dist/src/layout/docsComponents/DocsContent/OverviewPage/index.js.map +1 -0
  47. package/dist/src/layout/docsComponents/DocsHeader/DocsHeader.js +1 -1
  48. package/dist/src/layout/docsComponents/DocsHeader/DocsHeader.js.map +1 -1
  49. package/dist/src/layout/docsComponents/DocsSideMenuTree/DocsSideMenuTree.js +1 -1
  50. package/dist/src/layout/docsComponents/DocsSideMenuTree/DocsSideMenuTree.js.map +1 -1
  51. package/dist/src/layout/docsLayout.js +1 -1
  52. package/dist/src/layout/docsLayout.js.map +1 -1
  53. package/dist/styles.css +761 -757
  54. package/dist/types/components/dialog/dialog.d.ts +2 -0
  55. package/dist/types/components/dialog/index.d.ts +1 -1
  56. package/dist/types/layout/docsComponents/DocsContent/DocsContent.d.ts +2 -1
  57. package/dist/types/layout/docsComponents/DocsContent/OverviewPage/index.d.ts +9 -0
  58. package/dist/types/layout/docsComponents/DocsSideMenuTree/DocsSideMenuTree.d.ts +3 -1
  59. package/dist/types/layout/docsLayout.d.ts +2 -1
  60. package/package.json +1 -1
  61. package/src/components/InfoForm/InfoForm.tsx +16 -16
  62. package/src/components/LivePreview/LivePreview.module.scss +15 -14
  63. package/src/components/LivePreview/LivePreview.tsx +1 -0
  64. package/src/components/MethodAccordion/MethodAccordion.tsx +129 -122
  65. package/src/components/dialog/dialog.ts +3 -0
  66. package/src/components/dialog/index.tsx +7 -8
  67. package/src/components/table/table.tsx +39 -32
  68. package/src/components/table/tags-table.tsx +2 -2
  69. package/src/layout/docsComponents/DocsContent/DocsContent.tsx +5 -2
  70. package/src/layout/docsComponents/DocsContent/{TagPage → OverviewPage}/index.tsx +17 -4
  71. package/src/layout/docsComponents/DocsContent/{TagPage → OverviewPage}/style.scss +1 -0
  72. package/src/layout/docsComponents/DocsHeader/DocsHeader.tsx +1 -4
  73. package/src/layout/docsComponents/DocsSideMenuTree/DocsSideMenuTree.tsx +12 -1
  74. package/src/layout/docsLayout.tsx +7 -1
@@ -164,7 +164,12 @@ const ParamterTable = ({
164
164
  label: capitalize(values.in),
165
165
  value: values.in,
166
166
  }}
167
- onChange={(item) => setFieldValue('in', item?.value?.toLowerCase())} // Updates state on selection
167
+ onChange={(item) => {
168
+ setFieldValue('in', item?.value?.toLowerCase())
169
+ if (item?.value == 'in') {
170
+ setFieldValue('required', true)
171
+ }
172
+ }} // Updates state on selection
168
173
  options={[
169
174
  {
170
175
  list: isRequest
@@ -186,10 +191,7 @@ const ParamterTable = ({
186
191
  </td>
187
192
 
188
193
  <td key={'parameter schema type'}>
189
- <div
190
- data-id="TEXT_DESCRIPTION"
191
- className="tableData select-inputs"
192
- >
194
+ <div data-id="TEXT_DESCRIPTION" className="tableData select-inputs">
193
195
  <SelectGroupV2
194
196
  disabled={readOnly}
195
197
  clearable={false}
@@ -215,32 +217,32 @@ const ParamterTable = ({
215
217
  withSearch={false}
216
218
  />{' '}
217
219
  {!!values?.schema?.type && values?.schema?.type.toLowerCase() === 'array' ? (
218
- <SelectGroupV2
219
- disabled={readOnly}
220
- clearable={false}
221
- value={{
222
- label: capitalize(values?.schema?.items?.type),
223
- value: values.schema?.items?.type,
224
- }}
225
- errorMsg={!!errors?.schema?.items?.type && errors?.schema?.items?.type}
226
- onChange={(item) =>
227
- setFieldValue('schema.items.type', item?.value?.toLowerCase())
228
- } // Updates state on selection
229
- options={[
230
- {
231
- list: [
232
- { label: 'String', value: 'string' },
233
- { label: 'Integer', value: 'integer' },
234
- { label: 'Boolean', value: 'boolean' },
235
- { label: 'Object', value: 'object' },
236
- { label: 'Array', value: 'array' },
237
- { label: 'Number', value: 'number' },
238
- ],
239
- },
240
- ]}
241
- isMultiple={false}
242
- withSearch={false}
243
- />
220
+ <SelectGroupV2
221
+ disabled={readOnly}
222
+ clearable={false}
223
+ value={{
224
+ label: capitalize(values?.schema?.items?.type),
225
+ value: values.schema?.items?.type,
226
+ }}
227
+ errorMsg={!!errors?.schema?.items?.type && errors?.schema?.items?.type}
228
+ onChange={(item) =>
229
+ setFieldValue('schema.items.type', item?.value?.toLowerCase())
230
+ } // Updates state on selection
231
+ options={[
232
+ {
233
+ list: [
234
+ { label: 'String', value: 'string' },
235
+ { label: 'Integer', value: 'integer' },
236
+ { label: 'Boolean', value: 'boolean' },
237
+ { label: 'Object', value: 'object' },
238
+ { label: 'Array', value: 'array' },
239
+ { label: 'Number', value: 'number' },
240
+ ],
241
+ },
242
+ ]}
243
+ isMultiple={false}
244
+ withSearch={false}
245
+ />
244
246
  ) : (
245
247
  ''
246
248
  )}
@@ -362,7 +364,12 @@ const ParamterTable = ({
362
364
  <>{values.required ? 'True' : 'False'}</>
363
365
  ) : (
364
366
  <Switch
365
- checked={values.required}
367
+ checked={
368
+ values && values.in && values.in.toLowerCase() == 'path'
369
+ ? true
370
+ : values.required
371
+ }
372
+ disabled={values && values.in && values.in.toLowerCase() == 'path'}
366
373
  onClick={() => {
367
374
  if (readOnly) {
368
375
  return
@@ -16,7 +16,7 @@ const TagsTable = ({ id, headCells, data, isFormOpen, setIsFormOpen, saveNewRow,
16
16
  const [externalUrl, setExternalUrl] = useState('')
17
17
  const [tooltipRef, setTooltipRef] = useState(null)
18
18
  const [externalTooltipRefs, setExternalTooltipRefs] = useState(null)
19
- const { values, errors, setFieldValue, isValid, submitForm, resetForm } = useFormik({
19
+ const { values, errors, setFieldValue, isValid, submitForm, resetForm,dirty } = useFormik({
20
20
  validateOnMount: true,
21
21
  initialValues: {
22
22
  name: '',
@@ -307,7 +307,7 @@ const TagsTable = ({ id, headCells, data, isFormOpen, setIsFormOpen, saveNewRow,
307
307
  className={_styles.deleteParamBtn}
308
308
  variant="link"
309
309
  color="success"
310
- disabled={!isValid}
310
+ disabled={!isValid || !dirty}
311
311
  endIcon={<SVGLoader src={AddRow} width="0.125rem" height="0.125rem" />}
312
312
  onClick={() => {
313
313
  setText('')
@@ -1,6 +1,6 @@
1
1
  import React from 'react'
2
2
  import './style.scss'
3
- import { TagPage } from './TagPage'
3
+ import { OverviewPage } from './OverviewPage'
4
4
  import { EndpointPage } from './EndpointPage'
5
5
  import { EndpointData, OverviewData } from 'src/layout/docsLayout'
6
6
 
@@ -10,6 +10,7 @@ const DocsContent = ({
10
10
  setActiveItemData,
11
11
  setActiveType,
12
12
  setExpandedSections,
13
+ onProductNavigate,
13
14
  }: {
14
15
  data: OverviewData | EndpointData
15
16
  activeType: 'OVERVIEW' | 'ENDPOINT'
@@ -17,15 +18,17 @@ const DocsContent = ({
17
18
  setActiveType: React.Dispatch<React.SetStateAction<'OVERVIEW' | 'ENDPOINT'>>
18
19
  setExpandedSections: React.Dispatch<React.SetStateAction<Record<string, boolean>>>
19
20
  toggleSection: (apiId: string, sectionId: string, resetOthers?: boolean, key?: string[]) => void
21
+ onProductNavigate?: (productId: number) => void
20
22
  }) => {
21
23
  return (
22
24
  <main>
23
25
  {activeType === 'OVERVIEW' ? (
24
- <TagPage
26
+ <OverviewPage
25
27
  data={data as OverviewData}
26
28
  setActiveItemData={setActiveItemData}
27
29
  setActiveType={setActiveType}
28
30
  setExpandedSections={setExpandedSections}
31
+ onProductNavigate={onProductNavigate}
29
32
  />
30
33
  ) : (
31
34
  <EndpointPage data={data as EndpointData} />
@@ -3,16 +3,18 @@ import SVGLoader from '../../../../components/SVGLoader/SVGLoader'
3
3
  import { arrowRightGray, CopySticker } from '../../../../assets/icons/index'
4
4
  import { EndpointData, OverviewData } from 'src/layout/docsLayout'
5
5
 
6
- export const TagPage = ({
6
+ export const OverviewPage = ({
7
7
  data,
8
8
  setActiveItemData,
9
9
  setActiveType,
10
10
  setExpandedSections,
11
+ onProductNavigate,
11
12
  }: {
12
13
  data: OverviewData
13
14
  setActiveItemData: React.Dispatch<React.SetStateAction<OverviewData | EndpointData>>
14
15
  setActiveType: React.Dispatch<React.SetStateAction<'OVERVIEW' | 'ENDPOINT'>>
15
16
  setExpandedSections: React.Dispatch<React.SetStateAction<Record<string, boolean>>>
17
+ onProductNavigate?: (productId: number) => void
16
18
  }) => {
17
19
  const handleVersionClick = (verObj) => {
18
20
  if (verObj.apiSpecId === data.apiSpecId) {
@@ -72,6 +74,7 @@ export const TagPage = ({
72
74
  [`api-${data.apiSpecId}-resource-${endpoint.id}`]: true,
73
75
  }))
74
76
  }
77
+
75
78
  return (
76
79
  <div className="api-details-page">
77
80
  <h2 className="welcome">Welcome to</h2>
@@ -104,9 +107,19 @@ export const TagPage = ({
104
107
  </div>
105
108
 
106
109
  <p className="api-desc">API Description</p>
107
- <div className="api-product-tag">
108
- Product with this API <span className="product-tag">{data.associatedProduct.name}</span>
109
- </div>
110
+ {onProductNavigate && (
111
+ <div className="api-product-tag">
112
+ Product with this API{' '}
113
+ <span
114
+ className="product-tag"
115
+ role="button"
116
+ tabIndex={-1}
117
+ onClick={() => onProductNavigate(data.associatedProduct.productId)}
118
+ >
119
+ {data.associatedProduct.name}
120
+ </span>
121
+ </div>
122
+ )}
110
123
 
111
124
  <h3 className="section-title">Endpoints</h3>
112
125
 
@@ -101,6 +101,7 @@
101
101
  font-size: 0.75rem;
102
102
  letter-spacing: 0px;
103
103
  margin-left: 0.5rem;
104
+ cursor: pointer;
104
105
  }
105
106
  }
106
107
 
@@ -1,12 +1,11 @@
1
1
  import React, { useState, useRef } from 'react'
2
- import { Button, Size, Input, SelectGroup } from 'digitinary-ui'
2
+ import { Button, Size, Input } from 'digitinary-ui'
3
3
  import SVGLoader from '../../../components/SVGLoader/SVGLoader'
4
4
  import {
5
5
  FilterIcon,
6
6
  BookIcon,
7
7
  ApiIcon,
8
8
  SearchIcon,
9
- arrowDownGray,
10
9
  UpArrowIcon,
11
10
  DownArrowIcon,
12
11
  } from '../../../assets/icons'
@@ -25,9 +24,7 @@ const DocsHeader: React.FC = ({
25
24
  const [showSearchFilter, setShowSearchFilter] = useState<boolean>(false)
26
25
  const [apiName, setApiName] = useState<string>('')
27
26
  const [selectedMethods, setSelectedMethods] = useState<any[]>([])
28
- const [methodListOpened, setMethodListOpened] = useState(false)
29
27
  const [isMethodDropdownOpen, setIsMethodDropdownOpen] = useState<boolean>(false)
30
- const selectRef = useRef<any>(null)
31
28
 
32
29
  const handleOpenSearchFilter = (): void => {
33
30
  setShowSearchFilter(true)
@@ -1,5 +1,5 @@
1
1
  import './style.scss'
2
- import React, { useEffect, useState } from 'react'
2
+ import React, { useEffect, useRef } from 'react'
3
3
  import SVGLoader from '../../../components/SVGLoader/SVGLoader'
4
4
  import { arrowDownGray, arrowRightGray, document, eye } from '../../../assets/icons'
5
5
  import { EndpointData, OverviewData } from 'src/layout/docsLayout'
@@ -16,6 +16,8 @@ const DocsSideMenuTree = ({
16
16
  setActiveType,
17
17
  toggleSection,
18
18
  canSelectFirstApi,
19
+ canFocusSection,
20
+ setCanFocusSection,
19
21
  }: {
20
22
  apis: OverviewData[]
21
23
  setActiveItemData: React.Dispatch<React.SetStateAction<OverviewData | EndpointData>>
@@ -28,6 +30,8 @@ const DocsSideMenuTree = ({
28
30
  activeType: 'OVERVIEW' | 'ENDPOINT'
29
31
  toggleSection: (apiId: string, sectionId: string, resetOthers?: boolean, key?: string[]) => void
30
32
  canSelectFirstApi?: boolean
33
+ canFocusSection: boolean
34
+ setCanFocusSection: React.Dispatch<React.SetStateAction<boolean>>
31
35
  }) => {
32
36
  // Auto-expand first API only once
33
37
  useEffect(() => {
@@ -124,12 +128,19 @@ const DocsSideMenuTree = ({
124
128
  activeItemData.api.id === api.apiSpecId &&
125
129
  'path' in activeItemData &&
126
130
  'method' in activeItemData
131
+ const sectionRef = useRef<HTMLDivElement>(null)
132
+ // Scroll to the section if it's expanded
133
+ if (canFocusSection && sectionRef?.current) {
134
+ sectionRef.current.scrollIntoView({ behavior: 'smooth', block: 'start' })
135
+ setCanFocusSection(false)
136
+ }
127
137
 
128
138
  return (
129
139
  <div
130
140
  key={api.apiSpecId}
131
141
  className="api-docs-api-tree__section"
132
142
  data-active={isEndpointActive || isOverviewExpanded}
143
+ ref={sectionRef}
133
144
  >
134
145
  <div
135
146
  className="api-docs-api-tree__section-header"
@@ -8,6 +8,7 @@ import stableStringify from 'fast-json-stable-stringify'
8
8
  interface ILayoutProps {
9
9
  apis?: ApiSpecModel[]
10
10
  activeApiId?: string
11
+ onProductNavigate?: (productId: number) => void
11
12
  }
12
13
 
13
14
  export interface TagData {
@@ -46,7 +47,7 @@ function areEqual(prev: ILayoutProps, next: ILayoutProps): boolean {
46
47
  )
47
48
  }
48
49
 
49
- const DocsLayout = ({ apis, activeApiId }: ILayoutProps): JSX.Element => {
50
+ const DocsLayout = ({ apis, activeApiId, onProductNavigate }: ILayoutProps): JSX.Element => {
50
51
  const [transformedOpenApis, setTransformedOpenApis] = useState<OverviewData[]>([])
51
52
  const [isFirstApiExpanded, setIsFirstApiExpanded] = useState(true)
52
53
  const [activeItemData, setActiveItemData] = useState<
@@ -57,6 +58,7 @@ const DocsLayout = ({ apis, activeApiId }: ILayoutProps): JSX.Element => {
57
58
  const allData = useRef([])
58
59
  const [pending, setPending] = useState(true)
59
60
  const [canSelectFirstApi, setCanSelectFirstApi] = useState(false)
61
+ const [canFocusSection, setCanFocusSection] = useState(false)
60
62
 
61
63
  const toggleSection = (
62
64
  apiId: string,
@@ -127,6 +129,7 @@ const DocsLayout = ({ apis, activeApiId }: ILayoutProps): JSX.Element => {
127
129
  setActiveType('OVERVIEW')
128
130
  setIsFirstApiExpanded(false)
129
131
  setCanSelectFirstApi(true)
132
+ setCanFocusSection(true)
130
133
  }
131
134
  }, [activeApiId, transformedOpenApis])
132
135
 
@@ -154,6 +157,8 @@ const DocsLayout = ({ apis, activeApiId }: ILayoutProps): JSX.Element => {
154
157
  setActiveType={setActiveType}
155
158
  toggleSection={toggleSection}
156
159
  canSelectFirstApi={canSelectFirstApi}
160
+ canFocusSection={canFocusSection}
161
+ setCanFocusSection={setCanFocusSection}
157
162
  />
158
163
  )}
159
164
 
@@ -165,6 +170,7 @@ const DocsLayout = ({ apis, activeApiId }: ILayoutProps): JSX.Element => {
165
170
  setActiveType={setActiveType}
166
171
  setExpandedSections={setExpandedSections}
167
172
  toggleSection={toggleSection}
173
+ onProductNavigate={onProductNavigate}
168
174
  />
169
175
  )}
170
176
  {activeType === 'ENDPOINT' && <Layout.DocsAside data={activeItemData as EndpointData} />}