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 CHANGED
@@ -80,7 +80,7 @@ declare const AvatarImage: React$1.ForwardRefExoticComponent<Omit<AvatarPrimitiv
80
80
  declare const AvatarFallback: React$1.ForwardRefExoticComponent<Omit<AvatarPrimitive.AvatarFallbackProps & React$1.RefAttributes<HTMLSpanElement>, "ref"> & React$1.RefAttributes<HTMLSpanElement>>;
81
81
 
82
82
  declare const badgeVariants: (props?: ({
83
- variant?: "default" | "outline" | "destructive" | "secondary" | "surface" | "green" | "red" | "gray" | "blue" | "orange" | null | undefined;
83
+ variant?: "default" | "secondary" | "surface" | "destructive" | "outline" | "green" | "red" | "gray" | "blue" | "orange" | null | undefined;
84
84
  } & class_variance_authority_dist_types.ClassProp) | undefined) => string;
85
85
  interface BadgeProps extends React$1.HTMLAttributes<HTMLDivElement>, VariantProps<typeof badgeVariants> {
86
86
  }
@@ -105,7 +105,7 @@ declare const BreadcrumbEllipsis: {
105
105
  };
106
106
 
107
107
  declare const buttonVariants: (props?: ({
108
- variant?: "link" | "default" | "outline" | "destructive" | "secondary" | "ghost" | null | undefined;
108
+ variant?: "default" | "secondary" | "destructive" | "outline" | "link" | "ghost" | null | undefined;
109
109
  size?: "default" | "sm" | "lg" | "icon" | null | undefined;
110
110
  } & class_variance_authority_dist_types.ClassProp) | undefined) => string;
111
111
  interface ButtonProps extends React$1.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
@@ -208,7 +208,7 @@ declare const Command: React$1.ForwardRefExoticComponent<Omit<{
208
208
  ref?: React$1.Ref<HTMLDivElement>;
209
209
  } & {
210
210
  asChild?: boolean;
211
- }, "key" | "asChild" | keyof React$1.HTMLAttributes<HTMLDivElement>> & {
211
+ }, "key" | keyof React$1.HTMLAttributes<HTMLDivElement> | "asChild"> & {
212
212
  label?: string;
213
213
  shouldFilter?: boolean;
214
214
  filter?: (value: string, search: string, keywords?: string[]) => number;
@@ -224,7 +224,7 @@ declare const CommandInput: React$1.ForwardRefExoticComponent<Omit<Omit<Pick<Pic
224
224
  ref?: React$1.Ref<HTMLInputElement>;
225
225
  } & {
226
226
  asChild?: boolean;
227
- }, "key" | "asChild" | keyof React$1.InputHTMLAttributes<HTMLInputElement>>, "type" | "value" | "onChange"> & {
227
+ }, "key" | "asChild" | keyof React$1.InputHTMLAttributes<HTMLInputElement>>, "onChange" | "value" | "type"> & {
228
228
  value?: string;
229
229
  onValueChange?: (search: string) => void;
230
230
  } & React$1.RefAttributes<HTMLInputElement>, "ref"> & React$1.RefAttributes<HTMLInputElement>>;
@@ -234,7 +234,7 @@ declare const CommandList: React$1.ForwardRefExoticComponent<Omit<{
234
234
  ref?: React$1.Ref<HTMLDivElement>;
235
235
  } & {
236
236
  asChild?: boolean;
237
- }, "key" | "asChild" | keyof React$1.HTMLAttributes<HTMLDivElement>> & {
237
+ }, "key" | keyof React$1.HTMLAttributes<HTMLDivElement> | "asChild"> & {
238
238
  label?: string;
239
239
  } & React$1.RefAttributes<HTMLDivElement>, "ref"> & React$1.RefAttributes<HTMLDivElement>>;
