@knovator/pagecreator-admin 0.5.4 → 0.5.5
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.
- package/index.cjs +71 -73
- package/index.js +71 -73
- package/package.json +2 -2
- package/src/index.d.ts +5 -0
- package/src/lib/api/index.d.ts +10 -0
- package/src/lib/api/list.d.ts +48 -0
- package/src/lib/components/Page/AddButton/AddButton.d.ts +3 -0
- package/src/lib/components/Page/AddButton/index.d.ts +2 -0
- package/src/lib/components/Page/Form/PageForm.d.ts +4 -0
- package/src/lib/components/Page/Form/index.d.ts +2 -0
- package/src/lib/components/Page/Page/Page.d.ts +13 -0
- package/src/lib/components/Page/Page/index.d.ts +2 -0
- package/src/lib/components/Page/PageFormActions/PageFormActions.d.ts +4 -0
- package/src/lib/components/Page/PageFormActions/index.d.ts +2 -0
- package/src/lib/components/Page/PageFormWrapper/PageFormWrapper.d.ts +4 -0
- package/src/lib/components/Page/PageFormWrapper/index.d.ts +2 -0
- package/src/lib/components/Page/Pagination/PagePagination.d.ts +3 -0
- package/src/lib/components/Page/Pagination/index.d.ts +2 -0
- package/src/lib/components/Page/Search/PageSearch.d.ts +3 -0
- package/src/lib/components/Page/Search/index.d.ts +2 -0
- package/src/lib/components/Page/Table/PageTable.d.ts +3 -0
- package/src/lib/components/Page/Table/index.d.ts +2 -0
- package/src/lib/components/Page/index.d.ts +2 -0
- package/src/lib/components/Widget/AddButton/AddButton.d.ts +3 -0
- package/src/lib/components/Widget/AddButton/index.d.ts +2 -0
- package/src/lib/components/Widget/Form/ItemsAccordian.d.ts +4 -0
- package/src/lib/components/Widget/Form/Tabs/TabItem.d.ts +4 -0
- package/src/lib/components/Widget/Form/Tabs/Tabs.d.ts +4 -0
- package/src/lib/components/Widget/Form/Tabs/index.d.ts +2 -0
- package/src/lib/components/Widget/Form/WidgetForm.d.ts +4 -0
- package/src/lib/components/Widget/Form/index.d.ts +2 -0
- package/src/lib/components/Widget/Pagination/WidgetPagination.d.ts +3 -0
- package/src/lib/components/Widget/Pagination/index.d.ts +2 -0
- package/src/lib/components/Widget/Search/WidgetSearch.d.ts +3 -0
- package/src/lib/components/Widget/Search/index.d.ts +2 -0
- package/src/lib/components/Widget/Table/WidgetTable.d.ts +3 -0
- package/src/lib/components/Widget/Table/index.d.ts +2 -0
- package/src/lib/components/Widget/Widget/Widget.d.ts +13 -0
- package/src/lib/components/Widget/Widget/index.d.ts +2 -0
- package/src/lib/components/Widget/WidgetFormActions/WidgetFormActions.d.ts +4 -0
- package/src/lib/components/Widget/WidgetFormActions/index.d.ts +2 -0
- package/src/lib/components/Widget/WidgetFormWrapper/WidgetFormWrapper.d.ts +4 -0
- package/src/lib/components/Widget/WidgetFormWrapper/index.d.ts +2 -0
- package/src/lib/components/Widget/index.d.ts +2 -0
- package/src/lib/components/common/Accordian/Accordian.d.ts +13 -0
- package/src/lib/components/common/Accordian/index.d.ts +2 -0
- package/src/lib/components/common/Button/Button.d.ts +4 -0
- package/src/lib/components/common/Button/index.d.ts +2 -0
- package/src/lib/components/common/ConfirmPopover/ConfirmPopover.d.ts +4 -0
- package/src/lib/components/common/ConfirmPopover/index.d.ts +2 -0
- package/src/lib/components/common/DNDItemsList/DNDItemsList.d.ts +4 -0
- package/src/lib/components/common/DNDItemsList/index.d.ts +2 -0
- package/src/lib/components/common/DeleteModal/DeleteModal.d.ts +4 -0
- package/src/lib/components/common/DeleteModal/index.d.ts +2 -0
- package/src/lib/components/common/Drawer/Drawer.d.ts +9 -0
- package/src/lib/components/common/Drawer/index.d.ts +2 -0
- package/src/lib/components/common/Form/Form.d.ts +15 -0
- package/src/lib/components/common/Form/SimpleForm.d.ts +17 -0
- package/src/lib/components/common/Form/index.d.ts +4 -0
- package/src/lib/components/common/FormActions/FormActions.d.ts +10 -0
- package/src/lib/components/common/FormActions/index.d.ts +2 -0
- package/src/lib/components/common/ImageUpload/ImageUpload.d.ts +4 -0
- package/src/lib/components/common/ImageUpload/index.d.ts +2 -0
- package/src/lib/components/common/Input/Checkbox.d.ts +4 -0
- package/src/lib/components/common/Input/Input.d.ts +4 -0
- package/src/lib/components/common/Input/ReactSelect.d.ts +4 -0
- package/src/lib/components/common/Input/Select.d.ts +4 -0
- package/src/lib/components/common/Input/SrcSet.d.ts +4 -0
- package/src/lib/components/common/Input/index.d.ts +12 -0
- package/src/lib/components/common/Modal/Modal.d.ts +8 -0
- package/src/lib/components/common/Modal/index.d.ts +2 -0
- package/src/lib/components/common/Pagination/Pagination.d.ts +4 -0
- package/src/lib/components/common/Pagination/index.d.ts +2 -0
- package/src/lib/components/common/Table/Table.d.ts +4 -0
- package/src/lib/components/common/Table/index.d.ts +2 -0
- package/src/lib/components/common/Toggle/Toggle.d.ts +4 -0
- package/src/lib/components/common/Toggle/index.d.ts +2 -0
- package/src/lib/constants/common.d.ts +113 -0
- package/src/lib/context/PageContext.d.ts +7 -0
- package/src/lib/context/ProviderContext.d.ts +5 -0
- package/src/lib/context/WidgetContext.d.ts +7 -0
- package/src/lib/helper/utils.d.ts +11 -0
- package/src/lib/hooks/usePage.d.ts +40 -0
- package/src/lib/hooks/usePagination.d.ts +27 -0
- package/src/lib/hooks/useWidget.d.ts +50 -0
- package/src/lib/icons/chevronDown.d.ts +4 -0
- package/src/lib/icons/chevronLeft.d.ts +4 -0
- package/src/lib/icons/chevronRight.d.ts +4 -0
- package/src/lib/icons/chevronUp.d.ts +4 -0
- package/src/lib/icons/close.d.ts +4 -0
- package/src/lib/icons/pencil.d.ts +4 -0
- package/src/lib/icons/plus.d.ts +4 -0
- package/src/lib/icons/trash.d.ts +4 -0
- package/src/lib/types/api.d.ts +34 -0
- package/src/lib/types/common.d.ts +25 -0
- package/src/lib/types/components.d.ts +307 -0
- package/src/lib/types/context.d.ts +97 -0
- package/src/lib/types/index.d.ts +4 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface AccordianProps {
|
|
3
|
+
id?: string;
|
|
4
|
+
collapseId?: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
open?: boolean;
|
|
8
|
+
onToggle?: (status: boolean) => void;
|
|
9
|
+
title?: string;
|
|
10
|
+
footerContent?: React.ReactNode;
|
|
11
|
+
}
|
|
12
|
+
declare const Accordian: ({ id, className, children, open, onToggle, title, collapseId, footerContent, }: AccordianProps) => JSX.Element;
|
|
13
|
+
export default Accordian;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { DeleteModalProps } from '../../../types';
|
|
3
|
+
declare const DeleteModal: ({ formState, onClose, itemData, onConfirmDelete, confirmationRequired, permanentlyDelete, lossOfData, pleaseType, toProceedOrCancel, confirm, typeHerePlaceholder, }: DeleteModalProps) => JSX.Element | null;
|
|
4
|
+
export default DeleteModal;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface DrawerProps extends React.PropsWithChildren {
|
|
3
|
+
open: boolean;
|
|
4
|
+
onClose: () => void;
|
|
5
|
+
title?: string;
|
|
6
|
+
footerContent?: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
declare const Drawer: ({ children, open, onClose, title, footerContent, }: DrawerProps) => JSX.Element;
|
|
9
|
+
export default Drawer;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React, { MutableRefObject } from 'react';
|
|
2
|
+
import { EventType } from 'react-hook-form';
|
|
3
|
+
import { CombineObjectType, ObjectType, SchemaType } from '../../../types';
|
|
4
|
+
interface FormProps {
|
|
5
|
+
schema: SchemaType[];
|
|
6
|
+
data?: CombineObjectType;
|
|
7
|
+
isUpdating?: boolean;
|
|
8
|
+
onSubmit: (data: CombineObjectType) => void;
|
|
9
|
+
enable?: boolean;
|
|
10
|
+
updates?: CombineObjectType;
|
|
11
|
+
ref: MutableRefObject<HTMLFormElement | null>;
|
|
12
|
+
watcher?: (value: ObjectType, name: string | undefined, type: EventType | undefined) => void;
|
|
13
|
+
}
|
|
14
|
+
declare const Form: React.ForwardRefExoticComponent<Pick<FormProps, "schema" | "onSubmit" | "data" | "isUpdating" | "enable" | "updates" | "watcher"> & React.RefAttributes<HTMLFormElement | null>>;
|
|
15
|
+
export default Form;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React, { MutableRefObject } from 'react';
|
|
2
|
+
import { CombineObjectType, SchemaType } from '../../../types';
|
|
3
|
+
interface SimpleFormProps {
|
|
4
|
+
schema: SchemaType[];
|
|
5
|
+
isUpdating?: boolean;
|
|
6
|
+
onSubmit: (data: CombineObjectType) => void;
|
|
7
|
+
enable?: boolean;
|
|
8
|
+
ref: MutableRefObject<HTMLFormElement | null>;
|
|
9
|
+
register: any;
|
|
10
|
+
errors: any;
|
|
11
|
+
handleSubmit: any;
|
|
12
|
+
setValue: any;
|
|
13
|
+
control: any;
|
|
14
|
+
setError: any;
|
|
15
|
+
}
|
|
16
|
+
declare const SimpleForm: React.ForwardRefExoticComponent<Pick<SimpleFormProps, "schema" | "onSubmit" | "isUpdating" | "enable" | "register" | "errors" | "handleSubmit" | "setValue" | "control" | "setError"> & React.RefAttributes<HTMLFormElement | null>>;
|
|
17
|
+
export default SimpleForm;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface FormActionsProps {
|
|
3
|
+
loading?: boolean;
|
|
4
|
+
primaryLabel?: string;
|
|
5
|
+
secondaryLabel?: string;
|
|
6
|
+
onPrimaryButtonClick?: (e?: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
|
7
|
+
onSecondaryButtonClick?: () => void;
|
|
8
|
+
}
|
|
9
|
+
declare const FormActions: ({ loading, primaryLabel, secondaryLabel, onPrimaryButtonClick, onSecondaryButtonClick, }: FormActionsProps) => JSX.Element;
|
|
10
|
+
export default FormActions;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ImageUploadProps } from '../../../types';
|
|
3
|
+
declare const _default: React.MemoExoticComponent<({ className, text, maxSize, setImgId, onError, error, imgId, onImageUpload, onImageRemove, baseUrl, disabled, }: ImageUploadProps) => JSX.Element>;
|
|
4
|
+
export default _default;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { InputProps } from '../../../types';
|
|
3
|
+
declare const Input: ({ label, id, placeholder, type, size, required, error, className, disabled, rest, onInput, onBlur, value, info, onChange, wrapperClassName, }: InputProps) => JSX.Element;
|
|
4
|
+
export default Input;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ReactSelectProps } from '../../../types';
|
|
3
|
+
declare const CustomReactSelect: ({ onChange, label, error, className, isMulti, selectedOptions, required, isLoading, isSearchable, loadOptions, placeholder, wrapperClassName, formatOptionLabel, listCode, customStyles, selectKey, }: ReactSelectProps) => JSX.Element;
|
|
4
|
+
export default CustomReactSelect;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import Checkbox from "./Checkbox";
|
|
3
|
+
import Select from "./Select";
|
|
4
|
+
import ReactSelect from "./ReactSelect";
|
|
5
|
+
import SrcSet from './SrcSet';
|
|
6
|
+
declare const _default: (({ label, id, placeholder, type, size, required, error, className, disabled, rest, onInput, onBlur, value, onChange, wrapperClassName, }: import("../../../types").InputProps) => JSX.Element) & {
|
|
7
|
+
Select: typeof Select;
|
|
8
|
+
ReactSelect: typeof ReactSelect;
|
|
9
|
+
Checkbox: typeof Checkbox;
|
|
10
|
+
SrcSet: typeof SrcSet;
|
|
11
|
+
};
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { PaginationProps } from '../../../types';
|
|
3
|
+
declare const Pagination: ({ currentPage, pageSize, totalPages, totalRecords, setCurrentPage, showingText, pageText, ofText, previousContent, nextContent, }: PaginationProps) => JSX.Element;
|
|
4
|
+
export default Pagination;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
declare const DEFAULT_OFFSET_PAYLOAD = 0;
|
|
2
|
+
declare const DECIMAL_REDIX = 10;
|
|
3
|
+
declare const DEFAULT_CURRENT_PAGE = 1;
|
|
4
|
+
declare const INTERNAL_ERROR_CODE = "INTERNAL_ERROR";
|
|
5
|
+
declare const DEFAULT_LIMIT = 10;
|
|
6
|
+
declare const PAGE_LIMITS: number[];
|
|
7
|
+
declare enum CALLBACK_CODES {
|
|
8
|
+
'GET_ALL' = "GET_ALL",
|
|
9
|
+
'GET_SINGLE' = "GET_SINGLE",
|
|
10
|
+
'CREATE' = "CREATE",
|
|
11
|
+
'UPDATE' = "UPDATE",
|
|
12
|
+
'PARTIAL_UPDATE' = "PARTIAL_UPDATE",
|
|
13
|
+
'DELETE' = "DELETE",
|
|
14
|
+
'IMAGE_UPLOAD' = "IMAGE_UPLOAD",
|
|
15
|
+
'IMAGE_REMOVE' = "IMAGE_REMOVE",
|
|
16
|
+
'INTERNAL' = "INTERNAL"
|
|
17
|
+
}
|
|
18
|
+
declare const DEFAULT_PERMISSIONS: {
|
|
19
|
+
list: boolean;
|
|
20
|
+
add: boolean;
|
|
21
|
+
delete: boolean;
|
|
22
|
+
partialUpdate: boolean;
|
|
23
|
+
update: boolean;
|
|
24
|
+
};
|
|
25
|
+
declare const TRANSLATION_PAIRS_COMMON: {
|
|
26
|
+
confirmationRequired: string;
|
|
27
|
+
permanentlyDelete: string;
|
|
28
|
+
lossOfData: string;
|
|
29
|
+
pleaseType: string;
|
|
30
|
+
toProceedOrCancel: string;
|
|
31
|
+
confirm: string;
|
|
32
|
+
'common:actions': string;
|
|
33
|
+
'common:cancel': string;
|
|
34
|
+
page: string;
|
|
35
|
+
next: string;
|
|
36
|
+
previous: string;
|
|
37
|
+
indicatesRequired: string;
|
|
38
|
+
addButtonText: string;
|
|
39
|
+
editButtonText: string;
|
|
40
|
+
cancelButtonText: string;
|
|
41
|
+
yesButtonText: string;
|
|
42
|
+
deleteButtonText: string;
|
|
43
|
+
saveButtonText: string;
|
|
44
|
+
showing: string;
|
|
45
|
+
of: string;
|
|
46
|
+
typeHerePlaceholder: string;
|
|
47
|
+
};
|
|
48
|
+
declare const TRANSLATION_PAIRS_WIDGET: {
|
|
49
|
+
'widget.name': string;
|
|
50
|
+
'widget.namePlaceholder': string;
|
|
51
|
+
'widget.nameRequired': string;
|
|
52
|
+
'widget.widgetTitle': string;
|
|
53
|
+
'widget.widgetTitlePlaceholder': string;
|
|
54
|
+
'widget.widgetTitleRequired': string;
|
|
55
|
+
'widget.itemsType': string;
|
|
56
|
+
'widget.itemsTypePlaceholder': string;
|
|
57
|
+
'widget.widgetType': string;
|
|
58
|
+
'widget.widgetTypeRequired': string;
|
|
59
|
+
'widget.color': string;
|
|
60
|
+
'widget.code': string;
|
|
61
|
+
'widget.codePlaceholder': string;
|
|
62
|
+
'widget.codeRequired': string;
|
|
63
|
+
'widget.webPerRow': string;
|
|
64
|
+
'widget.webPerRowPlaceholder': string;
|
|
65
|
+
'widget.mobilePerRow': string;
|
|
66
|
+
'widget.mobilePerRowPlaceholder': string;
|
|
67
|
+
'widget.tabletPerRow': string;
|
|
68
|
+
'widget.tabletPerRowPlaceholder': string;
|
|
69
|
+
'widget.mobileItems': string;
|
|
70
|
+
'widget.webItems': string;
|
|
71
|
+
'widget.searchPlaceholder': string;
|
|
72
|
+
'widget.autoPlay': string;
|
|
73
|
+
'widget.tableName': string;
|
|
74
|
+
'widget.tableCode': string;
|
|
75
|
+
'widget.tableActive': string;
|
|
76
|
+
'widget.addWidgetTitle': string;
|
|
77
|
+
'widget.updateWidgetTitle': string;
|
|
78
|
+
'widget.webPerRowRequired': string;
|
|
79
|
+
'widget.tabletPerRowRequired': string;
|
|
80
|
+
'widget.mobilePerRowRequired': string;
|
|
81
|
+
'widget.tabDeleteTitle': string;
|
|
82
|
+
'widget.widgetTitleInfo': string;
|
|
83
|
+
};
|
|
84
|
+
declare const TRANSLATION_PAIRS_ITEM: {
|
|
85
|
+
'item.title': string;
|
|
86
|
+
'item.titlePlaceholder': string;
|
|
87
|
+
'item.subtitle': string;
|
|
88
|
+
'item.subTitlePlaceholder': string;
|
|
89
|
+
'item.altText': string;
|
|
90
|
+
'item.altTextPlaceholder': string;
|
|
91
|
+
'item.link': string;
|
|
92
|
+
'item.linkPlaceholder': string;
|
|
93
|
+
'item.image': string;
|
|
94
|
+
'item.uploadFile': string;
|
|
95
|
+
'item.dragDrop': string;
|
|
96
|
+
'item.allowedFormat': string;
|
|
97
|
+
'item.srcset': string;
|
|
98
|
+
};
|
|
99
|
+
declare const TRANSLATION_PAIRS_PAGE: {
|
|
100
|
+
'page.name': string;
|
|
101
|
+
'page.namePlaceholder': string;
|
|
102
|
+
'page.nameRequired': string;
|
|
103
|
+
'page.code': string;
|
|
104
|
+
'page.codePlaceholder': string;
|
|
105
|
+
'page.codeRequired': string;
|
|
106
|
+
'page.addPageTitle': string;
|
|
107
|
+
'page.updatePageTitle': string;
|
|
108
|
+
'page.searchPages': string;
|
|
109
|
+
'page.tableName': string;
|
|
110
|
+
'page.tableCode': string;
|
|
111
|
+
'page.widgets': string;
|
|
112
|
+
};
|
|
113
|
+
export { CALLBACK_CODES, DECIMAL_REDIX, DEFAULT_CURRENT_PAGE, DEFAULT_OFFSET_PAYLOAD, INTERNAL_ERROR_CODE, DEFAULT_PERMISSIONS, TRANSLATION_PAIRS_COMMON, DEFAULT_LIMIT, PAGE_LIMITS, TRANSLATION_PAIRS_WIDGET, TRANSLATION_PAIRS_ITEM, TRANSLATION_PAIRS_PAGE, };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { PageContextType } from '../types';
|
|
3
|
+
interface PageContextProviderProps extends React.PropsWithChildren, Partial<PageContextType> {
|
|
4
|
+
}
|
|
5
|
+
declare const PageContextProvider: ({ t, list, widgets, formState, closeForm, getPages, loading, onChangeFormState, onPageFormSubmit, canAdd, canUpdate, selectedWidgets, setSelectedWidgets, onChangeWidgetSequence, currentPage, limits, pageSize, setCurrentPage, setPageSize, totalPages, totalRecords, canList, columns, data, canDelete, loader, children, }: PageContextProviderProps) => JSX.Element;
|
|
6
|
+
export declare function usePageState(): PageContextType;
|
|
7
|
+
export default PageContextProvider;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ProviderContextProviderProps, ProviderContextType } from '../types';
|
|
3
|
+
declare const Provider: ({ children, baseUrl, token, onError, onSuccess, onLogout, switchClass, itemsRoutesPrefix, widgetRoutesPrefix, pageRoutesPrefix, }: ProviderContextProviderProps) => JSX.Element;
|
|
4
|
+
export declare function useProviderState(): ProviderContextType;
|
|
5
|
+
export default Provider;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { WidgetContextType } from '../types';
|
|
3
|
+
interface WidgetContextProviderProps extends React.PropsWithChildren, Partial<WidgetContextType> {
|
|
4
|
+
}
|
|
5
|
+
declare const WidgetContextProvider: ({ t, list, formState, closeForm, loading, onChangeFormState, onWidgetFormSubmit, updateData, canAdd, canUpdate, onDeleteItem, getWidgets, onImageUpload, onImageRemove, itemsTypes, widgetTypes, getCollectionData, collectionDataLoading, collectionData, formatListItem, formatOptionLabel, currentPage, limits, pageSize, setCurrentPage, setPageSize, totalPages, totalRecords, canList, canPartialUpdate, columns, data, canDelete, loader, onPartialUpdateWidget, webItems, mobileItems, itemsLoading, onItemFormSubmit, reactSelectStyles, children, }: WidgetContextProviderProps) => JSX.Element;
|
|
6
|
+
export declare function useWidgetState(): WidgetContextType;
|
|
7
|
+
export default WidgetContextProvider;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TFunc } from '../types';
|
|
2
|
+
export declare const paginationDataGatter: (data: any) => any;
|
|
3
|
+
export declare const dataGatter: (data: any) => any;
|
|
4
|
+
export declare const capitalizeFirstLetter: (string?: string) => string;
|
|
5
|
+
export declare const changeToCode: (string?: string) => string;
|
|
6
|
+
export declare const isObject: (data: any) => boolean;
|
|
7
|
+
export declare const isString: (data: any) => boolean;
|
|
8
|
+
export declare const isArray: (data: any) => boolean;
|
|
9
|
+
export declare const isEmpty: (data: any) => boolean;
|
|
10
|
+
export declare function createTranslation(t: TFunc | undefined, obj: Record<string, string>): (key: string) => string;
|
|
11
|
+
export declare const build_path: (...args: string[]) => string;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FormActionTypes, ObjectType, Routes_Input } from '../types';
|
|
3
|
+
interface UsePageProps {
|
|
4
|
+
canList?: boolean;
|
|
5
|
+
defaultLimit: number;
|
|
6
|
+
routes?: Routes_Input;
|
|
7
|
+
preConfirmDelete?: (data: {
|
|
8
|
+
row: ObjectType;
|
|
9
|
+
}) => Promise<boolean>;
|
|
10
|
+
}
|
|
11
|
+
declare const usePage: ({ routes, defaultLimit, canList, preConfirmDelete, }: UsePageProps) => {
|
|
12
|
+
list: ObjectType[];
|
|
13
|
+
getPages: (search?: string) => Promise<void>;
|
|
14
|
+
loading: boolean;
|
|
15
|
+
setLoading: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
16
|
+
pageSize: number;
|
|
17
|
+
totalPages: number;
|
|
18
|
+
currentPage: number;
|
|
19
|
+
totalRecords: number;
|
|
20
|
+
setCurrentPage: (value: number) => void;
|
|
21
|
+
setPageSize: (value: number) => void;
|
|
22
|
+
widgets: ObjectType[];
|
|
23
|
+
itemData: any;
|
|
24
|
+
formState: FormActionTypes | undefined;
|
|
25
|
+
onCloseForm: () => void;
|
|
26
|
+
widgetsLoading: boolean;
|
|
27
|
+
selectedWidgets: {
|
|
28
|
+
label: string;
|
|
29
|
+
value: string;
|
|
30
|
+
}[];
|
|
31
|
+
setSelectedWidgets: import("react").Dispatch<import("react").SetStateAction<{
|
|
32
|
+
label: string;
|
|
33
|
+
value: string;
|
|
34
|
+
}[]>>;
|
|
35
|
+
onPageFormSubmit: (data: ObjectType) => Promise<void>;
|
|
36
|
+
onChangeFormState: (state: FormActionTypes, data?: any) => void;
|
|
37
|
+
onCofirmDeletePage: () => Promise<void>;
|
|
38
|
+
onChangeWidgetSequence: (sourceIndex: number, destinationIndex: number) => void;
|
|
39
|
+
};
|
|
40
|
+
export default usePage;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
interface UsePaginationProps {
|
|
3
|
+
defaultLimit?: number;
|
|
4
|
+
}
|
|
5
|
+
declare const usePagination: ({ defaultLimit }: UsePaginationProps) => {
|
|
6
|
+
pageSize: number;
|
|
7
|
+
setPageSize: (value: number) => void;
|
|
8
|
+
currentPage: number;
|
|
9
|
+
changeSearch: (value: string) => void;
|
|
10
|
+
filter: {
|
|
11
|
+
search: string;
|
|
12
|
+
offset: number;
|
|
13
|
+
limit: number;
|
|
14
|
+
};
|
|
15
|
+
setCurrentPage: (value: number) => void;
|
|
16
|
+
defaultApiPayload: {
|
|
17
|
+
search: string;
|
|
18
|
+
offset: number;
|
|
19
|
+
limit: number;
|
|
20
|
+
};
|
|
21
|
+
setFilter: import("react").Dispatch<import("react").SetStateAction<{
|
|
22
|
+
search: string;
|
|
23
|
+
offset: number;
|
|
24
|
+
limit: number;
|
|
25
|
+
}>>;
|
|
26
|
+
};
|
|
27
|
+
export default usePagination;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Routes_Input, WidgetType, ItemsType } from '../types';
|
|
3
|
+
import { FormActionTypes, ObjectType } from '../types/common';
|
|
4
|
+
interface UseWidgetProps {
|
|
5
|
+
canList?: boolean;
|
|
6
|
+
defaultLimit: number;
|
|
7
|
+
routes?: Routes_Input;
|
|
8
|
+
preConfirmDelete?: (data: {
|
|
9
|
+
row: ObjectType;
|
|
10
|
+
}) => Promise<boolean>;
|
|
11
|
+
}
|
|
12
|
+
interface ItemsList {
|
|
13
|
+
web: ObjectType[];
|
|
14
|
+
mobile: ObjectType[];
|
|
15
|
+
}
|
|
16
|
+
declare const useWidget: ({ canList, defaultLimit, routes, preConfirmDelete, }: UseWidgetProps) => {
|
|
17
|
+
list: ObjectType[];
|
|
18
|
+
getWidgets: (search?: string) => Promise<void>;
|
|
19
|
+
loading: boolean;
|
|
20
|
+
setLoading: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
21
|
+
pageSize: number;
|
|
22
|
+
totalPages: number;
|
|
23
|
+
currentPage: number;
|
|
24
|
+
totalRecords: number;
|
|
25
|
+
setCurrentPage: (value: number) => void;
|
|
26
|
+
setPageSize: (value: number) => void;
|
|
27
|
+
formState: FormActionTypes | undefined;
|
|
28
|
+
itemData: ObjectType | null;
|
|
29
|
+
onChangeFormState: (state: FormActionTypes, data?: ObjectType) => void;
|
|
30
|
+
onCloseForm: () => void;
|
|
31
|
+
onDeleteItem: (id: string) => Promise<void>;
|
|
32
|
+
onWidgetFormSubmit: (data: ObjectType) => Promise<void>;
|
|
33
|
+
onCofirmDeleteWidget: () => Promise<void>;
|
|
34
|
+
onPartialUpdateWidget: (data: ObjectType, id: string) => Promise<void>;
|
|
35
|
+
onImageUpload: (file: File) => Promise<{
|
|
36
|
+
fileUrl: string;
|
|
37
|
+
fileId: string;
|
|
38
|
+
fileUri: string;
|
|
39
|
+
} | void>;
|
|
40
|
+
onImageRemove: (id: string) => Promise<void>;
|
|
41
|
+
itemsTypes: ItemsType[];
|
|
42
|
+
widgetTypes: WidgetType[];
|
|
43
|
+
collectionDataLoading: boolean;
|
|
44
|
+
getCollectionData: (collectionName: string, search?: string, callback?: ((data: any) => void) | undefined, collectionItems?: string[]) => Promise<void>;
|
|
45
|
+
collectionData: any[];
|
|
46
|
+
itemsList: ItemsList;
|
|
47
|
+
itemsLoading: boolean;
|
|
48
|
+
onItemFormSubmit: (state: FormActionTypes, data: ObjectType, updateId?: string) => Promise<void>;
|
|
49
|
+
};
|
|
50
|
+
export default useWidget;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export type ACTION_TYPES = 'IMAGE_UPLOAD' | 'IMAGE_REMOVE' | 'CREATE' | 'LIST' | 'DELETE' | 'UPDATE' | 'ITEM' | 'PARTIAL_UPDATE' | 'WIDGET_TYPES' | 'SELECTION_TYPES' | 'COLLECTION_DATA';
|
|
2
|
+
export type API_TYPE = {
|
|
3
|
+
url: string;
|
|
4
|
+
method: string;
|
|
5
|
+
};
|
|
6
|
+
export type API_INPUT_TYPE = {
|
|
7
|
+
prefix: string;
|
|
8
|
+
id?: string;
|
|
9
|
+
};
|
|
10
|
+
export type Routes_Input = {
|
|
11
|
+
[K in ACTION_TYPES]?: (data: API_INPUT_TYPE) => API_TYPE;
|
|
12
|
+
};
|
|
13
|
+
export type ItemsType = {
|
|
14
|
+
value: string;
|
|
15
|
+
label: string;
|
|
16
|
+
};
|
|
17
|
+
export type WidgetType = {
|
|
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
|
+
}
|
|
30
|
+
export interface ResponseType {
|
|
31
|
+
message: string;
|
|
32
|
+
code: 'SUCCESS' | 'FAILED';
|
|
33
|
+
data: any;
|
|
34
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type FormActionTypes = 'ADD' | 'UPDATE' | 'DELETE' | null | '';
|
|
2
|
+
export type TFunc = (key: string) => string;
|
|
3
|
+
export 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 type ObjectType = {
|
|
15
|
+
[key: string]: string;
|
|
16
|
+
};
|
|
17
|
+
export type CombineObjectType = {
|
|
18
|
+
[key: string]: string | boolean | number | string[] | null | Record<string | number, CombineObjectType> | CombineObjectType | CombineObjectType[];
|
|
19
|
+
};
|
|
20
|
+
export type ValuesType = string | boolean | number | string[];
|
|
21
|
+
export interface SrcSetItem {
|
|
22
|
+
screenSize: number | string;
|
|
23
|
+
width: number | string;
|
|
24
|
+
height: number | string;
|
|
25
|
+
}
|