Merge pull request '261103_01_FIX: KriAutoComplete 기본 검색을 contains 방식으로 변경' (#70) from develop into master

Reviewed-on: #70
This commit is contained in:
2026-11-03 09:03:23 +09:00
5 changed files with 20 additions and 4 deletions

View File

@@ -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<T> {
items: T[]
searchable?: boolean
searchMode?: 'filter' | 'inputOnly'
searchMatch?: MultiSelectSearchMatch
defaultSearchValue?: string
onSearchValueChange?: (value: string) => void
placeholder?: string
@@ -58,6 +59,7 @@ export function KriMultiSelect<T = unknown>({
onChange,
searchable = true,
searchMode = 'filter',
searchMatch = 'contains',
defaultSearchValue = '',
onSearchValueChange,
maxCount = 1,
@@ -100,6 +102,7 @@ export function KriMultiSelect<T = unknown>({
badgeLabelClassName={badgeLabelClassName}
searchable={searchable}
searchMode={searchMode}
searchMatch={searchMatch}
defaultSearchValue={defaultSearchValue}
onSearchValueChange={onSearchValueChange}
maxCount={maxCount}
@@ -135,6 +138,7 @@ function KriSingleSelectInner<T>(
onChange,
searchable = true,
searchMode = 'filter',
searchMatch = 'contains',
defaultSearchValue = '',
onSearchValueChange,
placeholder = '옵션을 선택하세요',
@@ -216,6 +220,7 @@ function KriSingleSelectInner<T>(
badgeLabelClassName={badgeLabelClassName ?? 'min-w-0 flex-1'}
searchable={searchable}
searchMode={searchMode}
searchMatch={searchMatch}
defaultSearchValue={defaultSearchValue}
onSearchValueChange={onSearchValueChange}
preventDeselect={preventDeselect}

View File

@@ -31,6 +31,7 @@ function MultiSelectInner<T>(
hideSelectAll = false,
searchable = true,
searchMode = 'filter',
searchMatch = 'fuzzy',
defaultSearchValue = '',
onSearchValueChange,
emptyIndicator = '검색 결과가 없습니다.',
@@ -201,6 +202,7 @@ function MultiSelectInner<T>(
selectedValues={selectedValues}
searchable={searchable}
searchMode={searchMode}
searchMatch={searchMatch}
searchValue={searchValue}
onSearchValueChange={handleSearchChange}
hideSelectAll={hideSelectAll}

View File

@@ -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<T> {
options: MultiSelectOptions<T>
selectedValues: string[]
searchable: boolean
searchMode: 'filter' | 'inputOnly'
searchMatch?: MultiSelectSearchMatch
searchValue: string
onSearchValueChange: (value: string) => void
hideSelectAll: boolean
@@ -96,6 +101,7 @@ export function MultiSelectContent<T>({
selectedValues,
searchable,
searchMode,
searchMatch = 'fuzzy',
searchValue,
onSearchValueChange,
hideSelectAll,
@@ -111,7 +117,7 @@ export function MultiSelectContent<T>({
const allSelected = selectableOptions.length > 0 && selectableOptions.every((option) => selectedValues.includes(option.value))
return (
<Command shouldFilter={searchMode === 'filter'}>
<Command shouldFilter={searchMode === 'filter'} filter={searchMatch === 'contains' ? containsFilter : undefined}>
{searchable ? (
<CommandInput
value={searchValue}

View File

@@ -3,6 +3,7 @@ export type {
AnimationConfig,
MultiSelectGroup,
MultiSelectOption,
MultiSelectSearchMatch,
MultiSelectOptions,
MultiSelectProps,
MultiSelectRef,

View File

@@ -28,6 +28,7 @@ export interface MultiSelectGroup<T = unknown> {
export type MultiSelectOptions<T = unknown> = MultiSelectOption<T>[] | MultiSelectGroup<T>[]
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<T = unknown>
hideSelectAll?: boolean
searchable?: boolean
searchMode?: 'filter' | 'inputOnly'
searchMatch?: MultiSelectSearchMatch
defaultSearchValue?: string
onSearchValueChange?: (value: string) => void
emptyIndicator?: React.ReactNode