haze-ui 1.12.2 → 1.14.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/README.md +64 -1
- package/dist/components/ColorPicker/ColorPickerCore.js +2 -0
- package/dist/components/Combobox/Combobox.js +45 -34
- package/dist/components/Command/Command.js +72 -37
- package/dist/components/ContextMenu/ContextMenu.js +19 -17
- package/dist/components/ContextMenu/ContextMenuContent.js +24 -12
- package/dist/components/ContextMenu/ContextMenuItem.js +2 -0
- package/dist/components/DateRangePicker/DateRangePickerCore.js +2 -0
- package/dist/components/Datepicker/Calendar.js +58 -44
- package/dist/components/Datepicker/DatepickerCore.js +37 -29
- package/dist/components/DropdownMenu/DropdownMenu.js +20 -20
- package/dist/components/DropdownMenu/DropdownMenuContent.js +38 -45
- package/dist/components/DropdownMenu/DropdownMenuTrigger.js +9 -7
- package/dist/components/InlineEdit/InlineEdit.js +1 -0
- package/dist/components/Menu/Menu.js +38 -26
- package/dist/components/Menu/MenuItem.js +1 -0
- package/dist/components/ModelPicker/ModelPicker.js +1 -0
- package/dist/components/OTPInput/OTPInputCore.js +1 -0
- package/dist/components/PasswordInput/PasswordInputCore.js +1 -0
- package/dist/components/Popover/Popover.js +32 -75
- package/dist/components/Progress/Progress.js +2 -0
- package/dist/components/Tooltip/Tooltip.js +50 -24
- package/dist/components/Tree/TreeItem.js +44 -41
- package/dist/components/Upload/Upload.js +1 -0
- package/dist/css/combobox.css +2 -1
- package/dist/css/command.css +1 -1
- package/dist/css/context-menu.css +1 -0
- package/dist/css/datepicker.css +3 -2
- package/dist/css/dropdown-menu.css +2 -1
- package/dist/css/menu.css +2 -1
- package/dist/css/popover.css +2 -1
- package/dist/css/tooltip.css +2 -1
- package/dist/form/FormItem.js +23 -15
- package/dist/haze-ui.css +15 -8
- package/dist/types/components/Alert/Alert.d.ts +2 -2
- package/dist/types/components/Banner/Banner.d.ts +2 -2
- package/dist/types/components/BottomSheet/BottomSheet.d.ts +2 -2
- package/dist/types/components/Carousel/Carousel.d.ts +2 -2
- package/dist/types/components/ChatInput/ChatInput.d.ts +2 -2
- package/dist/types/components/Checkbox/Checkbox.d.ts +2 -2
- package/dist/types/components/Collapsible/Collapsible.d.ts +2 -2
- package/dist/types/components/ColorPicker/ColorPicker.d.ts +2 -2
- package/dist/types/components/Combobox/Combobox.d.ts +3 -3
- package/dist/types/components/Command/Command.d.ts +2 -2
- package/dist/types/components/ConfirmDialog/ConfirmDialog.d.ts +2 -2
- package/dist/types/components/ContextMenu/ContextMenu.d.ts +2 -2
- package/dist/types/components/ContextMenu/ContextMenuContent.d.ts +1 -1
- package/dist/types/components/ContextMenu/ContextMenuContext.d.ts +5 -1
- package/dist/types/components/DateRangePicker/DateRangePicker.d.ts +3 -3
- package/dist/types/components/Datepicker/Datepicker.d.ts +3 -3
- package/dist/types/components/Dialog/Dialog.d.ts +2 -2
- package/dist/types/components/Disclosure/Disclosure.d.ts +2 -2
- package/dist/types/components/Drawer/Drawer.d.ts +2 -2
- package/dist/types/components/DropdownMenu/DropdownMenu.d.ts +2 -2
- package/dist/types/components/DropdownMenu/DropdownMenuContent.d.ts +1 -1
- package/dist/types/components/DropdownMenu/DropdownMenuContext.d.ts +3 -0
- package/dist/types/components/DropdownMenu/DropdownMenuTrigger.d.ts +1 -1
- package/dist/types/components/InlineEdit/InlineEdit.d.ts +2 -2
- package/dist/types/components/Input/Input.d.ts +2 -2
- package/dist/types/components/LogViewer/LogViewer.d.ts +2 -2
- package/dist/types/components/Menu/Menu.d.ts +2 -2
- package/dist/types/components/ModelPicker/ModelPicker.d.ts +2 -2
- package/dist/types/components/NumberInput/NumberInput.d.ts +2 -2
- package/dist/types/components/OTPInput/OTPInput.d.ts +2 -2
- package/dist/types/components/Pagination/Pagination.d.ts +2 -2
- package/dist/types/components/PasswordInput/PasswordInput.d.ts +2 -2
- package/dist/types/components/Popover/Popover.d.ts +2 -2
- package/dist/types/components/Radio/RadioGroup.d.ts +2 -2
- package/dist/types/components/Rating/Rating.d.ts +2 -2
- package/dist/types/components/Segmented/Segmented.d.ts +2 -2
- package/dist/types/components/Select/Select.d.ts +2 -2
- package/dist/types/components/Slider/Slider.d.ts +2 -2
- package/dist/types/components/Stepper/Stepper.d.ts +2 -2
- package/dist/types/components/Switch/Switch.d.ts +2 -2
- package/dist/types/components/Tabs/Tabs.d.ts +2 -2
- package/dist/types/components/TagInput/TagInput.d.ts +2 -2
- package/dist/types/components/Textarea/Textarea.d.ts +2 -2
- package/dist/types/components/TimePicker/TimePicker.d.ts +2 -2
- package/dist/types/components/Tooltip/Tooltip.d.ts +5 -1
- package/dist/types/components/Transfer/Transfer.d.ts +2 -2
- package/dist/types/components/Tree/types.d.ts +4 -4
- package/dist/types/form/FormItem.d.ts +63 -7
- package/dist/types/form/index.d.ts +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/utils/floating.d.ts +99 -0
- package/dist/types/utils/menuKeyboard.d.ts +43 -0
- package/dist/utils/floating.js +181 -0
- package/dist/utils/menuKeyboard.js +88 -0
- package/package.json +34 -8
- package/dist/components/DropdownMenu/useMenuKeyboard.js +0 -52
- package/dist/types/components/DropdownMenu/useMenuKeyboard.d.ts +0 -19
- package/dist/types/hooks/index.d.ts +0 -1
- package/dist/types/utils/index.d.ts +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ControlOrValue } from 'react-use-control';
|
|
3
3
|
type CheckboxProps = {
|
|
4
|
-
checked?:
|
|
4
|
+
checked?: ControlOrValue<boolean>;
|
|
5
5
|
label?: ReactNode;
|
|
6
6
|
} & Omit<ComponentPropsWithoutRef<'input'>, 'checked' | 'type'>;
|
|
7
7
|
export default function Checkbox({ checked: checkedControl, className, label, onChange, ...rest }: CheckboxProps): import("react").JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ControlOrValue } from 'react-use-control';
|
|
3
3
|
type CollapsibleProps = {
|
|
4
|
-
open?:
|
|
4
|
+
open?: ControlOrValue<boolean>;
|
|
5
5
|
defaultOpen?: boolean;
|
|
6
6
|
children: ReactNode;
|
|
7
7
|
className?: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ControlOrValue } from 'react-use-control';
|
|
2
2
|
type ColorPickerProps = {
|
|
3
|
-
value?:
|
|
3
|
+
value?: ControlOrValue<string>;
|
|
4
4
|
presets?: string[];
|
|
5
5
|
onChange?: (color: string) => void;
|
|
6
6
|
className?: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ControlOrValue } from 'react-use-control';
|
|
2
2
|
type ComboboxProps = {
|
|
3
|
-
value?:
|
|
4
|
-
open?:
|
|
3
|
+
value?: ControlOrValue<string>;
|
|
4
|
+
open?: ControlOrValue<boolean>;
|
|
5
5
|
options: {
|
|
6
6
|
value: string;
|
|
7
7
|
label: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ControlOrValue } from 'react-use-control';
|
|
3
3
|
type CommandProps = {
|
|
4
|
-
query?:
|
|
4
|
+
query?: ControlOrValue<string>;
|
|
5
5
|
children: ReactNode;
|
|
6
6
|
className?: string;
|
|
7
7
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ControlOrValue } from 'react-use-control';
|
|
3
3
|
type ConfirmDialogProps = {
|
|
4
|
-
open?:
|
|
4
|
+
open?: ControlOrValue<boolean>;
|
|
5
5
|
onClose?: () => void;
|
|
6
6
|
onConfirm?: () => void;
|
|
7
7
|
onCancel?: () => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ControlOrValue } from 'react-use-control';
|
|
3
3
|
type ContextMenuProps = {
|
|
4
|
-
open?:
|
|
4
|
+
open?: ControlOrValue<boolean>;
|
|
5
5
|
onOpenChange?: (open: boolean) => void;
|
|
6
6
|
children: ReactNode;
|
|
7
7
|
className?: string;
|
|
@@ -3,5 +3,5 @@ type ContextMenuContentProps = {
|
|
|
3
3
|
children: ReactNode;
|
|
4
4
|
className?: string;
|
|
5
5
|
};
|
|
6
|
-
export default function ContextMenuContent({ children, className }: ContextMenuContentProps): import("react").JSX.Element | null;
|
|
6
|
+
export default function ContextMenuContent({ children, className, }: ContextMenuContentProps): import("react").JSX.Element | null;
|
|
7
7
|
export type { ContextMenuContentProps };
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import type { Dispatch, SetStateAction } from 'react';
|
|
1
|
+
import type { Dispatch, RefObject, SetStateAction } from 'react';
|
|
2
|
+
import type { FloatingBehavior } from '../../utils/floating';
|
|
2
3
|
type ContextMenuContextValue = {
|
|
3
4
|
open: boolean;
|
|
4
5
|
setOpen: Dispatch<SetStateAction<boolean>>;
|
|
5
6
|
x: number;
|
|
6
7
|
y: number;
|
|
7
8
|
setPosition: (x: number, y: number) => void;
|
|
9
|
+
contentRef: RefObject<HTMLDivElement | null>;
|
|
10
|
+
/** Floating-panel behavior shared by the root and content. */
|
|
11
|
+
floating: FloatingBehavior;
|
|
8
12
|
};
|
|
9
13
|
export declare const ContextMenuProvider: import("react").Provider<ContextMenuContextValue | undefined>;
|
|
10
14
|
export declare function useContextMenuContext(): ContextMenuContextValue;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ControlOrValue } from 'react-use-control';
|
|
3
3
|
type DateRangePickerProps = {
|
|
4
|
-
startDate?:
|
|
5
|
-
endDate?:
|
|
4
|
+
startDate?: ControlOrValue<string>;
|
|
5
|
+
endDate?: ControlOrValue<string>;
|
|
6
6
|
onStartChange?: (value: string) => void;
|
|
7
7
|
onEndChange?: (value: string) => void;
|
|
8
8
|
separator?: ReactNode;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ControlOrValue } from 'react-use-control';
|
|
2
2
|
type DatepickerProps = {
|
|
3
|
-
value?:
|
|
4
|
-
open?:
|
|
3
|
+
value?: ControlOrValue<string>;
|
|
4
|
+
open?: ControlOrValue<boolean>;
|
|
5
5
|
min?: string;
|
|
6
6
|
max?: string;
|
|
7
7
|
placeholder?: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ControlOrValue } from 'react-use-control';
|
|
3
3
|
type DialogProps = {
|
|
4
|
-
open?:
|
|
4
|
+
open?: ControlOrValue<boolean>;
|
|
5
5
|
onClose?: () => void;
|
|
6
6
|
/**
|
|
7
7
|
* 对话框标题:渲染为 h2 并以生成的 id 关联 dialog 的
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ControlOrValue } from 'react-use-control';
|
|
3
3
|
type DisclosureProps = {
|
|
4
|
-
open?:
|
|
4
|
+
open?: ControlOrValue<boolean>;
|
|
5
5
|
summary: ReactNode;
|
|
6
6
|
className?: string;
|
|
7
7
|
children: ReactNode;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ControlOrValue } from 'react-use-control';
|
|
3
3
|
type DrawerProps = {
|
|
4
|
-
open?:
|
|
4
|
+
open?: ControlOrValue<boolean>;
|
|
5
5
|
placement?: 'left' | 'right' | 'top' | 'bottom';
|
|
6
6
|
onClose?: () => void;
|
|
7
7
|
className?: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ControlOrValue } from 'react-use-control';
|
|
3
3
|
type DropdownMenuProps = {
|
|
4
|
-
open?:
|
|
4
|
+
open?: ControlOrValue<boolean>;
|
|
5
5
|
onOpenChange?: (open: boolean) => void;
|
|
6
6
|
children: ReactNode;
|
|
7
7
|
className?: string;
|
|
@@ -4,5 +4,5 @@ type DropdownMenuContentProps = {
|
|
|
4
4
|
align?: 'start' | 'center' | 'end';
|
|
5
5
|
className?: string;
|
|
6
6
|
};
|
|
7
|
-
export default function DropdownMenuContent({ children, align, className }: DropdownMenuContentProps): import("react").JSX.Element | null;
|
|
7
|
+
export default function DropdownMenuContent({ children, align, className, }: DropdownMenuContentProps): import("react").JSX.Element | null;
|
|
8
8
|
export type { DropdownMenuContentProps };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Dispatch, RefObject, SetStateAction } from 'react';
|
|
2
|
+
import type { FloatingBehavior } from '../../utils/floating';
|
|
2
3
|
type DropdownMenuContextValue = {
|
|
3
4
|
open: boolean;
|
|
4
5
|
setOpen: Dispatch<SetStateAction<boolean>>;
|
|
@@ -14,6 +15,8 @@ type DropdownMenuContextValue = {
|
|
|
14
15
|
focusRequestRef: {
|
|
15
16
|
current: 'first' | 'last' | null;
|
|
16
17
|
};
|
|
18
|
+
/** Floating-panel behavior shared by the trigger and content. */
|
|
19
|
+
floating: FloatingBehavior;
|
|
17
20
|
};
|
|
18
21
|
export declare const DropdownMenuProvider: import("react").Provider<DropdownMenuContextValue | undefined>;
|
|
19
22
|
export declare function useDropdownMenuContext(): DropdownMenuContextValue;
|
|
@@ -3,5 +3,5 @@ type DropdownMenuTriggerProps = {
|
|
|
3
3
|
children: ReactNode;
|
|
4
4
|
className?: string;
|
|
5
5
|
};
|
|
6
|
-
export default function DropdownMenuTrigger({ children, className }: DropdownMenuTriggerProps): import("react").JSX.Element;
|
|
6
|
+
export default function DropdownMenuTrigger({ children, className, }: DropdownMenuTriggerProps): import("react").JSX.Element;
|
|
7
7
|
export type { DropdownMenuTriggerProps };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ControlOrValue } from 'react-use-control';
|
|
2
2
|
type InlineEditProps = {
|
|
3
|
-
value?:
|
|
3
|
+
value?: ControlOrValue<string>;
|
|
4
4
|
onChange?: (value: string) => void;
|
|
5
5
|
placeholder?: string;
|
|
6
6
|
disabled?: boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ComponentPropsWithoutRef } from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ControlOrValue } from 'react-use-control';
|
|
3
3
|
type InputProps = {
|
|
4
|
-
value?:
|
|
4
|
+
value?: ControlOrValue<string>;
|
|
5
5
|
size?: 'sm' | 'md' | 'lg';
|
|
6
6
|
} & Omit<ComponentPropsWithoutRef<'input'>, 'value' | 'size'>;
|
|
7
7
|
export default function Input({ value: valueControl, size, className, onChange, ...rest }: InputProps): import("react").JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ControlOrValue } from 'react-use-control';
|
|
2
2
|
type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
3
3
|
type LogEntry = {
|
|
4
4
|
level: LogLevel;
|
|
@@ -7,7 +7,7 @@ type LogEntry = {
|
|
|
7
7
|
};
|
|
8
8
|
type LogViewerProps = {
|
|
9
9
|
logs: LogEntry[];
|
|
10
|
-
filter?:
|
|
10
|
+
filter?: ControlOrValue<LogLevel | null>;
|
|
11
11
|
className?: string;
|
|
12
12
|
};
|
|
13
13
|
export default function LogViewer({ logs, filter: filterControl, className }: LogViewerProps): import("react").JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ControlOrValue } from 'react-use-control';
|
|
3
3
|
type MenuProps = {
|
|
4
|
-
open?:
|
|
4
|
+
open?: ControlOrValue<boolean>;
|
|
5
5
|
trigger?: ReactNode;
|
|
6
6
|
className?: string;
|
|
7
7
|
children: ReactNode;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ControlOrValue } from 'react-use-control';
|
|
2
2
|
type ModelOption = {
|
|
3
3
|
value: string;
|
|
4
4
|
label: string;
|
|
@@ -6,7 +6,7 @@ type ModelOption = {
|
|
|
6
6
|
contextLength?: string;
|
|
7
7
|
};
|
|
8
8
|
type ModelPickerProps = {
|
|
9
|
-
value?:
|
|
9
|
+
value?: ControlOrValue<string>;
|
|
10
10
|
onChange?: (value: string) => void;
|
|
11
11
|
options: ModelOption[];
|
|
12
12
|
disabled?: boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ComponentPropsWithoutRef } from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ControlOrValue } from 'react-use-control';
|
|
3
3
|
type NumberInputProps = {
|
|
4
|
-
value?:
|
|
4
|
+
value?: ControlOrValue<number>;
|
|
5
5
|
min?: number;
|
|
6
6
|
max?: number;
|
|
7
7
|
step?: number;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ControlOrValue } from 'react-use-control';
|
|
2
2
|
type OTPInputProps = {
|
|
3
3
|
length?: number;
|
|
4
|
-
value?:
|
|
4
|
+
value?: ControlOrValue<string>;
|
|
5
5
|
onChange?: (value: string) => void;
|
|
6
6
|
className?: string;
|
|
7
7
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ComponentPropsWithoutRef } from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ControlOrValue } from 'react-use-control';
|
|
3
3
|
type PaginationProps = {
|
|
4
|
-
page?:
|
|
4
|
+
page?: ControlOrValue<number>;
|
|
5
5
|
total: number;
|
|
6
6
|
pageSize?: number;
|
|
7
7
|
size?: 'sm' | 'md' | 'lg';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ControlOrValue } from 'react-use-control';
|
|
2
2
|
type PasswordInputProps = {
|
|
3
|
-
value?:
|
|
3
|
+
value?: ControlOrValue<string>;
|
|
4
4
|
onChange?: (value: string) => void;
|
|
5
5
|
placeholder?: string;
|
|
6
6
|
disabled?: boolean;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ControlOrValue } from 'react-use-control';
|
|
3
3
|
type PopoverProps = {
|
|
4
4
|
content: ReactNode;
|
|
5
|
-
open?:
|
|
5
|
+
open?: ControlOrValue<boolean>;
|
|
6
6
|
className?: string;
|
|
7
7
|
children: ReactNode;
|
|
8
8
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ControlOrValue } from 'react-use-control';
|
|
3
3
|
type RadioGroupProps = {
|
|
4
|
-
value?:
|
|
4
|
+
value?: ControlOrValue<string>;
|
|
5
5
|
name?: string;
|
|
6
6
|
className?: string;
|
|
7
7
|
children: ReactNode;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ControlOrValue } from 'react-use-control';
|
|
2
2
|
type RatingProps = {
|
|
3
|
-
value?:
|
|
3
|
+
value?: ControlOrValue<number>;
|
|
4
4
|
count?: number;
|
|
5
5
|
allowHalf?: boolean;
|
|
6
6
|
onChange?: (value: number) => void;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ControlOrValue } from 'react-use-control';
|
|
2
2
|
import type { SegmentedOption } from './SegmentedCore';
|
|
3
3
|
type SegmentedProps = {
|
|
4
4
|
options: SegmentedOption[];
|
|
5
|
-
value?:
|
|
5
|
+
value?: ControlOrValue<string>;
|
|
6
6
|
onChange?: (value: string) => void;
|
|
7
7
|
size?: 'sm' | 'md' | 'lg';
|
|
8
8
|
className?: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ControlOrValue } from 'react-use-control';
|
|
3
3
|
type SelectProps = {
|
|
4
|
-
value?:
|
|
4
|
+
value?: ControlOrValue<string>;
|
|
5
5
|
size?: 'sm' | 'md' | 'lg';
|
|
6
6
|
children: ReactNode;
|
|
7
7
|
} & Omit<ComponentPropsWithoutRef<'select'>, 'value' | 'size'>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ComponentPropsWithoutRef } from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ControlOrValue } from 'react-use-control';
|
|
3
3
|
type SliderProps = {
|
|
4
|
-
value?:
|
|
4
|
+
value?: ControlOrValue<number>;
|
|
5
5
|
} & Omit<ComponentPropsWithoutRef<'input'>, 'type' | 'value'>;
|
|
6
6
|
export default function Slider({ value: valueControl, className, onChange, ...rest }: SliderProps): import("react").JSX.Element;
|
|
7
7
|
export type { SliderProps };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ControlOrValue } from 'react-use-control';
|
|
3
3
|
type StepperProps = {
|
|
4
|
-
activeStep?:
|
|
4
|
+
activeStep?: ControlOrValue<number>;
|
|
5
5
|
children: ReactNode;
|
|
6
6
|
className?: string;
|
|
7
7
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ComponentPropsWithoutRef } from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ControlOrValue } from 'react-use-control';
|
|
3
3
|
type SwitchProps = {
|
|
4
|
-
checked?:
|
|
4
|
+
checked?: ControlOrValue<boolean>;
|
|
5
5
|
size?: 'sm' | 'md' | 'lg';
|
|
6
6
|
} & Omit<ComponentPropsWithoutRef<'button'>, 'type' | 'checked' | 'onChange'>;
|
|
7
7
|
export default function Switch({ checked: checkedControl, size, className, onClick, ...rest }: SwitchProps): import("react").JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ControlOrValue } from 'react-use-control';
|
|
3
3
|
type TabsProps = {
|
|
4
|
-
value?:
|
|
4
|
+
value?: ControlOrValue<string>;
|
|
5
5
|
className?: string;
|
|
6
6
|
children: ReactNode;
|
|
7
7
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ControlOrValue } from 'react-use-control';
|
|
2
2
|
type TagInputProps = {
|
|
3
|
-
value?:
|
|
3
|
+
value?: ControlOrValue<string[]>;
|
|
4
4
|
onChange?: (value: string[]) => void;
|
|
5
5
|
placeholder?: string;
|
|
6
6
|
maxTags?: number;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ComponentPropsWithoutRef } from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ControlOrValue } from 'react-use-control';
|
|
3
3
|
type TextareaProps = {
|
|
4
|
-
value?:
|
|
4
|
+
value?: ControlOrValue<string>;
|
|
5
5
|
size?: 'sm' | 'md' | 'lg';
|
|
6
6
|
} & Omit<ComponentPropsWithoutRef<'textarea'>, 'value'>;
|
|
7
7
|
export default function Textarea({ value: valueControl, size, className, onChange, ...rest }: TextareaProps): import("react").JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ComponentPropsWithoutRef } from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ControlOrValue } from 'react-use-control';
|
|
3
3
|
type TimePickerProps = {
|
|
4
|
-
value?:
|
|
4
|
+
value?: ControlOrValue<string>;
|
|
5
5
|
onChange?: (value: string) => void;
|
|
6
6
|
placeholder?: string;
|
|
7
7
|
className?: string;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
+
import type { ControlOrValue } from 'react-use-control';
|
|
2
3
|
type TooltipProps = {
|
|
3
4
|
content: ReactNode;
|
|
4
5
|
position?: 'top' | 'bottom' | 'left' | 'right';
|
|
6
|
+
/** Milliseconds of hover/focus before the tooltip appears. */
|
|
7
|
+
delay?: number;
|
|
8
|
+
open?: ControlOrValue<boolean>;
|
|
5
9
|
className?: string;
|
|
6
10
|
children: ReactNode;
|
|
7
11
|
};
|
|
8
|
-
export default function Tooltip({ content, position, className, children, }: TooltipProps): import("react").JSX.Element;
|
|
12
|
+
export default function Tooltip({ content, position, delay, open: openControl, className, children, }: TooltipProps): import("react").JSX.Element;
|
|
9
13
|
export type { TooltipProps };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ControlOrValue } from 'react-use-control';
|
|
2
2
|
type TransferItem = {
|
|
3
3
|
key: string;
|
|
4
4
|
title: string;
|
|
@@ -6,7 +6,7 @@ type TransferItem = {
|
|
|
6
6
|
};
|
|
7
7
|
type TransferProps = {
|
|
8
8
|
dataSource: TransferItem[];
|
|
9
|
-
targetKeys?:
|
|
9
|
+
targetKeys?: ControlOrValue<string[]>;
|
|
10
10
|
onChange?: (targetKeys: string[], direction: 'left' | 'right', moveKeys: string[]) => void;
|
|
11
11
|
className?: string;
|
|
12
12
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ControlOrValue } from 'react-use-control';
|
|
3
3
|
/**
|
|
4
4
|
* Tree 节点数据接口
|
|
5
5
|
*/
|
|
@@ -63,11 +63,11 @@ export type TreeProps = {
|
|
|
63
63
|
/** 自定义节点图标渲染 */
|
|
64
64
|
iconRender?: (node: TreeNodeData) => ReactNode;
|
|
65
65
|
/** (受控)展开的节点 */
|
|
66
|
-
expandedKeys?:
|
|
66
|
+
expandedKeys?: ControlOrValue<string[]>;
|
|
67
67
|
/** (受控)选中的节点 */
|
|
68
|
-
selectedKeys?:
|
|
68
|
+
selectedKeys?: ControlOrValue<string[]>;
|
|
69
69
|
/** (受控)复选的节点 */
|
|
70
|
-
checkedKeys?:
|
|
70
|
+
checkedKeys?: ControlOrValue<string[]>;
|
|
71
71
|
/** 自定义类名 */
|
|
72
72
|
className?: string;
|
|
73
73
|
/** 展开/收起回调 */
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
1
|
+
import type { ComponentType, ReactNode } from 'react';
|
|
2
2
|
import type { FieldError, FieldPath, FieldRules, Name, ValidationMode, FormInstance, PathValueOf } from 'react-f0rm';
|
|
3
3
|
/**
|
|
4
4
|
* Field-level validator, structurally compatible with react-f0rm's
|
|
5
5
|
* `Validator`: return an error (string, FieldError, or an array mixing
|
|
6
6
|
* both) or `undefined` when valid; return a Promise for async validation.
|
|
7
7
|
* `meta.signal` aborts as soon as the round is superseded.
|
|
8
|
+
*
|
|
9
|
+
* Generic like react-f0rm's own `useField` `validate`: with `form` (a
|
|
10
|
+
* `FormInstance<TValues>`) and `name` (a `FieldPath<TValues>`) in scope,
|
|
11
|
+
* the value argument is `PathValueOf<TValues, P>` — the field's actual
|
|
12
|
+
* type — instead of `any`. The bare defaults keep untyped call sites
|
|
13
|
+
* exactly as permissive as before.
|
|
8
14
|
*/
|
|
9
|
-
export type FieldValidator = (value:
|
|
15
|
+
export type FieldValidator<TValues extends Record<string, any> = any, P extends FieldPath<TValues> | Name = Name> = (value: PathValueOf<TValues, P>, meta: {
|
|
10
16
|
form: FormInstance;
|
|
11
17
|
signal: AbortSignal;
|
|
12
18
|
}) => string | FieldError | (string | FieldError)[] | undefined | Promise<string | FieldError | (string | FieldError)[] | undefined>;
|
|
@@ -32,13 +38,38 @@ export type FormItemBinding<TValues, P extends FieldPath<TValues> | Name> = {
|
|
|
32
38
|
* react-f0rm's built-in Field/Checkbox/Select. */
|
|
33
39
|
onChange: (next: PathValueOf<TValues, P>) => void;
|
|
34
40
|
};
|
|
41
|
+
/**
|
|
42
|
+
* Declarative `as` binding for `FormItem` — the same props shape as
|
|
43
|
+
* react-f0rm `Field`'s `as` (deliberately *not* Radix's `asChild`): pass
|
|
44
|
+
* any component as the field control and `FormItem` wires the id, aria
|
|
45
|
+
* attributes, `onBlur` and `onChange` itself.
|
|
46
|
+
*/
|
|
47
|
+
export type FormItemAsProps = {
|
|
48
|
+
/** Component rendered as the field control. When provided it takes
|
|
49
|
+
* precedence over the children render-prop. */
|
|
50
|
+
as?: ComponentType<any>;
|
|
51
|
+
/** Extra props spread onto the `as` component. They land before the
|
|
52
|
+
* value props, so `value`/`valueToProps` win conflicts — the same
|
|
53
|
+
* precedence react-f0rm's `Field` uses. */
|
|
54
|
+
asProps?: Record<string, any>;
|
|
55
|
+
/** Converts what the `as` component passes to its `onChange` into the
|
|
56
|
+
* field value. Defaults to identity — haze cores' `onChange` emits the
|
|
57
|
+
* next plain value; pass `(e) => e.target.value` when `as` is a raw
|
|
58
|
+
* DOM-element component. */
|
|
59
|
+
eventToValue?: (e: any) => any;
|
|
60
|
+
/** Derives the value props for the `as` component from the field value —
|
|
61
|
+
* e.g. `(checked) => ({checked})` for `CheckboxCore`. Defaults to
|
|
62
|
+
* passing `{value}`. */
|
|
63
|
+
valueToProps?: (value: any) => Record<string, any>;
|
|
64
|
+
};
|
|
35
65
|
export type FormItemProps<TValues extends Record<string, any> = any, P extends FieldPath<TValues> | Name = Name> = {
|
|
36
66
|
form: FormInstance<TValues>;
|
|
37
67
|
name: P;
|
|
38
68
|
label?: ReactNode;
|
|
39
69
|
/** Field-level validator, registered through react-f0rm's own
|
|
40
|
-
* `useField` channel — validated per the form's `mode` and on submit.
|
|
41
|
-
|
|
70
|
+
* `useField` channel — validated per the form's `mode` and on submit.
|
|
71
|
+
* With a typed form the value argument is `PathValueOf<TValues, P>`. */
|
|
72
|
+
validate?: FieldValidator<TValues, P>;
|
|
42
73
|
/** Per-field validation mode override (react-f0rm ≥0.6): when given,
|
|
43
74
|
* this field validates on its own schedule — e.g. `'onBlur'` — instead
|
|
44
75
|
* of the form's `mode`; other fields are unaffected. Omit to keep the
|
|
@@ -61,9 +92,19 @@ export type FormItemProps<TValues extends Record<string, any> = any, P extends F
|
|
|
61
92
|
* `validate` — both sources' errors merge, rules errors ahead. Omit for
|
|
62
93
|
* `validate`-only validation. */
|
|
63
94
|
rules?: FieldRules;
|
|
95
|
+
/** Custom error renderer: when provided and the field has errors, the
|
|
96
|
+
* built-in error span renders `renderError(errors[0].message, errorId)`
|
|
97
|
+
* instead of the bare message. The span itself — id, `role='alert'`,
|
|
98
|
+
* styling — stays FormItem's, in both the `as` and children modes. */
|
|
99
|
+
renderError?: (error: string, id: string) => ReactNode;
|
|
64
100
|
className?: string;
|
|
101
|
+
} & FormItemAsProps & ({
|
|
102
|
+
as: ComponentType<any>;
|
|
103
|
+
children?: never;
|
|
104
|
+
} | {
|
|
105
|
+
as?: undefined;
|
|
65
106
|
children: (binding: FormItemBinding<TValues, P>) => ReactNode;
|
|
66
|
-
};
|
|
107
|
+
});
|
|
67
108
|
/**
|
|
68
109
|
* Glue a single field of a react-f0rm form to a haze-ui controlled core.
|
|
69
110
|
* The binding layer is react-f0rm's own headless `useField` hook — the
|
|
@@ -85,8 +126,23 @@ export type FormItemProps<TValues extends Record<string, any> = any, P extends F
|
|
|
85
126
|
* </FormItem>
|
|
86
127
|
* ```
|
|
87
128
|
*
|
|
129
|
+
* Or declaratively, react-f0rm `Field`-style (`as` and children are
|
|
130
|
+
* mutually exclusive — pick one):
|
|
131
|
+
*
|
|
132
|
+
* ```tsx
|
|
133
|
+
* <FormItem form={form} name='email' label='Email' as={InputCore} />
|
|
134
|
+
* ```
|
|
135
|
+
*
|
|
136
|
+
* With `as`, the id/aria/onBlur/onChange wiring happens here: the control
|
|
137
|
+
* gets `id`, `aria-invalid`/`aria-describedby` while the field errors,
|
|
138
|
+
* and `onChange={(v) => onChange(toValue(v))}` where `toValue` defaults
|
|
139
|
+
* to identity (haze cores emit plain values — pass
|
|
140
|
+
* `eventToValue={(e) => e.target.value}` for a raw DOM element) and the
|
|
141
|
+
* value lands as `{value}` or, with `valueToProps`, whatever props the
|
|
142
|
+
* control wants (e.g. `{checked}` for CheckboxCore).
|
|
143
|
+
*
|
|
88
144
|
* When the field has errors, the first error's message is rendered into a
|
|
89
|
-
* `<span id={errorId} role='alert'>` next to the
|
|
145
|
+
* `<span id={errorId} role='alert'>` next to the control; with no errors
|
|
90
146
|
* no extra element is rendered.
|
|
91
147
|
*/
|
|
92
|
-
export default function FormItem<TValues extends Record<string, any> = any, P extends FieldPath<TValues> | Name = Name>({ form, name, label, validate, mode, validateDebounce, delayError, rules, className, children }: FormItemProps<TValues, P>): import("react").JSX.Element;
|
|
148
|
+
export default function FormItem<TValues extends Record<string, any> = any, P extends FieldPath<TValues> | Name = Name>({ form, name, label, validate, mode, validateDebounce, delayError, rules, className, renderError, as: As, asProps, eventToValue, valueToProps, children }: FormItemProps<TValues, P>): import("react").JSX.Element;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { default as FormItem } from './FormItem';
|
|
2
|
-
export type { FieldValidator, FormItemBinding, FormItemProps } from './FormItem';
|
|
2
|
+
export type { FieldValidator, FormItemAsProps, FormItemBinding, FormItemProps } from './FormItem';
|
|
3
3
|
export type { FormInstance, PathValueOf } from 'react-f0rm';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -182,5 +182,6 @@ export type { DiffViewerProps, DiffLine } from './components/DiffViewer';
|
|
|
182
182
|
export { LogViewer } from './components/LogViewer';
|
|
183
183
|
export type { LogViewerProps, LogEntry, LogLevel } from './components/LogViewer';
|
|
184
184
|
export { FormItem } from './form';
|
|
185
|
-
export type { FieldValidator, FormItemBinding, FormItemProps, FormInstance, PathValueOf, } from './form';
|
|
185
|
+
export type { FieldValidator, FormItemAsProps, FormItemBinding, FormItemProps, FormInstance, PathValueOf, } from './form';
|
|
186
186
|
export { useControl } from 'react-use-control';
|
|
187
|
+
export type { Control, ControlOrValue } from 'react-use-control';
|