diff --git a/packages/opendesign/src/components/_shared/constant.ts b/packages/opendesign/src/components/_shared/constant.ts deleted file mode 100644 index 814b4a97b6c77a5b85ca9c7243580954bf8fa3db..0000000000000000000000000000000000000000 --- a/packages/opendesign/src/components/_shared/constant.ts +++ /dev/null @@ -1,2 +0,0 @@ -export const PROVIDE_KEY_UPTION_UPDATE = Symbol('provide-option/update'); -export const PROVIDE_KEY_UPTION_VALUE = Symbol('provide-option/value'); diff --git a/packages/opendesign/src/components/_shared/global.ts b/packages/opendesign/src/components/_shared/global.ts index cca90c63c085cf9a52d26fddb6d6d72c296f921f..8e90de3356b3087e5485faa5f034a729f6b26e91 100644 --- a/packages/opendesign/src/components/_shared/global.ts +++ b/packages/opendesign/src/components/_shared/global.ts @@ -13,12 +13,3 @@ export function initSize(type: SizeT) { export type ShapeT = 'round' | 'normal' export const defaultShape = ref('normal'); - -export function initShape(shape: ShapeT) { - defaultShape.value = shape; -} - -export interface OptionValueT { - label: string; - value: string | number; -} \ No newline at end of file diff --git a/packages/opendesign/src/components/option/OOption.vue b/packages/opendesign/src/components/option/OOption.vue index 83d4a0bc85fe6275dc320b7a3d07234624e1cb48..82b2bdad59a1ce77228769d44729904949b8250b 100644 --- a/packages/opendesign/src/components/option/OOption.vue +++ b/packages/opendesign/src/components/option/OOption.vue @@ -1,37 +1,44 @@ diff --git a/packages/opendesign/src/components/option/index.ts b/packages/opendesign/src/components/option/index.ts index 34f7ead8a725b9def30f7da48a88433b2e960522..45c30c0fb8ec7cb807681e641a31a91cf4e094d0 100644 --- a/packages/opendesign/src/components/option/index.ts +++ b/packages/opendesign/src/components/option/index.ts @@ -1,8 +1,6 @@ import _OOption from './OOption.vue'; import type { App } from 'vue'; -// export * from './types'; - const OOption = Object.assign(_OOption, { install(app: App) { app.component(_OOption.name, _OOption); diff --git a/packages/opendesign/src/components/option/types.ts b/packages/opendesign/src/components/option/types.ts deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/packages/opendesign/src/components/select/OSelect.vue b/packages/opendesign/src/components/select/OSelect.vue index e6dc56e8407a26d5d27ebe80d898077ac586f3f7..a7c79345c0de105ee9f1c820c174fe68007908f0 100644 --- a/packages/opendesign/src/components/select/OSelect.vue +++ b/packages/opendesign/src/components/select/OSelect.vue @@ -2,10 +2,10 @@ import { provide, ref } from 'vue'; import { defaultSize, defaultShape } from '../_shared/global'; import type { SizeT, ShapeT } from '../_shared/global'; -import { PROVIDE_KEY_UPTION_UPDATE, PROVIDE_KEY_UPTION_VALUE } from '../_shared/constant'; -import type { OptionValueT } from '../_shared/global'; import { IconArrowTraingleDown } from '../icons'; import { OPopup, PopupPositionT } from '../popup'; +import { selectOptionUpdateFnInjectKey, selectOptionValueInjectKey } from './provide'; +import { SelectOptionT } from './types'; interface SelectPropT { size?: SizeT; @@ -33,7 +33,7 @@ const emits = defineEmits(['update:modelValue']); const selectRef = ref(); const showOption = ref(false); -provide(PROVIDE_KEY_UPTION_UPDATE, (val: OptionValueT, emit?: boolean) => { +provide(selectOptionUpdateFnInjectKey, (val: SelectOptionT, emit?: boolean) => { activeLabel.value = val.label; if (emit) { emits('update:modelValue', val.value); @@ -42,7 +42,8 @@ provide(PROVIDE_KEY_UPTION_UPDATE, (val: OptionValueT, emit?: boolean) => { } }); -provide(PROVIDE_KEY_UPTION_VALUE, activeVal); +provide(selectOptionValueInjectKey, activeVal); + const onOptionChange = (visible: boolean) => { if (visible) { console.log(selectRef.value?.clientWidth); diff --git a/packages/opendesign/src/components/select/provide.ts b/packages/opendesign/src/components/select/provide.ts new file mode 100644 index 0000000000000000000000000000000000000000..48ccc9661b69eecd58776ce1561ed0ae2d34e12c --- /dev/null +++ b/packages/opendesign/src/components/select/provide.ts @@ -0,0 +1,9 @@ +import { InjectionKey, Ref } from 'vue'; +import { SelectOptionT } from './types'; + + +export const selectOptionUpdateFnInjectKey: InjectionKey<(val: SelectOptionT, emit?: boolean) => void> = + Symbol('provide-select-option/updateFn'); + +export const selectOptionValueInjectKey: InjectionKey> = + Symbol('provide-select-option/value'); diff --git a/packages/opendesign/src/components/select/types.ts b/packages/opendesign/src/components/select/types.ts index 139597f9cb07c5d48bed18984ec4747f4b4f3438..859f1ef1de9eb8fed66aa5dd32c2d52f832f96f6 100644 --- a/packages/opendesign/src/components/select/types.ts +++ b/packages/opendesign/src/components/select/types.ts @@ -1,2 +1,4 @@ - - +export interface SelectOptionT { + label: string; + value: string | number; +} \ No newline at end of file