@knovator/pagecreator-admin 0.8.1 → 0.8.3
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/README.md
CHANGED
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
|
|
92
92
|
### Prerequisites
|
|
93
93
|
|
|
94
|
-
|
|
94
|
+
Create one reactjs/nextjs application if you don't have one,
|
|
95
95
|
* Project
|
|
96
96
|
```sh
|
|
97
97
|
npx create-react-app my-app
|
|
@@ -104,8 +104,7 @@ We can use `@knovator/pagecreator-admin` in React/Next application, we can creat
|
|
|
104
104
|
|
|
105
105
|
### Installation
|
|
106
106
|
|
|
107
|
-
|
|
108
|
-
1. Install NPM packages
|
|
107
|
+
1. Add pagecreator package
|
|
109
108
|
```sh
|
|
110
109
|
npm install @knovator/pagecreator-admin
|
|
111
110
|
# or
|
|
@@ -121,7 +120,7 @@ We can use `@knovator/pagecreator-admin` in React/Next application, we can creat
|
|
|
121
120
|
|
|
122
121
|
### Provider
|
|
123
122
|
|
|
124
|
-
`@knovator/pagecreator-admin` uses **Context API
|
|
123
|
+
In order to support communication between components `@knovator/pagecreator-admin` uses **Context API**. So, `Widget`/`Page` components should be wrapped by Provider.
|
|
125
124
|
```jsx
|
|
126
125
|
import { Provider } from '@knovator/pagecreator-admin';
|
|
127
126
|
|
package/index.cjs
CHANGED
|
@@ -2879,6 +2879,11 @@ const usePage = ({
|
|
|
2879
2879
|
}
|
|
2880
2880
|
}), [baseUrl, currentPageRef, limitRef, offsetRef, handleError, pageRoutesPrefix, routes, token]);
|
|
2881
2881
|
const onPageFormSubmit = data => __awaiter(void 0, void 0, void 0, function* () {
|
|
2882
|
+
if (selectedWidgets.length) {
|
|
2883
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2884
|
+
// @ts-ignore
|
|
2885
|
+
data.widgets = selectedWidgets.map(item => item.value);
|
|
2886
|
+
}
|
|
2882
2887
|
setLoading(true);
|
|
2883
2888
|
const code = formState === 'ADD' ? CALLBACK_CODES.CREATE : CALLBACK_CODES.UPDATE;
|
|
2884
2889
|
try {
|
|
@@ -2969,6 +2974,7 @@ const usePage = ({
|
|
|
2969
2974
|
}
|
|
2970
2975
|
};
|
|
2971
2976
|
const onChangeWidgetSequence = (sourceIndex, destinationIndex) => {
|
|
2977
|
+
console.log(sourceIndex, destinationIndex);
|
|
2972
2978
|
setSelectedWidgets(listData => {
|
|
2973
2979
|
const temporaryData = [...listData];
|
|
2974
2980
|
const [selectedRow] = temporaryData.splice(sourceIndex, 1);
|
|
@@ -6015,6 +6021,7 @@ const WidgetContextProvider = ({
|
|
|
6015
6021
|
loader: _loader = /*#__PURE__*/React__default["default"].createElement("span", null),
|
|
6016
6022
|
onPartialUpdateWidget: _onPartialUpdateWidget = () => Promise.resolve(),
|
|
6017
6023
|
reactSelectStyles: _reactSelectStyles = {},
|
|
6024
|
+
imageMaxSize: _imageMaxSize = 10485760,
|
|
6018
6025
|
// other
|
|
6019
6026
|
children
|
|
6020
6027
|
}) => {
|
|
@@ -6061,7 +6068,8 @@ const WidgetContextProvider = ({
|
|
|
6061
6068
|
columns: _columns,
|
|
6062
6069
|
data: _data,
|
|
6063
6070
|
canDelete: _canDelete,
|
|
6064
|
-
loader: _loader
|
|
6071
|
+
loader: _loader,
|
|
6072
|
+
imageMaxSize: _imageMaxSize
|
|
6065
6073
|
}
|
|
6066
6074
|
}, children);
|
|
6067
6075
|
};
|
|
@@ -6306,7 +6314,7 @@ const ImageUpload = ({
|
|
|
6306
6314
|
try {
|
|
6307
6315
|
if (typeof clearError === 'function') clearError();
|
|
6308
6316
|
if ((acceptedFiles === null || acceptedFiles === void 0 ? void 0 : acceptedFiles.length) > 0) {
|
|
6309
|
-
const regex = /\.(png|jpeg|jpg|webp|svg)$/gi;
|
|
6317
|
+
const regex = /\.(png|jpeg|jpg|webp|svg|gif)$/gi;
|
|
6310
6318
|
const files = acceptedFiles.filter(file => regex.test(file.name));
|
|
6311
6319
|
if (files[0]) {
|
|
6312
6320
|
const response = yield onImageUpload(files[0]);
|
|
@@ -6433,7 +6441,8 @@ const ItemsAccordian = ({
|
|
|
6433
6441
|
onImageUpload,
|
|
6434
6442
|
onImageRemove,
|
|
6435
6443
|
t,
|
|
6436
|
-
imageBaseUrl
|
|
6444
|
+
imageBaseUrl,
|
|
6445
|
+
imageMaxSize
|
|
6437
6446
|
} = useWidgetState();
|
|
6438
6447
|
const [itemsShow, setItemsShow] = React.useState([]);
|
|
6439
6448
|
const {
|
|
@@ -6555,7 +6564,7 @@ const ItemsAccordian = ({
|
|
|
6555
6564
|
return /*#__PURE__*/React__default["default"].createElement(ImageUpload$1, {
|
|
6556
6565
|
imgId: field.value,
|
|
6557
6566
|
clearError: () => clearError(`${name}.${index}.img`),
|
|
6558
|
-
maxSize:
|
|
6567
|
+
maxSize: imageMaxSize,
|
|
6559
6568
|
onError: msg => setError(`${name}.${index}.img`, {
|
|
6560
6569
|
type: 'custom',
|
|
6561
6570
|
message: msg
|
|
@@ -7299,6 +7308,7 @@ const Widget = ({
|
|
|
7299
7308
|
preConfirmDelete,
|
|
7300
7309
|
formatListItem,
|
|
7301
7310
|
formatOptionLabel,
|
|
7311
|
+
imageMaxSize,
|
|
7302
7312
|
children
|
|
7303
7313
|
}) => {
|
|
7304
7314
|
const derivedPermissions = Object.assign(DEFAULT_PERMISSIONS, _permissions);
|
|
@@ -7372,7 +7382,8 @@ const Widget = ({
|
|
|
7372
7382
|
canUpdate: derivedPermissions.update,
|
|
7373
7383
|
canPartialUpdate: derivedPermissions.partialUpdate,
|
|
7374
7384
|
formState: formState,
|
|
7375
|
-
closeForm: onCloseForm
|
|
7385
|
+
closeForm: onCloseForm,
|
|
7386
|
+
imageMaxSize: imageMaxSize
|
|
7376
7387
|
}, children ? children : /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(AddButton, null), /*#__PURE__*/React__default["default"].createElement(WidgetSearch, null), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
7377
7388
|
className: "khb_table-wrapper"
|
|
7378
7389
|
}, /*#__PURE__*/React__default["default"].createElement(WidgetTable, null), /*#__PURE__*/React__default["default"].createElement(WidgetPagination, null))), !_explicitForm && /*#__PURE__*/React__default["default"].createElement(Drawer, {
|
package/index.js
CHANGED
|
@@ -2867,6 +2867,11 @@ const usePage = ({
|
|
|
2867
2867
|
}
|
|
2868
2868
|
}), [baseUrl, currentPageRef, limitRef, offsetRef, handleError, pageRoutesPrefix, routes, token]);
|
|
2869
2869
|
const onPageFormSubmit = data => __awaiter(void 0, void 0, void 0, function* () {
|
|
2870
|
+
if (selectedWidgets.length) {
|
|
2871
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2872
|
+
// @ts-ignore
|
|
2873
|
+
data.widgets = selectedWidgets.map(item => item.value);
|
|
2874
|
+
}
|
|
2870
2875
|
setLoading(true);
|
|
2871
2876
|
const code = formState === 'ADD' ? CALLBACK_CODES.CREATE : CALLBACK_CODES.UPDATE;
|
|
2872
2877
|
try {
|
|
@@ -2957,6 +2962,7 @@ const usePage = ({
|
|
|
2957
2962
|
}
|
|
2958
2963
|
};
|
|
2959
2964
|
const onChangeWidgetSequence = (sourceIndex, destinationIndex) => {
|
|
2965
|
+
console.log(sourceIndex, destinationIndex);
|
|
2960
2966
|
setSelectedWidgets(listData => {
|
|
2961
2967
|
const temporaryData = [...listData];
|
|
2962
2968
|
const [selectedRow] = temporaryData.splice(sourceIndex, 1);
|
|
@@ -6003,6 +6009,7 @@ const WidgetContextProvider = ({
|
|
|
6003
6009
|
loader: _loader = /*#__PURE__*/React.createElement("span", null),
|
|
6004
6010
|
onPartialUpdateWidget: _onPartialUpdateWidget = () => Promise.resolve(),
|
|
6005
6011
|
reactSelectStyles: _reactSelectStyles = {},
|
|
6012
|
+
imageMaxSize: _imageMaxSize = 10485760,
|
|
6006
6013
|
// other
|
|
6007
6014
|
children
|
|
6008
6015
|
}) => {
|
|
@@ -6049,7 +6056,8 @@ const WidgetContextProvider = ({
|
|
|
6049
6056
|
columns: _columns,
|
|
6050
6057
|
data: _data,
|
|
6051
6058
|
canDelete: _canDelete,
|
|
6052
|
-
loader: _loader
|
|
6059
|
+
loader: _loader,
|
|
6060
|
+
imageMaxSize: _imageMaxSize
|
|
6053
6061
|
}
|
|
6054
6062
|
}, children);
|
|
6055
6063
|
};
|
|
@@ -6294,7 +6302,7 @@ const ImageUpload = ({
|
|
|
6294
6302
|
try {
|
|
6295
6303
|
if (typeof clearError === 'function') clearError();
|
|
6296
6304
|
if ((acceptedFiles === null || acceptedFiles === void 0 ? void 0 : acceptedFiles.length) > 0) {
|
|
6297
|
-
const regex = /\.(png|jpeg|jpg|webp|svg)$/gi;
|
|
6305
|
+
const regex = /\.(png|jpeg|jpg|webp|svg|gif)$/gi;
|
|
6298
6306
|
const files = acceptedFiles.filter(file => regex.test(file.name));
|
|
6299
6307
|
if (files[0]) {
|
|
6300
6308
|
const response = yield onImageUpload(files[0]);
|
|
@@ -6421,7 +6429,8 @@ const ItemsAccordian = ({
|
|
|
6421
6429
|
onImageUpload,
|
|
6422
6430
|
onImageRemove,
|
|
6423
6431
|
t,
|
|
6424
|
-
imageBaseUrl
|
|
6432
|
+
imageBaseUrl,
|
|
6433
|
+
imageMaxSize
|
|
6425
6434
|
} = useWidgetState();
|
|
6426
6435
|
const [itemsShow, setItemsShow] = useState([]);
|
|
6427
6436
|
const {
|
|
@@ -6543,7 +6552,7 @@ const ItemsAccordian = ({
|
|
|
6543
6552
|
return /*#__PURE__*/React.createElement(ImageUpload$1, {
|
|
6544
6553
|
imgId: field.value,
|
|
6545
6554
|
clearError: () => clearError(`${name}.${index}.img`),
|
|
6546
|
-
maxSize:
|
|
6555
|
+
maxSize: imageMaxSize,
|
|
6547
6556
|
onError: msg => setError(`${name}.${index}.img`, {
|
|
6548
6557
|
type: 'custom',
|
|
6549
6558
|
message: msg
|
|
@@ -7287,6 +7296,7 @@ const Widget = ({
|
|
|
7287
7296
|
preConfirmDelete,
|
|
7288
7297
|
formatListItem,
|
|
7289
7298
|
formatOptionLabel,
|
|
7299
|
+
imageMaxSize,
|
|
7290
7300
|
children
|
|
7291
7301
|
}) => {
|
|
7292
7302
|
const derivedPermissions = Object.assign(DEFAULT_PERMISSIONS, _permissions);
|
|
@@ -7360,7 +7370,8 @@ const Widget = ({
|
|
|
7360
7370
|
canUpdate: derivedPermissions.update,
|
|
7361
7371
|
canPartialUpdate: derivedPermissions.partialUpdate,
|
|
7362
7372
|
formState: formState,
|
|
7363
|
-
closeForm: onCloseForm
|
|
7373
|
+
closeForm: onCloseForm,
|
|
7374
|
+
imageMaxSize: imageMaxSize
|
|
7364
7375
|
}, children ? children : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(AddButton, null), /*#__PURE__*/React.createElement(WidgetSearch, null), /*#__PURE__*/React.createElement("div", {
|
|
7365
7376
|
className: "khb_table-wrapper"
|
|
7366
7377
|
}, /*#__PURE__*/React.createElement(WidgetTable, null), /*#__PURE__*/React.createElement(WidgetPagination, null))), !_explicitForm && /*#__PURE__*/React.createElement(Drawer, {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { WidgetProps } from '../../../types';
|
|
3
3
|
declare const Widget: {
|
|
4
|
-
({ t, routes, loader, explicitForm, imageBaseUrl, permissions, preConfirmDelete, formatListItem, formatOptionLabel, children, }: WidgetProps): JSX.Element;
|
|
4
|
+
({ t, routes, loader, explicitForm, imageBaseUrl, permissions, preConfirmDelete, formatListItem, formatOptionLabel, imageMaxSize, children, }: WidgetProps): JSX.Element;
|
|
5
5
|
Table: ({ extraActions, extraColumns }: import("../../../types").DerivedTableProps) => JSX.Element;
|
|
6
6
|
Form: ({ formRef, customInputs }: import("../../../types").FormProps) => JSX.Element | null;
|
|
7
7
|
AddButton: () => JSX.Element;
|
|
@@ -2,6 +2,6 @@ import React from 'react';
|
|
|
2
2
|
import { WidgetContextType } from '../types';
|
|
3
3
|
interface WidgetContextProviderProps extends React.PropsWithChildren, Partial<WidgetContextType> {
|
|
4
4
|
}
|
|
5
|
-
declare const WidgetContextProvider: ({ t, list, imageBaseUrl, searchText, changeSearch, 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, reactSelectStyles, children, }: WidgetContextProviderProps) => JSX.Element;
|
|
5
|
+
declare const WidgetContextProvider: ({ t, list, imageBaseUrl, searchText, changeSearch, 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, reactSelectStyles, imageMaxSize, children, }: WidgetContextProviderProps) => JSX.Element;
|
|
6
6
|
export declare function useWidgetState(): WidgetContextType;
|
|
7
7
|
export default WidgetContextProvider;
|