eai-frontend-components 2.0.19 → 2.0.20

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
@@ -698,28 +698,98 @@ const HoverCardTrigger = HoverCardPrimitive__namespace.Trigger;
698
698
  const HoverCardContent = React__namespace.forwardRef(({ className, align = 'center', sideOffset = 4, ...props }, ref) => (jsxRuntime.jsx(HoverCardPrimitive__namespace.Content, { ref: ref, align: align, sideOffset: sideOffset, className: cn('z-50 w-auto mr-20 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-2', className), ...props })));
699
699
  HoverCardContent.displayName = HoverCardPrimitive__namespace.Content.displayName;
700
700
 
701
+ /**
702
+ * Modify function for phone number input mask.
703
+ * Automatically adjusts between landline and mobile phone formats.
704
+ *
705
+ * @param value - Current input value
706
+ * @param data - New input data
707
+ * @param selectionStart - Cursor start position
708
+ * @param selectionEnd - Cursor end position
709
+ * @returns Mask configuration object
710
+ */
701
711
  const modifyPhone = ({ value, data, selectionStart, selectionEnd }) => {
702
712
  const _value = value.slice(0, selectionStart) + (data ?? '') + value.slice(selectionEnd);
703
713
  _value ? _value.replace(/[\D]+/g, '').length : 0;
704
714
  return maskPhone(_value);
705
715
  };
716
+ /**
717
+ * Creates a phone number mask based on the input length.
718
+ * - Landline: (XX) XXXX-XXXX
719
+ * - Mobile: (XX) X XXXX-XXXX
720
+ *
721
+ * @param value - Phone number string (can be null)
722
+ * @returns Mask configuration object with pattern and replacement rules
723
+ *
724
+ * @example
725
+ * ```tsx
726
+ * const mask = maskPhone('11987654321');
727
+ * // Returns: { mask: '(__) _ ____-____', replacement: { _: /\d/ } }
728
+ * ```
729
+ */
706
730
  function maskPhone(value) {
707
731
  const len = value ? value.replace(/[\D]+/g, '').length : 0;
708
732
  if (len > 10)
709
733
  return { mask: '(__) _ ____-____', replacement: { _: /\d/ } };
710
734
  return { mask: '(__) ____-_____', replacement: { _: /\d/ } };
711
735
  }
736
+ /**
737
+ * Modify function for CPF/CNPJ input mask.
738
+ * Automatically switches between CPF and CNPJ formats based on input length.
739
+ *
740
+ * @param value - Current input value
741
+ * @param data - New input data
742
+ * @param selectionStart - Cursor start position
743
+ * @param selectionEnd - Cursor end position
744
+ * @returns Mask configuration object
745
+ */
712
746
  const modifyCpfCnpj = ({ value, data, selectionStart, selectionEnd }) => {
713
747
  const _value = value.slice(0, selectionStart) + (data ?? '') + value.slice(selectionEnd);
714
748
  _value ? _value.replace(/[\D]+/g, '').length : 0;
715
749
  return maskCpfCnpj(_value);
716
750
  };
751
+ /**
752
+ * Creates a CPF or CNPJ mask based on the input length.
753
+ * - CPF: XXX.XXX.XXX-XX (up to 11 digits)
754
+ * - CNPJ: XX.XXX.XXX/XXXX-XX (12+ digits)
755
+ *
756
+ * @param value - CPF/CNPJ string (can be null)
757
+ * @returns Mask configuration object with pattern and replacement rules
758
+ *
759
+ * @example
760
+ * ```tsx
761
+ * const cpfMask = maskCpfCnpj('12345678901');
762
+ * // Returns: { mask: '___.___.___-___', replacement: { _: /\d/ } }
763
+ *
764
+ * const cnpjMask = maskCpfCnpj('12345678000195');
765
+ * // Returns: { mask: '__.___.___/____-__', replacement: { _: /\d/ } }
766
+ * ```
767
+ */
717
768
  function maskCpfCnpj(value) {
718
769
  const len = value ? value.replace(/[\D]+/g, '').length : 0;
719
770
  if (len > 11)
720
771
  return { mask: '__.___.___/____-__', replacement: { _: /\d/ } };
721
772
  return { mask: '___.___.___-___', replacement: { _: /\d/ } };
722
773
  }
774
+ /**
775
+ * Removes all non-numeric characters from a string.
776
+ * Useful for extracting only digits from masked inputs.
777
+ *
778
+ * @param value - String with potential mask characters
779
+ * @returns String containing only numeric characters
780
+ *
781
+ * @example
782
+ * ```tsx
783
+ * const cleaned = removeMaskNumber('(11) 9 8765-4321');
784
+ * // Returns: '11987654321'
785
+ *
786
+ * const cleanCpf = removeMaskNumber('123.456.789-01');
787
+ * // Returns: '12345678901'
788
+ * ```
789
+ */
790
+ const removeMaskNumber = (value) => {
791
+ return value?.replace(/\D/g, '');
792
+ };
723
793
 
724
794
  // PHONE
725
795
  function formatPhone(telefone, removerCountryCode = true) {
@@ -3665,8 +3735,11 @@ exports.getFirstDayOfCurrentMonth = getFirstDayOfCurrentMonth;
3665
3735
  exports.getTailwindColorShades = getTailwindColorShades;
3666
3736
  exports.invertDate = invertDate;
3667
3737
  exports.isUUIDv4 = isUUIDv4;
3738
+ exports.maskCpfCnpj = maskCpfCnpj;
3739
+ exports.maskPhone = maskPhone;
3668
3740
  exports.modifyCpfCnpj = modifyCpfCnpj;
3669
3741
  exports.modifyPhone = modifyPhone;
3742
+ exports.removeMaskNumber = removeMaskNumber;
3670
3743
  exports.replaceThemeTailwindColors = replaceThemeTailwindColors;
3671
3744
  exports.roundNumber = roundNumber;
3672
3745
  exports.stringDateToDate = stringDateToDate;