diff --git a/.agent/consumer.md b/.agent/consumer.md index 33108a2..76d2d48 100644 --- a/.agent/consumer.md +++ b/.agent/consumer.md @@ -17,6 +17,11 @@ When implementing or changing frontend UI, use this order: - `kri-auto-complete` exposes `optionTooltip?: 'singleLine' | 'wrap'` and `optionTooltipClassName?: string` on `KriSingleSelect`, `KriMultiSelect`, and `MultiSelect`. It is off by default, preserving existing behavior. - When enabled, hovering an option shows its full `label` in a right-side tooltip. `singleLine` stays on one line until the available viewport width; `wrap` wraps at 28rem. The item depends on the shadcn `tooltip` component and provides its own `TooltipProvider`. +### KriAutoComplete Search Match + +- `kri-auto-complete` exposes `searchMatch?: 'fuzzy' | 'contains'` on `KriSingleSelect`, `KriMultiSelect`, and `MultiSelect`. It defaults to `fuzzy` (cmdk's default subsequence scoring), preserving existing behavior. +- `contains` keeps only options whose label or value contains the search text as a case-insensitive substring, in the original option order. It applies only when `searchMode` is `filter`. + ### KriEditor SMS Preview - `changeSmsType` reports `SMS | LMS | MMS`. Update consumer callbacks to handle `MMS`; this widens the previous callback contract. diff --git a/.tooling/components/ui/command.tsx b/.tooling/components/ui/command.tsx index dcc77ac..84d7736 100644 --- a/.tooling/components/ui/command.tsx +++ b/.tooling/components/ui/command.tsx @@ -4,9 +4,10 @@ import { cn } from "@/lib/utils"; export interface CommandProps extends HTMLAttributes { shouldFilter?: boolean; + filter?: (value: string, search: string, keywords?: string[]) => number; } -export function Command({ className, shouldFilter, ...props }: CommandProps) { +export function Command({ className, shouldFilter, filter: _filter, ...props }: CommandProps) { return
; } diff --git a/AGENTS.md b/AGENTS.md index 3e74d62..afac27a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -253,6 +253,11 @@ When implementing or changing frontend UI, use this order: - `kri-auto-complete` exposes `optionTooltip?: 'singleLine' | 'wrap'` and `optionTooltipClassName?: string` on `KriSingleSelect`, `KriMultiSelect`, and `MultiSelect`. It is off by default, preserving existing behavior. - When enabled, hovering an option shows its full `label` in a right-side tooltip. `singleLine` stays on one line until the available viewport width; `wrap` wraps at 28rem. The item depends on the shadcn `tooltip` component and provides its own `TooltipProvider`. +### KriAutoComplete Search Match + +- `kri-auto-complete` exposes `searchMatch?: 'fuzzy' | 'contains'` on `KriSingleSelect`, `KriMultiSelect`, and `MultiSelect`. It defaults to `fuzzy` (cmdk's default subsequence scoring), preserving existing behavior. +- `contains` keeps only options whose label or value contains the search text as a case-insensitive substring, in the original option order. It applies only when `searchMode` is `filter`. + ### KriEditor SMS Preview - `changeSmsType` reports `SMS | LMS | MMS`. Update consumer callbacks to handle `MMS`; this widens the previous callback contract. diff --git a/README.md b/README.md index 4c86e5a..3f087d8 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,21 @@ npx shadcn@latest add https://ui-registry.kric.com/r/kri-dialog.json /> ``` +## KriAutoComplete 검색 일치 방식 + +`kri-auto-complete`의 `KriSingleSelect`, `KriMultiSelect`와 내부 `MultiSelect`는 `searchMatch?: 'fuzzy' | 'contains'`를 지원합니다. 기본값은 `fuzzy`(cmdk 기본 부분열 점수 방식)로 기존 동작을 유지합니다. + +`contains`이면 검색어를 대소문자 구분 없이 그대로 포함하는 옵션(라벨 또는 값)만 원래 순서대로 표시합니다. 예를 들어 `건설`은 `건`과 `설`이 떨어져 있는 항목과 일치하지 않습니다. `searchMode="filter"`일 때만 적용됩니다. + +```tsx + +``` + ## KRI Chart `kri-chart`는 `echarts`, `echarts-for-react` 기반 공통 차트 컴포넌트입니다. 내부적으로 `BaseEChart`를 사용하며, 모든 wrapper는 멀티 시리즈를 지원합니다. diff --git a/package-lock.json b/package-lock.json index 973b2c2..813fc14 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "kri-ui-registry", - "version": "0.15.2", + "version": "0.15.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "kri-ui-registry", - "version": "0.15.2", + "version": "0.15.3", "devDependencies": { "@tanstack/react-table": "^8.21.3", "@tiptap/extension-color": "^3.27.1", diff --git a/package.json b/package.json index b72d7f3..c79a51b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "kri-ui-registry", - "version": "0.15.2", + "version": "0.15.3", "private": true, "description": "KRI internal shadcn UI registry", "scripts": { diff --git a/registry/components/KriAutoComplete.tsx b/registry/components/KriAutoComplete.tsx index cec733e..a070c18 100644 --- a/registry/components/KriAutoComplete.tsx +++ b/registry/components/KriAutoComplete.tsx @@ -3,14 +3,25 @@ import * as React from 'react' import { cn } from '@/lib/utils' import { MultiSelect } from '@/components/common/multi-select' -import type { MultiSelectOption, MultiSelectOptionTooltip, MultiSelectRef } from '@/components/common/multi-select' +import type { + MultiSelectOption, + MultiSelectOptionTooltip, + MultiSelectRef, + MultiSelectSearchMatch, +} from '@/components/common/multi-select' -export type { MultiSelectOption, MultiSelectOptionTooltip, MultiSelectRef } from '@/components/common/multi-select' +export type { + MultiSelectOption, + MultiSelectOptionTooltip, + MultiSelectRef, + MultiSelectSearchMatch, +} from '@/components/common/multi-select' export interface KriAutoCompleteBaseProps { items: T[] searchable?: boolean searchMode?: 'filter' | 'inputOnly' + searchMatch?: MultiSelectSearchMatch resetScrollOnSearch?: boolean defaultSearchValue?: string onSearchValueChange?: (value: string) => void @@ -59,6 +70,7 @@ export function KriMultiSelect({ onChange, searchable = true, searchMode = 'filter', + searchMatch = 'fuzzy', resetScrollOnSearch = false, defaultSearchValue = '', onSearchValueChange, @@ -102,6 +114,7 @@ export function KriMultiSelect({ badgeClassName={badgeClassName} searchable={searchable} searchMode={searchMode} + searchMatch={searchMatch} resetScrollOnSearch={resetScrollOnSearch} defaultSearchValue={defaultSearchValue} onSearchValueChange={onSearchValueChange} @@ -140,6 +153,7 @@ function KriSingleSelectInner({ onChange, searchable = true, searchMode = 'filter', + searchMatch = 'fuzzy', resetScrollOnSearch = false, defaultSearchValue = '', onSearchValueChange, @@ -220,6 +234,7 @@ function KriSingleSelectInner({ badgeClassName={badgeClassName} searchable={searchable} searchMode={searchMode} + searchMatch={searchMatch} resetScrollOnSearch={resetScrollOnSearch} defaultSearchValue={defaultSearchValue} onSearchValueChange={onSearchValueChange} diff --git a/registry/components/multi-select/MultiSelect.tsx b/registry/components/multi-select/MultiSelect.tsx index 53c7207..0a13d0c 100644 --- a/registry/components/multi-select/MultiSelect.tsx +++ b/registry/components/multi-select/MultiSelect.tsx @@ -30,6 +30,7 @@ function MultiSelectInner( hideSelectAll = false, searchable = true, searchMode = 'filter', + searchMatch = 'fuzzy', resetScrollOnSearch = false, defaultSearchValue = '', onSearchValueChange, @@ -202,6 +203,7 @@ function MultiSelectInner( selectedValues={selectedValues} searchable={searchable} searchMode={searchMode} + searchMatch={searchMatch} resetScrollOnSearch={resetScrollOnSearch} searchValue={searchValue} onSearchValueChange={handleSearchChange} diff --git a/registry/components/multi-select/MultiSelectContent.tsx b/registry/components/multi-select/MultiSelectContent.tsx index 27957f5..98e3fda 100644 --- a/registry/components/multi-select/MultiSelectContent.tsx +++ b/registry/components/multi-select/MultiSelectContent.tsx @@ -13,14 +13,26 @@ import { } from '@/components/ui/command' import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip' import { cn } from '@/lib/utils' -import type { MultiSelectGroup, MultiSelectOption, MultiSelectOptionTooltip, MultiSelectOptions } from './types' +import type { + MultiSelectGroup, + MultiSelectOption, + MultiSelectOptionTooltip, + MultiSelectOptions, + MultiSelectSearchMatch, +} from './types' import { isGroupedOptions } from './utils' +// Case-insensitive substring match; equal scores keep the original option order. +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 resetScrollOnSearch?: boolean onSearchValueChange: (value: string) => void @@ -134,6 +146,7 @@ export function MultiSelectContent({ selectedValues, searchable, searchMode, + searchMatch = 'fuzzy', searchValue, resetScrollOnSearch = false, onSearchValueChange, @@ -164,7 +177,10 @@ export function MultiSelectContent({ const tooltip = optionTooltip ? { mode: optionTooltip, className: optionTooltipClassName } : undefined const content = ( - + {searchable ? ( = MultiSelectOption[] | MultiSele export type MultiSelectSelectionMode = 'single' | 'multiple' export type MultiSelectVariant = 'default' | 'secondary' | 'destructive' | 'inverted' export type MultiSelectOptionTooltip = 'singleLine' | 'wrap' +export type MultiSelectSearchMatch = 'fuzzy' | 'contains' export interface MultiSelectResponsiveSettings { maxCount?: number @@ -65,6 +66,7 @@ export interface MultiSelectProps hideSelectAll?: boolean searchable?: boolean searchMode?: 'filter' | 'inputOnly' + searchMatch?: MultiSelectSearchMatch resetScrollOnSearch?: boolean defaultSearchValue?: string onSearchValueChange?: (value: string) => void