@knovator/pagecreator-admin 1.2.6 → 1.2.8

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 (166) hide show
  1. package/index.d.ts +1 -0
  2. package/package.json +38 -42
  3. package/src/{index.d.ts → index.ts} +1 -0
  4. package/src/lib/api/index.ts +70 -0
  5. package/src/lib/api/list.ts +59 -0
  6. package/src/lib/components/Page/AddButton/AddButton.tsx +16 -0
  7. package/src/lib/components/Page/AddButton/{index.d.ts → index.ts} +1 -0
  8. package/src/lib/components/Page/Form/PageForm.tsx +194 -0
  9. package/src/lib/components/Page/Form/{index.d.ts → index.ts} +1 -0
  10. package/src/lib/components/Page/Page/Page.tsx +151 -0
  11. package/src/lib/components/Page/Page/{index.d.ts → index.ts} +1 -0
  12. package/src/lib/components/Page/PageFormActions/PageFormActions.tsx +50 -0
  13. package/src/lib/components/Page/PageFormActions/{index.d.ts → index.ts} +1 -0
  14. package/src/lib/components/Page/PageFormWrapper/PageFormWrapper.tsx +16 -0
  15. package/src/lib/components/Page/PageFormWrapper/{index.d.ts → index.ts} +1 -0
  16. package/src/lib/components/Page/Pagination/PagePagination.tsx +26 -0
  17. package/src/lib/components/Page/Pagination/{index.d.ts → index.ts} +1 -0
  18. package/src/lib/components/Page/Search/PageSearch.tsx +32 -0
  19. package/src/lib/components/Page/Search/{index.d.ts → index.tsx} +1 -0
  20. package/src/lib/components/Page/Table/PageTable.tsx +36 -0
  21. package/src/lib/components/Page/Table/{index.d.ts → index.ts} +1 -0
  22. package/src/lib/components/Page/{index.d.ts → index.ts} +1 -0
  23. package/src/lib/components/Widget/AddButton/AddButton.tsx +16 -0
  24. package/src/lib/components/Widget/AddButton/{index.d.ts → index.ts} +1 -0
  25. package/src/lib/components/Widget/Form/ItemsAccordian.tsx +354 -0
  26. package/src/lib/components/Widget/Form/Tabs/TabItem.tsx +43 -0
  27. package/src/lib/components/Widget/Form/Tabs/Tabs.tsx +190 -0
  28. package/src/lib/components/Widget/Form/Tabs/{index.d.ts → index.ts} +1 -0
  29. package/src/lib/components/Widget/Form/WidgetForm.tsx +771 -0
  30. package/src/lib/components/Widget/Form/{index.d.ts → index.ts} +1 -0
  31. package/src/lib/components/Widget/Pagination/WidgetPagination.tsx +26 -0
  32. package/src/lib/components/Widget/Pagination/{index.d.ts → index.ts} +1 -0
  33. package/src/lib/components/Widget/Search/WidgetSearch.tsx +32 -0
  34. package/src/lib/components/Widget/Search/{index.d.ts → index.tsx} +1 -0
  35. package/src/lib/components/Widget/Table/WidgetTable.tsx +70 -0
  36. package/src/lib/components/Widget/Table/{index.d.ts → index.ts} +1 -0
  37. package/src/lib/components/Widget/Widget/Widget.tsx +173 -0
  38. package/src/lib/components/Widget/Widget/{index.d.ts → index.ts} +1 -0
  39. package/src/lib/components/Widget/WidgetFormActions/WidgetFormActions.tsx +50 -0
  40. package/src/lib/components/Widget/WidgetFormActions/{index.d.ts → index.ts} +1 -0
  41. package/src/lib/components/Widget/WidgetFormWrapper/WidgetFormWrapper.tsx +16 -0
  42. package/src/lib/components/Widget/WidgetFormWrapper/{index.d.ts → index.ts} +1 -0
  43. package/src/lib/components/Widget/{index.d.ts → index.tsx} +1 -0
  44. package/src/lib/components/common/Accordian/Accordian.tsx +56 -0
  45. package/src/lib/components/common/Accordian/{index.d.ts → index.ts} +1 -0
  46. package/src/lib/components/common/Button/Button.tsx +45 -0
  47. package/src/lib/components/common/Button/{index.d.ts → index.ts} +1 -0
  48. package/src/lib/components/common/ConfirmPopover/ConfirmPopover.tsx +47 -0
  49. package/src/lib/components/common/ConfirmPopover/{index.d.ts → index.ts} +1 -0
  50. package/src/lib/components/common/DNDItemsList/DNDItemsList.tsx +77 -0
  51. package/src/lib/components/common/DNDItemsList/{index.d.ts → index.ts} +1 -0
  52. package/src/lib/components/common/DeleteModal/DeleteModal.tsx +72 -0
  53. package/src/lib/components/common/DeleteModal/index.tsx +3 -0
  54. package/src/lib/components/common/Drawer/Drawer.tsx +79 -0
  55. package/src/lib/components/common/Drawer/{index.d.ts → index.ts} +1 -0
  56. package/src/lib/components/common/Form/Form.tsx +256 -0
  57. package/src/lib/components/common/Form/SimpleForm.tsx +314 -0
  58. package/src/lib/components/common/Form/{index.d.ts → index.ts} +1 -0
  59. package/src/lib/components/common/FormActions/FormActions.tsx +37 -0
  60. package/src/lib/components/common/FormActions/{index.d.ts → index.ts} +1 -0
  61. package/src/lib/components/common/ImageUpload/ImageUpload.tsx +113 -0
  62. package/src/lib/components/common/ImageUpload/index.tsx +3 -0
  63. package/src/lib/components/common/Input/Checkbox.tsx +25 -0
  64. package/src/lib/components/common/Input/Input.tsx +51 -0
  65. package/src/lib/components/common/Input/ReactSelect.tsx +61 -0
  66. package/src/lib/components/common/Input/Select.tsx +47 -0
  67. package/src/lib/components/common/Input/SrcSet.tsx +143 -0
  68. package/src/lib/components/common/Input/index.ts +20 -0
  69. package/src/lib/components/common/Modal/Modal.tsx +57 -0
  70. package/src/lib/components/common/Modal/index.tsx +3 -0
  71. package/src/lib/components/common/Pagination/Pagination.tsx +88 -0
  72. package/src/lib/components/common/Pagination/{index.d.ts → index.ts} +1 -0
  73. package/src/lib/components/common/Table/Table.tsx +133 -0
  74. package/src/lib/components/common/Table/{index.d.ts → index.ts} +1 -0
  75. package/src/lib/components/common/Toggle/Toggle.tsx +23 -0
  76. package/src/lib/components/common/Toggle/{index.d.ts → index.ts} +1 -0
  77. package/src/lib/constants/common.ts +145 -0
  78. package/src/lib/context/PageContext.tsx +100 -0
  79. package/src/lib/context/ProviderContext.tsx +52 -0
  80. package/src/lib/context/WidgetContext.tsx +127 -0
  81. package/src/lib/helper/utils.ts +46 -0
  82. package/src/lib/hooks/usePage.tsx +306 -0
  83. package/src/lib/hooks/usePagination.tsx +41 -0
  84. package/src/lib/hooks/useWidget.tsx +503 -0
  85. package/src/lib/icons/chevronDown.tsx +21 -0
  86. package/src/lib/icons/chevronLeft.tsx +20 -0
  87. package/src/lib/icons/chevronRight.tsx +20 -0
  88. package/src/lib/icons/chevronUp.tsx +21 -0
  89. package/src/lib/icons/close.tsx +21 -0
  90. package/src/lib/icons/pencil.tsx +21 -0
  91. package/src/lib/icons/plus.tsx +23 -0
  92. package/src/lib/icons/settings.tsx +35 -0
  93. package/src/lib/icons/trash.tsx +21 -0
  94. package/src/lib/types/api.ts +44 -0
  95. package/src/lib/types/common.ts +31 -0
  96. package/src/lib/types/components.ts +428 -0
  97. package/src/lib/types/context.ts +184 -0
  98. package/src/styles/index.css +481 -0
  99. package/index.cjs +0 -7714
  100. package/index.css +0 -2
  101. package/index.js +0 -7700
  102. package/src/lib/api/index.d.ts +0 -10
  103. package/src/lib/api/list.d.ts +0 -56
  104. package/src/lib/components/Page/AddButton/AddButton.d.ts +0 -3
  105. package/src/lib/components/Page/Form/PageForm.d.ts +0 -4
  106. package/src/lib/components/Page/Page/Page.d.ts +0 -13
  107. package/src/lib/components/Page/PageFormActions/PageFormActions.d.ts +0 -4
  108. package/src/lib/components/Page/PageFormWrapper/PageFormWrapper.d.ts +0 -4
  109. package/src/lib/components/Page/Pagination/PagePagination.d.ts +0 -3
  110. package/src/lib/components/Page/Search/PageSearch.d.ts +0 -3
  111. package/src/lib/components/Page/Table/PageTable.d.ts +0 -4
  112. package/src/lib/components/Widget/AddButton/AddButton.d.ts +0 -3
  113. package/src/lib/components/Widget/Form/ItemsAccordian.d.ts +0 -4
  114. package/src/lib/components/Widget/Form/Tabs/TabItem.d.ts +0 -4
  115. package/src/lib/components/Widget/Form/Tabs/Tabs.d.ts +0 -4
  116. package/src/lib/components/Widget/Form/WidgetForm.d.ts +0 -4
  117. package/src/lib/components/Widget/Pagination/WidgetPagination.d.ts +0 -3
  118. package/src/lib/components/Widget/Search/WidgetSearch.d.ts +0 -3
  119. package/src/lib/components/Widget/Table/WidgetTable.d.ts +0 -4
  120. package/src/lib/components/Widget/Widget/Widget.d.ts +0 -13
  121. package/src/lib/components/Widget/WidgetFormActions/WidgetFormActions.d.ts +0 -4
  122. package/src/lib/components/Widget/WidgetFormWrapper/WidgetFormWrapper.d.ts +0 -4
  123. package/src/lib/components/common/Accordian/Accordian.d.ts +0 -13
  124. package/src/lib/components/common/Button/Button.d.ts +0 -4
  125. package/src/lib/components/common/ConfirmPopover/ConfirmPopover.d.ts +0 -4
  126. package/src/lib/components/common/DNDItemsList/DNDItemsList.d.ts +0 -4
  127. package/src/lib/components/common/DeleteModal/DeleteModal.d.ts +0 -4
  128. package/src/lib/components/common/DeleteModal/index.d.ts +0 -2
  129. package/src/lib/components/common/Drawer/Drawer.d.ts +0 -9
  130. package/src/lib/components/common/Form/Form.d.ts +0 -15
  131. package/src/lib/components/common/Form/SimpleForm.d.ts +0 -18
  132. package/src/lib/components/common/FormActions/FormActions.d.ts +0 -10
  133. package/src/lib/components/common/ImageUpload/ImageUpload.d.ts +0 -4
  134. package/src/lib/components/common/ImageUpload/index.d.ts +0 -2
  135. package/src/lib/components/common/Input/Checkbox.d.ts +0 -4
  136. package/src/lib/components/common/Input/Input.d.ts +0 -4
  137. package/src/lib/components/common/Input/ReactSelect.d.ts +0 -4
  138. package/src/lib/components/common/Input/Select.d.ts +0 -4
  139. package/src/lib/components/common/Input/SrcSet.d.ts +0 -4
  140. package/src/lib/components/common/Input/index.d.ts +0 -12
  141. package/src/lib/components/common/Modal/Modal.d.ts +0 -8
  142. package/src/lib/components/common/Modal/index.d.ts +0 -2
  143. package/src/lib/components/common/Pagination/Pagination.d.ts +0 -4
  144. package/src/lib/components/common/Table/Table.d.ts +0 -4
  145. package/src/lib/components/common/Toggle/Toggle.d.ts +0 -4
  146. package/src/lib/constants/common.d.ts +0 -122
  147. package/src/lib/context/PageContext.d.ts +0 -7
  148. package/src/lib/context/ProviderContext.d.ts +0 -5
  149. package/src/lib/context/WidgetContext.d.ts +0 -7
  150. package/src/lib/helper/utils.d.ts +0 -10
  151. package/src/lib/hooks/usePage.d.ts +0 -43
  152. package/src/lib/hooks/usePagination.d.ts +0 -15
  153. package/src/lib/hooks/useWidget.d.ts +0 -46
  154. package/src/lib/icons/chevronDown.d.ts +0 -4
  155. package/src/lib/icons/chevronLeft.d.ts +0 -4
  156. package/src/lib/icons/chevronRight.d.ts +0 -4
  157. package/src/lib/icons/chevronUp.d.ts +0 -4
  158. package/src/lib/icons/close.d.ts +0 -4
  159. package/src/lib/icons/pencil.d.ts +0 -4
  160. package/src/lib/icons/plus.d.ts +0 -4
  161. package/src/lib/icons/trash.d.ts +0 -4
  162. package/src/lib/types/api.d.ts +0 -34
  163. package/src/lib/types/common.d.ts +0 -29
  164. package/src/lib/types/components.d.ts +0 -420
  165. package/src/lib/types/context.d.ts +0 -135
  166. /package/src/lib/types/{index.d.ts → index.ts} +0 -0
