@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
@@ -1,4 +1,4 @@
1
- import { useState } from 'react'
1
+ import { useEffect, useState } from 'react'
2
2
  import './style.scss'
3
3
  import _styles from '../InfoForm/InfoForm.module.scss'
4
4
  import { Button, Input, TextArea } from 'digitinary-ui'
@@ -10,8 +10,6 @@ import { useFormik } from 'formik'
10
10
  import * as yup from 'yup'
11
11
  import regex from '../../constants/regex'
12
12
 
13
- const urlRegex = /^(https?:\/\/)?(www\.)?([a-zA-Z0-9-]+(\.[a-zA-Z]{2,})+)(\/[^\s]*)?$/
14
-
15
13
  const TagsTable = ({ id, headCells, data, isFormOpen, setIsFormOpen, saveNewRow, readOnly }) => {
16
14
  const [text, setText] = useState('')
17
15
  const [externalDesc, setExternalDesc] = useState('')
@@ -29,28 +27,27 @@ const TagsTable = ({ id, headCells, data, isFormOpen, setIsFormOpen, saveNewRow,
29
27
  },
30
28
  },
31
29
  validationSchema: yup.object().shape({
32
- name: yup.string().required('Tag name is required'),
30
+ name: yup.string().trim().required('Tag name is required'),
33
31
  description: yup.string().optional(),
34
32
  externalDocs: yup
35
33
  .object()
36
34
  .shape({
37
35
  url: yup
38
36
  .string()
39
- .matches(urlRegex, 'Invalid URL')
37
+ .trim()
38
+ .matches(regex.urlRegex, 'Invalid URL')
40
39
  .when('description', (description, schema) => {
41
40
  return description?.at(0)
42
41
  ? schema.required('URL is required when description is provided')
43
42
  : schema.optional()
44
43
  }),
45
- description: yup.string().optional(),
44
+ description: yup.string().trim().optional(),
46
45
  })
47
46
  .optional(),
48
47
  }),
49
48
  onSubmit: (values) => {
50
49
  saveNewRow(values)
51
50
  setText('')
52
- setExternalDesc('')
53
- setExternalUrl('')
54
51
  resetForm()
55
52
  setIsFormOpen(false)
56
53
  },
@@ -124,6 +121,7 @@ const TagsTable = ({ id, headCells, data, isFormOpen, setIsFormOpen, saveNewRow,
124
121
  placeholder="Tag name"
125
122
  size="large"
126
123
  type="text"
124
+ maxLength={25}
127
125
  onChange={(value) => {
128
126
  !regex.basic.test(value) && setFieldValue('name', value)
129
127
  }} // Pass the value directly
@@ -143,16 +141,20 @@ const TagsTable = ({ id, headCells, data, isFormOpen, setIsFormOpen, saveNewRow,
143
141
  trigger="click"
144
142
  delay={[0, 0]}
145
143
  onCreate={(instance) => setTooltipRef(instance)}
144
+ onHidden={() => {
145
+ setText(values.description)
146
+ }}
146
147
  content={
147
148
  <div className={_styles.editDescTooltipContent}>
148
149
  <p className={_styles.editDescTooltipContent_header}>Description</p>
149
150
  <TextArea
150
151
  value={text || values.description}
152
+ disabled={readOnly}
153
+ maxLength={25}
154
+ placeholder="Describe Tag..."
151
155
  onChange={(value) => {
152
156
  if (value === '' || regex.ASCII.test(value)) setText(value)
153
157
  }}
154
- disabled={readOnly}
155
- placeholder="Describe Tag..."
156
158
  />
157
159
  {!readOnly && (
158
160
  <Button
@@ -160,9 +162,10 @@ const TagsTable = ({ id, headCells, data, isFormOpen, setIsFormOpen, saveNewRow,
160
162
  variant="outlined"
161
163
  size="small"
162
164
  onClick={() => {
163
- setFieldValue('description', text)
165
+ setFieldValue('description', text?.trim())
164
166
  tooltipRef?.hide()
165
167
  }}
168
+ disabled={!(text || values.description)?.trim()}
166
169
  >
167
170
  Apply
168
171
  </Button>
@@ -193,6 +196,10 @@ const TagsTable = ({ id, headCells, data, isFormOpen, setIsFormOpen, saveNewRow,
193
196
  trigger="click"
194
197
  delay={[0, 0]}
195
198
  onCreate={(instance) => setExternalTooltipRefs(instance)}
199
+ onHidden={() => {
200
+ setExternalDesc(values.externalDocs.description)
201
+ setExternalUrl(values.externalDocs.url)
202
+ }}
196
203
  content={
197
204
  <div className={_styles.editDescTooltipContent}>
198
205
  <p className={_styles.editDescTooltipContent_header}>
@@ -202,6 +209,7 @@ const TagsTable = ({ id, headCells, data, isFormOpen, setIsFormOpen, saveNewRow,
202
209
  placeholder="Describe External Doc..."
203
210
  value={externalDesc || values.externalDocs.description}
204
211
  disabled={readOnly}
212
+ maxLength={25}
205
213
  onChange={(value) => {
206
214
  if (value === '' || regex.ASCII.test(value)) setExternalDesc(value)
207
215
  }}
@@ -213,6 +221,7 @@ const TagsTable = ({ id, headCells, data, isFormOpen, setIsFormOpen, saveNewRow,
213
221
  placeholder="External Docs Link..."
214
222
  value={externalUrl || values.externalDocs.url}
215
223
  disabled={readOnly}
224
+ maxLength={200}
216
225
  onChange={(value) => {
217
226
  if (value === '' || regex.ASCII.test(value)) setExternalUrl(value)
218
227
  }}
@@ -227,10 +236,14 @@ const TagsTable = ({ id, headCells, data, isFormOpen, setIsFormOpen, saveNewRow,
227
236
  description: externalDesc,
228
237
  url: externalUrl,
229
238
  })
230
- setExternalDesc('')
231
- setExternalUrl('')
239
+
232
240
  externalTooltipRefs?.hide()
233
241
  }}
242
+ disabled={
243
+ !(externalDesc || values.externalDocs.description)?.trim() ||
244
+ !(externalUrl || values.externalDocs.url)?.trim() ||
245
+ !regex.urlRegex.test(externalUrl || values.externalDocs.url)
246
+ }
234
247
  >
235
248
  Apply
236
249
  </Button>
@@ -2,5 +2,6 @@ const regex = {
2
2
  basic: /[^a-zA-Z0-9-_ ]/, // not (alphanumeric + underscore + dash + space)
3
3
  restrictNone: /^$/, // restrict nothing
4
4
  ASCII: /^[\x00-\x7F]+$/,
5
+ urlRegex: /^(https?:\/\/)?(www\.)?([a-zA-Z0-9-]+(\.[a-zA-Z]{2,})+)(\/[^\s]*)?$/,
5
6
  }
6
7
  export default regex
@@ -56,7 +56,7 @@ export const transformPathsToArray = (paths: OpenAPIFile['paths']): TransformedP
56
56
  const obj: any = {
57
57
  ...methodProps,
58
58
  type: method,
59
- tags: methodProps.tags,
59
+ tags: methodProps.tags || [],
60
60
  responses: Object.entries(methodProps.responses).map(([code, codeProps]) => {
61
61
  const contentType = Object.keys(codeProps.content || {})[0]
62
62
  return {
@@ -7,6 +7,7 @@
7
7
 
8
8
  .apiDocAlert {
9
9
  border-radius: 0;
10
+ z-index: 3;
10
11
  }
11
12
 
12
13
  .layoutContainer {
@@ -53,4 +54,8 @@
53
54
  scroll-behavior: smooth;
54
55
  }
55
56
  }
57
+
58
+ :global(.textArea .inputField) {
59
+ padding-inline-end: 2.5rem;
60
+ }
56
61
  }
@@ -38,6 +38,7 @@ const Layout = ({ openApiJson, handleSave, setIsFormDirty }: ILayoutProps): JSX.
38
38
  },
39
39
  })
40
40
  const [isPublishDialogOpen, setIsPublishDialogOpen] = useState(false)
41
+ const [openMethodIndex, setOpenMethodIndex] = useState<number | null>(null)
41
42
 
42
43
  useEffect(() => {
43
44
  if (setIsFormDirty) {
@@ -77,7 +78,7 @@ const Layout = ({ openApiJson, handleSave, setIsFormDirty }: ILayoutProps): JSX.
77
78
  <FormikProvider value={formik}>
78
79
  <InfoForm />
79
80
  </FormikProvider>
80
- <SectionHead className={styles.editorSectionHead} text="API Methods" />
81
+ <SectionHead className={styles.editorSectionHead} text="Endpoints" />
81
82
  <FormikProvider value={formik}>
82
83
  {formik.values.paths.map((path, pathIndex) => (
83
84
  <>
@@ -94,6 +95,8 @@ const Layout = ({ openApiJson, handleSave, setIsFormDirty }: ILayoutProps): JSX.
94
95
  const h = `paths[${pathIndex}].methods[${methodIndex}].${key}`
95
96
  formik.setFieldValue(h, value)
96
97
  }}
98
+ isOpen={openMethodIndex === methodIndex}
99
+ setIsOpen={(open) => setOpenMethodIndex(open ? methodIndex : null)}
97
100
  />
98
101
  ))}
99
102
  </>
@@ -4,7 +4,7 @@ export const schemaValidation = yup.object({
4
4
  info: yup
5
5
  .object({
6
6
  title: yup.string().trim().required('API Name is required.'),
7
- description: yup.string().required(),
7
+ description: yup.string().trim().required(),
8
8
  version: yup.string().required('API Version is required'),
9
9
  })
10
10
  .required(),