240
240
  declare const CommandEmpty: React$1.ForwardRefExoticComponent<Omit<{
@@ -243,14 +243,14 @@ declare const CommandEmpty: React$1.ForwardRefExoticComponent<Omit<{
243
243
  ref?: React$1.Ref<HTMLDivElement>;
244
244
  } & {
245
245
  asChild?: boolean;
246
- }, "key" | "asChild" | keyof React$1.HTMLAttributes<HTMLDivElement>> & React$1.RefAttributes<HTMLDivElement>, "ref"> & React$1.RefAttributes<HTMLDivElement>>;
246
+ }, "key" | keyof React$1.HTMLAttributes<HTMLDivElement> | "asChild"> & React$1.RefAttributes<HTMLDivElement>, "ref"> & React$1.RefAttributes<HTMLDivElement>>;
247
247
  declare const CommandGroup: React$1.ForwardRefExoticComponent<Omit<{
248
248
  children?: React$1.ReactNode;
249
249
  } & Omit<Pick<Pick<React$1.DetailedHTMLProps<React$1.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React$1.HTMLAttributes<HTMLDivElement>> & {
250
250
  ref?: React$1.Ref<HTMLDivElement>;
251
251
  } & {
252
252
  asChild?: boolean;
253
- }, "key" | "asChild" | keyof React$1.HTMLAttributes<HTMLDivElement>>, "value" | "heading"> & {
253
+ }, "key" | keyof React$1.HTMLAttributes<HTMLDivElement> | "asChild">, "value" | "heading"> & {
254
254
  heading?: React$1.ReactNode;
255
255
  value?: string;
256
256
  forceMount?: boolean;
@@ -259,7 +259,7 @@ declare const CommandSeparator: React$1.ForwardRefExoticComponent<Omit<Pick<Pick
259
259
  ref?: React$1.Ref<HTMLDivElement>;
260
260
  } & {
261
261
  asChild?: boolean;
262
- }, "key" | "asChild" | keyof React$1.HTMLAttributes<HTMLDivElement>> & {
262
+ }, "key" | keyof React$1.HTMLAttributes<HTMLDivElement> | "asChild"> & {
263
263
  alwaysRender?: boolean;
264
264
  } & React$1.RefAttributes<HTMLDivElement>, "ref"> & React$1.RefAttributes<HTMLDivElement>>;
