From db30284e7a24f14544c2c3b758c7912e98d3768a Mon Sep 17 00:00:00 2001 From: Benjamin Canac Date: Wed, 10 Jul 2024 12:56:38 +0200 Subject: [PATCH] feat(SelectMenu): add prop to disable search --- src/runtime/components/SelectMenu.vue | 8 +- test/components/SelectMenu.spec.ts | 1 + .../__snapshots__/SelectMenu.spec.ts.snap | 938 +++++++++--------- 3 files changed, 502 insertions(+), 445 deletions(-) diff --git a/src/runtime/components/SelectMenu.vue b/src/runtime/components/SelectMenu.vue index a731b36b..7fbc2aa6 100644 --- a/src/runtime/components/SelectMenu.vue +++ b/src/runtime/components/SelectMenu.vue @@ -30,6 +30,11 @@ export interface SelectMenuProps extends Pick, 'modelVal id?: string /** The placeholder text when the select is empty. */ placeholder?: string + /** + * Wether to display the search input or not. + * @defaultValue true + */ + search?: boolean /** The placeholder text when the search input is empty. */ searchPlaceholder?: string color?: SelectMenuVariants['color'] @@ -109,6 +114,7 @@ import { UIcon, UChip, UAvatar } from '#components' import { get } from '../utils' const props = withDefaults(defineProps>(), { + search: true, portal: true, autofocusDelay: 0, searchPlaceholder: 'Search...', @@ -234,7 +240,7 @@ function onUpdateOpen(value: boolean) { - + diff --git a/test/components/SelectMenu.spec.ts b/test/components/SelectMenu.spec.ts index 847fd153..334087c7 100644 --- a/test/components/SelectMenu.spec.ts +++ b/test/components/SelectMenu.spec.ts @@ -45,6 +45,7 @@ describe('SelectMenu', () => { ['with name', { props: { ...props, name: 'name' } }], ['with placeholder', { props: { ...props, placeholder: 'Search...' } }], ['with searchPlaceholder', { props: { ...props, searchPlaceholder: 'Filter items...' } }], + ['without search', { props: { ...props, search: false } }], ['with disabled', { props: { ...props, disabled: true } }], ['with required', { props: { ...props, required: true } }], ['with icon', { props: { ...props, icon: 'i-heroicons-magnifying-glass' } }], diff --git a/test/components/__snapshots__/SelectMenu.spec.ts.snap b/test/components/__snapshots__/SelectMenu.spec.ts.snap index 8a0062b6..ebb18ba5 100644 --- a/test/components/__snapshots__/SelectMenu.spec.ts.snap +++ b/test/components/__snapshots__/SelectMenu.spec.ts.snap @@ -8,23 +8,23 @@ exports[`SelectMenu > renders with arrow correctly 1`] = `
-
+