diff --git a/.eslintrc.js b/.eslintrc.js index f313521..6eb5167 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -30,7 +30,6 @@ module.exports = { "@typescript-eslint/ban-types": 0, "@typescript-eslint/no-var-requires": 0, "@typescript-eslint/no-non-null-assertion": 0, - "@typescript-eslint/no-unused-vars": 0, "vue/require-render-return": 0, "vue/require-explicit-emits": 0, "vue/require-default-prop": 0, diff --git a/packages/components/checkbox/src/index.ts b/packages/components/checkbox/src/index.ts index 237288c..f71847d 100644 --- a/packages/components/checkbox/src/index.ts +++ b/packages/components/checkbox/src/index.ts @@ -2,7 +2,7 @@ import type { SetupContext, ExtractPropTypes } from "vue-demi"; import { defineComponent } from "vue-demi"; -import { basicProps, basicEmits, useListeners } from "~/constants"; +import { basicProps, buttonProps, basicEmits, useListeners } from "~/constants"; import { h, dynamicComponent } from "~/utils"; import { useDict } from "~/composables"; @@ -11,7 +11,7 @@ export type CheckboxEmits = typeof checkboxEmits; export type CheckboxEmitFn = SetupContext["emit"]; export type CheckboxInstance = InstanceType; -export const checkboxProps = { ...basicProps, button: { type: Boolean } }; +export const checkboxProps = { ...basicProps, ...buttonProps }; export const checkboxEmits = basicEmits; export const VDictCheckbox = defineComponent({ diff --git a/packages/components/radio/src/index.ts b/packages/components/radio/src/index.ts index 072f52e..ae26af6 100644 --- a/packages/components/radio/src/index.ts +++ b/packages/components/radio/src/index.ts @@ -2,7 +2,7 @@ import type { SetupContext, ExtractPropTypes } from "vue-demi"; import { defineComponent } from "vue-demi"; -import { basicProps, basicEmits, useListeners } from "~/constants"; +import { basicProps, buttonProps, basicEmits, useListeners } from "~/constants"; import { h, dynamicComponent } from "~/utils"; import { useDict } from "~/composables"; @@ -11,7 +11,7 @@ export type RadioEmits = typeof radioEmits; export type RadioEmitFn = SetupContext["emit"]; export type RadioInstance = InstanceType; -export const radioProps = { ...basicProps, button: { type: Boolean } }; +export const radioProps = { ...basicProps, ...buttonProps }; export const radioEmits = basicEmits; export const VDictRadio = defineComponent({ diff --git a/packages/components/select/src/index.ts b/packages/components/select/src/index.ts index 1a87315..f2b0d0a 100644 --- a/packages/components/select/src/index.ts +++ b/packages/components/select/src/index.ts @@ -2,7 +2,7 @@ import type { SetupContext, ExtractPropTypes } from "vue-demi"; import { defineComponent } from "vue-demi"; -import { basicProps, basicEmits, useListeners } from "~/constants"; +import { basicProps, basicEmits, selectRestEmits, useListeners } from "~/constants"; import { h, dynamicComponent } from "~/utils"; import { useDict } from "~/composables"; @@ -12,14 +12,7 @@ export type SelectEmitFn = SetupContext["emit"]; export type SelectInstance = InstanceType; export const selectProps = basicProps; -export const selectEmits = { - ...basicEmits, - "visible-change": (v: boolean) => true, - "remove-tag": (...args: any[]) => true, - clear: () => true, - blur: (event: Event) => true, - focus: (event: Event) => true -}; +export const selectEmits = { ...basicEmits, ...selectRestEmits }; export const VDictSelect = defineComponent({ name: "VDictSelect", diff --git a/packages/constants/emits.ts b/packages/constants/emits.ts index 65e0452..99f0474 100644 --- a/packages/constants/emits.ts +++ b/packages/constants/emits.ts @@ -1,4 +1,4 @@ -import { checkboxEmits, radioEmits, selectEmits } from "../components"; +/* eslint-disable @typescript-eslint/no-unused-vars */ export const vModelEmits = { input: (...args: any[]) => true, // Vue2 @@ -14,13 +14,20 @@ export const basicEmits = { ...changeEmits }; -export const fullEmits = { - ...checkboxEmits, - ...radioEmits, - ...selectEmits +export const selectRestEmits = { + "visible-change": (v: boolean) => true, + "remove-tag": (...args: any[]) => true, + clear: () => true, + blur: (event: Event) => true, + focus: (event: Event) => true +}; + +export const cascaderRestEmits = { + "expand-change": (...args: any[]) => true }; -// export const cascaderEmits = { -// ...selectEmits, -// "expand-change": (...args: any[]) => true -// }; +export const fullEmits = { + ...basicEmits, + ...selectRestEmits, + ...cascaderRestEmits +}; diff --git a/packages/constants/props.ts b/packages/constants/props.ts index c96b9ae..4b01b8d 100644 --- a/packages/constants/props.ts +++ b/packages/constants/props.ts @@ -1,8 +1,6 @@ import type { PropType } from "vue-demi"; import type { DictValue, DictData, Config } from "../types"; -import { checkboxProps, radioProps, selectProps } from "../components"; - export const basicProps = { value: { type: [String, Number, Array] as PropType, default: "" }, // Vue2 modelValue: { type: [String, Number, Array] as PropType, default: "" }, // Vue3 @@ -11,9 +9,16 @@ export const basicProps = { cache: { type: String, default: "" } }; +export const typeProps = { + type: { type: String as PropType<"select" | "radio" | "checkbox" | "text">, default: "select" } +}; + +export const buttonProps = { + button: { type: Boolean } +}; + export const fullProps = { - type: { type: String as PropType<"select" | "radio" | "checkbox" | "text">, default: "select" }, - ...checkboxProps, - ...radioProps, - ...selectProps + ...basicProps, + ...typeProps, + ...buttonProps };