@knovator/pagecreator-admin 1.1.5 → 1.2.0

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