@knovator/pagecreator-admin 0.0.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 (80) hide show
  1. package/README.md +7 -0
  2. package/index.d.ts +5 -0
  3. package/index.js +7030 -0
  4. package/lib/api/index.d.ts +10 -0
  5. package/lib/api/list.d.ts +48 -0
  6. package/lib/components/Page/AddButton/AddButton.d.ts +3 -0
  7. package/lib/components/Page/AddButton/index.d.ts +2 -0
  8. package/lib/components/Page/Form/PageForm.d.ts +4 -0
  9. package/lib/components/Page/Form/index.d.ts +2 -0
  10. package/lib/components/Page/Page/Page.d.ts +4 -0
  11. package/lib/components/Page/Page/index.d.ts +2 -0
  12. package/lib/components/Page/Pagination/PagePagination.d.ts +3 -0
  13. package/lib/components/Page/Pagination/index.d.ts +2 -0
  14. package/lib/components/Page/Search/PageSearch.d.ts +3 -0
  15. package/lib/components/Page/Search/index.d.ts +2 -0
  16. package/lib/components/Page/Table/PageTable.d.ts +3 -0
  17. package/lib/components/Page/Table/index.d.ts +2 -0
  18. package/lib/components/Page/index.d.ts +2 -0
  19. package/lib/components/Widget/AddButton/AddButton.d.ts +3 -0
  20. package/lib/components/Widget/AddButton/index.d.ts +2 -0
  21. package/lib/components/Widget/Form/TileItemsAccordian.d.ts +4 -0
  22. package/lib/components/Widget/Form/WidgetForm.d.ts +4 -0
  23. package/lib/components/Widget/Form/index.d.ts +2 -0
  24. package/lib/components/Widget/Pagination/WidgetPagination.d.ts +3 -0
  25. package/lib/components/Widget/Pagination/index.d.ts +2 -0
  26. package/lib/components/Widget/Search/WidgetSearch.d.ts +3 -0
  27. package/lib/components/Widget/Search/index.d.ts +2 -0
  28. package/lib/components/Widget/Table/WidgetTable.d.ts +3 -0
  29. package/lib/components/Widget/Table/index.d.ts +2 -0
  30. package/lib/components/Widget/Widget/Widget.d.ts +7 -0
  31. package/lib/components/Widget/Widget/index.d.ts +2 -0
  32. package/lib/components/Widget/index.d.ts +2 -0
  33. package/lib/components/common/Accordian/Accordian.d.ts +13 -0
  34. package/lib/components/common/Accordian/index.d.ts +2 -0
  35. package/lib/components/common/Button/Button.d.ts +4 -0
  36. package/lib/components/common/Button/index.d.ts +2 -0
  37. package/lib/components/common/DNDItemsList/DNDItemsList.d.ts +4 -0
  38. package/lib/components/common/DNDItemsList/index.d.ts +2 -0
  39. package/lib/components/common/DeleteModal/DeleteModal.d.ts +4 -0
  40. package/lib/components/common/DeleteModal/index.d.ts +2 -0
  41. package/lib/components/common/Drawer/Drawer.d.ts +9 -0
  42. package/lib/components/common/Drawer/index.d.ts +2 -0
  43. package/lib/components/common/Form/Form.d.ts +15 -0
  44. package/lib/components/common/Form/index.d.ts +2 -0
  45. package/lib/components/common/ImageUpload/ImageUpload.d.ts +4 -0
  46. package/lib/components/common/ImageUpload/index.d.ts +2 -0
  47. package/lib/components/common/Input/Checkbox.d.ts +4 -0
  48. package/lib/components/common/Input/Input.d.ts +4 -0
  49. package/lib/components/common/Input/ReactSelect.d.ts +4 -0
  50. package/lib/components/common/Input/Select.d.ts +4 -0
  51. package/lib/components/common/Input/index.d.ts +10 -0
  52. package/lib/components/common/Modal/Modal.d.ts +8 -0
  53. package/lib/components/common/Modal/index.d.ts +2 -0
  54. package/lib/components/common/Pagination/Pagination.d.ts +4 -0
  55. package/lib/components/common/Pagination/index.d.ts +2 -0
  56. package/lib/components/common/Table/Table.d.ts +4 -0
  57. package/lib/components/common/Table/index.d.ts +2 -0
  58. package/lib/components/common/Toggle/Toggle.d.ts +4 -0
  59. package/lib/components/common/Toggle/index.d.ts +2 -0
  60. package/lib/constants/common.d.ts +100 -0
  61. package/lib/context/PageContext.d.ts +7 -0
  62. package/lib/context/ProviderContext.d.ts +5 -0
  63. package/lib/context/WidgetContext.d.ts +7 -0
  64. package/lib/helper/utils.d.ts +11 -0
  65. package/lib/hooks/usePage.d.ts +39 -0
  66. package/lib/hooks/usePagination.d.ts +27 -0
  67. package/lib/hooks/useWidget.d.ts +45 -0
  68. package/lib/icons/chevronDown.d.ts +4 -0
  69. package/lib/icons/chevronLeft.d.ts +4 -0
  70. package/lib/icons/chevronRight.d.ts +4 -0
  71. package/lib/icons/chevronUp.d.ts +4 -0
  72. package/lib/icons/close.d.ts +4 -0
  73. package/lib/icons/pencil.d.ts +4 -0
  74. package/lib/icons/trash.d.ts +4 -0
  75. package/lib/types/api.d.ts +29 -0
  76. package/lib/types/common.d.ts +20 -0
  77. package/lib/types/components.d.ts +257 -0
  78. package/lib/types/context.d.ts +93 -0
  79. package/lib/types/index.d.ts +4 -0
  80. package/package.json +39 -0
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { IconProps } from '../types';
3
+ declare const ChevronLeft: ({ srText }: IconProps) => JSX.Element;
4
+ export default ChevronLeft;
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { IconProps } from '../types';
3
+ declare const ChevronRight: ({ srText }: IconProps) => JSX.Element;
4
+ export default ChevronRight;
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { IconProps } from '../types';
3
+ declare const ChevronUp: ({ srText, className }: IconProps) => JSX.Element;
4
+ export default ChevronUp;
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { IconProps } from '../types';
3
+ declare const Close: ({ srText, className }: IconProps) => JSX.Element;
4
+ export default Close;
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { IconProps } from '../types';
3
+ declare const Pencil: ({ srText, className }: IconProps) => JSX.Element;
4
+ export default Pencil;
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { IconProps } from '../types';
3
+ declare const Trash: ({ srText, className }: IconProps) => JSX.Element;
4
+ export default Trash;
@@ -0,0 +1,29 @@
1
+ export declare type ACTION_TYPES = 'IMAGE_UPLOAD' | 'IMAGE_REMOVE' | 'CREATE' | 'LIST' | 'DELETE' | 'UPDATE' | 'TILES' | 'PARTIAL_UPDATE' | 'WIDGET_TYPES' | 'SELECTION_TYPES' | 'COLLECTION_DATA';
2
+ export declare type API_TYPE = {
3
+ url: string;
4
+ method: string;
5
+ };
6
+ export declare type API_INPUT_TYPE = {
7
+ prefix: string;
8
+ id?: string;
9
+ };
10
+ export declare type Routes_Input = {
11
+ [K in ACTION_TYPES]?: (data: API_INPUT_TYPE) => API_TYPE;
12
+ };
13
+ export declare type WidgetType = {
14
+ value: string;
15
+ label: string;
16
+ };
17
+ export declare type SelectionType = {
18
+ value: string;
19
+ label: string;
20
+ };
21
+ export interface BaseAPIProps {
22
+ config?: any;
23
+ baseUrl: string;
24
+ token: string | (() => Promise<string>);
25
+ data?: any;
26
+ url: string;
27
+ method: string;
28
+ onError?: (error: Error) => void;
29
+ }
@@ -0,0 +1,20 @@
1
+ export declare type FormActionTypes = 'ADD' | 'UPDATE' | 'DELETE' | null | '';
2
+ export declare type TFunc = (key: string) => string;
3
+ export declare type OptionType = {
4
+ label: string;
5
+ value: string;
6
+ };
7
+ export interface PermissionsObj {
8
+ list: boolean;
9
+ add: boolean;
10
+ update: boolean;
11
+ partialUpdate: boolean;
12
+ delete: boolean;
13
+ }
14
+ export declare type ObjectType = {
15
+ [key: string]: string;
16
+ };
17
+ export declare type CombineObjectType = {
18
+ [key: string]: string | boolean | number | string[] | null | ObjectType;
19
+ };
20
+ export declare type ValuesType = string | boolean | number | string[];
@@ -0,0 +1,257 @@
1
+ /// <reference types="react" />
2
+ import { DropResult } from 'react-beautiful-dnd';
3
+ import { RegisterOptions } from 'react-hook-form';
4
+ import { OptionType, FormActionTypes, PermissionsObj, ObjectType } from './common';
5
+ export interface DNDItemsListProps {
6
+ onDragEnd: (result: DropResult) => void;
7
+ items: OptionType[];
8
+ listCode?: string;
9
+ formatItem?: (code: string, data: any) => JSX.Element;
10
+ }
11
+ export interface DrawerProps {
12
+ children?: React.ReactNode;
13
+ open: boolean;
14
+ onClose?: () => void;
15
+ id?: string;
16
+ name?: string;
17
+ title?: string;
18
+ }
19
+ export declare type ButtonTypes = 'primary' | 'secondary' | 'success' | 'danger';
20
+ export declare type ButtonSizes = 'xs' | 'sm' | 'base' | 'lg';
21
+ export interface ButtonProps {
22
+ children?: React.ReactNode;
23
+ type?: ButtonTypes;
24
+ size?: ButtonSizes;
25
+ onClick?: () => void;
26
+ className?: string;
27
+ disabled?: boolean;
28
+ }
29
+ export interface IconProps {
30
+ srText?: string;
31
+ className?: string;
32
+ }
33
+ export declare type InputSizes = 'xs' | 'sm' | 'base' | 'lg';
34
+ export interface InputProps {
35
+ id?: string;
36
+ label?: string;
37
+ placeholder?: string;
38
+ type?: string;
39
+ size?: InputSizes;
40
+ className?: string;
41
+ error?: string;
42
+ required?: boolean;
43
+ disabled?: boolean;
44
+ rest?: any;
45
+ wrapperClassName?: string;
46
+ onInput?: (e: React.ChangeEvent<HTMLInputElement>) => void;
47
+ value?: string | number;
48
+ onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
49
+ onBlur?: (e: React.FocusEvent<HTMLInputElement>) => void;
50
+ }
51
+ export interface CheckboxProps {
52
+ rest?: any;
53
+ label?: string;
54
+ error?: string;
55
+ className?: string;
56
+ disabled?: boolean;
57
+ wrapperClassName?: string;
58
+ }
59
+ export interface SelectProps {
60
+ value?: string | number;
61
+ onChange?: (e: React.ChangeEvent<HTMLSelectElement>) => void;
62
+ label?: string;
63
+ error?: string;
64
+ options?: {
65
+ value: string;
66
+ label: string;
67
+ }[];
68
+ className?: string;
69
+ disabled?: boolean;
70
+ size?: InputSizes;
71
+ id?: string;
72
+ rest?: any;
73
+ required?: boolean;
74
+ wrapperClassName?: string;
75
+ }
76
+ export interface ReactSelectProps {
77
+ onChange?: (opt: OptionType[] | OptionType | null) => void;
78
+ label?: string;
79
+ error?: string;
80
+ options?: {
81
+ value: string;
82
+ label: string;
83
+ }[];
84
+ className?: string;
85
+ disabled?: boolean;
86
+ id?: string;
87
+ isMulti?: boolean;
88
+ required?: boolean;
89
+ selectedOptions?: {
90
+ value: string;
91
+ label: string;
92
+ }[];
93
+ isLoading?: boolean;
94
+ isSearchable?: boolean;
95
+ onSearch?: (text: string) => void;
96
+ placeholder?: string;
97
+ formatOptionLabel?: (code: string, data: any) => JSX.Element;
98
+ listCode?: string;
99
+ wrapperClassName?: string;
100
+ }
101
+ export interface SchemaType extends ReactSelectProps {
102
+ label?: string;
103
+ accessor: string;
104
+ Input?: (props: InputRendererProps) => JSX.Element;
105
+ validations?: import('react-hook-form').RegisterOptions;
106
+ editable?: boolean;
107
+ onInput?: (e: React.ChangeEvent<HTMLInputElement>) => void;
108
+ type?: 'text' | 'number' | 'select' | 'checkbox' | 'textarea' | 'file' | 'url' | 'ReactSelect';
109
+ options?: {
110
+ value: string;
111
+ label: string;
112
+ }[];
113
+ selectedOptions?: {
114
+ value: string;
115
+ label: string;
116
+ }[];
117
+ isMulti?: boolean;
118
+ defaultValue?: string | number | boolean;
119
+ placeholder?: string;
120
+ required?: boolean;
121
+ onChange?: (e: any) => void;
122
+ show?: boolean;
123
+ wrapperClassName?: string;
124
+ }
125
+ export interface FormProps {
126
+ open: boolean;
127
+ onClose: () => void;
128
+ formState: FormActionTypes | undefined;
129
+ }
130
+ export interface InputRendererProps {
131
+ field: import('react-hook-form').ControllerRenderProps;
132
+ error?: string;
133
+ setError: (msg: string) => void;
134
+ disabled?: boolean;
135
+ }
136
+ export interface WidgetProps {
137
+ t?: any;
138
+ loader?: any;
139
+ permissions?: PermissionsObj;
140
+ formatListItem?: (code: string, data: any) => JSX.Element;
141
+ formatOptionLabel?: (code: string, data: any) => JSX.Element;
142
+ }
143
+ export interface SchemaType extends ReactSelectProps {
144
+ label?: string;
145
+ accessor: string;
146
+ Input?: (props: InputRendererProps) => JSX.Element;
147
+ validations?: RegisterOptions;
148
+ editable?: boolean;
149
+ onInput?: (e: React.ChangeEvent<HTMLInputElement>) => void;
150
+ type?: 'text' | 'number' | 'select' | 'checkbox' | 'textarea' | 'file' | 'url' | 'ReactSelect';
151
+ options?: {
152
+ value: string;
153
+ label: string;
154
+ }[];
155
+ selectedOptions?: {
156
+ value: string;
157
+ label: string;
158
+ }[];
159
+ isMulti?: boolean;
160
+ defaultValue?: string | number | boolean;
161
+ placeholder?: string;
162
+ required?: boolean;
163
+ onChange?: (e: any) => void;
164
+ show?: boolean;
165
+ wrapperClassName?: string;
166
+ }
167
+ export interface PageProps {
168
+ t?: any;
169
+ loader?: any;
170
+ permissions?: PermissionsObj;
171
+ }
172
+ export interface PaginationProps {
173
+ totalPages: number;
174
+ totalRecords: number;
175
+ currentPage: number;
176
+ pageSize: number;
177
+ setCurrentPage: (value: number) => void;
178
+ showingText?: string;
179
+ pageText?: string;
180
+ ofText?: string;
181
+ }
182
+ export interface TileItemsAccordianProps {
183
+ id: string;
184
+ show: boolean;
185
+ title: string;
186
+ tilesData: any[];
187
+ widgetId: string;
188
+ collapseId: string;
189
+ schema: SchemaType[];
190
+ tileType: 'Web' | 'Mobile';
191
+ toggleShow: (status: boolean) => void;
192
+ onDataSubmit: (state: FormActionTypes, data: any, updateId?: string) => void;
193
+ onDelete: (id: string) => void;
194
+ addText?: string;
195
+ editText?: string;
196
+ cancelText?: string;
197
+ deleteText?: string;
198
+ saveText?: string;
199
+ }
200
+ export interface ImageUploadProps {
201
+ className?: string;
202
+ text: string | JSX.Element;
203
+ maxSize: number;
204
+ imgId?: string | ObjectType;
205
+ setImgId: (value?: string | null) => void;
206
+ clearError?: () => void;
207
+ onError: (msg: string) => void;
208
+ onImageUpload: (file: File) => Promise<{
209
+ fileUrl: string;
210
+ fileId: string;
211
+ fileUri: string;
212
+ } | void>;
213
+ onImageRemove?: (id: string) => Promise<void>;
214
+ baseUrl: string;
215
+ error?: string;
216
+ disabled?: boolean;
217
+ }
218
+ export interface ToggleProps {
219
+ isChecked?: boolean;
220
+ disabled?: boolean;
221
+ onChange?: (status: boolean) => void;
222
+ }
223
+ export interface DeleteModalProps {
224
+ formState: FormActionTypes | undefined;
225
+ onClose: () => void;
226
+ itemData: ObjectType;
227
+ onConfirmDelete: () => void;
228
+ permanentlyDelete?: string;
229
+ lossOfData?: string;
230
+ pleaseType?: string;
231
+ toProceedOrCancel?: string;
232
+ confirm?: string;
233
+ }
234
+ export declare type CellInputType = (parameters: {
235
+ row: any;
236
+ onUpdate?: (row: any) => void;
237
+ }) => JSX.Element | null | string;
238
+ export declare type TableDataItemFormat = {
239
+ label: string;
240
+ dataKey: string;
241
+ highlight?: boolean;
242
+ Cell?: CellInputType;
243
+ };
244
+ export interface TableProps {
245
+ data: any[];
246
+ dataKeys: TableDataItemFormat[];
247
+ loading?: boolean;
248
+ loader?: any;
249
+ actions?: {
250
+ edit?: (data: {
251
+ [key: string]: any;
252
+ }) => void;
253
+ delete?: (data: {
254
+ [key: string]: any;
255
+ }) => void;
256
+ };
257
+ }
@@ -0,0 +1,93 @@
1
+ /// <reference types="react" />
2
+ import { SelectionType, WidgetType } from './api';
3
+ import { FormActionTypes, OptionType } from './common';
4
+ export interface ProviderContextType {
5
+ baseUrl: string;
6
+ token: string | (() => Promise<string>);
7
+ onError: (callback_code: import('../constants/common').CALLBACK_CODES, code: string, message: string) => void;
8
+ onSuccess: (callback_code: import('../constants/common').CALLBACK_CODES, code: string, message: string) => void;
9
+ onLogout: () => void;
10
+ widgetRoutesPrefix: string;
11
+ tilesRoutesPrefix: string;
12
+ pageRoutesPrefix: string;
13
+ }
14
+ export interface ProviderContextProviderProps extends React.PropsWithChildren, Omit<ProviderContextType, 'onError' | 'onSuccess' | 'onLogout' | 'widgetRoutesPrefix' | 'tilesRoutesPrefix' | 'pageRoutesPrefix'> {
15
+ onError?: (callback_code: import('../constants/common').CALLBACK_CODES, code: string, message: string) => void;
16
+ onSuccess?: (callback_code: import('../constants/common').CALLBACK_CODES, code: string, message: string) => void;
17
+ onLogout?: () => void;
18
+ widgetRoutesPrefix?: string;
19
+ tilesRoutesPrefix?: string;
20
+ pageRoutesPrefix?: string;
21
+ }
22
+ export interface WidgetContextType {
23
+ t: (key: string) => string;
24
+ list: any[];
25
+ formState: FormActionTypes | undefined;
26
+ closeForm: () => void;
27
+ onWidgetFormSubmit: (data: any) => void;
28
+ onChangeFormState: (status: FormActionTypes, data?: any) => void;
29
+ updateData: any;
30
+ loading: boolean;
31
+ canAdd: boolean;
32
+ canUpdate: boolean;
33
+ onDeleteTile: (id: string) => void;
34
+ getWidgets: (searchText: string) => void;
35
+ onImageUpload: (file: File) => Promise<{
36
+ fileUrl: string;
37
+ fileId: string;
38
+ fileUri: string;
39
+ } | void>;
40
+ onImageRemove: (id: string) => Promise<void>;
41
+ widgetTypes: WidgetType[];
42
+ selectionTypes: SelectionType[];
43
+ getCollectionData: (collectionName: string, search?: string) => Promise<void>;
44
+ collectionDataLoading: boolean;
45
+ collectionData: any[];
46
+ formatListItem?: (code: string, data: any) => JSX.Element;
47
+ formatOptionLabel?: (code: string, data: any) => JSX.Element;
48
+ currentPage: number;
49
+ setCurrentPage: (page: number) => void;
50
+ totalPages: number;
51
+ pageSize: number;
52
+ setPageSize: (size: number) => void;
53
+ totalRecords: number;
54
+ limits: number[];
55
+ canList: boolean;
56
+ canPartialUpdate: boolean;
57
+ columns: any[];
58
+ data: any;
59
+ loader?: JSX.Element;
60
+ canDelete?: boolean;
61
+ onPartialUpdateWidget: (data: any, id: string) => Promise<void>;
62
+ tilesList: any[];
63
+ tilesLoading: boolean;
64
+ onTileFormSubmit: (state: FormActionTypes, data: any) => void;
65
+ }
66
+ export interface PageContextType {
67
+ t: (key: string) => string;
68
+ list: any[];
69
+ formState: FormActionTypes | undefined;
70
+ closeForm: () => void;
71
+ onPageFormSubmit: (data: any) => void;
72
+ onChangeFormState: (status: FormActionTypes, data?: any) => void;
73
+ loading: boolean;
74
+ canAdd: boolean;
75
+ canUpdate: boolean;
76
+ widgets: any[];
77
+ selectedWidgets: OptionType[];
78
+ setSelectedWidgets: (widgets: OptionType[]) => void;
79
+ onChangeWidgetSequence: (souceIndex: number, destinationIndex: number) => void;
80
+ getPages: (searchText: string) => void;
81
+ currentPage: number;
82
+ setCurrentPage: (page: number) => void;
83
+ totalPages: number;
84
+ pageSize: number;
85
+ setPageSize: (size: number) => void;
86
+ totalRecords: number;
87
+ limits: number[];
88
+ canList: boolean;
89
+ columns: any[];
90
+ data: any;
91
+ loader?: JSX.Element;
92
+ canDelete?: boolean;
93
+ }
@@ -0,0 +1,4 @@
1
+ export * from './api';
2
+ export * from './components';
3
+ export * from './common';
4
+ export * from './context';
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@knovator/pagecreator-admin",
3
+ "version": "0.0.1",
4
+ "dependencies": {
5
+ "classnames": "^2.3.1",
6
+ "react-beautiful-dnd": "^13.1.0",
7
+ "react-transition-group": "^4.4.5",
8
+ "react-hook-form": "^7.34.2",
9
+ "react-dropzone": "^14.2.2",
10
+ "react-select": "^5.4.0"
11
+ },
12
+ "peerDependencies": {
13
+ "@knovator/api": "^0.0.10",
14
+ "react": "*"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git@github.com:knovator/pagecreator.git"
19
+ },
20
+ "keywords": [
21
+ "pagecreator",
22
+ "pagebuilder",
23
+ "knovator",
24
+ "chavda-bhavik"
25
+ ],
26
+ "author": "knovator (https://knovator.com/)",
27
+ "files": [
28
+ "lib",
29
+ "package.json",
30
+ "README.md",
31
+ "style.css",
32
+ "index.d.ts",
33
+ "index.js"
34
+ ],
35
+ "module": "./index.js",
36
+ "main": "./index.js",
37
+ "type": "module",
38
+ "types": "./index.d.ts"
39
+ }