@eui/components 18.2.1-snapshot-1728031106807 → 18.2.1-snapshot-1728522473454

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.
@@ -763,19 +763,20 @@
763
763
  <tr>
764
764
  <td class="col-md-4">
765
765
  <i>Default value : </i><code>(maxWords: number): ValidatorFn &#x3D;&gt;
766
- (control: AbstractControl): { maxWords: { maxWords: number; actual: number } } | null &#x3D;&gt; {
766
+ (control: AbstractControl&lt;string&gt;): { maxWords: { maxWords: number; actual: number } } | null &#x3D;&gt; {
767
+ const regex &#x3D; /[\s\n]+/;
767
768
  if (control.value) {
768
769
  let actual &#x3D; 0;
769
770
  if (isJson(control.value)) {
770
771
  const content &#x3D; JSON.parse(control.value)
771
- .ops.filter((c: { attributes: string; insert: string }) &#x3D;&gt; typeof c.insert &#x3D;&#x3D;&#x3D; &#x27;string&#x27;)
772
- .map((c: { attributes: string; insert: string }) &#x3D;&gt; c.insert.replace(/\n/g, &#x27; &#x27;));
772
+ .ops.filter((c: { insert: string }) &#x3D;&gt; typeof c.insert &#x3D;&#x3D;&#x3D; &#x27;string&#x27;)
773
+ .map((c: { insert: string }) &#x3D;&gt; c.insert);
773
774
 
774
775
  const jsonStrippedContent &#x3D; content.join(&#x27;&#x27;);
775
- actual &#x3D; jsonStrippedContent.trim().split(/\s+/).length;
776
+ actual &#x3D; jsonStrippedContent.replace(/\n/g, &#x27; &#x27;).split(/\s+/).filter(t &#x3D;&gt; t !&#x3D;&#x3D; &#x27;&#x27;).length;
776
777
  } else {
777
- const tagsStrippedContent &#x3D; control.value.replace(/&lt;[^&gt;]*&gt;/g, &#x27;&#x27;);
778
- actual &#x3D; tagsStrippedContent.replace(/[\u200B-\u200D\uFEFF]/g, &#x27;&#x27;).trim().split(/\s+/).filter(t &#x3D;&gt; t !&#x3D;&#x3D; &#x27;&#x27;).length;
778
+ const text &#x3D; control.value.replace(/[\u200B-\u200D\uFEFF]/g, &#x27;&#x27;).replace(/&lt;\/(p|div|br|li|h[1-6])&gt;/gi, &#x27; &#x27;).replace(/&lt;[^&gt;]+&gt;/g, &#x27;&#x27;);
779
+ actual &#x3D; !text ? 0 : text.trim().split(regex).filter(t &#x3D;&gt; t !&#x3D;&#x3D; &#x27;&#x27;).length;
779
780
  }
780
781
 
781
782
  return actual &gt; maxWords ? { maxWords: { maxWords, actual } } : null;
@@ -869,19 +870,20 @@
869
870
  <tr>
870
871
  <td class="col-md-4">
871
872
  <i>Default value : </i><code>(minWords: number): ValidatorFn &#x3D;&gt;
872
- (control: AbstractControl): { minWords: { minWords: number; actual: number } } | null &#x3D;&gt; {
873
+ (control: AbstractControl&lt;string&gt;): { minWords: { minWords: number; actual: number } } | null &#x3D;&gt; {
874
+ const regex &#x3D; /[\s\n]+/;
873
875
  if (control.value) {
874
876
  let actual &#x3D; 0;
875
877
  if (isJson(control.value)) {
876
878
  const content &#x3D; JSON.parse(control.value)
877
- .ops.filter((c: { attributes: string; insert: string }) &#x3D;&gt; typeof c.insert &#x3D;&#x3D;&#x3D; &#x27;string&#x27;)
878
- .map((c: { attributes: string; insert: string }) &#x3D;&gt; c.insert.replace(/\n/g, &#x27; &#x27;));
879
+ .ops.filter((c: { insert: string }) &#x3D;&gt; typeof c.insert &#x3D;&#x3D;&#x3D; &#x27;string&#x27;)
880
+ .map((c: { insert: string }) &#x3D;&gt; c.insert);
879
881
 
880
882
  const jsonStrippedContent &#x3D; content.join(&#x27;&#x27;);
881
- actual &#x3D; jsonStrippedContent.trim().split(/\s+/).length;
883
+ actual &#x3D; jsonStrippedContent.replace(/\n/g, &#x27; &#x27;).split(/\s+/).filter(t &#x3D;&gt; t !&#x3D;&#x3D; &#x27;&#x27;).length;
882
884
  } else {
883
- const tagsStrippedContent &#x3D; control.value.replace(/&lt;[^&gt;]*&gt;/g, &#x27;&#x27;);
884
- actual &#x3D; tagsStrippedContent.replace(/[\u200B-\u200D\uFEFF]/g, &#x27;&#x27;).trim().split(/\s+/).filter(t &#x3D;&gt; t !&#x3D;&#x3D; &#x27;&#x27;).length;
885
+ const text &#x3D; control.value.replace(/[\u200B-\u200D\uFEFF]/g, &#x27;&#x27;).replace(/&lt;\/(p|div|br|li|h[1-6])&gt;/gi, &#x27; &#x27;).replace(/&lt;[^&gt;]+&gt;/g, &#x27;&#x27;);
886
+ actual &#x3D; !text ? 0 : text.trim().split(regex).filter(t &#x3D;&gt; t !&#x3D;&#x3D; &#x27;&#x27;).length;
885
887
  }
886
888
 
887
889
  return actual &lt; minWords ? { minWords: { minWords, actual } } : null;