tp-react-elements-dev 1.7.0 → 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.
package/dist/index.js CHANGED
@@ -52368,6 +52368,8 @@ var JoditEditor = /*@__PURE__*/getDefaultExportFromCjs(joditReactExports);
52368
52368
 
52369
52369
  const RichTextEditor = ({ props }) => {
52370
52370
  const editor = React$1.useRef(null);
52371
+ const [content, setContent] = React$1.useState("");
52372
+ const value = props.getValues(props.item.name);
52371
52373
  const config = Object.assign({ readonly: false, placeholder: "Start typing...", removeButtons: props.item.removeButtons, style: {
52372
52374
  'font-family': 'Arial', // Default font is Arial
52373
52375
  }, controls: {
@@ -52377,13 +52379,30 @@ const RichTextEditor = ({ props }) => {
52377
52379
  'Rotis Semi Sans': 'Rotis Semi Sans', // Allow Rotis Semi Sans
52378
52380
  },
52379
52381
  },
52380
- }, defaultFont: 'Arial' }, props.item.sx);
52382
+ fontsize: {
52383
+ list: joditReactExports.Jodit.atom([8, 9, 10, 11])
52384
+ }
52385
+ }, defaultFont: 'Arial', defaultFontSize: '11px' }, props.item.sx);
52381
52386
  // [placeholder]
52382
52387
  // );
52383
52388
  const handleBlur = (newContent) => {
52384
- props.setValue(props.item.name, newContent);
52389
+ if (newContent === "<p><br></p>") {
52390
+ setContent(newContent);
52391
+ props.setValue(props.item.name, '');
52392
+ }
52393
+ else {
52394
+ setContent(newContent);
52395
+ props.setValue(props.item.name, newContent);
52396
+ }
52397
+ props.item.onBlurFn && props.item.onBlurFn(newContent);
52398
+ };
52399
+ React$1.useEffect(() => {
52400
+ setContent(value);
52401
+ }, [value]);
52402
+ const handleChange = (newContent) => {
52403
+ console.log(newContent, 'newContent Editor');
52385
52404
  };
52386
- return (jsxRuntimeExports.jsx(JoditEditor, { ref: editor, value: props.getValues(props.item.name), config: config, tabIndex: 1, onBlur: handleBlur, onChange: (newContent) => { } }));
52405
+ return (jsxRuntimeExports.jsx(JoditEditor, { ref: editor, value: content, config: config, tabIndex: 1, onBlur: handleBlur, onChange: handleChange }));
52387
52406
  };
52388
52407
 
52389
52408
  const renderLabel = (label, isRequired, alignRight) => {
@@ -55242,7 +55261,7 @@ create$3.prototype = ObjectSchema.prototype;
55242
55261
  const useFormValidatingContext = (formArray) => {
55243
55262
  const initialValues = {};
55244
55263
  const validationShape = {};
55245
- console.log(formArray, 'formArrayformArray');
55264
+ console.log(formArray, "formArrayformArray");
55246
55265
  const renderCustomError = (field) => {
55247
55266
  if (field.customErrorMessage) {
55248
55267
  validationShape[field.name] = validationShape[field.name].test("custom-check", field.customErrorMessage, // Use the actual custom message
@@ -55314,22 +55333,25 @@ const useFormValidatingContext = (formArray) => {
55314
55333
  .test("valid-email", `Please enter valid Email`, (value) => {
55315
55334
  if (!value)
55316
55335
  return false;
55317
- const emails = value.split(';');
55336
+ const emails = value.split(";");
55318
55337
  const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
55319
- return emails.every(email => emailRegex.test(email.trim()));
55338
+ return emails.every((email) => emailRegex.test(email.trim()));
55320
55339
  });
55321
55340
  renderCustomError(field);
55322
55341
  }
55323
55342
  else {
55324
55343
  validationShape[field.name] = create$6()
55325
55344
  .typeError(`Please enter ${field.label}`)
55326
- .test("valid-email", `Please enter valid Email`, (value) => {
55345
+ .test("custom", `Please enter valid Email`, (value) => {
55327
55346
  // Custom validation to check for at least one period after '@'
55328
- if (!value)
55329
- return false;
55330
- const emails = value.split(';');
55331
- const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
55332
- return emails.every(email => emailRegex.test(email.trim()));
55347
+ if (!value || value === "") {
55348
+ return true;
55349
+ }
55350
+ else {
55351
+ const emails = value.split(";");
55352
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
55353
+ return emails.every((email) => emailRegex.test(email.trim()));
55354
+ }
55333
55355
  });
55334
55356
  renderCustomError(field);
55335
55357
  }