@digi-frontend/dgate-api-documentation 1.0.25 → 1.0.26

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 (40) hide show
  1. package/dist/src/components/InfoForm/InfoForm.js +1 -1
  2. package/dist/src/components/InfoForm/InfoForm.js.map +1 -1
  3. package/dist/src/components/JsonInput/JsonInput.js +1 -1
  4. package/dist/src/components/JsonInput/JsonInput.js.map +1 -1
  5. package/dist/src/components/LivePreview/LivePreview.js +1 -1
  6. package/dist/src/components/LivePreview/LivePreview.js.map +1 -1
  7. package/dist/src/components/MethodAccordion/MethodAccordion.js +1 -1
  8. package/dist/src/components/MethodAccordion/MethodAccordion.js.map +1 -1
  9. package/dist/src/components/table/table.js +1 -1
  10. package/dist/src/components/table/table.js.map +1 -1
  11. package/dist/src/components/table/tags-table.js +1 -1
  12. package/dist/src/components/table/tags-table.js.map +1 -1
  13. package/dist/src/constants/regex.js +1 -1
  14. package/dist/src/constants/regex.js.map +1 -1
  15. package/dist/src/helpers/layout.helper.js +1 -1
  16. package/dist/src/helpers/layout.helper.js.map +1 -1
  17. package/dist/src/layout/layout.js +1 -1
  18. package/dist/src/layout/layout.js.map +1 -1
  19. package/dist/src/layout/layout.module.css.js +1 -1
  20. package/dist/src/validator/form.scheme.js +1 -1
  21. package/dist/src/validator/form.scheme.js.map +1 -1
  22. package/dist/styles.css +265 -232
  23. package/dist/types/components/MethodAccordion/MethodAccordion.d.ts +3 -1
  24. package/dist/types/constants/regex.d.ts +1 -0
  25. package/package.json +1 -1
  26. package/src/components/InfoForm/InfoForm.module.scss +24 -1
  27. package/src/components/InfoForm/InfoForm.tsx +56 -33
  28. package/src/components/JsonInput/JsonInput.tsx +11 -6
  29. package/src/components/LivePreview/LivePreview.module.scss +18 -5
  30. package/src/components/LivePreview/LivePreview.tsx +7 -4
  31. package/src/components/MethodAccordion/MethodAccordion.tsx +77 -63
  32. package/src/components/Tooltip/Tooltip.scss +9 -6
  33. package/src/components/table/style.scss +1 -1
  34. package/src/components/table/table.tsx +9 -8
  35. package/src/components/table/tags-table.tsx +26 -13
  36. package/src/constants/regex.ts +1 -0
  37. package/src/helpers/layout.helper.ts +1 -1
  38. package/src/layout/layout.module.css +5 -0
  39. package/src/layout/layout.tsx +4 -1
  40. package/src/validator/form.scheme.ts +1 -1
