@digi-frontend/dgate-api-documentation 1.0.28 → 1.0.31

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 (103) hide show
  1. package/.editorconfig +12 -12
  2. package/.prettierignore +7 -7
  3. package/.prettierrc +15 -15
  4. package/dist/{a7568b270e175038.svg → 070dc6ecd197bc80.svg} +8 -8
  5. package/dist/{43595976d1fdccbf.svg → 2e10bbdb265df50e.svg} +4 -4
  6. package/dist/{b82c7612e73342f3.svg → 7f54eeb0bb2d1150.svg} +3 -3
  7. package/dist/{56dc416b683db280.svg → 8789eb84283ea95b.svg} +5 -5
  8. package/dist/{af16a554be8c4d69.svg → 9bdff13f8d8fa48a.svg} +3 -3
  9. package/dist/_virtual/index4.js +1 -1
  10. package/dist/_virtual/index5.js +1 -1
  11. package/dist/_virtual/index6.js +1 -1
  12. package/dist/{64efc2716808c4a4.svg → bb8b87cace25e052.svg} +3 -3
  13. package/dist/{72db3b05a96dd600.svg → d32ce84bbd78babd.svg} +3 -3
  14. package/dist/{844eba3f2e42a9eb.svg → d501922060662842.svg} +3 -3
  15. package/dist/node_modules/toposort/index.js +1 -1
  16. package/dist/node_modules/yup/index.esm.js +1 -1
  17. package/dist/src/assets/icons/AddRow.svg.js +1 -1
  18. package/dist/src/assets/icons/AddRow.svg.js.map +1 -1
  19. package/dist/src/assets/icons/CheckMarkSquare.svg.js +1 -1
  20. package/dist/src/assets/icons/CheckMarkSquare.svg.js.map +1 -1
  21. package/dist/src/assets/icons/CloseIcon.svg.js +1 -1
  22. package/dist/src/assets/icons/CloseIcon.svg.js.map +1 -1
  23. package/dist/src/assets/icons/DeleteIcon.svg.js +1 -1
  24. package/dist/src/assets/icons/DeleteIcon.svg.js.map +1 -1
  25. package/dist/src/assets/icons/DownArrow.svg.js +1 -1
  26. package/dist/src/assets/icons/DownArrow.svg.js.map +1 -1
  27. package/dist/src/assets/icons/EditIcon.svg.js +1 -1
  28. package/dist/src/assets/icons/EditIcon.svg.js.map +1 -1
  29. package/dist/src/assets/icons/UpArrow.svg.js +1 -1
  30. package/dist/src/assets/icons/UpArrow.svg.js.map +1 -1
  31. package/dist/src/assets/icons/deleteOutlinedIcon.svg.js +1 -1
  32. package/dist/src/assets/icons/deleteOutlinedIcon.svg.js.map +1 -1
  33. package/dist/src/components/Chips/Chips.js.map +1 -1
  34. package/dist/src/components/InfoForm/InfoForm.js.map +1 -1
  35. package/dist/src/components/JsonInput/JsonInput.js.map +1 -1
  36. package/dist/src/components/LivePreview/LivePreview.js.map +1 -1
  37. package/dist/src/components/MethodAccordion/MethodAccordion.js +1 -1
  38. package/dist/src/components/MethodAccordion/MethodAccordion.js.map +1 -1
  39. package/dist/src/components/SVGLoader/SVGLoader.js.map +1 -1
  40. package/dist/src/components/SectionHead/SectionHead.js.map +1 -1
  41. package/dist/src/components/SimpleLabelValue/SimpleLabelValue.js.map +1 -1
  42. package/dist/src/components/Tooltip/Tooltip.js.map +1 -1
  43. package/dist/src/components/dialog/index.js.map +1 -1
  44. package/dist/src/components/table/table.js +1 -1
  45. package/dist/src/components/table/table.js.map +1 -1
  46. package/dist/src/components/table/tags-table.js +1 -1
  47. package/dist/src/components/table/tags-table.js.map +1 -1
  48. package/dist/src/constants/index.js.map +1 -1
  49. package/dist/src/constants/regex.js.map +1 -1
  50. package/dist/src/helpers/layout.helper.js.map +1 -1
  51. package/dist/src/helpers/methodAccordion.helper.js.map +1 -1
  52. package/dist/src/layout/layout.js.map +1 -1
  53. package/dist/src/validator/form.scheme.js.map +1 -1
  54. package/dist/styles.css +212 -212
  55. package/package.json +43 -43
  56. package/rollup.config.js +35 -35
  57. package/src/assets/icons/AddRow.svg +3 -3
  58. package/src/assets/icons/CheckMarkSquare.svg +5 -5
  59. package/src/assets/icons/CloseIcon.svg +4 -4
  60. package/src/assets/icons/DeleteIcon.svg +3 -3
  61. package/src/assets/icons/DownArrow.svg +3 -3
  62. package/src/assets/icons/EditIcon.svg +3 -3
  63. package/src/assets/icons/UpArrow.svg +3 -3
  64. package/src/assets/icons/deleteOutlinedIcon.svg +8 -8
  65. package/src/assets/icons/index.ts +8 -8
  66. package/src/components/Chips/Chips.tsx +87 -87
  67. package/src/components/Chips/style.scss +147 -147
  68. package/src/components/InfoForm/InfoForm.module.scss +165 -165
  69. package/src/components/InfoForm/InfoForm.tsx +426 -426
  70. package/src/components/JsonInput/JsonInput.tsx +149 -149
  71. package/src/components/JsonInput/style.module.scss +133 -133
  72. package/src/components/LivePreview/LivePreview.module.scss +24 -24
  73. package/src/components/LivePreview/LivePreview.tsx +184 -184
  74. package/src/components/MethodAccordion/MethodAccordion.module.scss +338 -338
  75. package/src/components/MethodAccordion/MethodAccordion.tsx +515 -514
  76. package/src/components/SVGLoader/SVGLoader.tsx +94 -94
  77. package/src/components/SectionHead/SectionHead.scss +29 -29
  78. package/src/components/SectionHead/SectionHead.tsx +22 -22
  79. package/src/components/SimpleLabelValue/SimpleLabelValue.tsx +31 -31
  80. package/src/components/SimpleLabelValue/index.ts +1 -1
  81. package/src/components/SimpleLabelValue/style.scss +30 -30
  82. package/src/components/Tooltip/Tooltip.scss +133 -133
  83. package/src/components/Tooltip/Tooltip.tsx +85 -85
  84. package/src/components/_global.scss +337 -337
  85. package/src/components/dialog/dialog.ts +54 -54
  86. package/src/components/dialog/index.tsx +85 -85
  87. package/src/components/dialog/style.scss +104 -104
  88. package/src/components/table/style.scss +190 -190
  89. package/src/components/table/table.tsx +327 -322
  90. package/src/components/table/tags-table.tsx +348 -341
  91. package/src/constants/index.ts +93 -93
  92. package/src/constants/regex.ts +7 -7
  93. package/src/global.d.ts +13 -13
  94. package/src/helpers/layout.helper.ts +162 -162
  95. package/src/helpers/methodAccordion.helper.ts +19 -19
  96. package/src/index.ts +1 -1
  97. package/src/layout/layout.module.css +61 -61
  98. package/src/layout/layout.tsx +150 -150
  99. package/src/types/layout.type.ts +30 -30
  100. package/src/types/openApi.ts +108 -108
  101. package/src/types/transformedOpenApi.ts +52 -52
  102. package/src/validator/form.scheme.ts +70 -70
  103. package/tsconfig.json +33 -33