@@ -0,0 +1,26 @@
1
+ import React from "react";
2
+ import { usePageState } from "../../../context/PageContext";
3
+ import Pagination from "../../common/Pagination";
4
+ import { useProviderState } from '../../../context/ProviderContext';
5
+
6
+ const PagePagination = () => {
7
+ const { commonTranslations } = useProviderState();
8
+ const { totalPages, totalRecords, currentPage, pageSize, setCurrentPage } =
9
+ usePageState();
10
+ return (
11
+ <Pagination
12
+ ofText={commonTranslations.of}
13
+ pageText={commonTranslations.confirm}
14
+ showingText={commonTranslations.showing}
15
+ nextContent={commonTranslations.next}
16
+ previousContent={commonTranslations.previous}
17
+ totalPages={totalPages}
18
+ totalRecords={totalRecords}
19
+ currentPage={currentPage}
20
+ pageSize={pageSize}
21
+ setCurrentPage={setCurrentPage}
22
+ />
23
+ );
24
+ };
25
+
26
+ export default PagePagination;
@@ -1,2 +1,3 @@
1
1
  import PagePagination from "./PagePagination";
2
+
2
3
  export default PagePagination;
@@ -0,0 +1,32 @@
1
+ import React, { useRef, useState } from "react";
2
+ import Input from "../../common/Input";
3
+ import { usePageState } from "../../../context/PageContext";
4
+
5
+ const PageSearch = () => {
6
+ const { pageTranslations, canList, changeSearch, setCurrentPage } =
7
+ usePageState();
8
+ const callerRef = useRef<NodeJS.Timeout | null>(null);
9
+ const [search, setSearch] = useState<string>('');
10
+
11
+ const onChangeSearch = (str: string) => {
12
+ setSearch(str);
13
+ changeSearch(str);
14
+ if (callerRef.current) clearTimeout(callerRef.current);
15
+
16
+ callerRef.current = setTimeout(() => {
17
+ setCurrentPage(1);
18
+ }, 300);
19
+ };
20
+
21
+ return (
22
+ <Input
23
+ type="search"
24
+ value={search}
25
+ disabled={!canList}
26
+ onChange={(e) => onChangeSearch(e.target.value)}
27
+ placeholder={pageTranslations.searchPages}
28
+ />
29
+ );
30
+ };
31
+
32
+ export default PageSearch;
@@ -1,2 +1,3 @@
1
1
  import PageSearch from "./PageSearch";