@@ -44,7 +44,6 @@ const InfoForm = ({ readOnly }: { readOnly?: boolean }) => {
44
44
 
45
45
  useEffect(() => {
46
46
  if (values.tags && values.tags.length) {
47
- setTableRecords(generateTableRecords(values.tags))
48
47
  setTableData(values.tags)
49
48
  }
50
49
  }, [values.tags])
@@ -133,10 +132,14 @@ const InfoForm = ({ readOnly }: { readOnly?: boolean }) => {
133
132
  <div className={styles.editDescTooltipContent}>
134
133
  <p className={styles.editDescTooltipContent_header}>Description</p>
135
134
  <TextArea
136
- placeholder="Describe parameter..."
135
+ placeholder="Describe tag..."
137
136
  value={item.description}
138
137
  disabled={readOnly}
139
- onChange={(value) => onTableChange('description', value, index)}
138
+ onChange={(value) => {
139
+ if (value === '' || regex.ASCII.test(value))
140
+ onTableChange('description', value, index)
141
+ }}
142
+ maxLength={25}
140
143
  />
141
144
  {!readOnly && (
142
145
  <Button
@@ -144,9 +147,10 @@ const InfoForm = ({ readOnly }: { readOnly?: boolean }) => {
144
147
  variant="outlined"
145
148
  size="small"
146
149
  onClick={() => {
147
- setFieldValue(`tags[${index}].description`, item.description)
150
+ setFieldValue(`tags[${index}].description`, item.description?.trim())
148
151
  tooltipRefs[index]?.hide()
149
152
  }}
153
+ disabled={!item.description?.trim()}
150
154
  >
151
155
  Apply
152
156
  </Button>
@@ -178,6 +182,24 @@ const InfoForm = ({ readOnly }: { readOnly?: boolean }) => {
178
182
  ),
179
183
  externalDocs: (
180
184
  <div className={styles.paramDescContainer}>
185
+ <a
186
+ className={styles.externalDocsLink}
187
+ href={values.tags[index].externalDocs?.url}
188
+ target="_blank"
189
+ style={
190
+ !values.tags[index].externalDocs?.description
191
+ ? { textDecoration: 'none', pointerEvents: 'none' }
192
+ : {}
193
+ }
194
+ >
195
+ {values.tags[index].externalDocs?.description
196
+ ? values.tags[index].externalDocs?.description?.substring(0, 12)
197
+ : '-'}
198
+ {values.tags[index].externalDocs?.description &&
199
+ values.tags[index].externalDocs?.description?.length > 12
200
+ ? '...'
201
+ : ''}
202
+ </a>
181
203
  <Tooltip
182
204
  arrowWithBorder
183
205
  placement="bottom-end"
@@ -197,13 +219,16 @@ const InfoForm = ({ readOnly }: { readOnly?: boolean }) => {
197
219
  placeholder="Describe External Doc..."
198
220
  value={item.externalDocs?.description}
199
221
  disabled={readOnly}
222
+ maxLength={25}
200
223
  onChange={(value) => {
201
- onTableChange(
202
- 'externalDocs',
203
- { ...item.externalDocs, description: value },
204
- index
205
- )
206
- setDescription(value)
224
+ if (value === '' || regex.ASCII.test(value)) {
225
+ onTableChange(
226
+ 'externalDocs',
227
+ { ...item.externalDocs, description: value },
228
+ index
229
+ )
230
+ setDescription(value)
231
+ }
207
232
  }}
208
233
  />
209
234
  <p className={styles.editDescTooltipContent_header}>External Docs Link</p>
@@ -211,9 +236,12 @@ const InfoForm = ({ readOnly }: { readOnly?: boolean }) => {
211
236
  placeholder="External Docs Link..."
212
237
  value={item.externalDocs?.url}
213
238
  disabled={readOnly}
239
+ maxLength={200}
214
240
  onChange={(value) => {
215
- onTableChange('externalDocs', { ...item.externalDocs, url: value }, index)
216
- setURL(value)
241
+ if (value === '' || regex.ASCII.test(value)) {
242
+ onTableChange('externalDocs', { ...item.externalDocs, url: value }, index)
243
+ setURL(value)
244
+ }
217
245
  }}
218
246
  />
219
247
  {!readOnly && (
@@ -223,13 +251,14 @@ const InfoForm = ({ readOnly }: { readOnly?: boolean }) => {
223
251
  size="small"
224
252
  onClick={() => {
225
253
  setFieldValue(`tags[${index}].externalDocs`, {
226
- description: description,
227
- url: url,
254
+ description: description?.trim(),
255
+ url: url?.trim(),
228
256
  })
229
257
  setDescription('')
230
258
  setURL('')
231
259
  externalTooltipRefs[index]?.hide()
232
260
  }}
261
+ disabled={!description?.trim() || !url?.trim() || !regex.urlRegex.test(url)}
233
262
  >
234
263
  Apply
235
264
  </Button>
@@ -238,24 +267,18 @@ const InfoForm = ({ readOnly }: { readOnly?: boolean }) => {
238
267
  }
239
268
  >
240
269
  {readOnly || values.tags[index].externalDocs?.description ? (
241
- <Button
242
- className={styles.editDescBtn}
243
- variant="link"
244
- color="action"
245
- endIcon={<SVGLoader src={EditIcon} width="1.5rem" height="1.5rem" />}
246
- onClick={() => {
247
- setDescription(item.externalDocs?.description)
248
- setURL(item.externalDocs?.url)
249
- }}
250
- >
251
- {values.tags[index].externalDocs?.description
252
- ? values.tags[index].externalDocs?.description?.substring(0, 12)
253
- : '-'}
254
- {values.tags[index].externalDocs?.description &&
255
- values.tags[index].externalDocs?.description?.length > 12
256
- ? '...'
257
- : ''}
258
- </Button>
270
+ <div className={styles.editExternalDocs}>
271
+ <SVGLoader
272
+ src={EditIcon}
273
+ width="1.5rem"
274
+ height="1.5rem"
275
+ onClick={(e) => {
276
+ e?.stopPropagation()
277
+ setDescription(item.externalDocs?.description)
278
+ setURL(item.externalDocs?.url)
279
+ }}
280
+ />
281
+ </div>
259
282
  ) : (
260
283
  <Button
261
284
  className={styles.editDescBtn}
@@ -300,7 +323,7 @@ const InfoForm = ({ readOnly }: { readOnly?: boolean }) => {
300
323
  label="API Name"
301
324
  required
302
325
  value={values?.info?.title}
303
- maxLength={25}
326
+ maxLength={35}
304
327
  onChange={(value) => {
305
328
  setFieldValue('info.title', value)
306
329
  }}
@@ -1,6 +1,7 @@
1
1
  import React, { useEffect, useState } from 'react'
2
2
  import yaml from 'js-yaml'
3
3
  import styles from './style.module.scss'
4
+ import regex from '../../constants/regex'
4
5
 
5
6
  const errorMapping = {
6
7
  BOTH: 'Invalid JSON or YAML format',
@@ -93,15 +94,19 @@ const JsonInput = ({
93
94
  value={value}
94
95
  onChange={(e) => {
95
96
  if (fieldIsDisabled) return
96
- setIsValid(undefined)
97
- setDisabledBeautify(true)
98
- onChange(e.target.value)
97
+ if (regex.ASCII.test(e.target.value)) {
98
+ setIsValid(undefined)
99
+ setDisabledBeautify(true)
100
+ onChange(e.target.value)
101
+ }
99
102
  }}
100
103
  onPaste={(e) => {
101
104
  if (fieldIsDisabled) return
102
- setIsValid(undefined)
103
- setDisabledBeautify(true)
104
- onChange(e.target.value)
105
+ if (regex.ASCII.test(e.target.value)) {
106
+ setIsValid(undefined)
107
+ setDisabledBeautify(true)
108
+ onChange(e.target.value)
109
+ }
105
110
  }}
106
111
  min="1"
107
112
  placeholder={placeholder}
@@ -1,5 +1,18 @@
1
- p.apiName {
2
- font-size: 40px;
3
- line-height: 30px;
4
- font-weight: 500;
5
- }
1
+ .livePreviewContainer {
2
+ .titleContainer {
3
+ display: flex;
4
+ justify-content: space-between;
5
+ align-items: center;
6
+
7
+ p.apiName {
8
+ font-size: 40px;
9
+ line-height: 30px;
10
+ font-weight: 500;
11
+ }
12
+
13
+ .livePreviewChip {
14
+ background-color: #ebecf2;
15
+ color: #12131a;
16
+ }
17
+ }
18
+ }
@@ -6,7 +6,7 @@ import { TransformedOpenApi } from '../../types/transformedOpenApi'
6
6
  import { useFormikContext } from 'formik'
7
7
  import { methodColorMapping, tagsTableHeaders } from '../../constants/index'
8
8
  import TagsTable from '../table/tags-table'
9
- import { Button } from 'digitinary-ui'
9
+ import { Button, Chip } from 'digitinary-ui'
10
10
  import Tooltip from '../../components/Tooltip/Tooltip'
11
11
 
12
12
  interface LivePreviewProps {
@@ -105,10 +105,13 @@ const LivePreview: React.FC<LivePreviewProps> = ({ transformedData }) => {
105
105
  }
106
106
 
107
107
  return (
108
- <div>
108
+ <div className={styles.livePreviewContainer}>
109
109
  <div className="row">
110
110
  <div className="col-md-12">
111
- <p className={styles.apiName}>{info?.title}</p>
111
+ <div className={styles.titleContainer}>
112
+ <p className={styles.apiName}>{info?.title?.trim() || '-'}</p>
113
+ <Chip className={styles.livePreviewChip}>Live Preview</Chip>
114
+ </div>
112
115
  <SimpleLabelValue
113
116
  key={'APIAuthenticationType'}
114
117
  label={'API authentication type: '}
@@ -122,7 +125,7 @@ const LivePreview: React.FC<LivePreviewProps> = ({ transformedData }) => {
122
125
  <SimpleLabelValue
123
126
  key={'description'}
124
127
  label={'Description: '}
125
- value={info?.description || '-'}
128
+ value={info?.description?.trim() || '-'}
126
129
  />
127
130
 
128
131
  <SimpleLabelValue key={'tags'} label={'Tags: '} />
@@ -12,6 +12,7 @@ import CommonDialog from '../../components/dialog'
12
12
  import JsonInput from '../../components/JsonInput/JsonInput'
13
13
  import styles from './MethodAccordion.module.scss'
14
14
  import { Tags } from '@entities/openApi'
15
+ import regex from '../../constants/regex'
15
16
 
16
17
  const httpStatusCodeOptions = httpStatusCodes.map((code) => ({
17
18
  label: (
@@ -32,12 +33,16 @@ const MethodsAccordion = ({
32
33
  setFieldValue,
33
34
  readOnly,
34
35
  tags,
36
+ isOpen,
37
+ setIsOpen,
35
38
  }: {
36
39
  method: TransformedMethod
37
40
  path: string
38
41
  setFieldValue?: (key: string, value: string | string[]) => void
39
42
  readOnly?: boolean
40
43
  tags: Tags[]
44
+ isOpen: boolean
45
+ setIsOpen: (open: boolean) => void
41
46
  }) => {
42
47
  const [isExpanded, setIsExpanded] = useState({
43
48
  request: false,
@@ -115,70 +120,79 @@ const MethodsAccordion = ({
115
120
  <p style={{ alignSelf: 'center' }}>
116
121
  {method.parameters[index].description
117
122
  ? method.parameters[index].description.substring(0, 12)
118
- : '-'}
123
+ : readOnly && '-'}
119
124
  {method.parameters[index].description &&
120
125
  method.parameters[index].description.length > 12
121
126
  ? '...'
122
127
  : ''}
123
128
  </p>
124
129
  </Tooltip>
125
- <Tooltip
126
- key={`${index}-add-edit-description`}
127
- allowHTML
128
- arrowWithBorder
129
- placement="bottom-end"
130
- type="function"
131
- trigger="click"
132
- delay={[0, 0]}
133
- onCreate={(instance) =>
134
- setTooltipRefs((prev) => ({
135
- ...prev,
136
- [index]: instance,
137
- }))
138
- }
139
- content={
140
- <div className={styles.editDescTooltipContent}>
141
- <p className={styles.editDescTooltipContent_header}>Description</p>
142
- <TextArea
143
- placeholder="Describe parameter..."
144
- value={item.description}
145
- disabled={readOnly}
146
- onChange={(value) => onTableChange('description', value, index)}
147
- />
148
- {!readOnly && (
149
- <Button
150
- className={styles.editDescTooltipContent_btn}
151
- variant="outlined"
152
- size="small"
153
- onClick={() => {
154
- setFieldValue(`parameters[${index}].description`, item.description)
155
- tooltipRefs[index]?.hide()
130
+ {!readOnly && (
131
+ <Tooltip
132
+ key={`${index}-add-edit-description`}
133
+ allowHTML
134
+ arrowWithBorder
135
+ placement="bottom-end"
136
+ type="function"
137
+ trigger="click"
138
+ delay={[0, 0]}
139
+ onCreate={(instance) =>
140
+ setTooltipRefs((prev) => ({
141
+ ...prev,
142
+ [index]: instance,
143
+ }))
144
+ }
145
+ content={
146
+ <div className={styles.editDescTooltipContent}>
147
+ <p className={styles.editDescTooltipContent_header}>Description</p>
148
+ <TextArea
149
+ placeholder="Describe parameter..."
150
+ value={item.description}
151
+ disabled={readOnly}
152
+ onChange={(value) => {
153
+ if (value === '' || regex.ASCII.test(value))
154
+ onTableChange('description', value, index)
156
155
  }}
157
- >
158
- Apply
159
- </Button>
160
- )}
161
- </div>
162
- }
163
- >
164
- {readOnly || method.parameters[index].description?.length > 0 ? (
165
- <Button
166
- className={styles.editDescBtn}
167
- variant="link"
168
- color="action"
169
- endIcon={<SVGLoader src={EditIcon} width="1.5rem" height="1.5rem" />}
170
- ></Button>
171
- ) : (
172
- <Button
173
- className={styles.editDescBtn}
174
- variant="link"
175
- color="action"
176
- endIcon={<SVGLoader src={EditIcon} width="1.5rem" height="1.5rem" />}
177
- >
178
- {readOnly ? 'View ' : 'Add '} Description
179
- </Button>
180
- )}
181
- </Tooltip>
156
+ />
157
+ {!readOnly && (
158
+ <Button
159
+ className={styles.editDescTooltipContent_btn}
160
+ variant="outlined"
161
+ size="small"
162
+ onClick={() => {
163
+ setFieldValue(
164
+ `parameters[${index}].description`,
165
+ item.description?.trim()
166
+ )
167
+ tooltipRefs[index]?.hide()
168
+ }}
169
+ disabled={!item.description?.trim()}
170
+ >
171
+ Apply
172
+ </Button>
173
+ )}
174
+ </div>
175
+ }
176
+ >
177
+ {readOnly || method.parameters[index].description?.length > 0 ? (
178
+ <Button
179
+ className={styles.editDescBtn}
180
+ variant="link"
181
+ color="action"
182
+ endIcon={<SVGLoader src={EditIcon} width="1.5rem" height="1.5rem" />}
183
+ ></Button>
184
+ ) : (
185
+ <Button
186
+ className={styles.editDescBtn}
187
+ variant="link"
188
+ color="action"
189
+ endIcon={<SVGLoader src={EditIcon} width="1.5rem" height="1.5rem" />}
190
+ >
191
+ {readOnly ? 'View ' : 'Add '} Description
192
+ </Button>
193
+ )}
194
+ </Tooltip>
195
+ )}
182
196
 
183
197
  {!readOnly && <div className={styles.paramDescContainer_separator}></div>}
184
198
 
@@ -254,8 +268,8 @@ const MethodsAccordion = ({
254
268
  return (
255
269
  <div>
256
270
  <Accordion
257
- expanded={isExpanded.method}
258
- onChange={() => setIsExpanded((prev) => ({ ...prev, method: !prev.method }))}
271
+ expanded={isOpen}
272
+ onChange={() => setIsOpen(!isOpen)}
259
273
  className={`${styles.methodAccordion} ${readOnly ? styles.readOnly : ''}`}
260
274
  summary={
261
275
  <div className={styles.methodSummaryContainer}>
@@ -271,9 +285,7 @@ const MethodsAccordion = ({
271
285
  <span className={styles.methodPath}>{path}</span>
272
286
  </div>
273
287
  <div
274
- className={`${styles.methodExpandArrowContainer} ${
275
- isExpanded.method ? styles.expanded : ''
276
- }`}
288
+ className={`${styles.methodExpandArrowContainer} ${isOpen ? styles.expanded : ''}`}
277
289
  >
278
290
  <SVGLoader src={DownArrowIcon} width="2rem" height="2rem" />
279
291
  </div>
@@ -311,7 +323,9 @@ const MethodsAccordion = ({
311
323
  label="Description"
312
324
  placeholder="Describe the method's purpose and functionality..."
313
325
  value={method?.description}
314
- onChange={(value) => setFieldValue('description', value)}
326
+ onChange={(value) => {
327
+ if (value === '' || regex.ASCII.test(value)) setFieldValue('description', value)
328
+ }}
315
329
  />
316
330
  ) : (
317
331
  <SimpleLabelValue
@@ -1,7 +1,9 @@
1
1
  .tooltip-custom-wrapper {
2
2
  display: flex;
3
3
  }
4
-
4
+ [data-tippy-root] {
5
+ z-index: 2 !important;
6
+ }
5
7
  .tippy-box {
6
8
  background-color: #202f5b;
7
9
  font-size: 0.875rem;
@@ -12,16 +14,17 @@
12
14
  word-break: break-word;
13
15
  position: relative;
14
16
  border: 1px solid #d8dae5;
17
+ z-index: 2;
15
18
 
16
19
  &.function {
17
20
  .tippy-content {
18
21
  background-color: #fff !important;
19
22
  color: #000 !important;
20
23
  }
21
- }
22
24
 
23
- &[data-placement] > .tippy-arrow:before {
24
- color: #fff !important;
25
+ &[data-placement] > .tippy-arrow:before {
26
+ color: #fff !important;
27
+ }
25
28
  }
26
29
 
27
30
  &.info {
@@ -109,7 +112,7 @@
109
112
  .tippy-arrow {
110
113
  top: 1px;
111
114
  background-color: white;
112
- z-index: 9999;
115
+ z-index: 2;
113
116
  height: 1px;
114
117
 
115
118
  &:before {
@@ -120,7 +123,7 @@
120
123
  border: none;
121
124
  border-left: 1px solid #d8dae5 !important;
122
125
  border-top: 1px solid #d8dae5 !important;
123
- z-index: 20000000000;
126
+ z-index: 2;
124
127
  top: -0.45rem;
125
128
  transform-origin: center !important;
126
129
  }
@@ -29,7 +29,7 @@
29
29
  .tableHead {
30
30
  border: 1px solid var(--Gray-10);
31
31
  margin: 0rem !important;
32
- background-color: var(--background-color-header);
32
+ background-color: #f8f9fb;
33
33
  width: max-content;
34
34
  min-width: 100%;
35
35
  color: var(--Gray-50);
@@ -33,13 +33,13 @@ const ParamterTable = ({
33
33
  description: '',
34
34
  },
35
35
  validationSchema: yup.object().shape({
36
- name: yup.string().required('Parameter name is required'),
36
+ name: yup.string().trim().required('Parameter name is required'),
37
37
  in: yup.string().required('Paramter type is required'),
38
38
  schema: yup.object().shape({
39
39
  type: yup.string().required('Parameter schema type is required'),
40
40
  }),
41
41
  required: yup.boolean().optional(),
42
- description: yup.string().optional(),
42
+ description: yup.string().trim().optional(),
43
43
  }),
44
44
  onSubmit: (values) => {
45
45
  saveNewRow(values)
@@ -126,13 +126,12 @@ const ParamterTable = ({
126
126
  placeholder="Parameter name"
127
127
  size="large"
128
128
  type="text"
129
- // errorMsg={!!errors.name && errors.name}
130
129
  onChange={(value) => {
131
- setFieldValue('name', value)
132
- }} // Pass the value directly
133
- value={values.name} // Bind value to the state
130
+ if (value === '' || regex.ASCII.test(value as string))
131
+ setFieldValue('name', value)
132
+ }}
133
+ value={values.name}
134
134
  disabled={readOnly}
135
- restrictedCharactersRegex={regex.basic}
136
135
  />
137
136
  </div>
138
137
  </td>
@@ -231,6 +230,7 @@ const ParamterTable = ({
231
230
  }}
232
231
  disabled={readOnly}
233
232
  placeholder="Describe parameter..."
233
+ maxLength={120}
234
234
  />
235
235
  {!readOnly && (
236
236
  <Button
@@ -238,9 +238,10 @@ const ParamterTable = ({
238
238
  variant="outlined"
239
239
  size="small"
240
240
  onClick={() => {
241
- setFieldValue('description', text)
241
+ setFieldValue('description', text?.trim())
242
242
  tooltipRef?.hide()
243
243
  }}
244
+ disabled={text?.trim() === ''}
244
245
  >
245
246
  Apply
246
247
  </Button>