@parrot-co/parrot-ui 1.0.0-beta.0 → 1.0.0-beta.2
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.mts +229 -31
- package/dist/index.d.ts +229 -31
- package/dist/index.js +1402 -436
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1384 -438
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +437 -32
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React$1 from 'react';
|
|
2
2
|
import React__default from 'react';
|
|
3
3
|
import * as react_aria_components from 'react-aria-components';
|
|
4
|
-
import { TextFieldProps, NumberFieldProps, ButtonProps as ButtonProps$1, ToggleButtonProps as ToggleButtonProps$1, CheckboxFieldProps, CheckboxGroupProps as CheckboxGroupProps$1, MenuTriggerProps as MenuTriggerProps$1, MenuProps as MenuProps$1, Placement, MenuItemProps as MenuItemProps$1, MenuSectionProps as MenuSectionProps$1, ListBoxProps as ListBoxProps$1, ListBoxItemProps as ListBoxItemProps$1, ListBoxSectionProps as ListBoxSectionProps$1, RadioFieldProps, RadioGroupProps as RadioGroupProps$1, CalendarProps as CalendarProps$1, DateValue, RangeCalendarProps as RangeCalendarProps$1, DateFieldProps as DateFieldProps$1, TimeFieldProps as TimeFieldProps$1, TimeValue, DatePickerProps as DatePickerProps$1, DateRangePickerProps as DateRangePickerProps$1, ProgressBarProps, SwitchFieldProps, SliderProps as SliderProps$1, Key, TabsProps as TabsProps$1, Selection, SortDescriptor, ModalOverlayProps, PopoverProps as PopoverProps$1, TagGroupProps as TagGroupProps$1, TagListProps, TagProps as TagProps$1, Color as Color$1, ColorAreaProps as ColorAreaProps$1, ColorFieldProps as ColorFieldProps$1, ColorSwatchPickerProps as ColorSwatchPickerProps$1, ColorSliderProps as ColorSliderProps$1 } from 'react-aria-components';
|
|
4
|
+
import { TextFieldProps, NumberFieldProps, ButtonProps as ButtonProps$1, ToggleButtonProps as ToggleButtonProps$1, CheckboxFieldProps, CheckboxGroupProps as CheckboxGroupProps$1, MenuTriggerProps as MenuTriggerProps$1, MenuProps as MenuProps$1, Placement, MenuItemProps as MenuItemProps$1, MenuSectionProps as MenuSectionProps$1, ListBoxProps as ListBoxProps$1, ListBoxItemProps as ListBoxItemProps$1, ListBoxSectionProps as ListBoxSectionProps$1, RadioFieldProps, RadioGroupProps as RadioGroupProps$1, SelectProps as SelectProps$1, CalendarProps as CalendarProps$1, DateValue, RangeCalendarProps as RangeCalendarProps$1, DateFieldProps as DateFieldProps$1, TimeFieldProps as TimeFieldProps$1, TimeValue, DatePickerProps as DatePickerProps$1, DateRangePickerProps as DateRangePickerProps$1, ProgressBarProps, SwitchFieldProps, SliderProps as SliderProps$1, Key, TabsProps as TabsProps$1, Selection, SortDescriptor, ModalOverlayProps, PopoverProps as PopoverProps$1, TagGroupProps as TagGroupProps$1, TagListProps, TagProps as TagProps$1, Color as Color$1, ColorAreaProps as ColorAreaProps$1, ColorFieldProps as ColorFieldProps$1, ColorSwatchPickerProps as ColorSwatchPickerProps$1, ColorSliderProps as ColorSliderProps$1, TooltipProps as TooltipProps$1 } from 'react-aria-components';
|
|
5
5
|
import { OverlayTriggerProps } from 'react-stately';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -70,6 +70,11 @@ type ColorVariant = Variant;
|
|
|
70
70
|
type InputAppearance = "outline" | "filled" | "filled-outline";
|
|
71
71
|
/** The shared control-size scale (`.prt-size` recipe). */
|
|
72
72
|
type Size = "2xs" | "xs" | "sm" | "md" | "lg" | "xl";
|
|
73
|
+
/**
|
|
74
|
+
* The size range every control supports — the valid range for a theme-level
|
|
75
|
+
* `size` default. `2xs` (and larger opt-ins like `2xl`/`3xl`) stay per-component.
|
|
76
|
+
*/
|
|
77
|
+
type ControlSize = "xs" | "sm" | "md" | "lg" | "xl";
|
|
73
78
|
/** The radius scale (`data-radius` recipe). */
|
|
74
79
|
type Radius = "none" | "sm" | "md" | "lg" | "xl" | "2xl" | "full";
|
|
75
80
|
/** @deprecated use `Radius` */
|
|
@@ -77,11 +82,6 @@ type BorderRadius = "none" | "sm" | "md" | "lg" | "full";
|
|
|
77
82
|
type Appearance = "light" | "dark";
|
|
78
83
|
/** @deprecated use `Size` */
|
|
79
84
|
type ButtonSize = "xs" | "sm" | "md" | "lg" | "xl";
|
|
80
|
-
type ButtonAppearance = "primary" | "secondary" | "minimal";
|
|
81
|
-
type ButtonAppearanceSchemaType = Partial<Record<ButtonAppearance, {
|
|
82
|
-
variant: Variant;
|
|
83
|
-
color: Color;
|
|
84
|
-
}>>;
|
|
85
85
|
type SizeOption = "none" | "4xs" | "3xs" | "2xs" | "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl";
|
|
86
86
|
|
|
87
87
|
type ActionStatus = "idle" | "loading" | "success" | "error";
|
|
@@ -135,6 +135,45 @@ type NumberInputProps = Omit<NumberFieldProps, "className" | "style" | "children
|
|
|
135
135
|
};
|
|
136
136
|
declare function NumberInput({ appearance, size, color, classNames, styles, append, prepend, placeholder, showSteppers, error, label, description, incrementIcon, decrementIcon, inputRef, wrapperRef, validationStatus, shape, radius, ...props }: NumberInputProps): React$1.JSX.Element;
|
|
137
137
|
|
|
138
|
+
type PinInputType = "numeric" | "alphanumeric" | "all";
|
|
139
|
+
type PinInputProps = Omit<FieldComponentProps<"input" | "control" | "group" | "slot">, "prepend" | "append" | "shape"> & {
|
|
140
|
+
value?: string;
|
|
141
|
+
defaultValue?: string;
|
|
142
|
+
onChange?: (value: string) => void;
|
|
143
|
+
onComplete?: (value: string) => void;
|
|
144
|
+
/** Number of characters. Alias: `maxLength`. Defaults to 6. */
|
|
145
|
+
length?: number;
|
|
146
|
+
maxLength?: number;
|
|
147
|
+
type?: PinInputType;
|
|
148
|
+
/** Overrides `type`'s value filter. A `^...$` anchored source is expected. */
|
|
149
|
+
pattern?: RegExp;
|
|
150
|
+
/** Render each filled slot as a dot instead of the character. */
|
|
151
|
+
mask?: boolean;
|
|
152
|
+
/** Placeholder character shown in empty slots. */
|
|
153
|
+
placeholder?: string;
|
|
154
|
+
isReadOnly?: boolean;
|
|
155
|
+
autoFocus?: boolean;
|
|
156
|
+
name?: string;
|
|
157
|
+
/** Auto-render mode only: split slots into groups of this size. */
|
|
158
|
+
groupSize?: number;
|
|
159
|
+
/** Auto-render mode only: node rendered between groups. */
|
|
160
|
+
separator?: React$1.ReactNode;
|
|
161
|
+
children?: React$1.ReactNode;
|
|
162
|
+
};
|
|
163
|
+
declare function PinInput({ value, defaultValue, onChange, onComplete, length, maxLength, type, pattern, mask, placeholder, isReadOnly, autoFocus, name, groupSize, separator, children, inputRef: inputRefProp, classNames, styles, ...fieldProps }: PinInputProps): React$1.JSX.Element;
|
|
164
|
+
interface PinInputGroupProps extends React$1.HTMLAttributes<HTMLDivElement> {
|
|
165
|
+
_SILENCE_TS?: boolean;
|
|
166
|
+
}
|
|
167
|
+
declare function PinInputGroup({ className, ...props }: PinInputGroupProps): React$1.JSX.Element;
|
|
168
|
+
interface PinInputSlotProps extends Omit<React$1.HTMLAttributes<HTMLDivElement>, "children"> {
|
|
169
|
+
index: number;
|
|
170
|
+
}
|
|
171
|
+
declare function PinInputSlot({ index, className, ...props }: PinInputSlotProps): React$1.JSX.Element;
|
|
172
|
+
interface PinInputSeparatorProps extends React$1.HTMLAttributes<HTMLDivElement> {
|
|
173
|
+
_SILENCE_TS?: boolean;
|
|
174
|
+
}
|
|
175
|
+
declare function PinInputSeparator({ className, children, ...props }: PinInputSeparatorProps): React$1.JSX.Element;
|
|
176
|
+
|
|
138
177
|
type TextWeight = "light" | "regular" | "medium" | "semi-bold" | "bold" | "heavy" | "inherit";
|
|
139
178
|
type TextColorVariant = "light" | "lighter" | "dark" | "default";
|
|
140
179
|
interface TextProps extends Omit<React$1.ComponentPropsWithRef<"span">, "color"> {
|
|
@@ -373,37 +412,21 @@ interface RadioItemProps extends Omit<RadioFieldProps, "className" | "style" | "
|
|
|
373
412
|
}
|
|
374
413
|
declare function RadioItem({ className, style, classNames, styles, children, ...props }: RadioItemProps): React$1.JSX.Element;
|
|
375
414
|
|
|
376
|
-
type SingleOrMultipleValue = ID | Array<ID>;
|
|
377
415
|
type SelectionMode = "single" | "multiple";
|
|
378
|
-
interface
|
|
379
|
-
target: {
|
|
380
|
-
value: SingleOrMultipleValue;
|
|
381
|
-
name?: string;
|
|
382
|
-
};
|
|
383
|
-
}
|
|
384
|
-
interface SelectProps<T extends object> extends Pick<ListBoxProps<T>, "items" | "labelKey" | "valueKey" | "sectionKey" | "renderOption" | "renderSectionLabel" | "disabledKeys" | "children">, StyleProps<"wrapper" | "trigger" | "value" | "placeholder" | "label" | "popover"> {
|
|
416
|
+
interface SelectProps<T extends object, M extends SelectionMode = "single"> extends Omit<SelectProps$1<T, M>, "className" | "style" | "children" | "isInvalid" | "selectedKey" | "defaultSelectedKey" | "selectedKeys" | "defaultSelectedKeys" | "onSelectionChange">, Pick<ListBoxProps<T>, "items" | "labelKey" | "valueKey" | "sectionKey" | "renderOption" | "renderSectionLabel" | "disabledKeys" | "children">, StyleProps<"wrapper" | "trigger" | "value" | "placeholder" | "label" | "popover"> {
|
|
385
417
|
label?: React$1.ReactNode;
|
|
386
418
|
description?: React$1.ReactNode;
|
|
387
419
|
error?: React$1.ReactNode;
|
|
388
|
-
placeholder?: string;
|
|
389
|
-
selectionMode?: SelectionMode;
|
|
390
|
-
value?: SingleOrMultipleValue;
|
|
391
|
-
defaultValue?: SingleOrMultipleValue;
|
|
392
|
-
name?: string;
|
|
393
|
-
isDisabled?: boolean;
|
|
394
|
-
isRequired?: boolean;
|
|
395
420
|
color?: Color;
|
|
396
421
|
listBoxColor?: Color;
|
|
397
422
|
size?: "xs" | "sm" | "md" | "lg" | "xl";
|
|
398
|
-
radius?:
|
|
423
|
+
radius?: Radius;
|
|
399
424
|
appearance?: InputAppearance;
|
|
400
425
|
showSectionSeparator?: boolean;
|
|
401
426
|
showSelectionIndicator?: boolean;
|
|
402
427
|
renderValue?: (value: T) => React$1.ReactNode;
|
|
403
|
-
onChange?: (event: MockNativeOnChangeEvent) => void;
|
|
404
|
-
onSelectionChange?: (keys: Array<ID>) => void;
|
|
405
428
|
}
|
|
406
|
-
declare function Select<T extends object>({ label, description, error, placeholder,
|
|
429
|
+
declare function Select<T extends object, M extends SelectionMode = "single">({ label, description, error, placeholder, appearance, renderValue, color, size, radius, listBoxColor, showSectionSeparator, showSelectionIndicator, items, children, labelKey, valueKey, sectionKey, renderOption, renderSectionLabel, disabledKeys, className, classNames, style, styles, "aria-label": ariaLabel, ...racProps }: SelectProps<T, M>): React$1.JSX.Element;
|
|
407
430
|
|
|
408
431
|
interface CalendarProps extends Omit<CalendarProps$1<DateValue>, "className" | "style" | "children" | "visibleDuration"> {
|
|
409
432
|
numberOfMonths?: number;
|
|
@@ -599,12 +622,13 @@ interface TableProps<T extends object> extends StyleProps<"wrapper" | "header" |
|
|
|
599
622
|
selectionMode?: "none" | "single" | "multiple";
|
|
600
623
|
selectedKeys?: Selection;
|
|
601
624
|
onSelectionChange?: (keys: Selection) => void;
|
|
625
|
+
onRowAction?: (key: string | number) => void;
|
|
602
626
|
sortDescriptor?: SortDescriptor;
|
|
603
627
|
onSortChange?: (descriptor: SortDescriptor) => void;
|
|
604
628
|
renderEmptyState?: () => React$1.ReactNode;
|
|
605
629
|
"aria-label"?: string;
|
|
606
630
|
}
|
|
607
|
-
declare function Table<T extends object>({ columns, data, getRowId, selectionMode, selectedKeys, onSelectionChange, sortDescriptor, onSortChange, renderEmptyState, radius, className, classNames, style, styles, ...props }: TableProps<T>): React$1.JSX.Element;
|
|
631
|
+
declare function Table<T extends object>({ columns, data, getRowId, selectionMode, selectedKeys, onSelectionChange, onRowAction, sortDescriptor, onSortChange, renderEmptyState, radius, className, classNames, style, styles, ...props }: TableProps<T>): React$1.JSX.Element;
|
|
608
632
|
|
|
609
633
|
interface TimelineProps<T> extends StyleProps<"wrapper" | "item" | "content"> {
|
|
610
634
|
items: Array<T>;
|
|
@@ -635,6 +659,58 @@ interface ModalProps extends Omit<ModalOverlayProps, "children" | "className" |
|
|
|
635
659
|
declare function Modal({ variant, radius, isDismissable, width, title, description, onConfirm, onCancel, confirmLabel, cancelLabel, confirmButtonProps, cancelButtonProps, showCloseButton, hideTitle, onClose, children, className, style, classNames, styles, ...props }: ModalProps): React$1.JSX.Element;
|
|
636
660
|
declare function useModal(props?: OverlayTriggerProps): react_aria_components.OverlayTriggerState;
|
|
637
661
|
|
|
662
|
+
/**
|
|
663
|
+
* A modal component registered in the registry receives these three props from
|
|
664
|
+
* the provider. Extend it in your own modal components:
|
|
665
|
+
*
|
|
666
|
+
* interface EditUserModalProps extends BaseModalProps<User> { userId: string }
|
|
667
|
+
*
|
|
668
|
+
* Call `onResolve(result)` to close with a value; `onOpenChange(false)` dismisses
|
|
669
|
+
* (resolves with `undefined`). Resolve wins once — call `onResolve`, not
|
|
670
|
+
* `onOpenChange`, when you have a result.
|
|
671
|
+
*/
|
|
672
|
+
interface BaseModalProps<TResult = void> extends Pick<ModalOverlayProps, "isOpen" | "onOpenChange"> {
|
|
673
|
+
onResolve: (result: TResult) => void;
|
|
674
|
+
}
|
|
675
|
+
type ModalComponent = React$1.ComponentType<any>;
|
|
676
|
+
type ModalDef<C extends ModalComponent = ModalComponent> = {
|
|
677
|
+
component: C;
|
|
678
|
+
};
|
|
679
|
+
interface ModalRegistry {
|
|
680
|
+
[key: string]: ModalDef;
|
|
681
|
+
}
|
|
682
|
+
/**
|
|
683
|
+
* Ambient registry — augment it (like ParrotColorRegistry) so `useModals().open`
|
|
684
|
+
* is fully typed with no generics at the call site:
|
|
685
|
+
*
|
|
686
|
+
* declare module "@parrot-co/parrot-ui" {
|
|
687
|
+
* interface ParrotModalRegistry {
|
|
688
|
+
* editUser: { component: typeof EditUserModal };
|
|
689
|
+
* }
|
|
690
|
+
* }
|
|
691
|
+
*/
|
|
692
|
+
interface ParrotModalRegistry {
|
|
693
|
+
}
|
|
694
|
+
type ModalKey = keyof ParrotModalRegistry & string;
|
|
695
|
+
type ComponentOf<K extends ModalKey> = ParrotModalRegistry[K] extends ModalDef<infer C> ? C : ModalComponent;
|
|
696
|
+
type ModalInputProps<K extends ModalKey> = Omit<React$1.ComponentProps<ComponentOf<K>>, "isOpen" | "onOpenChange" | "onResolve">;
|
|
697
|
+
type ModalResult<K extends ModalKey> = React$1.ComponentProps<ComponentOf<K>> extends {
|
|
698
|
+
onResolve?: (result: infer TResult) => void;
|
|
699
|
+
} ? TResult : void;
|
|
700
|
+
interface ModalControls {
|
|
701
|
+
open: <K extends ModalKey>(key: K, props?: ModalInputProps<K>) => Promise<ModalResult<K>>;
|
|
702
|
+
close: (key: ModalKey) => void;
|
|
703
|
+
update: <K extends ModalKey>(key: K, props: ModalInputProps<K>) => void;
|
|
704
|
+
isOpen: (key: ModalKey) => boolean;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
interface ModalProviderProps {
|
|
708
|
+
registry: ModalRegistry;
|
|
709
|
+
children: React$1.ReactNode;
|
|
710
|
+
}
|
|
711
|
+
declare function ModalProvider({ registry, children }: ModalProviderProps): React$1.JSX.Element;
|
|
712
|
+
declare function useModals(): ModalControls;
|
|
713
|
+
|
|
638
714
|
type TagFormat = "text" | "email" | "url" | "number";
|
|
639
715
|
interface TagInputProps extends FieldComponentProps<"input"> {
|
|
640
716
|
tags?: Array<string>;
|
|
@@ -692,10 +768,9 @@ declare function TagGroupItem({ children, textValue, ...props }: TagGroupItemPro
|
|
|
692
768
|
|
|
693
769
|
interface ThemeProviderValue {
|
|
694
770
|
color?: Color;
|
|
695
|
-
radius?:
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
avatarRadiusSize?: BorderRadius;
|
|
771
|
+
radius?: Radius;
|
|
772
|
+
size?: ControlSize;
|
|
773
|
+
colorScheme?: Appearance;
|
|
699
774
|
inputAppearance?: InputAppearance;
|
|
700
775
|
}
|
|
701
776
|
interface ThemeProviderProps extends ThemeProviderValue {
|
|
@@ -770,4 +845,127 @@ interface ToggleProps extends ButtonToggleProps, StyleProps<"wrapper"> {
|
|
|
770
845
|
}
|
|
771
846
|
declare function Toggle({ value, ...props }: ToggleProps): React$1.JSX.Element;
|
|
772
847
|
|
|
773
|
-
|
|
848
|
+
type ToastVariant = "default" | "success" | "error" | "warning" | "info";
|
|
849
|
+
type ToastPosition = "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right";
|
|
850
|
+
interface ToastAction {
|
|
851
|
+
label: string;
|
|
852
|
+
onClick: () => void;
|
|
853
|
+
}
|
|
854
|
+
interface ToastOptions {
|
|
855
|
+
description?: string;
|
|
856
|
+
action?: ToastAction;
|
|
857
|
+
cancel?: ToastAction;
|
|
858
|
+
duration?: number;
|
|
859
|
+
position?: ToastPosition;
|
|
860
|
+
}
|
|
861
|
+
type CustomToastRender = (props: {
|
|
862
|
+
close: () => void;
|
|
863
|
+
}) => React$1.ReactNode;
|
|
864
|
+
interface ToastRegionProps {
|
|
865
|
+
position?: ToastPosition;
|
|
866
|
+
}
|
|
867
|
+
declare function ToastRegion({ position }: ToastRegionProps): React$1.JSX.Element;
|
|
868
|
+
declare function toast(title: string, options?: ToastOptions): string;
|
|
869
|
+
declare namespace toast {
|
|
870
|
+
var success: (title: string, options?: ToastOptions) => string;
|
|
871
|
+
var error: (title: string, options?: ToastOptions) => string;
|
|
872
|
+
var warning: (title: string, options?: ToastOptions) => string;
|
|
873
|
+
var info: (title: string, options?: ToastOptions) => string;
|
|
874
|
+
var custom: (render: CustomToastRender, options?: Pick<ToastOptions, "duration" | "position">) => string;
|
|
875
|
+
var dismiss: (key: string) => void;
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
interface TooltipProps extends Omit<TooltipProps$1, "className" | "style" | "children">, StyleProps<"tooltip"> {
|
|
879
|
+
content: React$1.ReactNode;
|
|
880
|
+
children: React$1.ReactElement;
|
|
881
|
+
delay?: number;
|
|
882
|
+
closeDelay?: number;
|
|
883
|
+
isDisabled?: boolean;
|
|
884
|
+
showArrow?: boolean;
|
|
885
|
+
}
|
|
886
|
+
declare function Tooltip({ content, children, delay, closeDelay, isDisabled, showArrow, placement, offset, className, classNames, style, styles, ...props }: TooltipProps): React$1.JSX.Element;
|
|
887
|
+
|
|
888
|
+
interface HoverCardProps extends Omit<PopoverProps$1, "triggerRef" | "children" | "className" | "style" | "isOpen" | "defaultOpen" | "onOpenChange" | "isNonModal">, StyleProps<"popover" | "content"> {
|
|
889
|
+
children: React$1.ReactElement;
|
|
890
|
+
content: React$1.ReactNode;
|
|
891
|
+
openDelay?: number;
|
|
892
|
+
closeDelay?: number;
|
|
893
|
+
isDisabled?: boolean;
|
|
894
|
+
isOpen?: boolean;
|
|
895
|
+
defaultOpen?: boolean;
|
|
896
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
897
|
+
}
|
|
898
|
+
declare function HoverCard({ children, content, openDelay, closeDelay, isDisabled, isOpen, defaultOpen, onOpenChange, offset, placement, className, classNames, style, styles, ...props }: HoverCardProps): React$1.JSX.Element;
|
|
899
|
+
|
|
900
|
+
type FieldValidator<T> = (value: unknown, values: T) => string | null;
|
|
901
|
+
interface UseFormOptions<T extends Record<string, unknown>> {
|
|
902
|
+
fields: T;
|
|
903
|
+
validators?: Partial<Record<keyof T, FieldValidator<T>>>;
|
|
904
|
+
optional?: Array<keyof T>;
|
|
905
|
+
resetKey?: string | number | null;
|
|
906
|
+
}
|
|
907
|
+
type Errors<T> = Record<keyof T, string | null>;
|
|
908
|
+
type Touched<T> = Record<keyof T, boolean>;
|
|
909
|
+
interface UseFormReturn<T extends Record<string, unknown>> {
|
|
910
|
+
values: T;
|
|
911
|
+
errors: Errors<T>;
|
|
912
|
+
touched: Touched<T>;
|
|
913
|
+
isDirty: boolean;
|
|
914
|
+
isSubmitting: boolean;
|
|
915
|
+
setIsSubmitting: React$1.Dispatch<React$1.SetStateAction<boolean>>;
|
|
916
|
+
onChange: (fieldName: keyof T, value: unknown) => void;
|
|
917
|
+
getFieldProps: (fieldName: keyof T) => {
|
|
918
|
+
name: string;
|
|
919
|
+
value: string;
|
|
920
|
+
onChange: (value: string) => void;
|
|
921
|
+
error: string | null;
|
|
922
|
+
};
|
|
923
|
+
getNumberFieldProps: (fieldName: keyof T) => {
|
|
924
|
+
name: string;
|
|
925
|
+
value: number;
|
|
926
|
+
onChange: (value: number) => void;
|
|
927
|
+
error: string | null;
|
|
928
|
+
};
|
|
929
|
+
getSelectProps: (fieldName: keyof T) => {
|
|
930
|
+
name: string;
|
|
931
|
+
value: Key | null;
|
|
932
|
+
onChange: (value: Key | null) => void;
|
|
933
|
+
error: string | null;
|
|
934
|
+
};
|
|
935
|
+
getCheckboxGroupProps: (fieldName: keyof T) => {
|
|
936
|
+
name: string;
|
|
937
|
+
value: string[];
|
|
938
|
+
onChange: (value: string[]) => void;
|
|
939
|
+
errorMessage: string | null;
|
|
940
|
+
};
|
|
941
|
+
getRadioGroupProps: (fieldName: keyof T) => {
|
|
942
|
+
name: string;
|
|
943
|
+
value: string;
|
|
944
|
+
onChange: (value: string) => void;
|
|
945
|
+
errorMessage: string | null;
|
|
946
|
+
};
|
|
947
|
+
getSwitchProps: (fieldName: keyof T) => {
|
|
948
|
+
name: string;
|
|
949
|
+
isSelected: boolean;
|
|
950
|
+
onChange: (value: boolean) => void;
|
|
951
|
+
};
|
|
952
|
+
handleSubmit: (callback: (values: T) => void | Promise<void>) => (e: React$1.FormEvent) => void;
|
|
953
|
+
isValid: () => boolean;
|
|
954
|
+
reset: () => void;
|
|
955
|
+
validateAll: () => Errors<T>;
|
|
956
|
+
setFieldValues: (newValues: Partial<T>) => void;
|
|
957
|
+
setFieldError: (fieldName: keyof T, error: string | null) => void;
|
|
958
|
+
}
|
|
959
|
+
declare function useForm<T extends Record<string, unknown>>({ fields: defaultFields, validators, optional, resetKey, }: UseFormOptions<T>): UseFormReturn<T>;
|
|
960
|
+
|
|
961
|
+
declare function required<T>(message?: string): FieldValidator<T>;
|
|
962
|
+
declare function email<T>(message?: string): FieldValidator<T>;
|
|
963
|
+
declare function minLength<T>(length: number, message?: string): FieldValidator<T>;
|
|
964
|
+
declare function maxLength<T>(length: number, message?: string): FieldValidator<T>;
|
|
965
|
+
declare function min<T>(n: number, message?: string): FieldValidator<T>;
|
|
966
|
+
declare function max<T>(n: number, message?: string): FieldValidator<T>;
|
|
967
|
+
declare function pattern<T>(regex: RegExp, message?: string): FieldValidator<T>;
|
|
968
|
+
declare function matches<T>(fieldName: keyof T & string, message?: string): FieldValidator<T>;
|
|
969
|
+
declare function compose<T>(...fns: Array<FieldValidator<T>>): FieldValidator<T>;
|
|
970
|
+
|
|
971
|
+
export { Avatar, AvatarGroup, type BaseModalProps, Button, ButtonGroup, Calendar, Checkbox, CheckboxGroup, CheckboxItem, ColorArea, ColorField, ColorPicker, ColorSlider, ColorSwatchPicker, ComboBox, type CustomToastRender, DateField, DatePicker, DateRangePicker, type FieldValidator, FileUploader, HoverCard, type HoverCardProps, IconButton, Input, ListBox, ListBoxItem, ListBoxSection, Loader, Menu, MenuContent, MenuItem, MenuSection, MenuTrigger, Modal, type ModalControls, type ModalDef, type ModalInputProps, type ModalKey, type ModalProps, ModalProvider, type ModalProviderProps, type ModalRegistry, type ModalResult, NumberInput, ListBoxItem as Option, type ParrotModalRegistry, PinInput, PinInputGroup, type PinInputGroupProps, type PinInputProps, PinInputSeparator, type PinInputSeparatorProps, PinInputSlot, type PinInputSlotProps, type PinInputType, Popover, PopoverContent, PopoverTrigger, Progress, Radio, RadioCard, RadioGroup, RadioItem, RangeCalendar, ListBoxSection as Section, Select, Separator, Slider, Space, Sticker, Switch, Tab, Table, Tabs, Tag, TagGroup, TagGroupItem, TagInput, Text, Textarea, ThemeProvider, TimeField, Timeline, type ToastAction, type ToastOptions, type ToastPosition, ToastRegion, type ToastRegionProps, type ToastVariant, Toggle, ToggleButton, ToggleGroup, Tooltip, type TooltipProps, type UseFormOptions, type UseFormReturn, compose, email, matches, max, maxLength, min, minLength, parseColor, pattern, required, toast, useForm, useModal, useModals, useTheme };
|