From 29bfe1e7ea8eda3ffd028dc854cbe783138ecd2c Mon Sep 17 00:00:00 2001 From: discreted66 <953831480@qq.com> Date: Thu, 27 Nov 2025 09:14:13 -0800 Subject: [PATCH] =?UTF-8?q?feat:select=E7=BB=84=E4=BB=B6=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pc/app/select/automatic-dropdown.spec.ts | 2 +- .../demos/pc/app/select/copy-multi.spec.ts | 7 +- .../sites/demos/pc/app/select/events.spec.ts | 6 +- .../pc/app/select/input-box-type.spec.ts | 4 +- .../pc/app/select/nest-grid-remote.spec.ts | 16 +- .../demos/pc/app/select/nest-grid.spec.ts | 6 +- .../select/nest-radio-grid-much-data.spec.ts | 2 +- .../demos/pc/app/select/nest-tree.spec.ts | 4 +- .../app/select/popup-style-position.spec.ts | 2 +- .../demos/pc/app/select/remote-method.spec.ts | 2 +- packages/renderless/src/base-select/index.ts | 2 +- packages/renderless/src/grid-select/index.ts | 16 +- packages/renderless/src/grid-select/vue.ts | 8 +- packages/renderless/src/select-wrapper/vue.ts | 143 +++ packages/renderless/src/tree-select/index.ts | 20 +- packages/renderless/src/tree-select/vue.ts | 20 +- packages/theme/src/option/index.less | 5 + packages/vue/src/base-select/src/pc.vue | 5 +- packages/vue/src/select/src/mobile-first.vue | 5 +- packages/vue/src/select/src/pc.vue | 1068 +++++------------ 20 files changed, 535 insertions(+), 808 deletions(-) create mode 100644 packages/renderless/src/select-wrapper/vue.ts diff --git a/examples/sites/demos/pc/app/select/automatic-dropdown.spec.ts b/examples/sites/demos/pc/app/select/automatic-dropdown.spec.ts index 303487fcb2..4872873f8a 100644 --- a/examples/sites/demos/pc/app/select/automatic-dropdown.spec.ts +++ b/examples/sites/demos/pc/app/select/automatic-dropdown.spec.ts @@ -23,7 +23,7 @@ test('可搜索时,获取焦点自动下拉', async ({ page }) => { await wrap.getByRole('button').nth(1).click() // 聚焦下拉 - await dropdown.getByRole('listitem').filter({ hasText: '上海' }).click() + await page.getByRole('list').getByText('上海').click() await expect(input).toHaveValue('上海') // 验证选中 await input.click() diff --git a/examples/sites/demos/pc/app/select/copy-multi.spec.ts b/examples/sites/demos/pc/app/select/copy-multi.spec.ts index ac973bc49a..6adecaee36 100644 --- a/examples/sites/demos/pc/app/select/copy-multi.spec.ts +++ b/examples/sites/demos/pc/app/select/copy-multi.spec.ts @@ -36,9 +36,12 @@ test('多选一键复制所有标签', async ({ page }) => { await page.goto('select#copy-multi') const wrap = page.locator('#copy-multi') - const select = wrap.locator('.tiny-select').nth(1) + const select = page + .locator('div') + .filter({ hasText: /^北京上海$/ }) + .first() const copyValueInput = wrap.locator('.copy-value .tiny-input__inner') - const copyIcon = select.locator('.tiny-select__copy .tiny-svg') + const copyIcon = page.locator('.copy_svg__st0') await select.hover() await expect(copyIcon).toBeVisible() diff --git a/examples/sites/demos/pc/app/select/events.spec.ts b/examples/sites/demos/pc/app/select/events.spec.ts index ae3897e614..a27e4d54f8 100644 --- a/examples/sites/demos/pc/app/select/events.spec.ts +++ b/examples/sites/demos/pc/app/select/events.spec.ts @@ -26,8 +26,8 @@ test('单选事件', async ({ page }) => { await page.waitForTimeout(200) await input.hover() - await select.locator('.tiny-select__caret.tiny-select__close').click() - await page.waitForTimeout(500) + await select.locator('.tiny-input__suffix-inner').first().click() + await page.waitForTimeout(1000) await expect(input).toHaveValue('') await expect(model.filter({ hasText: '触发 clear 事件' })).toHaveCount(1) }) @@ -65,7 +65,7 @@ test('多选事件', async ({ page }) => { await page.waitForTimeout(200) await select.hover() - await select.locator('.tiny-select__caret.tiny-select__close').click() + await select.locator('.tiny-input__suffix-inner').click() await expect(tag).toHaveCount(0) await expect(model.filter({ hasText: '触发 change 事件' })).toHaveCount(1) diff --git a/examples/sites/demos/pc/app/select/input-box-type.spec.ts b/examples/sites/demos/pc/app/select/input-box-type.spec.ts index 9148e0bb48..0c6d58b48c 100644 --- a/examples/sites/demos/pc/app/select/input-box-type.spec.ts +++ b/examples/sites/demos/pc/app/select/input-box-type.spec.ts @@ -60,7 +60,7 @@ test('下划线多选', async ({ page }) => { await expect(input).toHaveCSS('border-left-width', '0px') await expect(input).toHaveCSS('border-right-width', '0px') await expect(input).toHaveCSS('border-bottom-color', 'rgb(194, 194, 194)') - await expect(select.locator('.tiny-select__caret')).toHaveCSS('fill', 'rgb(128, 128, 128)') + await expect(select.locator('.tiny-base-select__caret')).toHaveCSS('fill', 'rgb(128, 128, 128)') await select.click() await expect(dropdown).toBeVisible() @@ -68,5 +68,5 @@ test('下划线多选', async ({ page }) => { await expect(tag).toHaveCount(5) await expect(select.locator('.tiny-input')).toHaveClass(/tiny-input-underline/) - await expect(select).toHaveClass(/tiny-select__multiple/) + await expect(select).toHaveClass(/tiny-base-select__multiple/) }) diff --git a/examples/sites/demos/pc/app/select/nest-grid-remote.spec.ts b/examples/sites/demos/pc/app/select/nest-grid-remote.spec.ts index b04dae8ed0..45cc0fc56c 100644 --- a/examples/sites/demos/pc/app/select/nest-grid-remote.spec.ts +++ b/examples/sites/demos/pc/app/select/nest-grid-remote.spec.ts @@ -9,7 +9,7 @@ test.describe('下拉表格远程搜索', () => { const select = wrap.locator('.tiny-select').nth(0) const input = select.locator('.tiny-input__inner') const dropdown = page.locator('body > .tiny-select-dropdown') - const suffixSvg = dropdown.locator('.tiny-input__suffix .tiny-select__caret') + const suffixSvg = dropdown.locator('.tiny-base-select__caret') await expect(suffixSvg).toBeHidden() await expect(dropdown).toBeHidden() @@ -45,7 +45,7 @@ test.describe('下拉表格远程搜索', () => { const select = wrap.locator('.tiny-select').nth(1) const input = select.locator('.tiny-input__inner') const dropdown = page.locator('body > .tiny-select-dropdown') - const suffixSvg = select.locator('.tiny-input__suffix .tiny-select__caret') + const suffixSvg = select.locator('.tiny-base-select__caret') await expect(suffixSvg).toBeVisible() await expect(dropdown).toBeHidden() @@ -72,7 +72,7 @@ test.describe('下拉表格远程搜索', () => { await page.goto('select#nest-grid-remote') const wrap = page.locator('#nest-grid-remote') const select = wrap.locator('.tiny-select').nth(2) - const input = select.locator('.tiny-select__input') + const input = select.locator('.tiny-base-select__input').first() const dropdown = page.locator('body > .tiny-select-dropdown') const suffixSvg = select.locator('.tiny-input__suffix .tiny-select__caret').first() @@ -80,6 +80,10 @@ test.describe('下拉表格远程搜索', () => { await expect(suffixSvg).toBeHidden() await expect(dropdown).toBeHidden() + // 先点击 select 打开下拉面板,确保输入框可见 + await select.click() + await page.waitForTimeout(200) + await input.fill(' ' + ' ') await input.press('Enter') await page.waitForTimeout(1000) @@ -90,7 +94,7 @@ test.describe('下拉表格远程搜索', () => { await page.waitForTimeout(1000) await expect(dropdown.locator('.tiny-grid__body tbody')).not.toBeEmpty() await page.getByRole('row', { name: '省份 0 城市 0 区域 0' }).getByRole('cell').first().click() - const tags = page.locator('.tiny-select .tiny-tag') + const tags = page.locator('.tiny-base-select .tiny-tag') expect((await tags.all()).length).toEqual(1) await expect(tags.first()).toContainText(/市 0/) await page.getByRole('row', { name: '省份 1 城市 1 区域 1' }).getByRole('cell').first().click() @@ -105,9 +109,9 @@ test.describe('下拉表格远程搜索', () => { const wrap = page.locator('#nest-grid-remote') const select = wrap.locator('.tiny-select').nth(3) - const input = select.locator('.tiny-select__input') + const input = select.locator('.tiny-base-select__input') const dropdown = page.locator('body > .tiny-select-dropdown') - const suffixSvg = select.locator('.tiny-input__suffix .tiny-select__caret').first() + const suffixSvg = select.locator('.tiny-base-select__caret').first() const tag = select.locator('.tiny-tag') await expect(suffixSvg).toBeVisible() diff --git a/examples/sites/demos/pc/app/select/nest-grid.spec.ts b/examples/sites/demos/pc/app/select/nest-grid.spec.ts index 94907f3be1..9144218921 100644 --- a/examples/sites/demos/pc/app/select/nest-grid.spec.ts +++ b/examples/sites/demos/pc/app/select/nest-grid.spec.ts @@ -8,7 +8,7 @@ test('嵌套表格(单选)', async ({ page }) => { const select = wrap.locator('.tiny-select').nth(0) const input = select.locator('.tiny-input__inner') const dropdown = page.locator('body > .tiny-select-dropdown') - const suffixSvg = select.locator('.tiny-select__caret') + const suffixSvg = select.locator('.tiny-base-select__caret') const row = dropdown.getByRole('row') await expect(suffixSvg).toHaveCount(1) @@ -31,7 +31,7 @@ test('嵌套表格(多选)', async ({ page }) => { const wrap = page.locator('#nest-grid') const select = wrap.locator('.tiny-select').nth(1) const dropdown = page.locator('body > .tiny-select-dropdown') - const suffixSvg = select.locator('.tiny-select__caret') + const suffixSvg = select.locator('.tiny-base-select__caret') const row = dropdown.getByRole('row') const tag = select.locator('.tiny-tag') const currentRow = dropdown.locator('.row__selected') @@ -71,7 +71,7 @@ test('嵌套表格 + 可搜索 + 可清除', async ({ page }) => { const select = wrap.locator('.tiny-select').nth(2) const input = select.locator('.tiny-input__inner') const dropdown = page.locator('body > .tiny-select-dropdown') - const suffixSvg = select.locator('.tiny-select__caret') + const suffixSvg = select.locator('.tiny-base-select__caret') const row = dropdown.getByRole('row') await input.click() diff --git a/examples/sites/demos/pc/app/select/nest-radio-grid-much-data.spec.ts b/examples/sites/demos/pc/app/select/nest-radio-grid-much-data.spec.ts index 722a5aabb3..eaa958c011 100644 --- a/examples/sites/demos/pc/app/select/nest-radio-grid-much-data.spec.ts +++ b/examples/sites/demos/pc/app/select/nest-radio-grid-much-data.spec.ts @@ -8,7 +8,7 @@ test('下拉表格大数据', async ({ page }) => { const select = wrap.locator('.tiny-select') const input = select.locator('.tiny-input__inner') const dropdown = page.locator('body > .tiny-select-dropdown') - const suffixSvg = select.locator('.tiny-input__suffix .tiny-select__caret') + const suffixSvg = select.locator('.tiny-base-select__caret') const row = dropdown.getByRole('row') await expect(suffixSvg).toHaveCount(1) diff --git a/examples/sites/demos/pc/app/select/nest-tree.spec.ts b/examples/sites/demos/pc/app/select/nest-tree.spec.ts index 84cb597763..bd275a602e 100644 --- a/examples/sites/demos/pc/app/select/nest-tree.spec.ts +++ b/examples/sites/demos/pc/app/select/nest-tree.spec.ts @@ -8,7 +8,7 @@ test('下拉树单选', async ({ page }) => { const select = wrap.locator('.tiny-select').nth(0) const input = select.locator('.tiny-input__inner') const dropdown = page.locator('body > .tiny-select-dropdown') - const suffixSvg = select.locator('.tiny-input__suffix .tiny-select__caret') + const suffixSvg = select.locator('.tiny-base-select__caret') const treeNode = dropdown.locator('.tiny-tree-node') await expect(suffixSvg).toHaveCount(1) @@ -32,7 +32,7 @@ test('下拉树多选', async ({ page }) => { const select = wrap.locator('.tiny-select').nth(1) const dropdown = page.locator('body > .tiny-select-dropdown') - const suffixSvg = select.locator('.tiny-input__suffix .tiny-select__caret') + const suffixSvg = select.locator('.tiny-base-select__caret') const treeNode = dropdown.locator('.tiny-tree-node') const checkedTreeNodes = dropdown.locator('.tiny-tree-node.is-checked') const tag = select.locator('.tiny-tag') diff --git a/examples/sites/demos/pc/app/select/popup-style-position.spec.ts b/examples/sites/demos/pc/app/select/popup-style-position.spec.ts index aa37dd9428..55c4140452 100644 --- a/examples/sites/demos/pc/app/select/popup-style-position.spec.ts +++ b/examples/sites/demos/pc/app/select/popup-style-position.spec.ts @@ -6,7 +6,7 @@ test('popup-style-position', async ({ page }) => { const wrap = page.locator('#popup-style-position') const select = wrap.locator('.tiny-select') - const dropdown = select.locator('.tiny-select__tags-group > .tiny-select-dropdown') + const dropdown = select.locator('.tiny-base-select__tags-group > .tiny-select-dropdown') await select.click() await expect(dropdown).toHaveCount(1) diff --git a/examples/sites/demos/pc/app/select/remote-method.spec.ts b/examples/sites/demos/pc/app/select/remote-method.spec.ts index 4cb249a922..dacf57368e 100644 --- a/examples/sites/demos/pc/app/select/remote-method.spec.ts +++ b/examples/sites/demos/pc/app/select/remote-method.spec.ts @@ -28,7 +28,7 @@ test('远程搜索多选 + 保留搜索关键字', async ({ page }) => { const wrap = page.locator('#remote-method') const select = wrap.locator('.tiny-select').nth(1) - const input = select.locator('.tiny-select__input') + const input = select.locator('.tiny-base-select__input') const dropdown = page.locator('body > .tiny-select-dropdown') const option = dropdown.locator('.tiny-option') const tag = select.locator('.tiny-tag') diff --git a/packages/renderless/src/base-select/index.ts b/packages/renderless/src/base-select/index.ts index 9b5d001544..a2eabc149d 100644 --- a/packages/renderless/src/base-select/index.ts +++ b/packages/renderless/src/base-select/index.ts @@ -2007,7 +2007,7 @@ export const computedGetIcon = return props.dropdownIcon ? { icon: props.dropdownIcon } : { - icon: designConfig?.icons.dropdownIcon || 'icon-delta-down', + icon: designConfig?.icons.dropdownIcon || 'icon-down-ward', isDefault: true } } diff --git a/packages/renderless/src/grid-select/index.ts b/packages/renderless/src/grid-select/index.ts index 14beb8bcc0..0b44557a4e 100644 --- a/packages/renderless/src/grid-select/index.ts +++ b/packages/renderless/src/grid-select/index.ts @@ -68,19 +68,31 @@ export const syncGridSelection = } export const handleVisibleChange = - ({ api, state }) => + ({ api, state, props }) => (visible: boolean) => { // 面板打开时,同步表格选中状态 if (visible && state.isMounted) { api.syncGridSelection() + + // 如果启用了自动搜索且是远程搜索,触发初始查询 + if (props.remote && props.remoteConfig?.autoSearch && state.firstAutoSearch !== false) { + // 触发远程搜索,使用空字符串作为初始查询 + api.filter('') + state.firstAutoSearch = false + } } } export const buildSelectConfig = ({ props, state }) => () => { - const checkRowKeys = state.gridCheckedData const selectConfig = props.selectConfig + const rawCheckRowKeys = state.gridCheckedData + const checkRowKeys = Array.isArray(rawCheckRowKeys) + ? rawCheckRowKeys + : rawCheckRowKeys && Array.isArray(rawCheckRowKeys.value) + ? rawCheckRowKeys.value + : [] return Object.assign({}, selectConfig, { checkRowKeys }) } diff --git a/packages/renderless/src/grid-select/vue.ts b/packages/renderless/src/grid-select/vue.ts index f2112e5753..beb804ad2a 100644 --- a/packages/renderless/src/grid-select/vue.ts +++ b/packages/renderless/src/grid-select/vue.ts @@ -22,7 +22,6 @@ export const api = [ 'selectChange', 'getcheckedData', 'getPluginOption', - 'initQuery', 'mounted', 'syncGridSelection', 'watchValue', @@ -30,7 +29,7 @@ export const api = [ ] export const renderless = (props, { reactive, computed, watch, onMounted, nextTick }, { vm, emit }) => { - const api = {} + const api: any = {} // 初始化 gridData,支持 { data: [], columns: [] } 格式 const initGridData = () => { @@ -54,7 +53,8 @@ export const renderless = (props, { reactive, computed, watch, onMounted, nextTi currentKey: props.multiple ? '' : props.modelValue, previousQuery: null, modelValue: props.multiple ? (Array.isArray(props.modelValue) ? [...props.modelValue] : []) : props.modelValue, - isMounted: false + isMounted: false, + firstAutoSearch: props.remoteConfig?.autoSearch || false }) Object.assign(api, { @@ -69,7 +69,7 @@ export const renderless = (props, { reactive, computed, watch, onMounted, nextTi radioChange: radioChange({ props, vm, emit, state }), selectChange: selectChange({ props, vm, emit, state, nextTick }), syncGridSelection: syncGridSelection({ props, vm, state, nextTick }), - handleVisibleChange: handleVisibleChange({ api, state }), + handleVisibleChange: handleVisibleChange({ api, state, props }), watchValue: watchValue({ api, props, vm, state }) }) diff --git a/packages/renderless/src/select-wrapper/vue.ts b/packages/renderless/src/select-wrapper/vue.ts new file mode 100644 index 0000000000..87134f2e4c --- /dev/null +++ b/packages/renderless/src/select-wrapper/vue.ts @@ -0,0 +1,143 @@ +export const api = [ + 'state', + 'resolvedComponent', + 'mergedProps', + 'listeners', + 'slotNames', + 'hasScopedDefault', + 'focus', + 'blur' +] + +export const renderless = (props, { reactive, computed, useAttrs }, { constants, vm, components }) => { + const api = {} + + const resolvedComponent = computed(() => computedResolvedComponent({ props, constants, vm, components })) + + const mergedProps = computed(() => { + const runtimeAttrs = typeof useAttrs === 'function' ? useAttrs() : null + const attrs = runtimeAttrs || vm.$attrs || {} + const className = attrs.class + const classArray = Array.isArray(className) + ? ['tiny-select', ...className] + : className + ? ['tiny-select', className] + : ['tiny-select'] + + const { class: _omitClass, ...restAttrs } = attrs + + return { + ...props, + ...restAttrs, + class: classArray + } + }) + + const slotNames = computed(() => Object.keys(vm.$slots || {}).filter((name) => name && name !== 'default')) + + const hasScopedDefault = computed(() => { + const scoped = vm.$scopedSlots?.default + if (scoped && scoped.length) { + return true + } + const slot = vm.$slots?.default + return typeof slot === 'function' && slot.length > 0 + }) + + const listeners = computed(() => { + if (vm.$listeners) { + return vm.$listeners + } + return {} + }) + + const getChildComponent = () => vm.$refs?.childComponent + + // 暴露子组件的 state,让用户可以通过 ref.state 访问子组件的状态(如 cachedOptions) + // 使用 Proxy 代理子组件的 state,实现动态访问 + const state = new Proxy( + {}, + { + get(target, prop) { + const child = getChildComponent() + return child?.state?.[prop] + }, + set(target, prop, value) { + const child = getChildComponent() + if (child?.state) { + child.state[prop] = value + return true + } + return false + }, + has(target, prop) { + const child = getChildComponent() + return prop in (child?.state || {}) + }, + ownKeys(target) { + const child = getChildComponent() + return Object.keys(child?.state || {}) + }, + getOwnPropertyDescriptor(target, prop) { + const child = getChildComponent() + const childState = child?.state || {} + if (prop in childState) { + return { + enumerable: true, + configurable: true, + value: childState[prop] + } + } + return undefined + } + } + ) + + const focus = () => { + const child = getChildComponent() + child && typeof child.focus === 'function' && child.focus() + } + + const blur = () => { + const child = getChildComponent() + child && typeof child.blur === 'function' && child.blur() + } + + const hasData = (value: any) => { + if (!value) { + return false + } + if (Array.isArray(value)) { + return value.length > 0 + } + if (typeof value === 'object') { + return Object.keys(value).length > 0 + } + return true + } + + const computedResolvedComponent = ({ props, constants, vm, components }) => { + // 优先使用传入的 components,否则从 vm.$options.components 获取 + const comps = components || vm.$options?.components || {} + + if (props.renderType === constants.TYPE.Tree || hasData(props.treeOp)) { + return comps.TinyTreeSelect || 'TinyTreeSelect' + } + if (props.renderType === constants.TYPE.Grid || hasData(props.gridOp)) { + return comps.TinyGridSelect || 'TinyGridSelect' + } + return comps.TinyBaseSelect || 'TinyBaseSelect' + } + Object.assign(api, { + state, + resolvedComponent, + mergedProps, + listeners, + slotNames, + hasScopedDefault, + focus, + blur + }) + + return api +} diff --git a/packages/renderless/src/tree-select/index.ts b/packages/renderless/src/tree-select/index.ts index 46f0027925..d2af7a3e97 100644 --- a/packages/renderless/src/tree-select/index.ts +++ b/packages/renderless/src/tree-select/index.ts @@ -156,17 +156,22 @@ export const getChildValue = () => (childNodes, key) => { export const mounted = ({ api, state, props, vm }) => () => { - if (!state.modelValue || state.modelValue.length === 0) return + if (!state.modelValue || (Array.isArray(state.modelValue) && state.modelValue.length === 0)) return if (props.multiple) { let initialNodes = [] if (Array.isArray(state.modelValue)) { state.modelValue.forEach((value) => { const option = api.getPluginOption(value) - initialNodes = initialNodes.concat(option) + if (option && option.length > 0) { + initialNodes = initialNodes.concat(option) + } }) } + // 如果没有找到任何节点(例如懒加载场景),直接返回 + if (initialNodes.length === 0) return + const selected = initialNodes.map((node) => { return { ...node, @@ -179,7 +184,12 @@ export const mounted = state.defaultCheckedKeys = api.getCheckedData(selected) } else { - const data = api.getPluginOption(state.modelValue)[0] + const options = api.getPluginOption(state.modelValue) + const data = options && options.length > 0 ? options[0] : null + + // 如果没有找到节点(例如懒加载场景),直接返回 + if (!data) return + vm.$refs.baseSelectRef.updateSelectedData({ ...data, currentLabel: data[props.textField], @@ -224,7 +234,9 @@ export const watchValue = if (Array.isArray(checkedKeys)) { checkedKeys.forEach((value) => { const option = api.getPluginOption(value) - initialNodes = initialNodes.concat(option) + if (option && option.length > 0) { + initialNodes = initialNodes.concat(option) + } }) } diff --git a/packages/renderless/src/tree-select/vue.ts b/packages/renderless/src/tree-select/vue.ts index 73fae305e2..e2e0c26ffe 100644 --- a/packages/renderless/src/tree-select/vue.ts +++ b/packages/renderless/src/tree-select/vue.ts @@ -15,12 +15,22 @@ export const api = ['state', 'check', 'filter', 'nodeClick'] export const renderless = (props, { reactive, computed, watch, onMounted }, { vm, emit }) => { const api = {} + const resolveTreeData = () => { + if (Array.isArray(props.treeOp)) { + return props.treeOp + } + if (props.treeOp && Array.isArray(props.treeOp.data)) { + return props.treeOp.data + } + return [] + } + const state = reactive({ childrenName: computed(() => (props.treeOp.props && props.treeOp.props.children) || 'children'), currentKey: props.modelValue, defaultCheckedKeys: [], remoteData: [], - treeData: props.treeOp.data, + treeData: resolveTreeData(), modelValue: [] }) @@ -38,8 +48,12 @@ export const renderless = (props, { reactive, computed, watch, onMounted }, { vm }) watch( - () => props.treeOp.data, - (data) => data && (state.treeData = data), + () => (Array.isArray(props.treeOp) ? props.treeOp : props.treeOp?.data), + (data) => { + if (Array.isArray(data)) { + state.treeData = data + } + }, { immediate: true, deep: true } ) diff --git a/packages/theme/src/option/index.less b/packages/theme/src/option/index.less index 547e9db1d2..7ffc7e6acb 100644 --- a/packages/theme/src/option/index.less +++ b/packages/theme/src/option/index.less @@ -92,6 +92,7 @@ text-overflow: ellipsis; white-space: nowrap; vertical-align: top; + padding-top: 3px; } } @@ -104,6 +105,10 @@ color: var(--tv-Option-text-color-selected); } + &__checkbox-wrap { + display: flex; + } + &.memorize-highlight { color: var(--tv-Option-text-color-highlight); } diff --git a/packages/vue/src/base-select/src/pc.vue b/packages/vue/src/base-select/src/pc.vue index ed3b1fe917..03d451ec5b 100644 --- a/packages/vue/src/base-select/src/pc.vue +++ b/packages/vue/src/base-select/src/pc.vue @@ -250,8 +250,8 @@ @input="debouncedQueryChange" :style="{ 'flex-grow': '1', - width: state.inputLength / (state.inputWidth - 32) + '%', - 'max-width': state.inputWidth - 42 + 'px', + width: state.inputWidth > 0 ? state.inputLength / (state.inputWidth - 32) + '%' : 'auto', + 'max-width': state.inputWidth > 0 ? state.inputWidth - 42 + 'px' : 'none', height: 'auto' }" /> @@ -538,6 +538,7 @@ {{ state.emptyText }} diff --git a/packages/vue/src/select/src/pc.vue b/packages/vue/src/select/src/pc.vue index 36c1ec8943..93ee29fe97 100644 --- a/packages/vue/src/select/src/pc.vue +++ b/packages/vue/src/select/src/pc.vue @@ -1,786 +1,316 @@ - -