From 82e164ce88fe882e63a38ad0c6af8a3fac2c33c8 Mon Sep 17 00:00:00 2001 From: devin Date: Wed, 4 Jan 2023 18:46:56 +0800 Subject: [PATCH] =?UTF-8?q?provide=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/docs/button.md | 17 +++-- packages/docs/select.md | 20 +++-- .../src/components/_shared/utils.ts | 5 +- .../src/components/option/OOption.vue | 27 ++++--- .../src/components/popup/OPopup.vue | 8 +- .../src/components/select/OSelect.vue | 76 +++++++++++-------- .../components/select/__demo__/SelectSize.vue | 4 +- .../src/components/select/provide.ts | 6 +- .../src/components/select/style/index.scss | 1 + 9 files changed, 95 insertions(+), 69 deletions(-) diff --git a/packages/docs/button.md b/packages/docs/button.md index f68d921f..8779fcb9 100644 --- a/packages/docs/button.md +++ b/packages/docs/button.md @@ -2,12 +2,19 @@ ## props -| name | type | 默认值 | 说明 | -| :---- | :---------- | :-------- | :----------------------------------- | -| shape | ShapeT | 'normal' | 形状: large \| normal \| small | -| size | SizeT | 'normal' | 形状 normal \| round | -| type | ButtonTypeT | 'outline' | 形状 primary \|outline\| text \|link | +| name | type | 默认值 | 说明 | +| :------ | :---------- | :-------- | :----------------------------------- | +| shape | ShapeT | 'normal' | 形状: large \| normal \| small | +| size | SizeT | 'normal' | 形状 normal \| round | +| type | ButtonTypeT | 'outline' | 形状 primary \|outline\| text \|link | +| loading | boolean | false | 加载状态 | ## event ## expose + +## slot + +| name | 说明 | +| :--- | :------- | +| icon | 按钮图标 | diff --git a/packages/docs/select.md b/packages/docs/select.md index 85703397..93baac4c 100644 --- a/packages/docs/select.md +++ b/packages/docs/select.md @@ -2,14 +2,18 @@ ## props -| name | type | 默认值 | 说明 | -| :----------- | :------- | :------- | ------------------------------------------------------------- | -| model:value | boolean | false | 开关状态 | -| shape | ShapeT | 'normal' | 形状: large \| normal \| small | -| size | SizeT | 'normal' | 形状 normal \| round | -| disabled | boolean | false | 形状 | -| loading | boolean | false | 加载状态 | -| beforeChange | function | ()=>true | return Promise. resolve(true)继续切换,resolve(false)阻止切换 | +| name | type | 默认值 | 说明 | +| :-------------- | :------------------------------- | :----------------- | ------------------------------------------------------------- | +| modelValue | string \| number(v-model) | false | 开关状态 | +| shape | ShapeT | 'normal' | 形状: large \| normal \| small | +| size | SizeT | 'normal' | 形状 normal \| round | +| disabled | boolean | false | 形状 | +| placeholder | string | 'please select...' | 提示文本 | +| loading | boolean | false | 加载状态 | +| beforeChange | function | ()=>true | return Promise. resolve(true)继续切换,resolve(false)阻止切换 | +| optionWrapClass | string | '' | 下拉的自定义类 | +| optionPosition | PopupPositionT | 'bl' | 下拉的位置 | +| optionWidthMode | 'auto' \| 'min-width' \| 'width' | 'min-width' | 下拉的宽度适配方式 | ## event diff --git a/packages/opendesign/src/components/_shared/utils.ts b/packages/opendesign/src/components/_shared/utils.ts index c471a595..7419a67e 100644 --- a/packages/opendesign/src/components/_shared/utils.ts +++ b/packages/opendesign/src/components/_shared/utils.ts @@ -4,7 +4,7 @@ import type { ThrottleSettings, DebounceSettings } from 'lodash-es'; export function isBoolean(val: unknown): val is boolean { return typeof val === 'boolean'; } -export function isString(val: unknown): val is string { +export function isString(val: unknown) { return typeof val === 'string'; } export function isNumber(val: unknown): val is number { @@ -13,6 +13,9 @@ export function isNumber(val: unknown): val is number { export function isFunction(val: unknown): val is Function { return typeof val === 'function'; } +export function isArray(val: unknown): val is Array { + return Array.isArray(val); +} export function isObject(val: unknown): val is Record { return val !== null && typeof val === 'object'; } diff --git a/packages/opendesign/src/components/option/OOption.vue b/packages/opendesign/src/components/option/OOption.vue index 82b2bdad..76aace7c 100644 --- a/packages/opendesign/src/components/option/OOption.vue +++ b/packages/opendesign/src/components/option/OOption.vue @@ -1,6 +1,6 @@ diff --git a/packages/opendesign/src/components/popup/OPopup.vue b/packages/opendesign/src/components/popup/OPopup.vue index fe9ca975..acdc699c 100644 --- a/packages/opendesign/src/components/popup/OPopup.vue +++ b/packages/opendesign/src/components/popup/OPopup.vue @@ -147,7 +147,7 @@ const wrapStyle = computed(() => ({ const anchorStyle = reactive<{ left?: string; top?: string; right?: string; bottom?: string }>({}); // 是否需要挂载 -const mounted = ref(false); +const toMount = ref(false); const isAnimating = ref(false); const { addResizeListener, removeResizeListener } = useResizeObserver(); @@ -242,7 +242,7 @@ const updateVisible = (isVisible: boolean, delay?: number) => { emits('change', isVisible); if (isVisible) { - mounted.value = true; + toMount.value = true; if (props.hideWhenTargetInvisible && targetEl) { intersctionObserver.addIntersectionListener(targetEl, onTargetInterscting); @@ -308,7 +308,7 @@ const handleTransitionStart = () => { const handleTransitionEnd = () => { isAnimating.value = false; if (!visible.value && props.unmountOnClose) { - mounted.value = false; + toMount.value = false; } }; @@ -424,7 +424,7 @@ onUnmounted(() => {