2
+
2
3
  export default PageSearch;
@@ -0,0 +1,36 @@
1
+ import React from 'react';
2
+ import Table from '../../common/Table';
3
+ import { usePageState } from '../../../context/PageContext';
4
+ import { useProviderState } from '../../../context/ProviderContext';
5
+ import { CombineObjectType, DerivedTableProps } from '../../../types';
6
+
7
+ const PageTable = ({ extraActions, extraColumns }: DerivedTableProps) => {
8
+ const { commonTranslations } = useProviderState();
9
+ const { list, onChangeFormState, loading, loader, canUpdate, canDelete } =
10
+ usePageState();
11
+
12
+ const onUpdateClick = (item: CombineObjectType) =>
13
+ onChangeFormState('UPDATE', item);
14
+ const onDeleteClick = (item: CombineObjectType) =>
15
+ onChangeFormState('DELETE', item);
16
+
17
+ return (
18
+ <Table
19
+ data={list}
20
+ loader={loader}
21
+ loading={loading}
22
+ dataKeys={[
23
+ { label: commonTranslations.name, dataKey: 'name', highlight: true },
24
+ { label: commonTranslations.code, dataKey: 'code' },
25
+ ]}
26
+ actionsLabel={commonTranslations.actions}
27
+ actions={{
28
+ edit: canUpdate ? onUpdateClick : undefined,
29
+ delete: canDelete ? onDeleteClick : undefined,
30
+ }}
31
+ extraColumns={extraColumns}
32
+ extraActions={extraActions}
33
+ />
34
+ );
35
+ };
36
+ export default PageTable;
@@ -1,2 +1,3 @@
1
1
  import PageTable from "./PageTable";
