@knovator/pagecreator-admin 1.7.1 → 1.7.2

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.
Files changed (3) hide show
  1. package/index.cjs +100 -52
  2. package/index.js +100 -52
  3. package/package.json +1 -1
package/index.cjs CHANGED
@@ -3826,40 +3826,53 @@ const SimpleForm = /*#__PURE__*/React.forwardRef(({
3826
3826
  languages
3827
3827
  }, ref) => {
3828
3828
  const inputRenderer = schema => {
3829
- var _a, _b, _c, _d, _e, _f;
3829
+ var _a, _b, _c, _d;
3830
3830
  let input;
3831
3831
  if (typeof schema.show !== 'undefined' && !schema.show) return null;
3832
3832
  if (schema.type) {
3833
3833
  switch (schema.type) {
3834
3834
  case 'ReactSelect':
3835
- input = /*#__PURE__*/React__default["default"].createElement(CustomReactSelect, {
3836
- disabled: _isUpdating && typeof schema.editable !== 'undefined' && !schema.editable || !_enable || schema.disabled,
3837
- label: schema.label,
3838
- error: (_b = (_a = errors[schema.accessor]) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.toString(),
3839
- onChange: value => {
3840
- // Handle clear (null value) and selection
3841
- const fieldValue = value ? Array.isArray(value) ? value.map(item => item.value) : value.value : null;
3842
- setValue(schema.accessor, fieldValue);
3843
- if (schema.onChange) schema.onChange(value);
3844
- },
3845
- selectedOptions: schema.selectedOptions,
3846
- required: schema.required,
3847
- isMulti: schema.isMulti,
3848
- isSearchable: schema.isSearchable,
3849
- isClearable: schema.isClearable,
3850
- isLoading: schema.isLoading,
3851
- placeholder: schema.placeholder,
3852
- wrapperClassName: schema.wrapperClassName,
3853
- formatOptionLabel: schema.formatOptionLabel,
3854
- listCode: schema.listCode,
3855
- customStyles: schema.customStyles,
3856
- loadOptions: schema.loadOptions,
3857
- selectKey: schema.selectKey
3835
+ input = /*#__PURE__*/React__default["default"].createElement(reactHookForm.Controller, {
3836
+ control: control,
3837
+ name: schema.accessor,
3838
+ rules: schema.validations,
3839
+ render: ({
3840
+ field
3841
+ }) => {
3842
+ var _a, _b;
3843
+ return /*#__PURE__*/React__default["default"].createElement(CustomReactSelect, {
3844
+ disabled: _isUpdating && typeof schema.editable !== 'undefined' && !schema.editable || !_enable || schema.disabled,
3845
+ label: schema.label,
3846
+ error: (_b = (_a = errors[schema.accessor]) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.toString(),
3847
+ onChange: value => {
3848
+ // Handle clear (null value) and selection
3849
+ const fieldValue = value ? Array.isArray(value) ? value.map(item => item.value) : value.value : null;
3850
+ field.onChange(fieldValue);
3851
+ setValue(schema.accessor, fieldValue, {
3852
+ shouldValidate: true
3853
+ });
3854
+ if (schema.onChange) schema.onChange(value);
3855
+ },
3856
+ selectedOptions: schema.selectedOptions,
3857
+ required: schema.required,
3858
+ isMulti: schema.isMulti,
3859
+ isSearchable: schema.isSearchable,
3860
+ isClearable: schema.isClearable,
3861
+ isLoading: schema.isLoading,
3862
+ placeholder: schema.placeholder,
3863
+ wrapperClassName: schema.wrapperClassName,
3864
+ formatOptionLabel: schema.formatOptionLabel,
3865
+ listCode: schema.listCode,
3866
+ customStyles: schema.customStyles,
3867
+ loadOptions: schema.loadOptions,
3868
+ selectKey: schema.selectKey
3869
+ });
3870
+ }
3858
3871
  });
3859
3872
  break;
3860
3873
  case 'checkbox':
3861
3874
  input = /*#__PURE__*/React__default["default"].createElement(Input.Checkbox, {
3862
- error: (_d = (_c = errors[schema.accessor]) === null || _c === void 0 ? void 0 : _c.message) === null || _d === void 0 ? void 0 : _d.toString(),
3875
+ error: (_b = (_a = errors[schema.accessor]) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.toString(),
3863
3876
  switchClass: schema.switchClass,
3864
3877
  label: schema.label,
3865
3878
  rest: register(schema.accessor, schema.validations || {}),
@@ -3915,7 +3928,7 @@ const SimpleForm = /*#__PURE__*/React.forwardRef(({
3915
3928
  } else input = /*#__PURE__*/React__default["default"].createElement(Input, {
3916
3929
  rest: register(schema.accessor, schema.validations || {}),
3917
3930
  label: schema.label,
3918
- error: (_f = (_e = errors[schema.accessor]) === null || _e === void 0 ? void 0 : _e.message) === null || _f === void 0 ? void 0 : _f.toString(),
3931
+ error: (_d = (_c = errors[schema.accessor]) === null || _c === void 0 ? void 0 : _c.message) === null || _d === void 0 ? void 0 : _d.toString(),
3919
3932
  type: schema.type,
3920
3933
  className: classNames__default["default"]('w-full p-2', schema.className),
3921
3934
  placeholder: schema.placeholder,
@@ -7476,6 +7489,17 @@ const WidgetForm = ({
7476
7489
  if (!formData[constants.widgetTypeAccessor] && formState === 'ADD') {
7477
7490
  formData[constants.widgetTypeAccessor] = getFirstWidgetTypeValue();
7478
7491
  }
7492
+ // Validate blogLimit is required when itemsType is 'blog'
7493
+ const widgetTypeValue = formData[constants.widgetTypeAccessor] || (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value);
7494
+ if (currentItemsType === 'blog' && !itemsEnabled && (widgetTypeValue === constants.carouselWidgetTypeValue || widgetTypeValue === constants.fixedCardWidgetTypeValue) && !!(selectedCollectionType === null || selectedCollectionType === void 0 ? void 0 : selectedCollectionType.value)) {
7495
+ if (!formData['blogLimit'] || formData['blogLimit'] === '') {
7496
+ setError('blogLimit', {
7497
+ type: 'manual',
7498
+ message: 'Number of blogs is required'
7499
+ });
7500
+ return;
7501
+ }
7502
+ }
7479
7503
  // setting tabs data if widgetType tab is selected
7480
7504
  const tabsData = getValues(constants.tabsAccessor);
7481
7505
  if (Array.isArray(tabsData) && tabsData.length > 0) {
@@ -7692,38 +7716,62 @@ const WidgetForm = ({
7692
7716
  isLoading: blogCategoriesLoading,
7693
7717
  show: currentItemsType === 'blog' && !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),
7694
7718
  placeholder: 'Select blog category...',
7695
- wrapperClassName: 'khb_grid-item-1of2 khb_padding-right-1',
7696
7719
  customStyles: reactSelectStyles || {},
7697
7720
  selectKey: `blog-category-select-${blogCategories.length}`
7698
7721
  }, {
7699
7722
  label: 'No. of Blogs',
7700
7723
  accessor: 'blogLimit',
7701
- type: 'select',
7702
- options: [{
7703
- value: '',
7704
- label: 'Select number of blogs'
7705
- }, {
7706
- value: '1',
7707
- label: '1'
7708
- }, {
7709
- value: '2',
7710
- label: '2'
7711
- }, {
7712
- value: '3',
7713
- label: '3'
7714
- }, {
7715
- value: '4',
7716
- label: '4'
7717
- }, {
7718
- value: '5',
7719
- label: '5'
7720
- }, {
7721
- value: '6',
7722
- label: '6'
7723
- }],
7724
- show: currentItemsType === 'blog' && !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),
7725
- wrapperClassName: 'khb_grid-item-1of2 khb_padding-left-1',
7724
+ type: 'ReactSelect',
7725
+ selectedOptions: blogLimit ? [{
7726
+ value: blogLimit.toString(),
7727
+ label: blogLimit.toString()
7728
+ }] : [],
7729
+ isMulti: false,
7730
+ isSearchable: false,
7726
7731
  required: true,
7732
+ isClearable: false,
7733
+ onChange: selected => {
7734
+ const selectedValue = Array.isArray(selected) ? selected[0] : selected;
7735
+ if (selectedValue) {
7736
+ setBlogLimit(parseInt(selectedValue.value));
7737
+ setValue('blogLimit', selectedValue.value);
7738
+ // Clear any existing error when a value is selected
7739
+ clearErrors('blogLimit');
7740
+ } else {
7741
+ // Set error if cleared
7742
+ setError('blogLimit', {
7743
+ type: 'manual',
7744
+ message: 'Number of blogs is required'
7745
+ });
7746
+ }
7747
+ },
7748
+ loadOptions: (_searchStr, callback) => {
7749
+ if (!callback) return;
7750
+ const options = [{
7751
+ value: '1',
7752
+ label: '1'
7753
+ }, {
7754
+ value: '2',
7755
+ label: '2'
7756
+ }, {
7757
+ value: '3',
7758
+ label: '3'
7759
+ }, {
7760
+ value: '4',
7761
+ label: '4'
7762
+ }, {
7763
+ value: '5',
7764
+ label: '5'
7765
+ }, {
7766
+ value: '6',
7767
+ label: '6'
7768
+ }];
7769
+ callback(options);
7770
+ },
7771
+ show: currentItemsType === 'blog' && !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),
7772
+ placeholder: 'Select number of blogs',
7773
+ customStyles: reactSelectStyles || {},
7774
+ selectKey: `blog-limit-select-${blogLimit}`,
7727
7775
  validations: {
7728
7776
  required: 'Number of blogs is required'
7729
7777
  }
package/index.js CHANGED
@@ -3814,40 +3814,53 @@ const SimpleForm = /*#__PURE__*/forwardRef(({
3814
3814
  languages
3815
3815
  }, ref) => {
3816
3816
  const inputRenderer = schema => {
3817
- var _a, _b, _c, _d, _e, _f;
3817
+ var _a, _b, _c, _d;
3818
3818
  let input;
3819
3819
  if (typeof schema.show !== 'undefined' && !schema.show) return null;
3820
3820
  if (schema.type) {
3821
3821
  switch (schema.type) {
3822
3822
  case 'ReactSelect':
3823
- input = /*#__PURE__*/React.createElement(CustomReactSelect, {
3824
- disabled: _isUpdating && typeof schema.editable !== 'undefined' && !schema.editable || !_enable || schema.disabled,
3825
- label: schema.label,
3826
- error: (_b = (_a = errors[schema.accessor]) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.toString(),
3827
- onChange: value => {
3828
- // Handle clear (null value) and selection
3829
- const fieldValue = value ? Array.isArray(value) ? value.map(item => item.value) : value.value : null;
3830
- setValue(schema.accessor, fieldValue);
3831
- if (schema.onChange) schema.onChange(value);
3832
- },
3833
- selectedOptions: schema.selectedOptions,
3834
- required: schema.required,
3835
- isMulti: schema.isMulti,
3836
- isSearchable: schema.isSearchable,
3837
- isClearable: schema.isClearable,
3838
- isLoading: schema.isLoading,
3839
- placeholder: schema.placeholder,
3840
- wrapperClassName: schema.wrapperClassName,
3841
- formatOptionLabel: schema.formatOptionLabel,
3842
- listCode: schema.listCode,
3843
- customStyles: schema.customStyles,
3844
- loadOptions: schema.loadOptions,
3845
- selectKey: schema.selectKey
3823
+ input = /*#__PURE__*/React.createElement(Controller, {
3824
+ control: control,
3825
+ name: schema.accessor,
3826
+ rules: schema.validations,
3827
+ render: ({
3828
+ field
3829
+ }) => {
3830
+ var _a, _b;
3831
+ return /*#__PURE__*/React.createElement(CustomReactSelect, {
3832
+ disabled: _isUpdating && typeof schema.editable !== 'undefined' && !schema.editable || !_enable || schema.disabled,
3833
+ label: schema.label,
3834
+ error: (_b = (_a = errors[schema.accessor]) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.toString(),
3835
+ onChange: value => {
3836
+ // Handle clear (null value) and selection
3837
+ const fieldValue = value ? Array.isArray(value) ? value.map(item => item.value) : value.value : null;
3838
+ field.onChange(fieldValue);
3839
+ setValue(schema.accessor, fieldValue, {
3840
+ shouldValidate: true
3841
+ });
3842
+ if (schema.onChange) schema.onChange(value);
3843
+ },
3844
+ selectedOptions: schema.selectedOptions,
3845
+ required: schema.required,
3846
+ isMulti: schema.isMulti,
3847
+ isSearchable: schema.isSearchable,
3848
+ isClearable: schema.isClearable,
3849
+ isLoading: schema.isLoading,
3850
+ placeholder: schema.placeholder,
3851
+ wrapperClassName: schema.wrapperClassName,
3852
+ formatOptionLabel: schema.formatOptionLabel,
3853
+ listCode: schema.listCode,
3854
+ customStyles: schema.customStyles,
3855
+ loadOptions: schema.loadOptions,
3856
+ selectKey: schema.selectKey
3857
+ });
3858
+ }
3846
3859
  });
3847
3860
  break;
3848
3861
  case 'checkbox':
3849
3862
  input = /*#__PURE__*/React.createElement(Input.Checkbox, {
3850
- error: (_d = (_c = errors[schema.accessor]) === null || _c === void 0 ? void 0 : _c.message) === null || _d === void 0 ? void 0 : _d.toString(),
3863
+ error: (_b = (_a = errors[schema.accessor]) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.toString(),
3851
3864
  switchClass: schema.switchClass,
3852
3865
  label: schema.label,
3853
3866
  rest: register(schema.accessor, schema.validations || {}),
@@ -3903,7 +3916,7 @@ const SimpleForm = /*#__PURE__*/forwardRef(({
3903
3916
  } else input = /*#__PURE__*/React.createElement(Input, {
3904
3917
  rest: register(schema.accessor, schema.validations || {}),
3905
3918
  label: schema.label,
3906
- error: (_f = (_e = errors[schema.accessor]) === null || _e === void 0 ? void 0 : _e.message) === null || _f === void 0 ? void 0 : _f.toString(),
3919
+ error: (_d = (_c = errors[schema.accessor]) === null || _c === void 0 ? void 0 : _c.message) === null || _d === void 0 ? void 0 : _d.toString(),
3907
3920
  type: schema.type,
3908
3921
  className: classNames('w-full p-2', schema.className),
3909
3922
  placeholder: schema.placeholder,
@@ -7464,6 +7477,17 @@ const WidgetForm = ({
7464
7477
  if (!formData[constants.widgetTypeAccessor] && formState === 'ADD') {
7465
7478
  formData[constants.widgetTypeAccessor] = getFirstWidgetTypeValue();
7466
7479
  }
7480
+ // Validate blogLimit is required when itemsType is 'blog'
7481
+ const widgetTypeValue = formData[constants.widgetTypeAccessor] || (selectedWidgetType === null || selectedWidgetType === void 0 ? void 0 : selectedWidgetType.value);
7482
+ if (currentItemsType === 'blog' && !itemsEnabled && (widgetTypeValue === constants.carouselWidgetTypeValue || widgetTypeValue === constants.fixedCardWidgetTypeValue) && !!(selectedCollectionType === null || selectedCollectionType === void 0 ? void 0 : selectedCollectionType.value)) {
7483
+ if (!formData['blogLimit'] || formData['blogLimit'] === '') {
7484
+ setError('blogLimit', {
7485
+ type: 'manual',
7486
+ message: 'Number of blogs is required'
7487
+ });
7488
+ return;
7489
+ }
7490
+ }
7467
7491
  // setting tabs data if widgetType tab is selected
7468
7492
  const tabsData = getValues(constants.tabsAccessor);
7469
7493
  if (Array.isArray(tabsData) && tabsData.length > 0) {
@@ -7680,38 +7704,62 @@ const WidgetForm = ({
7680
7704
  isLoading: blogCategoriesLoading,
7681
7705
  show: currentItemsType === 'blog' && !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),
7682
7706
  placeholder: 'Select blog category...',
7683
- wrapperClassName: 'khb_grid-item-1of2 khb_padding-right-1',
7684
7707
  customStyles: reactSelectStyles || {},
7685
7708
  selectKey: `blog-category-select-${blogCategories.length}`
7686
7709
  }, {
7687
7710
  label: 'No. of Blogs',
7688
7711
  accessor: 'blogLimit',
7689
- type: 'select',
7690
- options: [{
7691
- value: '',
7692
- label: 'Select number of blogs'
7693
- }, {
7694
- value: '1',
7695
- label: '1'
7696
- }, {
7697
- value: '2',
7698
- label: '2'
7699
- }, {
7700
- value: '3',
7701
- label: '3'
7702
- }, {
7703
- value: '4',
7704
- label: '4'
7705
- }, {
7706
- value: '5',
7707
- label: '5'
7708
- }, {
7709
- value: '6',
7710
- label: '6'
7711
- }],
7712
- show: currentItemsType === 'blog' && !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),
7713
- wrapperClassName: 'khb_grid-item-1of2 khb_padding-left-1',
7712
+ type: 'ReactSelect',
7713
+ selectedOptions: blogLimit ? [{
7714
+ value: blogLimit.toString(),
7715
+ label: blogLimit.toString()
7716
+ }] : [],
7717
+ isMulti: false,
7718
+ isSearchable: false,
7714
7719
  required: true,
7720
+ isClearable: false,
7721
+ onChange: selected => {
7722
+ const selectedValue = Array.isArray(selected) ? selected[0] : selected;
7723
+ if (selectedValue) {
7724
+ setBlogLimit(parseInt(selectedValue.value));
7725
+ setValue('blogLimit', selectedValue.value);
7726
+ // Clear any existing error when a value is selected
7727
+ clearErrors('blogLimit');
7728
+ } else {
7729
+ // Set error if cleared
7730
+ setError('blogLimit', {
7731
+ type: 'manual',
7732
+ message: 'Number of blogs is required'
7733
+ });
7734
+ }
7735
+ },
7736
+ loadOptions: (_searchStr, callback) => {
7737
+ if (!callback) return;
7738
+ const options = [{
7739
+ value: '1',
7740
+ label: '1'
7741
+ }, {
7742
+ value: '2',
7743
+ label: '2'
7744
+ }, {
7745
+ value: '3',
7746
+ label: '3'
7747
+ }, {
7748
+ value: '4',
7749
+ label: '4'
7750
+ }, {
7751
+ value: '5',
7752
+ label: '5'
7753
+ }, {
7754
+ value: '6',
7755
+ label: '6'
7756
+ }];
7757
+ callback(options);
7758
+ },
7759
+ show: currentItemsType === 'blog' && !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),
7760
+ placeholder: 'Select number of blogs',
7761
+ customStyles: reactSelectStyles || {},
7762
+ selectKey: `blog-limit-select-${blogLimit}`,
7715
7763
  validations: {
7716
7764
  required: 'Number of blogs is required'
7717
7765
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knovator/pagecreator-admin",
3
- "version": "1.7.1",
3
+ "version": "1.7.2",
4
4
  "dependencies": {
5
5
  "classnames": "^2.3.1",
6
6
  "react-beautiful-dnd": "^13.1.0",