@knovator/pagecreator-admin 0.5.9 → 0.5.11
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 +59 -74
- package/index.css +0 -3
- package/index.js +59 -73
- package/package.json +2 -3
- package/src/lib/components/Page/Table/PageTable.d.ts +2 -1
- package/src/lib/components/Widget/Form/WidgetForm.d.ts +1 -1
- package/src/lib/components/Widget/Table/WidgetTable.d.ts +2 -1
- package/src/lib/components/Widget/Widget/Widget.d.ts +3 -3
- package/src/lib/components/common/Input/index.d.ts +1 -3
- package/src/lib/components/common/Table/Table.d.ts +1 -1
- package/src/lib/constants/common.d.ts +2 -0
- package/src/lib/context/WidgetContext.d.ts +1 -1
- package/src/lib/hooks/useWidget.d.ts +2 -1
- package/src/lib/types/components.d.ts +24 -0
- package/src/lib/types/context.d.ts +1 -0
- package/src/lib/components/common/Input/HTMLEditor.d.ts +0 -4
package/index.cjs
CHANGED
|
@@ -7,7 +7,6 @@ var fetchUrl = require('@knovator/api');
|
|
|
7
7
|
var classNames = require('classnames');
|
|
8
8
|
var ReactSelect = require('react-select/async');
|
|
9
9
|
var reactHookForm = require('react-hook-form');
|
|
10
|
-
var JoditEditor = require('jodit-react');
|
|
11
10
|
var reactBeautifulDnd = require('react-beautiful-dnd');
|
|
12
11
|
var CSSTransition = require('react-transition-group/CSSTransition');
|
|
13
12
|
var reactDropzone = require('react-dropzone');
|
|
@@ -20,7 +19,6 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
20
19
|
var fetchUrl__default = /*#__PURE__*/_interopDefaultLegacy(fetchUrl);
|
|
21
20
|
var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
|
|
22
21
|
var ReactSelect__default = /*#__PURE__*/_interopDefaultLegacy(ReactSelect);
|
|
23
|
-
var JoditEditor__default = /*#__PURE__*/_interopDefaultLegacy(JoditEditor);
|
|
24
22
|
var CSSTransition__default = /*#__PURE__*/_interopDefaultLegacy(CSSTransition);
|
|
25
23
|
|
|
26
24
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
@@ -1741,7 +1739,8 @@ const TRANSLATION_PAIRS_WIDGET = {
|
|
|
1741
1739
|
'widget.mobilePerRowRequired': 'Mobile Per Row is required',
|
|
1742
1740
|
'widget.tabDeleteTitle': 'Are you sure you want to delete this tab?',
|
|
1743
1741
|
'widget.widgetTitleInfo': 'HTML is supported',
|
|
1744
|
-
'widget.minPerRow': 'Value must be greater than zero'
|
|
1742
|
+
'widget.minPerRow': 'Value must be greater than zero',
|
|
1743
|
+
'widget.actionsLabel': 'Actions'
|
|
1745
1744
|
};
|
|
1746
1745
|
const TRANSLATION_PAIRS_ITEM = {
|
|
1747
1746
|
'item.title': 'Title',
|
|
@@ -1770,7 +1769,8 @@ const TRANSLATION_PAIRS_PAGE = {
|
|
|
1770
1769
|
'page.searchPages': 'Search Pages...',
|
|
1771
1770
|
'page.tableName': 'Name',
|
|
1772
1771
|
'page.tableCode': 'Code',
|
|
1773
|
-
'page.widgets': 'Widgets'
|
|
1772
|
+
'page.widgets': 'Widgets',
|
|
1773
|
+
'page.actionsLabel': 'Actions'
|
|
1774
1774
|
};
|
|
1775
1775
|
|
|
1776
1776
|
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
@@ -3090,7 +3090,10 @@ const Table = ({
|
|
|
3090
3090
|
dataKeys,
|
|
3091
3091
|
actions,
|
|
3092
3092
|
loader,
|
|
3093
|
-
loading
|
|
3093
|
+
loading,
|
|
3094
|
+
extraActions,
|
|
3095
|
+
actionsLabel,
|
|
3096
|
+
extraColumns
|
|
3094
3097
|
}) => {
|
|
3095
3098
|
const cellItemRenderer = (item, dataKey, index) => {
|
|
3096
3099
|
if (dataKey.highlight) return /*#__PURE__*/React__default["default"].createElement("th", {
|
|
@@ -3122,32 +3125,41 @@ const Table = ({
|
|
|
3122
3125
|
scope: "col",
|
|
3123
3126
|
className: "khb_table-heading",
|
|
3124
3127
|
key: i
|
|
3125
|
-
}, key.label)),
|
|
3128
|
+
}, key.label)), Array.isArray(extraColumns) ? extraColumns.map(action => /*#__PURE__*/React__default["default"].createElement("th", {
|
|
3126
3129
|
scope: "col",
|
|
3127
3130
|
className: "khb_table-heading"
|
|
3128
|
-
},
|
|
3131
|
+
}, action.label)) : null, actions && ((actions === null || actions === void 0 ? void 0 : actions.edit) || (actions === null || actions === void 0 ? void 0 : actions.delete)) || typeof extraActions === 'function' ? /*#__PURE__*/React__default["default"].createElement("th", {
|
|
3132
|
+
scope: "col",
|
|
3133
|
+
className: "khb_table-heading"
|
|
3134
|
+
}, actionsLabel) : null)), /*#__PURE__*/React__default["default"].createElement("tbody", {
|
|
3129
3135
|
className: "khb_tbody"
|
|
3130
3136
|
}, data.length > 0 ? data.map((item, i) => /*#__PURE__*/React__default["default"].createElement("tr", {
|
|
3131
3137
|
className: "khb_table-row",
|
|
3132
3138
|
key: item['id'] || item['_id'] || i
|
|
3133
|
-
}, dataKeys.map((key, j) => cellItemRenderer(item, key, j)),
|
|
3139
|
+
}, dataKeys.map((key, j) => cellItemRenderer(item, key, j)), Array.isArray(extraColumns) ? extraColumns.map(column => /*#__PURE__*/React__default["default"].createElement("td", {
|
|
3140
|
+
className: "khb_table-row-data",
|
|
3141
|
+
key: i
|
|
3142
|
+
}, column.Cell(item))) : null, actions && ((actions === null || actions === void 0 ? void 0 : actions.edit) || (actions === null || actions === void 0 ? void 0 : actions.delete)) || typeof extraActions === 'function' ? /*#__PURE__*/React__default["default"].createElement("td", {
|
|
3134
3143
|
className: "khb_table-row-actions"
|
|
3135
|
-
}, actions.edit && typeof actions.edit === 'function' ? /*#__PURE__*/React__default["default"].createElement("button", {
|
|
3144
|
+
}, actions && actions.edit && typeof actions.edit === 'function' ? /*#__PURE__*/React__default["default"].createElement("button", {
|
|
3136
3145
|
className: "khb_actions-update",
|
|
3137
3146
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3138
3147
|
// @ts-ignore
|
|
3139
3148
|
onClick: () => actions.edit(item)
|
|
3140
|
-
}, /*#__PURE__*/React__default["default"].createElement(Pencil, null)) : null, actions.delete && typeof actions.delete === 'function' && /*#__PURE__*/React__default["default"].createElement("button", {
|
|
3149
|
+
}, /*#__PURE__*/React__default["default"].createElement(Pencil, null)) : null, actions && actions.delete && typeof actions.delete === 'function' && /*#__PURE__*/React__default["default"].createElement("button", {
|
|
3141
3150
|
className: "khb_actions-delete",
|
|
3142
3151
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3143
3152
|
// @ts-ignore
|
|
3144
3153
|
onClick: () => actions.delete(item)
|
|
3145
|
-
}, /*#__PURE__*/React__default["default"].createElement(Trash, null))))) : /*#__PURE__*/React__default["default"].createElement("tr", null, /*#__PURE__*/React__default["default"].createElement("td", {
|
|
3154
|
+
}, /*#__PURE__*/React__default["default"].createElement(Trash, null)), typeof extraActions === 'function' ? extraActions(item) : null) : null)) : /*#__PURE__*/React__default["default"].createElement("tr", null, /*#__PURE__*/React__default["default"].createElement("td", {
|
|
3146
3155
|
colSpan: ((dataKeys === null || dataKeys === void 0 ? void 0 : dataKeys.length) || 0) + 1
|
|
3147
3156
|
}, "No data found"))))));
|
|
3148
3157
|
};
|
|
3149
3158
|
|
|
3150
|
-
const PageTable = (
|
|
3159
|
+
const PageTable = ({
|
|
3160
|
+
extraActions,
|
|
3161
|
+
extraColumns
|
|
3162
|
+
}) => {
|
|
3151
3163
|
const {
|
|
3152
3164
|
list,
|
|
3153
3165
|
onChangeFormState,
|
|
@@ -3171,10 +3183,13 @@ const PageTable = () => {
|
|
|
3171
3183
|
label: t('page.tableCode'),
|
|
3172
3184
|
dataKey: 'code'
|
|
3173
3185
|
}],
|
|
3186
|
+
actionsLabel: t('page.actionsLabel'),
|
|
3174
3187
|
actions: {
|
|
3175
3188
|
edit: canUpdate ? onUpdateClick : undefined,
|
|
3176
3189
|
delete: canDelete ? onDeleteClick : undefined
|
|
3177
|
-
}
|
|
3190
|
+
},
|
|
3191
|
+
extraColumns: extraColumns,
|
|
3192
|
+
extraActions: extraActions
|
|
3178
3193
|
});
|
|
3179
3194
|
};
|
|
3180
3195
|
|
|
@@ -3473,38 +3488,11 @@ const SrcSet = ({
|
|
|
3473
3488
|
}, error));
|
|
3474
3489
|
};
|
|
3475
3490
|
|
|
3476
|
-
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
3477
|
-
const App = ({
|
|
3478
|
-
label,
|
|
3479
|
-
wrapperClassName,
|
|
3480
|
-
required,
|
|
3481
|
-
value,
|
|
3482
|
-
error,
|
|
3483
|
-
onChange
|
|
3484
|
-
}) => {
|
|
3485
|
-
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
3486
|
-
className: classNames__default["default"]('khb_input-wrapper', wrapperClassName)
|
|
3487
|
-
}, label && /*#__PURE__*/React__default["default"].createElement("label", {
|
|
3488
|
-
className: "khb_input-label"
|
|
3489
|
-
}, label, required ? /*#__PURE__*/React__default["default"].createElement("span", {
|
|
3490
|
-
className: "khb_input-label-required"
|
|
3491
|
-
}, "*") : null), /*#__PURE__*/React__default["default"].createElement(JoditEditor__default["default"], {
|
|
3492
|
-
value: value || '',
|
|
3493
|
-
config: {
|
|
3494
|
-
buttons: ['bold', 'italic', 'align', 'brush', 'undo', 'redo']
|
|
3495
|
-
},
|
|
3496
|
-
onBlur: newContent => onChange(newContent)
|
|
3497
|
-
}), error && /*#__PURE__*/React__default["default"].createElement("p", {
|
|
3498
|
-
className: "khb_input-error "
|
|
3499
|
-
}, error));
|
|
3500
|
-
};
|
|
3501
|
-
|
|
3502
3491
|
var Input = Object.assign(Input$1, {
|
|
3503
3492
|
Select,
|
|
3504
3493
|
ReactSelect: CustomReactSelect,
|
|
3505
3494
|
Checkbox,
|
|
3506
|
-
SrcSet
|
|
3507
|
-
HTML: App
|
|
3495
|
+
SrcSet
|
|
3508
3496
|
});
|
|
3509
3497
|
|
|
3510
3498
|
const PageSearch = () => {
|
|
@@ -3923,26 +3911,6 @@ const SimpleForm = /*#__PURE__*/React.forwardRef(({
|
|
|
3923
3911
|
}
|
|
3924
3912
|
});
|
|
3925
3913
|
break;
|
|
3926
|
-
case 'html':
|
|
3927
|
-
input = /*#__PURE__*/React__default["default"].createElement(reactHookForm.Controller, {
|
|
3928
|
-
control: control,
|
|
3929
|
-
name: schema.accessor,
|
|
3930
|
-
rules: schema.validations,
|
|
3931
|
-
render: ({
|
|
3932
|
-
field
|
|
3933
|
-
}) => {
|
|
3934
|
-
var _a, _b;
|
|
3935
|
-
return /*#__PURE__*/React__default["default"].createElement(Input.HTML, {
|
|
3936
|
-
label: schema.label,
|
|
3937
|
-
error: (_b = (_a = errors[schema.accessor]) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.toString(),
|
|
3938
|
-
onInput: schema.onInput,
|
|
3939
|
-
required: schema.required,
|
|
3940
|
-
value: field.value,
|
|
3941
|
-
onChange: field.onChange
|
|
3942
|
-
});
|
|
3943
|
-
}
|
|
3944
|
-
});
|
|
3945
|
-
break;
|
|
3946
3914
|
case 'text':
|
|
3947
3915
|
case 'number':
|
|
3948
3916
|
case 'url':
|
|
@@ -3965,10 +3933,12 @@ const SimpleForm = /*#__PURE__*/React.forwardRef(({
|
|
|
3965
3933
|
}
|
|
3966
3934
|
} else if (schema.Input) {
|
|
3967
3935
|
input = /*#__PURE__*/React__default["default"].createElement("div", {
|
|
3968
|
-
className: "
|
|
3969
|
-
}, /*#__PURE__*/React__default["default"].createElement("label", {
|
|
3970
|
-
className: "
|
|
3971
|
-
}, schema.label
|
|
3936
|
+
className: classNames__default["default"]('khb_input-wrapper', schema.wrapperClassName)
|
|
3937
|
+
}, schema.label && /*#__PURE__*/React__default["default"].createElement("label", {
|
|
3938
|
+
className: "khb_input-label"
|
|
3939
|
+
}, schema.label, schema.required ? /*#__PURE__*/React__default["default"].createElement("span", {
|
|
3940
|
+
className: "khb_input-label-required"
|
|
3941
|
+
}, "*") : null), /*#__PURE__*/React__default["default"].createElement(reactHookForm.Controller, {
|
|
3972
3942
|
control: control,
|
|
3973
3943
|
name: schema.accessor,
|
|
3974
3944
|
rules: schema.validations,
|
|
@@ -4604,7 +4574,8 @@ const useWidget = ({
|
|
|
4604
4574
|
canList: _canList = true,
|
|
4605
4575
|
defaultLimit,
|
|
4606
4576
|
routes,
|
|
4607
|
-
preConfirmDelete
|
|
4577
|
+
preConfirmDelete,
|
|
4578
|
+
imageBaseUrl
|
|
4608
4579
|
}) => {
|
|
4609
4580
|
const [list, setList] = React.useState([]);
|
|
4610
4581
|
const [itemsList, setItemsList] = React.useState({
|
|
@@ -5001,7 +4972,7 @@ const useWidget = ({
|
|
|
5001
4972
|
const responseData = (response === null || response === void 0 ? void 0 : response.data[0]) || (response === null || response === void 0 ? void 0 : response.data);
|
|
5002
4973
|
return {
|
|
5003
4974
|
fileId: (responseData === null || responseData === void 0 ? void 0 : responseData._id) || (responseData === null || responseData === void 0 ? void 0 : responseData.id),
|
|
5004
|
-
fileUrl: build_path(baseUrl, responseData === null || responseData === void 0 ? void 0 : responseData.uri),
|
|
4975
|
+
fileUrl: build_path(imageBaseUrl ? imageBaseUrl : baseUrl, responseData === null || responseData === void 0 ? void 0 : responseData.uri),
|
|
5005
4976
|
fileUri: responseData === null || responseData === void 0 ? void 0 : responseData.uri
|
|
5006
4977
|
};
|
|
5007
4978
|
} else onError(CALLBACK_CODES.IMAGE_REMOVE, response.code, response.message);
|
|
@@ -6154,6 +6125,7 @@ const WidgetContextProvider = ({
|
|
|
6154
6125
|
t: _t = () => '',
|
|
6155
6126
|
// Form
|
|
6156
6127
|
list: _list = [],
|
|
6128
|
+
imageBaseUrl: _imageBaseUrl = '',
|
|
6157
6129
|
searchText: _searchText = '',
|
|
6158
6130
|
changeSearch: _changeSearch = () => {},
|
|
6159
6131
|
formState: _formState = '',
|
|
@@ -6205,6 +6177,7 @@ const WidgetContextProvider = ({
|
|
|
6205
6177
|
t: _t,
|
|
6206
6178
|
// Form
|
|
6207
6179
|
list: _list,
|
|
6180
|
+
imageBaseUrl: _imageBaseUrl,
|
|
6208
6181
|
closeForm: _closeForm,
|
|
6209
6182
|
formState: _formState,
|
|
6210
6183
|
loading: _loading,
|
|
@@ -6276,7 +6249,10 @@ const Toggle = ({
|
|
|
6276
6249
|
}));
|
|
6277
6250
|
};
|
|
6278
6251
|
|
|
6279
|
-
const WidgetTable = (
|
|
6252
|
+
const WidgetTable = ({
|
|
6253
|
+
extraActions,
|
|
6254
|
+
extraColumns
|
|
6255
|
+
}) => {
|
|
6280
6256
|
const {
|
|
6281
6257
|
switchClass
|
|
6282
6258
|
} = useProviderState();
|
|
@@ -6322,6 +6298,9 @@ const WidgetTable = () => {
|
|
|
6322
6298
|
loader: loader,
|
|
6323
6299
|
loading: loading,
|
|
6324
6300
|
dataKeys: dataKeys,
|
|
6301
|
+
actionsLabel: t('widget.actionsLabel'),
|
|
6302
|
+
extraColumns: extraColumns,
|
|
6303
|
+
extraActions: extraActions,
|
|
6325
6304
|
actions: {
|
|
6326
6305
|
edit: canUpdate ? onUpdateClick : false,
|
|
6327
6306
|
delete: canDelete ? onDeleteClick : false
|
|
@@ -6851,7 +6830,8 @@ const constants = {
|
|
|
6851
6830
|
tabCollectionItemsAccessor: 'collectionItems'
|
|
6852
6831
|
};
|
|
6853
6832
|
const WidgetForm = ({
|
|
6854
|
-
formRef
|
|
6833
|
+
formRef,
|
|
6834
|
+
customInputs
|
|
6855
6835
|
}) => {
|
|
6856
6836
|
const {
|
|
6857
6837
|
register,
|
|
@@ -6892,7 +6872,8 @@ const WidgetForm = ({
|
|
|
6892
6872
|
collectionDataLoading,
|
|
6893
6873
|
formatListItem,
|
|
6894
6874
|
formatOptionLabel,
|
|
6895
|
-
reactSelectStyles
|
|
6875
|
+
reactSelectStyles,
|
|
6876
|
+
imageBaseUrl
|
|
6896
6877
|
} = useWidgetState();
|
|
6897
6878
|
const callerRef = React.useRef(null);
|
|
6898
6879
|
const [activeTab, setActiveTab] = React.useState(0);
|
|
@@ -7095,13 +7076,14 @@ const WidgetForm = ({
|
|
|
7095
7076
|
label: `${t('widget.widgetTitle')}`,
|
|
7096
7077
|
accessor: 'widgetTitle',
|
|
7097
7078
|
required: true,
|
|
7098
|
-
type: '
|
|
7079
|
+
type: customInputs && customInputs['widgetTitle'] ? undefined : 'text',
|
|
7099
7080
|
onInput: handleCapitalize,
|
|
7100
7081
|
placeholder: t('widget.widgetTitlePlaceholder'),
|
|
7101
7082
|
validations: {
|
|
7102
7083
|
required: t('widget.widgetTitleRequired')
|
|
7103
7084
|
},
|
|
7104
|
-
info: t('widget.widgetTitleInfo')
|
|
7085
|
+
info: t('widget.widgetTitleInfo'),
|
|
7086
|
+
Input: customInputs && customInputs['widgetTitle'] ? customInputs['widgetTitle'] : undefined
|
|
7105
7087
|
}, {
|
|
7106
7088
|
label: `${t('widget.widgetType')}`,
|
|
7107
7089
|
required: true,
|
|
@@ -7236,7 +7218,7 @@ const WidgetForm = ({
|
|
|
7236
7218
|
setImgId: value => {
|
|
7237
7219
|
field.onChange(value);
|
|
7238
7220
|
},
|
|
7239
|
-
baseUrl: baseUrl,
|
|
7221
|
+
baseUrl: imageBaseUrl ? imageBaseUrl : baseUrl,
|
|
7240
7222
|
disabled: disabled,
|
|
7241
7223
|
text: /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
7242
7224
|
className: "khb_img-text-wrapper"
|
|
@@ -7443,6 +7425,7 @@ const Widget = ({
|
|
|
7443
7425
|
routes,
|
|
7444
7426
|
loader,
|
|
7445
7427
|
explicitForm: _explicitForm = false,
|
|
7428
|
+
imageBaseUrl,
|
|
7446
7429
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
7447
7430
|
// @ts-ignore
|
|
7448
7431
|
permissions: _permissions = {},
|
|
@@ -7489,11 +7472,13 @@ const Widget = ({
|
|
|
7489
7472
|
canList: derivedPermissions.list,
|
|
7490
7473
|
routes,
|
|
7491
7474
|
defaultLimit: 10,
|
|
7492
|
-
preConfirmDelete
|
|
7475
|
+
preConfirmDelete,
|
|
7476
|
+
imageBaseUrl
|
|
7493
7477
|
});
|
|
7494
7478
|
return /*#__PURE__*/React__default["default"].createElement(WidgetContextProvider, {
|
|
7495
7479
|
loading: loading,
|
|
7496
7480
|
list: list,
|
|
7481
|
+
imageBaseUrl: imageBaseUrl,
|
|
7497
7482
|
onChangeFormState: onChangeFormState,
|
|
7498
7483
|
t: derivedT,
|
|
7499
7484
|
searchText: searchText,
|
package/index.css
CHANGED
package/index.js
CHANGED
|
@@ -3,7 +3,6 @@ import fetchUrl, { setAPIConfig } from '@knovator/api';
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import ReactSelect from 'react-select/async';
|
|
5
5
|
import { useFieldArray, useForm, Controller } from 'react-hook-form';
|
|
6
|
-
import JoditEditor from 'jodit-react';
|
|
7
6
|
import { DragDropContext, Droppable, Draggable } from 'react-beautiful-dnd';
|
|
8
7
|
import CSSTransition from 'react-transition-group/CSSTransition';
|
|
9
8
|
import { useDropzone } from 'react-dropzone';
|
|
@@ -1728,7 +1727,8 @@ const TRANSLATION_PAIRS_WIDGET = {
|
|
|
1728
1727
|
'widget.mobilePerRowRequired': 'Mobile Per Row is required',
|
|
1729
1728
|
'widget.tabDeleteTitle': 'Are you sure you want to delete this tab?',
|
|
1730
1729
|
'widget.widgetTitleInfo': 'HTML is supported',
|
|
1731
|
-
'widget.minPerRow': 'Value must be greater than zero'
|
|
1730
|
+
'widget.minPerRow': 'Value must be greater than zero',
|
|
1731
|
+
'widget.actionsLabel': 'Actions'
|
|
1732
1732
|
};
|
|
1733
1733
|
const TRANSLATION_PAIRS_ITEM = {
|
|
1734
1734
|
'item.title': 'Title',
|
|
@@ -1757,7 +1757,8 @@ const TRANSLATION_PAIRS_PAGE = {
|
|
|
1757
1757
|
'page.searchPages': 'Search Pages...',
|
|
1758
1758
|
'page.tableName': 'Name',
|
|
1759
1759
|
'page.tableCode': 'Code',
|
|
1760
|
-
'page.widgets': 'Widgets'
|
|
1760
|
+
'page.widgets': 'Widgets',
|
|
1761
|
+
'page.actionsLabel': 'Actions'
|
|
1761
1762
|
};
|
|
1762
1763
|
|
|
1763
1764
|
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
@@ -3077,7 +3078,10 @@ const Table = ({
|
|
|
3077
3078
|
dataKeys,
|
|
3078
3079
|
actions,
|
|
3079
3080
|
loader,
|
|
3080
|
-
loading
|
|
3081
|
+
loading,
|
|
3082
|
+
extraActions,
|
|
3083
|
+
actionsLabel,
|
|
3084
|
+
extraColumns
|
|
3081
3085
|
}) => {
|
|
3082
3086
|
const cellItemRenderer = (item, dataKey, index) => {
|
|
3083
3087
|
if (dataKey.highlight) return /*#__PURE__*/React.createElement("th", {
|
|
@@ -3109,32 +3113,41 @@ const Table = ({
|
|
|
3109
3113
|
scope: "col",
|
|
3110
3114
|
className: "khb_table-heading",
|
|
3111
3115
|
key: i
|
|
3112
|
-
}, key.label)),
|
|
3116
|
+
}, key.label)), Array.isArray(extraColumns) ? extraColumns.map(action => /*#__PURE__*/React.createElement("th", {
|
|
3113
3117
|
scope: "col",
|
|
3114
3118
|
className: "khb_table-heading"
|
|
3115
|
-
},
|
|
3119
|
+
}, action.label)) : null, actions && ((actions === null || actions === void 0 ? void 0 : actions.edit) || (actions === null || actions === void 0 ? void 0 : actions.delete)) || typeof extraActions === 'function' ? /*#__PURE__*/React.createElement("th", {
|
|
3120
|
+
scope: "col",
|
|
3121
|
+
className: "khb_table-heading"
|
|
3122
|
+
}, actionsLabel) : null)), /*#__PURE__*/React.createElement("tbody", {
|
|
3116
3123
|
className: "khb_tbody"
|
|
3117
3124
|
}, data.length > 0 ? data.map((item, i) => /*#__PURE__*/React.createElement("tr", {
|
|
3118
3125
|
className: "khb_table-row",
|
|
3119
3126
|
key: item['id'] || item['_id'] || i
|
|
3120
|
-
}, dataKeys.map((key, j) => cellItemRenderer(item, key, j)),
|
|
3127
|
+
}, dataKeys.map((key, j) => cellItemRenderer(item, key, j)), Array.isArray(extraColumns) ? extraColumns.map(column => /*#__PURE__*/React.createElement("td", {
|
|
3128
|
+
className: "khb_table-row-data",
|
|
3129
|
+
key: i
|
|
3130
|
+
}, column.Cell(item))) : null, actions && ((actions === null || actions === void 0 ? void 0 : actions.edit) || (actions === null || actions === void 0 ? void 0 : actions.delete)) || typeof extraActions === 'function' ? /*#__PURE__*/React.createElement("td", {
|
|
3121
3131
|
className: "khb_table-row-actions"
|
|
3122
|
-
}, actions.edit && typeof actions.edit === 'function' ? /*#__PURE__*/React.createElement("button", {
|
|
3132
|
+
}, actions && actions.edit && typeof actions.edit === 'function' ? /*#__PURE__*/React.createElement("button", {
|
|
3123
3133
|
className: "khb_actions-update",
|
|
3124
3134
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3125
3135
|
// @ts-ignore
|
|
3126
3136
|
onClick: () => actions.edit(item)
|
|
3127
|
-
}, /*#__PURE__*/React.createElement(Pencil, null)) : null, actions.delete && typeof actions.delete === 'function' && /*#__PURE__*/React.createElement("button", {
|
|
3137
|
+
}, /*#__PURE__*/React.createElement(Pencil, null)) : null, actions && actions.delete && typeof actions.delete === 'function' && /*#__PURE__*/React.createElement("button", {
|
|
3128
3138
|
className: "khb_actions-delete",
|
|
3129
3139
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3130
3140
|
// @ts-ignore
|
|
3131
3141
|
onClick: () => actions.delete(item)
|
|
3132
|
-
}, /*#__PURE__*/React.createElement(Trash, null))))) : /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
|
|
3142
|
+
}, /*#__PURE__*/React.createElement(Trash, null)), typeof extraActions === 'function' ? extraActions(item) : null) : null)) : /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
|
|
3133
3143
|
colSpan: ((dataKeys === null || dataKeys === void 0 ? void 0 : dataKeys.length) || 0) + 1
|
|
3134
3144
|
}, "No data found"))))));
|
|
3135
3145
|
};
|
|
3136
3146
|
|
|
3137
|
-
const PageTable = (
|
|
3147
|
+
const PageTable = ({
|
|
3148
|
+
extraActions,
|
|
3149
|
+
extraColumns
|
|
3150
|
+
}) => {
|
|
3138
3151
|
const {
|
|
3139
3152
|
list,
|
|
3140
3153
|
onChangeFormState,
|
|
@@ -3158,10 +3171,13 @@ const PageTable = () => {
|
|
|
3158
3171
|
label: t('page.tableCode'),
|
|
3159
3172
|
dataKey: 'code'
|
|
3160
3173
|
}],
|
|
3174
|
+
actionsLabel: t('page.actionsLabel'),
|
|
3161
3175
|
actions: {
|
|
3162
3176
|
edit: canUpdate ? onUpdateClick : undefined,
|
|
3163
3177
|
delete: canDelete ? onDeleteClick : undefined
|
|
3164
|
-
}
|
|
3178
|
+
},
|
|
3179
|
+
extraColumns: extraColumns,
|
|
3180
|
+
extraActions: extraActions
|
|
3165
3181
|
});
|
|
3166
3182
|
};
|
|
3167
3183
|
|
|
@@ -3460,38 +3476,11 @@ const SrcSet = ({
|
|
|
3460
3476
|
}, error));
|
|
3461
3477
|
};
|
|
3462
3478
|
|
|
3463
|
-
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
3464
|
-
const App = ({
|
|
3465
|
-
label,
|
|
3466
|
-
wrapperClassName,
|
|
3467
|
-
required,
|
|
3468
|
-
value,
|
|
3469
|
-
error,
|
|
3470
|
-
onChange
|
|
3471
|
-
}) => {
|
|
3472
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
3473
|
-
className: classNames('khb_input-wrapper', wrapperClassName)
|
|
3474
|
-
}, label && /*#__PURE__*/React.createElement("label", {
|
|
3475
|
-
className: "khb_input-label"
|
|
3476
|
-
}, label, required ? /*#__PURE__*/React.createElement("span", {
|
|
3477
|
-
className: "khb_input-label-required"
|
|
3478
|
-
}, "*") : null), /*#__PURE__*/React.createElement(JoditEditor, {
|
|
3479
|
-
value: value || '',
|
|
3480
|
-
config: {
|
|
3481
|
-
buttons: ['bold', 'italic', 'align', 'brush', 'undo', 'redo']
|
|
3482
|
-
},
|
|
3483
|
-
onBlur: newContent => onChange(newContent)
|
|
3484
|
-
}), error && /*#__PURE__*/React.createElement("p", {
|
|
3485
|
-
className: "khb_input-error "
|
|
3486
|
-
}, error));
|
|
3487
|
-
};
|
|
3488
|
-
|
|
3489
3479
|
var Input = Object.assign(Input$1, {
|
|
3490
3480
|
Select,
|
|
3491
3481
|
ReactSelect: CustomReactSelect,
|
|
3492
3482
|
Checkbox,
|
|
3493
|
-
SrcSet
|
|
3494
|
-
HTML: App
|
|
3483
|
+
SrcSet
|
|
3495
3484
|
});
|
|
3496
3485
|
|
|
3497
3486
|
const PageSearch = () => {
|
|
@@ -3910,26 +3899,6 @@ const SimpleForm = /*#__PURE__*/forwardRef(({
|
|
|
3910
3899
|
}
|
|
3911
3900
|
});
|
|
3912
3901
|
break;
|
|
3913
|
-
case 'html':
|
|
3914
|
-
input = /*#__PURE__*/React.createElement(Controller, {
|
|
3915
|
-
control: control,
|
|
3916
|
-
name: schema.accessor,
|
|
3917
|
-
rules: schema.validations,
|
|
3918
|
-
render: ({
|
|
3919
|
-
field
|
|
3920
|
-
}) => {
|
|
3921
|
-
var _a, _b;
|
|
3922
|
-
return /*#__PURE__*/React.createElement(Input.HTML, {
|
|
3923
|
-
label: schema.label,
|
|
3924
|
-
error: (_b = (_a = errors[schema.accessor]) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.toString(),
|
|
3925
|
-
onInput: schema.onInput,
|
|
3926
|
-
required: schema.required,
|
|
3927
|
-
value: field.value,
|
|
3928
|
-
onChange: field.onChange
|
|
3929
|
-
});
|
|
3930
|
-
}
|
|
3931
|
-
});
|
|
3932
|
-
break;
|
|
3933
3902
|
case 'text':
|
|
3934
3903
|
case 'number':
|
|
3935
3904
|
case 'url':
|
|
@@ -3952,10 +3921,12 @@ const SimpleForm = /*#__PURE__*/forwardRef(({
|
|
|
3952
3921
|
}
|
|
3953
3922
|
} else if (schema.Input) {
|
|
3954
3923
|
input = /*#__PURE__*/React.createElement("div", {
|
|
3955
|
-
className:
|
|
3956
|
-
}, /*#__PURE__*/React.createElement("label", {
|
|
3957
|
-
className: "
|
|
3958
|
-
}, schema.label
|
|
3924
|
+
className: classNames('khb_input-wrapper', schema.wrapperClassName)
|
|
3925
|
+
}, schema.label && /*#__PURE__*/React.createElement("label", {
|
|
3926
|
+
className: "khb_input-label"
|
|
3927
|
+
}, schema.label, schema.required ? /*#__PURE__*/React.createElement("span", {
|
|
3928
|
+
className: "khb_input-label-required"
|
|
3929
|
+
}, "*") : null), /*#__PURE__*/React.createElement(Controller, {
|
|
3959
3930
|
control: control,
|
|
3960
3931
|
name: schema.accessor,
|
|
3961
3932
|
rules: schema.validations,
|
|
@@ -4591,7 +4562,8 @@ const useWidget = ({
|
|
|
4591
4562
|
canList: _canList = true,
|
|
4592
4563
|
defaultLimit,
|
|
4593
4564
|
routes,
|
|
4594
|
-
preConfirmDelete
|
|
4565
|
+
preConfirmDelete,
|
|
4566
|
+
imageBaseUrl
|
|
4595
4567
|
}) => {
|
|
4596
4568
|
const [list, setList] = useState([]);
|
|
4597
4569
|
const [itemsList, setItemsList] = useState({
|
|
@@ -4988,7 +4960,7 @@ const useWidget = ({
|
|
|
4988
4960
|
const responseData = (response === null || response === void 0 ? void 0 : response.data[0]) || (response === null || response === void 0 ? void 0 : response.data);
|
|
4989
4961
|
return {
|
|
4990
4962
|
fileId: (responseData === null || responseData === void 0 ? void 0 : responseData._id) || (responseData === null || responseData === void 0 ? void 0 : responseData.id),
|
|
4991
|
-
fileUrl: build_path(baseUrl, responseData === null || responseData === void 0 ? void 0 : responseData.uri),
|
|
4963
|
+
fileUrl: build_path(imageBaseUrl ? imageBaseUrl : baseUrl, responseData === null || responseData === void 0 ? void 0 : responseData.uri),
|
|
4992
4964
|
fileUri: responseData === null || responseData === void 0 ? void 0 : responseData.uri
|
|
4993
4965
|
};
|
|
4994
4966
|
} else onError(CALLBACK_CODES.IMAGE_REMOVE, response.code, response.message);
|
|
@@ -6141,6 +6113,7 @@ const WidgetContextProvider = ({
|
|
|
6141
6113
|
t: _t = () => '',
|
|
6142
6114
|
// Form
|
|
6143
6115
|
list: _list = [],
|
|
6116
|
+
imageBaseUrl: _imageBaseUrl = '',
|
|
6144
6117
|
searchText: _searchText = '',
|
|
6145
6118
|
changeSearch: _changeSearch = () => {},
|
|
6146
6119
|
formState: _formState = '',
|
|
@@ -6192,6 +6165,7 @@ const WidgetContextProvider = ({
|
|
|
6192
6165
|
t: _t,
|
|
6193
6166
|
// Form
|
|
6194
6167
|
list: _list,
|
|
6168
|
+
imageBaseUrl: _imageBaseUrl,
|
|
6195
6169
|
closeForm: _closeForm,
|
|
6196
6170
|
formState: _formState,
|
|
6197
6171
|
loading: _loading,
|
|
@@ -6263,7 +6237,10 @@ const Toggle = ({
|
|
|
6263
6237
|
}));
|
|
6264
6238
|
};
|
|
6265
6239
|
|
|
6266
|
-
const WidgetTable = (
|
|
6240
|
+
const WidgetTable = ({
|
|
6241
|
+
extraActions,
|
|
6242
|
+
extraColumns
|
|
6243
|
+
}) => {
|
|
6267
6244
|
const {
|
|
6268
6245
|
switchClass
|
|
6269
6246
|
} = useProviderState();
|
|
@@ -6309,6 +6286,9 @@ const WidgetTable = () => {
|
|
|
6309
6286
|
loader: loader,
|
|
6310
6287
|
loading: loading,
|
|
6311
6288
|
dataKeys: dataKeys,
|
|
6289
|
+
actionsLabel: t('widget.actionsLabel'),
|
|
6290
|
+
extraColumns: extraColumns,
|
|
6291
|
+
extraActions: extraActions,
|
|
6312
6292
|
actions: {
|
|
6313
6293
|
edit: canUpdate ? onUpdateClick : false,
|
|
6314
6294
|
delete: canDelete ? onDeleteClick : false
|
|
@@ -6838,7 +6818,8 @@ const constants = {
|
|
|
6838
6818
|
tabCollectionItemsAccessor: 'collectionItems'
|
|
6839
6819
|
};
|
|
6840
6820
|
const WidgetForm = ({
|
|
6841
|
-
formRef
|
|
6821
|
+
formRef,
|
|
6822
|
+
customInputs
|
|
6842
6823
|
}) => {
|
|
6843
6824
|
const {
|
|
6844
6825
|
register,
|
|
@@ -6879,7 +6860,8 @@ const WidgetForm = ({
|
|
|
6879
6860
|
collectionDataLoading,
|
|
6880
6861
|
formatListItem,
|
|
6881
6862
|
formatOptionLabel,
|
|
6882
|
-
reactSelectStyles
|
|
6863
|
+
reactSelectStyles,
|
|
6864
|
+
imageBaseUrl
|
|
6883
6865
|
} = useWidgetState();
|
|
6884
6866
|
const callerRef = useRef(null);
|
|
6885
6867
|
const [activeTab, setActiveTab] = useState(0);
|
|
@@ -7082,13 +7064,14 @@ const WidgetForm = ({
|
|
|
7082
7064
|
label: `${t('widget.widgetTitle')}`,
|
|
7083
7065
|
accessor: 'widgetTitle',
|
|
7084
7066
|
required: true,
|
|
7085
|
-
type: '
|
|
7067
|
+
type: customInputs && customInputs['widgetTitle'] ? undefined : 'text',
|
|
7086
7068
|
onInput: handleCapitalize,
|
|
7087
7069
|
placeholder: t('widget.widgetTitlePlaceholder'),
|
|
7088
7070
|
validations: {
|
|
7089
7071
|
required: t('widget.widgetTitleRequired')
|
|
7090
7072
|
},
|
|
7091
|
-
info: t('widget.widgetTitleInfo')
|
|
7073
|
+
info: t('widget.widgetTitleInfo'),
|
|
7074
|
+
Input: customInputs && customInputs['widgetTitle'] ? customInputs['widgetTitle'] : undefined
|
|
7092
7075
|
}, {
|
|
7093
7076
|
label: `${t('widget.widgetType')}`,
|
|
7094
7077
|
required: true,
|
|
@@ -7223,7 +7206,7 @@ const WidgetForm = ({
|
|
|
7223
7206
|
setImgId: value => {
|
|
7224
7207
|
field.onChange(value);
|
|
7225
7208
|
},
|
|
7226
|
-
baseUrl: baseUrl,
|
|
7209
|
+
baseUrl: imageBaseUrl ? imageBaseUrl : baseUrl,
|
|
7227
7210
|
disabled: disabled,
|
|
7228
7211
|
text: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
7229
7212
|
className: "khb_img-text-wrapper"
|
|
@@ -7430,6 +7413,7 @@ const Widget = ({
|
|
|
7430
7413
|
routes,
|
|
7431
7414
|
loader,
|
|
7432
7415
|
explicitForm: _explicitForm = false,
|
|
7416
|
+
imageBaseUrl,
|
|
7433
7417
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
7434
7418
|
// @ts-ignore
|
|
7435
7419
|
permissions: _permissions = {},
|
|
@@ -7476,11 +7460,13 @@ const Widget = ({
|
|
|
7476
7460
|
canList: derivedPermissions.list,
|
|
7477
7461
|
routes,
|
|
7478
7462
|
defaultLimit: 10,
|
|
7479
|
-
preConfirmDelete
|
|
7463
|
+
preConfirmDelete,
|
|
7464
|
+
imageBaseUrl
|
|
7480
7465
|
});
|
|
7481
7466
|
return /*#__PURE__*/React.createElement(WidgetContextProvider, {
|
|
7482
7467
|
loading: loading,
|
|
7483
7468
|
list: list,
|
|
7469
|
+
imageBaseUrl: imageBaseUrl,
|
|
7484
7470
|
onChangeFormState: onChangeFormState,
|
|
7485
7471
|
t: derivedT,
|
|
7486
7472
|
searchText: searchText,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knovator/pagecreator-admin",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.11",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"classnames": "^2.3.1",
|
|
6
6
|
"react-beautiful-dnd": "^13.1.0",
|
|
@@ -9,8 +9,7 @@
|
|
|
9
9
|
"react-dropzone": "^14.2.2",
|
|
10
10
|
"react-select": "^5.4.0",
|
|
11
11
|
"react-tabs": "^6.0.0",
|
|
12
|
-
"react-tiny-popover": "^7.2.0"
|
|
13
|
-
"jodit-react": "^1.3.32"
|
|
12
|
+
"react-tiny-popover": "^7.2.0"
|
|
14
13
|
},
|
|
15
14
|
"peerDependencies": {
|
|
16
15
|
"react": "^18 | ^17",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { FormProps } from '../../../types';
|
|
3
|
-
declare const WidgetForm: ({ formRef }: FormProps) => JSX.Element | null;
|
|
3
|
+
declare const WidgetForm: ({ formRef, customInputs }: FormProps) => JSX.Element | null;
|
|
4
4
|
export default WidgetForm;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { WidgetProps } from '../../../types';
|
|
3
3
|
declare const Widget: {
|
|
4
|
-
({ t, routes, loader, explicitForm, permissions, preConfirmDelete, formatListItem, formatOptionLabel, children, }: WidgetProps): JSX.Element;
|
|
5
|
-
Table: () => JSX.Element;
|
|
6
|
-
Form: ({ formRef }: import("../../../types").FormProps) => JSX.Element | null;
|
|
4
|
+
({ t, routes, loader, explicitForm, imageBaseUrl, permissions, preConfirmDelete, formatListItem, formatOptionLabel, children, }: WidgetProps): JSX.Element;
|
|
5
|
+
Table: ({ extraActions, extraColumns }: import("../../../types").DerivedTableProps) => JSX.Element;
|
|
6
|
+
Form: ({ formRef, customInputs }: import("../../../types").FormProps) => JSX.Element | null;
|
|
7
7
|
AddButton: () => JSX.Element;
|
|
8
8
|
Search: () => JSX.Element;
|
|
9
9
|
Pagination: () => JSX.Element;
|
|
@@ -3,12 +3,10 @@ import Checkbox from "./Checkbox";
|
|
|
3
3
|
import Select from "./Select";
|
|
4
4
|
import ReactSelect from "./ReactSelect";
|
|
5
5
|
import SrcSet from './SrcSet';
|
|
6
|
-
import
|
|
7
|
-
declare const _default: (({ label, id, placeholder, type, size, required, error, className, disabled, rest, onInput, onBlur, value, info, onChange, wrapperClassName, }: import("../../../types").InputProps) => JSX.Element) & {
|
|
6
|
+
declare const _default: (({ label, id, placeholder, type, size, required, error, className, disabled, rest, onInput, onBlur, value, onChange, wrapperClassName, }: import("../../../types").InputProps) => JSX.Element) & {
|
|
8
7
|
Select: typeof Select;
|
|
9
8
|
ReactSelect: typeof ReactSelect;
|
|
10
9
|
Checkbox: typeof Checkbox;
|
|
11
10
|
SrcSet: typeof SrcSet;
|
|
12
|
-
HTML: typeof HTMLEditor;
|
|
13
11
|
};
|
|
14
12
|
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { TableProps } from '../../../types';
|
|
3
|
-
declare const Table: ({ data, dataKeys, actions, loader, loading }: TableProps) => JSX.Element;
|
|
3
|
+
declare const Table: ({ data, dataKeys, actions, loader, loading, extraActions, actionsLabel, extraColumns, }: TableProps) => JSX.Element;
|
|
4
4
|
export default Table;
|
|
@@ -81,6 +81,7 @@ declare const TRANSLATION_PAIRS_WIDGET: {
|
|
|
81
81
|
'widget.tabDeleteTitle': string;
|
|
82
82
|
'widget.widgetTitleInfo': string;
|
|
83
83
|
'widget.minPerRow': string;
|
|
84
|
+
'widget.actionsLabel': string;
|
|
84
85
|
};
|
|
85
86
|
declare const TRANSLATION_PAIRS_ITEM: {
|
|
86
87
|
'item.title': string;
|
|
@@ -110,5 +111,6 @@ declare const TRANSLATION_PAIRS_PAGE: {
|
|
|
110
111
|
'page.tableName': string;
|
|
111
112
|
'page.tableCode': string;
|
|
112
113
|
'page.widgets': string;
|
|
114
|
+
'page.actionsLabel': string;
|
|
113
115
|
};
|
|
114
116
|
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, };
|
|
@@ -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, 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, webItems, mobileItems, itemsLoading, onItemFormSubmit, 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, webItems, mobileItems, itemsLoading, onItemFormSubmit, reactSelectStyles, children, }: WidgetContextProviderProps) => JSX.Element;
|
|
6
6
|
export declare function useWidgetState(): WidgetContextType;
|
|
7
7
|
export default WidgetContextProvider;
|
|
@@ -8,12 +8,13 @@ interface UseWidgetProps {
|
|
|
8
8
|
preConfirmDelete?: (data: {
|
|
9
9
|
row: ObjectType;
|
|
10
10
|
}) => Promise<boolean>;
|
|
11
|
+
imageBaseUrl?: string;
|
|
11
12
|
}
|
|
12
13
|
interface ItemsList {
|
|
13
14
|
web: ObjectType[];
|
|
14
15
|
mobile: ObjectType[];
|
|
15
16
|
}
|
|
16
|
-
declare const useWidget: ({ canList, defaultLimit, routes, preConfirmDelete, }: UseWidgetProps) => {
|
|
17
|
+
declare const useWidget: ({ canList, defaultLimit, routes, preConfirmDelete, imageBaseUrl }: UseWidgetProps) => {
|
|
17
18
|
list: ObjectType[];
|
|
18
19
|
getWidgets: (search?: string) => Promise<void>;
|
|
19
20
|
loading: boolean;
|
|
@@ -117,8 +117,14 @@ export interface ReactSelectProps {
|
|
|
117
117
|
loadOptions?: (value?: string, callback?: (options: OptionType[]) => void) => Promise<OptionType[]>;
|
|
118
118
|
selectKey?: string;
|
|
119
119
|
}
|
|
120
|
+
export interface CustomInputType {
|
|
121
|
+
field: import('react-hook-form').ControllerRenderProps;
|
|
122
|
+
error?: string;
|
|
123
|
+
setError: (msg: string) => void;
|
|
124
|
+
}
|
|
120
125
|
export interface FormProps {
|
|
121
126
|
formRef: MutableRefObject<HTMLFormElement | null>;
|
|
127
|
+
customInputs?: Record<string, (props: InputRendererProps) => JSX.Element>;
|
|
122
128
|
}
|
|
123
129
|
export interface InputRendererProps {
|
|
124
130
|
field: import('react-hook-form').ControllerRenderProps;
|
|
@@ -139,6 +145,16 @@ export interface WidgetProps {
|
|
|
139
145
|
}) => Promise<boolean>;
|
|
140
146
|
children?: JSX.Element;
|
|
141
147
|
reactSelectStyles?: any;
|
|
148
|
+
imageBaseUrl?: string;
|
|
149
|
+
}
|
|
150
|
+
export interface DerivedTableProps {
|
|
151
|
+
extraActions?: (item: any) => JSX.Element;
|
|
152
|
+
extraColumns?: [
|
|
153
|
+
{
|
|
154
|
+
label: string;
|
|
155
|
+
Cell: (item: any) => JSX.Element;
|
|
156
|
+
}
|
|
157
|
+
];
|
|
142
158
|
}
|
|
143
159
|
export interface FormWrapperProps {
|
|
144
160
|
children: (data: {
|
|
@@ -315,4 +331,12 @@ export interface TableProps {
|
|
|
315
331
|
[key: string]: any;
|
|
316
332
|
}) => void) | boolean;
|
|
317
333
|
};
|
|
334
|
+
actionsLabel: string;
|
|
335
|
+
extraActions?: (item: any) => JSX.Element;
|
|
336
|
+
extraColumns?: [
|
|
337
|
+
{
|
|
338
|
+
label: string;
|
|
339
|
+
Cell: (item: any) => JSX.Element;
|
|
340
|
+
}
|
|
341
|
+
];
|
|
318
342
|
}
|