@knovator/pagecreator-admin 1.5.3 → 1.5.4
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 +22 -6
- package/index.js +22 -6
- package/package.json +1 -1
- package/src/lib/types/components.d.ts +2 -2
package/index.cjs
CHANGED
|
@@ -4028,6 +4028,7 @@ const DNDItemsList = ({
|
|
|
4028
4028
|
onFilterClick,
|
|
4029
4029
|
disableSettings: _disableSettings = false
|
|
4030
4030
|
}) => {
|
|
4031
|
+
console.log('items: ', items);
|
|
4031
4032
|
return /*#__PURE__*/React__default["default"].createElement(DragDropContextWrapper, {
|
|
4032
4033
|
onDragEnd: onDragEnd
|
|
4033
4034
|
}, /*#__PURE__*/React__default["default"].createElement(DroppableWrapper, {
|
|
@@ -7118,6 +7119,8 @@ const constants = {
|
|
|
7118
7119
|
imageItemsTypeValue: 'Image',
|
|
7119
7120
|
textWidgetTypeValue: 'Text',
|
|
7120
7121
|
htmlWidgetTypeValue: 'HTML',
|
|
7122
|
+
linksWidgetTypeValue: 'Links',
|
|
7123
|
+
pagesItemsTypeValue: 'pages',
|
|
7121
7124
|
tabsAccessor: 'tabs',
|
|
7122
7125
|
webItems: 'webItems',
|
|
7123
7126
|
mobileItems: 'mobileItems',
|
|
@@ -7186,7 +7189,7 @@ const WidgetForm = ({
|
|
|
7186
7189
|
if ((data === null || data === void 0 ? void 0 : data.collectionName) !== constants.imageItemsTypeValue && itemsTypes && itemsTypes.length > 0) {
|
|
7187
7190
|
setSelectedCollectionType(itemsTypes.find(item => item.value === (data === null || data === void 0 ? void 0 : data.collectionName)));
|
|
7188
7191
|
}
|
|
7189
|
-
if ((data === null || data === void 0 ? void 0 : data.widgetType) === constants.textWidgetTypeValue || (data === null || data === void 0 ? void 0 : data.widgetType) === constants.htmlWidgetTypeValue) {
|
|
7192
|
+
if ((data === null || data === void 0 ? void 0 : data.widgetType) === constants.textWidgetTypeValue || (data === null || data === void 0 ? void 0 : data.widgetType) === constants.htmlWidgetTypeValue || (data === null || data === void 0 ? void 0 : data.widgetType) === constants.linksWidgetTypeValue) {
|
|
7190
7193
|
setItemsEnabled(false);
|
|
7191
7194
|
}
|
|
7192
7195
|
}
|
|
@@ -7203,7 +7206,7 @@ const WidgetForm = ({
|
|
|
7203
7206
|
reset(data);
|
|
7204
7207
|
}
|
|
7205
7208
|
}, [data, reset]);
|
|
7206
|
-
const onChangeSearch = (str, callback) => {
|
|
7209
|
+
const onChangeSearch = (str, callback, collectionName) => {
|
|
7207
7210
|
let collectionItems = [];
|
|
7208
7211
|
let valueToSet = '';
|
|
7209
7212
|
if (formState === 'UPDATE') {
|
|
@@ -7220,8 +7223,10 @@ const WidgetForm = ({
|
|
|
7220
7223
|
}
|
|
7221
7224
|
if (callerRef.current) clearTimeout(callerRef.current);
|
|
7222
7225
|
let item;
|
|
7226
|
+
// Use passed collectionName or fall back to selectedCollectionType
|
|
7227
|
+
const collectionToUse = collectionName || (selectedCollectionType === null || selectedCollectionType === void 0 ? void 0 : selectedCollectionType.value);
|
|
7223
7228
|
callerRef.current = setTimeout(() => {
|
|
7224
|
-
if (
|
|
7229
|
+
if (collectionToUse) getCollectionData(collectionToUse, str, options => {
|
|
7225
7230
|
if (typeof callback === 'function') callback(options.map(item => Object.assign({
|
|
7226
7231
|
value: item['_id'] || item['id'],
|
|
7227
7232
|
label: item['name']
|
|
@@ -7276,6 +7281,12 @@ const WidgetForm = ({
|
|
|
7276
7281
|
setSelectedWidgetType(widgetType);
|
|
7277
7282
|
if ((widgetType === null || widgetType === void 0 ? void 0 : widgetType.value) === constants.textWidgetTypeValue || (widgetType === null || widgetType === void 0 ? void 0 : widgetType.value) === constants.htmlWidgetTypeValue) {
|
|
7278
7283
|
setItemsEnabled(false);
|
|
7284
|
+
} else if ((widgetType === null || widgetType === void 0 ? void 0 : widgetType.value) === constants.linksWidgetTypeValue) {
|
|
7285
|
+
setItemsEnabled(false);
|
|
7286
|
+
setValue(constants.itemTypeAccessor, constants.pagesItemsTypeValue);
|
|
7287
|
+
setValue(constants.collectionNameAccessor, constants.pagesItemsTypeValue);
|
|
7288
|
+
const pagesOption = itemsTypes.find(item => item.value === constants.pagesItemsTypeValue);
|
|
7289
|
+
if (pagesOption) setSelectedCollectionType(pagesOption);
|
|
7279
7290
|
} else {
|
|
7280
7291
|
setItemsEnabled(true);
|
|
7281
7292
|
}
|
|
@@ -7352,8 +7363,13 @@ const WidgetForm = ({
|
|
|
7352
7363
|
if (!formData[constants.itemTypeAccessor] && formState === 'ADD') {
|
|
7353
7364
|
formData[constants.itemTypeAccessor] = (_a = getFirstItemTypeValue(formData[constants.widgetTypeAccessor])) === null || _a === void 0 ? void 0 : _a.value;
|
|
7354
7365
|
}
|
|
7366
|
+
// Force collectionName and itemsType for Links widget
|
|
7367
|
+
if (formData[constants.widgetTypeAccessor] === constants.linksWidgetTypeValue) {
|
|
7368
|
+
formData[constants.collectionNameAccessor] = constants.pagesItemsTypeValue;
|
|
7369
|
+
formData[constants.itemTypeAccessor] = constants.pagesItemsTypeValue;
|
|
7370
|
+
}
|
|
7355
7371
|
// setting collectionName if widgetType is FixedCard or Carousel and FormState
|
|
7356
|
-
if (formData[constants.itemTypeAccessor] !== constants.imageItemsTypeValue && formState === 'ADD') {
|
|
7372
|
+
else if (formData[constants.itemTypeAccessor] !== constants.imageItemsTypeValue && formState === 'ADD') {
|
|
7357
7373
|
formData[constants.collectionNameAccessor] = selectedCollectionType ? selectedCollectionType.value : (_b = getFirstItemTypeValue(formData[constants.widgetTypeAccessor])) === null || _b === void 0 ? void 0 : _b.value;
|
|
7358
7374
|
}
|
|
7359
7375
|
// setting colleciton items if collectionItems are there
|
|
@@ -7510,7 +7526,7 @@ const WidgetForm = ({
|
|
|
7510
7526
|
validations: {
|
|
7511
7527
|
required: widgetTranslations.itemsTypePlaceholder
|
|
7512
7528
|
},
|
|
7513
|
-
options: (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) === constants.tabsWidgetTypeValue || (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.collectionsOnly) ? itemsTypes.filter(item => item.label !== constants.imageItemsTypeValue) : (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.imageOnly) ? itemsTypes.filter(item => item.label === constants.imageItemsTypeValue) : itemsTypes
|
|
7529
|
+
options: (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) === constants.linksWidgetTypeValue ? itemsTypes.filter(item => item.value === constants.pagesItemsTypeValue) : (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) === constants.tabsWidgetTypeValue || (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.collectionsOnly) ? itemsTypes.filter(item => item.label !== constants.imageItemsTypeValue && item.value !== constants.pagesItemsTypeValue) : (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.imageOnly) ? itemsTypes.filter(item => item.label === constants.imageItemsTypeValue) : itemsTypes.filter(item => item.value !== constants.pagesItemsTypeValue)
|
|
7514
7530
|
}, {
|
|
7515
7531
|
label: widgetTranslations.color,
|
|
7516
7532
|
accessor: 'backgroundColor',
|
|
@@ -7573,7 +7589,7 @@ const WidgetForm = ({
|
|
|
7573
7589
|
onChange: setSelectedCollectionItems,
|
|
7574
7590
|
loadOptions: onChangeSearch,
|
|
7575
7591
|
isLoading: collectionDataLoading,
|
|
7576
|
-
show: !itemsEnabled && ((selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) === constants.carouselWidgetTypeValue || (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) === constants.fixedCardWidgetTypeValue || !selectedWidgetType) && !!(selectedCollectionType === null || selectedCollectionType === void 0 ? void 0 : selectedCollectionType.value),
|
|
7592
|
+
show: !itemsEnabled && ((selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) === constants.carouselWidgetTypeValue || (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) === constants.fixedCardWidgetTypeValue || (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) === constants.linksWidgetTypeValue || !selectedWidgetType) && !!(selectedCollectionType === null || selectedCollectionType === void 0 ? void 0 : selectedCollectionType.value),
|
|
7577
7593
|
formatOptionLabel: formatOptionLabel,
|
|
7578
7594
|
listCode: selectedCollectionType === null || selectedCollectionType === void 0 ? void 0 : selectedCollectionType.value,
|
|
7579
7595
|
customStyles: reactSelectStyles || {},
|
package/index.js
CHANGED
|
@@ -4016,6 +4016,7 @@ const DNDItemsList = ({
|
|
|
4016
4016
|
onFilterClick,
|
|
4017
4017
|
disableSettings: _disableSettings = false
|
|
4018
4018
|
}) => {
|
|
4019
|
+
console.log('items: ', items);
|
|
4019
4020
|
return /*#__PURE__*/React.createElement(DragDropContextWrapper, {
|
|
4020
4021
|
onDragEnd: onDragEnd
|
|
4021
4022
|
}, /*#__PURE__*/React.createElement(DroppableWrapper, {
|
|
@@ -7106,6 +7107,8 @@ const constants = {
|
|
|
7106
7107
|
imageItemsTypeValue: 'Image',
|
|
7107
7108
|
textWidgetTypeValue: 'Text',
|
|
7108
7109
|
htmlWidgetTypeValue: 'HTML',
|
|
7110
|
+
linksWidgetTypeValue: 'Links',
|
|
7111
|
+
pagesItemsTypeValue: 'pages',
|
|
7109
7112
|
tabsAccessor: 'tabs',
|
|
7110
7113
|
webItems: 'webItems',
|
|
7111
7114
|
mobileItems: 'mobileItems',
|
|
@@ -7174,7 +7177,7 @@ const WidgetForm = ({
|
|
|
7174
7177
|
if ((data === null || data === void 0 ? void 0 : data.collectionName) !== constants.imageItemsTypeValue && itemsTypes && itemsTypes.length > 0) {
|
|
7175
7178
|
setSelectedCollectionType(itemsTypes.find(item => item.value === (data === null || data === void 0 ? void 0 : data.collectionName)));
|
|
7176
7179
|
}
|
|
7177
|
-
if ((data === null || data === void 0 ? void 0 : data.widgetType) === constants.textWidgetTypeValue || (data === null || data === void 0 ? void 0 : data.widgetType) === constants.htmlWidgetTypeValue) {
|
|
7180
|
+
if ((data === null || data === void 0 ? void 0 : data.widgetType) === constants.textWidgetTypeValue || (data === null || data === void 0 ? void 0 : data.widgetType) === constants.htmlWidgetTypeValue || (data === null || data === void 0 ? void 0 : data.widgetType) === constants.linksWidgetTypeValue) {
|
|
7178
7181
|
setItemsEnabled(false);
|
|
7179
7182
|
}
|
|
7180
7183
|
}
|
|
@@ -7191,7 +7194,7 @@ const WidgetForm = ({
|
|
|
7191
7194
|
reset(data);
|
|
7192
7195
|
}
|
|
7193
7196
|
}, [data, reset]);
|
|
7194
|
-
const onChangeSearch = (str, callback) => {
|
|
7197
|
+
const onChangeSearch = (str, callback, collectionName) => {
|
|
7195
7198
|
let collectionItems = [];
|
|
7196
7199
|
let valueToSet = '';
|
|
7197
7200
|
if (formState === 'UPDATE') {
|
|
@@ -7208,8 +7211,10 @@ const WidgetForm = ({
|
|
|
7208
7211
|
}
|
|
7209
7212
|
if (callerRef.current) clearTimeout(callerRef.current);
|
|
7210
7213
|
let item;
|
|
7214
|
+
// Use passed collectionName or fall back to selectedCollectionType
|
|
7215
|
+
const collectionToUse = collectionName || (selectedCollectionType === null || selectedCollectionType === void 0 ? void 0 : selectedCollectionType.value);
|
|
7211
7216
|
callerRef.current = setTimeout(() => {
|
|
7212
|
-
if (
|
|
7217
|
+
if (collectionToUse) getCollectionData(collectionToUse, str, options => {
|
|
7213
7218
|
if (typeof callback === 'function') callback(options.map(item => Object.assign({
|
|
7214
7219
|
value: item['_id'] || item['id'],
|
|
7215
7220
|
label: item['name']
|
|
@@ -7264,6 +7269,12 @@ const WidgetForm = ({
|
|
|
7264
7269
|
setSelectedWidgetType(widgetType);
|
|
7265
7270
|
if ((widgetType === null || widgetType === void 0 ? void 0 : widgetType.value) === constants.textWidgetTypeValue || (widgetType === null || widgetType === void 0 ? void 0 : widgetType.value) === constants.htmlWidgetTypeValue) {
|
|
7266
7271
|
setItemsEnabled(false);
|
|
7272
|
+
} else if ((widgetType === null || widgetType === void 0 ? void 0 : widgetType.value) === constants.linksWidgetTypeValue) {
|
|
7273
|
+
setItemsEnabled(false);
|
|
7274
|
+
setValue(constants.itemTypeAccessor, constants.pagesItemsTypeValue);
|
|
7275
|
+
setValue(constants.collectionNameAccessor, constants.pagesItemsTypeValue);
|
|
7276
|
+
const pagesOption = itemsTypes.find(item => item.value === constants.pagesItemsTypeValue);
|
|
7277
|
+
if (pagesOption) setSelectedCollectionType(pagesOption);
|
|
7267
7278
|
} else {
|
|
7268
7279
|
setItemsEnabled(true);
|
|
7269
7280
|
}
|
|
@@ -7340,8 +7351,13 @@ const WidgetForm = ({
|
|
|
7340
7351
|
if (!formData[constants.itemTypeAccessor] && formState === 'ADD') {
|
|
7341
7352
|
formData[constants.itemTypeAccessor] = (_a = getFirstItemTypeValue(formData[constants.widgetTypeAccessor])) === null || _a === void 0 ? void 0 : _a.value;
|
|
7342
7353
|
}
|
|
7354
|
+
// Force collectionName and itemsType for Links widget
|
|
7355
|
+
if (formData[constants.widgetTypeAccessor] === constants.linksWidgetTypeValue) {
|
|
7356
|
+
formData[constants.collectionNameAccessor] = constants.pagesItemsTypeValue;
|
|
7357
|
+
formData[constants.itemTypeAccessor] = constants.pagesItemsTypeValue;
|
|
7358
|
+
}
|
|
7343
7359
|
// setting collectionName if widgetType is FixedCard or Carousel and FormState
|
|
7344
|
-
if (formData[constants.itemTypeAccessor] !== constants.imageItemsTypeValue && formState === 'ADD') {
|
|
7360
|
+
else if (formData[constants.itemTypeAccessor] !== constants.imageItemsTypeValue && formState === 'ADD') {
|
|
7345
7361
|
formData[constants.collectionNameAccessor] = selectedCollectionType ? selectedCollectionType.value : (_b = getFirstItemTypeValue(formData[constants.widgetTypeAccessor])) === null || _b === void 0 ? void 0 : _b.value;
|
|
7346
7362
|
}
|
|
7347
7363
|
// setting colleciton items if collectionItems are there
|
|
@@ -7498,7 +7514,7 @@ const WidgetForm = ({
|
|
|
7498
7514
|
validations: {
|
|
7499
7515
|
required: widgetTranslations.itemsTypePlaceholder
|
|
7500
7516
|
},
|
|
7501
|
-
options: (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) === constants.tabsWidgetTypeValue || (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.collectionsOnly) ? itemsTypes.filter(item => item.label !== constants.imageItemsTypeValue) : (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.imageOnly) ? itemsTypes.filter(item => item.label === constants.imageItemsTypeValue) : itemsTypes
|
|
7517
|
+
options: (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) === constants.linksWidgetTypeValue ? itemsTypes.filter(item => item.value === constants.pagesItemsTypeValue) : (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) === constants.tabsWidgetTypeValue || (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.collectionsOnly) ? itemsTypes.filter(item => item.label !== constants.imageItemsTypeValue && item.value !== constants.pagesItemsTypeValue) : (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.imageOnly) ? itemsTypes.filter(item => item.label === constants.imageItemsTypeValue) : itemsTypes.filter(item => item.value !== constants.pagesItemsTypeValue)
|
|
7502
7518
|
}, {
|
|
7503
7519
|
label: widgetTranslations.color,
|
|
7504
7520
|
accessor: 'backgroundColor',
|
|
@@ -7561,7 +7577,7 @@ const WidgetForm = ({
|
|
|
7561
7577
|
onChange: setSelectedCollectionItems,
|
|
7562
7578
|
loadOptions: onChangeSearch,
|
|
7563
7579
|
isLoading: collectionDataLoading,
|
|
7564
|
-
show: !itemsEnabled && ((selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) === constants.carouselWidgetTypeValue || (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) === constants.fixedCardWidgetTypeValue || !selectedWidgetType) && !!(selectedCollectionType === null || selectedCollectionType === void 0 ? void 0 : selectedCollectionType.value),
|
|
7580
|
+
show: !itemsEnabled && ((selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) === constants.carouselWidgetTypeValue || (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) === constants.fixedCardWidgetTypeValue || (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) === constants.linksWidgetTypeValue || !selectedWidgetType) && !!(selectedCollectionType === null || selectedCollectionType === void 0 ? void 0 : selectedCollectionType.value),
|
|
7565
7581
|
formatOptionLabel: formatOptionLabel,
|
|
7566
7582
|
listCode: selectedCollectionType === null || selectedCollectionType === void 0 ? void 0 : selectedCollectionType.value,
|
|
7567
7583
|
customStyles: reactSelectStyles || {},
|
package/package.json
CHANGED
|
@@ -126,7 +126,7 @@ export interface ReactSelectProps {
|
|
|
126
126
|
listCode?: string;
|
|
127
127
|
wrapperClassName?: string;
|
|
128
128
|
customStyles?: any;
|
|
129
|
-
loadOptions?: (value?: string, callback?: (options: OptionType[]) => void) => Promise<OptionType[]
|
|
129
|
+
loadOptions?: (value?: string, callback?: (options: OptionType[]) => void, collectionName?: string) => Promise<OptionType[]> | void;
|
|
130
130
|
selectKey?: string;
|
|
131
131
|
}
|
|
132
132
|
export interface CustomInputType {
|
|
@@ -349,7 +349,7 @@ export interface TabsProps {
|
|
|
349
349
|
getValues: UseFormGetValues<FieldValues>;
|
|
350
350
|
setValue: UseFormSetValue<FieldValues>;
|
|
351
351
|
languages?: LanguageType[];
|
|
352
|
-
loadOptions?: (value?: string, callback?: (options: OptionType[]) => void) => Promise<OptionType[]
|
|
352
|
+
loadOptions?: (value?: string, callback?: (options: OptionType[]) => void, collectionName?: string) => Promise<OptionType[]> | void;
|
|
353
353
|
}
|
|
354
354
|
export interface ImageUploadProps {
|
|
355
355
|
className?: string;
|