From d91fc8f5a8ae17da15e0df18df3f406aae46afd8 Mon Sep 17 00:00:00 2001 From: kric_jspark Date: Tue, 3 Nov 2026 08:37:04 +0900 Subject: [PATCH] =?UTF-8?q?261103=5F01=5FFIX:=20KriAutoComplete=20?= =?UTF-8?q?=EA=B8=B0=EB=B3=B8=20=EA=B2=80=EC=83=89=EC=9D=84=20contains=20?= =?UTF-8?q?=EB=B0=A9=EC=8B=9D=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/common/KriAutoComplete.tsx | 9 +++++++-- src/components/common/multi-select/MultiSelect.tsx | 2 ++ .../common/multi-select/MultiSelectContent.tsx | 10 ++++++++-- src/components/common/multi-select/index.ts | 1 + src/components/common/multi-select/types.ts | 2 ++ 5 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/components/common/KriAutoComplete.tsx b/src/components/common/KriAutoComplete.tsx index 1aa29e5..2621a71 100644 --- a/src/components/common/KriAutoComplete.tsx +++ b/src/components/common/KriAutoComplete.tsx @@ -3,14 +3,15 @@ import * as React from 'react' import { cn } from '@/lib/utils' import { MultiSelect } from '@/components/common/multi-select' -import type { MultiSelectOption, MultiSelectRef } from '@/components/common/multi-select' +import type { MultiSelectOption, MultiSelectRef, MultiSelectSearchMatch } from '@/components/common/multi-select' -export type { MultiSelectOption, MultiSelectRef } from '@/components/common/multi-select' +export type { MultiSelectOption, MultiSelectRef, MultiSelectSearchMatch } from '@/components/common/multi-select' export interface KriAutoCompleteBaseProps { items: T[] searchable?: boolean searchMode?: 'filter' | 'inputOnly' + searchMatch?: MultiSelectSearchMatch defaultSearchValue?: string onSearchValueChange?: (value: string) => void placeholder?: string @@ -58,6 +59,7 @@ export function KriMultiSelect({ onChange, searchable = true, searchMode = 'filter', + searchMatch = 'contains', defaultSearchValue = '', onSearchValueChange, maxCount = 1, @@ -100,6 +102,7 @@ export function KriMultiSelect({ badgeLabelClassName={badgeLabelClassName} searchable={searchable} searchMode={searchMode} + searchMatch={searchMatch} defaultSearchValue={defaultSearchValue} onSearchValueChange={onSearchValueChange} maxCount={maxCount} @@ -135,6 +138,7 @@ function KriSingleSelectInner( onChange, searchable = true, searchMode = 'filter', + searchMatch = 'contains', defaultSearchValue = '', onSearchValueChange, placeholder = '옵션을 선택하세요', @@ -216,6 +220,7 @@ function KriSingleSelectInner( badgeLabelClassName={badgeLabelClassName ?? 'min-w-0 flex-1'} searchable={searchable} searchMode={searchMode} + searchMatch={searchMatch} defaultSearchValue={defaultSearchValue} onSearchValueChange={onSearchValueChange} preventDeselect={preventDeselect} diff --git a/src/components/common/multi-select/MultiSelect.tsx b/src/components/common/multi-select/MultiSelect.tsx index 50981de..57dd2e5 100644 --- a/src/components/common/multi-select/MultiSelect.tsx +++ b/src/components/common/multi-select/MultiSelect.tsx @@ -31,6 +31,7 @@ function MultiSelectInner( hideSelectAll = false, searchable = true, searchMode = 'filter', + searchMatch = 'fuzzy', defaultSearchValue = '', onSearchValueChange, emptyIndicator = '검색 결과가 없습니다.', @@ -201,6 +202,7 @@ function MultiSelectInner( selectedValues={selectedValues} searchable={searchable} searchMode={searchMode} + searchMatch={searchMatch} searchValue={searchValue} onSearchValueChange={handleSearchChange} hideSelectAll={hideSelectAll} diff --git a/src/components/common/multi-select/MultiSelectContent.tsx b/src/components/common/multi-select/MultiSelectContent.tsx index 905f117..eddd1eb 100644 --- a/src/components/common/multi-select/MultiSelectContent.tsx +++ b/src/components/common/multi-select/MultiSelectContent.tsx @@ -11,14 +11,19 @@ import { CommandSeparator, } from '@/components/ui/command' import { cn } from '@/lib/utils' -import type { MultiSelectGroup, MultiSelectOption, MultiSelectOptions } from './types' +import type { MultiSelectGroup, MultiSelectOption, MultiSelectOptions, MultiSelectSearchMatch } from './types' import { isGroupedOptions } from './utils' +function containsFilter(value: string, search: string) { + return value.toLowerCase().includes(search.toLowerCase()) ? 1 : 0 +} + interface MultiSelectContentProps { options: MultiSelectOptions selectedValues: string[] searchable: boolean searchMode: 'filter' | 'inputOnly' + searchMatch?: MultiSelectSearchMatch searchValue: string onSearchValueChange: (value: string) => void hideSelectAll: boolean @@ -96,6 +101,7 @@ export function MultiSelectContent({ selectedValues, searchable, searchMode, + searchMatch = 'fuzzy', searchValue, onSearchValueChange, hideSelectAll, @@ -111,7 +117,7 @@ export function MultiSelectContent({ const allSelected = selectableOptions.length > 0 && selectableOptions.every((option) => selectedValues.includes(option.value)) return ( - + {searchable ? ( { export type MultiSelectOptions = MultiSelectOption[] | MultiSelectGroup[] export type MultiSelectSelectionMode = 'single' | 'multiple' +export type MultiSelectSearchMatch = 'fuzzy' | 'contains' export type MultiSelectVariant = 'default' | 'secondary' | 'destructive' | 'inverted' export interface MultiSelectResponsiveSettings { @@ -65,6 +66,7 @@ export interface MultiSelectProps hideSelectAll?: boolean searchable?: boolean searchMode?: 'filter' | 'inputOnly' + searchMatch?: MultiSelectSearchMatch defaultSearchValue?: string onSearchValueChange?: (value: string) => void emptyIndicator?: React.ReactNode -- 2.49.0.windows.1