2
+
2
3
  export default PageTable;
@@ -1,2 +1,3 @@
1
1
  import Page from "./Page";
2
+
2
3
  export { Page };
@@ -0,0 +1,16 @@
1
+ import React from "react";
2
+ import Button from "../../common/Button";
3
+ import { useWidgetState } from "../../../context/WidgetContext";
4
+ import { useProviderState } from '../../../context/ProviderContext';
5
+
6
+ const AddButton = () => {
7
+ const { commonTranslations } = useProviderState();
8
+ const { onChangeFormState, canAdd } = useWidgetState();
9
+ return (
10
+ <Button disabled={!canAdd} onClick={() => onChangeFormState('ADD')}>
11
+ {commonTranslations.add}
12
+ </Button>
13
+ );
14
+ };
15
+
16
+ export default AddButton;
@@ -1,2 +1,3 @@
1
1
  import AddButton from "./AddButton";
2
+
2
3
  export default AddButton;
@@ -0,0 +1,354 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import { Controller, useFieldArray } from 'react-hook-form';
3
+
4
+ import Input from '../../common/Input';
5
+ import Button from '../../common/Button';
6
+ import Accordian from '../../common/Accordian';
7
+ import ImageUpload from '../../common/ImageUpload';
8
+ import { ItemsAccordianProps } from '../../../types';
9
+ import ConfirmPopover from '../../common/ConfirmPopover';
10
+ import { useWidgetState } from '../../../context/WidgetContext';
11
+ import { useProviderState } from '../../../context/ProviderContext';
12
+
13
+ interface ImageInputProps {
14
+ label: string;
15
+ control: any;
16
+ name: string;
17
+ error: any;
18
+ baseUrl: string;
19
+ imageMaxSize: number;
20
+ onImageUpload: (file: File) => Promise<void | {
21
+ fileUrl: string;
22
+ fileId: string;
23
+ fileUri: string;
24
+ }>;
25
+ text: string | JSX.Element;
26
+ onImageRemove: (fileId: string) => Promise<void>;
27
+ setError: (name: string, error: any) => void;
28
+ clearError: (name: string) => void;
29
+ }
30
+
31
+ const ImageInput = ({
32
+ label,
33
+ control,
34
+ name,
35
+ text,
36
+ error,
37
+ baseUrl,
38
+ setError,
39
+ clearError,
40
+ onImageRemove,
41
+ imageMaxSize,
42
+ onImageUpload,
43
+ }: ImageInputProps) => {
44
+ return (
45
+ <div className="kms_input-wrapper">
46
+ <label className="kms_input-label">{label}</label>
47
+ <Controller
48
+ control={control}
49
+ name={name}
50
+ render={({ field }) => (
51
+ <ImageUpload
52
+ imgId={field.value}
53
+ clearError={() => clearError(name)}
54
+ maxSize={imageMaxSize}
55
+ onError={(msg) =>
56
+ setError(name, {
57
+ type: 'custom',
58
+ message: msg,
59
+ })
60
+ }
61
+ error={error}
62
+ setImgId={(value) => {
63
+ field.onChange(value);
64
+ }}
65
+ baseUrl={baseUrl}
66
+ text={text}
67
+ onImageUpload={onImageUpload}
68
+ onImageRemove={onImageRemove}
69
+ className="khb_img-upload-wrapper-3"
70
+ />
71
+ )}
72
+ />
73
+ </div>
74
+ );
75
+ };
76
+
77
+ const ItemsAccordian = ({
78
+ show,
79
+ title,
80
+ id,
81
+ collapseId,
82
+ toggleShow,
83
+ loading,
84
+ name,
85
+ errors,
86
+ control,
87
+ register,
88
+ setError,
89
+ itemType,
90
+ languages,
91
+ clearError,
92
+ addText = 'Add',
93
+ deleteText = 'Delete',
94
+ }: ItemsAccordianProps) => {
95
+ const { baseUrl, commonTranslations } = useProviderState();
96
+ const {
97
+ onImageUpload,
98
+ onImageRemove,
99
+ imageBaseUrl,
100
+ imageMaxSize,
101
+ widgetTranslations,
102
+ } = useWidgetState();
103
+ const [itemsShow, setItemsShow] = useState<boolean[]>([]);
104
+ const {
105
+ fields: items,
106
+ append: appendItem,
107
+ remove: removeItem,
108
+ } = useFieldArray({ name, control });
109
+
110
+ const onItemsToggleClick = (index: number, status?: boolean) => {
111
+ const newItemsShow: boolean[] = [...itemsShow];
112
+ const newStatus = errors?.[name]?.[index]
113
+ ? true
114
+ : typeof status === 'undefined'
115
+ ? !newItemsShow[index]
116
+ : status;
117
+ newItemsShow[index] = newStatus;
118
+ setItemsShow(newItemsShow);
119
+ };
120
+
121
+ useEffect(() => {
122
+ if (errors && errors?.[name]?.length > 0) {
123
+ errors?.[name]?.forEach((errorItem: any, index: number) => {
124
+ if (errorItem) onItemsToggleClick(index, true);
125
+ });
126
+ }
127
+ // eslint-disable-next-line react-hooks/exhaustive-deps
128
+ }, [errors, name, errors?.[name]]);
129
+
130
+ const addTab = (index: number) => {
131
+ appendItem({
132
+ altText: '',
133
+ link: '',
134
+ img: '',
135
+ srcset: [],
136
+ itemType,
137
+ sequence: index,
138
+ });
139
+ };
140
+
141
+ return (
142
+ <Accordian
143
+ open={show}
144
+ onToggle={() => toggleShow(!show)}
145
+ title={title}
146
+ collapseId={collapseId}
147
+ id={id}
148
+ footerContent={
149
+ <Button
150
+ size="sm"
151
+ disabled={loading}
152
+ onClick={() => addTab(items.length)}
153
+ >
154
+ {addText}
155
+ </Button>
156
+ }
157
+ >
158
+ <div className="khb_item-items">
159
+ {items?.map((field, index) => (
160
+ <Accordian
161
+ key={index}
162
+ open={itemsShow[index]}
163
+ onToggle={() => onItemsToggleClick(index)}
164
+ title={`Item ${index + 1}`}
165
+ collapseId={`${id}-item-content-${index}`}
166
+ id={`${id}-item-${index}`}
167
+ footerContent={
168
+ <ConfirmPopover
169
+ onConfirm={() => removeItem(index)}
170
+ title={widgetTranslations.deleteTitle}
171
+ confirmText={commonTranslations.yes}
172
+ cancelText={commonTranslations.cancel}
173
+ >
174
+ <Button type="danger" size="sm" disabled={loading}>
175
+ {deleteText}
176
+ </Button>
177
+ </ConfirmPopover>
178
+ }
179
+ >
180
+ <div className="khb-form-items">
181
+ {Array.isArray(languages) && languages.length > 0 ? (
182
+ <>
183
+ {languages.map((lang) => (
184
+ <Input
185
+ rest={register(`${name}.${index}.titles.${lang.code}`)}
186
+ label={commonTranslations.title + ` (${lang.name})`}
187
+ error={
188
+ errors[name]?.[index]?.['titles']?.[lang.code]
189
+ ? errors[name]?.[index]?.['titles']?.[
190
+ lang.code
191
+ ]?.message?.toString() + ` (${lang.name})`
192
+ : ''
193
+ }
194
+ type="text"
195
+ className="w-full p-2"
196
+ placeholder={
197
+ commonTranslations.titlePlaceholder + ` (${lang.name})`
198
+ }
199
+
200
+ />
201
+ ))}
202
+ </>
203
+ ) : (
204
+ <Input
205
+ rest={register(`${name}.${index}.title`)}
206
+ label={commonTranslations.title}
207
+ error={errors[name]?.[index]?.['title']?.message?.toString()}
208
+ type="text"
209
+ className="w-full p-2"
210
+ placeholder={commonTranslations.titlePlaceholder}
211
+
212
+ />
213
+ )}
214
+ {Array.isArray(languages) && languages.length > 0 ? (
215
+ <>
216
+ {languages.map((lang) => (
217
+ <Input
218
+ rest={register(`${name}.${index}.subtitles.${lang.code}`)}
219
+ label={widgetTranslations.subtitle + ` (${lang.name})`}
220
+ type="text"
221
+ className="w-full p-2"
222
+ placeholder={
223
+ widgetTranslations.subTitlePlaceholder +
224
+ ` (${lang.name})`
225
+ }
226
+ />
227
+ ))}
228
+ </>
229
+ ) : (
230
+ <Input
231
+ rest={register(`${name}.${index}.subtitle`)}
232
+ label={widgetTranslations.subtitle}
233
+ type="text"
234
+ className="w-full p-2"
235
+ placeholder={widgetTranslations.subTitlePlaceholder}
236
+ />
237
+ )}
238
+ {Array.isArray(languages) && languages.length > 0 ? (
239
+ <>
240
+ {languages.map((lang) => (
241
+ <Input
242
+ rest={register(`${name}.${index}.altTexts.${lang.code}`)}
243
+ label={widgetTranslations.altText + ` (${lang.name})`}
244
+ type="text"
245
+ className="w-full p-2"
246
+ placeholder={
247
+ widgetTranslations.altTextPlaceholder +
248
+ ` (${lang.name})`
249
+ }
250
+ />
251
+ ))}
252
+ </>
253
+ ) : (
254
+ <Input
255
+ rest={register(`${name}.${index}.altText`)}
256
+ label={widgetTranslations.altText}
257
+ type="text"
258
+ className="w-full p-2"
259
+ placeholder={widgetTranslations.altTextPlaceholder}
260
+ />
261
+ )}
262
+ <Input
263
+ rest={register(`${name}.${index}.link`)}
264
+ label={widgetTranslations.link}
265
+ type="url"
266
+ className="w-full p-2"
267
+ placeholder={widgetTranslations.linkPlaceholder}
268
+ />
269
+ <Input.SrcSet
270
+ control={control}
271
+ register={register}
272
+ label={widgetTranslations.srcset}
273
+ name={`${name}.${index}.srcset`}
274
+ errors={errors[name]?.[index]?.['srcset']}
275
+ screenSizeRequired={widgetTranslations.screenSizeRequired}
276
+ heightRequired={widgetTranslations.heightRequired}
277
+ minHeight={widgetTranslations.minHeight}
278
+ minScreenSize={widgetTranslations.minScreenSize}
279
+ minWidth={widgetTranslations.minWidth}
280
+ widthRequired={widgetTranslations.widthRequired}
281
+ />
282
+ {Array.isArray(languages) && languages.length > 0 ? (
283
+ <>
284
+ {languages.map((lang) => (
285
+ <ImageInput
286
+ key={lang.code}
287
+ label={widgetTranslations.image + ` (${lang.name})`}
288
+ control={control}
289
+ name={`${name}.${index}.imgs.${lang.code}`}
290
+ error={errors[name]?.[index]?.['imgs']?.[
291
+ lang.code
292
+ ]?.message?.toString()}
293
+ baseUrl={imageBaseUrl ? imageBaseUrl : baseUrl}
294
+ setError={setError}
295
+ clearError={clearError}
296
+ onImageRemove={onImageRemove}
297
+ imageMaxSize={imageMaxSize}
298
+ onImageUpload={onImageUpload}
299
+ text={
300
+ <>
301
+ <div className="khb_img-text-wrapper">
302
+ <div className="khb_img-text-label">
303
+ <span>{widgetTranslations.uploadFile}</span>
304
+ </div>
305
+ <p className="khb_img-text-1">
306
+ {widgetTranslations.dragDrop}
307
+ </p>
308
+ </div>
309
+ <p className="khb_img-text-2">
310
+ {widgetTranslations.allowedFormat}
311
+ </p>
312
+ </>
313
+ }
314
+ />
315
+ ))}
316
+ </>
317
+ ) : (
318
+ <ImageInput
319
+ label={widgetTranslations.image}
320
+ control={control}
321
+ name={`${name}.${index}.img`}
322
+ error={errors[name]?.[index]?.['img']?.message?.toString()}
323
+ baseUrl={imageBaseUrl ? imageBaseUrl : baseUrl}
324
+ setError={setError}
325
+ clearError={clearError}
326
+ onImageRemove={onImageRemove}
327
+ imageMaxSize={imageMaxSize}
328
+ onImageUpload={onImageUpload}
329
+ text={
330
+ <>
331
+ <div className="khb_img-text-wrapper">
332
+ <div className="khb_img-text-label">
333
+ <span>{widgetTranslations.uploadFile}</span>
334
+ </div>
335
+ <p className="khb_img-text-1">
336
+ {widgetTranslations.dragDrop}
337
+ </p>
338
+ </div>
339
+ <p className="khb_img-text-2">
340
+ {widgetTranslations.allowedFormat}
341
+ </p>
342
+ </>
343
+ }
344
+ />
345
+ )}
346
+ </div>
347
+ </Accordian>
348
+ ))}
349
+ </div>
350
+ </Accordian>
351
+ );
352
+ };
353
+
354
+ export default ItemsAccordian;
@@ -0,0 +1,43 @@
1
+ import React from 'react';
2
+ import Trash from '../../../../icons/trash';
3
+ import { TabItemProps } from '../../../../types';
4
+ import ConfirmPopover from '../../../common/ConfirmPopover';
5
+
6
+ const TabItem = ({
7
+ showDelete,
8
+ isDisabled,
9
+ deleteTitle,
10
+ onRemoveTab,
11
+ register,
12
+ error,
13
+ noButtonText,
14
+ yesButtonText,
15
+ }: TabItemProps) => {
16
+ return (
17
+ <>
18
+ <input
19
+ type="text"
20
+ className="khb_tabs-input"
21
+ autoFocus
22
+ style={{ display: 'block' }}
23
+ disabled={isDisabled}
24
+ {...(register || {})}
25
+ />
26
+ {error && <p className="khb_input-error ">{error}</p>}
27
+ {showDelete ? (
28
+ <ConfirmPopover
29
+ onConfirm={onRemoveTab}
30
+ title={deleteTitle}
31
+ confirmText={yesButtonText}
32
+ cancelText={noButtonText}
33
+ >
34
+ <Trash className="khb_tabs-remove" />
35
+ </ConfirmPopover>
36
+ ) : (
37
+ ''
38
+ )}
39
+ </>
40
+ );
41
+ };
42
+
43
+ export default TabItem;