@knovator/pagecreator-admin 1.2.9 → 1.3.1

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 (167) hide show
  1. package/index.cjs +7878 -0
  2. package/index.css +2 -0
  3. package/index.js +7864 -0
  4. package/package.json +42 -38
  5. package/src/{index.ts → index.d.ts} +0 -1
  6. package/src/lib/api/index.d.ts +10 -0
  7. package/src/lib/api/list.d.ts +56 -0
  8. package/src/lib/components/Page/AddButton/AddButton.d.ts +3 -0
  9. package/src/lib/components/Page/AddButton/{index.ts → index.d.ts} +0 -1
  10. package/src/lib/components/Page/Form/PageForm.d.ts +4 -0
  11. package/src/lib/components/Page/Form/{index.ts → index.d.ts} +0 -1
  12. package/src/lib/components/Page/Page/Page.d.ts +13 -0
  13. package/src/lib/components/Page/Page/{index.ts → index.d.ts} +0 -1
  14. package/src/lib/components/Page/PageFormActions/PageFormActions.d.ts +4 -0
  15. package/src/lib/components/Page/PageFormActions/{index.ts → index.d.ts} +0 -1
  16. package/src/lib/components/Page/PageFormWrapper/PageFormWrapper.d.ts +4 -0
  17. package/src/lib/components/Page/PageFormWrapper/{index.ts → index.d.ts} +0 -1
  18. package/src/lib/components/Page/Pagination/PagePagination.d.ts +3 -0
  19. package/src/lib/components/Page/Pagination/{index.ts → index.d.ts} +0 -1
  20. package/src/lib/components/Page/Search/PageSearch.d.ts +3 -0
  21. package/src/lib/components/Page/Search/{index.tsx → index.d.ts} +0 -1
  22. package/src/lib/components/Page/Table/PageTable.d.ts +4 -0
  23. package/src/lib/components/Page/Table/{index.ts → index.d.ts} +0 -1
  24. package/src/lib/components/Page/{index.ts → index.d.ts} +0 -1
  25. package/src/lib/components/Widget/AddButton/AddButton.d.ts +3 -0
  26. package/src/lib/components/Widget/AddButton/{index.ts → index.d.ts} +0 -1
  27. package/src/lib/components/Widget/Form/ItemsAccordian.d.ts +4 -0
  28. package/src/lib/components/Widget/Form/Tabs/TabItem.d.ts +4 -0
  29. package/src/lib/components/Widget/Form/Tabs/Tabs.d.ts +4 -0
  30. package/src/lib/components/Widget/Form/Tabs/{index.ts → index.d.ts} +0 -1
  31. package/src/lib/components/Widget/Form/WidgetForm.d.ts +4 -0
  32. package/src/lib/components/Widget/Form/{index.ts → index.d.ts} +0 -1
  33. package/src/lib/components/Widget/Pagination/WidgetPagination.d.ts +3 -0
  34. package/src/lib/components/Widget/Pagination/{index.ts → index.d.ts} +0 -1
  35. package/src/lib/components/Widget/Search/WidgetSearch.d.ts +3 -0
  36. package/src/lib/components/Widget/Search/{index.tsx → index.d.ts} +0 -1
  37. package/src/lib/components/Widget/Table/WidgetTable.d.ts +4 -0
  38. package/src/lib/components/Widget/Table/{index.ts → index.d.ts} +0 -1
  39. package/src/lib/components/Widget/Widget/Widget.d.ts +13 -0
  40. package/src/lib/components/Widget/Widget/{index.ts → index.d.ts} +0 -1
  41. package/src/lib/components/Widget/WidgetFormActions/WidgetFormActions.d.ts +4 -0
  42. package/src/lib/components/Widget/WidgetFormActions/{index.ts → index.d.ts} +0 -1
  43. package/src/lib/components/Widget/WidgetFormWrapper/WidgetFormWrapper.d.ts +4 -0
  44. package/src/lib/components/Widget/WidgetFormWrapper/{index.ts → index.d.ts} +0 -1
  45. package/src/lib/components/Widget/{index.tsx → index.d.ts} +0 -1
  46. package/src/lib/components/common/Accordian/Accordian.d.ts +13 -0
  47. package/src/lib/components/common/Accordian/{index.ts → index.d.ts} +0 -1
  48. package/src/lib/components/common/Button/Button.d.ts +4 -0
  49. package/src/lib/components/common/Button/{index.ts → index.d.ts} +0 -1
  50. package/src/lib/components/common/ConfirmPopover/ConfirmPopover.d.ts +4 -0
  51. package/src/lib/components/common/ConfirmPopover/{index.ts → index.d.ts} +0 -1
  52. package/src/lib/components/common/DNDItemsList/DNDItemsList.d.ts +4 -0
  53. package/src/lib/components/common/DNDItemsList/{index.ts → index.d.ts} +0 -1
  54. package/src/lib/components/common/DeleteModal/DeleteModal.d.ts +4 -0
  55. package/src/lib/components/common/DeleteModal/index.d.ts +2 -0
  56. package/src/lib/components/common/Drawer/Drawer.d.ts +9 -0
  57. package/src/lib/components/common/Drawer/{index.ts → index.d.ts} +0 -1
  58. package/src/lib/components/common/Form/Form.d.ts +15 -0
  59. package/src/lib/components/common/Form/SimpleForm.d.ts +18 -0
  60. package/src/lib/components/common/Form/{index.ts → index.d.ts} +0 -1
  61. package/src/lib/components/common/FormActions/FormActions.d.ts +10 -0
  62. package/src/lib/components/common/FormActions/{index.ts → index.d.ts} +0 -1
  63. package/src/lib/components/common/ImageUpload/ImageUpload.d.ts +4 -0
  64. package/src/lib/components/common/ImageUpload/index.d.ts +2 -0
  65. package/src/lib/components/common/Input/Checkbox.d.ts +4 -0
  66. package/src/lib/components/common/Input/Input.d.ts +4 -0
  67. package/src/lib/components/common/Input/ReactSelect.d.ts +4 -0
  68. package/src/lib/components/common/Input/Select.d.ts +4 -0
  69. package/src/lib/components/common/Input/SrcSet.d.ts +4 -0
  70. package/src/lib/components/common/Input/index.d.ts +12 -0
  71. package/src/lib/components/common/Modal/Modal.d.ts +8 -0
  72. package/src/lib/components/common/Modal/index.d.ts +2 -0
  73. package/src/lib/components/common/Pagination/Pagination.d.ts +4 -0
  74. package/src/lib/components/common/Pagination/{index.ts → index.d.ts} +0 -1
  75. package/src/lib/components/common/Table/Table.d.ts +4 -0
  76. package/src/lib/components/common/Table/{index.ts → index.d.ts} +0 -1
  77. package/src/lib/components/common/Toggle/Toggle.d.ts +4 -0
  78. package/src/lib/components/common/Toggle/{index.ts → index.d.ts} +0 -1
  79. package/src/lib/constants/common.d.ts +122 -0
  80. package/src/lib/context/PageContext.d.ts +7 -0
  81. package/src/lib/context/ProviderContext.d.ts +5 -0
  82. package/src/lib/context/WidgetContext.d.ts +7 -0
  83. package/src/lib/helper/utils.d.ts +10 -0
  84. package/src/lib/hooks/usePage.d.ts +37 -0
  85. package/src/lib/hooks/usePagination.d.ts +15 -0
  86. package/src/lib/hooks/useWidget.d.ts +46 -0
  87. package/src/lib/icons/chevronDown.d.ts +4 -0
  88. package/src/lib/icons/chevronLeft.d.ts +4 -0
  89. package/src/lib/icons/chevronRight.d.ts +4 -0
  90. package/src/lib/icons/chevronUp.d.ts +4 -0
  91. package/src/lib/icons/close.d.ts +4 -0
  92. package/src/lib/icons/pencil.d.ts +4 -0
  93. package/src/lib/icons/plus.d.ts +4 -0
  94. package/src/lib/icons/settings.d.ts +4 -0
  95. package/src/lib/icons/trash.d.ts +4 -0
  96. package/src/lib/types/api.d.ts +34 -0
  97. package/src/lib/types/common.d.ts +30 -0
  98. package/src/lib/types/components.d.ts +422 -0
  99. package/src/lib/types/context.d.ts +135 -0
  100. package/index.d.ts +0 -1
  101. package/src/lib/api/index.ts +0 -70
  102. package/src/lib/api/list.ts +0 -59
  103. package/src/lib/components/Page/AddButton/AddButton.tsx +0 -16
  104. package/src/lib/components/Page/Form/PageForm.tsx +0 -194
  105. package/src/lib/components/Page/Page/Page.tsx +0 -151
  106. package/src/lib/components/Page/PageFormActions/PageFormActions.tsx +0 -50
  107. package/src/lib/components/Page/PageFormWrapper/PageFormWrapper.tsx +0 -16
  108. package/src/lib/components/Page/Pagination/PagePagination.tsx +0 -26
  109. package/src/lib/components/Page/Search/PageSearch.tsx +0 -32
  110. package/src/lib/components/Page/Table/PageTable.tsx +0 -36
  111. package/src/lib/components/Widget/AddButton/AddButton.tsx +0 -16
  112. package/src/lib/components/Widget/Form/ItemsAccordian.tsx +0 -354
  113. package/src/lib/components/Widget/Form/Tabs/TabItem.tsx +0 -43
  114. package/src/lib/components/Widget/Form/Tabs/Tabs.tsx +0 -190
  115. package/src/lib/components/Widget/Form/WidgetForm.tsx +0 -771
  116. package/src/lib/components/Widget/Pagination/WidgetPagination.tsx +0 -26
  117. package/src/lib/components/Widget/Search/WidgetSearch.tsx +0 -32
  118. package/src/lib/components/Widget/Table/WidgetTable.tsx +0 -70
  119. package/src/lib/components/Widget/Widget/Widget.tsx +0 -173
  120. package/src/lib/components/Widget/WidgetFormActions/WidgetFormActions.tsx +0 -50
  121. package/src/lib/components/Widget/WidgetFormWrapper/WidgetFormWrapper.tsx +0 -16
  122. package/src/lib/components/common/Accordian/Accordian.tsx +0 -56
  123. package/src/lib/components/common/Button/Button.tsx +0 -45
  124. package/src/lib/components/common/ConfirmPopover/ConfirmPopover.tsx +0 -47
  125. package/src/lib/components/common/DNDItemsList/DNDItemsList.tsx +0 -77
  126. package/src/lib/components/common/DeleteModal/DeleteModal.tsx +0 -72
  127. package/src/lib/components/common/DeleteModal/index.tsx +0 -3
  128. package/src/lib/components/common/Drawer/Drawer.tsx +0 -79
  129. package/src/lib/components/common/Form/Form.tsx +0 -256
  130. package/src/lib/components/common/Form/SimpleForm.tsx +0 -314
  131. package/src/lib/components/common/FormActions/FormActions.tsx +0 -37
  132. package/src/lib/components/common/ImageUpload/ImageUpload.tsx +0 -113
  133. package/src/lib/components/common/ImageUpload/index.tsx +0 -3
  134. package/src/lib/components/common/Input/Checkbox.tsx +0 -25
  135. package/src/lib/components/common/Input/Input.tsx +0 -51
  136. package/src/lib/components/common/Input/ReactSelect.tsx +0 -61
  137. package/src/lib/components/common/Input/Select.tsx +0 -47
  138. package/src/lib/components/common/Input/SrcSet.tsx +0 -143
  139. package/src/lib/components/common/Input/index.ts +0 -20
  140. package/src/lib/components/common/Modal/Modal.tsx +0 -57
  141. package/src/lib/components/common/Modal/index.tsx +0 -3
  142. package/src/lib/components/common/Pagination/Pagination.tsx +0 -88
  143. package/src/lib/components/common/Table/Table.tsx +0 -133
  144. package/src/lib/components/common/Toggle/Toggle.tsx +0 -23
  145. package/src/lib/constants/common.ts +0 -145
  146. package/src/lib/context/PageContext.tsx +0 -100
  147. package/src/lib/context/ProviderContext.tsx +0 -52
  148. package/src/lib/context/WidgetContext.tsx +0 -127
  149. package/src/lib/helper/utils.ts +0 -46
  150. package/src/lib/hooks/usePage.tsx +0 -306
  151. package/src/lib/hooks/usePagination.tsx +0 -41
  152. package/src/lib/hooks/useWidget.tsx +0 -503
  153. package/src/lib/icons/chevronDown.tsx +0 -21
  154. package/src/lib/icons/chevronLeft.tsx +0 -20
  155. package/src/lib/icons/chevronRight.tsx +0 -20
  156. package/src/lib/icons/chevronUp.tsx +0 -21
  157. package/src/lib/icons/close.tsx +0 -21
  158. package/src/lib/icons/pencil.tsx +0 -21
  159. package/src/lib/icons/plus.tsx +0 -23
  160. package/src/lib/icons/settings.tsx +0 -35
  161. package/src/lib/icons/trash.tsx +0 -21
  162. package/src/lib/types/api.ts +0 -44
  163. package/src/lib/types/common.ts +0 -31
  164. package/src/lib/types/components.ts +0 -428
  165. package/src/lib/types/context.ts +0 -184
  166. package/src/styles/index.css +0 -481
  167. /package/src/lib/types/{index.ts → index.d.ts} +0 -0
