Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

refactor(dify-ui): export Base UI event types under component names (#43876)

yyh7068d0d60ab1
diff --git a/packages/dify-ui/README.md b/packages/dify-ui/README.md
index 44c1bee059e..223aecf4061 100644
--- a/packages/dify-ui/README.md
+++ b/packages/dify-ui/README.md
@@ -54,6 +54,7 @@ Utilities:
- `./cn` re-exports `cn` from the `cn` package through Dify UI's public subpath.
- `./use-merged-refs` exports `useMergedRefs` for combining internal and caller refs, including callback cleanup.
- `./use-ref-with-init` exports `useRefWithInit` for lazy ref initialization. Later initializer or argument changes do not reset the ref; initialization runs during render and must be safe to retry or discard.
+- `./use-render` exports `useRender` for building a part with Base UI's `render` prop, `className(state)` callback and state data attributes; `./merge-props` exports `mergeProps` for chaining event handlers and merging `className`/`style` when composing parts.
- `./styles.css` provides design tokens, theme variables, and shared utilities.
## Guides
diff --git a/packages/dify-ui/docs/authoring.md b/packages/dify-ui/docs/authoring.md
index 2540bebff7d..0a8691f9718 100644
--- a/packages/dify-ui/docs/authoring.md
+++ b/packages/dify-ui/docs/authoring.md
@@ -5,6 +5,12 @@ module-local and publish the complete surface through separate `export { ... }`
`export type { ... }` manifests at the bottom of the file. Do not mix scattered inline exports
with the manifest or use wildcard exports.
+## Base UI imports
+
+Import a Base UI part once per module and read its types from that binding's namespace, such as
+`BaseRadio.Root.Props`. Use `import type` only when the module has no runtime use of the part. Do
+not keep a value import and a type import of the same module side by side.
+
## React imports
Use React namespace imports throughout this package, including stories and tests. Use
@@ -62,9 +68,13 @@ A type is not public merely because Base UI names it or an implementation once e
addition to matching component props, export a type only when it pairs with a public factory or a
real consumer must name it independently.
-State, event details and reasons, controlled-state helpers, context values, render helpers,
-styling helpers, and upstream passthrough aliases are private by default. Public props
-already provide contextual typing for inline render and event callbacks.
+State, controlled-state helpers, context values, render helpers, styling helpers, and upstream
+passthrough aliases are private by default. Public props already provide contextual typing for
+inline render and event callbacks.
+
+Event details and reasons are the exception. A component that aliases or wraps a Base UI part
+re-exports that part's `*EventDetails` and `*EventReason` types under its own name. A composite
+that only uses a part internally does not. `State` and enum namespaces stay private.
Preserve upstream `className` and `style` callbacks. Resolve `className` with the owning Base UI
part's state before merging default classes with `cn()`, including through composite wrappers.
diff --git a/packages/dify-ui/package.json b/packages/dify-ui/package.json
index 4bb1321d102..80f24c1b82d 100644
--- a/packages/dify-ui/package.json
+++ b/packages/dify-ui/package.json
@@ -17,6 +17,14 @@
"types": "./src/use-ref-with-init.ts",
"import": "./src/use-ref-with-init.ts"
},
+ "./use-render": {
+ "types": "./src/use-render.ts",
+ "import": "./src/use-render.ts"
+ },
+ "./merge-props": {
+ "types": "./src/merge-props.ts",
+ "import": "./src/merge-props.ts"
+ },
"./alert-dialog": {
"types": "./src/alert-dialog/index.tsx",
"import": "./src/alert-dialog/index.tsx"
diff --git a/packages/dify-ui/src/alert-dialog/__tests__/types.tsx b/packages/dify-ui/src/alert-dialog/__tests__/types.tsx
index 439d467cb70..ac73e335063 100644
--- a/packages/dify-ui/src/alert-dialog/__tests__/types.tsx
+++ b/packages/dify-ui/src/alert-dialog/__tests__/types.tsx
@@ -1,5 +1,13 @@
-import type { AlertDialogActions, AlertDialogProps } from '@langgenius/dify-ui/alert-dialog'
-import { AlertDialog } from '@langgenius/dify-ui/alert-dialog'
+import type {
+ AlertDialogActions,
+ AlertDialogHandle,
+ AlertDialogProps,
+} from '@langgenius/dify-ui/alert-dialog'
+import {
+ AlertDialog,
+ AlertDialogTrigger,
+ createAlertDialogHandle,
+} from '@langgenius/dify-ui/alert-dialog'
import * as React from 'react'
import { expectTypeOf } from 'vite-plus/test'
@@ -10,3 +18,30 @@ export function alertDialogActionsTypeContract() {
>()
return <AlertDialog actionsRef={actionsRef} />
}
+
+type Payload = { documentId: string }
+
+export function alertDialogHandleTypeContracts() {
+ const handle = createAlertDialogHandle<Payload>()
+ expectTypeOf(handle).toEqualTypeOf<AlertDialogHandle<Payload>>()
+ const trigger = (
+ <AlertDialogTrigger handle={handle} payload={{ documentId: 'document-1' }}>
+ Delete
+ </AlertDialogTrigger>
+ )
+ const dialog = (
+ <AlertDialog handle={handle}>
+ {({ payload }) => {
+ expectTypeOf(payload).toEqualTypeOf<Payload | undefined>()
+ return <span>{payload?.documentId}</span>
+ }}
+ </AlertDialog>
+ )
+ const invalid = (
+ // @ts-expect-error Detached triggers preserve the handle payload contract.
+ <AlertDialogTrigger handle={handle} payload={{ documentId: 1 }}>
+ Delete
+ </AlertDialogTrigger>
+ )
+ return { trigger, dialog, invalid }
+}
diff --git a/packages/dify-ui/src/alert-dialog/index.tsx b/packages/dify-ui/src/alert-dialog/index.tsx
index 9f51c5f3a67..f25ea6bec82 100644
--- a/packages/dify-ui/src/alert-dialog/index.tsx
+++ b/packages/dify-ui/src/alert-dialog/index.tsx
@@ -15,10 +15,14 @@ import {
const AlertDialog = BaseAlertDialog.Root
const AlertDialogTitle = BaseAlertDialog.Title
const AlertDialogDescription = BaseAlertDialog.Description
+const createAlertDialogHandle = BaseAlertDialog.createHandle
type AlertDialogActions = BaseAlertDialog.Root.Actions
+type AlertDialogChangeEventReason = BaseAlertDialog.Root.ChangeEventReason
+type AlertDialogChangeEventDetails = BaseAlertDialog.Root.ChangeEventDetails
type AlertDialogProps<Payload = unknown> = BaseAlertDialog.Root.Props<Payload>
+type AlertDialogHandle<Payload = unknown> = BaseAlertDialog.Handle<Payload>
type AlertDialogTriggerProps<Payload = unknown> = BaseAlertDialog.Trigger.Props<Payload>
function AlertDialogTrigger<Payload = unknown>({
@@ -114,15 +118,19 @@ export {
AlertDialogFooter,
AlertDialogTitle,
AlertDialogTrigger,
+ createAlertDialogHandle,
}
export type {
AlertDialogActions,
AlertDialogCancelButtonProps,
+ AlertDialogChangeEventDetails,
+ AlertDialogChangeEventReason,
AlertDialogConfirmButtonProps,
AlertDialogContentProps,
AlertDialogDescriptionProps,
AlertDialogFooterProps,
+ AlertDialogHandle,
AlertDialogProps,
AlertDialogTitleProps,
AlertDialogTriggerProps,
diff --git a/packages/dify-ui/src/autocomplete/index.tsx b/packages/dify-ui/src/autocomplete/index.tsx
index a7599c2e5e4..23710b37462 100644
--- a/packages/dify-ui/src/autocomplete/index.tsx
+++ b/packages/dify-ui/src/autocomplete/index.tsx
@@ -19,8 +19,11 @@ import { parsePlacement } from '../placement'
type AutocompleteActions = BaseAutocomplete.Root.Actions
type AutocompleteProps<ItemValue> = BaseAutocomplete.Root.Props<ItemValue>
+type AutocompleteChangeEventReason = BaseAutocomplete.Root.ChangeEventReason
type AutocompleteChangeEventDetails = BaseAutocomplete.Root.ChangeEventDetails
type AutocompleteOpenChangeEventDetails = BaseAutocomplete.Root.OpenChangeEventDetails
+type AutocompleteHighlightEventReason = BaseAutocomplete.Root.HighlightEventReason
+type AutocompleteHighlightEventDetails = BaseAutocomplete.Root.HighlightEventDetails
type AutocompleteGroupedProps<Items extends readonly { items: readonly unknown[] }[]> = Omit<
AutocompleteProps<Items[number]['items'][number]>,
'items'
@@ -439,6 +442,7 @@ export {
export type {
AutocompleteActions,
AutocompleteChangeEventDetails,
+ AutocompleteChangeEventReason,
AutocompleteClearProps,
AutocompleteCollectionProps,
AutocompleteEmptyProps,
@@ -446,6 +450,8 @@ export type {
AutocompleteGroupedProps,
AutocompleteGroupLabelProps,
AutocompleteGroupProps,
+ AutocompleteHighlightEventDetails,
+ AutocompleteHighlightEventReason,
AutocompleteIconProps,
AutocompleteInputGroupProps,
AutocompleteInputProps,
diff --git a/packages/dify-ui/src/button/index.tsx b/packages/dify-ui/src/button/index.tsx
index 40f1bdb7b02..72278558630 100644
--- a/packages/dify-ui/src/button/index.tsx
+++ b/packages/dify-ui/src/button/index.tsx
@@ -1,6 +1,5 @@
'use client'
-import type { Button as BaseButtonNS } from '@base-ui/react/button'
import type { VariantProps } from 'class-variance-authority'
import { Button as BaseButton } from '@base-ui/react/button'
import { cva } from 'class-variance-authority'
@@ -104,7 +103,7 @@ const buttonVariants = cva(
},
)
-type ButtonProps = BaseButtonNS.Props &
+type ButtonProps = BaseButton.Props &
VariantProps<typeof buttonVariants> & {
/**
* Marks an action as pending, blocks activation, and keeps the button focusable by default.
diff --git a/packages/dify-ui/src/checkbox-group/index.tsx b/packages/dify-ui/src/checkbox-group/index.tsx
index a080d0b1788..fb188dbc426 100644
--- a/packages/dify-ui/src/checkbox-group/index.tsx
+++ b/packages/dify-ui/src/checkbox-group/index.tsx
@@ -1,11 +1,12 @@
'use client'
-import type { CheckboxGroup as BaseCheckboxGroupNS } from '@base-ui/react/checkbox-group'
import { CheckboxGroup as BaseCheckboxGroup } from '@base-ui/react/checkbox-group'
-type CheckboxGroupProps = BaseCheckboxGroupNS.Props
+type CheckboxGroupProps = BaseCheckboxGroup.Props
+type CheckboxGroupChangeEventReason = BaseCheckboxGroup.ChangeEventReason
+type CheckboxGroupChangeEventDetails = BaseCheckboxGroup.ChangeEventDetails
const CheckboxGroup = BaseCheckboxGroup
export { CheckboxGroup }
-export type { CheckboxGroupProps }
+export type { CheckboxGroupChangeEventDetails, CheckboxGroupChangeEventReason, CheckboxGroupProps }
diff --git a/packages/dify-ui/src/checkbox/index.tsx b/packages/dify-ui/src/checkbox/index.tsx
index d3d8032920a..64e95196e96 100644
--- a/packages/dify-ui/src/checkbox/index.tsx
+++ b/packages/dify-ui/src/checkbox/index.tsx
@@ -1,6 +1,5 @@
'use client'
-import type { Checkbox as BaseCheckboxNS } from '@base-ui/react/checkbox'
import type * as React from 'react'
import { Checkbox as BaseCheckbox } from '@base-ui/react/checkbox'
import { cn } from '../cn'
@@ -27,7 +26,9 @@ const checkboxIndicatorClassName =
const checkboxSkeletonClassName = 'size-4 shrink-0 rounded-sm bg-text-quaternary opacity-20'
-type CheckboxProps = Omit<BaseCheckboxNS.Root.Props, 'children'>
+type CheckboxProps = Omit<BaseCheckbox.Root.Props, 'children'>
+type CheckboxChangeEventReason = BaseCheckbox.Root.ChangeEventReason
+type CheckboxChangeEventDetails = BaseCheckbox.Root.ChangeEventDetails
function Checkbox({ className, ...props }: CheckboxProps) {
return (
@@ -61,4 +62,9 @@ function CheckboxSkeleton({ className, ...props }: CheckboxSkeletonProps) {
export { Checkbox, CheckboxSkeleton }
-export type { CheckboxProps, CheckboxSkeletonProps }
+export type {
+ CheckboxChangeEventDetails,
+ CheckboxChangeEventReason,
+ CheckboxProps,
+ CheckboxSkeletonProps,
+}
diff --git a/packages/dify-ui/src/collapsible/index.tsx b/packages/dify-ui/src/collapsible/index.tsx
index f98a196f2a2..80c5c172790 100644
--- a/packages/dify-ui/src/collapsible/index.tsx
+++ b/packages/dify-ui/src/collapsible/index.tsx
@@ -1,12 +1,13 @@
'use client'
-import type { Collapsible as BaseCollapsibleNS } from '@base-ui/react/collapsible'
import { Collapsible as BaseCollapsible } from '@base-ui/react/collapsible'
import { cn } from '../cn'
import { resolveClassName } from '../internals/resolve-class-name'
import { triggerFocusClassName } from '../overlay-shared'
-type CollapsibleProps = BaseCollapsibleNS.Root.Props
+type CollapsibleProps = BaseCollapsible.Root.Props
+type CollapsibleChangeEventReason = BaseCollapsible.Root.ChangeEventReason
+type CollapsibleChangeEventDetails = BaseCollapsible.Root.ChangeEventDetails
function Collapsible({ className, ...props }: CollapsibleProps) {
return (
<BaseCollapsible.Root
@@ -16,7 +17,7 @@ function Collapsible({ className, ...props }: CollapsibleProps) {
)
}
-type CollapsibleTriggerProps = BaseCollapsibleNS.Trigger.Props
+type CollapsibleTriggerProps = BaseCollapsible.Trigger.Props
function CollapsibleTrigger({ className, ...props }: CollapsibleTriggerProps) {
return (
<BaseCollapsible.Trigger
@@ -26,7 +27,7 @@ function CollapsibleTrigger({ className, ...props }: CollapsibleTriggerProps) {
)
}
-type CollapsiblePanelProps = BaseCollapsibleNS.Panel.Props
+type CollapsiblePanelProps = BaseCollapsible.Panel.Props
function CollapsiblePanel({ className, ...props }: CollapsiblePanelProps) {
return (
<BaseCollapsible.Panel
@@ -45,4 +46,10 @@ function CollapsiblePanel({ className, ...props }: CollapsiblePanelProps) {
export { Collapsible, CollapsiblePanel, CollapsibleTrigger }
-export type { CollapsiblePanelProps, CollapsibleProps, CollapsibleTriggerProps }
+export type {
+ CollapsibleChangeEventDetails,
+ CollapsibleChangeEventReason,
+ CollapsiblePanelProps,
+ CollapsibleProps,
+ CollapsibleTriggerProps,
+}
diff --git a/packages/dify-ui/src/combobox/index.tsx b/packages/dify-ui/src/combobox/index.tsx
index 1aa597825b6..7949828c0cd 100644
--- a/packages/dify-ui/src/combobox/index.tsx
+++ b/packages/dify-ui/src/combobox/index.tsx
@@ -25,8 +25,11 @@ type ComboboxProps<
Item = Value,
> = BaseCombobox.Root.Props<Value, Multiple, Item> &
([Multiple] extends [true] ? { multiple: true } : unknown)
+type ComboboxChangeEventReason = BaseCombobox.Root.ChangeEventReason
type ComboboxChangeEventDetails = BaseCombobox.Root.ChangeEventDetails
type ComboboxOpenChangeEventDetails = BaseCombobox.Root.OpenChangeEventDetails
+type ComboboxHighlightEventReason = BaseCombobox.Root.HighlightEventReason
+type ComboboxHighlightEventDetails = BaseCombobox.Root.HighlightEventDetails
function Combobox<Value, Multiple extends boolean | undefined = false, Item = Value>(
props: ComboboxProps<Value, Multiple, Item>,
@@ -533,6 +536,7 @@ export {
export type {
ComboboxActions,
ComboboxChangeEventDetails,
+ ComboboxChangeEventReason,
ComboboxChipProps,
ComboboxChipRemoveProps,
ComboboxChipsProps,
@@ -541,6 +545,8 @@ export type {
ComboboxEmptyProps,
ComboboxGroupLabelProps,
ComboboxGroupProps,
+ ComboboxHighlightEventDetails,
+ ComboboxHighlightEventReason,
ComboboxIconProps,
ComboboxInputGroupProps,
ComboboxInputProps,
diff --git a/packages/dify-ui/src/context-menu/index.tsx b/packages/dify-ui/src/context-menu/index.tsx
index a5d119625ad..b17287b46e7 100644
--- a/packages/dify-ui/src/context-menu/index.tsx
+++ b/packages/dify-ui/src/context-menu/index.tsx
@@ -23,18 +23,21 @@ const ContextMenuSub = BaseContextMenu.SubmenuRoot
const ContextMenuGroup = BaseContextMenu.Group
type ContextMenuProps = BaseContextMenu.Root.Props
type ContextMenuActions = BaseContextMenu.Root.Actions
+type ContextMenuChangeEventReason = BaseContextMenu.Root.ChangeEventReason
+type ContextMenuChangeEventDetails = BaseContextMenu.Root.ChangeEventDetails
type ContextMenuTriggerProps = BaseContextMenu.Trigger.Props
type ContextMenuSubProps = BaseContextMenu.SubmenuRoot.Props
+type ContextMenuSubChangeEventReason = BaseContextMenu.SubmenuRoot.ChangeEventReason
+type ContextMenuSubChangeEventDetails = BaseContextMenu.SubmenuRoot.ChangeEventDetails
type ContextMenuGroupProps = BaseContextMenu.Group.Props
+type ContextMenuRadioGroupChangeEventReason = BaseContextMenu.RadioGroup.ChangeEventReason
+type ContextMenuRadioGroupChangeEventDetails = BaseContextMenu.RadioGroup.ChangeEventDetails
type ContextMenuRadioGroupProps<Value = unknown> = Omit<
BaseContextMenu.RadioGroup.Props,
'defaultValue' | 'onValueChange' | 'value'
> & {
defaultValue?: Value
- onValueChange?: (
- value: Value,
- eventDetails: BaseContextMenu.RadioGroup.ChangeEventDetails,
- ) => void
+ onValueChange?: (value: Value, eventDetails: ContextMenuRadioGroupChangeEventDetails) => void
value?: Value
}
type ContextMenuItemVariant = MenuItemVariant
@@ -152,6 +155,8 @@ function ContextMenuCheckboxItem({ className, ...props }: ContextMenuCheckboxIte
}
type ContextMenuCheckboxItemProps = BaseContextMenu.CheckboxItem.Props
+type ContextMenuCheckboxItemChangeEventReason = BaseContextMenu.CheckboxItem.ChangeEventReason
+type ContextMenuCheckboxItemChangeEventDetails = BaseContextMenu.CheckboxItem.ChangeEventDetails
function ContextMenuCheckboxItemIndicator({
className,
@@ -299,6 +304,10 @@ export {
export type {
ContextMenuActions,
+ ContextMenuChangeEventDetails,
+ ContextMenuChangeEventReason,
+ ContextMenuCheckboxItemChangeEventDetails,
+ ContextMenuCheckboxItemChangeEventReason,
ContextMenuCheckboxItemIndicatorProps,
ContextMenuCheckboxItemProps,
ContextMenuContentProps,
@@ -307,10 +316,14 @@ export type {
ContextMenuItemProps,
ContextMenuLinkItemProps,
ContextMenuProps,
+ ContextMenuRadioGroupChangeEventDetails,
+ ContextMenuRadioGroupChangeEventReason,
ContextMenuRadioGroupProps,
ContextMenuRadioItemIndicatorProps,
ContextMenuRadioItemProps,
ContextMenuSeparatorProps,
+ ContextMenuSubChangeEventDetails,
+ ContextMenuSubChangeEventReason,
ContextMenuSubContentProps,
ContextMenuSubProps,
ContextMenuSubTriggerProps,
diff --git a/packages/dify-ui/src/dialog/index.tsx b/packages/dify-ui/src/dialog/index.tsx
index 61b38faf723..2e2057dcdac 100644
--- a/packages/dify-ui/src/dialog/index.tsx
+++ b/packages/dify-ui/src/dialog/index.tsx
@@ -18,6 +18,8 @@ const DialogClose = BaseDialog.Close
const createDialogHandle = BaseDialog.createHandle
type DialogActions = BaseDialog.Root.Actions
+type DialogChangeEventReason = BaseDialog.Root.ChangeEventReason
+type DialogChangeEventDetails = BaseDialog.Root.ChangeEventDetails
type DialogProps<Payload = unknown> = BaseDialog.Root.Props<Payload>
type DialogHandle<Payload = unknown> = BaseDialog.Handle<Payload>
@@ -116,6 +118,8 @@ export {
export type {
DialogActions,
DialogBackdropProps,
+ DialogChangeEventDetails,
+ DialogChangeEventReason,
DialogCloseProps,
DialogContentProps,
DialogDescriptionProps,
diff --git a/packages/dify-ui/src/drawer/index.tsx b/packages/dify-ui/src/drawer/index.tsx
index fbfe86c5b61..d40338b8fae 100644
--- a/packages/dify-ui/src/drawer/index.tsx
+++ b/packages/dify-ui/src/drawer/index.tsx
@@ -17,6 +17,10 @@ const DrawerClose = BaseDrawer.Close
const createDrawerHandle = BaseDrawer.createHandle
type DrawerActions = BaseDrawer.Root.Actions
+type DrawerChangeEventReason = BaseDrawer.Root.ChangeEventReason
+type DrawerChangeEventDetails = BaseDrawer.Root.ChangeEventDetails
+type DrawerSnapPointChangeEventReason = BaseDrawer.Root.SnapPointChangeEventReason
+type DrawerSnapPointChangeEventDetails = BaseDrawer.Root.SnapPointChangeEventDetails
type DrawerProps<Payload = unknown> = BaseDrawer.Root.Props<Payload>
type DrawerHandle<Payload = unknown> = BaseDrawer.Handle<Payload>
@@ -134,6 +138,8 @@ export {
export type {
DrawerActions,
DrawerBackdropProps,
+ DrawerChangeEventDetails,
+ DrawerChangeEventReason,
DrawerCloseProps,
DrawerContentProps,
DrawerDescriptionProps,
@@ -144,6 +150,8 @@ export type {
DrawerPortalProps,
DrawerProps,
DrawerProviderProps,
+ DrawerSnapPointChangeEventDetails,
+ DrawerSnapPointChangeEventReason,
DrawerSwipeAreaProps,
DrawerTitleProps,
DrawerTriggerProps,
diff --git a/packages/dify-ui/src/dropdown-menu/index.tsx b/packages/dify-ui/src/dropdown-menu/index.tsx
index bc7d62a8b03..ed3a1c8175c 100644
--- a/packages/dify-ui/src/dropdown-menu/index.tsx
+++ b/packages/dify-ui/src/dropdown-menu/index.tsx
@@ -36,6 +36,10 @@ const useDropdownMenuFilter = Menu.useFilter
type DropdownMenuHandle<Payload = unknown> = Menu.Handle<Payload>
type DropdownMenuActions = Menu.Root.Actions
+type DropdownMenuChangeEventReason = Menu.Root.ChangeEventReason
+type DropdownMenuChangeEventDetails = Menu.Root.ChangeEventDetails
+type DropdownMenuHighlightEventReason = Menu.Root.HighlightEventReason
+type DropdownMenuHighlightEventDetails = Menu.Root.HighlightEventDetails
type DropdownMenuProps<Payload = unknown> = Menu.Root.Props<Payload>
type DropdownMenuTriggerProps<Payload = unknown> = Menu.Trigger.Props<Payload>
@@ -53,8 +57,12 @@ function DropdownMenuTrigger<Payload = unknown>({
}
type DropdownMenuPortalProps = Menu.Portal.Props
type DropdownMenuSubProps = Menu.SubmenuRoot.Props
+type DropdownMenuSubChangeEventReason = Menu.SubmenuRoot.ChangeEventReason
+type DropdownMenuSubChangeEventDetails = Menu.SubmenuRoot.ChangeEventDetails
type DropdownMenuGroupProps = Menu.Group.Props
type DropdownMenuFilterProviderProps = Menu.FilterProvider.Props
+type DropdownMenuFilterProviderChangeEventReason = Menu.FilterProvider.ChangeEventReason
+type DropdownMenuFilterProviderChangeEventDetails = Menu.FilterProvider.ChangeEventDetails
type DropdownMenuInputGroupProps = InputGroupProps
@@ -145,12 +153,14 @@ function DropdownMenuList({ className, ...props }: DropdownMenuListProps) {
/>
)
}
+type DropdownMenuRadioGroupChangeEventReason = Menu.RadioGroup.ChangeEventReason
+type DropdownMenuRadioGroupChangeEventDetails = Menu.RadioGroup.ChangeEventDetails
type DropdownMenuRadioGroupProps<Value = unknown> = Omit<
Menu.RadioGroup.Props,
'defaultValue' | 'onValueChange' | 'value'
> & {
defaultValue?: Value
- onValueChange?: (value: Value, eventDetails: Menu.RadioGroup.ChangeEventDetails) => void
+ onValueChange?: (value: Value, eventDetails: DropdownMenuRadioGroupChangeEventDetails) => void
value?: Value
}
type DropdownMenuItemVariant = MenuItemVariant
@@ -194,6 +204,8 @@ function DropdownMenuRadioItemIndicator({
type DropdownMenuRadioItemIndicatorProps = Omit<Menu.RadioItemIndicator.Props, 'children'>
type DropdownMenuCheckboxItemProps = Menu.CheckboxItem.Props
+type DropdownMenuCheckboxItemChangeEventReason = Menu.CheckboxItem.ChangeEventReason
+type DropdownMenuCheckboxItemChangeEventDetails = Menu.CheckboxItem.ChangeEventDetails
function DropdownMenuCheckboxItem({ className, ...props }: DropdownMenuCheckboxItemProps) {
return (
@@ -447,15 +459,23 @@ export {
export type {
DropdownMenuActions,
+ DropdownMenuChangeEventDetails,
+ DropdownMenuChangeEventReason,
+ DropdownMenuCheckboxItemChangeEventDetails,
+ DropdownMenuCheckboxItemChangeEventReason,
DropdownMenuCheckboxItemIndicatorProps,
DropdownMenuCheckboxItemProps,
DropdownMenuClearProps,
DropdownMenuContentProps,
DropdownMenuEmptyProps,
+ DropdownMenuFilterProviderChangeEventDetails,
+ DropdownMenuFilterProviderChangeEventReason,
DropdownMenuFilterProviderProps,
DropdownMenuGroupLabelProps,
DropdownMenuGroupProps,
DropdownMenuHandle,
+ DropdownMenuHighlightEventDetails,
+ DropdownMenuHighlightEventReason,
DropdownMenuInputGroupProps,
DropdownMenuInputProps,
DropdownMenuItemProps,
@@ -465,10 +485,14 @@ export type {
DropdownMenuPortalProps,
DropdownMenuPositionerProps,
DropdownMenuProps,
+ DropdownMenuRadioGroupChangeEventDetails,
+ DropdownMenuRadioGroupChangeEventReason,
DropdownMenuRadioGroupProps,
DropdownMenuRadioItemIndicatorProps,
DropdownMenuRadioItemProps,
DropdownMenuSeparatorProps,
+ DropdownMenuSubChangeEventDetails,
+ DropdownMenuSubChangeEventReason,
DropdownMenuSubContentProps,
DropdownMenuSubProps,
DropdownMenuSubTriggerProps,
diff --git a/packages/dify-ui/src/field/index.tsx b/packages/dify-ui/src/field/index.tsx
index b905cc0a45a..69c6d26947a 100644
--- a/packages/dify-ui/src/field/index.tsx
+++ b/packages/dify-ui/src/field/index.tsx
@@ -1,14 +1,13 @@
'use client'
-import type { Field as BaseFieldNS } from '@base-ui/react/field'
import { Field as BaseField } from '@base-ui/react/field'
import { cn } from '../cn'
import { formLabelClassName } from '../form-control-shared'
import { resolveClassName } from '../internals/resolve-class-name'
-type FieldActions = BaseFieldNS.Root.Actions
+type FieldActions = BaseField.Root.Actions
-type FieldProps = BaseFieldNS.Root.Props
+type FieldProps = BaseField.Root.Props
function Field({ className, ...props }: FieldProps) {
return (
@@ -21,7 +20,7 @@ function Field({ className, ...props }: FieldProps) {
)
}
-type FieldItemProps = BaseFieldNS.Item.Props
+type FieldItemProps = BaseField.Item.Props
function FieldItem({ className, ...props }: FieldItemProps) {
return (
@@ -32,7 +31,7 @@ function FieldItem({ className, ...props }: FieldItemProps) {
)
}
-type FieldLabelProps = BaseFieldNS.Label.Props
+type FieldLabelProps = BaseField.Label.Props
function FieldLabel({ className, ...props }: FieldLabelProps) {
return (
@@ -43,7 +42,7 @@ function FieldLabel({ className, ...props }: FieldLabelProps) {
)
}
-type FieldDescriptionProps = BaseFieldNS.Description.Props
+type FieldDescriptionProps = BaseField.Description.Props
function FieldDescription({ className, ...props }: FieldDescriptionProps) {
return (
@@ -56,7 +55,7 @@ function FieldDescription({ className, ...props }: FieldDescriptionProps) {
)
}
-type FieldErrorProps = BaseFieldNS.Error.Props
+type FieldErrorProps = BaseField.Error.Props
function FieldError({ className, ...props }: FieldErrorProps) {
return (
@@ -69,7 +68,7 @@ function FieldError({ className, ...props }: FieldErrorProps) {
)
}
-type FieldValidityProps = BaseFieldNS.Validity.Props
+type FieldValidityProps = BaseField.Validity.Props
const FieldValidity = BaseField.Validity
diff --git a/packages/dify-ui/src/fieldset/index.tsx b/packages/dify-ui/src/fieldset/index.tsx
index 8a6acdfadb7..c981acf81cf 100644
--- a/packages/dify-ui/src/fieldset/index.tsx
+++ b/packages/dify-ui/src/fieldset/index.tsx
@@ -1,11 +1,10 @@
'use client'
-import type { Fieldset as BaseFieldsetNS } from '@base-ui/react/fieldset'
import { Fieldset as BaseFieldset } from '@base-ui/react/fieldset'
import { cn } from '../cn'
import { resolveClassName } from '../internals/resolve-class-name'
-type FieldsetProps = BaseFieldsetNS.Root.Props
+type FieldsetProps = BaseFieldset.Root.Props
function Fieldset({ className, ...props }: FieldsetProps) {
return (
@@ -16,7 +15,7 @@ function Fieldset({ className, ...props }: FieldsetProps) {
)
}
-type FieldsetLegendProps = BaseFieldsetNS.Legend.Props
+type FieldsetLegendProps = BaseFieldset.Legend.Props
function FieldsetLegend({ className, ...props }: FieldsetLegendProps) {
return (
diff --git a/packages/dify-ui/src/form/index.tsx b/packages/dify-ui/src/form/index.tsx
index c5e3b07499a..19796cd6f40 100644
--- a/packages/dify-ui/src/form/index.tsx
+++ b/packages/dify-ui/src/form/index.tsx
@@ -1,14 +1,14 @@
'use client'
-import type { Form as BaseFormNS } from '@base-ui/react/form'
import { Form as BaseForm } from '@base-ui/react/form'
const Form = BaseForm
-type FormActions = BaseFormNS.Actions
+type FormActions = BaseForm.Actions
+type FormSubmitEventReason = BaseForm.SubmitEventReason
+type FormSubmitEventDetails = BaseForm.SubmitEventDetails
-type FormProps<FormValues extends BaseFormNS.Values = BaseFormNS.Values> =
- BaseFormNS.Props<FormValues>
+type FormProps<FormValues extends BaseForm.Values = BaseForm.Values> = BaseForm.Props<FormValues>
export { Form }
-export type { FormActions, FormProps }
+export type { FormActions, FormProps, FormSubmitEventDetails, FormSubmitEventReason }
diff --git a/packages/dify-ui/src/icon-button/index.tsx b/packages/dify-ui/src/icon-button/index.tsx
index 95279b6ae55..959bab9f2f0 100644
--- a/packages/dify-ui/src/icon-button/index.tsx
+++ b/packages/dify-ui/src/icon-button/index.tsx
@@ -1,6 +1,5 @@
'use client'
-import type { Button as BaseButtonNS } from '@base-ui/react/button'
import type { VariantProps } from 'class-variance-authority'
import type * as React from 'react'
import { Button as BaseButton } from '@base-ui/react/button'
@@ -18,7 +17,7 @@ type AccessibleName =
'aria-labelledby': string
}
-type IconButtonProps = Omit<BaseButtonNS.Props, 'aria-label' | 'aria-labelledby' | 'children'> &
+type IconButtonProps = Omit<BaseButton.Props, 'aria-label' | 'aria-labelledby' | 'children'> &
AccessibleName &
VariantProps<typeof iconButtonVariants> & {
children: React.ReactElement
diff --git a/packages/dify-ui/src/infotip/index.tsx b/packages/dify-ui/src/infotip/index.tsx
index 706a256e780..9991a876b40 100644
--- a/packages/dify-ui/src/infotip/index.tsx
+++ b/packages/dify-ui/src/infotip/index.tsx
@@ -24,6 +24,8 @@ const iconSizeClassNames = {
const Infotip = BasePopover.Root
const InfotipTitle = BasePopover.Title
type InfotipActions = BasePopover.Root.Actions
+type InfotipChangeEventReason = BasePopover.Root.ChangeEventReason
+type InfotipChangeEventDetails = BasePopover.Root.ChangeEventDetails
type InfotipProps<Payload = unknown> = BasePopover.Root.Props<Payload>
type InfotipTitleProps = BasePopover.Title.Props
@@ -110,6 +112,8 @@ function InfotipContent({
export { Infotip, InfotipContent, InfotipTitle, InfotipTrigger }
export type {
InfotipActions,
+ InfotipChangeEventDetails,
+ InfotipChangeEventReason,
InfotipContentProps,
InfotipProps,
InfotipTitleProps,
diff --git a/packages/dify-ui/src/input-group/index.tsx b/packages/dify-ui/src/input-group/index.tsx
index d125f4cb507..bc1461c7c95 100644
--- a/packages/dify-ui/src/input-group/index.tsx
+++ b/packages/dify-ui/src/input-group/index.tsx
@@ -1,6 +1,5 @@
'use client'
-import type { Input as BaseInputNS } from '@base-ui/react/input'
import type { VariantProps } from 'class-variance-authority'
import type * as React from 'react'
import { Input as BaseInput } from '@base-ui/react/input'
@@ -56,7 +55,7 @@ function InputGroup({ className, onMouseDown, ...props }: InputGroupProps) {
)
}
-type InputGroupInputProps = Omit<BaseInputNS.Props, 'render' | 'size'>
+type InputGroupInputProps = Omit<BaseInput.Props, 'render' | 'size'>
function InputGroupInput({ className, ...props }: InputGroupInputProps) {
return (
diff --git a/packages/dify-ui/src/input/index.tsx b/packages/dify-ui/src/input/index.tsx
index f8995116ed0..cfd311ec82b 100644
--- a/packages/dify-ui/src/input/index.tsx
+++ b/packages/dify-ui/src/input/index.tsx
@@ -1,12 +1,13 @@
'use client'
-import type { Input as BaseInputNS } from '@base-ui/react/input'
import { Input as BaseInput } from '@base-ui/react/input'
import { cn } from '../cn'
import { textControlClassName } from '../form-control-shared'
import { resolveClassName } from '../internals/resolve-class-name'
-type InputProps = Omit<BaseInputNS.Props, 'size'>
+type InputProps = Omit<BaseInput.Props, 'size'>
+type InputChangeEventReason = BaseInput.ChangeEventReason
+type InputChangeEventDetails = BaseInput.ChangeEventDetails
function Input({ className, ...props }: InputProps) {
return (
@@ -24,4 +25,4 @@ function Input({ className, ...props }: InputProps) {
}
export { Input }
-export type { InputProps }
+export type { InputChangeEventDetails, InputChangeEventReason, InputProps }
diff --git a/packages/dify-ui/src/merge-props.ts b/packages/dify-ui/src/merge-props.ts
new file mode 100644
index 00000000000..c6f694d37f2
--- /dev/null
+++ b/packages/dify-ui/src/merge-props.ts
@@ -0,0 +1 @@
+export { mergeProps } from '@base-ui/react/merge-props'
diff --git a/packages/dify-ui/src/number-field/index.tsx b/packages/dify-ui/src/number-field/index.tsx
index f74905824b6..db5093ba91e 100644
--- a/packages/dify-ui/src/number-field/index.tsx
+++ b/packages/dify-ui/src/number-field/index.tsx
@@ -10,6 +10,10 @@ import { resolveClassName } from '../internals/resolve-class-name'
const NumberField = BaseNumberField.Root
type NumberFieldProps = BaseNumberField.Root.Props
+type NumberFieldChangeEventReason = BaseNumberField.Root.ChangeEventReason
+type NumberFieldChangeEventDetails = BaseNumberField.Root.ChangeEventDetails
+type NumberFieldCommitEventReason = BaseNumberField.Root.CommitEventReason
+type NumberFieldCommitEventDetails = BaseNumberField.Root.CommitEventDetails
const numberFieldGroupVariants = cva(
[textControlGroupClassName, 'group/number-field items-stretch overflow-hidden'],
@@ -226,6 +230,10 @@ export {
NumberFieldUnit,
}
export type {
+ NumberFieldChangeEventDetails,
+ NumberFieldChangeEventReason,
+ NumberFieldCommitEventDetails,
+ NumberFieldCommitEventReason,
NumberFieldControlsProps,
NumberFieldDecrementProps,
NumberFieldGroupProps,
diff --git a/packages/dify-ui/src/pagination/index.tsx b/packages/dify-ui/src/pagination/index.tsx
index 9245cdec8ec..f651674fe67 100644
--- a/packages/dify-ui/src/pagination/index.tsx
+++ b/packages/dify-ui/src/pagination/index.tsx
@@ -1,6 +1,5 @@
'use client'
-import type { Button as BaseButtonNS } from '@base-ui/react/button'
import { Button as BaseButton } from '@base-ui/react/button'
import { mergeProps } from '@base-ui/react/merge-props'
import { useRender } from '@base-ui/react/use-render'
@@ -210,11 +209,11 @@ function PaginationNavigation({ render, className, ...props }: PaginationNavigat
})
}
-type PaginationPreviousProps = Omit<BaseButtonNS.Props, 'children'> & {
+type PaginationPreviousProps = Omit<BaseButton.Props, 'children'> & {
children?: React.ReactNode
}
-type PaginationNextProps = Omit<BaseButtonNS.Props, 'children'> & {
+type PaginationNextProps = Omit<BaseButton.Props, 'children'> & {
children?: React.ReactNode
}
@@ -296,7 +295,7 @@ function PaginationNext({
)
}
-type PaginationPageJumpProps = Omit<BaseButtonNS.Props, 'children'> & {
+type PaginationPageJumpProps = Omit<BaseButton.Props, 'children'> & {
inputLabel?: string
children?: React.ReactNode
}
@@ -437,7 +436,7 @@ function PaginationPageList({ render, className, ...props }: PaginationPageListP
})
}
-type PaginationPageProps = Omit<BaseButtonNS.Props, 'children'> & {
+type PaginationPageProps = Omit<BaseButton.Props, 'children'> & {
page: number
children?: React.ReactNode
}
diff --git a/packages/dify-ui/src/popover/index.tsx b/packages/dify-ui/src/popover/index.tsx
index 34c78011d4d..81f4aa70c21 100644
--- a/packages/dify-ui/src/popover/index.tsx
+++ b/packages/dify-ui/src/popover/index.tsx
@@ -14,11 +14,15 @@ const PopoverPortal = BasePopover.Portal
const PopoverClose = BasePopover.Close
const PopoverTitle = BasePopover.Title
const PopoverDescription = BasePopover.Description
+// Transition container for one popup shared by several triggers; unstyled passthrough.
+const PopoverViewport = BasePopover.Viewport
const createPopoverHandle = BasePopover.createHandle
type PopoverActions = BasePopover.Root.Actions
type PopoverProps<Payload = unknown> = BasePopover.Root.Props<Payload>
+type PopoverChangeEventReason = BasePopover.Root.ChangeEventReason
+type PopoverChangeEventDetails = BasePopover.Root.ChangeEventDetails
type PopoverArrowProps = BasePopover.Arrow.Props
type PopoverPortalProps = BasePopover.Portal.Props
type PopoverHandle<Payload = unknown> = BasePopover.Handle<Payload>
@@ -35,6 +39,7 @@ function PopoverTrigger<Payload = unknown>({ className, ...props }: PopoverTrigg
type PopoverCloseProps = BasePopover.Close.Props
type PopoverTitleProps = BasePopover.Title.Props
type PopoverDescriptionProps = BasePopover.Description.Props
+type PopoverViewportProps = BasePopover.Viewport.Props
type PopoverBackdropProps = BasePopover.Backdrop.Props
@@ -134,11 +139,14 @@ export {
PopoverPositioner,
PopoverTitle,
PopoverTrigger,
+ PopoverViewport,
}
export type {
PopoverActions,
PopoverArrowProps,
PopoverBackdropProps,
+ PopoverChangeEventDetails,
+ PopoverChangeEventReason,
PopoverCloseProps,
PopoverContentProps,
PopoverDescriptionProps,
@@ -149,4 +157,5 @@ export type {
PopoverProps,
PopoverTitleProps,
PopoverTriggerProps,
+ PopoverViewportProps,
}
diff --git a/packages/dify-ui/src/preview-card/index.tsx b/packages/dify-ui/src/preview-card/index.tsx
index 8446592efb5..85cadd098b8 100644
--- a/packages/dify-ui/src/preview-card/index.tsx
+++ b/packages/dify-ui/src/preview-card/index.tsx
@@ -27,6 +27,8 @@ const PreviewCardViewport = BasePreviewCard.Viewport
const createPreviewCardHandle = BasePreviewCard.createHandle
type PreviewCardActions = BasePreviewCard.Root.Actions
+type PreviewCardChangeEventReason = BasePreviewCard.Root.ChangeEventReason
+type PreviewCardChangeEventDetails = BasePreviewCard.Root.ChangeEventDetails
type PreviewCardProps<Payload = unknown> = BasePreviewCard.Root.Props<Payload>
type PreviewCardHandle<Payload = unknown> = BasePreviewCard.Handle<Payload>
@@ -118,6 +120,8 @@ export {
}
export type {
PreviewCardActions,
+ PreviewCardChangeEventDetails,
+ PreviewCardChangeEventReason,
PreviewCardContentProps,
PreviewCardHandle,
PreviewCardPopupProps,
diff --git a/packages/dify-ui/src/radio-group/index.tsx b/packages/dify-ui/src/radio-group/index.tsx
index 016f257ebf9..f9142e502f2 100644
--- a/packages/dify-ui/src/radio-group/index.tsx
+++ b/packages/dify-ui/src/radio-group/index.tsx
@@ -1,7 +1,5 @@
'use client'
-import type { Radio as BaseRadioNS } from '@base-ui/react/radio'
-import type { RadioGroup as BaseRadioGroupNS } from '@base-ui/react/radio-group'
import type * as React from 'react'
import { Radio as BaseRadio } from '@base-ui/react/radio'
import { RadioGroup as BaseRadioGroup } from '@base-ui/react/radio-group'
@@ -9,7 +7,9 @@ import { cn } from '../cn'
import { checkedControlFocusClassName } from '../form-control-shared'
import { resolveClassName } from '../internals/resolve-class-name'
-type RadioGroupProps<Value = string> = BaseRadioGroupNS.Props<Value>
+type RadioGroupProps<Value = string> = BaseRadioGroup.Props<Value>
+type RadioGroupChangeEventReason = BaseRadioGroup.ChangeEventReason
+type RadioGroupChangeEventDetails = BaseRadioGroup.ChangeEventDetails
function RadioGroup<Value = string>({ className, ...props }: RadioGroupProps<Value>) {
return (
@@ -20,13 +20,13 @@ function RadioGroup<Value = string>({ className, ...props }: RadioGroupProps<Val
)
}
-type RadioItemProps<Value = string> = BaseRadioNS.Root.Props<Value>
+type RadioItemProps<Value = string> = BaseRadio.Root.Props<Value>
function RadioItem<Value = string>({ className, ...props }: RadioItemProps<Value>) {
return <BaseRadio.Root<Value> className={className} {...props} />
}
-type RadioControlProps = Omit<BaseRadioNS.Indicator.Props, 'children' | 'keepMounted'>
+type RadioControlProps = Omit<BaseRadio.Indicator.Props, 'children' | 'keepMounted'>
function RadioControl({ className, ...props }: RadioControlProps) {
return (
@@ -87,4 +87,12 @@ function RadioSkeleton({ className, ...props }: RadioSkeletonProps) {
export { Radio, RadioControl, RadioGroup, RadioItem, RadioSkeleton }
-export type { RadioControlProps, RadioGroupProps, RadioItemProps, RadioProps, RadioSkeletonProps }
+export type {
+ RadioControlProps,
+ RadioGroupChangeEventDetails,
+ RadioGroupChangeEventReason,
+ RadioGroupProps,
+ RadioItemProps,
+ RadioProps,
+ RadioSkeletonProps,
+}
diff --git a/packages/dify-ui/src/segmented-control/index.tsx b/packages/dify-ui/src/segmented-control/index.tsx
index 0f03a421a95..8be49b90b4a 100644
--- a/packages/dify-ui/src/segmented-control/index.tsx
+++ b/packages/dify-ui/src/segmented-control/index.tsx
@@ -1,7 +1,5 @@
'use client'
-import type { Radio as BaseRadioNS } from '@base-ui/react/radio'
-import type { RadioGroup as BaseRadioGroupNS } from '@base-ui/react/radio-group'
import type * as React from 'react'
import { Radio as BaseRadio } from '@base-ui/react/radio'
import { RadioGroup as BaseRadioGroup } from '@base-ui/react/radio-group'
@@ -19,7 +17,7 @@ type SegmentedControlSelectionProps<Value> =
}
type SegmentedControlProps<Value = string> = Omit<
- BaseRadioGroupNS.Props<Value>,
+ BaseRadioGroup.Props<Value>,
'defaultValue' | 'value'
> &
SegmentedControlSelectionProps<Value>
@@ -38,7 +36,7 @@ function SegmentedControl<Value = string>({ className, ...props }: SegmentedCont
)
}
-type SegmentedControlItemProps<Value = string> = BaseRadioNS.Root.Props<Value>
+type SegmentedControlItemProps<Value = string> = BaseRadio.Root.Props<Value>
function SegmentedControlItem<Value = string>({
className,
diff --git a/packages/dify-ui/src/select/index.tsx b/packages/dify-ui/src/select/index.tsx
index 998bda89b22..43f9a47f9c9 100644
--- a/packages/dify-ui/src/select/index.tsx
+++ b/packages/dify-ui/src/select/index.tsx
@@ -18,6 +18,7 @@ import {
import { parsePlacement } from '../placement'
type SelectActions = BaseSelect.Root.Actions
+type SelectChangeEventReason = BaseSelect.Root.ChangeEventReason
type SelectChangeEventDetails = BaseSelect.Root.ChangeEventDetails
type SelectOpenChangeEventDetails = BaseSelect.Root.OpenChangeEventDetails
@@ -298,6 +299,7 @@ export {
export type {
SelectActions,
SelectChangeEventDetails,
+ SelectChangeEventReason,
SelectContentProps,
SelectGroupLabelProps,
SelectGroupProps,
diff --git a/packages/dify-ui/src/slider/index.tsx b/packages/dify-ui/src/slider/index.tsx
index 53730e26ee3..bef3af03fbc 100644
--- a/packages/dify-ui/src/slider/index.tsx
+++ b/packages/dify-ui/src/slider/index.tsx
@@ -7,6 +7,10 @@ import { resolveClassName } from '../internals/resolve-class-name'
type SliderRootValue = NonNullable<BaseSlider.Root.Props['value']>
type SliderProps<Value extends SliderRootValue = SliderRootValue> = BaseSlider.Root.Props<Value>
+type SliderChangeEventReason = BaseSlider.Root.ChangeEventReason
+type SliderChangeEventDetails = BaseSlider.Root.ChangeEventDetails
+type SliderCommitEventReason = BaseSlider.Root.CommitEventReason
+type SliderCommitEventDetails = BaseSlider.Root.CommitEventDetails
function Slider<Value extends SliderRootValue = SliderRootValue>({
className,
@@ -123,6 +127,10 @@ export {
}
export type {
+ SliderChangeEventDetails,
+ SliderChangeEventReason,
+ SliderCommitEventDetails,
+ SliderCommitEventReason,
SliderControlProps,
SliderIndicatorProps,
SliderLabelProps,
diff --git a/packages/dify-ui/src/switch/index.tsx b/packages/dify-ui/src/switch/index.tsx
index f3c6ec44b2f..17218ae91c0 100644
--- a/packages/dify-ui/src/switch/index.tsx
+++ b/packages/dify-ui/src/switch/index.tsx
@@ -1,6 +1,5 @@
'use client'
-import type { Switch as BaseSwitchNS } from '@base-ui/react/switch'
import type { VariantProps } from 'class-variance-authority'
import type * as React from 'react'
import { Switch as BaseSwitch } from '@base-ui/react/switch'
@@ -72,10 +71,9 @@ type UncontrolledSwitchProps = {
type SwitchControlProps = ControlledSwitchProps | UncontrolledSwitchProps
-type SwitchProps = Omit<
- BaseSwitchNS.Root.Props,
- 'checked' | 'children' | 'defaultChecked' | 'size'
-> &
+type SwitchChangeEventReason = BaseSwitch.Root.ChangeEventReason
+type SwitchChangeEventDetails = BaseSwitch.Root.ChangeEventDetails
+type SwitchProps = Omit<BaseSwitch.Root.Props, 'checked' | 'children' | 'defaultChecked' | 'size'> &
VariantProps<typeof switchRootVariants> &
SwitchControlProps & {
loading?: boolean
@@ -131,4 +129,4 @@ function SwitchSkeleton({ size = 'md', className, ...props }: SwitchSkeletonProp
export { Switch, SwitchSkeleton }
-export type { SwitchProps, SwitchSkeletonProps }
+export type { SwitchChangeEventDetails, SwitchChangeEventReason, SwitchProps, SwitchSkeletonProps }
diff --git a/packages/dify-ui/src/tabs/index.tsx b/packages/dify-ui/src/tabs/index.tsx
index ae3d6bd6880..ed95cc8feb8 100644
--- a/packages/dify-ui/src/tabs/index.tsx
+++ b/packages/dify-ui/src/tabs/index.tsx
@@ -1,14 +1,15 @@
'use client'
-import type { Tabs as BaseTabsNS } from '@base-ui/react/tabs'
import { Tabs as BaseTabs } from '@base-ui/react/tabs'
import { cn } from '../cn'
import { resolveClassName } from '../internals/resolve-class-name'
-type TabsProps = BaseTabsNS.Root.Props
+type TabsProps = BaseTabs.Root.Props
+type TabsChangeEventReason = BaseTabs.Root.ChangeEventReason
+type TabsChangeEventDetails = BaseTabs.Root.ChangeEventDetails
const Tabs = BaseTabs.Root
-type TabsListProps = BaseTabsNS.List.Props
+type TabsListProps = BaseTabs.List.Props
function TabsList({ className, ...props }: TabsListProps) {
return (
@@ -19,7 +20,7 @@ function TabsList({ className, ...props }: TabsListProps) {
)
}
-type TabsTabProps = BaseTabsNS.Tab.Props
+type TabsTabProps = BaseTabs.Tab.Props
function TabsTab({ className, ...props }: TabsTabProps) {
return (
@@ -35,7 +36,7 @@ function TabsTab({ className, ...props }: TabsTabProps) {
)
}
-type TabsPanelProps = BaseTabsNS.Panel.Props
+type TabsPanelProps = BaseTabs.Panel.Props
function TabsPanel({ className, ...props }: TabsPanelProps) {
return (
@@ -52,8 +53,16 @@ function TabsPanel({ className, ...props }: TabsPanelProps) {
}
const TabsIndicator = BaseTabs.Indicator
-type TabsIndicatorProps = BaseTabsNS.Indicator.Props
+type TabsIndicatorProps = BaseTabs.Indicator.Props
export { Tabs, TabsIndicator, TabsList, TabsPanel, TabsTab }
-export type { TabsIndicatorProps, TabsListProps, TabsPanelProps, TabsProps, TabsTabProps }
+export type {
+ TabsChangeEventDetails,
+ TabsChangeEventReason,
+ TabsIndicatorProps,
+ TabsListProps,
+ TabsPanelProps,
+ TabsProps,
+ TabsTabProps,
+}
diff --git a/packages/dify-ui/src/textarea/index.tsx b/packages/dify-ui/src/textarea/index.tsx
index 5c93e51d7f4..b4b3b2704dc 100644
--- a/packages/dify-ui/src/textarea/index.tsx
+++ b/packages/dify-ui/src/textarea/index.tsx
@@ -1,6 +1,5 @@
'use client'
-import type { Field as BaseFieldNS } from '@base-ui/react/field'
import type { VariantProps } from 'class-variance-authority'
import type * as React from 'react'
import { Field as BaseField } from '@base-ui/react/field'
@@ -23,7 +22,7 @@ const textareaVariants = cva([textControlClassName, 'min-h-20 overflow-auto'], {
})
type TextareaValue = string | number
-type TextareaChangeEventDetails = BaseFieldNS.Control.ChangeEventDetails
+type TextareaChangeEventDetails = BaseField.Control.ChangeEventDetails
type TextareaOnValueChange = (value: string, eventDetails: TextareaChangeEventDetails) => void
type ControlledTextareaProps = {
@@ -57,12 +56,12 @@ type TextareaElementProps = Omit<
type TextareaControlProps = ControlledTextareaProps | UncontrolledTextareaProps
type TextareaVariantProps = VariantProps<typeof textareaVariants>
type FieldControlTextareaProps = Omit<
- BaseFieldNS.Control.Props,
+ BaseField.Control.Props,
'className' | 'defaultValue' | 'onValueChange' | 'render' | 'value'
>
type TextareaProps = TextareaElementProps &
- Pick<BaseFieldNS.Control.Props, 'className' | 'style'> &
+ Pick<BaseField.Control.Props, 'className' | 'style'> &
TextareaOnlyProps &
TextareaControlProps &
TextareaVariantProps & {
diff --git a/packages/dify-ui/src/toggle/index.tsx b/packages/dify-ui/src/toggle/index.tsx
index 65196a44708..75494b0bb60 100644
--- a/packages/dify-ui/src/toggle/index.tsx
+++ b/packages/dify-ui/src/toggle/index.tsx
@@ -1,12 +1,13 @@
'use client'
-import type { Toggle as BaseToggleNS } from '@base-ui/react/toggle'
import { Toggle as BaseToggle } from '@base-ui/react/toggle'
-type ToggleProps<Value extends string = string> = BaseToggleNS.Props<Value>
+type ToggleProps<Value extends string = string> = BaseToggle.Props<Value>
+type ToggleChangeEventReason = BaseToggle.ChangeEventReason
+type ToggleChangeEventDetails = BaseToggle.ChangeEventDetails
const Toggle = BaseToggle
export { Toggle }
-export type { ToggleProps }
+export type { ToggleChangeEventDetails, ToggleChangeEventReason, ToggleProps }
diff --git a/packages/dify-ui/src/tooltip/index.tsx b/packages/dify-ui/src/tooltip/index.tsx
index b19d3f3c1c3..3f2d97537ec 100644
--- a/packages/dify-ui/src/tooltip/index.tsx
+++ b/packages/dify-ui/src/tooltip/index.tsx
@@ -14,6 +14,8 @@ const TooltipTrigger = BaseTooltip.Trigger
type TooltipProviderProps = BaseTooltip.Provider.Props
type TooltipActions = BaseTooltip.Root.Actions
+type TooltipChangeEventReason = BaseTooltip.Root.ChangeEventReason
+type TooltipChangeEventDetails = BaseTooltip.Root.ChangeEventDetails
type TooltipProps<Payload = unknown> = BaseTooltip.Root.Props<Payload>
type TooltipTriggerProps<Payload = unknown> = BaseTooltip.Trigger.Props<Payload>
@@ -58,6 +60,8 @@ export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger }
export type {
TooltipActions,
+ TooltipChangeEventDetails,
+ TooltipChangeEventReason,
TooltipContentProps,
TooltipProps,
TooltipProviderProps,
diff --git a/packages/dify-ui/src/use-render.ts b/packages/dify-ui/src/use-render.ts
new file mode 100644
index 00000000000..9b5f19bdbd6
--- /dev/null
+++ b/packages/dify-ui/src/use-render.ts
@@ -0,0 +1,3 @@
+'use client'
+
+export { useRender } from '@base-ui/react/use-render'
diff --git a/web/app/components/app/app-publisher/publisher-content/publisher-panel/index.tsx b/web/app/components/app/app-publisher/publisher-content/publisher-panel/index.tsx
index 07003c91b09..3d82fbe2f58 100644
--- a/web/app/components/app/app-publisher/publisher-content/publisher-panel/index.tsx
+++ b/web/app/components/app/app-publisher/publisher-content/publisher-panel/index.tsx
@@ -1,4 +1,4 @@
-import type { PopoverProps } from '@langgenius/dify-ui/popover'
+import type { PopoverChangeEventDetails } from '@langgenius/dify-ui/popover'
import type { ComponentProps } from 'react'
import type { AppPublisherProps } from '../../types'
import { Button } from '@langgenius/dify-ui/button'
@@ -36,7 +36,7 @@ export function PublisherPanel({
const popupRef = useRef<HTMLDivElement>(null)
const { t } = useTranslation(['workflow'])
const [deploymentConfigurationOpen, setDeploymentConfigurationOpen] = useState(false)
- const handleOpenChange: NonNullable<PopoverProps['onOpenChange']> = (nextOpen, eventDetails) => {
+ const handleOpenChange = (nextOpen: boolean, eventDetails: PopoverChangeEventDetails) => {
const isOutsideDismiss =
eventDetails.reason === 'outside-press' || eventDetails.reason === 'focus-out'
if (!nextOpen && deploymentConfigurationOpen && isOutsideDismiss) {
diff --git a/web/app/components/datasets/hit-testing/components/chunk-detail-dialog.tsx b/web/app/components/datasets/hit-testing/components/chunk-detail-dialog.tsx
index aa86955c05b..ea26284cc93 100644
--- a/web/app/components/datasets/hit-testing/components/chunk-detail-dialog.tsx
+++ b/web/app/components/datasets/hit-testing/components/chunk-detail-dialog.tsx
@@ -1,5 +1,5 @@
'use client'
-import type { DialogProps } from '@langgenius/dify-ui/dialog'
+import type { DialogChangeEventDetails } from '@langgenius/dify-ui/dialog'
import type { FileAppearanceTypeEnum } from '@/app/components/base/file-uploader/types'
import type { HitTesting } from '@/models/datasets'
import { cn } from '@langgenius/dify-ui/cn'
@@ -31,7 +31,7 @@ const i18nPrefix = ''
type ChunkDetailDialogProps = {
payload: HitTesting
open: boolean
- onOpenChange: DialogProps['onOpenChange']
+ onOpenChange: (open: boolean, eventDetails: DialogChangeEventDetails) => void
}
export function ChunkDetailDialog({ payload, open, onOpenChange }: ChunkDetailDialogProps) {
diff --git a/web/app/components/header/account-setting/model-provider-page/model-selector/popup-item.tsx b/web/app/components/header/account-setting/model-provider-page/model-selector/popup-item.tsx
index 8fb2b24db3c..219ef05144b 100644
--- a/web/app/components/header/account-setting/model-provider-page/model-selector/popup-item.tsx
+++ b/web/app/components/header/account-setting/model-provider-page/model-selector/popup-item.tsx
@@ -1,5 +1,5 @@
import type { ModelType } from '@dify/contracts/api/console/workspaces/types.gen'
-import type { ComponentProps } from 'react'
+import type { PreviewCardHandle } from '@langgenius/dify-ui/preview-card'
import type {
ModelSelectorModel,
ModelSelectorModelPredicate,
@@ -38,8 +38,6 @@ export type ModelSelectorPreviewPayload = {
modelItem: ModelSelectorModel
}
-type PreviewCardHandle = NonNullable<ComponentProps<typeof PreviewCardTrigger>['handle']>
-
type PopupItemProps = {
defaultModel?: ModelSelectorValue
model: ModelSelectorProvider
diff --git a/web/app/components/tools/workflow-tool/index.tsx b/web/app/components/tools/workflow-tool/index.tsx
index 29cddfa4d8f..9b515d5141a 100644
--- a/web/app/components/tools/workflow-tool/index.tsx
+++ b/web/app/components/tools/workflow-tool/index.tsx
@@ -1,5 +1,4 @@
'use client'
-import type { DrawerProps } from '@langgenius/dify-ui/drawer'
import type {
Emoji,
WorkflowToolOutputSource,
@@ -97,8 +96,8 @@ const WorkflowToolDrawerFrame = ({
onHide,
children,
}: WorkflowToolDrawerFrameProps) => {
- const handleOpenChange = React.useCallback<NonNullable<DrawerProps['onOpenChange']>>(
- (open) => {
+ const handleOpenChange = React.useCallback(
+ (open: boolean) => {
if (!open) onHide()
},
[onHide],
diff --git a/web/app/components/workflow/block-selector/index.tsx b/web/app/components/workflow/block-selector/index.tsx
index 204e8ee0a7b..fc76a7f505d 100644
--- a/web/app/components/workflow/block-selector/index.tsx
+++ b/web/app/components/workflow/block-selector/index.tsx
@@ -1,8 +1,8 @@
import type { RagPipelineDatasourceProviderResponse } from '@dify/contracts/api/console/rag/types.gen'
import type {
+ PopoverChangeEventDetails,
PopoverPopupProps,
PopoverPositionerProps,
- PopoverProps,
PopoverTriggerProps,
} from '@langgenius/dify-ui/popover'
import type { CSSProperties, KeyboardEvent, MouseEventHandler, Ref } from 'react'
@@ -37,10 +37,7 @@ export type BlockSelectorProps = Pick<
finalFocus?: PopoverPopupProps['finalFocus']
triggerRef?: Ref<HTMLButtonElement>
open?: boolean
- onOpenChange?: (
- open: boolean,
- details?: Parameters<NonNullable<PopoverProps['onOpenChange']>>[1],
- ) => void
+ onOpenChange?: (open: boolean, details?: PopoverChangeEventDetails) => void
onSelect: OnSelectBlock
trigger?: NonNullable<PopoverTriggerProps['render']>
triggerTooltip?: string
@@ -98,7 +95,7 @@ function BlockSelector({
const searchInputRef = useRef<HTMLInputElement>(null)
const open = openFromProps === undefined ? localOpen : openFromProps
const handleOpenChange = useCallback(
- (newOpen: boolean, details?: Parameters<NonNullable<PopoverProps['onOpenChange']>>[1]) => {
+ (newOpen: boolean, details?: PopoverChangeEventDetails) => {
if (newOpen && disabled) return
setLocalOpen(newOpen)
diff --git a/web/app/components/workflow/nodes/_base/components/node-handle.tsx b/web/app/components/workflow/nodes/_base/components/node-handle.tsx
index 4ea57ec9268..e26dc4bd2fa 100644
--- a/web/app/components/workflow/nodes/_base/components/node-handle.tsx
+++ b/web/app/components/workflow/nodes/_base/components/node-handle.tsx
@@ -1,5 +1,5 @@
+import type { PopoverChangeEventDetails } from '@langgenius/dify-ui/popover'
import type { MouseEvent } from 'react'
-import type { BlockSelectorProps } from '../../../block-selector'
import type { BlockDefaultValue } from '../../../block-selector/types'
import type { Node } from '../../../types'
import { cn } from '@langgenius/dify-ui/cn'
@@ -51,14 +51,11 @@ export const NodeTargetHandle = memo(
)
const isConnectable = !!availablePrevBlocks.length
- const handleOpenChange = useCallback<NonNullable<BlockSelectorProps['onOpenChange']>>(
- (v, details) => {
- preserveOutsideFocusRef.current =
- details?.reason === 'outside-press' || details?.reason === 'focus-out'
- setOpen(v)
- },
- [],
- )
+ const handleOpenChange = useCallback((v: boolean, details?: PopoverChangeEventDetails) => {
+ preserveOutsideFocusRef.current =
+ details?.reason === 'outside-press' || details?.reason === 'focus-out'
+ setOpen(v)
+ }, [])
const handleHandleClick = useCallback(
(e: MouseEvent) => {
e.stopPropagation()
@@ -181,14 +178,11 @@ export const NodeSourceHandle = memo(
hasAgentV2OutputRoutes(data) ||
data.type === BlockEnum.HumanInput ||
data.error_strategy === ErrorHandleTypeEnum.failBranch
- const handleOpenChange = useCallback<NonNullable<BlockSelectorProps['onOpenChange']>>(
- (v, details) => {
- preserveOutsideFocusRef.current =
- details?.reason === 'outside-press' || details?.reason === 'focus-out'
- setOpen(v)
- },
- [],
- )
+ const handleOpenChange = useCallback((v: boolean, details?: PopoverChangeEventDetails) => {
+ preserveOutsideFocusRef.current =
+ details?.reason === 'outside-press' || details?.reason === 'focus-out'
+ setOpen(v)
+ }, [])
const handleHandleClick = useCallback((e: MouseEvent) => {
e.stopPropagation()
preserveOutsideFocusRef.current = false