eai-frontend-components 2.0.45 → 2.0.47
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.d.ts +14 -12
- package/dist/index.esm.js +15 -5
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +15 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -791,23 +791,33 @@ const removeMaskNumber = (value) => {
|
|
|
791
791
|
* Automatically detects landline vs mobile format.
|
|
792
792
|
*
|
|
793
793
|
* @param telefone - Raw phone number string
|
|
794
|
-
* @param
|
|
794
|
+
* @param removeDDD - Whether to remove DDD (area code) from the formatted output
|
|
795
|
+
* @param removeCountryCode - Whether to remove country code (55) if present
|
|
795
796
|
* @returns Formatted phone number string
|
|
796
797
|
*
|
|
797
798
|
* @example
|
|
798
799
|
* ```tsx
|
|
799
800
|
* formatPhone('11987654321') // '(11) 9 8765-4321'
|
|
800
801
|
* formatPhone('1134567890') // '(11) 3456-7890'
|
|
802
|
+
* formatPhone('11987654321', true) // '9 8765-4321'
|
|
801
803
|
* ```
|
|
802
804
|
*/
|
|
803
|
-
function formatPhone(telefone,
|
|
805
|
+
function formatPhone(telefone, removeDDD = false, removeCountryCode = true) {
|
|
804
806
|
if (!telefone)
|
|
805
807
|
return '';
|
|
806
808
|
let numberPhone = telefone.replace(/\D/g, '');
|
|
807
809
|
// Remover código do país apenas se ele começar com '55'
|
|
808
|
-
if (
|
|
810
|
+
if (removeCountryCode && numberPhone.startsWith('55')) {
|
|
809
811
|
numberPhone = numberPhone.substring(2);
|
|
810
812
|
}
|
|
813
|
+
// Se removeDDD for true, remover os dois primeiros dígitos (DDD)
|
|
814
|
+
if (removeDDD && numberPhone.length >= 10) {
|
|
815
|
+
const phoneWithoutDDD = numberPhone.substring(2);
|
|
816
|
+
// Aplicar máscara sem DDD
|
|
817
|
+
const isMobile = phoneWithoutDDD.length === 9;
|
|
818
|
+
const mask = isMobile ? { mask: '_ ____-____', replacement: { _: /\d/ } } : { mask: '____-_____', replacement: { _: /\d/ } };
|
|
819
|
+
return mask$1.format(phoneWithoutDDD, mask);
|
|
820
|
+
}
|
|
811
821
|
return mask$1.format(numberPhone, maskPhone(numberPhone));
|
|
812
822
|
}
|
|
813
823
|
// CPF/CNPJ
|
|
@@ -9244,7 +9254,7 @@ const FormCombobox = ({ control, variant = 'outline', name, label, subLabel, hel
|
|
|
9244
9254
|
const [open, setOpen] = React$1.useState(false);
|
|
9245
9255
|
const [loading, setLoading] = React$1.useState(false);
|
|
9246
9256
|
const [searchString, setSearchString] = React$1.useState('');
|
|
9247
|
-
const DEFAULT_PLACEHOLDER = '
|
|
9257
|
+
const DEFAULT_PLACEHOLDER = 'Digite para buscar...';
|
|
9248
9258
|
React$1.useEffect(() => {
|
|
9249
9259
|
setLoading(false);
|
|
9250
9260
|
}, [options]);
|
|
@@ -9313,7 +9323,7 @@ const FormCombobox = ({ control, variant = 'outline', name, label, subLabel, hel
|
|
|
9313
9323
|
return (jsxRuntime.jsx(FormField, { control: control, name: name, render: ({ field, formState }) => (jsxRuntime.jsxs(FormItem, { className: className, children: [jsxRuntime.jsxs("div", { className: 'flex items-center space-x-1.5', children: [label && formLabelAndSubLabel(FormLabel, label, subLabel, required), helpText && formHelpText(helpText)] }), jsxRuntime.jsxs(Popover, { open: open, onOpenChange: (open) => {
|
|
9314
9324
|
if (!disabled)
|
|
9315
9325
|
setOpen(open);
|
|
9316
|
-
}, children: [jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: jsxRuntime.jsx(FormControl, { children: jsxRuntime.jsx("div", { className: cn(`rounded-sm outline-none ${open ? 'ring-2 ring-ring ring-offset-2' : 'ring-0'}`, className), children: jsxRuntime.jsxs(Button, { type: 'button', variant: variant, role: 'combobox', "aria-expanded": open, className: cn('justify-between disabled:border-disabled disabled:cursor-not-allowed disabled:opacity-50', formState.errors[name] ? 'border-red-600' : '', className), disabled: disabled || formState.isSubmitting, children: [iconLeft, jsxRuntime.jsx("div", { className: 'grid flex-1 text-left text-sm leading-tight', children: jsxRuntime.jsx("span", { className: 'truncate font-normal', children: getSelectedOption(field.value) ? (jsxRuntime.jsxs("div", { className: 'flex gap-2', children: [getSelectedOption(field.value)?.icon, getSelectedOption(field.value)?.title] })) : (jsxRuntime.jsx("span", { className: 'text-zinc-500', children: placeholder ?? DEFAULT_PLACEHOLDER })) }) }), iconRight ?? jsxRuntime.jsx(lucideReact.ChevronsUpDown, { size: 20, className: 'stroke-zinc-500' })] }) }) }) }), jsxRuntime.jsxs(PopoverContent, { className: cn('p-0', className, 'w-[--radix-popover-trigger-width]'), children: [jsxRuntime.jsxs(Command, { shouldFilter: false, children: [!disabledSearch && jsxRuntime.jsx(CommandInput, { placeholder:
|
|
9326
|
+
}, children: [jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: jsxRuntime.jsx(FormControl, { children: jsxRuntime.jsx("div", { className: cn(`rounded-sm outline-none ${open ? 'ring-2 ring-ring ring-offset-2' : 'ring-0'}`, className), children: jsxRuntime.jsxs(Button, { type: 'button', variant: variant, role: 'combobox', "aria-expanded": open, className: cn('justify-between disabled:border-disabled disabled:cursor-not-allowed disabled:opacity-50', formState.errors[name] ? 'border-red-600' : '', className), disabled: disabled || formState.isSubmitting, children: [iconLeft, jsxRuntime.jsx("div", { className: 'grid flex-1 text-left text-sm leading-tight', children: jsxRuntime.jsx("span", { className: 'truncate font-normal', children: getSelectedOption(field.value) ? (jsxRuntime.jsxs("div", { className: 'flex gap-2', children: [getSelectedOption(field.value)?.icon, getSelectedOption(field.value)?.title] })) : (jsxRuntime.jsx("span", { className: 'text-zinc-500', children: placeholder ?? (disabledSearch ? 'Selecione' : DEFAULT_PLACEHOLDER) })) }) }), iconRight ?? jsxRuntime.jsx(lucideReact.ChevronsUpDown, { size: 20, className: 'stroke-zinc-500' })] }) }) }) }), jsxRuntime.jsxs(PopoverContent, { className: cn('p-0', className, 'w-[--radix-popover-trigger-width]'), children: [jsxRuntime.jsxs(Command, { shouldFilter: false, children: [!disabledSearch && jsxRuntime.jsx(CommandInput, { placeholder: placeholderSearch ?? DEFAULT_PLACEHOLDER, onKeyUp: handleKeyUp }), jsxRuntime.jsxs(CommandList, { children: [jsxRuntime.jsx(CommandEmpty, { className: 'flex flex-col justify-between items-center p-3 font-normal text-sm', children: loading ? (jsxRuntime.jsx(lucideReact.LoaderCircle, { size: 16, className: 'text-muted-foreground animate-spin mr-2' })) : getOptions()?.length === 0 && (searchString !== '' || disabledSearch) ? ('Nenhum resultado encontrado') : ('...') }), options.length > 0 && (jsxRuntime.jsx(CommandGroup, { children: getOptions().map((option) => (jsxRuntime.jsxs(CommandItem, { value: option.value, className: 'group', onSelect: () => handleSelect(option.value, field), children: [jsxRuntime.jsxs("div", { className: cn('grid flex-1 text-left text-sm leading-tight', option.className), children: [jsxRuntime.jsxs("div", { className: 'flex gap-2', children: [option.icon, jsxRuntime.jsx("span", { className: 'truncate font-normal', children: option.title })] }), jsxRuntime.jsx("span", { className: 'truncate text-xs text-zinc-500', children: option.subTitle })] }), jsxRuntime.jsxs("div", { className: `ml-auto text-zinc-500 ${field.value === option.value ? 'opacity-100' : 'opacity-0'}`, children: [jsxRuntime.jsx(lucideReact.Check, { className: cn('flex', canUnselect && 'group-hover:hidden hover:hidden'), size: 16 }), jsxRuntime.jsx(lucideReact.X, { className: cn('hidden', canUnselect && 'group-hover:flex hover:flex'), size: 16 })] })] }, `key-opt-${option.value}`))) }))] })] }), footerAction && (jsxRuntime.jsx("div", { className: 'grid w-full p-1 border-t', children: jsxRuntime.jsxs(Button, { type: 'button', variant: 'ghost', className: 'h-8', onClick: () => footerAction.onClick(), children: [footerAction.icon, footerAction.label] }) }))] })] }), formMessage(FormMessage)] })) }));
|
|
9317
9327
|
};
|
|
9318
9328
|
|
|
9319
9329
|
const masks$1 = ['999.999.999-999', '99.999.999/9999-99'];
|