diff --git a/src/dynamic-input/index.ts b/src/dynamic-input/index.ts index 63739648f96..c8ad2322d59 100644 --- a/src/dynamic-input/index.ts +++ b/src/dynamic-input/index.ts @@ -1,2 +1,6 @@ export { dynamicInputProps, default as NDynamicInput } from './src/DynamicInput' -export type { DynamicInputProps } from './src/DynamicInput' +export type { DynamicInputProps, DynamicInputSlots } from './src/DynamicInput' +export type { + DynamicInputActionSlotOptions, + DynamicInputDefaultSlotOptions +} from './src/interface' diff --git a/src/dynamic-input/src/DynamicInput.tsx b/src/dynamic-input/src/DynamicInput.tsx index 15402d382a4..04c64b8f25a 100644 --- a/src/dynamic-input/src/DynamicInput.tsx +++ b/src/dynamic-input/src/DynamicInput.tsx @@ -2,7 +2,11 @@ import type { ThemeProps } from '../../_mixins' import type { ExtractPublicPropTypes, MaybeArray } from '../../_utils' import type { ButtonProps } from '../../button' import type { DynamicInputTheme } from '../styles' -import type { OnUpdateValue } from './interface' +import type { + DynamicInputActionSlotOptions, + DynamicInputDefaultSlotOptions, + OnUpdateValue +} from './interface' import { createId } from 'seemly' import { useMergedState } from 'vooks' import { @@ -88,6 +92,13 @@ export const dynamicInputProps = { export type DynamicInputProps = ExtractPublicPropTypes +export interface DynamicInputSlots { + action?: (options: DynamicInputActionSlotOptions) => any + default?: (options: DynamicInputDefaultSlotOptions) => any + 'create-button-default'?: any + 'create-button-icon'?: any +} + export default defineComponent({ name: 'DynamicInput', props: dynamicInputProps, diff --git a/src/dynamic-input/src/interface.ts b/src/dynamic-input/src/interface.ts index eafada8916c..d054d07a87c 100644 --- a/src/dynamic-input/src/interface.ts +++ b/src/dynamic-input/src/interface.ts @@ -14,3 +14,16 @@ export const dynamicInputInjectionKey = createInjectionKey('n-dynamic-input') export type OnUpdateValue = (value: T[]) => void + +export interface DynamicInputDefaultSlotOptions { + value: any + index: number +} + +export interface DynamicInputActionSlotOptions { + value: any + index: number + create: (index: number) => void + remove: (index: number) => void + move: (type: 'up' | 'down', index: number) => void +}