265
265
  declare const CommandItem: React$1.ForwardRefExoticComponent<Omit<{
@@ -268,7 +268,7 @@ declare const CommandItem: React$1.ForwardRefExoticComponent<Omit<{
268
268
  ref?: React$1.Ref<HTMLDivElement>;
269
269
  } & {
270
270
  asChild?: boolean;
271
- }, "key" | "asChild" | keyof React$1.HTMLAttributes<HTMLDivElement>>, "disabled" | "value" | "onSelect"> & {
271
+ }, "key" | keyof React$1.HTMLAttributes<HTMLDivElement> | "asChild">, "onSelect" | "disabled" | "value"> & {
272
272
  disabled?: boolean;
273
273
  onSelect?: (value: string) => void;
274
274
  value?: string;
@@ -881,7 +881,7 @@ interface Props$8 {
881
881
  declare const FormInputMask: React.FC<Props$8>;
882
882
 
883
883
  declare const multiSelectVariants: (props?: ({
884
- variant?: "default" | "destructive" | "secondary" | "inverted" | null | undefined;
884
+ variant?: "default" | "secondary" | "destructive" | "inverted" | null | undefined;
885
885
  } & class_variance_authority_dist_types.ClassProp) | undefined) => string;
886
886
  interface MultiSelectOption {
887
887
  value: string;
@@ -1341,16 +1341,18 @@ declare const isDateRangeValid: (startDate: Date, endDate: Date, maxDays?: numbe
1341
1341
  * Automatically detects landline vs mobile format.
1342
1342
  *
1343
1343
  * @param telefone - Raw phone number string
1344
- * @param removerCountryCode - Whether to remove country code (55) if present
1344
+ * @param removeDDD - Whether to remove DDD (area code) from the formatted output
1345
+ * @param removeCountryCode - Whether to remove country code (55) if present
1345
1346
  * @returns Formatted phone number string
1346
1347
  *
1347
1348
  * @example
1348
1349
  * ```tsx
1349
1350
  * formatPhone('11987654321') // '(11) 9 8765-4321'
1350
1351
  * formatPhone('1134567890') // '(11) 3456-7890'
1352
+ * formatPhone('11987654321', true) // '9 8765-4321'
1351
1353
  * ```
1352
1354
  */
1353
- declare function formatPhone(telefone: string, removerCountryCode?: boolean): string;
1355
+ declare function formatPhone(telefone: string, removeDDD?: boolean, removeCountryCode?: boolean): string;
1354
1356
  /**
1355
1357
  * Formats a CPF or CNPJ string with proper mask.
1356
1358
  * Automatically detects CPF vs CNPJ format based on length.
package/dist/index.esm.js CHANGED
@@ -751,23 +751,33 @@ const removeMaskNumber = (value) => {
751
751
  * Automatically detects landline vs mobile format.
752
752
  *
753
753
  * @param telefone - Raw phone number string
754
- * @param removerCountryCode - Whether to remove country code (55) if present
754
+ * @param removeDDD - Whether to remove DDD (area code) from the formatted output
755
+ * @param removeCountryCode - Whether to remove country code (55) if present
755
756
  * @returns Formatted phone number string
756
757
  *
757
758
  * @example
758
759
  * ```tsx
759
760
  * formatPhone('11987654321') // '(11) 9 8765-4321'
760
761
  * formatPhone('1134567890') // '(11) 3456-7890'
762
+ * formatPhone('11987654321', true) // '9 8765-4321'
761
763
  * ```
762
764
  */
763
- function formatPhone(telefone, removerCountryCode = true) {
765
+ function formatPhone(telefone, removeDDD = false, removeCountryCode = true) {
764
766
  if (!telefone)
765
767
  return '';
766
768
  let numberPhone = telefone.replace(/\D/g, '');
767
769
  // Remover código do país apenas se ele começar com '55'
768
- if (removerCountryCode && numberPhone.startsWith('55')) {
770
+ if (removeCountryCode && numberPhone.startsWith('55')) {
769
771
  numberPhone = numberPhone.substring(2);
770
772
  }
773
+ // Se removeDDD for true, remover os dois primeiros dígitos (DDD)
774
+ if (removeDDD && numberPhone.length >= 10) {
775
+ const phoneWithoutDDD = numberPhone.substring(2);
776
+ // Aplicar máscara sem DDD
777
+ const isMobile = phoneWithoutDDD.length === 9;
778
+ const mask = isMobile ? { mask: '_ ____-____', replacement: { _: /\d/ } } : { mask: '____-_____', replacement: { _: /\d/ } };
779
+ return format$1(phoneWithoutDDD, mask);
780
+ }
771
781
  return format$1(numberPhone, maskPhone(numberPhone));
772
782
  }
773
783
  // CPF/CNPJ
@@ -9204,7 +9214,7 @@ const FormCombobox = ({ control, variant = 'outline', name, label, subLabel, hel
9204
9214
  const [open, setOpen] = useState(false);
9205
9215
  const [loading, setLoading] = useState(false);
9206
9216
  const [searchString, setSearchString] = useState('');
9207
- const DEFAULT_PLACEHOLDER = 'Selecione';
9217
+ const DEFAULT_PLACEHOLDER = 'Digite para buscar...';
9208
9218
  useEffect(() => {
9209
9219
  setLoading(false);
9210
9220
  }, [options]);
@@ -9273,7 +9283,7 @@ const FormCombobox = ({ control, variant = 'outline', name, label, subLabel, hel
9273
9283
  return (jsx(FormField, { control: control, name: name, render: ({ field, formState }) => (jsxs(FormItem, { className: className, children: [jsxs("div", { className: 'flex items-center space-x-1.5', children: [label && formLabelAndSubLabel(FormLabel, label, subLabel, required), helpText && formHelpText(helpText)] }), jsxs(Popover, { open: open, onOpenChange: (open) => {
9274
9284
  if (!disabled)
9275
9285
  setOpen(open);
9276
- }, children: [jsx(PopoverTrigger, { asChild: true, children: jsx(FormControl, { children: jsx("div", { className: cn(`rounded-sm outline-none ${open ? 'ring-2 ring-ring ring-offset-2' : 'ring-0'}`, className), children: 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, jsx("div", { className: 'grid flex-1 text-left text-sm leading-tight', children: jsx("span", { className: 'truncate font-normal', children: getSelectedOption(field.value) ? (jsxs("div", { className: 'flex gap-2', children: [getSelectedOption(field.value)?.icon, getSelectedOption(field.value)?.title] })) : (jsx("span", { className: 'text-zinc-500', children: placeholder ?? DEFAULT_PLACEHOLDER })) }) }), iconRight ?? jsx(ChevronsUpDown, { size: 20, className: 'stroke-zinc-500' })] }) }) }) }), jsxs(PopoverContent, { className: cn('p-0', className, 'w-[--radix-popover-trigger-width]'), children: [jsxs(Command, { shouldFilter: false, children: [!disabledSearch && jsx(CommandInput, { placeholder: placeholder ?? DEFAULT_PLACEHOLDER, onKeyUp: handleKeyUp }), jsxs(CommandList, { children: [jsx(CommandEmpty, { className: 'flex flex-col justify-between items-center p-3 font-normal text-sm', children: loading ? (jsx(LoaderCircle, { size: 16, className: 'text-muted-foreground animate-spin mr-2' })) : getOptions()?.length === 0 && (searchString !== '' || disabledSearch) ? ('Nenhum resultado encontrado') : ((placeholderSearch ?? 'Utilize o campo de busca acima')) }), options.length > 0 && (jsx(CommandGroup, { children: getOptions().map((option) => (jsxs(CommandItem, { value: option.value, className: 'group', onSelect: () => handleSelect(option.value, field), children: [jsxs("div", { className: cn('grid flex-1 text-left text-sm leading-tight', option.className), children: [jsxs("div", { className: 'flex gap-2', children: [option.icon, jsx("span", { className: 'truncate font-normal', children: option.title })] }), jsx("span", { className: 'truncate text-xs text-zinc-500', children: option.subTitle })] }), jsxs("div", { className: `ml-auto text-zinc-500 ${field.value === option.value ? 'opacity-100' : 'opacity-0'}`, children: [jsx(Check, { className: cn('flex', canUnselect && 'group-hover:hidden hover:hidden'), size: 16 }), jsx(X, { className: cn('hidden', canUnselect && 'group-hover:flex hover:flex'), size: 16 })] })] }, `key-opt-${option.value}`))) }))] })] }), footerAction && (jsx("div", { className: 'grid w-full p-1 border-t', children: jsxs(Button, { type: 'button', variant: 'ghost', className: 'h-8', onClick: () => footerAction.onClick(), children: [footerAction.icon, footerAction.label] }) }))] })] }), formMessage(FormMessage)] })) }));
9286
+ }, children: [jsx(PopoverTrigger, { asChild: true, children: jsx(FormControl, { children: jsx("div", { className: cn(`rounded-sm outline-none ${open ? 'ring-2 ring-ring ring-offset-2' : 'ring-0'}`, className), children: 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, jsx("div", { className: 'grid flex-1 text-left text-sm leading-tight', children: jsx("span", { className: 'truncate font-normal', children: getSelectedOption(field.value) ? (jsxs("div", { className: 'flex gap-2', children: [getSelectedOption(field.value)?.icon, getSelectedOption(field.value)?.title] })) : (jsx("span", { className: 'text-zinc-500', children: placeholder ?? (disabledSearch ? 'Selecione' : DEFAULT_PLACEHOLDER) })) }) }), iconRight ?? jsx(ChevronsUpDown, { size: 20, className: 'stroke-zinc-500' })] }) }) }) }), jsxs(PopoverContent, { className: cn('p-0', className, 'w-[--radix-popover-trigger-width]'), children: [jsxs(Command, { shouldFilter: false, children: [!disabledSearch && jsx(CommandInput, { placeholder: placeholderSearch ?? DEFAULT_PLACEHOLDER, onKeyUp: handleKeyUp }), jsxs(CommandList, { children: [jsx(CommandEmpty, { className: 'flex flex-col justify-between items-center p-3 font-normal text-sm', children: loading ? (jsx(LoaderCircle, { size: 16, className: 'text-muted-foreground animate-spin mr-2' })) : getOptions()?.length === 0 && (searchString !== '' || disabledSearch) ? ('Nenhum resultado encontrado') : ('...') }), options.length > 0 && (jsx(CommandGroup, { children: getOptions().map((option) => (jsxs(CommandItem, { value: option.value, className: 'group', onSelect: () => handleSelect(option.value, field), children: [jsxs("div", { className: cn('grid flex-1 text-left text-sm leading-tight', option.className), children: [jsxs("div", { className: 'flex gap-2', children: [option.icon, jsx("span", { className: 'truncate font-normal', children: option.title })] }), jsx("span", { className: 'truncate text-xs text-zinc-500', children: option.subTitle })] }), jsxs("div", { className: `ml-auto text-zinc-500 ${field.value === option.value ? 'opacity-100' : 'opacity-0'}`, children: [jsx(Check, { className: cn('flex', canUnselect && 'group-hover:hidden hover:hidden'), size: 16 }), jsx(X, { className: cn('hidden', canUnselect && 'group-hover:flex hover:flex'), size: 16 })] })] }, `key-opt-${option.value}`))) }))] })] }), footerAction && (jsx("div", { className: 'grid w-full p-1 border-t', children: jsxs(Button, { type: 'button', variant: 'ghost', className: 'h-8', onClick: () => footerAction.onClick(), children: [footerAction.icon, footerAction.label] }) }))] })] }), formMessage(FormMessage)] })) }));
9277
9287
  };
9278
9288
 
9279
9289
  const masks$1 = ['999.999.999-999', '99.999.999/9999-99'];