@knovator/pagecreator-admin 1.4.0 → 1.4.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.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 +206 -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 +74 -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 +430 -0
  97. package/src/lib/types/context.ts +184 -0
  98. package/src/styles/index.css +481 -0
  99. package/index.cjs +0 -7881
  100. package/index.css +0 -2
  101. package/index.js +0 -7867
  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 -37
  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/settings.d.ts +0 -4
  162. package/src/lib/icons/trash.d.ts +0 -4
  163. package/src/lib/types/api.d.ts +0 -34
  164. package/src/lib/types/common.d.ts +0 -30
  165. package/src/lib/types/components.d.ts +0 -423
  166. package/src/lib/types/context.d.ts +0 -135
  167. /package/src/lib/types/{index.d.ts → index.ts} +0 -0
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import { IconProps } from '../types';
3
+
4
+ const Trash = ({ srText, className }: IconProps) => {
5
+ return (
6
+ <>
7
+ {srText ? <span className="khb_sr-only">{srText}</span> : null}
8
+ <svg
9
+ className={className}
10
+ xmlns="http://www.w3.org/2000/svg"
11
+ viewBox="-4 -2 24 24"
12
+ width="24"
13
+ fill="currentColor"
14
+ >
15
+ <path d="M14.833 5l-.728 13.11A2 2 0 0 1 12.108 20H3.892a2 2 0 0 1-1.997-1.89L1.167 5H1a1 1 0 0 1-1-1V1a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1h-.167zM12.83 5H3.17l.722 13h8.216l.722-13zM2 2v1h12V2H2zm4 5a1 1 0 0 1 1 1v7a1 1 0 0 1-2 0V8a1 1 0 0 1 1-1zm4 0a1 1 0 0 1 1 1v7a1 1 0 0 1-2 0V8a1 1 0 0 1 1-1z"></path>
16
+ </svg>
17
+ </>
18
+ );
19
+ };
20
+
21
+ export default Trash;
@@ -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; code?: 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,430 @@
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
+ onFilterClick?: (item?: any) => void;
26
+ }
27
+ export interface DrawerProps {
28
+ children?: React.ReactNode;
29
+ open: boolean;
30
+ onClose?: () => void;
31
+ id?: string;
32
+ name?: string;
33
+ title?: string;
34
+ }
35
+ export type ButtonTypes = 'primary' | 'secondary' | 'success' | 'danger';
36
+ export type ButtonSizes = 'xs' | 'sm' | 'base' | 'lg';
37
+ export interface ButtonProps {
38
+ children?: React.ReactNode;
39
+ type?: ButtonTypes;
40
+ size?: ButtonSizes;
41
+ onClick?: () => void;
42
+ className?: string;
43
+ disabled?: boolean;
44
+ loading?: boolean;
45
+ }
46
+ export interface IconProps {
47
+ srText?: string;
48
+ className?: string;
49
+ }
50
+ export type InputSizes = 'xs' | 'sm' | 'base' | 'lg';
51
+ export interface InputProps {
52
+ id?: string;
53
+ label?: string;
54
+ placeholder?: string;
55
+ type?: string;
56
+ size?: InputSizes;
57
+ className?: string;
58
+ error?: string;
59
+ errors?: any;
60
+ required?: boolean;
61
+ disabled?: boolean;
62
+ rest?: any;
63
+ wrapperClassName?: string;
64
+ onInput?: (e: React.ChangeEvent<HTMLInputElement>) => void;
65
+ value?: string | number;
66
+ onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
67
+ onBlur?: (e: React.FocusEvent<HTMLInputElement>) => void;
68
+ control?: any;
69
+ register?: any;
70
+ info?: string;
71
+ name?: string;
72
+ }
73
+ export interface SrcSetMessageProps {
74
+ screenSizeRequired: string;
75
+ minScreenSize: string;
76
+ widthRequired: string;
77
+ minWidth: string;
78
+ heightRequired: string;
79
+ minHeight: string;
80
+ }
81
+ export interface HTMLEditorProps {
82
+ id?: string;
83
+ label?: string;
84
+ placeholder?: string;
85
+ value?: string;
86
+ wrapperClassName?: string;
87
+ onChange: (value: string) => void;
88
+ onInput?: (e: any) => void;
89
+ required?: boolean;
90
+ error?: string;
91
+ }
92
+ export interface CheckboxProps {
93
+ rest?: any;
94
+ label?: string;
95
+ error?: string;
96
+ className?: string;
97
+ disabled?: boolean;
98
+ wrapperClassName?: string;
99
+ switchClass?: string;
100
+ }
101
+ export interface SelectProps {
102
+ value?: string | number;
103
+ onChange?: (e: React.ChangeEvent<HTMLSelectElement>) => void;
104
+ label?: string;
105
+ error?: string;
106
+ options?: { value: string; label: string }[];
107
+ className?: string;
108
+ disabled?: boolean;
109
+ size?: InputSizes;
110
+ id?: string;
111
+ rest?: any;
112
+ required?: boolean;
113
+ wrapperClassName?: string;
114
+ }
115
+ export interface ReactSelectProps {
116
+ onChange?: (opt: OptionType[] | OptionType | null) => void;
117
+ label?: string;
118
+ error?: string;
119
+ options?: { value: string; label: string }[];
120
+ className?: string;
121
+ disabled?: boolean;
122
+ id?: string;
123
+ isMulti?: boolean;
124
+ required?: boolean;
125
+ selectedOptions?: { value: string; label: string }[];
126
+ isLoading?: boolean;
127
+ isSearchable?: boolean;
128
+ placeholder?: string;
129
+ formatOptionLabel?: (code: string, data: any) => JSX.Element;
130
+ listCode?: string;
131
+ wrapperClassName?: string;
132
+ customStyles?: any;
133
+ loadOptions?: (
134
+ value?: string,
135
+ callback?: (options: OptionType[]) => void
136
+ ) => Promise<OptionType[]>;
137
+ selectKey?: string;
138
+ }
139
+ export interface CustomInputType {
140
+ field: import('react-hook-form').ControllerRenderProps;
141
+ error?: string;
142
+ setError: (msg: string) => void;
143
+ }
144
+ export interface FormProps {
145
+ onFilterClick?: (pageData?: any) => void;
146
+ filterQuery?: string;
147
+ formRef: MutableRefObject<HTMLFormElement | null>;
148
+ customInputs?: Record<string, (props: InputRendererProps) => JSX.Element>;
149
+ }
150
+ export interface InputRendererProps {
151
+ field: import('react-hook-form').ControllerRenderProps;
152
+ error?: string;
153
+ setError: (msg: string) => void;
154
+ disabled?: boolean;
155
+ }
156
+ export interface WidgetTranslationPairs {
157
+ htmlContentRequired: string | ValidationRule<boolean> | undefined;
158
+ htmlContentPlaceholder: string | undefined;
159
+ htmlContent: string | undefined;
160
+ itemsType: string;
161
+ itemsTypePlaceholder: string;
162
+ widgetType: string;
163
+ widgetTypeRequired: string;
164
+ color: string;
165
+ webPerRow: string;
166
+ webPerRowPlaceholder: string;
167
+ mobilePerRow: string;
168
+ mobilePerRowPlaceholder: string;
169
+ tabletPerRow: string;
170
+ tabletPerRowPlaceholder: string;
171
+ mobileItems: string;
172
+ webItems: string;
173
+ searchPlaceholder: string;
174
+ autoPlay: string;
175
+ addWidgetTitle: string;
176
+ updateWidgetTitle: string;
177
+ webPerRowRequired: string;
178
+ tabletPerRowRequired: string;
179
+ mobilePerRowRequired: string;
180
+ tabDeleteTitle: string;
181
+ widgetTitleInfo: string;
182
+ minPerRow: string;
183
+ tabNameRequired: string;
184
+
185
+ subtitle: string;
186
+ subTitlePlaceholder: string;
187
+ altText: string;
188
+ altTextPlaceholder: string;
189
+ link: string;
190
+ linkPlaceholder: string;
191
+ image: string;
192
+ uploadFile: string;
193
+ dragDrop: string;
194
+ allowedFormat: string;
195
+ srcset: string;
196
+ screenSizeRequired: string;
197
+ widthRequired: string;
198
+ heightRequired: string;
199
+ minScreenSize: string;
200
+ minWidth: string;
201
+ minHeight: string;
202
+ deleteTitle: string;
203
+
204
+ textContent: string;
205
+ textContentRequired: string;
206
+ textContentInfo: string;
207
+ textContentPlaceholder: string;
208
+ }
209
+ export interface WidgetProps {
210
+ loader?: any;
211
+ routes?: Routes_Input;
212
+ explicitForm?: boolean;
213
+ permissions?: PermissionsObj;
214
+ formatListItem?: (code: string, data: any) => JSX.Element;
215
+ formatOptionLabel?: (code: string, data: any) => JSX.Element;
216
+ preConfirmDelete?: (data: { row: ObjectType }) => Promise<boolean>;
217
+ children?: JSX.Element;
218
+ reactSelectStyles?: any;
219
+ imageBaseUrl?: string;
220
+ imageMaxSize?: number;
221
+ translations?: WidgetTranslationPairs;
222
+ }
223
+ export interface DerivedTableProps {
224
+ extraActions?: (item: any) => JSX.Element;
225
+ extraColumns?: [
226
+ {
227
+ label: string;
228
+ Cell: (item: any) => JSX.Element;
229
+ }
230
+ ];
231
+ }
232
+
233
+ export interface FormWrapperProps {
234
+ children: (data: {
235
+ formState: FormActionTypes | undefined;
236
+ onClose: () => void;
237
+ open: boolean;
238
+ }) => JSX.Element | null;
239
+ }
240
+ export interface FormActionWrapperProps {
241
+ formRef: MutableRefObject<HTMLFormElement | null>;
242
+ }
243
+
244
+ export interface SchemaType extends ReactSelectProps {
245
+ label?: string;
246
+ accessor: string;
247
+ Input?: (props: InputRendererProps) => JSX.Element;
248
+ validations?: RegisterOptions;
249
+ editable?: boolean;
250
+ onInput?: (e: React.ChangeEvent<HTMLInputElement>) => void;
251
+ type?:
252
+ | 'text'
253
+ | 'number'
254
+ | 'select'
255
+ | 'checkbox'
256
+ | 'textarea'
257
+ | 'file'
258
+ | 'url'
259
+ | 'ReactSelect'
260
+ // | 'srcset'
261
+ | 'color'
262
+ | 'html';
263
+ options?: { value: string; label: string }[];
264
+ selectedOptions?: { value: string; label: string }[];
265
+ isMulti?: boolean;
266
+ placeholder?: string;
267
+ required?: boolean;
268
+ onChange?: (e: any) => void;
269
+ show?: boolean;
270
+ wrapperClassName?: string;
271
+ switchClass?: string;
272
+ info?: string;
273
+ customStyles?: any;
274
+ }
275
+ export interface PageTranslationPairs {
276
+ slug: string;
277
+ slugPlaceholder: string;
278
+ slugRequired: string;
279
+ addPage: string;
280
+ updatePage: string;
281
+ searchPages: string;
282
+ widgets: string;
283
+ }
284
+ export interface PageProps {
285
+ loader?: any;
286
+ explicitForm?: boolean;
287
+ children?: JSX.Element;
288
+ permissions?: PermissionsObj;
289
+ translations?: PageTranslationPairs;
290
+ preConfirmDelete?: (data: { row: ObjectType }) => Promise<boolean>;
291
+ }
292
+ export interface PaginationProps {
293
+ totalPages: number;
294
+ totalRecords: number;
295
+ currentPage: number;
296
+ pageSize: number;
297
+ setCurrentPage: (value: number) => void;
298
+ showingText?: string;
299
+ pageText?: string;
300
+ ofText?: string;
301
+ previousContent?: string | React.ReactNode;
302
+ nextContent?: string | React.ReactNode;
303
+ }
304
+ export interface ItemsAccordianProps {
305
+ id: string;
306
+ show: boolean;
307
+ title: string;
308
+ collapseId: string;
309
+ toggleShow: (status: boolean) => void;
310
+ addText?: string;
311
+ deleteText?: string;
312
+ loading?: boolean;
313
+ languages?: LanguageType[];
314
+
315
+ name: string;
316
+ itemType: 'Web' | 'Mobile';
317
+ errors: any;
318
+ control: any;
319
+ register: any;
320
+ setError: any;
321
+ clearError: (key: string) => void;
322
+ }
323
+ export interface TabItemProps {
324
+ showDelete?: boolean;
325
+ isDisabled?: boolean;
326
+ deleteTitle: string;
327
+ onRemoveTab: () => void;
328
+ register?: any;
329
+ noButtonText: string;
330
+ yesButtonText: string;
331
+ error?: string;
332
+ }
333
+ export interface TabsProps {
334
+ activeTab: number;
335
+ setActiveTab: (value: number) => void;
336
+ onSubmit?: () => void;
337
+ control: any;
338
+ options?: { value: string; label: string }[];
339
+ deleteTitle: string;
340
+ listCode: string;
341
+ noButtonText: string;
342
+ yesButtonText: string;
343
+ itemsPlaceholder?: string;
344
+ formatOptionLabel?: (code: string, data: any) => JSX.Element;
345
+ isItemsLoading?: boolean;
346
+ formatItem?: (code: string, data: any) => JSX.Element;
347
+ onCollectionItemsIndexChange: (index: number, data: DropResult) => void;
348
+ tabCollectionItems: any[];
349
+ errors?: { [key: string]: any };
350
+ customStyles?: any;
351
+ clearErrors: UseFormClearErrors<FieldValues>;
352
+ getValues: UseFormGetValues<FieldValues>;
353
+ setValue: UseFormSetValue<FieldValues>;
354
+ languages?: LanguageType[];
355
+ loadOptions?: (
356
+ value?: string,
357
+ callback?: (options: OptionType[]) => void
358
+ ) => Promise<OptionType[]>;
359
+ }
360
+
361
+ export interface ImageUploadProps {
362
+ className?: string;
363
+ text: string | JSX.Element;
364
+ maxSize: number;
365
+ imgId?: string | ObjectType;
366
+ setImgId: (value?: string | null) => void;
367
+ clearError?: () => void;
368
+ onError: (msg: string) => void;
369
+ onImageUpload: (
370
+ file: File
371
+ ) => Promise<{ fileUrl: string; fileId: string; fileUri: string } | void>;
372
+ onImageRemove?: (id: string) => Promise<void>;
373
+ baseUrl: string;
374
+ error?: string;
375
+ disabled?: boolean;
376
+ }
377
+ export interface ToggleProps {
378
+ isChecked?: boolean;
379
+ disabled?: boolean;
380
+ onChange?: (status: boolean) => void;
381
+ switchClass?: string;
382
+ }
383
+ export interface ConfirmPopoverProps {
384
+ children?: JSX.Element;
385
+ onConfirm: () => void;
386
+ confirmText?: string;
387
+ cancelText?: string;
388
+ title: string;
389
+ }
390
+ export interface DeleteModalProps {
391
+ formState: FormActionTypes | undefined;
392
+ onClose: () => void;
393
+ itemData: ObjectType;
394
+ onConfirmDelete: () => void;
395
+ confirmationRequired?: string;
396
+ permanentlyDelete?: string;
397
+ lossOfData?: string;
398
+ pleaseType?: string;
399
+ toProceedOrCancel?: string;
400
+ confirm?: string;
401
+ typeHerePlaceholder?: string;
402
+ }
403
+ // Table
404
+ export type CellInputType = (parameters: {
405
+ row: any;
406
+ onUpdate?: (row: any) => void;
407
+ }) => JSX.Element | null | string;
408
+ export type TableDataItemFormat = {
409
+ label: string;
410
+ dataKey: string;
411
+ highlight?: boolean;
412
+ Cell?: CellInputType;
413
+ };
414
+ export interface TableProps {
415
+ data: any[];
416
+ dataKeys: TableDataItemFormat[];
417
+ loading?: boolean;
418
+ loader?: any;
419
+ actions?: {
420
+ edit?: ((data: { [key: string]: any }) => void) | boolean;
421
+ delete?: ((data: { [key: string]: any }) => void) | boolean;
422
+ };
423
+ actionsLabel: string;
424
+ extraActions?: (item: any) => JSX.Element;
425
+ extraColumns?: [{
426
+ label: string
427
+ Cell: (item: any) => JSX.Element;
428
+ }]
429
+ }
430
+ // \ 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
+ }