Skip to content

Commit

Permalink
feat: 更新 .d.ts 文档
Browse files Browse the repository at this point in the history
  • Loading branch information
TerryZ committed Sep 17, 2023
1 parent 46457c2 commit 68e5d01
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 50 deletions.
3 changes: 1 addition & 2 deletions src/RegionCityPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const fullCityDirectory = cityDirectory()
export default defineComponent({
name: 'RegionCityPicker',
props: {
disabled: { type: Boolean, default: false },
modelValue: { type: Array, default: () => [] },
/**
* 按钮中显示选中城市模式
Expand Down Expand Up @@ -137,8 +138,6 @@ export default defineComponent({
}, clear
)



// 搜索栏
const searchInput = h('input', {
ref: search,
Expand Down
2 changes: 2 additions & 0 deletions types/city.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { DefineComponent, ComputedOptions } from 'vue'
import { RegionItem, CommonMethods } from './component'

interface Props {
/** 禁用 */
disabled?: boolean
/** 输入区域编码列表 */
modelValue: string[]
/**
Expand Down
34 changes: 21 additions & 13 deletions types/component.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,27 @@ export declare interface RegionItem {

export declare interface RegionModel {
/** 省份模型 */
province: RegionItem
province?: RegionItem
/** 城市模型 */
city: RegionItem
city?: RegionItem
/** 区域模型 */
area: RegionItem
area?: RegionItem
/** 村镇模型 */
town: RegionItem
town?: RegionItem
}

/**
* 用户输入模型
*/
export declare interface RegionInputModel {
/** 省份编码 */
province: string
province?: string
/** 城市编码 */
city: string
city?: string
/** 区域编码 */
area: string
area?: string
/** 村镇编码 */
town: string
town?: string
}

export declare interface CommonProps {
Expand All @@ -53,15 +53,23 @@ export declare interface CommonProps {
town?: boolean
/**
* 语言
* @default 'CN'
* @default `CN`
*/
language?: string
/** v-model 内容修改响应事件 */
'onUpdate:modelValue': (val: RegionInputModel) => void
/** 内容修改后的响应事件 */
onChange?: (data: RegionModel) => void
}

/** 更新选中区域的键值 */
type EmitUpdateModelValue = (event: "update:modelValue", value: RegionInputModel) => void
/** 内容修改后的响应事件 */
type EmitChange = (event: "change", value: RegionModel) => void
/** 下拉栏调整位置事件 */
type EmitAdjust = () => void
/** 选择完成 */
type EmitComplete = () => void

export declare type CommonEmits = EmitUpdateModelValue & EmitChange
export declare type CoreModuleEmits = EmitAdjust & EmitComplete

export declare interface CommonMethods extends MethodOptions {
/** 重置数据 */
reset: () => void
Expand Down
42 changes: 19 additions & 23 deletions types/group.d.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
import { DefineComponent, ComputedOptions } from 'vue'
import { CommonProps, CommonMethods } from './component'
import { AllowedComponentProps, ComponentCustomProps, VNodeProps } from 'vue'
import { CommonProps, CommonEmits, CoreModuleEmits } from './component'

declare interface RegionGroupCore {
new (): {
$props: AllowedComponentProps & ComponentCustomProps & VNodeProps & CommonProps
$emit: CommonEmits & CoreModuleEmits
}
}
declare interface RegionGroup {
new (): {
$props: AllowedComponentProps & ComponentCustomProps & VNodeProps & CommonProps
$emit: CommonEmits & CoreModuleEmits
}
}

/**
* 多分组选择器核心模块
* 多分组选择器组件核心模块
*/
interface Props extends CommonProps {
/** 下拉栏调整位置事件 */
onAdjust?: () => void
/** 选择完成 */
onComplete?: () => void
}
export const RegionGroupCore: DefineComponent<
Props,
{},
{},
ComputedOptions,
CommonMethods
>
export const RegionGroupCore: RegionGroupCore

interface GroupProps extends CommonProps {
/** 禁用 */
Expand All @@ -28,10 +30,4 @@ interface GroupProps extends CommonProps {
/**
* 多分组选择器组件
*/
export const RegionGroup: DefineComponent<
GroupProps,
{},
{},
ComputedOptions,
CommonMethods
>
export const RegionGroup: RegionGroup
19 changes: 10 additions & 9 deletions types/selects.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DefineComponent, ComputedOptions } from 'vue'
import { CommonProps, CommonMethods } from './component'
import { AllowedComponentProps, ComponentCustomProps, VNodeProps } from 'vue'
import { CommonProps, CommonEmits } from './component'

/**
* 级联下拉列表模式
Expand All @@ -17,10 +17,11 @@ interface Props extends CommonProps {
disabled?: boolean
}

export const RegionSelects: DefineComponent<
Props,
{},
{},
ComputedOptions,
CommonMethods
>
declare interface RegionSelects {
new (): {
$props: AllowedComponentProps & ComponentCustomProps & VNodeProps & Props,
$emit: CommonEmits
}
}

export const RegionSelects: RegionSelects
12 changes: 9 additions & 3 deletions types/text.d.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
import { DefineComponent } from 'vue'
import { AllowedComponentProps, ComponentCustomProps, VNodeProps } from 'vue'
import { RegionInputModel } from './component'

interface Props {
/** 输入区域模型 */
modelValue: RegionInputModel
modelValue?: RegionInputModel
/**
* 分隔符
* @default ''
*/
separator?: string
}

declare interface RegionText {
new (): {
$props: AllowedComponentProps & ComponentCustomProps & VNodeProps & Props
}
}

/**
* 行政区划内容显示
*/
export const RegionText: DefineComponent<Props>
export const RegionText: RegionText

0 comments on commit 68e5d01

Please sign in to comment.