@@ -1,341 +1,348 @@
1
- import { useEffect, useState } from 'react'
2
- import './style.scss'
3
- import _styles from '../InfoForm/InfoForm.module.scss'
4
- import { Button, Input, TextArea } from 'digitinary-ui'
5
- import Tooltip from '../Tooltip/Tooltip'
6
- import SVGLoader from '../SVGLoader/SVGLoader'
7
- import { AddRow, EditIcon, DeleteIcon } from '../../assets/icons'
8
- import styles from '../MethodAccordion/MethodAccordion.module.scss'
9
- import { useFormik } from 'formik'
10
- import * as yup from 'yup'
11
- import regex from '../../constants/regex'
12
-
13
- const TagsTable = ({ id, headCells, data, isFormOpen, setIsFormOpen, saveNewRow, readOnly }) => {
14
- const [text, setText] = useState('')
15
- const [externalDesc, setExternalDesc] = useState('')
16
- const [externalUrl, setExternalUrl] = useState('')
17
- const [tooltipRef, setTooltipRef] = useState(null)
18
- const [externalTooltipRefs, setExternalTooltipRefs] = useState(null)
19
- const { values, errors, setFieldValue, isValid, submitForm, resetForm } = useFormik({
20
- validateOnMount: true,
21
- initialValues: {
22
- name: '',
23
- description: '',
24
- externalDocs: {
25
- url: '',
26
- description: '',
27
- },
28
- },
29
- validationSchema: yup.object().shape({
30
- name: yup.string().trim().required('Tag name is required'),
31
- description: yup.string().optional(),
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(),
47
- }),
48
- onSubmit: (values) => {
49
- saveNewRow(values)
50
- setText('')
51
- resetForm()
52
- setIsFormOpen(false)
53
- },
54
- validateOnChange: true,
55
- })
56
-
57
- return (
58
- <div className="tableSectionContainer">
59
- <div className="tableContainer">
60
- <table id={id || ''} className={`table borderRadiusTop borderRadiusBottom`}>
61
- <thead className="tableHead">
62
- <tr>
63
- {headCells?.map((headCell) => (
64
- <th
65
- key={headCell.id}
66
- className={`tableHeadCell ${headCell.classes || ''}`}
67
- style={{ width: headCell.width, minWidth: headCell.minWidth }}
68
- >
69
- <div
70
- className="headContainer"
71
- data-id={`${
72
- typeof headCell.label === 'string'
73
- ? headCell.label.toUpperCase().replace(/[^a-zA-Z0-9]+/g, '_')
74
- : 'UNKNOWN_LABEL'
75
- }_COLUMN`}
76
- >
77
- {headCell.label}
78
- </div>
79
- </th>
80
- ))}
81
- </tr>
82
- </thead>
83
- <tbody className="tableBody" data-id="TABLE_BODY">
84
- {data?.map((row, rowIndex) => {
85
- return (
86
- <tr key={rowIndex} data-i={rowIndex} className={`row`}>
87
- {headCells?.map((headCell) => {
88
- const cellContent = row[headCell.id] !== '_' && (
89
- <div
90
- data-id="TEXT_DESCRIPTION"
91
- className="tableData"
92
- style={{
93
- width: headCell.width,
94
- minWidth: headCell.minWidth,
95
- }}
96
- >
97
- {row[headCell.id]}
98
- </div>
99
- )
100
-
101
- return (
102
- <td
103
- key={headCell.id}
104
- style={{
105
- width: headCell.width,
106
- minWidth: headCell.minWidth,
107
- }}
108
- >
109
- {cellContent}
110
- </td>
111
- )
112
- })}
113
- </tr>
114
- )
115
- })}
116
- {isFormOpen ? (
117
- <tr key={''} data-i={''} className={`row`}>
118
- <td key={'tag name'}>
119
- <div data-id="TEXT_DESCRIPTION" className="tableData">
120
- <Input
121
- placeholder="Tag name"
122
- size="large"
123
- type="text"
124
- maxLength={25}
125
- onChange={(value) => {
126
- !regex.basic.test(value) && setFieldValue('name', value)
127
- }} // Pass the value directly
128
- value={values.name} // Bind value to the state
129
- disabled={readOnly}
130
- />
131
- </div>
132
- </td>
133
-
134
- <td key={'tagDescRequired'}>
135
- <div data-id="TEXT_DESCRIPTION" className="tableData">
136
- <div className={styles.paramDescContainer}>
137
- <Tooltip
138
- arrowWithBorder
139
- placement="bottom-end"
140
- type="function"
141
- trigger="click"
142
- delay={[0, 0]}
143
- onCreate={(instance) => setTooltipRef(instance)}
144
- onHidden={() => {
145
- setText(values.description)
146
- }}
147
- content={
148
- <div className={_styles.editDescTooltipContent}>
149
- <p className={_styles.editDescTooltipContent_header}>Description</p>
150
- <TextArea
151
- value={text || values.description}
152
- disabled={readOnly}
153
- maxLength={25}
154
- placeholder="Describe Tag..."
155
- onChange={(value) => {
156
- if (value === '' || regex.ASCII.test(value)) setText(value)
157
- }}
158
- />
159
- {!readOnly && (
160
- <Button
161
- className={_styles.editDescTooltipContent_btn}
162
- variant="outlined"
163
- size="small"
164
- onClick={() => {
165
- setFieldValue('description', text?.trim())
166
- tooltipRef?.hide()
167
- }}
168
- disabled={!(text || values.description)?.trim()}
169
- >
170
- Apply
171
- </Button>
172
- )}
173
- </div>
174
- }
175
- >
176
- <Button
177
- className={_styles.editDescBtn}
178
- style={{ paddingLeft: 0 }}
179
- variant="link"
180
- color="action"
181
- endIcon={<SVGLoader src={EditIcon} width="1.5rem" height="1.5rem" />}
182
- >
183
- {readOnly ? 'View ' : 'Add '} Description
184
- </Button>
185
- </Tooltip>
186
- </div>{' '}
187
- </div>
188
- </td>
189
- <td key={'tagExternal'}>
190
- <div className="tableData">
191
- <div className={_styles.paramDescContainer}>
192
- <Tooltip
193
- arrowWithBorder
194
- placement="bottom-end"
195
- type="function"
196
- trigger="click"
197
- delay={[0, 0]}
198
- onCreate={(instance) => setExternalTooltipRefs(instance)}
199
- onHidden={() => {
200
- setExternalDesc(values.externalDocs.description)
201
- setExternalUrl(values.externalDocs.url)
202
- }}
203
- content={
204
- <div className={_styles.editDescTooltipContent}>
205
- <p className={_styles.editDescTooltipContent_header}>
206
- External Docs Description
207
- </p>
208
- <TextArea
209
- placeholder="Describe External Doc..."
210
- value={externalDesc || values.externalDocs.description}
211
- disabled={readOnly}
212
- maxLength={25}
213
- onChange={(value) => {
214
- if (value === '' || regex.ASCII.test(value)) setExternalDesc(value)
215
- }}
216
- />
217
- <p className={_styles.editDescTooltipContent_header}>
218
- External Docs Link
219
- </p>
220
- <TextArea
221
- placeholder="External Docs Link..."
222
- value={externalUrl || values.externalDocs.url}
223
- disabled={readOnly}
224
- maxLength={200}
225
- onChange={(value) => {
226
- if (value === '' || regex.ASCII.test(value)) setExternalUrl(value)
227
- }}
228
- />
229
- {!readOnly && (
230
- <Button
231
- className={_styles.editDescTooltipContent_btn}
232
- variant="outlined"
233
- size="small"
234
- onClick={() => {
235
- setFieldValue(`externalDocs`, {
236
- description: externalDesc,
237
- url: externalUrl,
238
- })
239
-
240
- externalTooltipRefs?.hide()
241
- }}
242
- disabled={
243
- !(externalDesc || values.externalDocs.description)?.trim() ||
244
- !(externalUrl || values.externalDocs.url)?.trim() ||
245
- !regex.urlRegex.test(externalUrl || values.externalDocs.url)
246
- }
247
- >
248
- Apply
249
- </Button>
250
- )}
251
- </div>
252
- }
253
- >
254
- {readOnly ? (
255
- <a
256
- className={_styles.editDescBtn}
257
- variant="link"
258
- color="action"
259
- href={values.externalDocs?.url}
260
- target="_blank"
261
- >
262
- {values?.externalDocs?.description
263
- ? values?.externalDocs?.description?.substring(0, 12)
264
- : '-'}
265
- {values?.externalDocs?.description &&
266
- values?.externalDocs?.description?.length > 12
267
- ? '...'
268
- : ''}
269
- </a>
270
- ) : (
271
- <Button
272
- className={_styles.editDescBtn}
273
- variant="link"
274
- color="action"
275
- endIcon={<SVGLoader src={EditIcon} width="1.5rem" height="1.5rem" />}
276
- >
277
- {readOnly ? 'View ' : 'Add '} External Docs Link
278
- </Button>
279
- )}
280
- </Tooltip>
281
- <div className={_styles.paramDescContainer_separator}></div>
282
- {!readOnly && (
283
- <Button
284
- className={_styles.deleteParamBtn}
285
- variant="link"
286
- color="error"
287
- endIcon={
288
- <SVGLoader src={DeleteIcon} width="1.125rem" height="1.125rem" />
289
- }
290
- onClick={() => {
291
- resetForm()
292
- setText('')
293
- setIsFormOpen(false)
294
- }} // Correctly delete the new row
295
- />
296
- )}
297
-
298
- {!readOnly && (
299
- <Button
300
- className={_styles.deleteParamBtn}
301
- variant="link"
302
- color="success"
303
- disabled={!isValid}
304
- endIcon={<SVGLoader src={AddRow} width="0.125rem" height="0.125rem" />}
305
- onClick={() => {
306
- setText('')
307
- submitForm()
308
- }} // Save the new row when clicked
309
- />
310
- )}
311
- </div>
312
- </div>
313
- </td>
314
- </tr>
315
- ) : (
316
- <>
317
- {!readOnly && (
318
- <tr key={'addNew'} data-i={'addNew'} className={`row`}>
319
- <td colSpan={5}>
320
- <Button
321
- variant="link"
322
- color="primary"
323
- onClick={() => {
324
- setIsFormOpen((prev) => !prev)
325
- }}
326
- >
327
- + Add Tag
328
- </Button>
329
- </td>
330
- </tr>
331
- )}
332
- </>
333
- )}
334
- </tbody>
335
- </table>
336
- </div>
337
- </div>
338
- )
339
- }
340
-
341
- export default TagsTable
1
+ import { useEffect, useState } from 'react'
2
+ import './style.scss'
3
+ import _styles from '../InfoForm/InfoForm.module.scss'
4
+ import { Button, Input, TextArea } from 'digitinary-ui'
5
+ import Tooltip from '../Tooltip/Tooltip'
6
+ import SVGLoader from '../SVGLoader/SVGLoader'
7
+ import { AddRow, EditIcon, DeleteIcon } from '../../assets/icons'
8
+ import styles from '../MethodAccordion/MethodAccordion.module.scss'
9
+ import { useFormik } from 'formik'
10
+ import * as yup from 'yup'
11
+ import regex from '../../constants/regex'
12
+
13
+ const TagsTable = ({ id, headCells, data, isFormOpen, setIsFormOpen, saveNewRow, readOnly }) => {
14
+ const [text, setText] = useState('')
15
+ const [externalDesc, setExternalDesc] = useState('')
16
+ const [externalUrl, setExternalUrl] = useState('')
17
+ const [tooltipRef, setTooltipRef] = useState(null)
18
+ const [externalTooltipRefs, setExternalTooltipRefs] = useState(null)
19
+ const { values, errors, setFieldValue, isValid, submitForm, resetForm } = useFormik({
20
+ validateOnMount: true,
21
+ initialValues: {
22
+ name: '',
23
+ description: '',
24
+ externalDocs: {
25
+ url: '',
26
+ description: '',
27
+ },
28
+ },
29
+ validationSchema: yup.object().shape({
30
+ name: yup.string().trim().required('Tag name is required'),
31
+ description: yup.string().optional(),
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(),
47
+ }),
48
+ onSubmit: (values) => {
49
+ saveNewRow(values)
50
+ setText('')
51
+ resetForm()
52
+ setIsFormOpen(false)
53
+ },
54
+ validateOnChange: true,
55
+ })
56
+
57
+ return (
58
+ <div className="tableSectionContainer">
59
+ <div className="tableContainer">
60
+ <table id={id || ''} className={`table borderRadiusTop borderRadiusBottom`}>
61
+ <thead className="tableHead">
62
+ <tr>
63
+ {headCells?.map((headCell) => (
64
+ <th
65
+ key={headCell.id}
66
+ className={`tableHeadCell ${headCell.classes || ''}`}
67
+ style={{ width: headCell.width, minWidth: headCell.minWidth }}
68
+ >
69
+ <div
70
+ className="headContainer"
71
+ data-id={`${
72
+ typeof headCell.label === 'string'
73
+ ? headCell.label.toUpperCase().replace(/[^a-zA-Z0-9]+/g, '_')
74
+ : 'UNKNOWN_LABEL'
75
+ }_COLUMN`}
76
+ >
77
+ {headCell.label}
78
+ </div>
79
+ </th>
80
+ ))}
81
+ </tr>
82
+ </thead>
83
+ <tbody className="tableBody" data-id="TABLE_BODY">
84
+ {data?.map((row, rowIndex) => {
85
+ return (
86
+ <tr key={rowIndex} data-i={rowIndex} className={`row`}>
87
+ {headCells?.map((headCell) => {
88
+ const cellContent = row[headCell.id] !== '_' && (
89
+ <div
90
+ data-id="TEXT_DESCRIPTION"
91
+ className="tableData"
92
+ style={{
93
+ width: headCell.width,
94
+ minWidth: headCell.minWidth,
95
+ }}
96
+ >
97
+ {row[headCell.id]}
98
+ </div>
99
+ )
100
+
101
+ return (
102
+ <td
103
+ key={headCell.id}
104
+ style={{
105
+ width: headCell.width,
106
+ minWidth: headCell.minWidth,
107
+ }}
108
+ >
109
+ {cellContent}
110
+ </td>
111
+ )
112
+ })}
113
+ </tr>
114
+ )
115
+ })}
116
+ {isFormOpen ? (
117
+ <tr key={''} data-i={''} className={`row`}>
118
+ <td key={'tag name'}>
119
+ <div data-id="TEXT_DESCRIPTION" className="tableData">
120
+ <Input
121
+ placeholder="Tag name"
122
+ size="large"
123
+ type="text"
124
+ maxLength={25}
125
+ onChange={(value) => {
126
+ !regex.basic.test(value) && setFieldValue('name', value)
127
+ }} // Pass the value directly
128
+ value={values.name} // Bind value to the state
129
+ disabled={readOnly}
130
+ />
131
+ </div>
132
+ </td>
133
+
134
+ <td key={'tagDescRequired'}>
135
+ <div data-id="TEXT_DESCRIPTION" className="tableData">
136
+ <div className={styles.paramDescContainer}>
137
+ <Tooltip
138
+ arrowWithBorder
139
+ placement="bottom-end"
140
+ type="function"
141
+ trigger="click"
142
+ delay={[0, 0]}
143
+ onCreate={(instance) => setTooltipRef(instance)}
144
+ onShow={() => {
145
+ setText(values.description || '') // Reset to current value when shown
146
+ }}
147
+ onHidden={() => {
148
+ setText(values.description || '') // Reset on close
149
+ }}
150
+ content={
151
+ <div className={_styles.editDescTooltipContent}>
152
+ <p className={_styles.editDescTooltipContent_header}>Description</p>
153
+ <TextArea
154
+ value={text || values.description}
155
+ disabled={readOnly}
156
+ maxLength={25}
157
+ placeholder="Describe Tag..."
158
+ onChange={(value) => {
159
+ if (value === '' || regex.ASCII.test(value)) setText(value)
160
+ }}
161
+ />
162
+ {!readOnly && (
163
+ <Button
164
+ className={_styles.editDescTooltipContent_btn}
165
+ variant="outlined"
166
+ size="small"
167
+ onClick={() => {
168
+ setFieldValue('description', text?.trim())
169
+ tooltipRef?.hide()
170
+ }}
171
+ disabled={!(text || values.description)?.trim()}
172
+ >
173
+ Apply
174
+ </Button>
175
+ )}
176
+ </div>
177
+ }
178
+ >
179
+ <Button
180
+ className={_styles.editDescBtn}
181
+ style={{ paddingLeft: 0 }}
182
+ variant="link"
183
+ color="action"
184
+ endIcon={<SVGLoader src={EditIcon} width="1.5rem" height="1.5rem" />}
185
+ >
186
+ {readOnly ? 'View ' : 'Add '} Description
187
+ </Button>
188
+ </Tooltip>
189
+ </div>{' '}
190
+ </div>
191
+ </td>
192
+ <td key={'tagExternal'}>
193
+ <div className="tableData">
194
+ <div className={_styles.paramDescContainer}>
195
+ <Tooltip
196
+ arrowWithBorder
197
+ placement="bottom-end"
198
+ type="function"
199
+ trigger="click"
200
+ delay={[0, 0]}
201
+ onCreate={(instance) => setExternalTooltipRefs(instance)}
202
+ onShow={() => {
203
+ setExternalDesc(values.externalDocs.description || '')
204
+ setExternalUrl(values.externalDocs.url || '')
205
+ }}
206
+ onHidden={() => {
207
+ setExternalDesc(values.externalDocs.description || '')
208
+ setExternalUrl(values.externalDocs.url || '')
209
+ }}
210
+ content={
211
+ <div className={_styles.editDescTooltipContent}>
212
+ <p className={_styles.editDescTooltipContent_header}>
213
+ External Docs Description
214
+ </p>
215
+ <TextArea
216
+ placeholder="Describe External Doc..."
217
+ value={externalDesc || values.externalDocs.description}
218
+ disabled={readOnly}
219
+ maxLength={25}
220
+ onChange={(value) => {
221
+ if (value === '' || regex.ASCII.test(value)) setExternalDesc(value)
222
+ }}
223
+ />
224
+ <p className={_styles.editDescTooltipContent_header}>
225
+ External Docs Link
226
+ </p>
227
+ <TextArea
228
+ placeholder="External Docs Link..."
229
+ value={externalUrl || values.externalDocs.url}
230
+ disabled={readOnly}
231
+ maxLength={200}
232
+ onChange={(value) => {
233
+ if (value === '' || regex.ASCII.test(value)) setExternalUrl(value)
234
+ }}
235
+ />
236
+ {!readOnly && (
237
+ <Button
238
+ className={_styles.editDescTooltipContent_btn}
239
+ variant="outlined"
240
+ size="small"
241
+ onClick={() => {
242
+ setFieldValue(`externalDocs`, {
243
+ description: externalDesc,
244
+ url: externalUrl,
245
+ })
246
+
247
+ externalTooltipRefs?.hide()
248
+ }}
249
+ disabled={
250
+ !(externalDesc || values.externalDocs.description)?.trim() ||
251
+ !(externalUrl || values.externalDocs.url)?.trim() ||
252
+ !regex.urlRegex.test(externalUrl || values.externalDocs.url)
253
+ }
254
+ >
255
+ Apply
256
+ </Button>
257
+ )}
258
+ </div>
259
+ }
260
+ >
261
+ {readOnly ? (
262
+ <a
263
+ className={_styles.editDescBtn}
264
+ variant="link"
265
+ color="action"
266
+ href={values.externalDocs?.url}
267
+ target="_blank"
268
+ >
269
+ {values?.externalDocs?.description
270
+ ? values?.externalDocs?.description?.substring(0, 12)
271
+ : '-'}
272
+ {values?.externalDocs?.description &&
273
+ values?.externalDocs?.description?.length > 12
274
+ ? '...'
275
+ : ''}
276
+ </a>
277
+ ) : (
278
+ <Button
279
+ className={_styles.editDescBtn}
280
+ variant="link"
281
+ color="action"
282
+ endIcon={<SVGLoader src={EditIcon} width="1.5rem" height="1.5rem" />}
283
+ >
284
+ {readOnly ? 'View ' : 'Add '} External Docs Link
285
+ </Button>
286
+ )}
287
+ </Tooltip>
288
+ <div className={_styles.paramDescContainer_separator}></div>
289
+ {!readOnly && (
290
+ <Button
291
+ className={_styles.deleteParamBtn}
292
+ variant="link"
293
+ color="error"
294
+ endIcon={
295
+ <SVGLoader src={DeleteIcon} width="1.125rem" height="1.125rem" />
296
+ }
297
+ onClick={() => {
298
+ resetForm()
299
+ setText('')
300
+ setIsFormOpen(false)
301
+ }} // Correctly delete the new row
302
+ />
303
+ )}
304
+
305
+ {!readOnly && (
306
+ <Button
307
+ className={_styles.deleteParamBtn}
308
+ variant="link"
309
+ color="success"
310
+ disabled={!isValid}
311
+ endIcon={<SVGLoader src={AddRow} width="0.125rem" height="0.125rem" />}
312
+ onClick={() => {
313
+ setText('')
314
+ submitForm()
315
+ }} // Save the new row when clicked
316
+ />
317
+ )}
318
+ </div>
319
+ </div>
320
+ </td>
321
+ </tr>
322
+ ) : (
323
+ <>
324
+ {!readOnly && (
325
+ <tr key={'addNew'} data-i={'addNew'} className={`row`}>
326
+ <td colSpan={5}>
327
+ <Button
328
+ variant="link"
329
+ color="primary"
330
+ onClick={() => {
331
+ setIsFormOpen((prev) => !prev)
332
+ }}
333
+ >
334
+ + Add Tag
335
+ </Button>
336
+ </td>
337
+ </tr>
338
+ )}
339
+ </>
340
+ )}
341
+ </tbody>
342
+ </table>
343
+ </div>
344
+ </div>
345
+ )
346
+ }
347
+
348
+ export default TagsTable