@fast-food/design-system 1.31.0 → 1.33.0
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/components/atoms/Input/Input.type.d.ts +5 -1
- package/dist/components/atoms/index.d.ts +1 -0
- package/dist/components/molecules/ComboboxSelect/ComboboxSelect.d.ts +6 -0
- package/dist/components/molecules/ComboboxSelect/ComboboxSelect.type.d.ts +58 -0
- package/dist/components/molecules/ComboboxSelect/index.d.ts +2 -0
- package/dist/components/molecules/DateRangePicker/DateRangePicker.d.ts +4 -0
- package/dist/components/molecules/DateRangePicker/DateRangePicker.type.d.ts +18 -0
- package/dist/components/molecules/DateRangePicker/index.d.ts +2 -0
- package/dist/components/molecules/Form/Form.d.ts +37 -0
- package/dist/components/molecules/Form/index.d.ts +1 -0
- package/dist/components/molecules/FormField/index.d.ts +2 -2
- package/dist/components/molecules/FormFields/BooleanField/BooleanField.d.ts +3 -0
- package/dist/components/molecules/FormFields/BooleanField/index.d.ts +1 -0
- package/dist/components/molecules/FormFields/ComboboxField/ComboboxField.d.ts +8 -0
- package/dist/components/molecules/FormFields/ComboboxField/index.d.ts +2 -0
- package/dist/components/molecules/FormFields/CurrencyField/CurrencyField.d.ts +8 -3
- package/dist/components/molecules/FormFields/DurationField/DurationField.d.ts +6 -0
- package/dist/components/molecules/FormFields/DurationField/index.d.ts +1 -0
- package/dist/components/molecules/FormFields/EmailField/EmailField.d.ts +1 -3
- package/dist/components/molecules/FormFields/MaskField/MaskField.d.ts +6 -3
- package/dist/components/molecules/FormFields/NumberField/NumberField.d.ts +8 -3
- package/dist/components/molecules/FormFields/PasswordField/PasswordField.d.ts +1 -3
- package/dist/components/molecules/FormFields/PercentageField/PercentageField.d.ts +8 -3
- package/dist/components/molecules/FormFields/TextAreaField/TextAreaField.d.ts +5 -3
- package/dist/components/molecules/FormFields/TextField/TextField.d.ts +6 -3
- package/dist/components/molecules/FormFields/TimeField/TimeField.d.ts +5 -0
- package/dist/components/molecules/FormFields/TimeField/index.d.ts +1 -0
- package/dist/components/molecules/FormFields/index.d.ts +4 -0
- package/dist/components/molecules/FormFields/shared/applyMask.d.ts +12 -2
- package/dist/components/molecules/FormFields/shared/emitFieldValue.d.ts +9 -0
- package/dist/components/molecules/FormFields/shared/formFieldTypes.d.ts +87 -15
- package/dist/components/molecules/FormFields/shared/maskFieldHelpers.d.ts +24 -0
- package/dist/components/molecules/FormFields/shared/mergeRefs.d.ts +7 -0
- package/dist/components/molecules/PopoverMultiSelect/PopoverMultiSelect.d.ts +6 -0
- package/dist/components/molecules/PopoverMultiSelect/PopoverMultiSelect.type.d.ts +43 -0
- package/dist/components/molecules/PopoverMultiSelect/index.d.ts +2 -0
- package/dist/components/molecules/index.d.ts +4 -0
- package/dist/fast-food-design-system-1.33.0.tgz +0 -0
- package/dist/fast-food-design-system.cjs.js +160 -160
- package/dist/fast-food-design-system.css +1 -1
- package/dist/fast-food-design-system.es.js +17084 -15307
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useDebouncedValue.d.ts +6 -0
- package/package.json +13 -3
- package/dist/fast-food-design-system-1.31.0.tgz +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InputHTMLAttributes } from 'react';
|
|
1
|
+
import { InputHTMLAttributes, ReactNode } from 'react';
|
|
2
2
|
export type InputVariant = 'default' | 'primary' | 'secondary' | 'error';
|
|
3
3
|
export type InputSize = 'xs' | 'sm' | 'md' | 'lg';
|
|
4
4
|
export interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'size'> {
|
|
@@ -9,4 +9,8 @@ export interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>,
|
|
|
9
9
|
success?: boolean;
|
|
10
10
|
/** Shows a skeleton placeholder instead of the input control. */
|
|
11
11
|
isLoading?: boolean;
|
|
12
|
+
/** Conteúdo fixo à esquerda do campo (ícone, "R$", etc.). */
|
|
13
|
+
startAdornment?: ReactNode;
|
|
14
|
+
/** Conteúdo fixo à direita do campo (ícone, "%", botão, etc.). */
|
|
15
|
+
endAdornment?: ReactNode;
|
|
12
16
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ComboboxSelectProps } from './ComboboxSelect.type';
|
|
2
|
+
declare function ComboboxSelect<TData, TParams = void>({ id, label, value, onChange, loadOptions, loadPage, loadParams, getValue, getLabel, getDescription, selectedItem: selectedItemProp, placeholder, searchPlaceholder, loadingText, noOptionsText, loadErrorText, helperText, errorText, error, disabled, readOnly, clearable, onClear, className, containerClassName, reloadOnParamsChange, searchDebounce, }: ComboboxSelectProps<TData, TParams>): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
declare namespace ComboboxSelect {
|
|
4
|
+
var displayName: string;
|
|
5
|
+
}
|
|
6
|
+
export default ComboboxSelect;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/** Argumentos passados ao carregador paginado (busca no servidor + scroll infinito). */
|
|
2
|
+
export interface LoadPageArgs<TParams = void> {
|
|
3
|
+
/** Texto de busca atual (já com debounce aplicado). */
|
|
4
|
+
search: string;
|
|
5
|
+
/** Página solicitada (base 0). A primeira carga e toda nova busca usam página 0. */
|
|
6
|
+
page: number;
|
|
7
|
+
/** Parâmetros extras fornecidos via `loadParams`. */
|
|
8
|
+
params?: TParams;
|
|
9
|
+
}
|
|
10
|
+
/** Resultado de uma página: itens daquela página + se há mais para carregar. */
|
|
11
|
+
export interface LoadPageResult<TData> {
|
|
12
|
+
data: TData[];
|
|
13
|
+
hasMore: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface ComboboxSelectProps<TData, TParams = void> {
|
|
16
|
+
id?: string;
|
|
17
|
+
label?: string;
|
|
18
|
+
value?: string | null;
|
|
19
|
+
onChange?: (value: string | null, item: TData | null) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Carregador simples: busca todas as opções de uma vez. A busca é feita no
|
|
22
|
+
* cliente. Use quando a lista é pequena. Obrigatório se `loadPage` não for usado.
|
|
23
|
+
*/
|
|
24
|
+
loadOptions?: (params?: TParams) => Promise<TData[]>;
|
|
25
|
+
/**
|
|
26
|
+
* Carregador paginado com busca no servidor + scroll infinito. Quando fornecido,
|
|
27
|
+
* tem prioridade sobre `loadOptions`: a busca é debounced e enviada ao servidor,
|
|
28
|
+
* e novas páginas são carregadas ao rolar até o fim da lista.
|
|
29
|
+
*/
|
|
30
|
+
loadPage?: (args: LoadPageArgs<TParams>) => Promise<LoadPageResult<TData>>;
|
|
31
|
+
loadParams?: TParams;
|
|
32
|
+
getValue: (item: TData) => string;
|
|
33
|
+
getLabel: (item: TData) => string;
|
|
34
|
+
getDescription?: (item: TData) => string | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Item já resolvido correspondente a `value`. Use no modo paginado para
|
|
37
|
+
* exibir o rótulo de um valor pré-selecionado (edição) que pode não estar
|
|
38
|
+
* na primeira página carregada.
|
|
39
|
+
*/
|
|
40
|
+
selectedItem?: TData | null;
|
|
41
|
+
placeholder?: string;
|
|
42
|
+
searchPlaceholder?: string;
|
|
43
|
+
loadingText?: string;
|
|
44
|
+
noOptionsText?: string;
|
|
45
|
+
loadErrorText?: string;
|
|
46
|
+
helperText?: string;
|
|
47
|
+
errorText?: string;
|
|
48
|
+
error?: boolean;
|
|
49
|
+
disabled?: boolean;
|
|
50
|
+
readOnly?: boolean;
|
|
51
|
+
clearable?: boolean;
|
|
52
|
+
onClear?: () => void;
|
|
53
|
+
className?: string;
|
|
54
|
+
containerClassName?: string;
|
|
55
|
+
reloadOnParamsChange?: boolean;
|
|
56
|
+
/** Debounce (ms) da busca no servidor quando `loadPage` é usado. Padrão: 300. */
|
|
57
|
+
searchDebounce?: number;
|
|
58
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DateRange } from 'react-day-picker';
|
|
2
|
+
export type { DateRange };
|
|
3
|
+
export interface DateRangePreset {
|
|
4
|
+
label: string;
|
|
5
|
+
range: () => DateRange;
|
|
6
|
+
}
|
|
7
|
+
export interface DateRangePickerProps {
|
|
8
|
+
value?: DateRange;
|
|
9
|
+
onChange?: (range: DateRange | undefined) => void;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
className?: string;
|
|
13
|
+
/** Exibe botões de atalho (Hoje, Últimos 7 dias…). Padrão: true */
|
|
14
|
+
showPresets?: boolean;
|
|
15
|
+
/** Substitui os presets padrão por uma lista customizada */
|
|
16
|
+
presets?: DateRangePreset[];
|
|
17
|
+
'aria-invalid'?: boolean;
|
|
18
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { FormProvider, ControllerProps, FieldPath, FieldValues } from 'react-hook-form';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
declare const FormField: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ ...props }: ControllerProps<TFieldValues, TName>) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
declare function useFormField(): {
|
|
5
|
+
invalid: boolean;
|
|
6
|
+
isDirty: boolean;
|
|
7
|
+
isTouched: boolean;
|
|
8
|
+
isValidating: boolean;
|
|
9
|
+
error?: import('react-hook-form').FieldError;
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
formItemId: string;
|
|
13
|
+
formDescriptionId: string;
|
|
14
|
+
formMessageId: string;
|
|
15
|
+
};
|
|
16
|
+
declare const FormItem: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
17
|
+
declare const FormLabel: React.ForwardRefExoticComponent<Omit<React.LabelHTMLAttributes<HTMLLabelElement> & import('../../atoms/Label/Label.style').LabelStyleProps & {
|
|
18
|
+
as?: "label" | "p" | "span";
|
|
19
|
+
} & React.RefAttributes<HTMLLabelElement | HTMLParagraphElement | HTMLSpanElement>, "ref"> & React.RefAttributes<HTMLLabelElement>>;
|
|
20
|
+
declare const FormControl: React.ForwardRefExoticComponent<Omit<import('@radix-ui/react-slot').SlotProps & React.RefAttributes<HTMLElement>, "ref"> & React.RefAttributes<HTMLElement>>;
|
|
21
|
+
declare const FormDescription: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLParagraphElement> & React.RefAttributes<HTMLParagraphElement>>;
|
|
22
|
+
declare const FormMessage: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLParagraphElement> & React.RefAttributes<HTMLParagraphElement>>;
|
|
23
|
+
/**
|
|
24
|
+
* `Form` equivale ao `FormProvider` do react-hook-form e também agrupa as
|
|
25
|
+
* primitivas como propriedades: `<Form.Field>`, `<Form.Item>`, `<Form.Label>`,
|
|
26
|
+
* `<Form.Control>`, `<Form.Description>`, `<Form.Message>`.
|
|
27
|
+
*/
|
|
28
|
+
type FormComponent = typeof FormProvider & {
|
|
29
|
+
Field: typeof FormField;
|
|
30
|
+
Item: typeof FormItem;
|
|
31
|
+
Label: typeof FormLabel;
|
|
32
|
+
Control: typeof FormControl;
|
|
33
|
+
Description: typeof FormDescription;
|
|
34
|
+
Message: typeof FormMessage;
|
|
35
|
+
};
|
|
36
|
+
declare const Form: FormComponent;
|
|
37
|
+
export { Form, FormItem, FormLabel, FormControl, FormDescription, FormMessage, FormField, useFormField, };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Form, FormItem, FormLabel, FormControl, FormDescription, FormMessage, useFormField, } from './Form';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default as FormField } from './FormField';
|
|
2
|
-
export type { FormFieldProps } from './FormField.type';
|
|
1
|
+
export { default as FormField, default as InputField } from './FormField';
|
|
2
|
+
export type { FormFieldProps, FormFieldProps as InputFieldProps } from './FormField.type';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { BooleanField } from './BooleanField';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ComboboxSelectProps } from '../../ComboboxSelect/ComboboxSelect.type';
|
|
2
|
+
import { BaseFieldProps } from '../shared/formFieldTypes';
|
|
3
|
+
export type ComboboxFieldProps<TData, TParams = void> = Omit<ComboboxSelectProps<TData, TParams>, 'label' | 'helperText' | 'errorText' | 'containerClassName'> & BaseFieldProps;
|
|
4
|
+
declare function ComboboxField<TData, TParams = void>({ label, helperText, errorText, containerClassName, id, ...props }: ComboboxFieldProps<TData, TParams>): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
declare namespace ComboboxField {
|
|
6
|
+
var displayName: string;
|
|
7
|
+
}
|
|
8
|
+
export default ComboboxField;
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export declare const CurrencyField: import('react').ForwardRefExoticComponent<Omit<import('react').InputHTMLAttributes<HTMLInputElement>, "type" | "onChange" | "defaultValue" | "value"> & import('..').BaseFieldProps & {
|
|
2
|
+
value?: number | null;
|
|
3
|
+
defaultValue?: number;
|
|
4
|
+
onValueChange?: (value: number | null) => void;
|
|
5
|
+
onChange?: (value: number | null) => void;
|
|
6
|
+
locale?: string;
|
|
7
|
+
currency?: string;
|
|
8
|
+
} & import('react').RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const DurationField: import('react').ForwardRefExoticComponent<Omit<import('react').InputHTMLAttributes<HTMLInputElement>, "type" | "onChange" | "defaultValue" | "value"> & import('..').BaseFieldProps & {
|
|
2
|
+
value?: number | null;
|
|
3
|
+
onValueChange?: (value: number | null) => void;
|
|
4
|
+
onChange?: (value: number | null) => void;
|
|
5
|
+
lengthHoursMask?: number;
|
|
6
|
+
} & import('react').RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DurationField } from './DurationField';
|
|
@@ -1,3 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { EmailFieldProps } from '../shared/formFieldTypes';
|
|
3
|
-
export declare const EmailField: React.FC<EmailFieldProps>;
|
|
1
|
+
export declare const EmailField: import('react').ForwardRefExoticComponent<import('react').InputHTMLAttributes<HTMLInputElement> & import('..').BaseFieldProps & import('react').RefAttributes<HTMLInputElement>>;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export declare const MaskField: import('react').ForwardRefExoticComponent<Omit<import('react').InputHTMLAttributes<HTMLInputElement>, "type" | "onChange"> & import('..').BaseFieldProps & {
|
|
2
|
+
mask: string | string[];
|
|
3
|
+
onValueChange?: (value: string) => void;
|
|
4
|
+
onChange?: (value: string) => void;
|
|
5
|
+
onComplete?: (value: string) => void;
|
|
6
|
+
} & import('react').RefAttributes<HTMLInputElement>>;
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export declare const NumberField: import('react').ForwardRefExoticComponent<Omit<import('react').InputHTMLAttributes<HTMLInputElement>, "type" | "onChange" | "value"> & import('..').BaseFieldProps & {
|
|
2
|
+
value?: number | null;
|
|
3
|
+
onValueChange?: (value: number | null) => void;
|
|
4
|
+
onChange?: (value: number | null) => void;
|
|
5
|
+
min?: number;
|
|
6
|
+
max?: number;
|
|
7
|
+
allowDecimal?: boolean;
|
|
8
|
+
} & import('react').RefAttributes<HTMLInputElement>>;
|
|
@@ -1,3 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { PasswordFieldProps } from '../shared/formFieldTypes';
|
|
3
|
-
export declare const PasswordField: React.FC<PasswordFieldProps>;
|
|
1
|
+
export declare const PasswordField: import('react').ForwardRefExoticComponent<import('react').InputHTMLAttributes<HTMLInputElement> & import('..').BaseFieldProps & import('react').RefAttributes<HTMLInputElement>>;
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export declare const PercentageField: import('react').ForwardRefExoticComponent<Omit<import('react').InputHTMLAttributes<HTMLInputElement>, "type" | "onChange" | "defaultValue" | "value"> & import('..').BaseFieldProps & {
|
|
2
|
+
value?: number | null;
|
|
3
|
+
defaultValue?: number;
|
|
4
|
+
onValueChange?: (value: number | null) => void;
|
|
5
|
+
onChange?: (value: number | null) => void;
|
|
6
|
+
min?: number;
|
|
7
|
+
max?: number;
|
|
8
|
+
} & import('react').RefAttributes<HTMLInputElement>>;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export declare const TextAreaField: import('react').ForwardRefExoticComponent<import('react').TextareaHTMLAttributes<HTMLTextAreaElement> & import('..').BaseFieldProps & {
|
|
2
|
+
error?: boolean;
|
|
3
|
+
characterCount?: boolean;
|
|
4
|
+
characterLimit?: number;
|
|
5
|
+
} & import('react').RefAttributes<HTMLTextAreaElement>>;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Campo de texto rotulado. Encaminha o `ref` para o `<input>` interno — assim
|
|
3
|
+
* `<TextField {...register('campo')} />` (react-hook-form, não-controlado) e o
|
|
4
|
+
* `field.ref` do `Controller` (foco automático no erro) funcionam diretamente.
|
|
5
|
+
*/
|
|
6
|
+
export declare const TextField: import('react').ForwardRefExoticComponent<import('react').InputHTMLAttributes<HTMLInputElement> & import('..').BaseFieldProps & import('react').RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const TimeField: import('react').ForwardRefExoticComponent<Omit<import('react').InputHTMLAttributes<HTMLInputElement>, "type" | "onChange" | "defaultValue" | "value"> & import('..').BaseFieldProps & {
|
|
2
|
+
value?: string;
|
|
3
|
+
onValueChange?: (value: string) => void;
|
|
4
|
+
onChange?: (value: string) => void;
|
|
5
|
+
} & import('react').RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TimeField } from './TimeField';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from './ComboboxField';
|
|
1
2
|
export * from './TextField';
|
|
2
3
|
export * from './EmailField';
|
|
3
4
|
export * from './PasswordField';
|
|
@@ -9,4 +10,7 @@ export * from './TextAreaField';
|
|
|
9
10
|
export * from './DateField';
|
|
10
11
|
export * from './DateTimeField';
|
|
11
12
|
export * from './DateRangeField';
|
|
13
|
+
export * from './TimeField';
|
|
14
|
+
export * from './DurationField';
|
|
15
|
+
export * from './BooleanField';
|
|
12
16
|
export type * from './shared/formFieldTypes';
|
|
@@ -1,2 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
export declare function
|
|
1
|
+
/** Conta quantos dígitos-curinga (`#`) a máscara possui. */
|
|
2
|
+
export declare function countMaskSlots(mask: string): number;
|
|
3
|
+
/**
|
|
4
|
+
* Escolhe a máscara mais adequada à quantidade de dígitos informada.
|
|
5
|
+
* Entre as máscaras ordenadas por capacidade, retorna a primeira cujo número de
|
|
6
|
+
* slots `#` comporta os dígitos; se nenhuma comporta, retorna a de maior capacidade.
|
|
7
|
+
*/
|
|
8
|
+
export declare function pickMask(mask: string | string[], digitCount: number): string;
|
|
9
|
+
/** Máscara com `#` = um dígito; demais caracteres são literais. Aceita array de máscaras. */
|
|
10
|
+
export declare function applyMask(rawValue: string, mask: string | string[]): string;
|
|
11
|
+
/** Verifica se os dígitos preencheram completamente a máscara escolhida. */
|
|
12
|
+
export declare function isMaskComplete(rawValue: string, mask: string | string[]): boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dispara o valor tratado de um campo tanto para `onChange` (assinatura
|
|
3
|
+
* RHF-native `(value) => void`, compatível com `{...field}` do `Controller`)
|
|
4
|
+
* quanto para o alias `onValueChange`. Ambos recebem exatamente o mesmo valor.
|
|
5
|
+
*/
|
|
6
|
+
export declare function emitFieldValue<T>(value: T, handlers: {
|
|
7
|
+
onChange?: (value: T) => void;
|
|
8
|
+
onValueChange?: (value: T) => void;
|
|
9
|
+
}): void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InputHTMLAttributes, ReactNode, TextareaHTMLAttributes } from 'react';
|
|
2
|
+
import { DateRange } from 'react-day-picker';
|
|
2
3
|
import { DatePickerCalendarProps } from '../../DatePicker/DatePicker.type';
|
|
3
4
|
export type BaseFieldProps = {
|
|
4
5
|
label?: ReactNode;
|
|
@@ -6,38 +7,71 @@ export type BaseFieldProps = {
|
|
|
6
7
|
errorText?: ReactNode;
|
|
7
8
|
containerClassName?: string;
|
|
8
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* Convenção RHF-native: nos campos de valor abaixo, `onChange` recebe o **valor
|
|
12
|
+
* já tratado** (e não o evento do DOM), com a mesma assinatura do `field.onChange`
|
|
13
|
+
* do `Controller` do react-hook-form. Isso permite `<NumberField {...field} />`.
|
|
14
|
+
* `onValueChange` permanece como alias equivalente (ambos são disparados).
|
|
15
|
+
*/
|
|
9
16
|
export type TextFieldProps = InputHTMLAttributes<HTMLInputElement> & BaseFieldProps;
|
|
10
17
|
export type EmailFieldProps = InputHTMLAttributes<HTMLInputElement> & BaseFieldProps;
|
|
11
18
|
export type PasswordFieldProps = InputHTMLAttributes<HTMLInputElement> & BaseFieldProps;
|
|
12
|
-
export type NumberFieldProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'onChange'> & BaseFieldProps & {
|
|
19
|
+
export type NumberFieldProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'onChange' | 'value'> & BaseFieldProps & {
|
|
20
|
+
value?: number | null;
|
|
13
21
|
onValueChange?: (value: number | null) => void;
|
|
14
|
-
|
|
22
|
+
/** RHF-native: recebe o número tratado (ou `null`). Compatível com `{...field}`. */
|
|
23
|
+
onChange?: (value: number | null) => void;
|
|
24
|
+
/** Mínimo permitido — aplicado no onBlur */
|
|
25
|
+
min?: number;
|
|
26
|
+
/** Máximo permitido — aplicado no onBlur */
|
|
27
|
+
max?: number;
|
|
28
|
+
/** Permite decimais (ponto/vírgula). Padrão: false */
|
|
29
|
+
allowDecimal?: boolean;
|
|
15
30
|
};
|
|
16
31
|
export type CurrencyFieldProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'value' | 'defaultValue' | 'onChange'> & BaseFieldProps & {
|
|
17
|
-
value?: number;
|
|
32
|
+
value?: number | null;
|
|
18
33
|
defaultValue?: number;
|
|
19
34
|
onValueChange?: (value: number | null) => void;
|
|
35
|
+
/** RHF-native: recebe o número tratado (ou `null`). Compatível com `{...field}`. */
|
|
36
|
+
onChange?: (value: number | null) => void;
|
|
20
37
|
locale?: string;
|
|
21
38
|
currency?: string;
|
|
22
39
|
};
|
|
23
40
|
export type PercentageFieldProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'value' | 'defaultValue' | 'onChange'> & BaseFieldProps & {
|
|
24
|
-
value?: number;
|
|
41
|
+
value?: number | null;
|
|
25
42
|
defaultValue?: number;
|
|
26
43
|
onValueChange?: (value: number | null) => void;
|
|
44
|
+
/** RHF-native: recebe o número tratado (ou `null`). Compatível com `{...field}`. */
|
|
45
|
+
onChange?: (value: number | null) => void;
|
|
27
46
|
min?: number;
|
|
28
47
|
max?: number;
|
|
29
48
|
};
|
|
30
49
|
export type MaskFieldProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'onChange'> & BaseFieldProps & {
|
|
31
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Máscara com `#` = um dígito; demais caracteres são literais. Aceita um
|
|
52
|
+
* array de máscaras — a mais adequada ao número de dígitos digitados é
|
|
53
|
+
* escolhida automaticamente (ex.: `['###.###.###-##', '##.###.###/####-##']`
|
|
54
|
+
* para CPF/CNPJ).
|
|
55
|
+
*/
|
|
56
|
+
mask: string | string[];
|
|
32
57
|
onValueChange?: (value: string) => void;
|
|
33
|
-
|
|
58
|
+
/** RHF-native: recebe o valor mascarado. Compatível com `{...field}`. */
|
|
59
|
+
onChange?: (value: string) => void;
|
|
60
|
+
/** Disparado quando a máscara escolhida fica completamente preenchida. */
|
|
61
|
+
onComplete?: (value: string) => void;
|
|
34
62
|
};
|
|
35
63
|
export type TextAreaFieldProps = TextareaHTMLAttributes<HTMLTextAreaElement> & BaseFieldProps & {
|
|
36
64
|
error?: boolean;
|
|
65
|
+
/** Exibe contador de caracteres. Ativado automaticamente quando `characterLimit` é fornecido. */
|
|
66
|
+
characterCount?: boolean;
|
|
67
|
+
/** Limite máximo de caracteres — aplica `maxLength` e exibe contador. */
|
|
68
|
+
characterLimit?: number;
|
|
37
69
|
};
|
|
38
70
|
export type DateFieldProps = BaseFieldProps & DatePickerCalendarProps & {
|
|
39
71
|
value?: Date;
|
|
40
72
|
onValueChange?: (value: Date | undefined) => void;
|
|
73
|
+
/** RHF-native: recebe a data selecionada. Compatível com `{...field}`. */
|
|
74
|
+
onChange?: (value: Date | undefined) => void;
|
|
41
75
|
placeholder?: string;
|
|
42
76
|
disabled?: boolean;
|
|
43
77
|
id?: string;
|
|
@@ -46,20 +80,58 @@ export type DateFieldProps = BaseFieldProps & DatePickerCalendarProps & {
|
|
|
46
80
|
export type DateTimeFieldProps = BaseFieldProps & DatePickerCalendarProps & {
|
|
47
81
|
value?: Date;
|
|
48
82
|
onValueChange?: (value: Date | undefined) => void;
|
|
83
|
+
/** RHF-native: recebe a data/hora selecionada. Compatível com `{...field}`. */
|
|
84
|
+
onChange?: (value: Date | undefined) => void;
|
|
49
85
|
placeholder?: string;
|
|
50
86
|
disabled?: boolean;
|
|
51
87
|
id?: string;
|
|
52
88
|
readOnly?: boolean;
|
|
53
89
|
};
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
90
|
+
/** Alias de `DateRange` do react-day-picker para conveniência. */
|
|
91
|
+
export type DateRangeValue = DateRange;
|
|
92
|
+
export type DateRangeFieldProps = BaseFieldProps & {
|
|
93
|
+
value?: DateRange;
|
|
94
|
+
onValueChange?: (value: DateRange | undefined) => void;
|
|
95
|
+
/** RHF-native: recebe o intervalo selecionado. Compatível com `{...field}`. */
|
|
96
|
+
onChange?: (value: DateRange | undefined) => void;
|
|
97
|
+
disabled?: boolean;
|
|
98
|
+
readOnly?: boolean;
|
|
99
|
+
};
|
|
100
|
+
export type TimeFieldProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'value' | 'defaultValue' | 'onChange'> & BaseFieldProps & {
|
|
101
|
+
/** Valor no formato `HH:mm`. */
|
|
102
|
+
value?: string;
|
|
103
|
+
/** Disparado com o valor formatado `HH:mm` (normalizado e clamped no blur). */
|
|
104
|
+
onValueChange?: (value: string) => void;
|
|
105
|
+
/** RHF-native: recebe o valor `HH:mm`. Compatível com `{...field}`. */
|
|
106
|
+
onChange?: (value: string) => void;
|
|
107
|
+
};
|
|
108
|
+
export type DurationFieldProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'value' | 'defaultValue' | 'onChange'> & BaseFieldProps & {
|
|
109
|
+
/** Duração total em minutos. */
|
|
110
|
+
value?: number | null;
|
|
111
|
+
/** Disparado com a duração total em minutos (ou `null` quando vazio). */
|
|
112
|
+
onValueChange?: (value: number | null) => void;
|
|
113
|
+
/** RHF-native: recebe a duração em minutos (ou `null`). Compatível com `{...field}`. */
|
|
114
|
+
onChange?: (value: number | null) => void;
|
|
115
|
+
/** Número de dígitos reservados para as horas. Padrão: 3 (até 999h). */
|
|
116
|
+
lengthHoursMask?: number;
|
|
57
117
|
};
|
|
58
|
-
export type
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
118
|
+
export type BooleanFieldProps = BaseFieldProps & {
|
|
119
|
+
/** Valor booleano. `null`/`undefined` = nenhuma opção selecionada. */
|
|
120
|
+
value?: boolean | null;
|
|
121
|
+
onValueChange?: (value: boolean | null) => void;
|
|
122
|
+
/** RHF-native: recebe o booleano (ou `null`). Compatível com `{...field}`. */
|
|
123
|
+
onChange?: (value: boolean | null) => void;
|
|
124
|
+
/** Apresentação do campo. Padrão: `'select'`. */
|
|
125
|
+
variant?: 'select' | 'radio';
|
|
126
|
+
/** Rótulo da opção verdadeira. Padrão: `'Sim'`. */
|
|
127
|
+
trueLabel?: string;
|
|
128
|
+
/** Rótulo da opção falsa. Padrão: `'Não'`. */
|
|
129
|
+
falseLabel?: string;
|
|
130
|
+
/** Texto do placeholder (apenas variante `select`). Padrão: `'Selecione'`. */
|
|
131
|
+
placeholder?: string;
|
|
63
132
|
disabled?: boolean;
|
|
64
133
|
readOnly?: boolean;
|
|
134
|
+
required?: boolean;
|
|
135
|
+
name?: string;
|
|
136
|
+
id?: string;
|
|
65
137
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers compartilhados pelos campos com máscara numérica
|
|
3
|
+
* (`TimeField`, `DurationField`, `CurrencyField`). Centralizar essa lógica
|
|
4
|
+
* evita cópias divergentes de formatação/parsing entre os campos.
|
|
5
|
+
*/
|
|
6
|
+
/** Remove tudo que não é dígito de uma string (tolerante a `null`/`undefined`). */
|
|
7
|
+
export declare const onlyDigits: (raw: string | null | undefined) => string;
|
|
8
|
+
/** Formatação progressiva enquanto digita: `1230` -> `12:30`. */
|
|
9
|
+
export declare function formatTimeMask(raw: string): string;
|
|
10
|
+
/** Normaliza para `HH:mm` válido, com clamp de horas (0-23) e minutos (0-59). */
|
|
11
|
+
export declare function normalizeTime(raw: string): string;
|
|
12
|
+
/** Converte minutos totais para a string `HHhMMm` (horas com zero-padding). */
|
|
13
|
+
export declare function minutesToDisplay(value: number | null | undefined, lengthHoursMask: number): string;
|
|
14
|
+
/**
|
|
15
|
+
* Interpreta os dígitos digitados: os 2 últimos são minutos (clamp 0-59) e os
|
|
16
|
+
* demais são horas. Retorna o total de minutos (ou `null` quando vazio).
|
|
17
|
+
*/
|
|
18
|
+
export declare function digitsToMinutes(raw: string, lengthHoursMask: number): number | null;
|
|
19
|
+
/**
|
|
20
|
+
* Posição do cursor no texto formatado após `n` dígitos (preserva a posição
|
|
21
|
+
* lógica ao reformatar — ex.: máscara de moeda). Para `n <= 0` retorna o índice
|
|
22
|
+
* do primeiro dígito (ou o fim quando não há dígitos).
|
|
23
|
+
*/
|
|
24
|
+
export declare function caretPosForDigits(formatted: string, n: number): number;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Ref } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Combina vários refs (callback ou objeto) em um único callback ref. Útil quando
|
|
4
|
+
* um componente precisa manter um ref interno e, ao mesmo tempo, encaminhar o
|
|
5
|
+
* `ref` recebido (ex.: `field.ref` do react-hook-form).
|
|
6
|
+
*/
|
|
7
|
+
export declare function mergeRefs<T>(...refs: Array<Ref<T> | undefined>): (node: T | null) => void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { PopoverMultiSelectProps } from './PopoverMultiSelect.type';
|
|
2
|
+
declare function PopoverMultiSelect<TData, TParams = void>({ label, value, onChange, loadOptions, loadPage, loadParams, getValue, getLabel, getSubLabel, selectedItems: selectedItemsProp, placeholder, searchPlaceholder, emptyText, loadingText, loadErrorText, helperText, errorText, error, disabled, readOnly, clearable, previewLimit, className, containerClassName, searchDebounce, }: PopoverMultiSelectProps<TData, TParams>): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
declare namespace PopoverMultiSelect {
|
|
4
|
+
var displayName: string;
|
|
5
|
+
}
|
|
6
|
+
export default PopoverMultiSelect;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { LoadPageArgs, LoadPageResult } from '../ComboboxSelect/ComboboxSelect.type';
|
|
2
|
+
export type { LoadPageArgs, LoadPageResult };
|
|
3
|
+
export interface PopoverMultiSelectProps<TData, TParams = void> {
|
|
4
|
+
label?: string;
|
|
5
|
+
value: string[];
|
|
6
|
+
onChange: (values: string[]) => void;
|
|
7
|
+
/**
|
|
8
|
+
* Carregador simples: busca todas as opções de uma vez (filtro no cliente).
|
|
9
|
+
* Obrigatório se `loadPage` não for usado.
|
|
10
|
+
*/
|
|
11
|
+
loadOptions?: (params?: TParams) => Promise<TData[]>;
|
|
12
|
+
/**
|
|
13
|
+
* Carregador paginado com busca no servidor + scroll infinito. Quando fornecido,
|
|
14
|
+
* tem prioridade sobre `loadOptions`.
|
|
15
|
+
*/
|
|
16
|
+
loadPage?: (args: LoadPageArgs<TParams>) => Promise<LoadPageResult<TData>>;
|
|
17
|
+
loadParams?: TParams;
|
|
18
|
+
getValue: (item: TData) => string;
|
|
19
|
+
getLabel: (item: TData) => string;
|
|
20
|
+
getSubLabel?: (item: TData) => string | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Itens já resolvidos correspondentes a `value`. Use no modo paginado para
|
|
23
|
+
* exibir os chips de valores pré-selecionados (edição) que podem não estar
|
|
24
|
+
* nas páginas já carregadas.
|
|
25
|
+
*/
|
|
26
|
+
selectedItems?: TData[];
|
|
27
|
+
placeholder?: string;
|
|
28
|
+
searchPlaceholder?: string;
|
|
29
|
+
emptyText?: string;
|
|
30
|
+
loadingText?: string;
|
|
31
|
+
loadErrorText?: string;
|
|
32
|
+
helperText?: string;
|
|
33
|
+
errorText?: string;
|
|
34
|
+
error?: boolean;
|
|
35
|
+
disabled?: boolean;
|
|
36
|
+
readOnly?: boolean;
|
|
37
|
+
clearable?: boolean;
|
|
38
|
+
previewLimit?: number;
|
|
39
|
+
className?: string;
|
|
40
|
+
containerClassName?: string;
|
|
41
|
+
/** Debounce (ms) da busca no servidor quando `loadPage` é usado. Padrão: 300. */
|
|
42
|
+
searchDebounce?: number;
|
|
43
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './DashboardChart';
|
|
2
2
|
export * from './DatePicker';
|
|
3
|
+
export * from './DateRangePicker';
|
|
3
4
|
export * from './DateTimePicker';
|
|
4
5
|
export * from './DataTableActions';
|
|
5
6
|
export * from './Drawer';
|
|
@@ -11,13 +12,16 @@ export * from './FilterBar';
|
|
|
11
12
|
export * from './FilterForm';
|
|
12
13
|
export * from './FormFields';
|
|
13
14
|
export * from './FormField';
|
|
15
|
+
export * from './Form';
|
|
14
16
|
export * from './Grid';
|
|
15
17
|
export * from './ListingTable';
|
|
16
18
|
export * from './PageLoadingSkeleton';
|
|
17
19
|
export * from './PageHeader';
|
|
18
20
|
export * from './Pagination';
|
|
19
21
|
export * from './PaymentInfo';
|
|
22
|
+
export * from './ComboboxSelect';
|
|
20
23
|
export * from './MultiSelect';
|
|
24
|
+
export * from './PopoverMultiSelect';
|
|
21
25
|
export * from './RadioGroup';
|
|
22
26
|
export * from './Section';
|
|
23
27
|
export * from './SidebarNav';
|
|
Binary file
|