261023_01_ENH: 자동완성 옵션 툴팁 추가 및 문자 편집기 LMS·MMS 분리와 UTF-8 바이트 계산 적용

This commit is contained in:
2026-10-23 11:21:14 +09:00
parent 487302d374
commit 24a59057a5
14 changed files with 159 additions and 17 deletions

View File

@@ -12,6 +12,18 @@ When implementing or changing frontend UI, use this order:
- `kri-auto-complete` exposes `resetScrollOnSearch?: boolean` on `KriSingleSelect`, `KriMultiSelect`, and `MultiSelect`. It defaults to `false`, preserving existing behavior.
- When enabled, a search value change (including clearing it) resets the option list scroll to the top on the next animation frame in both `filter` and `inputOnly` modes. Async result updates alone do not trigger another reset.
### KriAutoComplete Option Tooltip
- `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`.
### KriEditor SMS Preview
- `changeSmsType` reports `SMS | LMS | MMS`. Update consumer callbacks to handle `MMS`; this widens the previous callback contract.
- Attachment presence (`smsHasAttachment`) takes priority and reports MMS. Otherwise a title or UTF-8 preview size >= `smsMaxBytes` (default 90) reports LMS; the remainder reports SMS. LMS/MMS share `lmsMaxBytes` (default 2000).
- UTF-8 byte counting includes `smsPreviewSuffix` and its separating newline, without storing the suffix in the body.
- This is a preview. Use the template-save response for saved `tmplatTy` and delivery-result `sendTy` for actual per-recipient type after server substitution. Registry updates require updating installed consumer copies.
### Required Shared References
Before each related task, read the current contents of every matching reference, even if it was read earlier in the session.

View File

@@ -0,0 +1,40 @@
import type { HTMLAttributes, ReactNode } from "react";
import { renderAsChild } from "@/lib/as-child";
import { cn } from "@/lib/utils";
export interface TooltipProviderProps {
delayDuration?: number;
children?: ReactNode;
}
export function TooltipProvider({ children }: TooltipProviderProps) {
return <>{children}</>;
}
export interface TooltipProps {
open?: boolean;
onOpenChange?: (open: boolean) => void;
delayDuration?: number;
children?: ReactNode;
}
export function Tooltip({ children }: TooltipProps) {
return <>{children}</>;
}
export function TooltipTrigger({
asChild,
children,
...props
}: HTMLAttributes<HTMLElement> & { asChild?: boolean }) {
return renderAsChild(asChild, children, props);
}
export interface TooltipContentProps extends HTMLAttributes<HTMLDivElement> {
side?: "top" | "right" | "bottom" | "left";
sideOffset?: number;
}
export function TooltipContent({ className, side, sideOffset, ...props }: TooltipContentProps) {
return <div data-side={side} className={cn(className)} {...props} />;
}

View File

@@ -248,6 +248,18 @@ When implementing or changing frontend UI, use this order:
- `kri-auto-complete` exposes `resetScrollOnSearch?: boolean` on `KriSingleSelect`, `KriMultiSelect`, and `MultiSelect`. It defaults to `false`, preserving existing behavior.
- When enabled, a search value change (including clearing it) resets the option list scroll to the top on the next animation frame in both `filter` and `inputOnly` modes. Async result updates alone do not trigger another reset.
### KriAutoComplete Option Tooltip
- `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`.
### KriEditor SMS Preview
- `changeSmsType` reports `SMS | LMS | MMS`. Update consumer callbacks to handle `MMS`; this widens the previous callback contract.
- Attachment presence (`smsHasAttachment`) takes priority and reports MMS. Otherwise a title or UTF-8 preview size >= `smsMaxBytes` (default 90) reports LMS; the remainder reports SMS. LMS/MMS share `lmsMaxBytes` (default 2000).
- UTF-8 byte counting includes `smsPreviewSuffix` and its separating newline, without storing the suffix in the body.
- This is a preview. Use the template-save response for saved `tmplatTy` and delivery-result `sendTy` for actual per-recipient type after server substitution. Registry updates require updating installed consumer copies.
### Required Shared References
Before each related task, read the current contents of every matching reference, even if it was read earlier in the session.

View File