@@ -0,0 +1,422 @@
1
+ import React, { MutableRefObject } from 'react';
2
+ import { DropResult } from 'react-beautiful-dnd';
3
+ import { FieldValues, RegisterOptions, UseFormClearErrors, UseFormGetValues, UseFormSetValue, ValidationRule } from 'react-hook-form';
4
+ import { Routes_Input } from './api';
5
+ import { OptionType, FormActionTypes, PermissionsObj, ObjectType, LanguageType } from './common';
6
+ export interface DNDItemsListProps {
7
+ onDragEnd: (result: DropResult) => void;
8
+ items: OptionType[];
9
+ listCode?: string;
10
+ formatItem?: (code: string, data: any) => JSX.Element;
11
+ onFilterClick?: (item: OptionType) => void;
12
+ }
13
+ export interface DrawerProps {
14
+ children?: React.ReactNode;
15
+ open: boolean;
16
+ onClose?: () => void;
17
+ id?: string;
18
+ name?: string;
19
+ title?: string;
20
+ }
21
+ export type ButtonTypes = 'primary' | 'secondary' | 'success' | 'danger';
22
+ export type ButtonSizes = 'xs' | 'sm' | 'base' | 'lg';
23
+ export interface ButtonProps {
24
+ children?: React.ReactNode;
25
+ type?: ButtonTypes;
26
+ size?: ButtonSizes;
27
+ onClick?: () => void;
28
+ className?: string;
29
+ disabled?: boolean;
30
+ loading?: boolean;
31
+ }
32
+ export interface IconProps {
33
+ srText?: string;
34
+ className?: string;
35
+ }
36
+ export type InputSizes = 'xs' | 'sm' | 'base' | 'lg';
37
+ export interface InputProps {
38
+ id?: string;
39
+ label?: string;
40
+ placeholder?: string;
41
+ type?: string;
42
+ size?: InputSizes;
43
+ className?: string;
44
+ error?: string;
45
+ errors?: any;
46
+ required?: boolean;
47
+ disabled?: boolean;
48
+ rest?: any;
49
+ wrapperClassName?: string;
50
+ onInput?: (e: React.ChangeEvent<HTMLInputElement>) => void;
51
+ value?: string | number;
52
+ onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
53
+ onBlur?: (e: React.FocusEvent<HTMLInputElement>) => void;
54
+ control?: any;
55
+ register?: any;
56
+ info?: string;
57
+ name?: string;
58
+ }
59
+ export interface SrcSetMessageProps {
60
+ screenSizeRequired: string;
61
+ minScreenSize: string;
62
+ widthRequired: string;
63
+ minWidth: string;
64
+ heightRequired: string;
65
+ minHeight: string;
66
+ }
67
+ export interface HTMLEditorProps {
68
+ id?: string;
69
+ label?: string;
70
+ placeholder?: string;
71
+ value?: string;
72
+ wrapperClassName?: string;
73
+ onChange: (value: string) => void;
74
+ onInput?: (e: any) => void;
75
+ required?: boolean;
76
+ error?: string;
77
+ }
78
+ export interface CheckboxProps {
79
+ rest?: any;
80
+ label?: string;
81
+ error?: string;
82
+ className?: string;
83
+ disabled?: boolean;
84
+ wrapperClassName?: string;
85
+ switchClass?: string;
86
+ }
87
+ export interface SelectProps {
88
+ value?: string | number;
89
+ onChange?: (e: React.ChangeEvent<HTMLSelectElement>) => void;
90
+ label?: string;
91
+ error?: string;
92
+ options?: {
93
+ value: string;
94
+ label: string;
95
+ }[];
96
+ className?: string;
97
+ disabled?: boolean;
98
+ size?: InputSizes;
99
+ id?: string;
100
+ rest?: any;
101
+ required?: boolean;
102
+ wrapperClassName?: string;
103
+ }
104
+ export interface ReactSelectProps {
105
+ onChange?: (opt: OptionType[] | OptionType | null) => void;
106
+ label?: string;
107
+ error?: string;
108
+ options?: {
109
+ value: string;
110
+ label: string;
111
+ }[];
112
+ className?: string;
113
+ disabled?: boolean;
114
+ id?: string;
115
+ isMulti?: boolean;
116
+ required?: boolean;
117
+ selectedOptions?: {
118
+ value: string;
119
+ label: string;
120
+ }[];
121
+ isLoading?: boolean;
122
+ isSearchable?: boolean;
123
+ placeholder?: string;
124
+ formatOptionLabel?: (code: string, data: any) => JSX.Element;
125
+ listCode?: string;
126
+ wrapperClassName?: string;
127
+ customStyles?: any;
128
+ loadOptions?: (value?: string, callback?: (options: OptionType[]) => void) => Promise<OptionType[]>;
129
+ selectKey?: string;
130
+ }
131
+ export interface CustomInputType {
132
+ field: import('react-hook-form').ControllerRenderProps;
133
+ error?: string;
134
+ setError: (msg: string) => void;
135
+ }
136
+ export interface FormProps {
137
+ onFilterClick?: () => void;
138
+ formRef: MutableRefObject<HTMLFormElement | null>;
139
+ customInputs?: Record<string, (props: InputRendererProps) => JSX.Element>;
140
+ }
141
+ export interface InputRendererProps {
142
+ field: import('react-hook-form').ControllerRenderProps;
143
+ error?: string;
144
+ setError: (msg: string) => void;
145
+ disabled?: boolean;
146
+ }
147
+ export interface WidgetTranslationPairs {
148
+ htmlContentRequired: string | ValidationRule<boolean> | undefined;
149
+ htmlContentPlaceholder: string | undefined;
150
+ htmlContent: string | undefined;
151
+ itemsType: string;
152
+ itemsTypePlaceholder: string;
153
+ widgetType: string;
154
+ widgetTypeRequired: string;
155
+ color: string;
156
+ webPerRow: string;
157
+ webPerRowPlaceholder: string;
158
+ mobilePerRow: string;
159
+ mobilePerRowPlaceholder: string;
160
+ tabletPerRow: string;
161
+ tabletPerRowPlaceholder: string;
162
+ mobileItems: string;
163
+ webItems: string;
164
+ searchPlaceholder: string;
165
+ autoPlay: string;
166
+ addWidgetTitle: string;
167
+ updateWidgetTitle: string;
168
+ webPerRowRequired: string;
169
+ tabletPerRowRequired: string;
170
+ mobilePerRowRequired: string;
171
+ tabDeleteTitle: string;
172
+ widgetTitleInfo: string;
173
+ minPerRow: string;
174
+ tabNameRequired: string;
175
+ subtitle: string;
176
+ subTitlePlaceholder: string;
177
+ altText: string;
178
+ altTextPlaceholder: string;
179
+ link: string;
180
+ linkPlaceholder: string;
181
+ image: string;
182
+ uploadFile: string;
183
+ dragDrop: string;
184
+ allowedFormat: string;
185
+ srcset: string;
186
+ screenSizeRequired: string;
187
+ widthRequired: string;
188
+ heightRequired: string;
189
+ minScreenSize: string;
190
+ minWidth: string;
191
+ minHeight: string;
192
+ deleteTitle: string;
193
+ textContent: string;
194
+ textContentRequired: string;
195
+ textContentInfo: string;
196
+ textContentPlaceholder: string;
197
+ }
198
+ export interface WidgetProps {
199
+ loader?: any;
200
+ routes?: Routes_Input;
201
+ explicitForm?: boolean;
202
+ permissions?: PermissionsObj;
203
+ formatListItem?: (code: string, data: any) => JSX.Element;
204
+ formatOptionLabel?: (code: string, data: any) => JSX.Element;
205
+ preConfirmDelete?: (data: {
206
+ row: ObjectType;
207
+ }) => Promise<boolean>;
208
+ children?: JSX.Element;
209
+ reactSelectStyles?: any;
210
+ imageBaseUrl?: string;
211
+ imageMaxSize?: number;
212
+ translations?: WidgetTranslationPairs;
213
+ }
214
+ export interface DerivedTableProps {
215
+ extraActions?: (item: any) => JSX.Element;
216
+ extraColumns?: [
217
+ {
218
+ label: string;
219
+ Cell: (item: any) => JSX.Element;
220
+ }
221
+ ];
222
+ }
223
+ export interface FormWrapperProps {
224
+ children: (data: {
225
+ formState: FormActionTypes | undefined;
226
+ onClose: () => void;
227
+ open: boolean;
228
+ }) => JSX.Element | null;
229
+ }
230
+ export interface FormActionWrapperProps {
231
+ formRef: MutableRefObject<HTMLFormElement | null>;
232
+ }
233
+ export interface SchemaType extends ReactSelectProps {
234
+ label?: string;
235
+ accessor: string;
236
+ Input?: (props: InputRendererProps) => JSX.Element;
237
+ validations?: RegisterOptions;
238
+ editable?: boolean;
239
+ onInput?: (e: React.ChangeEvent<HTMLInputElement>) => void;
240
+ type?: 'text' | 'number' | 'select' | 'checkbox' | 'textarea' | 'file' | 'url' | 'ReactSelect' | 'color' | 'html';
241
+ options?: {
242
+ value: string;
243
+ label: string;
244
+ }[];
245
+ selectedOptions?: {
246
+ value: string;
247
+ label: string;
248
+ }[];
249
+ isMulti?: boolean;
250
+ placeholder?: string;
251
+ required?: boolean;
252
+ onChange?: (e: any) => void;
253
+ show?: boolean;
254
+ wrapperClassName?: string;
255
+ switchClass?: string;
256
+ info?: string;
257
+ customStyles?: any;
258
+ }
259
+ export interface PageTranslationPairs {
260
+ slug: string;
261
+ slugPlaceholder: string;
262
+ slugRequired: string;
263
+ addPage: string;
264
+ updatePage: string;
265
+ searchPages: string;
266
+ widgets: string;
267
+ }
268
+ export interface PageProps {
269
+ loader?: any;
270
+ explicitForm?: boolean;
271
+ children?: JSX.Element;
272
+ permissions?: PermissionsObj;
273
+ translations?: PageTranslationPairs;
274
+ preConfirmDelete?: (data: {
275
+ row: ObjectType;
276
+ }) => Promise<boolean>;
277
+ }
278
+ export interface PaginationProps {
279
+ totalPages: number;
280
+ totalRecords: number;
281
+ currentPage: number;
282
+ pageSize: number;
283
+ setCurrentPage: (value: number) => void;
284
+ showingText?: string;
285
+ pageText?: string;
286
+ ofText?: string;
287
+ previousContent?: string | React.ReactNode;
288
+ nextContent?: string | React.ReactNode;
289
+ }
290
+ export interface ItemsAccordianProps {
291
+ id: string;
292
+ show: boolean;
293
+ title: string;
294
+ collapseId: string;
295
+ toggleShow: (status: boolean) => void;
296
+ addText?: string;
297
+ deleteText?: string;
298
+ loading?: boolean;
299
+ languages?: LanguageType[];
300
+ name: string;
301
+ itemType: 'Web' | 'Mobile';
302
+ errors: any;
303
+ control: any;
304
+ register: any;
305
+ setError: any;
306
+ clearError: (key: string) => void;
307
+ }
308
+ export interface TabItemProps {
309
+ showDelete?: boolean;
310
+ isDisabled?: boolean;
311
+ deleteTitle: string;
312
+ onRemoveTab: () => void;
313
+ register?: any;
314
+ noButtonText: string;
315
+ yesButtonText: string;
316
+ error?: string;
317
+ }
318
+ export interface TabsProps {
319
+ activeTab: number;
320
+ setActiveTab: (value: number) => void;
321
+ onSubmit?: () => void;
322
+ control: any;
323
+ options?: {
324
+ value: string;
325
+ label: string;
326
+ }[];
327
+ deleteTitle: string;
328
+ listCode: string;
329
+ noButtonText: string;
330
+ yesButtonText: string;
331
+ itemsPlaceholder?: string;
332
+ formatOptionLabel?: (code: string, data: any) => JSX.Element;
333
+ isItemsLoading?: boolean;
334
+ formatItem?: (code: string, data: any) => JSX.Element;
335
+ onCollectionItemsIndexChange: (index: number, data: DropResult) => void;
336
+ tabCollectionItems: any[];
337
+ errors?: {
338
+ [key: string]: any;
339
+ };
340
+ customStyles?: any;
341
+ clearErrors: UseFormClearErrors<FieldValues>;
342
+ getValues: UseFormGetValues<FieldValues>;
343
+ setValue: UseFormSetValue<FieldValues>;
344
+ languages?: LanguageType[];
345
+ loadOptions?: (value?: string, callback?: (options: OptionType[]) => void) => Promise<OptionType[]>;
346
+ }
347
+ export interface ImageUploadProps {
348
+ className?: string;
349
+ text: string | JSX.Element;
350
+ maxSize: number;
351
+ imgId?: string | ObjectType;
352
+ setImgId: (value?: string | null) => void;
353
+ clearError?: () => void;
354
+ onError: (msg: string) => void;
355
+ onImageUpload: (file: File) => Promise<{
356
+ fileUrl: string;
357
+ fileId: string;
358
+ fileUri: string;
359
+ } | void>;
360
+ onImageRemove?: (id: string) => Promise<void>;
361
+ baseUrl: string;
362
+ error?: string;
363
+ disabled?: boolean;
364
+ }
365
+ export interface ToggleProps {
366
+ isChecked?: boolean;
367
+ disabled?: boolean;
368
+ onChange?: (status: boolean) => void;
369
+ switchClass?: string;
370
+ }
371
+ export interface ConfirmPopoverProps {
372
+ children?: JSX.Element;
373
+ onConfirm: () => void;
374
+ confirmText?: string;
375
+ cancelText?: string;
376
+ title: string;
377
+ }
378
+ export interface DeleteModalProps {
379
+ formState: FormActionTypes | undefined;
380
+ onClose: () => void;
381
+ itemData: ObjectType;
382
+ onConfirmDelete: () => void;
383
+ confirmationRequired?: string;
384
+ permanentlyDelete?: string;
385
+ lossOfData?: string;
386
+ pleaseType?: string;
387
+ toProceedOrCancel?: string;
388
+ confirm?: string;
389
+ typeHerePlaceholder?: string;
390
+ }
391
+ export type CellInputType = (parameters: {
392
+ row: any;
393
+ onUpdate?: (row: any) => void;
394
+ }) => JSX.Element | null | string;
395
+ export type TableDataItemFormat = {
396
+ label: string;
397
+ dataKey: string;
398
+ highlight?: boolean;
399
+ Cell?: CellInputType;
400
+ };
401
+ export interface TableProps {
402
+ data: any[];
403
+ dataKeys: TableDataItemFormat[];
404
+ loading?: boolean;
405
+ loader?: any;
406
+ actions?: {
407
+ edit?: ((data: {
408
+ [key: string]: any;
409
+ }) => void) | boolean;
410
+ delete?: ((data: {
411
+ [key: string]: any;
412
+ }) => void) | boolean;
413
+ };
414
+ actionsLabel: string;
415
+ extraActions?: (item: any) => JSX.Element;
416
+ extraColumns?: [
417
+ {
418
+ label: string;
419
+ Cell: (item: any) => JSX.Element;
420
+ }
421
+ ];
422
+ }
@@ -0,0 +1,135 @@
1
+ /// <reference types="react" />
2
+ import { WidgetType, ItemsType } from './api';
3
+ import { FormActionTypes, LanguageType, OptionType } from './common';
4
+ import { WidgetTranslationPairs, PageTranslationPairs } from './components';
5
+ export interface CommonTranslationPairs {
6
+ confirmationRequired: string;
7
+ permanentlyDelete: string;
8
+ lossOfData: string;
9
+ pleaseType: string;
10
+ toProceedOrCancel: string;
11
+ confirm: string;
12
+ next: string;
13
+ previous: string;
14
+ page: string;
15
+ indicatesRequired: string;
16
+ cancel: string;
17
+ yes: string;
18
+ delete: string;
19
+ create: string;
20
+ update: string;
21
+ showing: string;
22
+ add: string;
23
+ of: string;
24
+ typeHerePlaceholder: string;
25
+ code: string;
26
+ codePlaceholder: string;
27
+ codeRequired: string;
28
+ name: string;
29
+ namePlaceholder: string;
30
+ nameRequired: string;
31
+ title: string;
32
+ titlePlaceholder: string;
33
+ titleRequired: string;
34
+ active: string;
35
+ actions: string;
36
+ }
37
+ export interface ProviderContextType {
38
+ baseUrl: string;
39
+ token: string | (() => Promise<string>);
40
+ onError: (callback_code: import('../constants/common').CALLBACK_CODES, code: string, message: string) => void;
41
+ onSuccess: (callback_code: import('../constants/common').CALLBACK_CODES, code: string, message: string) => void;
42
+ switchClass: string;
43
+ onLogout: () => void;
44
+ commonTranslations: CommonTranslationPairs;
45
+ widgetRoutesPrefix: string;
46
+ pageRoutesPrefix: string;
47
+ }
48
+ export interface ProviderContextProviderProps extends React.PropsWithChildren, Omit<ProviderContextType, 'onError' | 'onSuccess' | 'onLogout' | 'widgetRoutesPrefix' | 'itemsRoutesPrefix' | 'pageRoutesPrefix' | 'switchClass' | 'commonTranslations'> {
49
+ onError?: (callback_code: import('../constants/common').CALLBACK_CODES, code: string, message: string) => void;
50
+ onSuccess?: (callback_code: import('../constants/common').CALLBACK_CODES, code: string, message: string) => void;
51
+ onLogout?: () => void;
52
+ switchClass?: string;
53
+ widgetRoutesPrefix?: string;
54
+ itemsRoutesPrefix?: string;
55
+ pageRoutesPrefix?: string;
56
+ translations?: Partial<CommonTranslationPairs>;
57
+ }
58
+ export interface WidgetContextType {
59
+ list: any[];
60
+ languages: LanguageType[];
61
+ searchText?: string;
62
+ changeSearch: (str: string) => void;
63
+ formState: FormActionTypes | undefined;
64
+ closeForm: () => void;
65
+ onWidgetFormSubmit: (data: any) => void;
66
+ onChangeFormState: (status: FormActionTypes, data?: any) => void;
67
+ updateData: any;
68
+ loading: boolean;
69
+ canAdd: boolean;
70
+ canUpdate: boolean;
71
+ onDeleteItem: (id: string) => void;
72
+ getWidgets: (searchText?: string) => void;
73
+ onImageUpload: (file: File) => Promise<{
74
+ fileUrl: string;
75
+ fileId: string;
76
+ fileUri: string;
77
+ } | void>;
78
+ onImageRemove: (id: string) => Promise<void>;
79
+ itemsTypes: ItemsType[];
80
+ widgetTypes: WidgetType[];
81
+ getCollectionData: (collectionName: string, search?: string, callback?: (options: OptionType[]) => void, collectionItems?: string[]) => Promise<void>;
82
+ collectionDataLoading: boolean;
83
+ collectionData: any[];
84
+ formatListItem?: (code: string, data: any) => JSX.Element;
85
+ formatOptionLabel?: (code: string, data: any) => JSX.Element;
86
+ currentPage: number;
87
+ setCurrentPage: (page: number) => void;
88
+ totalPages: number;
89
+ pageSize: number;
90
+ setPageSize: (size: number) => void;
91
+ totalRecords: number;
92
+ limits: number[];
93
+ canList: boolean;
94
+ canPartialUpdate: boolean;
95
+ columns: any[];
96
+ data: any;
97
+ loader?: JSX.Element;
98
+ canDelete?: boolean;
99
+ onPartialUpdateWidget: (data: any, id: string) => Promise<void>;
100
+ reactSelectStyles?: any;
101
+ imageBaseUrl?: string;
102
+ imageMaxSize: number;
103
+ widgetTranslations: WidgetTranslationPairs;
104
+ }
105
+ export interface PageContextType {
106
+ list: any[];
107
+ searchText: string;
108
+ changeSearch: (val: string) => void;
109
+ getWidgets: (search: string, collectionItems: string[], callback?: (data: any) => void) => void;
110
+ formState: FormActionTypes | undefined;
111
+ closeForm: () => void;
112
+ onPageFormSubmit: (data: any) => void;
113
+ onChangeFormState: (status: FormActionTypes, data?: any) => void;
114
+ loading: boolean;
115
+ canAdd: boolean;
116
+ canUpdate: boolean;
117
+ widgets: any[];
118
+ selectedWidgets: OptionType[];
119
+ setSelectedWidgets: (widgets: OptionType[]) => void;
120
+ onChangeWidgetSequence: (souceIndex: number, destinationIndex: number) => void;
121
+ getPages: (searchText: string) => void;
122
+ currentPage: number;
123
+ setCurrentPage: (page: number) => void;
124
+ totalPages: number;
125
+ pageSize: number;
126
+ setPageSize: (size: number) => void;
127
+ totalRecords: number;
128
+ limits: number[];
129
+ canList: boolean;
130
+ columns: any[];
131
+ data: any;
132
+ loader?: JSX.Element;
133
+ canDelete?: boolean;
134
+ pageTranslations: PageTranslationPairs;
135
+ }
package/index.d.ts DELETED
@@ -1 +0,0 @@
1
- declare module '@knovator/api';
@@ -1,70 +0,0 @@
1
- import fetchUrl, { setAPIConfig } from '@knovator/api';
2
- import apiList from './list';
3
- import {
4
- ACTION_TYPES,
5
- API_TYPE,
6
- BaseAPIProps,
7
- Routes_Input,
8
- ResponseType,
9
- } from '../types';
10
-
11
- const handleError = (error: Error) => {
12
- console.log(error);
13
- };
14
-
15
- const commonApi = async ({
16
- data,
17
- config,
18
-
19
- baseUrl,
20
- token,
21
-
22
- url,
23
- method,
24
-
25
- onError = handleError,
26
- }: BaseAPIProps): Promise<ResponseType> => {
27
- let apiToken = token;
28
- if (typeof token === 'function') {
29
- apiToken = await token();
30
- }
31
- setAPIConfig({
32
- baseUrl,
33
- tokenPrefix: 'jwt',
34
- getToken: apiToken,
35
- onError,
36
- });
37
- const response: ResponseType = (await fetchUrl({
38
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
39
- // @ts-ignore
40
- type: method,
41
- url,
42
- data,
43
- config,
44
- })) as ResponseType;
45
- return response;
46
- };
47
-
48
- const getApiType = ({
49
- routes,
50
- action,
51
- prefix,
52
- id,
53
- }: {
54
- routes?: Routes_Input;
55
- action: ACTION_TYPES;
56
- prefix: string;
57
- id?: string;
58
- }): API_TYPE => {
59
- let route: API_TYPE;
60
- if (routes && typeof routes[action] === 'function') {
61
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
62
- route = routes[action]!({ prefix, id });
63
- } else {
64
- route = apiList[action]({ prefix, id });
65
- }
66
- return route;
67
- };
68
-
69
- export default commonApi;
70
- export { getApiType };
@@ -1,59 +0,0 @@
1
- import { API_INPUT_TYPE } from '../types';
2
-
3
- const apiList = {
4
- GET_ONE: ({ prefix, id }: API_INPUT_TYPE) => ({
5
- url: `${prefix}/${id}`,
6
- method: 'GET',
7
- }),
8
- LIST: ({ prefix }: API_INPUT_TYPE) => ({
9
- url: `${prefix}/list`,
10
- method: 'POST',
11
- }),
12
- CREATE: ({ prefix }: API_INPUT_TYPE) => ({
13
- url: `${prefix}`,
14
- method: 'POST',
15
- }),
16
- UPDATE: ({ prefix, id }: API_INPUT_TYPE) => ({
17
- url: `${prefix}/${id}`,
18
- method: 'PUT',
19
- }),
20
- PARTIAL_UPDATE: ({ prefix, id }: API_INPUT_TYPE) => ({
21
- url: `${prefix}/${id}`,
22
- method: 'PATCH',
23
- }),
24
- DELETE: ({ prefix, id }: API_INPUT_TYPE) => ({
25
- url: `${prefix}/${id}`,
26
- method: 'DELETE',
27
- }),
28
- WIDGET_TYPES: ({ prefix }: API_INPUT_TYPE) => ({
29
- url: `${prefix}/widget-types`,
30
- method: 'GET',
31
- }),
32
- SELECTION_TYPES: ({ prefix }: API_INPUT_TYPE) => ({
33
- url: `${prefix}/selection-types`,
34
- method: 'GET',
35
- }),
36
- ITEM: ({ prefix, id }: API_INPUT_TYPE) => ({
37
- url: `${prefix}/${id}`,
38
- method: 'GET',
39
- }),
40
- COLLECTION_DATA: ({ prefix }: API_INPUT_TYPE) => ({
41
- url: `${prefix}/collection-data`,
42
- method: 'POST',
43
- }),
44
- LANGUAGES: ({ prefix }: API_INPUT_TYPE) => ({
45
- url: `${prefix}/languages`,
46
- method: 'GET',
47
- }),
48
- // Image Upload API
49
- IMAGE_UPLOAD: ({ prefix }: API_INPUT_TYPE) => ({
50
- url: `${prefix}/upload`,
51
- method: 'post',
52
- }),
53
- IMAGE_REMOVE: ({ prefix, id }: API_INPUT_TYPE) => ({
54
- url: `${prefix}/${id}/delete`,
55
- method: 'DELETE',
56
- }),
57
- };
58
-
59
- export default apiList;
@@ -1,16 +0,0 @@
1
- import React from "react";
2
- import Button from "../../common/Button";
3
- import { usePageState } from "../../../context/PageContext";
4
- import { useProviderState } from '../../../context/ProviderContext';
5
-
6
- const AddButton = () => {
7
- const { commonTranslations } = useProviderState();
8
- const { onChangeFormState, canAdd } = usePageState();
9
- return (
10
- <Button disabled={!canAdd} onClick={() => onChangeFormState('ADD')}>
11
- {commonTranslations.add}
12
- </Button>
13
- );
14
- };
15
-
16
- export default AddButton;