@knovator/pagecreator-admin 0.5.10 → 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 +47 -17
- package/index.js +47 -17
- package/package.json +1 -1
- package/src/lib/components/Page/Table/PageTable.d.ts +2 -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/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 +18 -0
- package/src/lib/types/context.d.ts +1 -0
package/index.cjs
CHANGED
|
@@ -1739,7 +1739,8 @@ const TRANSLATION_PAIRS_WIDGET = {
|
|
|
1739
1739
|
'widget.mobilePerRowRequired': 'Mobile Per Row is required',
|
|
1740
1740
|
'widget.tabDeleteTitle': 'Are you sure you want to delete this tab?',
|
|
1741
1741
|
'widget.widgetTitleInfo': 'HTML is supported',
|
|
1742
|
-
'widget.minPerRow': 'Value must be greater than zero'
|
|
1742
|
+
'widget.minPerRow': 'Value must be greater than zero',
|
|
1743
|
+
'widget.actionsLabel': 'Actions'
|
|
1743
1744
|
};
|
|
1744
1745
|
const TRANSLATION_PAIRS_ITEM = {
|
|
1745
1746
|
'item.title': 'Title',
|
|
@@ -1768,7 +1769,8 @@ const TRANSLATION_PAIRS_PAGE = {
|
|
|
1768
1769
|
'page.searchPages': 'Search Pages...',
|
|
1769
1770
|
'page.tableName': 'Name',
|
|
1770
1771
|
'page.tableCode': 'Code',
|
|
1771
|
-
'page.widgets': 'Widgets'
|
|
1772
|
+
'page.widgets': 'Widgets',
|
|
1773
|
+
'page.actionsLabel': 'Actions'
|
|
1772
1774
|
};
|
|
1773
1775
|
|
|
1774
1776
|
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
@@ -3088,7 +3090,10 @@ const Table = ({
|
|
|
3088
3090
|
dataKeys,
|
|
3089
3091
|
actions,
|
|
3090
3092
|
loader,
|
|
3091
|
-
loading
|
|
3093
|
+
loading,
|
|
3094
|
+
extraActions,
|
|
3095
|
+
actionsLabel,
|
|
3096
|
+
extraColumns
|
|
3092
3097
|
}) => {
|
|
3093
3098
|
const cellItemRenderer = (item, dataKey, index) => {
|
|
3094
3099
|
if (dataKey.highlight) return /*#__PURE__*/React__default["default"].createElement("th", {
|
|
@@ -3120,32 +3125,41 @@ const Table = ({
|
|
|
3120
3125
|
scope: "col",
|
|
3121
3126
|
className: "khb_table-heading",
|
|
3122
3127
|
key: i
|
|
3123
|
-
}, key.label)),
|
|
3128
|
+
}, key.label)), Array.isArray(extraColumns) ? extraColumns.map(action => /*#__PURE__*/React__default["default"].createElement("th", {
|
|
3124
3129
|
scope: "col",
|
|
3125
3130
|
className: "khb_table-heading"
|
|
3126
|
-
},
|
|
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", {
|
|
3127
3135
|
className: "khb_tbody"
|
|
3128
3136
|
}, data.length > 0 ? data.map((item, i) => /*#__PURE__*/React__default["default"].createElement("tr", {
|
|
3129
3137
|
className: "khb_table-row",
|
|
3130
3138
|
key: item['id'] || item['_id'] || i
|
|
3131
|
-
}, 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", {
|
|
3132
3143
|
className: "khb_table-row-actions"
|
|
3133
|
-
}, 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", {
|
|
3134
3145
|
className: "khb_actions-update",
|
|
3135
3146
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3136
3147
|
// @ts-ignore
|
|
3137
3148
|
onClick: () => actions.edit(item)
|
|
3138
|
-
}, /*#__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", {
|
|
3139
3150
|
className: "khb_actions-delete",
|
|
3140
3151
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3141
3152
|
// @ts-ignore
|
|
3142
3153
|
onClick: () => actions.delete(item)
|
|
3143
|
-
}, /*#__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", {
|
|
3144
3155
|
colSpan: ((dataKeys === null || dataKeys === void 0 ? void 0 : dataKeys.length) || 0) + 1
|
|
3145
3156
|
}, "No data found"))))));
|
|
3146
3157
|
};
|
|
3147
3158
|
|
|
3148
|
-
const PageTable = (
|
|
3159
|
+
const PageTable = ({
|
|
3160
|
+
extraActions,
|
|
3161
|
+
extraColumns
|
|
3162
|
+
}) => {
|
|
3149
3163
|
const {
|
|
3150
3164
|
list,
|
|
3151
3165
|
onChangeFormState,
|
|
@@ -3169,10 +3183,13 @@ const PageTable = () => {
|
|
|
3169
3183
|
label: t('page.tableCode'),
|
|
3170
3184
|
dataKey: 'code'
|
|
3171
3185
|
}],
|
|
3186
|
+
actionsLabel: t('page.actionsLabel'),
|
|
3172
3187
|
actions: {
|
|
3173
3188
|
edit: canUpdate ? onUpdateClick : undefined,
|
|
3174
3189
|
delete: canDelete ? onDeleteClick : undefined
|
|
3175
|
-
}
|
|
3190
|
+
},
|
|
3191
|
+
extraColumns: extraColumns,
|
|
3192
|
+
extraActions: extraActions
|
|
3176
3193
|
});
|
|
3177
3194
|
};
|
|
3178
3195
|
|
|
@@ -4557,7 +4574,8 @@ const useWidget = ({
|
|
|
4557
4574
|
canList: _canList = true,
|
|
4558
4575
|
defaultLimit,
|
|
4559
4576
|
routes,
|
|
4560
|
-
preConfirmDelete
|
|
4577
|
+
preConfirmDelete,
|
|
4578
|
+
imageBaseUrl
|
|
4561
4579
|
}) => {
|
|
4562
4580
|
const [list, setList] = React.useState([]);
|
|
4563
4581
|
const [itemsList, setItemsList] = React.useState({
|
|
@@ -4954,7 +4972,7 @@ const useWidget = ({
|
|
|
4954
4972
|
const responseData = (response === null || response === void 0 ? void 0 : response.data[0]) || (response === null || response === void 0 ? void 0 : response.data);
|
|
4955
4973
|
return {
|
|
4956
4974
|
fileId: (responseData === null || responseData === void 0 ? void 0 : responseData._id) || (responseData === null || responseData === void 0 ? void 0 : responseData.id),
|
|
4957
|
-
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),
|
|
4958
4976
|
fileUri: responseData === null || responseData === void 0 ? void 0 : responseData.uri
|
|
4959
4977
|
};
|
|
4960
4978
|
} else onError(CALLBACK_CODES.IMAGE_REMOVE, response.code, response.message);
|
|
@@ -6107,6 +6125,7 @@ const WidgetContextProvider = ({
|
|
|
6107
6125
|
t: _t = () => '',
|
|
6108
6126
|
// Form
|
|
6109
6127
|
list: _list = [],
|
|
6128
|
+
imageBaseUrl: _imageBaseUrl = '',
|
|
6110
6129
|
searchText: _searchText = '',
|
|
6111
6130
|
changeSearch: _changeSearch = () => {},
|
|
6112
6131
|
formState: _formState = '',
|
|
@@ -6158,6 +6177,7 @@ const WidgetContextProvider = ({
|
|
|
6158
6177
|
t: _t,
|
|
6159
6178
|
// Form
|
|
6160
6179
|
list: _list,
|
|
6180
|
+
imageBaseUrl: _imageBaseUrl,
|
|
6161
6181
|
closeForm: _closeForm,
|
|
6162
6182
|
formState: _formState,
|
|
6163
6183
|
loading: _loading,
|
|
@@ -6229,7 +6249,10 @@ const Toggle = ({
|
|
|
6229
6249
|
}));
|
|
6230
6250
|
};
|
|
6231
6251
|
|
|
6232
|
-
const WidgetTable = (
|
|
6252
|
+
const WidgetTable = ({
|
|
6253
|
+
extraActions,
|
|
6254
|
+
extraColumns
|
|
6255
|
+
}) => {
|
|
6233
6256
|
const {
|
|
6234
6257
|
switchClass
|
|
6235
6258
|
} = useProviderState();
|
|
@@ -6275,6 +6298,9 @@ const WidgetTable = () => {
|
|
|
6275
6298
|
loader: loader,
|
|
6276
6299
|
loading: loading,
|
|
6277
6300
|
dataKeys: dataKeys,
|
|
6301
|
+
actionsLabel: t('widget.actionsLabel'),
|
|
6302
|
+
extraColumns: extraColumns,
|
|
6303
|
+
extraActions: extraActions,
|
|
6278
6304
|
actions: {
|
|
6279
6305
|
edit: canUpdate ? onUpdateClick : false,
|
|
6280
6306
|
delete: canDelete ? onDeleteClick : false
|
|
@@ -6846,7 +6872,8 @@ const WidgetForm = ({
|
|
|
6846
6872
|
collectionDataLoading,
|
|
6847
6873
|
formatListItem,
|
|
6848
6874
|
formatOptionLabel,
|
|
6849
|
-
reactSelectStyles
|
|
6875
|
+
reactSelectStyles,
|
|
6876
|
+
imageBaseUrl
|
|
6850
6877
|
} = useWidgetState();
|
|
6851
6878
|
const callerRef = React.useRef(null);
|
|
6852
6879
|
const [activeTab, setActiveTab] = React.useState(0);
|
|
@@ -7191,7 +7218,7 @@ const WidgetForm = ({
|
|
|
7191
7218
|
setImgId: value => {
|
|
7192
7219
|
field.onChange(value);
|
|
7193
7220
|
},
|
|
7194
|
-
baseUrl: baseUrl,
|
|
7221
|
+
baseUrl: imageBaseUrl ? imageBaseUrl : baseUrl,
|
|
7195
7222
|
disabled: disabled,
|
|
7196
7223
|
text: /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
7197
7224
|
className: "khb_img-text-wrapper"
|
|
@@ -7398,6 +7425,7 @@ const Widget = ({
|
|
|
7398
7425
|
routes,
|
|
7399
7426
|
loader,
|
|
7400
7427
|
explicitForm: _explicitForm = false,
|
|
7428
|
+
imageBaseUrl,
|
|
7401
7429
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
7402
7430
|
// @ts-ignore
|
|
7403
7431
|
permissions: _permissions = {},
|
|
@@ -7444,11 +7472,13 @@ const Widget = ({
|
|
|
7444
7472
|
canList: derivedPermissions.list,
|
|
7445
7473
|
routes,
|
|
7446
7474
|
defaultLimit: 10,
|
|
7447
|
-
preConfirmDelete
|
|
7475
|
+
preConfirmDelete,
|
|
7476
|
+
imageBaseUrl
|
|
7448
7477
|
});
|
|
7449
7478
|
return /*#__PURE__*/React__default["default"].createElement(WidgetContextProvider, {
|
|
7450
7479
|
loading: loading,
|
|
7451
7480
|
list: list,
|
|
7481
|
+
imageBaseUrl: imageBaseUrl,
|
|
7452
7482
|
onChangeFormState: onChangeFormState,
|
|
7453
7483
|
t: derivedT,
|
|
7454
7484
|
searchText: searchText,
|
package/index.js
CHANGED
|
@@ -1727,7 +1727,8 @@ const TRANSLATION_PAIRS_WIDGET = {
|
|
|
1727
1727
|
'widget.mobilePerRowRequired': 'Mobile Per Row is required',
|
|
1728
1728
|
'widget.tabDeleteTitle': 'Are you sure you want to delete this tab?',
|
|
1729
1729
|
'widget.widgetTitleInfo': 'HTML is supported',
|
|
1730
|
-
'widget.minPerRow': 'Value must be greater than zero'
|
|
1730
|
+
'widget.minPerRow': 'Value must be greater than zero',
|
|
1731
|
+
'widget.actionsLabel': 'Actions'
|
|
1731
1732
|
};
|
|
1732
1733
|
const TRANSLATION_PAIRS_ITEM = {
|
|
1733
1734
|
'item.title': 'Title',
|
|
@@ -1756,7 +1757,8 @@ const TRANSLATION_PAIRS_PAGE = {
|
|
|
1756
1757
|
'page.searchPages': 'Search Pages...',
|
|
1757
1758
|
'page.tableName': 'Name',
|
|
1758
1759
|
'page.tableCode': 'Code',
|
|
1759
|
-
'page.widgets': 'Widgets'
|
|
1760
|
+
'page.widgets': 'Widgets',
|
|
1761
|
+
'page.actionsLabel': 'Actions'
|
|
1760
1762
|
};
|
|
1761
1763
|
|
|
1762
1764
|
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
@@ -3076,7 +3078,10 @@ const Table = ({
|
|
|
3076
3078
|
dataKeys,
|
|
3077
3079
|
actions,
|
|
3078
3080
|
loader,
|
|
3079
|
-
loading
|
|
3081
|
+
loading,
|
|
3082
|
+
extraActions,
|
|
3083
|
+
actionsLabel,
|
|
3084
|
+
extraColumns
|
|
3080
3085
|
}) => {
|
|
3081
3086
|
const cellItemRenderer = (item, dataKey, index) => {
|
|
3082
3087
|
if (dataKey.highlight) return /*#__PURE__*/React.createElement("th", {
|
|
@@ -3108,32 +3113,41 @@ const Table = ({
|
|
|
3108
3113
|
scope: "col",
|
|
3109
3114
|
className: "khb_table-heading",
|
|
3110
3115
|
key: i
|
|
3111
|
-
}, key.label)),
|
|
3116
|
+
}, key.label)), Array.isArray(extraColumns) ? extraColumns.map(action => /*#__PURE__*/React.createElement("th", {
|
|
3112
3117
|
scope: "col",
|
|
3113
3118
|
className: "khb_table-heading"
|
|
3114
|
-
},
|
|
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", {
|
|
3115
3123
|
className: "khb_tbody"
|
|
3116
3124
|
}, data.length > 0 ? data.map((item, i) => /*#__PURE__*/React.createElement("tr", {
|
|
3117
3125
|
className: "khb_table-row",
|
|
3118
3126
|
key: item['id'] || item['_id'] || i
|
|
3119
|
-
}, 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", {
|
|
3120
3131
|
className: "khb_table-row-actions"
|
|
3121
|
-
}, actions.edit && typeof actions.edit === 'function' ? /*#__PURE__*/React.createElement("button", {
|
|
3132
|
+
}, actions && actions.edit && typeof actions.edit === 'function' ? /*#__PURE__*/React.createElement("button", {
|
|
3122
3133
|
className: "khb_actions-update",
|
|
3123
3134
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3124
3135
|
// @ts-ignore
|
|
3125
3136
|
onClick: () => actions.edit(item)
|
|
3126
|
-
}, /*#__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", {
|
|
3127
3138
|
className: "khb_actions-delete",
|
|
3128
3139
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3129
3140
|
// @ts-ignore
|
|
3130
3141
|
onClick: () => actions.delete(item)
|
|
3131
|
-
}, /*#__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", {
|
|
3132
3143
|
colSpan: ((dataKeys === null || dataKeys === void 0 ? void 0 : dataKeys.length) || 0) + 1
|
|
3133
3144
|
}, "No data found"))))));
|
|
3134
3145
|
};
|
|
3135
3146
|
|
|
3136
|
-
const PageTable = (
|
|
3147
|
+
const PageTable = ({
|
|
3148
|
+
extraActions,
|
|
3149
|
+
extraColumns
|
|
3150
|
+
}) => {
|
|
3137
3151
|
const {
|
|
3138
3152
|
list,
|
|
3139
3153
|
onChangeFormState,
|
|
@@ -3157,10 +3171,13 @@ const PageTable = () => {
|
|
|
3157
3171
|
label: t('page.tableCode'),
|
|
3158
3172
|
dataKey: 'code'
|
|
3159
3173
|
}],
|
|
3174
|
+
actionsLabel: t('page.actionsLabel'),
|
|
3160
3175
|
actions: {
|
|
3161
3176
|
edit: canUpdate ? onUpdateClick : undefined,
|
|
3162
3177
|
delete: canDelete ? onDeleteClick : undefined
|
|
3163
|
-
}
|
|
3178
|
+
},
|
|
3179
|
+
extraColumns: extraColumns,
|
|
3180
|
+
extraActions: extraActions
|
|
3164
3181
|
});
|
|
3165
3182
|
};
|
|
3166
3183
|
|
|
@@ -4545,7 +4562,8 @@ const useWidget = ({
|
|
|
4545
4562
|
canList: _canList = true,
|
|
4546
4563
|
defaultLimit,
|
|
4547
4564
|
routes,
|
|
4548
|
-
preConfirmDelete
|
|
4565
|
+
preConfirmDelete,
|
|
4566
|
+
imageBaseUrl
|
|
4549
4567
|
}) => {
|
|
4550
4568
|
const [list, setList] = useState([]);
|
|
4551
4569
|
const [itemsList, setItemsList] = useState({
|
|
@@ -4942,7 +4960,7 @@ const useWidget = ({
|
|
|
4942
4960
|
const responseData = (response === null || response === void 0 ? void 0 : response.data[0]) || (response === null || response === void 0 ? void 0 : response.data);
|
|
4943
4961
|
return {
|
|
4944
4962
|
fileId: (responseData === null || responseData === void 0 ? void 0 : responseData._id) || (responseData === null || responseData === void 0 ? void 0 : responseData.id),
|
|
4945
|
-
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),
|
|
4946
4964
|
fileUri: responseData === null || responseData === void 0 ? void 0 : responseData.uri
|
|
4947
4965
|
};
|
|
4948
4966
|
} else onError(CALLBACK_CODES.IMAGE_REMOVE, response.code, response.message);
|
|
@@ -6095,6 +6113,7 @@ const WidgetContextProvider = ({
|
|
|
6095
6113
|
t: _t = () => '',
|
|
6096
6114
|
// Form
|
|
6097
6115
|
list: _list = [],
|
|
6116
|
+
imageBaseUrl: _imageBaseUrl = '',
|
|
6098
6117
|
searchText: _searchText = '',
|
|
6099
6118
|
changeSearch: _changeSearch = () => {},
|
|
6100
6119
|
formState: _formState = '',
|
|
@@ -6146,6 +6165,7 @@ const WidgetContextProvider = ({
|
|
|
6146
6165
|
t: _t,
|
|
6147
6166
|
// Form
|
|
6148
6167
|
list: _list,
|
|
6168
|
+
imageBaseUrl: _imageBaseUrl,
|
|
6149
6169
|
closeForm: _closeForm,
|
|
6150
6170
|
formState: _formState,
|
|
6151
6171
|
loading: _loading,
|
|
@@ -6217,7 +6237,10 @@ const Toggle = ({
|
|
|
6217
6237
|
}));
|
|
6218
6238
|
};
|
|
6219
6239
|
|
|
6220
|
-
const WidgetTable = (
|
|
6240
|
+
const WidgetTable = ({
|
|
6241
|
+
extraActions,
|
|
6242
|
+
extraColumns
|
|
6243
|
+
}) => {
|
|
6221
6244
|
const {
|
|
6222
6245
|
switchClass
|
|
6223
6246
|
} = useProviderState();
|
|
@@ -6263,6 +6286,9 @@ const WidgetTable = () => {
|
|
|
6263
6286
|
loader: loader,
|
|
6264
6287
|
loading: loading,
|
|
6265
6288
|
dataKeys: dataKeys,
|
|
6289
|
+
actionsLabel: t('widget.actionsLabel'),
|
|
6290
|
+
extraColumns: extraColumns,
|
|
6291
|
+
extraActions: extraActions,
|
|
6266
6292
|
actions: {
|
|
6267
6293
|
edit: canUpdate ? onUpdateClick : false,
|
|
6268
6294
|
delete: canDelete ? onDeleteClick : false
|
|
@@ -6834,7 +6860,8 @@ const WidgetForm = ({
|
|
|
6834
6860
|
collectionDataLoading,
|
|
6835
6861
|
formatListItem,
|
|
6836
6862
|
formatOptionLabel,
|
|
6837
|
-
reactSelectStyles
|
|
6863
|
+
reactSelectStyles,
|
|
6864
|
+
imageBaseUrl
|
|
6838
6865
|
} = useWidgetState();
|
|
6839
6866
|
const callerRef = useRef(null);
|
|
6840
6867
|
const [activeTab, setActiveTab] = useState(0);
|
|
@@ -7179,7 +7206,7 @@ const WidgetForm = ({
|
|
|
7179
7206
|
setImgId: value => {
|
|
7180
7207
|
field.onChange(value);
|
|
7181
7208
|
},
|
|
7182
|
-
baseUrl: baseUrl,
|
|
7209
|
+
baseUrl: imageBaseUrl ? imageBaseUrl : baseUrl,
|
|
7183
7210
|
disabled: disabled,
|
|
7184
7211
|
text: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
7185
7212
|
className: "khb_img-text-wrapper"
|
|
@@ -7386,6 +7413,7 @@ const Widget = ({
|
|
|
7386
7413
|
routes,
|
|
7387
7414
|
loader,
|
|
7388
7415
|
explicitForm: _explicitForm = false,
|
|
7416
|
+
imageBaseUrl,
|
|
7389
7417
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
7390
7418
|
// @ts-ignore
|
|
7391
7419
|
permissions: _permissions = {},
|
|
@@ -7432,11 +7460,13 @@ const Widget = ({
|
|
|
7432
7460
|
canList: derivedPermissions.list,
|
|
7433
7461
|
routes,
|
|
7434
7462
|
defaultLimit: 10,
|
|
7435
|
-
preConfirmDelete
|
|
7463
|
+
preConfirmDelete,
|
|
7464
|
+
imageBaseUrl
|
|
7436
7465
|
});
|
|
7437
7466
|
return /*#__PURE__*/React.createElement(WidgetContextProvider, {
|
|
7438
7467
|
loading: loading,
|
|
7439
7468
|
list: list,
|
|
7469
|
+
imageBaseUrl: imageBaseUrl,
|
|
7440
7470
|
onChangeFormState: onChangeFormState,
|
|
7441
7471
|
t: derivedT,
|
|
7442
7472
|
searchText: searchText,
|
package/package.json
CHANGED
|
@@ -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;
|
|
@@ -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;
|
|
@@ -145,6 +145,16 @@ export interface WidgetProps {
|
|
|
145
145
|
}) => Promise<boolean>;
|
|
146
146
|
children?: JSX.Element;
|
|
147
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
|
+
];
|
|
148
158
|
}
|
|
149
159
|
export interface FormWrapperProps {
|
|
150
160
|
children: (data: {
|
|
@@ -321,4 +331,12 @@ export interface TableProps {
|
|
|
321
331
|
[key: string]: any;
|
|
322
332
|
}) => void) | boolean;
|
|
323
333
|
};
|
|
334
|
+
actionsLabel: string;
|
|
335
|
+
extraActions?: (item: any) => JSX.Element;
|
|
336
|
+
extraColumns?: [
|
|
337
|
+
{
|
|
338
|
+
label: string;
|
|
339
|
+
Cell: (item: any) => JSX.Element;
|
|
340
|
+
}
|
|
341
|
+
];
|
|
324
342
|
}
|