@knovator/pagecreator-admin 1.7.8 → 1.8.0
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 +117 -114
- package/index.js +117 -114
- package/package.json +1 -1
- package/src/lib/components/Widget/Form/ItemsAccordian.d.ts +1 -1
- package/src/lib/components/Widget/Form/WidgetForm.d.ts +1 -1
- package/src/lib/components/Widget/Widget/Widget.d.ts +2 -2
- package/src/lib/constants/common.d.ts +4 -0
- package/src/lib/types/components.d.ts +6 -26
- package/src/lib/components/Widget/Form/customItemRenderers/TestimonialItemRenderer.d.ts +0 -4
- package/src/lib/components/Widget/Form/customItemRenderers/defaultCustomItemRenderers.d.ts +0 -3
package/index.cjs
CHANGED
|
@@ -1777,6 +1777,10 @@ const TRANSLATION_PAIRS_WIDGET = {
|
|
|
1777
1777
|
subTitlePlaceholder: 'Enter Subtitle',
|
|
1778
1778
|
quote: 'Quote',
|
|
1779
1779
|
quotePlaceholder: 'Enter quote',
|
|
1780
|
+
question: 'Question',
|
|
1781
|
+
questionPlaceholder: 'Enter question',
|
|
1782
|
+
answer: 'Answer',
|
|
1783
|
+
answerPlaceholder: 'Enter answer',
|
|
1780
1784
|
personName: 'Person Name',
|
|
1781
1785
|
personNamePlaceholder: 'Enter person name',
|
|
1782
1786
|
personRole: 'Person Role',
|
|
@@ -6817,7 +6821,7 @@ const ItemsAccordian = ({
|
|
|
6817
6821
|
itemType,
|
|
6818
6822
|
languages,
|
|
6819
6823
|
clearError,
|
|
6820
|
-
|
|
6824
|
+
widgetType,
|
|
6821
6825
|
addText: _addText = 'Add',
|
|
6822
6826
|
deleteText: _deleteText = 'Delete'
|
|
6823
6827
|
}) => {
|
|
@@ -6841,6 +6845,8 @@ const ItemsAccordian = ({
|
|
|
6841
6845
|
name,
|
|
6842
6846
|
control
|
|
6843
6847
|
});
|
|
6848
|
+
const isTestimonialWidget = widgetType === 'Testimonial';
|
|
6849
|
+
const isFaqWidget = widgetType === 'FAQ';
|
|
6844
6850
|
const onItemsToggleClick = (index, status) => {
|
|
6845
6851
|
var _a;
|
|
6846
6852
|
const newItemsShow = [...itemsShow];
|
|
@@ -6858,11 +6864,25 @@ const ItemsAccordian = ({
|
|
|
6858
6864
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
6859
6865
|
}, [errors, name, errors === null || errors === void 0 ? void 0 : errors[name]]);
|
|
6860
6866
|
const addTab = index => {
|
|
6861
|
-
if (
|
|
6862
|
-
appendItem(
|
|
6863
|
-
|
|
6864
|
-
|
|
6865
|
-
|
|
6867
|
+
if (isTestimonialWidget) {
|
|
6868
|
+
appendItem({
|
|
6869
|
+
quote: '',
|
|
6870
|
+
personName: '',
|
|
6871
|
+
personRole: '',
|
|
6872
|
+
personOrganization: '',
|
|
6873
|
+
rating: 5,
|
|
6874
|
+
itemType,
|
|
6875
|
+
sequence: index
|
|
6876
|
+
});
|
|
6877
|
+
return;
|
|
6878
|
+
}
|
|
6879
|
+
if (isFaqWidget) {
|
|
6880
|
+
appendItem({
|
|
6881
|
+
question: '',
|
|
6882
|
+
answer: '',
|
|
6883
|
+
itemType,
|
|
6884
|
+
sequence: index
|
|
6885
|
+
});
|
|
6866
6886
|
return;
|
|
6867
6887
|
}
|
|
6868
6888
|
appendItem({
|
|
@@ -6888,7 +6908,7 @@ const ItemsAccordian = ({
|
|
|
6888
6908
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
6889
6909
|
className: "khb_item-items"
|
|
6890
6910
|
}, items === null || items === void 0 ? void 0 : items.map((field, index) => {
|
|
6891
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
6911
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13;
|
|
6892
6912
|
return /*#__PURE__*/React__default["default"].createElement(Accordian, {
|
|
6893
6913
|
key: index,
|
|
6894
6914
|
open: itemsShow[index],
|
|
@@ -6908,20 +6928,65 @@ const ItemsAccordian = ({
|
|
|
6908
6928
|
}, _deleteText))
|
|
6909
6929
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
6910
6930
|
className: "khb-form-items"
|
|
6911
|
-
},
|
|
6912
|
-
name,
|
|
6913
|
-
|
|
6914
|
-
|
|
6915
|
-
|
|
6916
|
-
|
|
6917
|
-
|
|
6918
|
-
|
|
6919
|
-
|
|
6920
|
-
|
|
6921
|
-
|
|
6922
|
-
|
|
6923
|
-
|
|
6924
|
-
|
|
6931
|
+
}, isTestimonialWidget ? (/*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(Input, {
|
|
6932
|
+
rest: register(`${name}.${index}.quote`),
|
|
6933
|
+
label: widgetTranslations.quote,
|
|
6934
|
+
error: (_d = (_c = (_b = (_a = errors[name]) === null || _a === void 0 ? void 0 : _a[index]) === null || _b === void 0 ? void 0 : _b['quote']) === null || _c === void 0 ? void 0 : _c.message) === null || _d === void 0 ? void 0 : _d.toString(),
|
|
6935
|
+
type: "text",
|
|
6936
|
+
className: "w-full p-2",
|
|
6937
|
+
placeholder: widgetTranslations.quotePlaceholder
|
|
6938
|
+
}), /*#__PURE__*/React__default["default"].createElement(Input, {
|
|
6939
|
+
rest: register(`${name}.${index}.personName`),
|
|
6940
|
+
label: widgetTranslations.personName,
|
|
6941
|
+
error: (_h = (_g = (_f = (_e = errors[name]) === null || _e === void 0 ? void 0 : _e[index]) === null || _f === void 0 ? void 0 : _f['personName']) === null || _g === void 0 ? void 0 : _g.message) === null || _h === void 0 ? void 0 : _h.toString(),
|
|
6942
|
+
type: "text",
|
|
6943
|
+
className: "w-full p-2",
|
|
6944
|
+
placeholder: widgetTranslations.personNamePlaceholder
|
|
6945
|
+
}), /*#__PURE__*/React__default["default"].createElement(Input, {
|
|
6946
|
+
rest: register(`${name}.${index}.personRole`),
|
|
6947
|
+
label: widgetTranslations.personRole,
|
|
6948
|
+
error: (_m = (_l = (_k = (_j = errors[name]) === null || _j === void 0 ? void 0 : _j[index]) === null || _k === void 0 ? void 0 : _k['personRole']) === null || _l === void 0 ? void 0 : _l.message) === null || _m === void 0 ? void 0 : _m.toString(),
|
|
6949
|
+
type: "text",
|
|
6950
|
+
className: "w-full p-2",
|
|
6951
|
+
placeholder: widgetTranslations.personRolePlaceholder
|
|
6952
|
+
}), /*#__PURE__*/React__default["default"].createElement(Input, {
|
|
6953
|
+
rest: register(`${name}.${index}.personOrganization`),
|
|
6954
|
+
label: widgetTranslations.personOrganization,
|
|
6955
|
+
error: (_r = (_q = (_p = (_o = errors[name]) === null || _o === void 0 ? void 0 : _o[index]) === null || _p === void 0 ? void 0 : _p['personOrganization']) === null || _q === void 0 ? void 0 : _q.message) === null || _r === void 0 ? void 0 : _r.toString(),
|
|
6956
|
+
type: "text",
|
|
6957
|
+
className: "w-full p-2",
|
|
6958
|
+
placeholder: widgetTranslations.personOrganizationPlaceholder
|
|
6959
|
+
}), /*#__PURE__*/React__default["default"].createElement(Input, {
|
|
6960
|
+
rest: register(`${name}.${index}.rating`, {
|
|
6961
|
+
min: {
|
|
6962
|
+
value: 0,
|
|
6963
|
+
message: 'Rating should be greater than or equal to 0'
|
|
6964
|
+
},
|
|
6965
|
+
max: {
|
|
6966
|
+
value: 5,
|
|
6967
|
+
message: 'Rating should be less than or equal to 5'
|
|
6968
|
+
}
|
|
6969
|
+
}),
|
|
6970
|
+
label: widgetTranslations.rating,
|
|
6971
|
+
error: (_v = (_u = (_t = (_s = errors[name]) === null || _s === void 0 ? void 0 : _s[index]) === null || _t === void 0 ? void 0 : _t['rating']) === null || _u === void 0 ? void 0 : _u.message) === null || _v === void 0 ? void 0 : _v.toString(),
|
|
6972
|
+
type: "number",
|
|
6973
|
+
className: "w-full p-2",
|
|
6974
|
+
placeholder: widgetTranslations.ratingPlaceholder
|
|
6975
|
+
}))) : isFaqWidget ? (/*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(Input, {
|
|
6976
|
+
rest: register(`${name}.${index}.question`),
|
|
6977
|
+
label: widgetTranslations.question,
|
|
6978
|
+
error: (_z = (_y = (_x = (_w = errors[name]) === null || _w === void 0 ? void 0 : _w[index]) === null || _x === void 0 ? void 0 : _x['question']) === null || _y === void 0 ? void 0 : _y.message) === null || _z === void 0 ? void 0 : _z.toString(),
|
|
6979
|
+
type: "text",
|
|
6980
|
+
className: "w-full p-2",
|
|
6981
|
+
placeholder: widgetTranslations.questionPlaceholder
|
|
6982
|
+
}), /*#__PURE__*/React__default["default"].createElement(Input, {
|
|
6983
|
+
rest: register(`${name}.${index}.answer`),
|
|
6984
|
+
label: widgetTranslations.answer,
|
|
6985
|
+
error: (_3 = (_2 = (_1 = (_0 = errors[name]) === null || _0 === void 0 ? void 0 : _0[index]) === null || _1 === void 0 ? void 0 : _1['answer']) === null || _2 === void 0 ? void 0 : _2.message) === null || _3 === void 0 ? void 0 : _3.toString(),
|
|
6986
|
+
type: "textarea",
|
|
6987
|
+
className: "w-full p-2",
|
|
6988
|
+
placeholder: widgetTranslations.answerPlaceholder
|
|
6989
|
+
}))) : (/*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, Array.isArray(languages) && languages.length > 0 ? (/*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, languages.map(lang => {
|
|
6925
6990
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
6926
6991
|
return /*#__PURE__*/React__default["default"].createElement(Input, {
|
|
6927
6992
|
rest: register(`${name}.${index}.titles.${lang.code}`),
|
|
@@ -6934,7 +6999,7 @@ const ItemsAccordian = ({
|
|
|
6934
6999
|
}))) : (/*#__PURE__*/React__default["default"].createElement(Input, {
|
|
6935
7000
|
rest: register(`${name}.${index}.title`),
|
|
6936
7001
|
label: commonTranslations.title,
|
|
6937
|
-
error: (
|
|
7002
|
+
error: (_7 = (_6 = (_5 = (_4 = errors[name]) === null || _4 === void 0 ? void 0 : _4[index]) === null || _5 === void 0 ? void 0 : _5['title']) === null || _6 === void 0 ? void 0 : _6.message) === null || _7 === void 0 ? void 0 : _7.toString(),
|
|
6938
7003
|
type: "text",
|
|
6939
7004
|
className: "w-full p-2",
|
|
6940
7005
|
placeholder: commonTranslations.titlePlaceholder
|
|
@@ -6973,7 +7038,7 @@ const ItemsAccordian = ({
|
|
|
6973
7038
|
register: register,
|
|
6974
7039
|
label: widgetTranslations.srcset,
|
|
6975
7040
|
name: `${name}.${index}.srcset`,
|
|
6976
|
-
errors: (
|
|
7041
|
+
errors: (_9 = (_8 = errors[name]) === null || _8 === void 0 ? void 0 : _8[index]) === null || _9 === void 0 ? void 0 : _9['srcset'],
|
|
6977
7042
|
screenSizeRequired: widgetTranslations.screenSizeRequired,
|
|
6978
7043
|
heightRequired: widgetTranslations.heightRequired,
|
|
6979
7044
|
minHeight: widgetTranslations.minHeight,
|
|
@@ -7008,7 +7073,7 @@ const ItemsAccordian = ({
|
|
|
7008
7073
|
label: widgetTranslations.image,
|
|
7009
7074
|
control: control,
|
|
7010
7075
|
name: `${name}.${index}.img`,
|
|
7011
|
-
error: (
|
|
7076
|
+
error: (_13 = (_12 = (_11 = (_10 = errors[name]) === null || _10 === void 0 ? void 0 : _10[index]) === null || _11 === void 0 ? void 0 : _11['img']) === null || _12 === void 0 ? void 0 : _12.message) === null || _13 === void 0 ? void 0 : _13.toString(),
|
|
7012
7077
|
baseUrl: imageBaseUrl ? imageBaseUrl : baseUrl,
|
|
7013
7078
|
setError: setError,
|
|
7014
7079
|
clearError: clearError,
|
|
@@ -7212,6 +7277,7 @@ const constants = {
|
|
|
7212
7277
|
htmlWidgetTypeValue: 'HTML',
|
|
7213
7278
|
linksWidgetTypeValue: 'Links',
|
|
7214
7279
|
testimonialWidgetTypeValue: 'Testimonial',
|
|
7280
|
+
faqWidgetTypeValue: 'FAQ',
|
|
7215
7281
|
pagesItemsTypeValue: 'pages',
|
|
7216
7282
|
tabsAccessor: 'tabs',
|
|
7217
7283
|
webItems: 'webItems',
|
|
@@ -7221,7 +7287,6 @@ const constants = {
|
|
|
7221
7287
|
const WidgetForm = ({
|
|
7222
7288
|
formRef,
|
|
7223
7289
|
customInputs,
|
|
7224
|
-
customItemRenderers,
|
|
7225
7290
|
onPrimaryButtonClick
|
|
7226
7291
|
}) => {
|
|
7227
7292
|
const {
|
|
@@ -7286,7 +7351,6 @@ const WidgetForm = ({
|
|
|
7286
7351
|
const pagesLoadedRef = React.useRef(false);
|
|
7287
7352
|
const blogCategoryInitialized = React.useRef(false);
|
|
7288
7353
|
const selectedWidgetTypeValue = (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) || getValues(constants.widgetTypeAccessor);
|
|
7289
|
-
const selectedCustomItemRenderer = selectedWidgetTypeValue ? customItemRenderers === null || customItemRenderers === void 0 ? void 0 : customItemRenderers[selectedWidgetTypeValue] : undefined;
|
|
7290
7354
|
React.useEffect(() => {
|
|
7291
7355
|
if (data && formState === 'UPDATE') {
|
|
7292
7356
|
const widgetType = widgetTypes.find(type => type.value === (data === null || data === void 0 ? void 0 : data.widgetType));
|
|
@@ -7299,6 +7363,10 @@ const WidgetForm = ({
|
|
|
7299
7363
|
}
|
|
7300
7364
|
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) {
|
|
7301
7365
|
setItemsEnabled(false);
|
|
7366
|
+
} else if ((data === null || data === void 0 ? void 0 : data.widgetType) === constants.faqWidgetTypeValue) {
|
|
7367
|
+
setItemsEnabled(true);
|
|
7368
|
+
setSelectedCollectionType(undefined);
|
|
7369
|
+
setSelectedCollectionItems([]);
|
|
7302
7370
|
}
|
|
7303
7371
|
}
|
|
7304
7372
|
}, [data, formState, itemsTypes, widgetTypes]);
|
|
@@ -7496,8 +7564,14 @@ const WidgetForm = ({
|
|
|
7496
7564
|
setSelectedCollectionItems([]);
|
|
7497
7565
|
setValue(constants.itemTypeAccessor, constants.imageItemsTypeValue);
|
|
7498
7566
|
setValue(constants.collectionNameAccessor, constants.imageItemsTypeValue);
|
|
7499
|
-
|
|
7500
|
-
|
|
7567
|
+
} else if ((widgetType === null || widgetType === void 0 ? void 0 : widgetType.value) === constants.faqWidgetTypeValue) {
|
|
7568
|
+
setItemsEnabled(true);
|
|
7569
|
+
setSelectedCollectionType(undefined);
|
|
7570
|
+
setSelectedCollectionItems([]);
|
|
7571
|
+
setValue(constants.itemTypeAccessor, constants.imageItemsTypeValue);
|
|
7572
|
+
setValue(constants.collectionNameAccessor, constants.imageItemsTypeValue);
|
|
7573
|
+
setValue('webPerRow', 1);
|
|
7574
|
+
setValue('tabletPerRow', 1);
|
|
7501
7575
|
setValue('mobilePerRow', 1);
|
|
7502
7576
|
} else {
|
|
7503
7577
|
setItemsEnabled(true);
|
|
@@ -7586,10 +7660,16 @@ const WidgetForm = ({
|
|
|
7586
7660
|
if (!formData[constants.itemTypeAccessor] && formState === 'ADD') {
|
|
7587
7661
|
formData[constants.itemTypeAccessor] = (_a = getFirstItemTypeValue(formData[constants.widgetTypeAccessor])) === null || _a === void 0 ? void 0 : _a.value;
|
|
7588
7662
|
}
|
|
7589
|
-
// Force collectionName and itemsType for Links
|
|
7663
|
+
// Force collectionName and itemsType for Links/FAQ widgets
|
|
7590
7664
|
if (formData[constants.widgetTypeAccessor] === constants.linksWidgetTypeValue) {
|
|
7591
7665
|
formData[constants.collectionNameAccessor] = constants.pagesItemsTypeValue;
|
|
7592
7666
|
formData[constants.itemTypeAccessor] = constants.pagesItemsTypeValue;
|
|
7667
|
+
} else if (formData[constants.widgetTypeAccessor] === constants.faqWidgetTypeValue) {
|
|
7668
|
+
formData[constants.collectionNameAccessor] = constants.imageItemsTypeValue;
|
|
7669
|
+
formData[constants.itemTypeAccessor] = constants.imageItemsTypeValue;
|
|
7670
|
+
formData['webPerRow'] = 1;
|
|
7671
|
+
formData['tabletPerRow'] = 1;
|
|
7672
|
+
formData['mobilePerRow'] = 1;
|
|
7593
7673
|
}
|
|
7594
7674
|
// setting collectionName if widgetType is FixedCard or Carousel and FormState
|
|
7595
7675
|
else if (formData[constants.itemTypeAccessor] !== constants.imageItemsTypeValue && formState === 'ADD') {
|
|
@@ -7774,7 +7854,7 @@ const WidgetForm = ({
|
|
|
7774
7854
|
label: widgetTranslations.itemsType,
|
|
7775
7855
|
required: true,
|
|
7776
7856
|
editable: false,
|
|
7777
|
-
show: selectedWidgetTypeValue !== constants.textWidgetTypeValue && selectedWidgetTypeValue !== constants.htmlWidgetTypeValue && selectedWidgetTypeValue !== constants.testimonialWidgetTypeValue,
|
|
7857
|
+
show: selectedWidgetTypeValue !== constants.textWidgetTypeValue && selectedWidgetTypeValue !== constants.htmlWidgetTypeValue && selectedWidgetTypeValue !== constants.testimonialWidgetTypeValue && selectedWidgetTypeValue !== constants.faqWidgetTypeValue,
|
|
7778
7858
|
accessor: constants.itemTypeAccessor,
|
|
7779
7859
|
type: 'select',
|
|
7780
7860
|
validations: {
|
|
@@ -7864,7 +7944,7 @@ const WidgetForm = ({
|
|
|
7864
7944
|
label: widgetTranslations.webPerRow,
|
|
7865
7945
|
accessor: 'webPerRow',
|
|
7866
7946
|
type: 'number',
|
|
7867
|
-
show: (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) !== constants.textWidgetTypeValue && (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) !== constants.htmlWidgetTypeValue,
|
|
7947
|
+
show: (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) !== constants.textWidgetTypeValue && (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) !== constants.htmlWidgetTypeValue && (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) !== constants.faqWidgetTypeValue,
|
|
7868
7948
|
required: true,
|
|
7869
7949
|
placeholder: widgetTranslations.webPerRowPlaceholder,
|
|
7870
7950
|
wrapperClassName: 'khb_grid-item-1of3 khb_padding-right-1',
|
|
@@ -7879,7 +7959,7 @@ const WidgetForm = ({
|
|
|
7879
7959
|
label: widgetTranslations.tabletPerRow,
|
|
7880
7960
|
accessor: 'tabletPerRow',
|
|
7881
7961
|
type: 'number',
|
|
7882
|
-
show: (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) !== constants.textWidgetTypeValue && (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) !== constants.htmlWidgetTypeValue,
|
|
7962
|
+
show: (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) !== constants.textWidgetTypeValue && (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) !== constants.htmlWidgetTypeValue && (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) !== constants.faqWidgetTypeValue,
|
|
7883
7963
|
required: true,
|
|
7884
7964
|
placeholder: widgetTranslations.tabletPerRowPlaceholder,
|
|
7885
7965
|
wrapperClassName: 'khb_grid-item-1of3 khb_padding-left-1',
|
|
@@ -7894,7 +7974,7 @@ const WidgetForm = ({
|
|
|
7894
7974
|
label: widgetTranslations.mobilePerRow,
|
|
7895
7975
|
accessor: 'mobilePerRow',
|
|
7896
7976
|
type: 'number',
|
|
7897
|
-
show: (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) !== 'Text' && (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) !== 'HTML',
|
|
7977
|
+
show: (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) !== 'Text' && (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) !== 'HTML' && (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) !== constants.faqWidgetTypeValue,
|
|
7898
7978
|
required: true,
|
|
7899
7979
|
placeholder: widgetTranslations.mobilePerRowPlaceholder,
|
|
7900
7980
|
wrapperClassName: 'khb_grid-item-1of3 khb_padding-right-1 khb_padding-left-1',
|
|
@@ -7987,7 +8067,7 @@ const WidgetForm = ({
|
|
|
7987
8067
|
loading: loading,
|
|
7988
8068
|
addText: commonTranslations.add,
|
|
7989
8069
|
deleteText: commonTranslations.delete,
|
|
7990
|
-
|
|
8070
|
+
widgetType: selectedWidgetTypeValue
|
|
7991
8071
|
}), /*#__PURE__*/React__default["default"].createElement(ItemsAccordian, {
|
|
7992
8072
|
languages: languages,
|
|
7993
8073
|
clearError: clearErrors,
|
|
@@ -8005,7 +8085,7 @@ const WidgetForm = ({
|
|
|
8005
8085
|
register: register,
|
|
8006
8086
|
addText: commonTranslations.add,
|
|
8007
8087
|
deleteText: commonTranslations.delete,
|
|
8008
|
-
|
|
8088
|
+
widgetType: selectedWidgetTypeValue
|
|
8009
8089
|
}))));
|
|
8010
8090
|
};
|
|
8011
8091
|
|
|
@@ -8128,79 +8208,6 @@ const WiddgetFormWrapper = ({
|
|
|
8128
8208
|
}) : null;
|
|
8129
8209
|
};
|
|
8130
8210
|
|
|
8131
|
-
const TestimonialItemRenderer = ({
|
|
8132
|
-
name,
|
|
8133
|
-
index,
|
|
8134
|
-
register,
|
|
8135
|
-
errors,
|
|
8136
|
-
widgetTranslations
|
|
8137
|
-
}) => {
|
|
8138
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
8139
|
-
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(Input, {
|
|
8140
|
-
rest: register(`${name}.${index}.quote`),
|
|
8141
|
-
label: widgetTranslations.quote,
|
|
8142
|
-
error: (_d = (_c = (_b = (_a = errors[name]) === null || _a === void 0 ? void 0 : _a[index]) === null || _b === void 0 ? void 0 : _b['quote']) === null || _c === void 0 ? void 0 : _c.message) === null || _d === void 0 ? void 0 : _d.toString(),
|
|
8143
|
-
type: "textarea",
|
|
8144
|
-
className: "w-full p-2",
|
|
8145
|
-
placeholder: widgetTranslations.quotePlaceholder
|
|
8146
|
-
}), /*#__PURE__*/React__default["default"].createElement(Input, {
|
|
8147
|
-
rest: register(`${name}.${index}.personName`),
|
|
8148
|
-
label: widgetTranslations.personName,
|
|
8149
|
-
error: (_h = (_g = (_f = (_e = errors[name]) === null || _e === void 0 ? void 0 : _e[index]) === null || _f === void 0 ? void 0 : _f['personName']) === null || _g === void 0 ? void 0 : _g.message) === null || _h === void 0 ? void 0 : _h.toString(),
|
|
8150
|
-
type: "text",
|
|
8151
|
-
className: "w-full p-2",
|
|
8152
|
-
placeholder: widgetTranslations.personNamePlaceholder
|
|
8153
|
-
}), /*#__PURE__*/React__default["default"].createElement(Input, {
|
|
8154
|
-
rest: register(`${name}.${index}.personRole`),
|
|
8155
|
-
label: widgetTranslations.personRole,
|
|
8156
|
-
error: (_m = (_l = (_k = (_j = errors[name]) === null || _j === void 0 ? void 0 : _j[index]) === null || _k === void 0 ? void 0 : _k['personRole']) === null || _l === void 0 ? void 0 : _l.message) === null || _m === void 0 ? void 0 : _m.toString(),
|
|
8157
|
-
type: "text",
|
|
8158
|
-
className: "w-full p-2",
|
|
8159
|
-
placeholder: widgetTranslations.personRolePlaceholder
|
|
8160
|
-
}), /*#__PURE__*/React__default["default"].createElement(Input, {
|
|
8161
|
-
rest: register(`${name}.${index}.personOrganization`),
|
|
8162
|
-
label: widgetTranslations.personOrganization,
|
|
8163
|
-
error: (_r = (_q = (_p = (_o = errors[name]) === null || _o === void 0 ? void 0 : _o[index]) === null || _p === void 0 ? void 0 : _p['personOrganization']) === null || _q === void 0 ? void 0 : _q.message) === null || _r === void 0 ? void 0 : _r.toString(),
|
|
8164
|
-
type: "text",
|
|
8165
|
-
className: "w-full p-2",
|
|
8166
|
-
placeholder: widgetTranslations.personOrganizationPlaceholder
|
|
8167
|
-
}), /*#__PURE__*/React__default["default"].createElement(Input, {
|
|
8168
|
-
rest: register(`${name}.${index}.rating`, {
|
|
8169
|
-
min: {
|
|
8170
|
-
value: 0,
|
|
8171
|
-
message: 'Rating should be greater than or equal to 0'
|
|
8172
|
-
},
|
|
8173
|
-
max: {
|
|
8174
|
-
value: 5,
|
|
8175
|
-
message: 'Rating should be less than or equal to 5'
|
|
8176
|
-
}
|
|
8177
|
-
}),
|
|
8178
|
-
label: widgetTranslations.rating,
|
|
8179
|
-
error: (_v = (_u = (_t = (_s = errors[name]) === null || _s === void 0 ? void 0 : _s[index]) === null || _t === void 0 ? void 0 : _t['rating']) === null || _u === void 0 ? void 0 : _u.message) === null || _v === void 0 ? void 0 : _v.toString(),
|
|
8180
|
-
type: "number",
|
|
8181
|
-
className: "w-full p-2",
|
|
8182
|
-
placeholder: widgetTranslations.ratingPlaceholder
|
|
8183
|
-
}));
|
|
8184
|
-
};
|
|
8185
|
-
|
|
8186
|
-
const getDefaultCustomItemRenderers = () => ({
|
|
8187
|
-
Testimonial: {
|
|
8188
|
-
render: TestimonialItemRenderer,
|
|
8189
|
-
createItem: ({
|
|
8190
|
-
index,
|
|
8191
|
-
itemType
|
|
8192
|
-
}) => ({
|
|
8193
|
-
quote: '',
|
|
8194
|
-
personName: '',
|
|
8195
|
-
personRole: '',
|
|
8196
|
-
personOrganization: '',
|
|
8197
|
-
rating: 5,
|
|
8198
|
-
itemType,
|
|
8199
|
-
sequence: index
|
|
8200
|
-
})
|
|
8201
|
-
}
|
|
8202
|
-
});
|
|
8203
|
-
|
|
8204
8211
|
const Widget = ({
|
|
8205
8212
|
routes,
|
|
8206
8213
|
loader,
|
|
@@ -8215,8 +8222,7 @@ const Widget = ({
|
|
|
8215
8222
|
imageMaxSize,
|
|
8216
8223
|
translations,
|
|
8217
8224
|
children,
|
|
8218
|
-
onPrimaryButtonClick
|
|
8219
|
-
customItemRenderers
|
|
8225
|
+
onPrimaryButtonClick
|
|
8220
8226
|
}) => {
|
|
8221
8227
|
const {
|
|
8222
8228
|
commonTranslations
|
|
@@ -8224,8 +8230,6 @@ const Widget = ({
|
|
|
8224
8230
|
const derivedPermissions = Object.assign(DEFAULT_PERMISSIONS, _permissions);
|
|
8225
8231
|
const widgetFormRef = React.useRef(null);
|
|
8226
8232
|
const derivedT = Object.assign(Object.assign({}, TRANSLATION_PAIRS_WIDGET), translations || {});
|
|
8227
|
-
const defaultCustomItemRenderers = getDefaultCustomItemRenderers();
|
|
8228
|
-
const derivedCustomItemRenderers = Object.assign(Object.assign({}, defaultCustomItemRenderers), customItemRenderers || {});
|
|
8229
8233
|
const {
|
|
8230
8234
|
list,
|
|
8231
8235
|
loading,
|
|
@@ -8310,8 +8314,7 @@ const Widget = ({
|
|
|
8310
8314
|
})
|
|
8311
8315
|
}, /*#__PURE__*/React__default["default"].createElement(WidgetForm, {
|
|
8312
8316
|
formRef: widgetFormRef,
|
|
8313
|
-
onPrimaryButtonClick: onPrimaryButtonClick
|
|
8314
|
-
customItemRenderers: derivedCustomItemRenderers
|
|
8317
|
+
onPrimaryButtonClick: onPrimaryButtonClick
|
|
8315
8318
|
}))), itemData && (/*#__PURE__*/React__default["default"].createElement(DeleteModal, {
|
|
8316
8319
|
formState: formState,
|
|
8317
8320
|
itemData: itemData,
|
package/index.js
CHANGED
|
@@ -1765,6 +1765,10 @@ const TRANSLATION_PAIRS_WIDGET = {
|
|
|
1765
1765
|
subTitlePlaceholder: 'Enter Subtitle',
|
|
1766
1766
|
quote: 'Quote',
|
|
1767
1767
|
quotePlaceholder: 'Enter quote',
|
|
1768
|
+
question: 'Question',
|
|
1769
|
+
questionPlaceholder: 'Enter question',
|
|
1770
|
+
answer: 'Answer',
|
|
1771
|
+
answerPlaceholder: 'Enter answer',
|
|
1768
1772
|
personName: 'Person Name',
|
|
1769
1773
|
personNamePlaceholder: 'Enter person name',
|
|
1770
1774
|
personRole: 'Person Role',
|
|
@@ -6805,7 +6809,7 @@ const ItemsAccordian = ({
|
|
|
6805
6809
|
itemType,
|
|
6806
6810
|
languages,
|
|
6807
6811
|
clearError,
|
|
6808
|
-
|
|
6812
|
+
widgetType,
|
|
6809
6813
|
addText: _addText = 'Add',
|
|
6810
6814
|
deleteText: _deleteText = 'Delete'
|
|
6811
6815
|
}) => {
|
|
@@ -6829,6 +6833,8 @@ const ItemsAccordian = ({
|
|
|
6829
6833
|
name,
|
|
6830
6834
|
control
|
|
6831
6835
|
});
|
|
6836
|
+
const isTestimonialWidget = widgetType === 'Testimonial';
|
|
6837
|
+
const isFaqWidget = widgetType === 'FAQ';
|
|
6832
6838
|
const onItemsToggleClick = (index, status) => {
|
|
6833
6839
|
var _a;
|
|
6834
6840
|
const newItemsShow = [...itemsShow];
|
|
@@ -6846,11 +6852,25 @@ const ItemsAccordian = ({
|
|
|
6846
6852
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
6847
6853
|
}, [errors, name, errors === null || errors === void 0 ? void 0 : errors[name]]);
|
|
6848
6854
|
const addTab = index => {
|
|
6849
|
-
if (
|
|
6850
|
-
appendItem(
|
|
6851
|
-
|
|
6852
|
-
|
|
6853
|
-
|
|
6855
|
+
if (isTestimonialWidget) {
|
|
6856
|
+
appendItem({
|
|
6857
|
+
quote: '',
|
|
6858
|
+
personName: '',
|
|
6859
|
+
personRole: '',
|
|
6860
|
+
personOrganization: '',
|
|
6861
|
+
rating: 5,
|
|
6862
|
+
itemType,
|
|
6863
|
+
sequence: index
|
|
6864
|
+
});
|
|
6865
|
+
return;
|
|
6866
|
+
}
|
|
6867
|
+
if (isFaqWidget) {
|
|
6868
|
+
appendItem({
|
|
6869
|
+
question: '',
|
|
6870
|
+
answer: '',
|
|
6871
|
+
itemType,
|
|
6872
|
+
sequence: index
|
|
6873
|
+
});
|
|
6854
6874
|
return;
|
|
6855
6875
|
}
|
|
6856
6876
|
appendItem({
|
|
@@ -6876,7 +6896,7 @@ const ItemsAccordian = ({
|
|
|
6876
6896
|
}, /*#__PURE__*/React.createElement("div", {
|
|
6877
6897
|
className: "khb_item-items"
|
|
6878
6898
|
}, items === null || items === void 0 ? void 0 : items.map((field, index) => {
|
|
6879
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
6899
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13;
|
|
6880
6900
|
return /*#__PURE__*/React.createElement(Accordian, {
|
|
6881
6901
|
key: index,
|
|
6882
6902
|
open: itemsShow[index],
|
|
@@ -6896,20 +6916,65 @@ const ItemsAccordian = ({
|
|
|
6896
6916
|
}, _deleteText))
|
|
6897
6917
|
}, /*#__PURE__*/React.createElement("div", {
|
|
6898
6918
|
className: "khb-form-items"
|
|
6899
|
-
},
|
|
6900
|
-
name,
|
|
6901
|
-
|
|
6902
|
-
|
|
6903
|
-
|
|
6904
|
-
|
|
6905
|
-
|
|
6906
|
-
|
|
6907
|
-
|
|
6908
|
-
|
|
6909
|
-
|
|
6910
|
-
|
|
6911
|
-
|
|
6912
|
-
|
|
6919
|
+
}, isTestimonialWidget ? (/*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Input, {
|
|
6920
|
+
rest: register(`${name}.${index}.quote`),
|
|
6921
|
+
label: widgetTranslations.quote,
|
|
6922
|
+
error: (_d = (_c = (_b = (_a = errors[name]) === null || _a === void 0 ? void 0 : _a[index]) === null || _b === void 0 ? void 0 : _b['quote']) === null || _c === void 0 ? void 0 : _c.message) === null || _d === void 0 ? void 0 : _d.toString(),
|
|
6923
|
+
type: "text",
|
|
6924
|
+
className: "w-full p-2",
|
|
6925
|
+
placeholder: widgetTranslations.quotePlaceholder
|
|
6926
|
+
}), /*#__PURE__*/React.createElement(Input, {
|
|
6927
|
+
rest: register(`${name}.${index}.personName`),
|
|
6928
|
+
label: widgetTranslations.personName,
|
|
6929
|
+
error: (_h = (_g = (_f = (_e = errors[name]) === null || _e === void 0 ? void 0 : _e[index]) === null || _f === void 0 ? void 0 : _f['personName']) === null || _g === void 0 ? void 0 : _g.message) === null || _h === void 0 ? void 0 : _h.toString(),
|
|
6930
|
+
type: "text",
|
|
6931
|
+
className: "w-full p-2",
|
|
6932
|
+
placeholder: widgetTranslations.personNamePlaceholder
|
|
6933
|
+
}), /*#__PURE__*/React.createElement(Input, {
|
|
6934
|
+
rest: register(`${name}.${index}.personRole`),
|
|
6935
|
+
label: widgetTranslations.personRole,
|
|
6936
|
+
error: (_m = (_l = (_k = (_j = errors[name]) === null || _j === void 0 ? void 0 : _j[index]) === null || _k === void 0 ? void 0 : _k['personRole']) === null || _l === void 0 ? void 0 : _l.message) === null || _m === void 0 ? void 0 : _m.toString(),
|
|
6937
|
+
type: "text",
|
|
6938
|
+
className: "w-full p-2",
|
|
6939
|
+
placeholder: widgetTranslations.personRolePlaceholder
|
|
6940
|
+
}), /*#__PURE__*/React.createElement(Input, {
|
|
6941
|
+
rest: register(`${name}.${index}.personOrganization`),
|
|
6942
|
+
label: widgetTranslations.personOrganization,
|
|
6943
|
+
error: (_r = (_q = (_p = (_o = errors[name]) === null || _o === void 0 ? void 0 : _o[index]) === null || _p === void 0 ? void 0 : _p['personOrganization']) === null || _q === void 0 ? void 0 : _q.message) === null || _r === void 0 ? void 0 : _r.toString(),
|
|
6944
|
+
type: "text",
|
|
6945
|
+
className: "w-full p-2",
|
|
6946
|
+
placeholder: widgetTranslations.personOrganizationPlaceholder
|
|
6947
|
+
}), /*#__PURE__*/React.createElement(Input, {
|
|
6948
|
+
rest: register(`${name}.${index}.rating`, {
|
|
6949
|
+
min: {
|
|
6950
|
+
value: 0,
|
|
6951
|
+
message: 'Rating should be greater than or equal to 0'
|
|
6952
|
+
},
|
|
6953
|
+
max: {
|
|
6954
|
+
value: 5,
|
|
6955
|
+
message: 'Rating should be less than or equal to 5'
|
|
6956
|
+
}
|
|
6957
|
+
}),
|
|
6958
|
+
label: widgetTranslations.rating,
|
|
6959
|
+
error: (_v = (_u = (_t = (_s = errors[name]) === null || _s === void 0 ? void 0 : _s[index]) === null || _t === void 0 ? void 0 : _t['rating']) === null || _u === void 0 ? void 0 : _u.message) === null || _v === void 0 ? void 0 : _v.toString(),
|
|
6960
|
+
type: "number",
|
|
6961
|
+
className: "w-full p-2",
|
|
6962
|
+
placeholder: widgetTranslations.ratingPlaceholder
|
|
6963
|
+
}))) : isFaqWidget ? (/*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Input, {
|
|
6964
|
+
rest: register(`${name}.${index}.question`),
|
|
6965
|
+
label: widgetTranslations.question,
|
|
6966
|
+
error: (_z = (_y = (_x = (_w = errors[name]) === null || _w === void 0 ? void 0 : _w[index]) === null || _x === void 0 ? void 0 : _x['question']) === null || _y === void 0 ? void 0 : _y.message) === null || _z === void 0 ? void 0 : _z.toString(),
|
|
6967
|
+
type: "text",
|
|
6968
|
+
className: "w-full p-2",
|
|
6969
|
+
placeholder: widgetTranslations.questionPlaceholder
|
|
6970
|
+
}), /*#__PURE__*/React.createElement(Input, {
|
|
6971
|
+
rest: register(`${name}.${index}.answer`),
|
|
6972
|
+
label: widgetTranslations.answer,
|
|
6973
|
+
error: (_3 = (_2 = (_1 = (_0 = errors[name]) === null || _0 === void 0 ? void 0 : _0[index]) === null || _1 === void 0 ? void 0 : _1['answer']) === null || _2 === void 0 ? void 0 : _2.message) === null || _3 === void 0 ? void 0 : _3.toString(),
|
|
6974
|
+
type: "textarea",
|
|
6975
|
+
className: "w-full p-2",
|
|
6976
|
+
placeholder: widgetTranslations.answerPlaceholder
|
|
6977
|
+
}))) : (/*#__PURE__*/React.createElement(React.Fragment, null, Array.isArray(languages) && languages.length > 0 ? (/*#__PURE__*/React.createElement(React.Fragment, null, languages.map(lang => {
|
|
6913
6978
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
6914
6979
|
return /*#__PURE__*/React.createElement(Input, {
|
|
6915
6980
|
rest: register(`${name}.${index}.titles.${lang.code}`),
|
|
@@ -6922,7 +6987,7 @@ const ItemsAccordian = ({
|
|
|
6922
6987
|
}))) : (/*#__PURE__*/React.createElement(Input, {
|
|
6923
6988
|
rest: register(`${name}.${index}.title`),
|
|
6924
6989
|
label: commonTranslations.title,
|
|
6925
|
-
error: (
|
|
6990
|
+
error: (_7 = (_6 = (_5 = (_4 = errors[name]) === null || _4 === void 0 ? void 0 : _4[index]) === null || _5 === void 0 ? void 0 : _5['title']) === null || _6 === void 0 ? void 0 : _6.message) === null || _7 === void 0 ? void 0 : _7.toString(),
|
|
6926
6991
|
type: "text",
|
|
6927
6992
|
className: "w-full p-2",
|
|
6928
6993
|
placeholder: commonTranslations.titlePlaceholder
|
|
@@ -6961,7 +7026,7 @@ const ItemsAccordian = ({
|
|
|
6961
7026
|
register: register,
|
|
6962
7027
|
label: widgetTranslations.srcset,
|
|
6963
7028
|
name: `${name}.${index}.srcset`,
|
|
6964
|
-
errors: (
|
|
7029
|
+
errors: (_9 = (_8 = errors[name]) === null || _8 === void 0 ? void 0 : _8[index]) === null || _9 === void 0 ? void 0 : _9['srcset'],
|
|
6965
7030
|
screenSizeRequired: widgetTranslations.screenSizeRequired,
|
|
6966
7031
|
heightRequired: widgetTranslations.heightRequired,
|
|
6967
7032
|
minHeight: widgetTranslations.minHeight,
|
|
@@ -6996,7 +7061,7 @@ const ItemsAccordian = ({
|
|
|
6996
7061
|
label: widgetTranslations.image,
|
|
6997
7062
|
control: control,
|
|
6998
7063
|
name: `${name}.${index}.img`,
|
|
6999
|
-
error: (
|
|
7064
|
+
error: (_13 = (_12 = (_11 = (_10 = errors[name]) === null || _10 === void 0 ? void 0 : _10[index]) === null || _11 === void 0 ? void 0 : _11['img']) === null || _12 === void 0 ? void 0 : _12.message) === null || _13 === void 0 ? void 0 : _13.toString(),
|
|
7000
7065
|
baseUrl: imageBaseUrl ? imageBaseUrl : baseUrl,
|
|
7001
7066
|
setError: setError,
|
|
7002
7067
|
clearError: clearError,
|
|
@@ -7200,6 +7265,7 @@ const constants = {
|
|
|
7200
7265
|
htmlWidgetTypeValue: 'HTML',
|
|
7201
7266
|
linksWidgetTypeValue: 'Links',
|
|
7202
7267
|
testimonialWidgetTypeValue: 'Testimonial',
|
|
7268
|
+
faqWidgetTypeValue: 'FAQ',
|
|
7203
7269
|
pagesItemsTypeValue: 'pages',
|
|
7204
7270
|
tabsAccessor: 'tabs',
|
|
7205
7271
|
webItems: 'webItems',
|
|
@@ -7209,7 +7275,6 @@ const constants = {
|
|
|
7209
7275
|
const WidgetForm = ({
|
|
7210
7276
|
formRef,
|
|
7211
7277
|
customInputs,
|
|
7212
|
-
customItemRenderers,
|
|
7213
7278
|
onPrimaryButtonClick
|
|
7214
7279
|
}) => {
|
|
7215
7280
|
const {
|
|
@@ -7274,7 +7339,6 @@ const WidgetForm = ({
|
|
|
7274
7339
|
const pagesLoadedRef = useRef(false);
|
|
7275
7340
|
const blogCategoryInitialized = useRef(false);
|
|
7276
7341
|
const selectedWidgetTypeValue = (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) || getValues(constants.widgetTypeAccessor);
|
|
7277
|
-
const selectedCustomItemRenderer = selectedWidgetTypeValue ? customItemRenderers === null || customItemRenderers === void 0 ? void 0 : customItemRenderers[selectedWidgetTypeValue] : undefined;
|
|
7278
7342
|
useEffect(() => {
|
|
7279
7343
|
if (data && formState === 'UPDATE') {
|
|
7280
7344
|
const widgetType = widgetTypes.find(type => type.value === (data === null || data === void 0 ? void 0 : data.widgetType));
|
|
@@ -7287,6 +7351,10 @@ const WidgetForm = ({
|
|
|
7287
7351
|
}
|
|
7288
7352
|
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) {
|
|
7289
7353
|
setItemsEnabled(false);
|
|
7354
|
+
} else if ((data === null || data === void 0 ? void 0 : data.widgetType) === constants.faqWidgetTypeValue) {
|
|
7355
|
+
setItemsEnabled(true);
|
|
7356
|
+
setSelectedCollectionType(undefined);
|
|
7357
|
+
setSelectedCollectionItems([]);
|
|
7290
7358
|
}
|
|
7291
7359
|
}
|
|
7292
7360
|
}, [data, formState, itemsTypes, widgetTypes]);
|
|
@@ -7484,8 +7552,14 @@ const WidgetForm = ({
|
|
|
7484
7552
|
setSelectedCollectionItems([]);
|
|
7485
7553
|
setValue(constants.itemTypeAccessor, constants.imageItemsTypeValue);
|
|
7486
7554
|
setValue(constants.collectionNameAccessor, constants.imageItemsTypeValue);
|
|
7487
|
-
|
|
7488
|
-
|
|
7555
|
+
} else if ((widgetType === null || widgetType === void 0 ? void 0 : widgetType.value) === constants.faqWidgetTypeValue) {
|
|
7556
|
+
setItemsEnabled(true);
|
|
7557
|
+
setSelectedCollectionType(undefined);
|
|
7558
|
+
setSelectedCollectionItems([]);
|
|
7559
|
+
setValue(constants.itemTypeAccessor, constants.imageItemsTypeValue);
|
|
7560
|
+
setValue(constants.collectionNameAccessor, constants.imageItemsTypeValue);
|
|
7561
|
+
setValue('webPerRow', 1);
|
|
7562
|
+
setValue('tabletPerRow', 1);
|
|
7489
7563
|
setValue('mobilePerRow', 1);
|
|
7490
7564
|
} else {
|
|
7491
7565
|
setItemsEnabled(true);
|
|
@@ -7574,10 +7648,16 @@ const WidgetForm = ({
|
|
|
7574
7648
|
if (!formData[constants.itemTypeAccessor] && formState === 'ADD') {
|
|
7575
7649
|
formData[constants.itemTypeAccessor] = (_a = getFirstItemTypeValue(formData[constants.widgetTypeAccessor])) === null || _a === void 0 ? void 0 : _a.value;
|
|
7576
7650
|
}
|
|
7577
|
-
// Force collectionName and itemsType for Links
|
|
7651
|
+
// Force collectionName and itemsType for Links/FAQ widgets
|
|
7578
7652
|
if (formData[constants.widgetTypeAccessor] === constants.linksWidgetTypeValue) {
|
|
7579
7653
|
formData[constants.collectionNameAccessor] = constants.pagesItemsTypeValue;
|
|
7580
7654
|
formData[constants.itemTypeAccessor] = constants.pagesItemsTypeValue;
|
|
7655
|
+
} else if (formData[constants.widgetTypeAccessor] === constants.faqWidgetTypeValue) {
|
|
7656
|
+
formData[constants.collectionNameAccessor] = constants.imageItemsTypeValue;
|
|
7657
|
+
formData[constants.itemTypeAccessor] = constants.imageItemsTypeValue;
|
|
7658
|
+
formData['webPerRow'] = 1;
|
|
7659
|
+
formData['tabletPerRow'] = 1;
|
|
7660
|
+
formData['mobilePerRow'] = 1;
|
|
7581
7661
|
}
|
|
7582
7662
|
// setting collectionName if widgetType is FixedCard or Carousel and FormState
|
|
7583
7663
|
else if (formData[constants.itemTypeAccessor] !== constants.imageItemsTypeValue && formState === 'ADD') {
|
|
@@ -7762,7 +7842,7 @@ const WidgetForm = ({
|
|
|
7762
7842
|
label: widgetTranslations.itemsType,
|
|
7763
7843
|
required: true,
|
|
7764
7844
|
editable: false,
|
|
7765
|
-
show: selectedWidgetTypeValue !== constants.textWidgetTypeValue && selectedWidgetTypeValue !== constants.htmlWidgetTypeValue && selectedWidgetTypeValue !== constants.testimonialWidgetTypeValue,
|
|
7845
|
+
show: selectedWidgetTypeValue !== constants.textWidgetTypeValue && selectedWidgetTypeValue !== constants.htmlWidgetTypeValue && selectedWidgetTypeValue !== constants.testimonialWidgetTypeValue && selectedWidgetTypeValue !== constants.faqWidgetTypeValue,
|
|
7766
7846
|
accessor: constants.itemTypeAccessor,
|
|
7767
7847
|
type: 'select',
|
|
7768
7848
|
validations: {
|
|
@@ -7852,7 +7932,7 @@ const WidgetForm = ({
|
|
|
7852
7932
|
label: widgetTranslations.webPerRow,
|
|
7853
7933
|
accessor: 'webPerRow',
|
|
7854
7934
|
type: 'number',
|
|
7855
|
-
show: (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) !== constants.textWidgetTypeValue && (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) !== constants.htmlWidgetTypeValue,
|
|
7935
|
+
show: (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) !== constants.textWidgetTypeValue && (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) !== constants.htmlWidgetTypeValue && (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) !== constants.faqWidgetTypeValue,
|
|
7856
7936
|
required: true,
|
|
7857
7937
|
placeholder: widgetTranslations.webPerRowPlaceholder,
|
|
7858
7938
|
wrapperClassName: 'khb_grid-item-1of3 khb_padding-right-1',
|
|
@@ -7867,7 +7947,7 @@ const WidgetForm = ({
|
|
|
7867
7947
|
label: widgetTranslations.tabletPerRow,
|
|
7868
7948
|
accessor: 'tabletPerRow',
|
|
7869
7949
|
type: 'number',
|
|
7870
|
-
show: (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) !== constants.textWidgetTypeValue && (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) !== constants.htmlWidgetTypeValue,
|
|
7950
|
+
show: (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) !== constants.textWidgetTypeValue && (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) !== constants.htmlWidgetTypeValue && (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) !== constants.faqWidgetTypeValue,
|
|
7871
7951
|
required: true,
|
|
7872
7952
|
placeholder: widgetTranslations.tabletPerRowPlaceholder,
|
|
7873
7953
|
wrapperClassName: 'khb_grid-item-1of3 khb_padding-left-1',
|
|
@@ -7882,7 +7962,7 @@ const WidgetForm = ({
|
|
|
7882
7962
|
label: widgetTranslations.mobilePerRow,
|
|
7883
7963
|
accessor: 'mobilePerRow',
|
|
7884
7964
|
type: 'number',
|
|
7885
|
-
show: (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) !== 'Text' && (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) !== 'HTML',
|
|
7965
|
+
show: (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) !== 'Text' && (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) !== 'HTML' && (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value) !== constants.faqWidgetTypeValue,
|
|
7886
7966
|
required: true,
|
|
7887
7967
|
placeholder: widgetTranslations.mobilePerRowPlaceholder,
|
|
7888
7968
|
wrapperClassName: 'khb_grid-item-1of3 khb_padding-right-1 khb_padding-left-1',
|
|
@@ -7975,7 +8055,7 @@ const WidgetForm = ({
|
|
|
7975
8055
|
loading: loading,
|
|
7976
8056
|
addText: commonTranslations.add,
|
|
7977
8057
|
deleteText: commonTranslations.delete,
|
|
7978
|
-
|
|
8058
|
+
widgetType: selectedWidgetTypeValue
|
|
7979
8059
|
}), /*#__PURE__*/React.createElement(ItemsAccordian, {
|
|
7980
8060
|
languages: languages,
|
|
7981
8061
|
clearError: clearErrors,
|
|
@@ -7993,7 +8073,7 @@ const WidgetForm = ({
|
|
|
7993
8073
|
register: register,
|
|
7994
8074
|
addText: commonTranslations.add,
|
|
7995
8075
|
deleteText: commonTranslations.delete,
|
|
7996
|
-
|
|
8076
|
+
widgetType: selectedWidgetTypeValue
|
|
7997
8077
|
}))));
|
|
7998
8078
|
};
|
|
7999
8079
|
|
|
@@ -8116,79 +8196,6 @@ const WiddgetFormWrapper = ({
|
|
|
8116
8196
|
}) : null;
|
|
8117
8197
|
};
|
|
8118
8198
|
|
|
8119
|
-
const TestimonialItemRenderer = ({
|
|
8120
|
-
name,
|
|
8121
|
-
index,
|
|
8122
|
-
register,
|
|
8123
|
-
errors,
|
|
8124
|
-
widgetTranslations
|
|
8125
|
-
}) => {
|
|
8126
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
8127
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Input, {
|
|
8128
|
-
rest: register(`${name}.${index}.quote`),
|
|
8129
|
-
label: widgetTranslations.quote,
|
|
8130
|
-
error: (_d = (_c = (_b = (_a = errors[name]) === null || _a === void 0 ? void 0 : _a[index]) === null || _b === void 0 ? void 0 : _b['quote']) === null || _c === void 0 ? void 0 : _c.message) === null || _d === void 0 ? void 0 : _d.toString(),
|
|
8131
|
-
type: "textarea",
|
|
8132
|
-
className: "w-full p-2",
|
|
8133
|
-
placeholder: widgetTranslations.quotePlaceholder
|
|
8134
|
-
}), /*#__PURE__*/React.createElement(Input, {
|
|
8135
|
-
rest: register(`${name}.${index}.personName`),
|
|
8136
|
-
label: widgetTranslations.personName,
|
|
8137
|
-
error: (_h = (_g = (_f = (_e = errors[name]) === null || _e === void 0 ? void 0 : _e[index]) === null || _f === void 0 ? void 0 : _f['personName']) === null || _g === void 0 ? void 0 : _g.message) === null || _h === void 0 ? void 0 : _h.toString(),
|
|
8138
|
-
type: "text",
|
|
8139
|
-
className: "w-full p-2",
|
|
8140
|
-
placeholder: widgetTranslations.personNamePlaceholder
|
|
8141
|
-
}), /*#__PURE__*/React.createElement(Input, {
|
|
8142
|
-
rest: register(`${name}.${index}.personRole`),
|
|
8143
|
-
label: widgetTranslations.personRole,
|
|
8144
|
-
error: (_m = (_l = (_k = (_j = errors[name]) === null || _j === void 0 ? void 0 : _j[index]) === null || _k === void 0 ? void 0 : _k['personRole']) === null || _l === void 0 ? void 0 : _l.message) === null || _m === void 0 ? void 0 : _m.toString(),
|
|
8145
|
-
type: "text",
|
|
8146
|
-
className: "w-full p-2",
|
|
8147
|
-
placeholder: widgetTranslations.personRolePlaceholder
|
|
8148
|
-
}), /*#__PURE__*/React.createElement(Input, {
|
|
8149
|
-
rest: register(`${name}.${index}.personOrganization`),
|
|
8150
|
-
label: widgetTranslations.personOrganization,
|
|
8151
|
-
error: (_r = (_q = (_p = (_o = errors[name]) === null || _o === void 0 ? void 0 : _o[index]) === null || _p === void 0 ? void 0 : _p['personOrganization']) === null || _q === void 0 ? void 0 : _q.message) === null || _r === void 0 ? void 0 : _r.toString(),
|
|
8152
|
-
type: "text",
|
|
8153
|
-
className: "w-full p-2",
|
|
8154
|
-
placeholder: widgetTranslations.personOrganizationPlaceholder
|
|
8155
|
-
}), /*#__PURE__*/React.createElement(Input, {
|
|
8156
|
-
rest: register(`${name}.${index}.rating`, {
|
|
8157
|
-
min: {
|
|
8158
|
-
value: 0,
|
|
8159
|
-
message: 'Rating should be greater than or equal to 0'
|
|
8160
|
-
},
|
|
8161
|
-
max: {
|
|
8162
|
-
value: 5,
|
|
8163
|
-
message: 'Rating should be less than or equal to 5'
|
|
8164
|
-
}
|
|
8165
|
-
}),
|
|
8166
|
-
label: widgetTranslations.rating,
|
|
8167
|
-
error: (_v = (_u = (_t = (_s = errors[name]) === null || _s === void 0 ? void 0 : _s[index]) === null || _t === void 0 ? void 0 : _t['rating']) === null || _u === void 0 ? void 0 : _u.message) === null || _v === void 0 ? void 0 : _v.toString(),
|
|
8168
|
-
type: "number",
|
|
8169
|
-
className: "w-full p-2",
|
|
8170
|
-
placeholder: widgetTranslations.ratingPlaceholder
|
|
8171
|
-
}));
|
|
8172
|
-
};
|
|
8173
|
-
|
|
8174
|
-
const getDefaultCustomItemRenderers = () => ({
|
|
8175
|
-
Testimonial: {
|
|
8176
|
-
render: TestimonialItemRenderer,
|
|
8177
|
-
createItem: ({
|
|
8178
|
-
index,
|
|
8179
|
-
itemType
|
|
8180
|
-
}) => ({
|
|
8181
|
-
quote: '',
|
|
8182
|
-
personName: '',
|
|
8183
|
-
personRole: '',
|
|
8184
|
-
personOrganization: '',
|
|
8185
|
-
rating: 5,
|
|
8186
|
-
itemType,
|
|
8187
|
-
sequence: index
|
|
8188
|
-
})
|
|
8189
|
-
}
|
|
8190
|
-
});
|
|
8191
|
-
|
|
8192
8199
|
const Widget = ({
|
|
8193
8200
|
routes,
|
|
8194
8201
|
loader,
|
|
@@ -8203,8 +8210,7 @@ const Widget = ({
|
|
|
8203
8210
|
imageMaxSize,
|
|
8204
8211
|
translations,
|
|
8205
8212
|
children,
|
|
8206
|
-
onPrimaryButtonClick
|
|
8207
|
-
customItemRenderers
|
|
8213
|
+
onPrimaryButtonClick
|
|
8208
8214
|
}) => {
|
|
8209
8215
|
const {
|
|
8210
8216
|
commonTranslations
|
|
@@ -8212,8 +8218,6 @@ const Widget = ({
|
|
|
8212
8218
|
const derivedPermissions = Object.assign(DEFAULT_PERMISSIONS, _permissions);
|
|
8213
8219
|
const widgetFormRef = useRef(null);
|
|
8214
8220
|
const derivedT = Object.assign(Object.assign({}, TRANSLATION_PAIRS_WIDGET), translations || {});
|
|
8215
|
-
const defaultCustomItemRenderers = getDefaultCustomItemRenderers();
|
|
8216
|
-
const derivedCustomItemRenderers = Object.assign(Object.assign({}, defaultCustomItemRenderers), customItemRenderers || {});
|
|
8217
8221
|
const {
|
|
8218
8222
|
list,
|
|
8219
8223
|
loading,
|
|
@@ -8298,8 +8302,7 @@ const Widget = ({
|
|
|
8298
8302
|
})
|
|
8299
8303
|
}, /*#__PURE__*/React.createElement(WidgetForm, {
|
|
8300
8304
|
formRef: widgetFormRef,
|
|
8301
|
-
onPrimaryButtonClick: onPrimaryButtonClick
|
|
8302
|
-
customItemRenderers: derivedCustomItemRenderers
|
|
8305
|
+
onPrimaryButtonClick: onPrimaryButtonClick
|
|
8303
8306
|
}))), itemData && (/*#__PURE__*/React.createElement(DeleteModal, {
|
|
8304
8307
|
formState: formState,
|
|
8305
8308
|
itemData: itemData,
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ItemsAccordianProps } from '../../../types';
|
|
3
|
-
declare const ItemsAccordian: ({ show, title, id, collapseId, toggleShow, loading, name, errors, control, register, setError, itemType, languages, clearError,
|
|
3
|
+
declare const ItemsAccordian: ({ show, title, id, collapseId, toggleShow, loading, name, errors, control, register, setError, itemType, languages, clearError, widgetType, addText, deleteText, }: ItemsAccordianProps) => JSX.Element;
|
|
4
4
|
export default ItemsAccordian;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { FormProps } from '../../../types';
|
|
3
|
-
declare const WidgetForm: ({ formRef, customInputs,
|
|
3
|
+
declare const WidgetForm: ({ formRef, customInputs, onPrimaryButtonClick, }: FormProps) => JSX.Element | null;
|
|
4
4
|
export default WidgetForm;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { WidgetProps } from '../../../types';
|
|
3
3
|
declare const Widget: {
|
|
4
|
-
({ routes, loader, explicitForm, imageBaseUrl, permissions, preConfirmDelete, formatListItem, formatOptionLabel, imageMaxSize, translations, children, onPrimaryButtonClick,
|
|
4
|
+
({ routes, loader, explicitForm, imageBaseUrl, permissions, preConfirmDelete, formatListItem, formatOptionLabel, imageMaxSize, translations, children, onPrimaryButtonClick, }: WidgetProps): JSX.Element;
|
|
5
5
|
Table: ({ extraActions, extraColumns }: import("../../../types").DerivedTableProps) => JSX.Element;
|
|
6
|
-
Form: ({ formRef, customInputs,
|
|
6
|
+
Form: ({ formRef, customInputs, onPrimaryButtonClick, }: import("../../../types").FormProps) => JSX.Element | null;
|
|
7
7
|
AddButton: () => JSX.Element;
|
|
8
8
|
Search: () => JSX.Element;
|
|
9
9
|
Pagination: () => JSX.Element;
|
|
@@ -88,6 +88,10 @@ declare const TRANSLATION_PAIRS_WIDGET: {
|
|
|
88
88
|
subTitlePlaceholder: string;
|
|
89
89
|
quote: string;
|
|
90
90
|
quotePlaceholder: string;
|
|
91
|
+
question: string;
|
|
92
|
+
questionPlaceholder: string;
|
|
93
|
+
answer: string;
|
|
94
|
+
answerPlaceholder: string;
|
|
91
95
|
personName: string;
|
|
92
96
|
personNamePlaceholder: string;
|
|
93
97
|
personRole: string;
|
|
@@ -2,8 +2,7 @@ import React, { MutableRefObject } from 'react';
|
|
|
2
2
|
import { DropResult } from 'react-beautiful-dnd';
|
|
3
3
|
import { FieldValues, RegisterOptions, UseFormClearErrors, UseFormGetValues, UseFormSetValue, ValidationRule } from 'react-hook-form';
|
|
4
4
|
import { Routes_Input } from './api';
|
|
5
|
-
import { OptionType, FormActionTypes, PermissionsObj, ObjectType,
|
|
6
|
-
import type { CommonTranslationPairs } from './context';
|
|
5
|
+
import { OptionType, FormActionTypes, PermissionsObj, ObjectType, LanguageType } from './common';
|
|
7
6
|
export interface DNDItemsListProps {
|
|
8
7
|
onDragEnd: (result: DropResult) => void;
|
|
9
8
|
items: OptionType[];
|
|
@@ -141,7 +140,6 @@ export interface FormProps {
|
|
|
141
140
|
filterQuery?: string;
|
|
142
141
|
formRef: MutableRefObject<HTMLFormElement | null>;
|
|
143
142
|
customInputs?: Record<string, (props: InputRendererProps) => JSX.Element>;
|
|
144
|
-
customItemRenderers?: Record<string, CustomItemRendererConfig>;
|
|
145
143
|
onPrimaryButtonClick?: (e?: React.MouseEvent<HTMLButtonElement, MouseEvent>, data?: any) => void;
|
|
146
144
|
}
|
|
147
145
|
export interface InputRendererProps {
|
|
@@ -150,27 +148,6 @@ export interface InputRendererProps {
|
|
|
150
148
|
setError: (msg: string) => void;
|
|
151
149
|
disabled?: boolean;
|
|
152
150
|
}
|
|
153
|
-
export interface ItemRendererProps {
|
|
154
|
-
name: string;
|
|
155
|
-
index: number;
|
|
156
|
-
itemType: 'Web' | 'Mobile';
|
|
157
|
-
errors: any;
|
|
158
|
-
control: any;
|
|
159
|
-
register: any;
|
|
160
|
-
setError: any;
|
|
161
|
-
clearError: (key: string) => void;
|
|
162
|
-
languages?: LanguageType[];
|
|
163
|
-
loading?: boolean;
|
|
164
|
-
widgetTranslations: WidgetTranslationPairs;
|
|
165
|
-
commonTranslations: CommonTranslationPairs;
|
|
166
|
-
}
|
|
167
|
-
export interface CustomItemRendererConfig {
|
|
168
|
-
render: (props: ItemRendererProps) => JSX.Element;
|
|
169
|
-
createItem?: (props: {
|
|
170
|
-
index: number;
|
|
171
|
-
itemType: 'Web' | 'Mobile';
|
|
172
|
-
}) => CombineObjectType;
|
|
173
|
-
}
|
|
174
151
|
export interface WidgetTranslationPairs {
|
|
175
152
|
htmlContentRequired: string | ValidationRule<boolean> | undefined;
|
|
176
153
|
htmlContentPlaceholder: string | undefined;
|
|
@@ -203,6 +180,10 @@ export interface WidgetTranslationPairs {
|
|
|
203
180
|
subTitlePlaceholder: string;
|
|
204
181
|
quote: string;
|
|
205
182
|
quotePlaceholder: string;
|
|
183
|
+
question: string;
|
|
184
|
+
questionPlaceholder: string;
|
|
185
|
+
answer: string;
|
|
186
|
+
answerPlaceholder: string;
|
|
206
187
|
personName: string;
|
|
207
188
|
personNamePlaceholder: string;
|
|
208
189
|
personRole: string;
|
|
@@ -247,7 +228,6 @@ export interface WidgetProps {
|
|
|
247
228
|
imageBaseUrl?: string;
|
|
248
229
|
imageMaxSize?: number;
|
|
249
230
|
translations?: WidgetTranslationPairs;
|
|
250
|
-
customItemRenderers?: Record<string, CustomItemRendererConfig>;
|
|
251
231
|
onPrimaryButtonClick?: (e?: React.MouseEvent<HTMLButtonElement, MouseEvent>, data?: any) => void;
|
|
252
232
|
}
|
|
253
233
|
export interface DerivedTableProps {
|
|
@@ -347,7 +327,7 @@ export interface ItemsAccordianProps {
|
|
|
347
327
|
register: any;
|
|
348
328
|
setError: any;
|
|
349
329
|
clearError: (key: string) => void;
|
|
350
|
-
|
|
330
|
+
widgetType?: string;
|
|
351
331
|
}
|
|
352
332
|
export interface TabItemProps {
|
|
353
333
|
showDelete?: boolean;
|