260714_01_ENH: 테스트 서버에서 기동 후 중간 테스트를 위한 커밋

This commit is contained in:
2026-07-14 10:59:07 +09:00
parent a8ce35f5bf
commit 192d47bdb1
180 changed files with 11942 additions and 6007 deletions

View File

@@ -2,15 +2,17 @@
import * as React from 'react'
import { cn } from '@/lib/utils'
import {MultiSelect, MultiSelectRef} from '@/components/ui/multi-select'
import type { MultiSelectOption } from '@/components/ui/multi-select'
import { MultiSelect } from '@/components/common/multi-select'
import type { MultiSelectOption, MultiSelectRef } from '@/components/common/multi-select'
type BaseProps<T> = {
export type { MultiSelectOption, MultiSelectRef } from '@/components/common/multi-select'
export interface KriAutoCompleteBaseProps<T> {
items: T[]
searchable?: boolean
searchMode?: "filter" | "inputOnly";
defaultSearchValue?: string;
onSearchValueChange?: (value: string) => void;
searchMode?: 'filter' | 'inputOnly'
defaultSearchValue?: string
onSearchValueChange?: (value: string) => void
placeholder?: string
widthClassName?: string
heightClassName?: string
@@ -19,219 +21,185 @@ type BaseProps<T> = {
className?: string
getValue?: (item: T) => string
getLabel?: (item: T) => string
/** ✅ 옵션: 원본 item을 option.info에 실어둘지 */
withInfo?: boolean
disabled?: boolean
}
type KriMultiSelectProps<T = unknown> = BaseProps<T> & {
export interface KriMultiSelectProps<T = unknown> extends KriAutoCompleteBaseProps<T> {
value: string[]
onChange: (value: string[]) => void
maxCount?: number
maxSelected?: number
hideSelectAll?: boolean
/** ✅ withInfo=true일 때만 의미 있게 쓰면 됨 */
onItemsChange?: (items: T[]) => void
onOptionsChange?: (options: MultiSelectOption<T>[]) => void
}
function toOptions<T>(
items: T[],
getValue: ((item: T) => string) | undefined,
getLabel: ((item: T) => string) | undefined,
withInfo: boolean,
): MultiSelectOption<T>[] {
return items.map((item) => ({
value: getValue ? getValue(item) : String(item),
label: getLabel ? getLabel(item) : String(item),
...(withInfo ? { info: item } : {}),
}))
}
export function KriMultiSelect<T = unknown>({
items,
value,
onChange,
searchable = true,
searchMode = "filter",
defaultSearchValue = "",
onSearchValueChange,
maxCount = 1,
maxSelected,
hideSelectAll = false,
placeholder = 'Select options',
widthClassName,
heightClassName,
spanClassName = "text-lg",
badgeClassName = "text-lg",
className,
getValue,
getLabel,
withInfo = false,
onItemsChange,
onOptionsChange,
}: KriMultiSelectProps<T>) {
const msRef = React.useRef<MultiSelectRef>(null);
const extractValue = React.useCallback(
(item: T) => (getValue ? getValue(item) : String(item)),
[getValue]
items,
value,
onChange,
searchable = true,
searchMode = 'filter',
defaultSearchValue = '',
onSearchValueChange,
maxCount = 1,
maxSelected,
hideSelectAll = false,
placeholder = 'Select options',
widthClassName,
heightClassName,
spanClassName = 'text-base',
badgeClassName = 'text-base',
className,
getValue,
getLabel,
withInfo = false,
onItemsChange,
onOptionsChange,
disabled,
}: KriMultiSelectProps<T>) {
const options = React.useMemo(
() => toOptions(items, getValue, getLabel, withInfo),
[getLabel, getValue, items, withInfo],
)
const extractLabel = React.useCallback(
(item: T) => (getLabel ? getLabel(item) : String(item)),
[getLabel]
)
const options = React.useMemo<MultiSelectOption<T>[]>(() => {
return items.map((item) => ({
value: extractValue(item),
label: extractLabel(item),
...(withInfo ? { info: item } : {}), // ✅ 필요할 때만 info를 실음
}))
}, [items, extractValue, extractLabel, withInfo])
return (
<div className={cn(widthClassName, heightClassName, "flex-none overflow-hidden")}>
<MultiSelect<T>
ref={msRef}
options={options}
defaultValue={value}
onValueChange={onChange}
onOptionChange={onOptionsChange}
onInfoChange={onItemsChange}
maxSelected={maxSelected}
placeholder={placeholder}
className={cn("bg-white text-lg", className)}
spanClassName={spanClassName}
badgeClassName={badgeClassName}
searchable={searchable}
searchMode={searchMode}
defaultSearchValue={defaultSearchValue}
onSearchValueChange={onSearchValueChange}
maxCount={maxCount}
hideSelectAll={hideSelectAll}
autoSize
singleLine
resetOnDefaultValueChange
deduplicateOptions
/>
</div>
<div className={cn('flex-none', widthClassName, heightClassName)}>
<MultiSelect<T>
options={options}
defaultValue={value}
onValueChange={onChange}
onOptionChange={onOptionsChange}
onInfoChange={onItemsChange}
maxSelected={maxSelected}
placeholder={placeholder}
className={cn('bg-background text-base', !widthClassName && 'w-auto', className)}
spanClassName={spanClassName}
badgeClassName={badgeClassName}
searchable={searchable}
searchMode={searchMode}
defaultSearchValue={defaultSearchValue}
onSearchValueChange={onSearchValueChange}
maxCount={maxCount}
hideSelectAll={hideSelectAll}
singleLine
resetOnDefaultValueChange
deduplicateOptions
disabled={disabled}
/>
</div>
)
}
type KriSingleSelectProps<T = unknown> = BaseProps<T> & {
export interface KriSingleSelectProps<T = unknown> extends KriAutoCompleteBaseProps<T> {
value: string
onChange: (value: string) => void
onItemChange?: (item: T | null) => void
onOptionChange?: (option: MultiSelectOption<T> | null) => void
preventDeselect?: boolean;
hideOptionCheck?: boolean;
preventDeselect?: boolean
hideOptionCheck?: boolean
useClear?: boolean
clearLabel?: string
clearValue?: string
showSelectedTooltip?: boolean
}
export function KriSingleSelect<T = unknown>({
items,
value,
onChange,
searchable = true,
searchMode = "filter",
defaultSearchValue = "",
onSearchValueChange,
placeholder = 'Select an option',
heightClassName,
widthClassName,
spanClassName = "text-lg",
badgeClassName = "text-lg",
className,
getValue,
getLabel,
withInfo = false,
onItemChange,
onOptionChange,
preventDeselect = false,
hideOptionCheck = false,
showSelectedTooltip = false,
useClear = false,
clearLabel = "선택 해제",
clearValue = "__CLEAR__",
}: KriSingleSelectProps<T>) {
const msRef = React.useRef<MultiSelectRef>(null);
const extractValue = React.useCallback(
(item: T) => (getValue ? getValue(item) : String(item)),
[getValue]
)
const extractLabel = React.useCallback(
(item: T) => (getLabel ? getLabel(item) : String(item)),
[getLabel]
)
const options = React.useMemo<MultiSelectOption<T>[]>(() => {
const special: MultiSelectOption<T>[] = [];
if (useClear) special.push({ value: clearValue, label: clearLabel });
const normal = items.map((item) => ({
value: extractValue(item),
label: extractLabel(item),
...(withInfo ? { info: item } : {}),
}));
return [...special, ...normal]
}, [items, extractValue, extractLabel, withInfo, useClear, clearLabel, clearValue])
const defaultValue = React.useMemo(() => (value ? [value] : []), [value])
const tooltipText = React.useMemo(() => {
if (!showSelectedTooltip) return undefined;
if (!value || !value) return undefined;
if (useClear && value === clearValue) return undefined;
const label = options.find(o => o.value === value)?.label;
return label ?? value; // options에 없으면 value라도 표시
}, [showSelectedTooltip, value, options, useClear, clearValue]);
items,
value,
onChange,
searchable = true,
searchMode = 'filter',
defaultSearchValue = '',
onSearchValueChange,
placeholder = 'Select an option',
heightClassName,
widthClassName,
spanClassName = 'text-base',
badgeClassName = 'text-base',
className,
getValue,
getLabel,
withInfo = false,
onItemChange,
onOptionChange,
preventDeselect = false,
hideOptionCheck = false,
showSelectedTooltip = false,
useClear = false,
clearLabel = '선택 해제',
clearValue = '__CLEAR__',
disabled,
}: KriSingleSelectProps<T>) {
const ref = React.useRef<MultiSelectRef>(null)
const options = React.useMemo(() => {
const normal = toOptions(items, getValue, getLabel, withInfo)
return useClear ? [{ value: clearValue, label: clearLabel }, ...normal] : normal
}, [clearLabel, clearValue, getLabel, getValue, items, useClear, withInfo])
const selectedLabel = options.find((option) => option.value === value)?.label
return (
<div className={cn(widthClassName, heightClassName, "flex-none overflow-hidden")}>
<MultiSelect<T>
ref={msRef}
options={options}
defaultValue={defaultValue}
onValueChange={(next) => {
const v = next[0] ?? ""
if (v === clearValue) {
msRef.current?.clear();
onChange("")
onOptionChange?.(null)
onItemChange?.(null)
return
}
onChange(v)
}}
onOptionChange={(opts) => {
const opt = opts[0] ?? null
const item = withInfo ? ((opt as any)?.info ?? null) : null
onOptionChange?.(opt)
onItemChange?.(item)
}}
selectionMode="single"
maxCount={1}
maxSelected={1}
placeholder={placeholder}
className={cn("bg-white text-lg", className)}
spanClassName={spanClassName}
badgeClassName={badgeClassName}
searchable={searchable}
searchMode={searchMode}
defaultSearchValue={defaultSearchValue}
onSearchValueChange={onSearchValueChange}
preventDeselect={preventDeselect}
hideOptionCheck={hideOptionCheck}
hideSelectAll
autoSize
singleLine
closeOnSelect
resetOnDefaultValueChange
deduplicateOptions
/>
</div>
<div className={cn('flex-none', widthClassName, heightClassName)}>
<MultiSelect<T>
ref={ref}
options={options}
defaultValue={value ? [value] : []}
onValueChange={(next) => {
const selected = next[0] ?? ''
if (selected === clearValue) {
ref.current?.clear()
onChange('')
onOptionChange?.(null)
onItemChange?.(null)
return
}
onChange(selected)
}}
onOptionChange={(next) => {
const option = next[0] ?? null
if (option?.value === clearValue) {
onOptionChange?.(null)
onItemChange?.(null)
return
}
onOptionChange?.(option)
onItemChange?.(option?.info ?? null)
}}
selectionMode="single"
maxCount={1}
maxSelected={1}
placeholder={placeholder}
className={cn('bg-background text-base', !widthClassName && 'w-auto', className)}
spanClassName={spanClassName}
badgeClassName={badgeClassName}
searchable={searchable}
searchMode={searchMode}
defaultSearchValue={defaultSearchValue}
onSearchValueChange={onSearchValueChange}
preventDeselect={preventDeselect}
hideOptionCheck={hideOptionCheck}
hideSelectAll
singleLine
closeOnSelect
resetOnDefaultValueChange
deduplicateOptions
disabled={disabled}
title={showSelectedTooltip ? selectedLabel ?? value : undefined}
/>
</div>
)
}