@knovator/pagecreator-admin 0.5.4 → 0.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs +71 -73
- package/index.js +71 -73
- package/package.json +2 -2
- package/src/index.d.ts +5 -0
- package/src/lib/api/index.d.ts +10 -0
- package/src/lib/api/list.d.ts +48 -0
- package/src/lib/components/Page/AddButton/AddButton.d.ts +3 -0
- package/src/lib/components/Page/AddButton/index.d.ts +2 -0
- package/src/lib/components/Page/Form/PageForm.d.ts +4 -0
- package/src/lib/components/Page/Form/index.d.ts +2 -0
- package/src/lib/components/Page/Page/Page.d.ts +13 -0
- package/src/lib/components/Page/Page/index.d.ts +2 -0
- package/src/lib/components/Page/PageFormActions/PageFormActions.d.ts +4 -0
- package/src/lib/components/Page/PageFormActions/index.d.ts +2 -0
- package/src/lib/components/Page/PageFormWrapper/PageFormWrapper.d.ts +4 -0
- package/src/lib/components/Page/PageFormWrapper/index.d.ts +2 -0
- package/src/lib/components/Page/Pagination/PagePagination.d.ts +3 -0
- package/src/lib/components/Page/Pagination/index.d.ts +2 -0
- package/src/lib/components/Page/Search/PageSearch.d.ts +3 -0
- package/src/lib/components/Page/Search/index.d.ts +2 -0
- package/src/lib/components/Page/Table/PageTable.d.ts +3 -0
- package/src/lib/components/Page/Table/index.d.ts +2 -0
- package/src/lib/components/Page/index.d.ts +2 -0
- package/src/lib/components/Widget/AddButton/AddButton.d.ts +3 -0
- package/src/lib/components/Widget/AddButton/index.d.ts +2 -0
- package/src/lib/components/Widget/Form/ItemsAccordian.d.ts +4 -0
- package/src/lib/components/Widget/Form/Tabs/TabItem.d.ts +4 -0
- package/src/lib/components/Widget/Form/Tabs/Tabs.d.ts +4 -0
- package/src/lib/components/Widget/Form/Tabs/index.d.ts +2 -0
- package/src/lib/components/Widget/Form/WidgetForm.d.ts +4 -0
- package/src/lib/components/Widget/Form/index.d.ts +2 -0
- package/src/lib/components/Widget/Pagination/WidgetPagination.d.ts +3 -0
- package/src/lib/components/Widget/Pagination/index.d.ts +2 -0
- package/src/lib/components/Widget/Search/WidgetSearch.d.ts +3 -0
- package/src/lib/components/Widget/Search/index.d.ts +2 -0
- package/src/lib/components/Widget/Table/WidgetTable.d.ts +3 -0
- package/src/lib/components/Widget/Table/index.d.ts +2 -0
- package/src/lib/components/Widget/Widget/Widget.d.ts +13 -0
- package/src/lib/components/Widget/Widget/index.d.ts +2 -0
- package/src/lib/components/Widget/WidgetFormActions/WidgetFormActions.d.ts +4 -0
- package/src/lib/components/Widget/WidgetFormActions/index.d.ts +2 -0
- package/src/lib/components/Widget/WidgetFormWrapper/WidgetFormWrapper.d.ts +4 -0
- package/src/lib/components/Widget/WidgetFormWrapper/index.d.ts +2 -0
- package/src/lib/components/Widget/index.d.ts +2 -0
- package/src/lib/components/common/Accordian/Accordian.d.ts +13 -0
- package/src/lib/components/common/Accordian/index.d.ts +2 -0
- package/src/lib/components/common/Button/Button.d.ts +4 -0
- package/src/lib/components/common/Button/index.d.ts +2 -0
- package/src/lib/components/common/ConfirmPopover/ConfirmPopover.d.ts +4 -0
- package/src/lib/components/common/ConfirmPopover/index.d.ts +2 -0
- package/src/lib/components/common/DNDItemsList/DNDItemsList.d.ts +4 -0
- package/src/lib/components/common/DNDItemsList/index.d.ts +2 -0
- package/src/lib/components/common/DeleteModal/DeleteModal.d.ts +4 -0
- package/src/lib/components/common/DeleteModal/index.d.ts +2 -0
- package/src/lib/components/common/Drawer/Drawer.d.ts +9 -0
- package/src/lib/components/common/Drawer/index.d.ts +2 -0
- package/src/lib/components/common/Form/Form.d.ts +15 -0
- package/src/lib/components/common/Form/SimpleForm.d.ts +17 -0
- package/src/lib/components/common/Form/index.d.ts +4 -0
- package/src/lib/components/common/FormActions/FormActions.d.ts +10 -0
- package/src/lib/components/common/FormActions/index.d.ts +2 -0
- package/src/lib/components/common/ImageUpload/ImageUpload.d.ts +4 -0
- package/src/lib/components/common/ImageUpload/index.d.ts +2 -0
- package/src/lib/components/common/Input/Checkbox.d.ts +4 -0
- package/src/lib/components/common/Input/Input.d.ts +4 -0
- package/src/lib/components/common/Input/ReactSelect.d.ts +4 -0
- package/src/lib/components/common/Input/Select.d.ts +4 -0
- package/src/lib/components/common/Input/SrcSet.d.ts +4 -0
- package/src/lib/components/common/Input/index.d.ts +12 -0
- package/src/lib/components/common/Modal/Modal.d.ts +8 -0
- package/src/lib/components/common/Modal/index.d.ts +2 -0
- package/src/lib/components/common/Pagination/Pagination.d.ts +4 -0
- package/src/lib/components/common/Pagination/index.d.ts +2 -0
- package/src/lib/components/common/Table/Table.d.ts +4 -0
- package/src/lib/components/common/Table/index.d.ts +2 -0
- package/src/lib/components/common/Toggle/Toggle.d.ts +4 -0
- package/src/lib/components/common/Toggle/index.d.ts +2 -0
- package/src/lib/constants/common.d.ts +113 -0
- package/src/lib/context/PageContext.d.ts +7 -0
- package/src/lib/context/ProviderContext.d.ts +5 -0
- package/src/lib/context/WidgetContext.d.ts +7 -0
- package/src/lib/helper/utils.d.ts +11 -0
- package/src/lib/hooks/usePage.d.ts +40 -0
- package/src/lib/hooks/usePagination.d.ts +27 -0
- package/src/lib/hooks/useWidget.d.ts +50 -0
- package/src/lib/icons/chevronDown.d.ts +4 -0
- package/src/lib/icons/chevronLeft.d.ts +4 -0
- package/src/lib/icons/chevronRight.d.ts +4 -0
- package/src/lib/icons/chevronUp.d.ts +4 -0
- package/src/lib/icons/close.d.ts +4 -0
- package/src/lib/icons/pencil.d.ts +4 -0
- package/src/lib/icons/plus.d.ts +4 -0
- package/src/lib/icons/trash.d.ts +4 -0
- package/src/lib/types/api.d.ts +34 -0
- package/src/lib/types/common.d.ts +25 -0
- package/src/lib/types/components.d.ts +307 -0
- package/src/lib/types/context.d.ts +97 -0
- package/src/lib/types/index.d.ts +4 -0
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');
|
|
@@ -3323,19 +3323,19 @@ const CustomReactSelect = ({
|
|
|
3323
3323
|
onChange,
|
|
3324
3324
|
label,
|
|
3325
3325
|
error,
|
|
3326
|
-
options: _options = [],
|
|
3327
3326
|
className,
|
|
3328
3327
|
isMulti,
|
|
3329
3328
|
selectedOptions: _selectedOptions = [],
|
|
3330
3329
|
required,
|
|
3331
3330
|
isLoading,
|
|
3332
3331
|
isSearchable,
|
|
3333
|
-
|
|
3332
|
+
loadOptions,
|
|
3334
3333
|
placeholder,
|
|
3335
3334
|
wrapperClassName,
|
|
3336
3335
|
formatOptionLabel,
|
|
3337
3336
|
listCode,
|
|
3338
|
-
customStyles
|
|
3337
|
+
customStyles,
|
|
3338
|
+
selectKey
|
|
3339
3339
|
}) => {
|
|
3340
3340
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
3341
3341
|
className: wrapperClassName
|
|
@@ -3344,6 +3344,7 @@ const CustomReactSelect = ({
|
|
|
3344
3344
|
}, label, required ? /*#__PURE__*/React__default["default"].createElement("span", {
|
|
3345
3345
|
className: "khb_input-label-required"
|
|
3346
3346
|
}, "*") : null), /*#__PURE__*/React__default["default"].createElement(ReactSelect__default["default"], {
|
|
3347
|
+
key: selectKey,
|
|
3347
3348
|
"data-testid": `input-select-${label}`,
|
|
3348
3349
|
value: _selectedOptions,
|
|
3349
3350
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -3351,10 +3352,10 @@ const CustomReactSelect = ({
|
|
|
3351
3352
|
onChange: onChange,
|
|
3352
3353
|
className: classNames__default["default"](className),
|
|
3353
3354
|
isMulti: isMulti,
|
|
3354
|
-
|
|
3355
|
+
defaultOptions: true,
|
|
3355
3356
|
isSearchable: isSearchable,
|
|
3356
3357
|
isLoading: isLoading,
|
|
3357
|
-
|
|
3358
|
+
loadOptions: loadOptions,
|
|
3358
3359
|
placeholder: placeholder,
|
|
3359
3360
|
formatOptionLabel: formatOptionLabel ? option => formatOptionLabel(listCode, option) : undefined,
|
|
3360
3361
|
styles: customStyles
|
|
@@ -3723,7 +3724,6 @@ const Form = /*#__PURE__*/React.forwardRef(({
|
|
|
3723
3724
|
switch (schema.type) {
|
|
3724
3725
|
case 'ReactSelect':
|
|
3725
3726
|
input = /*#__PURE__*/React__default["default"].createElement(CustomReactSelect, {
|
|
3726
|
-
options: schema.options,
|
|
3727
3727
|
disabled: !_enable,
|
|
3728
3728
|
label: schema.label,
|
|
3729
3729
|
error: (_b = (_a = errors[schema.accessor]) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.toString(),
|
|
@@ -3737,11 +3737,12 @@ const Form = /*#__PURE__*/React.forwardRef(({
|
|
|
3737
3737
|
required: schema.required,
|
|
3738
3738
|
isMulti: schema.isMulti,
|
|
3739
3739
|
isSearchable: schema.isSearchable,
|
|
3740
|
-
onSearch: schema.onSearch,
|
|
3741
3740
|
isLoading: schema.isLoading,
|
|
3742
3741
|
placeholder: schema.placeholder,
|
|
3743
3742
|
wrapperClassName: schema.wrapperClassName,
|
|
3744
|
-
formatOptionLabel: schema.formatOptionLabel
|
|
3743
|
+
formatOptionLabel: schema.formatOptionLabel,
|
|
3744
|
+
selectKey: schema.selectKey,
|
|
3745
|
+
loadOptions: schema.loadOptions
|
|
3745
3746
|
});
|
|
3746
3747
|
break;
|
|
3747
3748
|
case 'checkbox':
|
|
@@ -3876,7 +3877,6 @@ const SimpleForm = /*#__PURE__*/React.forwardRef(({
|
|
|
3876
3877
|
switch (schema.type) {
|
|
3877
3878
|
case 'ReactSelect':
|
|
3878
3879
|
input = /*#__PURE__*/React__default["default"].createElement(CustomReactSelect, {
|
|
3879
|
-
options: schema.options,
|
|
3880
3880
|
disabled: !_enable,
|
|
3881
3881
|
label: schema.label,
|
|
3882
3882
|
error: (_b = (_a = errors[schema.accessor]) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.toString(),
|
|
@@ -3890,13 +3890,14 @@ const SimpleForm = /*#__PURE__*/React.forwardRef(({
|
|
|
3890
3890
|
required: schema.required,
|
|
3891
3891
|
isMulti: schema.isMulti,
|
|
3892
3892
|
isSearchable: schema.isSearchable,
|
|
3893
|
-
onSearch: schema.onSearch,
|
|
3894
3893
|
isLoading: schema.isLoading,
|
|
3895
3894
|
placeholder: schema.placeholder,
|
|
3896
3895
|
wrapperClassName: schema.wrapperClassName,
|
|
3897
3896
|
formatOptionLabel: schema.formatOptionLabel,
|
|
3898
3897
|
listCode: schema.listCode,
|
|
3899
|
-
customStyles: schema.customStyles
|
|
3898
|
+
customStyles: schema.customStyles,
|
|
3899
|
+
loadOptions: schema.loadOptions,
|
|
3900
|
+
selectKey: schema.selectKey
|
|
3900
3901
|
});
|
|
3901
3902
|
break;
|
|
3902
3903
|
case 'checkbox':
|
|
@@ -4837,7 +4838,7 @@ const useWidget = ({
|
|
|
4837
4838
|
}
|
|
4838
4839
|
setLoading(false);
|
|
4839
4840
|
});
|
|
4840
|
-
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* () {
|
|
4841
4842
|
setCollectionDataLoading(true);
|
|
4842
4843
|
const api = getApiType({
|
|
4843
4844
|
routes,
|
|
@@ -4853,7 +4854,8 @@ const useWidget = ({
|
|
|
4853
4854
|
onError: handleError(CALLBACK_CODES.GET_ALL),
|
|
4854
4855
|
data: {
|
|
4855
4856
|
search: search || '',
|
|
4856
|
-
collectionName
|
|
4857
|
+
collectionName,
|
|
4858
|
+
collectionItems: collectionItems || []
|
|
4857
4859
|
}
|
|
4858
4860
|
});
|
|
4859
4861
|
if ((response === null || response === void 0 ? void 0 : response.code) === 'SUCCESS') {
|
|
@@ -4897,35 +4899,6 @@ const useWidget = ({
|
|
|
4897
4899
|
setFormState(undefined);
|
|
4898
4900
|
setItemData(null);
|
|
4899
4901
|
};
|
|
4900
|
-
const updateCollectionDataReferences = itemData => collectionData => {
|
|
4901
|
-
const itemDataUpdated = Object.assign({}, itemData);
|
|
4902
|
-
if (itemDataUpdated['tabs'] && itemDataUpdated['tabs'].length > 0 && collectionData && collectionData.length > 0) {
|
|
4903
|
-
itemDataUpdated['tabs'] = itemDataUpdated['tabs'].map(item => {
|
|
4904
|
-
var _a;
|
|
4905
|
-
return {
|
|
4906
|
-
name: item.name,
|
|
4907
|
-
collectionItems: ((_a = item === null || item === void 0 ? void 0 : item.collectionItems) === null || _a === void 0 ? void 0 : _a.map(itemId => {
|
|
4908
|
-
item = collectionData.find(item => item._id === itemId || item.id === itemId);
|
|
4909
|
-
return item ? Object.assign({
|
|
4910
|
-
label: item.name,
|
|
4911
|
-
value: item._id || item.id
|
|
4912
|
-
}, item) : {};
|
|
4913
|
-
})) || []
|
|
4914
|
-
};
|
|
4915
|
-
});
|
|
4916
|
-
}
|
|
4917
|
-
if (itemDataUpdated['collectionItems'] && itemDataUpdated['collectionItems'].length > 0 && collectionData && collectionData.length > 0) {
|
|
4918
|
-
let item;
|
|
4919
|
-
itemDataUpdated['collectionItems'] = itemDataUpdated['collectionItems'].map(itemId => {
|
|
4920
|
-
item = collectionData.find(item => item._id === itemId || item.id === itemId);
|
|
4921
|
-
return item ? Object.assign({
|
|
4922
|
-
label: item.name,
|
|
4923
|
-
value: item._id || item.id
|
|
4924
|
-
}, item) : {};
|
|
4925
|
-
});
|
|
4926
|
-
}
|
|
4927
|
-
setItemData(itemDataUpdated);
|
|
4928
|
-
};
|
|
4929
4902
|
const onChangeFormState = (state, data) => {
|
|
4930
4903
|
setFormState(state);
|
|
4931
4904
|
// fetch ItemsTypes & WidgetTypes if needed
|
|
@@ -4935,10 +4908,10 @@ const useWidget = ({
|
|
|
4935
4908
|
}
|
|
4936
4909
|
// get Item data if widget is updating
|
|
4937
4910
|
if (state === 'UPDATE' && data) {
|
|
4938
|
-
if (data['itemsType']
|
|
4911
|
+
if (data['itemsType'] === 'Image') {
|
|
4939
4912
|
getItems(data['_id']);
|
|
4940
|
-
setItemData(data);
|
|
4941
4913
|
}
|
|
4914
|
+
setItemData(data);
|
|
4942
4915
|
} else if (state === 'ADD') {
|
|
4943
4916
|
// reset Item data if widget is adding
|
|
4944
4917
|
setItemsList({
|
|
@@ -6734,23 +6707,24 @@ const TabItem = ({
|
|
|
6734
6707
|
};
|
|
6735
6708
|
|
|
6736
6709
|
const Tabs = ({
|
|
6710
|
+
activeTab,
|
|
6711
|
+
setActiveTab,
|
|
6737
6712
|
options,
|
|
6738
6713
|
control,
|
|
6739
6714
|
register,
|
|
6740
6715
|
listCode,
|
|
6741
6716
|
formatItem,
|
|
6742
6717
|
deleteTitle,
|
|
6718
|
+
loadOptions,
|
|
6743
6719
|
customStyles,
|
|
6744
6720
|
noButtonText,
|
|
6745
6721
|
yesButtonText,
|
|
6746
|
-
onItemsSearch,
|
|
6747
6722
|
isItemsLoading,
|
|
6748
6723
|
itemsPlaceholder,
|
|
6749
6724
|
formatOptionLabel,
|
|
6750
6725
|
tabCollectionItems,
|
|
6751
6726
|
onCollectionItemsIndexChange
|
|
6752
6727
|
}) => {
|
|
6753
|
-
const [activeTab, setActiveTab] = React.useState(0);
|
|
6754
6728
|
const {
|
|
6755
6729
|
fields: tabFields,
|
|
6756
6730
|
append: appendField,
|
|
@@ -6808,16 +6782,17 @@ const Tabs = ({
|
|
|
6808
6782
|
onChange
|
|
6809
6783
|
}
|
|
6810
6784
|
}) => /*#__PURE__*/React__default["default"].createElement(CustomReactSelect, {
|
|
6811
|
-
options: options,
|
|
6785
|
+
options: options || [],
|
|
6812
6786
|
onChange: value => {
|
|
6813
6787
|
if (value) {
|
|
6814
6788
|
if (Array.isArray(value)) onChange(value);else onChange([value]);
|
|
6815
6789
|
}
|
|
6816
6790
|
},
|
|
6791
|
+
selectKey: `tabs.${index}.collectionItems.${listCode}`,
|
|
6817
6792
|
selectedOptions: value,
|
|
6818
6793
|
isMulti: true,
|
|
6819
6794
|
isSearchable: true,
|
|
6820
|
-
|
|
6795
|
+
loadOptions: loadOptions,
|
|
6821
6796
|
isLoading: isItemsLoading,
|
|
6822
6797
|
placeholder: itemsPlaceholder,
|
|
6823
6798
|
listCode: listCode,
|
|
@@ -6837,6 +6812,7 @@ const constants = {
|
|
|
6837
6812
|
widgetTypeAccessor: 'widgetType',
|
|
6838
6813
|
itemTypeAccessor: 'itemsType',
|
|
6839
6814
|
collectionNameAccessor: 'collectionName',
|
|
6815
|
+
collectionItemsAccessor: 'collectionItems',
|
|
6840
6816
|
tabsWidgetTypeValue: 'Tabs',
|
|
6841
6817
|
fixedCardWidgetTypeValue: 'FixedCard',
|
|
6842
6818
|
carouselWidgetTypeValue: 'Carousel',
|
|
@@ -6889,6 +6865,7 @@ const WidgetForm = ({
|
|
|
6889
6865
|
reactSelectStyles
|
|
6890
6866
|
} = useWidgetState();
|
|
6891
6867
|
const callerRef = React.useRef(null);
|
|
6868
|
+
const [activeTab, setActiveTab] = React.useState(0);
|
|
6892
6869
|
const [webItemsVisible, setWebItemsVisible] = React.useState(false);
|
|
6893
6870
|
const [mobileItemsVisible, setMobileItemsVisible] = React.useState(false);
|
|
6894
6871
|
const [selectedWidgetType, setSelectedWidgetType] = React.useState();
|
|
@@ -6904,11 +6881,6 @@ const WidgetForm = ({
|
|
|
6904
6881
|
} else {
|
|
6905
6882
|
setItemsEnabled(false);
|
|
6906
6883
|
}
|
|
6907
|
-
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) {
|
|
6908
|
-
setSelectedCollectionItems((data === null || data === void 0 ? void 0 : data.collectionItems) || []);
|
|
6909
|
-
} else {
|
|
6910
|
-
setSelectedCollectionItems([]);
|
|
6911
|
-
}
|
|
6912
6884
|
if ((data === null || data === void 0 ? void 0 : data.collectionName) !== 'Image' && itemsTypes && itemsTypes.length > 0) {
|
|
6913
6885
|
setSelectedCollectionType(itemsTypes.find(item => item.value === (data === null || data === void 0 ? void 0 : data.collectionName)));
|
|
6914
6886
|
}
|
|
@@ -6926,10 +6898,42 @@ const WidgetForm = ({
|
|
|
6926
6898
|
reset(data);
|
|
6927
6899
|
}
|
|
6928
6900
|
}, [data, reset]);
|
|
6929
|
-
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
|
+
|
|
6930
6914
|
if (callerRef.current) clearTimeout(callerRef.current);
|
|
6915
|
+
let item;
|
|
6931
6916
|
callerRef.current = setTimeout(() => {
|
|
6932
|
-
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);
|
|
6933
6937
|
}, 300);
|
|
6934
6938
|
};
|
|
6935
6939
|
// Form Utility Functions
|
|
@@ -6955,7 +6959,6 @@ const WidgetForm = ({
|
|
|
6955
6959
|
if (value[name] === 'Tabs') {
|
|
6956
6960
|
const firstItemType = getFirstItemTypeValue(value[name]);
|
|
6957
6961
|
if (firstItemType) {
|
|
6958
|
-
getCollectionData(firstItemType.value);
|
|
6959
6962
|
setSelectedCollectionType(firstItemType);
|
|
6960
6963
|
}
|
|
6961
6964
|
}
|
|
@@ -6966,13 +6969,12 @@ const WidgetForm = ({
|
|
|
6966
6969
|
} else {
|
|
6967
6970
|
const selectedWType = itemsTypes.find(wType => wType.value === value[constants.itemTypeAccessor]);
|
|
6968
6971
|
setSelectedCollectionType(selectedWType);
|
|
6969
|
-
getCollectionData(value[constants.itemTypeAccessor]);
|
|
6970
6972
|
setItemsEnabled(false);
|
|
6971
6973
|
}
|
|
6972
|
-
} 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])) {
|
|
6973
6975
|
setTabCollectionItems(value[constants.tabsAccessor].map(tabItem => tabItem[constants.tabCollectionItemsAccessor]));
|
|
6974
6976
|
}
|
|
6975
|
-
}, [
|
|
6977
|
+
}, [getFirstItemTypeValue, itemsTypes]);
|
|
6976
6978
|
const onFormSubmit = data => {
|
|
6977
6979
|
var _a, _b;
|
|
6978
6980
|
const formData = Object.assign({}, data);
|
|
@@ -6985,7 +6987,7 @@ const WidgetForm = ({
|
|
|
6985
6987
|
if (Array.isArray(tabsData) && (formData[constants.widgetTypeAccessor] === constants.tabsWidgetTypeValue || formState === 'UPDATE')) {
|
|
6986
6988
|
formData[constants.tabsAccessor] = tabsData.map(tabItem => ({
|
|
6987
6989
|
name: tabItem.name,
|
|
6988
|
-
collectionItems: tabItem.collectionItems.map(item => item.value)
|
|
6990
|
+
collectionItems: tabItem.collectionItems.map(item => typeof item == 'string' ? item : item.value)
|
|
6989
6991
|
}));
|
|
6990
6992
|
} else formData[constants.tabsAccessor] = [];
|
|
6991
6993
|
// setting items type if undefined
|
|
@@ -7137,20 +7139,18 @@ const WidgetForm = ({
|
|
|
7137
7139
|
required: true,
|
|
7138
7140
|
accessor: 'collectionItems',
|
|
7139
7141
|
type: 'ReactSelect',
|
|
7140
|
-
options: collectionData
|
|
7141
|
-
value: item['_id'] || item['id'],
|
|
7142
|
-
label: item['name']
|
|
7143
|
-
}, item)),
|
|
7142
|
+
options: collectionData,
|
|
7144
7143
|
selectedOptions: selectedCollectionItems,
|
|
7145
7144
|
isMulti: true,
|
|
7146
7145
|
isSearchable: true,
|
|
7147
7146
|
onChange: setSelectedCollectionItems,
|
|
7148
|
-
|
|
7147
|
+
loadOptions: onChangeSearch,
|
|
7149
7148
|
isLoading: collectionDataLoading,
|
|
7150
7149
|
show: !itemsEnabled && selectedWidgetType !== 'Tabs',
|
|
7151
7150
|
formatOptionLabel: formatOptionLabel,
|
|
7152
7151
|
listCode: selectedCollectionType === null || selectedCollectionType === void 0 ? void 0 : selectedCollectionType.value,
|
|
7153
|
-
customStyles: reactSelectStyles || {}
|
|
7152
|
+
customStyles: reactSelectStyles || {},
|
|
7153
|
+
selectKey: selectedCollectionType === null || selectedCollectionType === void 0 ? void 0 : selectedCollectionType.value
|
|
7154
7154
|
}];
|
|
7155
7155
|
const itemFormSchema = [{
|
|
7156
7156
|
label: `${t('item.title')}`,
|
|
@@ -7231,19 +7231,17 @@ const WidgetForm = ({
|
|
|
7231
7231
|
deleteTitle: t('widget.tabDeleteTitle'),
|
|
7232
7232
|
yesButtonText: t('yesButtonText'),
|
|
7233
7233
|
noButtonText: t('cancelButtonText'),
|
|
7234
|
-
options: collectionData.map(item => Object.assign({
|
|
7235
|
-
value: item['_id'] || item['id'],
|
|
7236
|
-
label: item['name']
|
|
7237
|
-
}, item)),
|
|
7238
7234
|
itemsPlaceholder: `Select ${selectedCollectionType === null || selectedCollectionType === void 0 ? void 0 : selectedCollectionType.label}...`,
|
|
7239
|
-
|
|
7235
|
+
loadOptions: onChangeSearch,
|
|
7240
7236
|
isItemsLoading: collectionDataLoading,
|
|
7241
7237
|
formatOptionLabel: formatOptionLabel,
|
|
7242
7238
|
listCode: (selectedCollectionType === null || selectedCollectionType === void 0 ? void 0 : selectedCollectionType.value) || '',
|
|
7243
7239
|
onCollectionItemsIndexChange: onTabItemsIndexChange,
|
|
7244
7240
|
tabCollectionItems: tabCollectionItems,
|
|
7245
7241
|
formatItem: formatListItem,
|
|
7246
|
-
customStyles: reactSelectStyles || {}
|
|
7242
|
+
customStyles: reactSelectStyles || {},
|
|
7243
|
+
activeTab: activeTab,
|
|
7244
|
+
setActiveTab: setActiveTab
|
|
7247
7245
|
}) : null, !itemsEnabled && selectedWidgetType !== 'Tabs' && /*#__PURE__*/React__default["default"].createElement(DNDItemsList, {
|
|
7248
7246
|
items: selectedCollectionItems,
|
|
7249
7247
|
onDragEnd: onCollectionIndexChange,
|