@knovator/pagecreator-admin 0.5.3 → 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 +93 -79
- package/index.css +12 -1
- package/index.js +93 -79
- 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
package/index.cjs
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var fetchUrl = require('@knovator/api');
|
|
7
7
|
var classNames = require('classnames');
|
|
8
|
-
var ReactSelect = require('react-select');
|
|
8
|
+
var ReactSelect = require('react-select/async');
|
|
9
9
|
var reactHookForm = require('react-hook-form');
|
|
10
10
|
var reactBeautifulDnd = require('react-beautiful-dnd');
|
|
11
11
|
var CSSTransition = require('react-transition-group/CSSTransition');
|
|
@@ -1737,7 +1737,8 @@ const TRANSLATION_PAIRS_WIDGET = {
|
|
|
1737
1737
|
'widget.webPerRowRequired': 'Web Per Row is required',
|
|
1738
1738
|
'widget.tabletPerRowRequired': 'Tablet Per Row is required',
|
|
1739
1739
|
'widget.mobilePerRowRequired': 'Mobile Per Row is required',
|
|
1740
|
-
'widget.tabDeleteTitle': 'Are you sure you want to delete this tab?'
|
|
1740
|
+
'widget.tabDeleteTitle': 'Are you sure you want to delete this tab?',
|
|
1741
|
+
'widget.widgetTitleInfo': 'HTML is supported'
|
|
1741
1742
|
};
|
|
1742
1743
|
const TRANSLATION_PAIRS_ITEM = {
|
|
1743
1744
|
'item.title': 'Title',
|
|
@@ -3256,6 +3257,7 @@ const Input$1 = ({
|
|
|
3256
3257
|
onInput,
|
|
3257
3258
|
onBlur,
|
|
3258
3259
|
value,
|
|
3260
|
+
info,
|
|
3259
3261
|
onChange,
|
|
3260
3262
|
wrapperClassName
|
|
3261
3263
|
}) => {
|
|
@@ -3278,7 +3280,9 @@ const Input$1 = ({
|
|
|
3278
3280
|
onBlur: onBlur
|
|
3279
3281
|
})), error && /*#__PURE__*/React__default["default"].createElement("p", {
|
|
3280
3282
|
className: "khb_input-error "
|
|
3281
|
-
}, error)
|
|
3283
|
+
}, error), info && /*#__PURE__*/React__default["default"].createElement("p", {
|
|
3284
|
+
className: "khb_input-info"
|
|
3285
|
+
}, info));
|
|
3282
3286
|
};
|
|
3283
3287
|
|
|
3284
3288
|
const Select = ({
|
|
@@ -3319,18 +3323,19 @@ const CustomReactSelect = ({
|
|
|
3319
3323
|
onChange,
|
|
3320
3324
|
label,
|
|
3321
3325
|
error,
|
|
3322
|
-
options: _options = [],
|
|
3323
3326
|
className,
|
|
3324
3327
|
isMulti,
|
|
3325
3328
|
selectedOptions: _selectedOptions = [],
|
|
3326
3329
|
required,
|
|
3327
3330
|
isLoading,
|
|
3328
3331
|
isSearchable,
|
|
3329
|
-
|
|
3332
|
+
loadOptions,
|
|
3330
3333
|
placeholder,
|
|
3331
3334
|
wrapperClassName,
|
|
3332
3335
|
formatOptionLabel,
|
|
3333
|
-
listCode
|
|
3336
|
+
listCode,
|
|
3337
|
+
customStyles,
|
|
3338
|
+
selectKey
|
|
3334
3339
|
}) => {
|
|
3335
3340
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
3336
3341
|
className: wrapperClassName
|
|
@@ -3339,6 +3344,7 @@ const CustomReactSelect = ({
|
|
|
3339
3344
|
}, label, required ? /*#__PURE__*/React__default["default"].createElement("span", {
|
|
3340
3345
|
className: "khb_input-label-required"
|
|
3341
3346
|
}, "*") : null), /*#__PURE__*/React__default["default"].createElement(ReactSelect__default["default"], {
|
|
3347
|
+
key: selectKey,
|
|
3342
3348
|
"data-testid": `input-select-${label}`,
|
|
3343
3349
|
value: _selectedOptions,
|
|
3344
3350
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -3346,12 +3352,13 @@ const CustomReactSelect = ({
|
|
|
3346
3352
|
onChange: onChange,
|
|
3347
3353
|
className: classNames__default["default"](className),
|
|
3348
3354
|
isMulti: isMulti,
|
|
3349
|
-
|
|
3355
|
+
defaultOptions: true,
|
|
3350
3356
|
isSearchable: isSearchable,
|
|
3351
3357
|
isLoading: isLoading,
|
|
3352
|
-
|
|
3358
|
+
loadOptions: loadOptions,
|
|
3353
3359
|
placeholder: placeholder,
|
|
3354
|
-
formatOptionLabel: formatOptionLabel ? option => formatOptionLabel(listCode, option) : undefined
|
|
3360
|
+
formatOptionLabel: formatOptionLabel ? option => formatOptionLabel(listCode, option) : undefined,
|
|
3361
|
+
styles: customStyles
|
|
3355
3362
|
}), error && /*#__PURE__*/React__default["default"].createElement("p", {
|
|
3356
3363
|
className: "khb_input-error "
|
|
3357
3364
|
}, error));
|
|
@@ -3717,7 +3724,6 @@ const Form = /*#__PURE__*/React.forwardRef(({
|
|
|
3717
3724
|
switch (schema.type) {
|
|
3718
3725
|
case 'ReactSelect':
|
|
3719
3726
|
input = /*#__PURE__*/React__default["default"].createElement(CustomReactSelect, {
|
|
3720
|
-
options: schema.options,
|
|
3721
3727
|
disabled: !_enable,
|
|
3722
3728
|
label: schema.label,
|
|
3723
3729
|
error: (_b = (_a = errors[schema.accessor]) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.toString(),
|
|
@@ -3731,11 +3737,12 @@ const Form = /*#__PURE__*/React.forwardRef(({
|
|
|
3731
3737
|
required: schema.required,
|
|
3732
3738
|
isMulti: schema.isMulti,
|
|
3733
3739
|
isSearchable: schema.isSearchable,
|
|
3734
|
-
onSearch: schema.onSearch,
|
|
3735
3740
|
isLoading: schema.isLoading,
|
|
3736
3741
|
placeholder: schema.placeholder,
|
|
3737
3742
|
wrapperClassName: schema.wrapperClassName,
|
|
3738
|
-
formatOptionLabel: schema.formatOptionLabel
|
|
3743
|
+
formatOptionLabel: schema.formatOptionLabel,
|
|
3744
|
+
selectKey: schema.selectKey,
|
|
3745
|
+
loadOptions: schema.loadOptions
|
|
3739
3746
|
});
|
|
3740
3747
|
break;
|
|
3741
3748
|
case 'checkbox':
|
|
@@ -3870,7 +3877,6 @@ const SimpleForm = /*#__PURE__*/React.forwardRef(({
|
|
|
3870
3877
|
switch (schema.type) {
|
|
3871
3878
|
case 'ReactSelect':
|
|
3872
3879
|
input = /*#__PURE__*/React__default["default"].createElement(CustomReactSelect, {
|
|
3873
|
-
options: schema.options,
|
|
3874
3880
|
disabled: !_enable,
|
|
3875
3881
|
label: schema.label,
|
|
3876
3882
|
error: (_b = (_a = errors[schema.accessor]) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.toString(),
|
|
@@ -3884,12 +3890,14 @@ const SimpleForm = /*#__PURE__*/React.forwardRef(({
|
|
|
3884
3890
|
required: schema.required,
|
|
3885
3891
|
isMulti: schema.isMulti,
|
|
3886
3892
|
isSearchable: schema.isSearchable,
|
|
3887
|
-
onSearch: schema.onSearch,
|
|
3888
3893
|
isLoading: schema.isLoading,
|
|
3889
3894
|
placeholder: schema.placeholder,
|
|
3890
3895
|
wrapperClassName: schema.wrapperClassName,
|
|
3891
3896
|
formatOptionLabel: schema.formatOptionLabel,
|
|
3892
|
-
listCode: schema.listCode
|
|
3897
|
+
listCode: schema.listCode,
|
|
3898
|
+
customStyles: schema.customStyles,
|
|
3899
|
+
loadOptions: schema.loadOptions,
|
|
3900
|
+
selectKey: schema.selectKey
|
|
3893
3901
|
});
|
|
3894
3902
|
break;
|
|
3895
3903
|
case 'checkbox':
|
|
@@ -3941,7 +3949,8 @@ const SimpleForm = /*#__PURE__*/React.forwardRef(({
|
|
|
3941
3949
|
disabled: _isUpdating && typeof schema.editable !== 'undefined' && !schema.editable || !_enable,
|
|
3942
3950
|
required: schema.required,
|
|
3943
3951
|
onInput: schema.onInput,
|
|
3944
|
-
wrapperClassName: schema.wrapperClassName
|
|
3952
|
+
wrapperClassName: schema.wrapperClassName,
|
|
3953
|
+
info: schema.info
|
|
3945
3954
|
});
|
|
3946
3955
|
break;
|
|
3947
3956
|
}
|
|
@@ -4829,7 +4838,7 @@ const useWidget = ({
|
|
|
4829
4838
|
}
|
|
4830
4839
|
setLoading(false);
|
|
4831
4840
|
});
|
|
4832
|
-
const getCollectionData = (collectionName, search, callback) => __awaiter(void 0, void 0, void 0, function* () {
|
|
4841
|
+
const getCollectionData = (collectionName, search, callback, collectionItems) => __awaiter(void 0, void 0, void 0, function* () {
|
|
4833
4842
|
setCollectionDataLoading(true);
|
|
4834
4843
|
const api = getApiType({
|
|
4835
4844
|
routes,
|
|
@@ -4845,7 +4854,8 @@ const useWidget = ({
|
|
|
4845
4854
|
onError: handleError(CALLBACK_CODES.GET_ALL),
|
|
4846
4855
|
data: {
|
|
4847
4856
|
search: search || '',
|
|
4848
|
-
collectionName
|
|
4857
|
+
collectionName,
|
|
4858
|
+
collectionItems: collectionItems || []
|
|
4849
4859
|
}
|
|
4850
4860
|
});
|
|
4851
4861
|
if ((response === null || response === void 0 ? void 0 : response.code) === 'SUCCESS') {
|
|
@@ -4889,35 +4899,6 @@ const useWidget = ({
|
|
|
4889
4899
|
setFormState(undefined);
|
|
4890
4900
|
setItemData(null);
|
|
4891
4901
|
};
|
|
4892
|
-
const updateCollectionDataReferences = itemData => collectionData => {
|
|
4893
|
-
const itemDataUpdated = Object.assign({}, itemData);
|
|
4894
|
-
if (itemDataUpdated['tabs'] && itemDataUpdated['tabs'].length > 0 && collectionData && collectionData.length > 0) {
|
|
4895
|
-
itemDataUpdated['tabs'] = itemDataUpdated['tabs'].map(item => {
|
|
4896
|
-
var _a;
|
|
4897
|
-
return {
|
|
4898
|
-
name: item.name,
|
|
4899
|
-
collectionItems: ((_a = item === null || item === void 0 ? void 0 : item.collectionItems) === null || _a === void 0 ? void 0 : _a.map(itemId => {
|
|
4900
|
-
item = collectionData.find(item => item._id === itemId || item.id === itemId);
|
|
4901
|
-
return item ? Object.assign({
|
|
4902
|
-
label: item.name,
|
|
4903
|
-
value: item._id || item.id
|
|
4904
|
-
}, item) : {};
|
|
4905
|
-
})) || []
|
|
4906
|
-
};
|
|
4907
|
-
});
|
|
4908
|
-
}
|
|
4909
|
-
if (itemDataUpdated['collectionItems'] && itemDataUpdated['collectionItems'].length > 0 && collectionData && collectionData.length > 0) {
|
|
4910
|
-
let item;
|
|
4911
|
-
itemDataUpdated['collectionItems'] = itemDataUpdated['collectionItems'].map(itemId => {
|
|
4912
|
-
item = collectionData.find(item => item._id === itemId || item.id === itemId);
|
|
4913
|
-
return item ? Object.assign({
|
|
4914
|
-
label: item.name,
|
|
4915
|
-
value: item._id || item.id
|
|
4916
|
-
}, item) : {};
|
|
4917
|
-
});
|
|
4918
|
-
}
|
|
4919
|
-
setItemData(itemDataUpdated);
|
|
4920
|
-
};
|
|
4921
4902
|
const onChangeFormState = (state, data) => {
|
|
4922
4903
|
setFormState(state);
|
|
4923
4904
|
// fetch ItemsTypes & WidgetTypes if needed
|
|
@@ -4927,10 +4908,10 @@ const useWidget = ({
|
|
|
4927
4908
|
}
|
|
4928
4909
|
// get Item data if widget is updating
|
|
4929
4910
|
if (state === 'UPDATE' && data) {
|
|
4930
|
-
if (data['itemsType']
|
|
4911
|
+
if (data['itemsType'] === 'Image') {
|
|
4931
4912
|
getItems(data['_id']);
|
|
4932
|
-
setItemData(data);
|
|
4933
4913
|
}
|
|
4914
|
+
setItemData(data);
|
|
4934
4915
|
} else if (state === 'ADD') {
|
|
4935
4916
|
// reset Item data if widget is adding
|
|
4936
4917
|
setItemsList({
|
|
@@ -6187,6 +6168,7 @@ const WidgetContextProvider = ({
|
|
|
6187
6168
|
mobileItems: _mobileItems = [],
|
|
6188
6169
|
itemsLoading: _itemsLoading = false,
|
|
6189
6170
|
onItemFormSubmit: _onItemFormSubmit = () => {},
|
|
6171
|
+
reactSelectStyles: _reactSelectStyles = {},
|
|
6190
6172
|
// other
|
|
6191
6173
|
children
|
|
6192
6174
|
}) => {
|
|
@@ -6215,6 +6197,7 @@ const WidgetContextProvider = ({
|
|
|
6215
6197
|
collectionData: _collectionData,
|
|
6216
6198
|
formatListItem,
|
|
6217
6199
|
formatOptionLabel,
|
|
6200
|
+
reactSelectStyles: _reactSelectStyles,
|
|
6218
6201
|
// Pagination
|
|
6219
6202
|
currentPage: _currentPage,
|
|
6220
6203
|
limits: _limits,
|
|
@@ -6724,22 +6707,24 @@ const TabItem = ({
|
|
|
6724
6707
|
};
|
|
6725
6708
|
|
|
6726
6709
|
const Tabs = ({
|
|
6710
|
+
activeTab,
|
|
6711
|
+
setActiveTab,
|
|
6727
6712
|
options,
|
|
6728
6713
|
control,
|
|
6729
6714
|
register,
|
|
6730
6715
|
listCode,
|
|
6731
6716
|
formatItem,
|
|
6732
6717
|
deleteTitle,
|
|
6718
|
+
loadOptions,
|
|
6719
|
+
customStyles,
|
|
6733
6720
|
noButtonText,
|
|
6734
6721
|
yesButtonText,
|
|
6735
|
-
onItemsSearch,
|
|
6736
6722
|
isItemsLoading,
|
|
6737
6723
|
itemsPlaceholder,
|
|
6738
6724
|
formatOptionLabel,
|
|
6739
6725
|
tabCollectionItems,
|
|
6740
6726
|
onCollectionItemsIndexChange
|
|
6741
6727
|
}) => {
|
|
6742
|
-
const [activeTab, setActiveTab] = React.useState(0);
|
|
6743
6728
|
const {
|
|
6744
6729
|
fields: tabFields,
|
|
6745
6730
|
append: appendField,
|
|
@@ -6797,19 +6782,21 @@ const Tabs = ({
|
|
|
6797
6782
|
onChange
|
|
6798
6783
|
}
|
|
6799
6784
|
}) => /*#__PURE__*/React__default["default"].createElement(CustomReactSelect, {
|
|
6800
|
-
options: options,
|
|
6785
|
+
options: options || [],
|
|
6801
6786
|
onChange: value => {
|
|
6802
6787
|
if (value) {
|
|
6803
6788
|
if (Array.isArray(value)) onChange(value);else onChange([value]);
|
|
6804
6789
|
}
|
|
6805
6790
|
},
|
|
6791
|
+
selectKey: `tabs.${index}.collectionItems.${listCode}`,
|
|
6806
6792
|
selectedOptions: value,
|
|
6807
6793
|
isMulti: true,
|
|
6808
6794
|
isSearchable: true,
|
|
6809
|
-
|
|
6795
|
+
loadOptions: loadOptions,
|
|
6810
6796
|
isLoading: isItemsLoading,
|
|
6811
6797
|
placeholder: itemsPlaceholder,
|
|
6812
6798
|
listCode: listCode,
|
|
6799
|
+
customStyles: customStyles,
|
|
6813
6800
|
// wrapperClassName={schema.wrapperClassName}
|
|
6814
6801
|
formatOptionLabel: formatOptionLabel
|
|
6815
6802
|
})
|
|
@@ -6825,6 +6812,7 @@ const constants = {
|
|
|
6825
6812
|
widgetTypeAccessor: 'widgetType',
|
|
6826
6813
|
itemTypeAccessor: 'itemsType',
|
|
6827
6814
|
collectionNameAccessor: 'collectionName',
|
|
6815
|
+
collectionItemsAccessor: 'collectionItems',
|
|
6828
6816
|
tabsWidgetTypeValue: 'Tabs',
|
|
6829
6817
|
fixedCardWidgetTypeValue: 'FixedCard',
|
|
6830
6818
|
carouselWidgetTypeValue: 'Carousel',
|
|
@@ -6873,9 +6861,11 @@ const WidgetForm = ({
|
|
|
6873
6861
|
collectionData,
|
|
6874
6862
|
collectionDataLoading,
|
|
6875
6863
|
formatListItem,
|
|
6876
|
-
formatOptionLabel
|
|
6864
|
+
formatOptionLabel,
|
|
6865
|
+
reactSelectStyles
|
|
6877
6866
|
} = useWidgetState();
|
|
6878
6867
|
const callerRef = React.useRef(null);
|
|
6868
|
+
const [activeTab, setActiveTab] = React.useState(0);
|
|
6879
6869
|
const [webItemsVisible, setWebItemsVisible] = React.useState(false);
|
|
6880
6870
|
const [mobileItemsVisible, setMobileItemsVisible] = React.useState(false);
|
|
6881
6871
|
const [selectedWidgetType, setSelectedWidgetType] = React.useState();
|
|
@@ -6891,11 +6881,6 @@ const WidgetForm = ({
|
|
|
6891
6881
|
} else {
|
|
6892
6882
|
setItemsEnabled(false);
|
|
6893
6883
|
}
|
|
6894
|
-
if ((data === null || data === void 0 ? void 0 : data.collectionItems) && (data === null || data === void 0 ? void 0 : data.collectionItems.length) > 0 && collectionData && collectionData.length > 0) {
|
|
6895
|
-
setSelectedCollectionItems((data === null || data === void 0 ? void 0 : data.collectionItems) || []);
|
|
6896
|
-
} else {
|
|
6897
|
-
setSelectedCollectionItems([]);
|
|
6898
|
-
}
|
|
6899
6884
|
if ((data === null || data === void 0 ? void 0 : data.collectionName) !== 'Image' && itemsTypes && itemsTypes.length > 0) {
|
|
6900
6885
|
setSelectedCollectionType(itemsTypes.find(item => item.value === (data === null || data === void 0 ? void 0 : data.collectionName)));
|
|
6901
6886
|
}
|
|
@@ -6913,10 +6898,42 @@ const WidgetForm = ({
|
|
|
6913
6898
|
reset(data);
|
|
6914
6899
|
}
|
|
6915
6900
|
}, [data, reset]);
|
|
6916
|
-
const onChangeSearch = str => {
|
|
6901
|
+
const onChangeSearch = (str, callback) => {
|
|
6902
|
+
let collectionItems = [];
|
|
6903
|
+
let valueToSet = '';
|
|
6904
|
+
if (formState === 'UPDATE') {
|
|
6905
|
+
if (data[constants.widgetTypeAccessor] === constants.tabsWidgetTypeValue) {
|
|
6906
|
+
collectionItems = data[constants.tabsAccessor][activeTab]['collectionItems'];
|
|
6907
|
+
valueToSet = `${constants.tabsAccessor}.${activeTab}.${constants.tabCollectionItemsAccessor}`;
|
|
6908
|
+
} else if (Array.isArray(data[constants.collectionItemsAccessor]) && data[constants.collectionItemsAccessor].length > 0) {
|
|
6909
|
+
collectionItems = data[constants.collectionItemsAccessor];
|
|
6910
|
+
// valueToSet = constants.collectionItemsAccessor;
|
|
6911
|
+
}
|
|
6912
|
+
}
|
|
6913
|
+
|
|
6917
6914
|
if (callerRef.current) clearTimeout(callerRef.current);
|
|
6915
|
+
let item;
|
|
6918
6916
|
callerRef.current = setTimeout(() => {
|
|
6919
|
-
if (selectedCollectionType) getCollectionData(selectedCollectionType.value, str
|
|
6917
|
+
if (selectedCollectionType) getCollectionData(selectedCollectionType.value, str, options => {
|
|
6918
|
+
if (typeof callback === 'function') callback(options.map(item => Object.assign({
|
|
6919
|
+
value: item['_id'] || item['id'],
|
|
6920
|
+
label: item['name']
|
|
6921
|
+
}, item)));
|
|
6922
|
+
if (formState === 'UPDATE') {
|
|
6923
|
+
const selectedOptions = (collectionItems === null || collectionItems === void 0 ? void 0 : collectionItems.map(itemId => {
|
|
6924
|
+
item = options.find(item => item._id === itemId || item.id === itemId);
|
|
6925
|
+
return item ? Object.assign({
|
|
6926
|
+
label: item.name,
|
|
6927
|
+
value: item._id || item.id
|
|
6928
|
+
}, item) : {};
|
|
6929
|
+
})) || [];
|
|
6930
|
+
if (valueToSet) {
|
|
6931
|
+
setValue(valueToSet, selectedOptions);
|
|
6932
|
+
} else {
|
|
6933
|
+
setSelectedCollectionItems(selectedOptions);
|
|
6934
|
+
}
|
|
6935
|
+
}
|
|
6936
|
+
}, collectionItems);
|
|
6920
6937
|
}, 300);
|
|
6921
6938
|
};
|
|
6922
6939
|
// Form Utility Functions
|
|
@@ -6942,7 +6959,6 @@ const WidgetForm = ({
|
|
|
6942
6959
|
if (value[name] === 'Tabs') {
|
|
6943
6960
|
const firstItemType = getFirstItemTypeValue(value[name]);
|
|
6944
6961
|
if (firstItemType) {
|
|
6945
|
-
getCollectionData(firstItemType.value);
|
|
6946
6962
|
setSelectedCollectionType(firstItemType);
|
|
6947
6963
|
}
|
|
6948
6964
|
}
|
|
@@ -6953,13 +6969,12 @@ const WidgetForm = ({
|
|
|
6953
6969
|
} else {
|
|
6954
6970
|
const selectedWType = itemsTypes.find(wType => wType.value === value[constants.itemTypeAccessor]);
|
|
6955
6971
|
setSelectedCollectionType(selectedWType);
|
|
6956
|
-
getCollectionData(value[constants.itemTypeAccessor]);
|
|
6957
6972
|
setItemsEnabled(false);
|
|
6958
6973
|
}
|
|
6959
|
-
} else if (name === null || name === void 0 ? void 0 : name.includes(constants.tabsAccessor)) {
|
|
6974
|
+
} else if ((name === null || name === void 0 ? void 0 : name.includes(constants.tabsAccessor)) && Array.isArray(value[constants.tabsAccessor])) {
|
|
6960
6975
|
setTabCollectionItems(value[constants.tabsAccessor].map(tabItem => tabItem[constants.tabCollectionItemsAccessor]));
|
|
6961
6976
|
}
|
|
6962
|
-
}, [
|
|
6977
|
+
}, [getFirstItemTypeValue, itemsTypes]);
|
|
6963
6978
|
const onFormSubmit = data => {
|
|
6964
6979
|
var _a, _b;
|
|
6965
6980
|
const formData = Object.assign({}, data);
|
|
@@ -6972,7 +6987,7 @@ const WidgetForm = ({
|
|
|
6972
6987
|
if (Array.isArray(tabsData) && (formData[constants.widgetTypeAccessor] === constants.tabsWidgetTypeValue || formState === 'UPDATE')) {
|
|
6973
6988
|
formData[constants.tabsAccessor] = tabsData.map(tabItem => ({
|
|
6974
6989
|
name: tabItem.name,
|
|
6975
|
-
collectionItems: tabItem.collectionItems.map(item => item.value)
|
|
6990
|
+
collectionItems: tabItem.collectionItems.map(item => typeof item == 'string' ? item : item.value)
|
|
6976
6991
|
}));
|
|
6977
6992
|
} else formData[constants.tabsAccessor] = [];
|
|
6978
6993
|
// setting items type if undefined
|
|
@@ -7055,7 +7070,8 @@ const WidgetForm = ({
|
|
|
7055
7070
|
placeholder: t('widget.widgetTitlePlaceholder'),
|
|
7056
7071
|
validations: {
|
|
7057
7072
|
required: t('widget.widgetTitleRequired')
|
|
7058
|
-
}
|
|
7073
|
+
},
|
|
7074
|
+
info: t('widget.widgetTitleInfo')
|
|
7059
7075
|
}, {
|
|
7060
7076
|
label: `${t('widget.widgetType')}`,
|
|
7061
7077
|
required: true,
|
|
@@ -7123,19 +7139,18 @@ const WidgetForm = ({
|
|
|
7123
7139
|
required: true,
|
|
7124
7140
|
accessor: 'collectionItems',
|
|
7125
7141
|
type: 'ReactSelect',
|
|
7126
|
-
options: collectionData
|
|
7127
|
-
value: item['_id'] || item['id'],
|
|
7128
|
-
label: item['name']
|
|
7129
|
-
}, item)),
|
|
7142
|
+
options: collectionData,
|
|
7130
7143
|
selectedOptions: selectedCollectionItems,
|
|
7131
7144
|
isMulti: true,
|
|
7132
7145
|
isSearchable: true,
|
|
7133
7146
|
onChange: setSelectedCollectionItems,
|
|
7134
|
-
|
|
7147
|
+
loadOptions: onChangeSearch,
|
|
7135
7148
|
isLoading: collectionDataLoading,
|
|
7136
7149
|
show: !itemsEnabled && selectedWidgetType !== 'Tabs',
|
|
7137
7150
|
formatOptionLabel: formatOptionLabel,
|
|
7138
|
-
listCode: selectedCollectionType === null || selectedCollectionType === void 0 ? void 0 : selectedCollectionType.value
|
|
7151
|
+
listCode: selectedCollectionType === null || selectedCollectionType === void 0 ? void 0 : selectedCollectionType.value,
|
|
7152
|
+
customStyles: reactSelectStyles || {},
|
|
7153
|
+
selectKey: selectedCollectionType === null || selectedCollectionType === void 0 ? void 0 : selectedCollectionType.value
|
|
7139
7154
|
}];
|
|
7140
7155
|
const itemFormSchema = [{
|
|
7141
7156
|
label: `${t('item.title')}`,
|
|
@@ -7216,18 +7231,17 @@ const WidgetForm = ({
|
|
|
7216
7231
|
deleteTitle: t('widget.tabDeleteTitle'),
|
|
7217
7232
|
yesButtonText: t('yesButtonText'),
|
|
7218
7233
|
noButtonText: t('cancelButtonText'),
|
|
7219
|
-
options: collectionData.map(item => Object.assign({
|
|
7220
|
-
value: item['_id'] || item['id'],
|
|
7221
|
-
label: item['name']
|
|
7222
|
-
}, item)),
|
|
7223
7234
|
itemsPlaceholder: `Select ${selectedCollectionType === null || selectedCollectionType === void 0 ? void 0 : selectedCollectionType.label}...`,
|
|
7224
|
-
|
|
7235
|
+
loadOptions: onChangeSearch,
|
|
7225
7236
|
isItemsLoading: collectionDataLoading,
|
|
7226
7237
|
formatOptionLabel: formatOptionLabel,
|
|
7227
7238
|
listCode: (selectedCollectionType === null || selectedCollectionType === void 0 ? void 0 : selectedCollectionType.value) || '',
|
|
7228
7239
|
onCollectionItemsIndexChange: onTabItemsIndexChange,
|
|
7229
7240
|
tabCollectionItems: tabCollectionItems,
|
|
7230
|
-
formatItem: formatListItem
|
|
7241
|
+
formatItem: formatListItem,
|
|
7242
|
+
customStyles: reactSelectStyles || {},
|
|
7243
|
+
activeTab: activeTab,
|
|
7244
|
+
setActiveTab: setActiveTab
|
|
7231
7245
|
}) : null, !itemsEnabled && selectedWidgetType !== 'Tabs' && /*#__PURE__*/React__default["default"].createElement(DNDItemsList, {
|
|
7232
7246
|
items: selectedCollectionItems,
|
|
7233
7247
|
onDragEnd: onCollectionIndexChange,
|
package/index.css
CHANGED
|
@@ -937,6 +937,10 @@ video {
|
|
|
937
937
|
--tw-text-opacity: 1;
|
|
938
938
|
color: rgb(55 65 81 / var(--tw-text-opacity));
|
|
939
939
|
}
|
|
940
|
+
.text-gray-400 {
|
|
941
|
+
--tw-text-opacity: 1;
|
|
942
|
+
color: rgb(156 163 175 / var(--tw-text-opacity));
|
|
943
|
+
}
|
|
940
944
|
.text-red-600 {
|
|
941
945
|
--tw-text-opacity: 1;
|
|
942
946
|
color: rgb(220 38 38 / var(--tw-text-opacity));
|
|
@@ -1504,6 +1508,13 @@ video {
|
|
|
1504
1508
|
--tw-text-opacity: 1;
|
|
1505
1509
|
color: rgb(107 114 128 / var(--tw-text-opacity));
|
|
1506
1510
|
}
|
|
1511
|
+
.khb_input-info {
|
|
1512
|
+
margin-top: 0.25rem;
|
|
1513
|
+
font-size: 0.875rem;
|
|
1514
|
+
line-height: 1.25rem;
|
|
1515
|
+
--tw-text-opacity: 1;
|
|
1516
|
+
color: rgb(156 163 175 / var(--tw-text-opacity));
|
|
1517
|
+
}
|
|
1507
1518
|
.khb_input-error {
|
|
1508
1519
|
font-size: 0.875rem;
|
|
1509
1520
|
line-height: 1.25rem;
|
|
@@ -1611,7 +1622,7 @@ video {
|
|
|
1611
1622
|
.khb_drawer-container-2 {
|
|
1612
1623
|
position: relative;
|
|
1613
1624
|
width: 100vw;
|
|
1614
|
-
max-width:
|
|
1625
|
+
max-width: 72rem;
|
|
1615
1626
|
}
|
|
1616
1627
|
.khb_drawer-close-section {
|
|
1617
1628
|
position: absolute;
|