@@ -76,6 +76,22 @@ npx shadcn@latest add https://ui-registry.kric.com/r/kri-dialog.json
/>
```
## KriAutoComplete 옵션 툴팁
`kri-auto-complete`의 `KriSingleSelect`, `KriMultiSelect`와 내부 `MultiSelect`는 `optionTooltip?: 'singleLine' | 'wrap'`과 `optionTooltipClassName?: string`을 지원합니다. 지정하지 않으면 툴팁을 표시하지 않아 기존 동작을 유지합니다.
지정하면 옵션에 마우스를 올렸을 때 말줄임 없이 전체 `label`을 오른쪽 툴팁으로 표시합니다. `singleLine`은 화면의 사용 가능한 폭까지 한 줄로, `wrap`은 28rem 폭에서 줄바꿈합니다. `optionTooltipClassName`으로 투명도 등 프로젝트별 스타일을 덧붙일 수 있습니다. 이 항목은 shadcn `tooltip` 컴포넌트에 의존하며 `TooltipProvider`를 내부에서 제공합니다.
```tsx
<KriSingleSelect
items={items}
value={value}
onChange={setValue}
optionTooltip="singleLine"
optionTooltipClassName="opacity-65"
/>
```
## KRI Chart
`kri-chart`는 `echarts`, `echarts-for-react` 기반 공통 차트 컴포넌트입니다. 내부적으로 `BaseEChart`를 사용하며, 모든 wrapper는 멀티 시리즈를 지원합니다.
@@ -264,7 +280,9 @@ import { KriScatterChart } from '@/components/chart'
- 편집 값은 HTML 문자열입니다.
- 이미지 업로드 함수는 URL 문자열 또는 `{ url }`을 반환할 수 있습니다.
- `toolbar={false}`로 toolbar 전체를 숨길 수 있습니다.
- SMS/LMS 기본 제한은 각각 90/2,000바이트입니다.
- SMS preview uses UTF-8 bytes: below 90 bytes is SMS, 90 bytes or more (or a title) is LMS. Attachments take priority and display MMS. LMS/MMS input limit defaults to 2,000 UTF-8 bytes.
- `changeSmsType` now reports `'SMS' | 'LMS' | 'MMS'`; update callbacks to handle MMS. Preview type is an estimate; use the saved `tmplatTy` and actual delivery `sendTy` from server responses.
- Regression check: `node --test tests/kri-editor-sms.test.mjs`.
- `enableImageMap`은 `map`, `area`, `img.usemap` 보존을 선택적으로 활성화합니다.
- `htmlSanitizer`로 서비스의 서버 정책에 맞는 정제 함수를 주입할 수 있습니다.
- `getWysiwygCompatibility`가 `compatible: false`를 반환하면 HTML 원문을 유지하고 WYSIWYG 전환을 비활성화합니다.

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "kri-ui-registry",
"version": "0.14.0",
"version": "0.15.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "kri-ui-registry",
"version": "0.14.0",
"version": "0.15.1",
"devDependencies": {
"@tanstack/react-table": "^8.21.3",
"@tiptap/extension-color": "^3.27.1",

View File

@@ -1,6 +1,6 @@
{
"name": "kri-ui-registry",
"version": "0.14.1",
"version": "0.15.1",
"private": true,
"description": "KRI internal shadcn UI registry",
"scripts": {

View File

@@ -3,9 +3,9 @@
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, MultiSelectOptionTooltip, MultiSelectRef } from '@/components/common/multi-select'
export type { MultiSelectOption, MultiSelectRef } from '@/components/common/multi-select'
export type { MultiSelectOption, MultiSelectOptionTooltip, MultiSelectRef } from '@/components/common/multi-select'
export interface KriAutoCompleteBaseProps<T> {
items: T[]
@@ -26,6 +26,8 @@ export interface KriAutoCompleteBaseProps<T> {
disabled?: boolean
'aria-invalid'?: boolean
modalPopover?: boolean
optionTooltip?: MultiSelectOptionTooltip
optionTooltipClassName?: string
}
export interface KriMultiSelectProps<T = unknown> extends KriAutoCompleteBaseProps<T> {
@@ -77,6 +79,8 @@ export function KriMultiSelect<T = unknown>({
disabled,
'aria-invalid': ariaInvalid,
modalPopover = true,
optionTooltip,
optionTooltipClassName,
}: KriMultiSelectProps<T>) {
const options = React.useMemo(
() => toOptions(items, getValue, getLabel, withInfo),
@@ -110,6 +114,8 @@ export function KriMultiSelect<T = unknown>({
disabled={disabled}
aria-invalid={ariaInvalid}
modalPopover={modalPopover}
optionTooltip={optionTooltip}
optionTooltipClassName={optionTooltipClassName}
/>
</div>
)
@@ -157,6 +163,8 @@ function KriSingleSelectInner<T>({
disabled,
'aria-invalid': ariaInvalid,
modalPopover = true,
optionTooltip,
optionTooltipClassName,
}: KriSingleSelectProps<T>, forwardedRef: React.ForwardedRef<MultiSelectRef>) {
const ref = React.useRef<MultiSelectRef>(null)
React.useImperativeHandle(
@@ -227,6 +235,8 @@ function KriSingleSelectInner<T>({
aria-invalid={ariaInvalid}
title={showSelectedTooltip ? selectedLabel ?? value : undefined}
modalPopover={modalPopover}
optionTooltip={optionTooltip}
optionTooltipClassName={optionTooltipClassName}
/>
</div>
)

View File

@@ -9,7 +9,7 @@ import { useTextareaInsert } from './hooks/useTextareaInsert'
type SmsEditorProps = Omit<KriEditorProps, 'mode'> & { mode: 'sms' }
function calculateBytes(value: string): number {
return Array.from(value).reduce((total, character) => total + (character.charCodeAt(0) > 127 ? 2 : 1), 0)
return new TextEncoder().encode(value).byteLength
}
export function KriEditorSms({
@@ -33,12 +33,12 @@ export function KriEditorSms({
const [text, setText] = React.useState(value || '')
const textareaRef = React.useRef<HTMLTextAreaElement | null>(null)
const latestTextRef = React.useRef(text)
const lastTypeRef = React.useRef<'SMS' | 'LMS' | null>(null)
const lastTypeRef = React.useRef<'SMS' | 'LMS' | 'MMS' | null>(null)
const { scheduleChange, flushChange } = useDebouncedChange(onChange, debounceMs)
const textareaInsert = useTextareaInsert(textareaRef)
const previewText = smsPreviewSuffix ? `${text}\n${smsPreviewSuffix}` : text
const byteSize = React.useMemo(() => calculateBytes(previewText), [previewText])
const messageType: 'SMS' | 'LMS' = byteSize > smsMaxBytes || Boolean(smsTitle) || smsHasAttachment ? 'LMS' : 'SMS'
const messageType: 'SMS' | 'LMS' | 'MMS' = smsHasAttachment ? 'MMS' : byteSize >= smsMaxBytes || Boolean(smsTitle) ? 'LMS' : 'SMS'
const maxBytes = messageType === 'SMS' ? smsMaxBytes : lmsMaxBytes
const commitText = React.useCallback((next: string, immediate = false) => {
@@ -89,8 +89,8 @@ export function KriEditorSms({
<div className="flex h-full flex-col bg-gray-50 px-4 pt-8 pb-4">
<div className="mb-3 flex items-center justify-between px-2">
<span className="text-xs font-medium text-gray-600">{byteSize}/{maxBytes}byte</span>
<span className={cn('rounded-md px-3 py-1 text-xs font-bold text-white', messageType === 'LMS' ? 'bg-blue-500' : 'bg-red-500')}>
{messageType === 'LMS' ? 'LMS/MMS' : 'SMS'}
<span className={cn('rounded-md px-3 py-1 text-xs font-bold text-white', messageType === 'SMS' ? 'bg-red-500' : 'bg-blue-500')}>
{messageType}
</span>
</div>
<div className={cn('flex flex-1 flex-col rounded-2xl bg-white shadow-sm', smsImages.length > 0 ? 'overflow-y-auto' : 'overflow-hidden')}>

View File

@@ -80,12 +80,13 @@ export type KriEditorProps = {
onImageUploadError?: (error: unknown) => void
debounceMs?: number
smsTitle?: string
changeSmsType?: (type: 'SMS' | 'LMS') => void
/** Preview only; consumers must handle MMS. Actual delivery type is determined by the server. */
changeSmsType?: (type: 'SMS' | 'LMS' | 'MMS') => void
isSmsReadOnly?: boolean
smsMaxBytes?: number
lmsMaxBytes?: number
smsPreviewSuffix?: string
/** 첨부파일이 있으면 길이·제목과 무관하게 LMS/MMS로 판정한다. */
/** 첨부파일이 있으면 길이·제목과 무관하게 MMS로 판정한다. */
smsHasAttachment?: boolean
/** 문자 미리보기의 제목과 본문 사이에 표시할 첨부 이미지 */
smsImages?: KriEditorSmsImage[]

View File

@@ -46,6 +46,8 @@ function MultiSelectInner<T>(
closeOnSelect = false,
preventDeselect = false,
hideOptionCheck = false,
optionTooltip,
optionTooltipClassName,
style,
...buttonProps
}: MultiSelectProps<T>,
@@ -205,6 +207,8 @@ function MultiSelectInner<T>(
onSearchValueChange={handleSearchChange}
hideSelectAll={hideSelectAll}
hideOptionCheck={hideOptionCheck}
optionTooltip={optionTooltip}
optionTooltipClassName={optionTooltipClassName}
selectionMode={selectionMode}
emptyIndicator={emptyIndicator}
onToggleOption={toggleOption}

View File

@@ -11,8 +11,9 @@ import {
CommandList,
CommandSeparator,
} from '@/components/ui/command'
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip'
import { cn } from '@/lib/utils'
import type { MultiSelectGroup, MultiSelectOption, MultiSelectOptions } from './types'
import type { MultiSelectGroup, MultiSelectOption, MultiSelectOptionTooltip, MultiSelectOptions } from './types'
import { isGroupedOptions } from './utils'
interface MultiSelectContentProps<T> {
@@ -25,26 +26,35 @@ interface MultiSelectContentProps<T> {
onSearchValueChange: (value: string) => void
hideSelectAll: boolean
hideOptionCheck: boolean
optionTooltip?: MultiSelectOptionTooltip
optionTooltipClassName?: string
selectionMode: 'single' | 'multiple'
emptyIndicator: React.ReactNode
onToggleOption: (option: MultiSelectOption<T>) => void
onToggleAll: () => void
}
interface OptionTooltipSettings {
mode: MultiSelectOptionTooltip
className?: string
}
function OptionItem<T>({
option,
selected,
hideOptionCheck,
tooltip,
onToggle,
}: {
option: MultiSelectOption<T>
selected: boolean
hideOptionCheck: boolean
tooltip?: OptionTooltipSettings
onToggle: () => void
}) {
const Icon = option.icon
return (
const item = (
<CommandItem
value={`${option.label} ${option.value}`}
disabled={option.disabled}
@@ -65,17 +75,39 @@ function OptionItem<T>({
<span className="truncate">{option.label}</span>
</CommandItem>
)
if (!tooltip) return item
return (
<Tooltip>
<TooltipTrigger asChild>{item}</TooltipTrigger>
<TooltipContent
side="right"
className={cn(
'break-words',
tooltip.mode === 'wrap'
? 'max-w-[min(28rem,var(--radix-tooltip-content-available-width))]'
: 'max-w-[var(--radix-tooltip-content-available-width)]',
tooltip.className,
)}
>
{option.label}
</TooltipContent>
</Tooltip>
)
}
function OptionsGroup<T>({
group,
selectedValues,
hideOptionCheck,
tooltip,
onToggleOption,
}: {
group: MultiSelectGroup<T>
selectedValues: string[]
hideOptionCheck: boolean
tooltip?: OptionTooltipSettings
onToggleOption: (option: MultiSelectOption<T>) => void
}) {
return (
@@ -86,6 +118,7 @@ function OptionsGroup<T>({
option={option}
selected={selectedValues.includes(option.value)}
hideOptionCheck={hideOptionCheck}
tooltip={tooltip}
onToggle={() => onToggleOption(option)}
/>
))}
@@ -103,6 +136,8 @@ export function MultiSelectContent<T>({
onSearchValueChange,
hideSelectAll,
hideOptionCheck,
optionTooltip,
optionTooltipClassName,
selectionMode,
emptyIndicator,
onToggleOption,
@@ -123,8 +158,9 @@ export function MultiSelectContent<T>({
const flatOptions = grouped ? options.flatMap((group) => group.options) : options
const selectableOptions = flatOptions.filter((option) => !option.disabled)
const allSelected = selectableOptions.length > 0 && selectableOptions.every((option) => selectedValues.includes(option.value))
const tooltip = optionTooltip ? { mode: optionTooltip, className: optionTooltipClassName } : undefined
return (
const content = (
<Command shouldFilter={searchMode === 'filter'}>
{searchable ? (
<CommandInput
@@ -161,6 +197,7 @@ export function MultiSelectContent<T>({
group={group}
selectedValues={selectedValues}
hideOptionCheck={hideOptionCheck}
tooltip={tooltip}
onToggleOption={onToggleOption}
/>
))
@@ -172,6 +209,7 @@ export function MultiSelectContent<T>({
option={option}
selected={selectedValues.includes(option.value)}
hideOptionCheck={hideOptionCheck}
tooltip={tooltip}
onToggle={() => onToggleOption(option)}
/>
))}
@@ -180,4 +218,6 @@ export function MultiSelectContent<T>({
</CommandList>
</Command>
)
return tooltip ? <TooltipProvider delayDuration={0}>{content}</TooltipProvider> : content
}

View File

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

View File

@@ -29,6 +29,7 @@ export interface MultiSelectGroup<T = unknown> {
export type MultiSelectOptions<T = unknown> = MultiSelectOption<T>[] | MultiSelectGroup<T>[]
export type MultiSelectSelectionMode = 'single' | 'multiple'
export type MultiSelectVariant = 'default' | 'secondary' | 'destructive' | 'inverted'
export type MultiSelectOptionTooltip = 'singleLine' | 'wrap'
export interface MultiSelectResponsiveSettings {
maxCount?: number
@@ -79,6 +80,8 @@ export interface MultiSelectProps<T = unknown>
closeOnSelect?: boolean
preventDeselect?: boolean
hideOptionCheck?: boolean
optionTooltip?: MultiSelectOptionTooltip
optionTooltipClassName?: string
}
export interface MultiSelectRef {

View File

@@ -205,7 +205,8 @@
"badge",
"button",
"command",
"popover"
"popover",
"tooltip"
],
"dependencies": [
"lucide-react"