Skip to content

Commit

Permalink
fix: fullProps and fullEmits error
Browse files Browse the repository at this point in the history
  • Loading branch information
SoulLyoko committed Jun 16, 2022
1 parent db4866a commit 69c1ab6
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 29 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions packages/components/checkbox/src/index.ts
Expand Up @@ -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";

Expand All @@ -11,7 +11,7 @@ export type CheckboxEmits = typeof checkboxEmits;
export type CheckboxEmitFn = SetupContext<CheckboxEmits>["emit"];
export type CheckboxInstance = InstanceType<typeof VDictCheckbox>;

export const checkboxProps = { ...basicProps, button: { type: Boolean } };
export const checkboxProps = { ...basicProps, ...buttonProps };
export const checkboxEmits = basicEmits;

export const VDictCheckbox = defineComponent({
Expand Down
4 changes: 2 additions & 2 deletions packages/components/radio/src/index.ts
Expand Up @@ -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";

Expand All @@ -11,7 +11,7 @@ export type RadioEmits = typeof radioEmits;
export type RadioEmitFn = SetupContext<RadioEmits>["emit"];
export type RadioInstance = InstanceType<typeof VDictRadio>;

export const radioProps = { ...basicProps, button: { type: Boolean } };
export const radioProps = { ...basicProps, ...buttonProps };
export const radioEmits = basicEmits;

export const VDictRadio = defineComponent({
Expand Down
11 changes: 2 additions & 9 deletions packages/components/select/src/index.ts
Expand Up @@ -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";

Expand All @@ -12,14 +12,7 @@ export type SelectEmitFn = SetupContext<SelectEmits>["emit"];
export type SelectInstance = InstanceType<typeof VDictSelect>;

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",
Expand Down
25 changes: 16 additions & 9 deletions 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
Expand All @@ -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
};
17 changes: 11 additions & 6 deletions 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<DictValue>, default: "" }, // Vue2
modelValue: { type: [String, Number, Array] as PropType<DictValue>, default: "" }, // Vue3
Expand All @@ -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
};

0 comments on commit 69c1ab6

Please sign in to comment.