@digi-frontend/dgate-api-documentation 1.0.21 → 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.
- package/dist/src/components/InfoForm/InfoForm.js +1 -1
- package/dist/src/components/InfoForm/InfoForm.js.map +1 -1
- package/dist/src/components/JsonInput/JsonInput.js +1 -1
- package/dist/src/components/JsonInput/JsonInput.js.map +1 -1
- package/dist/src/components/LivePreview/LivePreview.js +1 -1
- package/dist/src/components/LivePreview/LivePreview.js.map +1 -1
- package/dist/src/components/MethodAccordion/MethodAccordion.js +1 -1
- package/dist/src/components/MethodAccordion/MethodAccordion.js.map +1 -1
- package/dist/src/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/src/components/table/table.js +1 -1
- package/dist/src/components/table/table.js.map +1 -1
- package/dist/src/components/table/tags-table.js +1 -1
- package/dist/src/components/table/tags-table.js.map +1 -1
- package/dist/src/constants/regex.js +1 -1
- package/dist/src/constants/regex.js.map +1 -1
- package/dist/src/helpers/layout.helper.js +1 -1
- package/dist/src/helpers/layout.helper.js.map +1 -1
- package/dist/src/layout/layout.js +1 -1
- package/dist/src/layout/layout.js.map +1 -1
- package/dist/src/layout/layout.module.css.js +1 -1
- package/dist/src/validator/form.scheme.js +1 -1
- package/dist/src/validator/form.scheme.js.map +1 -1
- package/dist/styles.css +344 -311
- package/dist/types/components/MethodAccordion/MethodAccordion.d.ts +3 -1
- package/dist/types/components/Tooltip/Tooltip.d.ts +2 -2
- package/dist/types/constants/regex.d.ts +2 -0
- package/dist/types/validator/form.scheme.d.ts +1 -1
- package/package.json +2 -2
- package/src/components/InfoForm/InfoForm.module.scss +24 -1
- package/src/components/InfoForm/InfoForm.tsx +89 -47
- package/src/components/JsonInput/JsonInput.tsx +18 -7
- package/src/components/LivePreview/LivePreview.module.scss +18 -5
- package/src/components/LivePreview/LivePreview.tsx +47 -25
- package/src/components/MethodAccordion/MethodAccordion.tsx +103 -67
- package/src/components/Tooltip/Tooltip.scss +12 -9
- package/src/components/Tooltip/Tooltip.tsx +2 -3
- package/src/components/table/style.scss +1 -1
- package/src/components/table/table.tsx +11 -8
- package/src/components/table/tags-table.tsx +49 -14
- package/src/constants/regex.ts +2 -0
- package/src/helpers/layout.helper.ts +1 -1
- package/src/layout/layout.module.css +5 -0
- package/src/layout/layout.tsx +45 -7
- package/src/validator/form.scheme.ts +9 -9
|
@@ -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,
|
|
@@ -100,68 +105,94 @@ const MethodsAccordion = ({
|
|
|
100
105
|
description: (
|
|
101
106
|
<div className={styles.paramDescContainer}>
|
|
102
107
|
<Tooltip
|
|
108
|
+
key={`${index}-description`}
|
|
109
|
+
allowHTML
|
|
110
|
+
disabled={method.parameters[index].description?.length <= 12}
|
|
111
|
+
content={
|
|
112
|
+
<div style={{ padding: '0.625rem' }}>{method.parameters[index].description}</div>
|
|
113
|
+
}
|
|
103
114
|
arrowWithBorder
|
|
104
115
|
placement="bottom-end"
|
|
105
116
|
type="function"
|
|
106
|
-
trigger="click"
|
|
107
117
|
delay={[0, 0]}
|
|
108
|
-
|
|
109
|
-
setTooltipRefs((prev) => ({
|
|
110
|
-
...prev,
|
|
111
|
-
[index]: instance,
|
|
112
|
-
}))
|
|
113
|
-
}
|
|
114
|
-
content={
|
|
115
|
-
<div className={styles.editDescTooltipContent}>
|
|
116
|
-
<p className={styles.editDescTooltipContent_header}>Description</p>
|
|
117
|
-
<TextArea
|
|
118
|
-
placeholder="Describe parameter..."
|
|
119
|
-
value={item.description}
|
|
120
|
-
disabled={readOnly}
|
|
121
|
-
onChange={(value) => onTableChange('description', value, index)}
|
|
122
|
-
/>
|
|
123
|
-
{!readOnly && (
|
|
124
|
-
<Button
|
|
125
|
-
className={styles.editDescTooltipContent_btn}
|
|
126
|
-
variant="outlined"
|
|
127
|
-
size="small"
|
|
128
|
-
onClick={() => {
|
|
129
|
-
setFieldValue(`parameters[${index}].description`, item.description)
|
|
130
|
-
tooltipRefs[index]?.hide()
|
|
131
|
-
}}
|
|
132
|
-
>
|
|
133
|
-
Apply
|
|
134
|
-
</Button>
|
|
135
|
-
)}
|
|
136
|
-
</div>
|
|
137
|
-
}
|
|
118
|
+
onShow={() => tooltipRefs[index]?.hide()}
|
|
138
119
|
>
|
|
139
|
-
{
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
: '-'}
|
|
149
|
-
{method.parameters[index].description &&
|
|
150
|
-
method.parameters[index].description.length > 12
|
|
151
|
-
? '...'
|
|
152
|
-
: ''}
|
|
153
|
-
</Button>
|
|
154
|
-
) : (
|
|
155
|
-
<Button
|
|
156
|
-
className={styles.editDescBtn}
|
|
157
|
-
variant="link"
|
|
158
|
-
color="action"
|
|
159
|
-
endIcon={<SVGLoader src={EditIcon} width="1.5rem" height="1.5rem" />}
|
|
160
|
-
>
|
|
161
|
-
{readOnly ? 'View ' : 'Add '} Description
|
|
162
|
-
</Button>
|
|
163
|
-
)}
|
|
120
|
+
<p style={{ alignSelf: 'center' }}>
|
|
121
|
+
{method.parameters[index].description
|
|
122
|
+
? method.parameters[index].description.substring(0, 12)
|
|
123
|
+
: readOnly && '-'}
|
|
124
|
+
{method.parameters[index].description &&
|
|
125
|
+
method.parameters[index].description.length > 12
|
|
126
|
+
? '...'
|
|
127
|
+
: ''}
|
|
128
|
+
</p>
|
|
164
129
|
</Tooltip>
|
|
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)
|
|
155
|
+
}}
|
|
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
|
+
)}
|
|
165
196
|
|
|
166
197
|
{!readOnly && <div className={styles.paramDescContainer_separator}></div>}
|
|
167
198
|
|
|
@@ -210,14 +241,13 @@ const MethodsAccordion = ({
|
|
|
210
241
|
|
|
211
242
|
useEffect(() => {
|
|
212
243
|
if (method?.parameters) {
|
|
213
|
-
setTableRecords(generateTableData(method.parameters))
|
|
214
244
|
setTableData(method.parameters)
|
|
215
245
|
}
|
|
216
246
|
}, [method, path])
|
|
217
247
|
|
|
218
248
|
useEffect(() => {
|
|
219
249
|
// prepare tags selection list
|
|
220
|
-
if (
|
|
250
|
+
if (method?.tags.length || tags.length) {
|
|
221
251
|
const convertedStringArray = (method?.tags || [])?.map((item) => ({
|
|
222
252
|
label: capitalize(item),
|
|
223
253
|
value: item,
|
|
@@ -230,6 +260,7 @@ const MethodsAccordion = ({
|
|
|
230
260
|
const filteredArray = mergedArray.filter(
|
|
231
261
|
(value, index, self) => index === self.findIndex((t) => t.value === value.value)
|
|
232
262
|
)
|
|
263
|
+
|
|
233
264
|
setSelectionTags(filteredArray)
|
|
234
265
|
}
|
|
235
266
|
}, [tags, method])
|
|
@@ -237,8 +268,8 @@ const MethodsAccordion = ({
|
|
|
237
268
|
return (
|
|
238
269
|
<div>
|
|
239
270
|
<Accordion
|
|
240
|
-
expanded={
|
|
241
|
-
onChange={() =>
|
|
271
|
+
expanded={isOpen}
|
|
272
|
+
onChange={() => setIsOpen(!isOpen)}
|
|
242
273
|
className={`${styles.methodAccordion} ${readOnly ? styles.readOnly : ''}`}
|
|
243
274
|
summary={
|
|
244
275
|
<div className={styles.methodSummaryContainer}>
|
|
@@ -254,9 +285,7 @@ const MethodsAccordion = ({
|
|
|
254
285
|
<span className={styles.methodPath}>{path}</span>
|
|
255
286
|
</div>
|
|
256
287
|
<div
|
|
257
|
-
className={`${styles.methodExpandArrowContainer} ${
|
|
258
|
-
isExpanded.method ? styles.expanded : ''
|
|
259
|
-
}`}
|
|
288
|
+
className={`${styles.methodExpandArrowContainer} ${isOpen ? styles.expanded : ''}`}
|
|
260
289
|
>
|
|
261
290
|
<SVGLoader src={DownArrowIcon} width="2rem" height="2rem" />
|
|
262
291
|
</div>
|
|
@@ -294,7 +323,9 @@ const MethodsAccordion = ({
|
|
|
294
323
|
label="Description"
|
|
295
324
|
placeholder="Describe the method's purpose and functionality..."
|
|
296
325
|
value={method?.description}
|
|
297
|
-
onChange={(value) =>
|
|
326
|
+
onChange={(value) => {
|
|
327
|
+
if (value === '' || regex.ASCII.test(value)) setFieldValue('description', value)
|
|
328
|
+
}}
|
|
298
329
|
/>
|
|
299
330
|
) : (
|
|
300
331
|
<SimpleLabelValue
|
|
@@ -343,6 +374,7 @@ const MethodsAccordion = ({
|
|
|
343
374
|
}
|
|
344
375
|
children={
|
|
345
376
|
<JsonInput
|
|
377
|
+
acceptType="JSON"
|
|
346
378
|
withFooter={!readOnly}
|
|
347
379
|
className={'jsonField'}
|
|
348
380
|
placeholder="Enter your request body as a JSON object...."
|
|
@@ -399,6 +431,7 @@ const MethodsAccordion = ({
|
|
|
399
431
|
}
|
|
400
432
|
children={
|
|
401
433
|
<JsonInput
|
|
434
|
+
acceptType="JSON"
|
|
402
435
|
withFooter={!readOnly}
|
|
403
436
|
className={'jsonField'}
|
|
404
437
|
placeholder="Enter your response as a JSON object..."
|
|
@@ -451,17 +484,20 @@ const MethodsAccordion = ({
|
|
|
451
484
|
className="delete-msg-container"
|
|
452
485
|
>
|
|
453
486
|
Are you sure you want to delete
|
|
454
|
-
<span className="plan-name">
|
|
487
|
+
<span className="plan-name">
|
|
488
|
+
Parameter <strong>{selectedParamName}</strong>
|
|
489
|
+
</span>
|
|
490
|
+
?
|
|
455
491
|
</p>
|
|
456
492
|
}
|
|
457
493
|
onSubmit={{
|
|
458
494
|
onClick: confirmDeleteParameter,
|
|
459
|
-
text: '
|
|
495
|
+
text: 'Delete',
|
|
460
496
|
color: 'error',
|
|
461
497
|
fullWidth: true,
|
|
462
498
|
}}
|
|
463
499
|
onCancel={{
|
|
464
|
-
text: '
|
|
500
|
+
text: 'Cancel',
|
|
465
501
|
color: 'normal',
|
|
466
502
|
fullWidth: true,
|
|
467
503
|
}}
|
|
@@ -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
|
-
|
|
24
|
-
|
|
25
|
+
&[data-placement] > .tippy-arrow:before {
|
|
26
|
+
color: #fff !important;
|
|
27
|
+
}
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
&.info {
|
|
@@ -109,19 +112,19 @@
|
|
|
109
112
|
.tippy-arrow {
|
|
110
113
|
top: 1px;
|
|
111
114
|
background-color: white;
|
|
112
|
-
z-index:
|
|
115
|
+
z-index: 2;
|
|
113
116
|
height: 1px;
|
|
114
117
|
|
|
115
118
|
&:before {
|
|
116
|
-
width:
|
|
117
|
-
height:
|
|
119
|
+
width: 0.625rem;
|
|
120
|
+
height: 0.625rem;
|
|
118
121
|
background-color: white;
|
|
119
122
|
transform: rotate(45deg);
|
|
120
123
|
border: none;
|
|
121
124
|
border-left: 1px solid #d8dae5 !important;
|
|
122
125
|
border-top: 1px solid #d8dae5 !important;
|
|
123
|
-
z-index:
|
|
124
|
-
top: -0.
|
|
126
|
+
z-index: 2;
|
|
127
|
+
top: -0.45rem;
|
|
125
128
|
transform-origin: center !important;
|
|
126
129
|
}
|
|
127
130
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import React, { useState, useEffect, ReactNode } from 'react'
|
|
2
|
-
import Tippy from '@tippyjs/react'
|
|
2
|
+
import Tippy, { TippyProps } from '@tippyjs/react'
|
|
3
3
|
import 'tippy.js/dist/tippy.css'
|
|
4
4
|
import './Tooltip.scss'
|
|
5
5
|
|
|
6
|
-
interface TooltipProps {
|
|
7
|
-
children: ReactNode
|
|
6
|
+
interface TooltipProps extends TippyProps {
|
|
8
7
|
content: ReactNode
|
|
9
8
|
success?: boolean
|
|
10
9
|
onMouseEnter?: (event: React.MouseEvent<HTMLDivElement>) => void
|
|
@@ -8,6 +8,7 @@ import styles from '../MethodAccordion/MethodAccordion.module.scss'
|
|
|
8
8
|
import { useFormik } from 'formik'
|
|
9
9
|
import * as yup from 'yup'
|
|
10
10
|
import { capitalize } from '../../helpers/methodAccordion.helper'
|
|
11
|
+
import regex from '../../constants/regex'
|
|
11
12
|
|
|
12
13
|
const ParamterTable = ({
|
|
13
14
|
id,
|
|
@@ -32,13 +33,13 @@ const ParamterTable = ({
|
|
|
32
33
|
description: '',
|
|
33
34
|
},
|
|
34
35
|
validationSchema: yup.object().shape({
|
|
35
|
-
name: yup.string().required('Parameter name is required'),
|
|
36
|
+
name: yup.string().trim().required('Parameter name is required'),
|
|
36
37
|
in: yup.string().required('Paramter type is required'),
|
|
37
38
|
schema: yup.object().shape({
|
|
38
39
|
type: yup.string().required('Parameter schema type is required'),
|
|
39
40
|
}),
|
|
40
41
|
required: yup.boolean().optional(),
|
|
41
|
-
description: yup.string().optional(),
|
|
42
|
+
description: yup.string().trim().optional(),
|
|
42
43
|
}),
|
|
43
44
|
onSubmit: (values) => {
|
|
44
45
|
saveNewRow(values)
|
|
@@ -125,11 +126,11 @@ const ParamterTable = ({
|
|
|
125
126
|
placeholder="Parameter name"
|
|
126
127
|
size="large"
|
|
127
128
|
type="text"
|
|
128
|
-
// errorMsg={!!errors.name && errors.name}
|
|
129
129
|
onChange={(value) => {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
130
|
+
if (value === '' || regex.ASCII.test(value as string))
|
|
131
|
+
setFieldValue('name', value)
|
|
132
|
+
}}
|
|
133
|
+
value={values.name}
|
|
133
134
|
disabled={readOnly}
|
|
134
135
|
/>
|
|
135
136
|
</div>
|
|
@@ -225,10 +226,11 @@ const ParamterTable = ({
|
|
|
225
226
|
<TextArea
|
|
226
227
|
value={text || values.description}
|
|
227
228
|
onChange={(value) => {
|
|
228
|
-
setText(value)
|
|
229
|
+
if (value === '' || regex.ASCII.test(value)) setText(value)
|
|
229
230
|
}}
|
|
230
231
|
disabled={readOnly}
|
|
231
232
|
placeholder="Describe parameter..."
|
|
233
|
+
maxLength={120}
|
|
232
234
|
/>
|
|
233
235
|
{!readOnly && (
|
|
234
236
|
<Button
|
|
@@ -236,9 +238,10 @@ const ParamterTable = ({
|
|
|
236
238
|
variant="outlined"
|
|
237
239
|
size="small"
|
|
238
240
|
onClick={() => {
|
|
239
|
-
setFieldValue('description', text)
|
|
241
|
+
setFieldValue('description', text?.trim())
|
|
240
242
|
tooltipRef?.hide()
|
|
241
243
|
}}
|
|
244
|
+
disabled={text?.trim() === ''}
|
|
242
245
|
>
|
|
243
246
|
Apply
|
|
244
247
|
</Button>
|
|
@@ -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'
|
|
@@ -8,6 +8,7 @@ import { AddRow, EditIcon, DeleteIcon } from '../../assets/icons'
|
|
|
8
8
|
import styles from '../MethodAccordion/MethodAccordion.module.scss'
|
|
9
9
|
import { useFormik } from 'formik'
|
|
10
10
|
import * as yup from 'yup'
|
|
11
|
+
import regex from '../../constants/regex'
|
|
11
12
|
|
|
12
13
|
const TagsTable = ({ id, headCells, data, isFormOpen, setIsFormOpen, saveNewRow, readOnly }) => {
|
|
13
14
|
const [text, setText] = useState('')
|
|
@@ -26,19 +27,33 @@ const TagsTable = ({ id, headCells, data, isFormOpen, setIsFormOpen, saveNewRow,
|
|
|
26
27
|
},
|
|
27
28
|
},
|
|
28
29
|
validationSchema: yup.object().shape({
|
|
29
|
-
name: yup.string().required('Tag name is required'),
|
|
30
|
+
name: yup.string().trim().required('Tag name is required'),
|
|
30
31
|
description: yup.string().optional(),
|
|
31
|
-
externalDocs: yup
|
|
32
|
+
externalDocs: yup
|
|
33
|
+
.object()
|
|
34
|
+
.shape({
|
|
35
|
+
url: yup
|
|
36
|
+
.string()
|
|
37
|
+
.trim()
|
|
38
|
+
.matches(regex.urlRegex, 'Invalid URL')
|
|
39
|
+
.when('description', (description, schema) => {
|
|
40
|
+
return description?.at(0)
|
|
41
|
+
? schema.required('URL is required when description is provided')
|
|
42
|
+
: schema.optional()
|
|
43
|
+
}),
|
|
44
|
+
description: yup.string().trim().optional(),
|
|
45
|
+
})
|
|
46
|
+
.optional(),
|
|
32
47
|
}),
|
|
33
48
|
onSubmit: (values) => {
|
|
34
49
|
saveNewRow(values)
|
|
35
50
|
setText('')
|
|
36
|
-
setExternalDesc('')
|
|
37
|
-
setExternalUrl('')
|
|
38
51
|
resetForm()
|
|
39
52
|
setIsFormOpen(false)
|
|
40
53
|
},
|
|
54
|
+
validateOnChange: true,
|
|
41
55
|
})
|
|
56
|
+
|
|
42
57
|
return (
|
|
43
58
|
<div className="tableSectionContainer">
|
|
44
59
|
<div className="tableContainer">
|
|
@@ -106,8 +121,9 @@ const TagsTable = ({ id, headCells, data, isFormOpen, setIsFormOpen, saveNewRow,
|
|
|
106
121
|
placeholder="Tag name"
|
|
107
122
|
size="large"
|
|
108
123
|
type="text"
|
|
124
|
+
maxLength={25}
|
|
109
125
|
onChange={(value) => {
|
|
110
|
-
setFieldValue('name', value)
|
|
126
|
+
!regex.basic.test(value) && setFieldValue('name', value)
|
|
111
127
|
}} // Pass the value directly
|
|
112
128
|
value={values.name} // Bind value to the state
|
|
113
129
|
disabled={readOnly}
|
|
@@ -125,16 +141,20 @@ const TagsTable = ({ id, headCells, data, isFormOpen, setIsFormOpen, saveNewRow,
|
|
|
125
141
|
trigger="click"
|
|
126
142
|
delay={[0, 0]}
|
|
127
143
|
onCreate={(instance) => setTooltipRef(instance)}
|
|
144
|
+
onHidden={() => {
|
|
145
|
+
setText(values.description)
|
|
146
|
+
}}
|
|
128
147
|
content={
|
|
129
148
|
<div className={_styles.editDescTooltipContent}>
|
|
130
149
|
<p className={_styles.editDescTooltipContent_header}>Description</p>
|
|
131
150
|
<TextArea
|
|
132
151
|
value={text || values.description}
|
|
133
|
-
onChange={(value) => {
|
|
134
|
-
setText(value)
|
|
135
|
-
}}
|
|
136
152
|
disabled={readOnly}
|
|
153
|
+
maxLength={25}
|
|
137
154
|
placeholder="Describe Tag..."
|
|
155
|
+
onChange={(value) => {
|
|
156
|
+
if (value === '' || regex.ASCII.test(value)) setText(value)
|
|
157
|
+
}}
|
|
138
158
|
/>
|
|
139
159
|
{!readOnly && (
|
|
140
160
|
<Button
|
|
@@ -142,9 +162,10 @@ const TagsTable = ({ id, headCells, data, isFormOpen, setIsFormOpen, saveNewRow,
|
|
|
142
162
|
variant="outlined"
|
|
143
163
|
size="small"
|
|
144
164
|
onClick={() => {
|
|
145
|
-
setFieldValue('description', text)
|
|
165
|
+
setFieldValue('description', text?.trim())
|
|
146
166
|
tooltipRef?.hide()
|
|
147
167
|
}}
|
|
168
|
+
disabled={!(text || values.description)?.trim()}
|
|
148
169
|
>
|
|
149
170
|
Apply
|
|
150
171
|
</Button>
|
|
@@ -175,6 +196,10 @@ const TagsTable = ({ id, headCells, data, isFormOpen, setIsFormOpen, saveNewRow,
|
|
|
175
196
|
trigger="click"
|
|
176
197
|
delay={[0, 0]}
|
|
177
198
|
onCreate={(instance) => setExternalTooltipRefs(instance)}
|
|
199
|
+
onHidden={() => {
|
|
200
|
+
setExternalDesc(values.externalDocs.description)
|
|
201
|
+
setExternalUrl(values.externalDocs.url)
|
|
202
|
+
}}
|
|
178
203
|
content={
|
|
179
204
|
<div className={_styles.editDescTooltipContent}>
|
|
180
205
|
<p className={_styles.editDescTooltipContent_header}>
|
|
@@ -184,7 +209,10 @@ const TagsTable = ({ id, headCells, data, isFormOpen, setIsFormOpen, saveNewRow,
|
|
|
184
209
|
placeholder="Describe External Doc..."
|
|
185
210
|
value={externalDesc || values.externalDocs.description}
|
|
186
211
|
disabled={readOnly}
|
|
187
|
-
|
|
212
|
+
maxLength={25}
|
|
213
|
+
onChange={(value) => {
|
|
214
|
+
if (value === '' || regex.ASCII.test(value)) setExternalDesc(value)
|
|
215
|
+
}}
|
|
188
216
|
/>
|
|
189
217
|
<p className={_styles.editDescTooltipContent_header}>
|
|
190
218
|
External Docs Link
|
|
@@ -193,7 +221,10 @@ const TagsTable = ({ id, headCells, data, isFormOpen, setIsFormOpen, saveNewRow,
|
|
|
193
221
|
placeholder="External Docs Link..."
|
|
194
222
|
value={externalUrl || values.externalDocs.url}
|
|
195
223
|
disabled={readOnly}
|
|
196
|
-
|
|
224
|
+
maxLength={200}
|
|
225
|
+
onChange={(value) => {
|
|
226
|
+
if (value === '' || regex.ASCII.test(value)) setExternalUrl(value)
|
|
227
|
+
}}
|
|
197
228
|
/>
|
|
198
229
|
{!readOnly && (
|
|
199
230
|
<Button
|
|
@@ -205,10 +236,14 @@ const TagsTable = ({ id, headCells, data, isFormOpen, setIsFormOpen, saveNewRow,
|
|
|
205
236
|
description: externalDesc,
|
|
206
237
|
url: externalUrl,
|
|
207
238
|
})
|
|
208
|
-
|
|
209
|
-
setExternalUrl('')
|
|
239
|
+
|
|
210
240
|
externalTooltipRefs?.hide()
|
|
211
241
|
}}
|
|
242
|
+
disabled={
|
|
243
|
+
!(externalDesc || values.externalDocs.description)?.trim() ||
|
|
244
|
+
!(externalUrl || values.externalDocs.url)?.trim() ||
|
|
245
|
+
!regex.urlRegex.test(externalUrl || values.externalDocs.url)
|
|
246
|
+
}
|
|
212
247
|
>
|
|
213
248
|
Apply
|
|
214
249
|
</Button>
|
package/src/constants/regex.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const regex = {
|
|
2
2
|
basic: /[^a-zA-Z0-9-_ ]/, // not (alphanumeric + underscore + dash + space)
|
|
3
3
|
restrictNone: /^$/, // restrict nothing
|
|
4
|
+
ASCII: /^[\x00-\x7F]+$/,
|
|
5
|
+
urlRegex: /^(https?:\/\/)?(www\.)?([a-zA-Z0-9-]+(\.[a-zA-Z]{2,})+)(\/[^\s]*)?$/,
|
|
4
6
|
}
|
|
5
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 {
|