diff --git a/.agent/consumer.md b/.agent/consumer.md index 1b7be26..33108a2 100644 --- a/.agent/consumer.md +++ b/.agent/consumer.md @@ -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. diff --git a/.tooling/components/ui/tooltip.tsx b/.tooling/components/ui/tooltip.tsx new file mode 100644 index 0000000..fb87945 --- /dev/null +++ b/.tooling/components/ui/tooltip.tsx @@ -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 & { asChild?: boolean }) { + return renderAsChild(asChild, children, props); +} + +export interface TooltipContentProps extends HTMLAttributes { + side?: "top" | "right" | "bottom" | "left"; + sideOffset?: number; +} + +export function TooltipContent({ className, side, sideOffset, ...props }: TooltipContentProps) { + return
; +} diff --git a/AGENTS.md b/AGENTS.md index fc30842..3e74d62 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -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. diff --git a/README.md b/README.md index ad3e276..4c86e5a 100644 --- a/README.md +++ b/README.md @@ -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 + +``` + ## 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 전환을 비활성화합니다. diff --git a/package-lock.json b/package-lock.json index fd3d86a..712be58 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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", diff --git a/package.json b/package.json index 3f6acc7..da38e30 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/registry/components/KriAutoComplete.tsx b/registry/components/KriAutoComplete.tsx index 5212f97..cec733e 100644 --- a/registry/components/KriAutoComplete.tsx +++ b/registry/components/KriAutoComplete.tsx @@ -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 { items: T[] @@ -26,6 +26,8 @@ export interface KriAutoCompleteBaseProps { disabled?: boolean 'aria-invalid'?: boolean modalPopover?: boolean + optionTooltip?: MultiSelectOptionTooltip + optionTooltipClassName?: string } export interface KriMultiSelectProps extends KriAutoCompleteBaseProps { @@ -77,6 +79,8 @@ export function KriMultiSelect({ disabled, 'aria-invalid': ariaInvalid, modalPopover = true, + optionTooltip, + optionTooltipClassName, }: KriMultiSelectProps) { const options = React.useMemo( () => toOptions(items, getValue, getLabel, withInfo), @@ -110,6 +114,8 @@ export function KriMultiSelect({ disabled={disabled} aria-invalid={ariaInvalid} modalPopover={modalPopover} + optionTooltip={optionTooltip} + optionTooltipClassName={optionTooltipClassName} />
) @@ -157,6 +163,8 @@ function KriSingleSelectInner({ disabled, 'aria-invalid': ariaInvalid, modalPopover = true, + optionTooltip, + optionTooltipClassName, }: KriSingleSelectProps, forwardedRef: React.ForwardedRef) { const ref = React.useRef(null) React.useImperativeHandle( @@ -227,6 +235,8 @@ function KriSingleSelectInner({ aria-invalid={ariaInvalid} title={showSelectedTooltip ? selectedLabel ?? value : undefined} modalPopover={modalPopover} + optionTooltip={optionTooltip} + optionTooltipClassName={optionTooltipClassName} /> ) diff --git a/registry/components/kri-editor/KriEditorSms.tsx b/registry/components/kri-editor/KriEditorSms.tsx index 0b40870..26d4119 100644 --- a/registry/components/kri-editor/KriEditorSms.tsx +++ b/registry/components/kri-editor/KriEditorSms.tsx @@ -9,7 +9,7 @@ import { useTextareaInsert } from './hooks/useTextareaInsert' type SmsEditorProps = Omit & { 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(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({
{byteSize}/{maxBytes}byte - - {messageType === 'LMS' ? 'LMS/MMS' : 'SMS'} + + {messageType}
0 ? 'overflow-y-auto' : 'overflow-hidden')}> diff --git a/registry/components/kri-editor/types.ts b/registry/components/kri-editor/types.ts index 028d720..1027b7e 100644 --- a/registry/components/kri-editor/types.ts +++ b/registry/components/kri-editor/types.ts @@ -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[] diff --git a/registry/components/multi-select/MultiSelect.tsx b/registry/components/multi-select/MultiSelect.tsx index b4731d7..53c7207 100644 --- a/registry/components/multi-select/MultiSelect.tsx +++ b/registry/components/multi-select/MultiSelect.tsx @@ -46,6 +46,8 @@ function MultiSelectInner( closeOnSelect = false, preventDeselect = false, hideOptionCheck = false, + optionTooltip, + optionTooltipClassName, style, ...buttonProps }: MultiSelectProps, @@ -205,6 +207,8 @@ function MultiSelectInner( onSearchValueChange={handleSearchChange} hideSelectAll={hideSelectAll} hideOptionCheck={hideOptionCheck} + optionTooltip={optionTooltip} + optionTooltipClassName={optionTooltipClassName} selectionMode={selectionMode} emptyIndicator={emptyIndicator} onToggleOption={toggleOption} diff --git a/registry/components/multi-select/MultiSelectContent.tsx b/registry/components/multi-select/MultiSelectContent.tsx index df0cec8..f6e854f 100644 --- a/registry/components/multi-select/MultiSelectContent.tsx +++ b/registry/components/multi-select/MultiSelectContent.tsx @@ -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 { @@ -25,26 +26,35 @@ interface MultiSelectContentProps { onSearchValueChange: (value: string) => void hideSelectAll: boolean hideOptionCheck: boolean + optionTooltip?: MultiSelectOptionTooltip + optionTooltipClassName?: string selectionMode: 'single' | 'multiple' emptyIndicator: React.ReactNode onToggleOption: (option: MultiSelectOption) => void onToggleAll: () => void } +interface OptionTooltipSettings { + mode: MultiSelectOptionTooltip + className?: string +} + function OptionItem({ option, selected, hideOptionCheck, + tooltip, onToggle, }: { option: MultiSelectOption selected: boolean hideOptionCheck: boolean + tooltip?: OptionTooltipSettings onToggle: () => void }) { const Icon = option.icon - return ( + const item = ( ({ {option.label} ) + + if (!tooltip) return item + + return ( + + {item} + + {option.label} + + + ) } function OptionsGroup({ group, selectedValues, hideOptionCheck, + tooltip, onToggleOption, }: { group: MultiSelectGroup selectedValues: string[] hideOptionCheck: boolean + tooltip?: OptionTooltipSettings onToggleOption: (option: MultiSelectOption) => void }) { return ( @@ -86,6 +118,7 @@ function OptionsGroup({ option={option} selected={selectedValues.includes(option.value)} hideOptionCheck={hideOptionCheck} + tooltip={tooltip} onToggle={() => onToggleOption(option)} /> ))} @@ -103,6 +136,8 @@ export function MultiSelectContent({ onSearchValueChange, hideSelectAll, hideOptionCheck, + optionTooltip, + optionTooltipClassName, selectionMode, emptyIndicator, onToggleOption, @@ -123,8 +158,9 @@ export function MultiSelectContent({ 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 = ( {searchable ? ( ({ group={group} selectedValues={selectedValues} hideOptionCheck={hideOptionCheck} + tooltip={tooltip} onToggleOption={onToggleOption} /> )) @@ -172,6 +209,7 @@ export function MultiSelectContent({ option={option} selected={selectedValues.includes(option.value)} hideOptionCheck={hideOptionCheck} + tooltip={tooltip} onToggle={() => onToggleOption(option)} /> ))} @@ -180,4 +218,6 @@ export function MultiSelectContent({ ) + + return tooltip ? {content} : content } diff --git a/registry/components/multi-select/index.ts b/registry/components/multi-select/index.ts index 6392afd..a630b2f 100644 --- a/registry/components/multi-select/index.ts +++ b/registry/components/multi-select/index.ts @@ -3,6 +3,7 @@ export type { AnimationConfig, MultiSelectGroup, MultiSelectOption, + MultiSelectOptionTooltip, MultiSelectOptions, MultiSelectProps, MultiSelectRef, diff --git a/registry/components/multi-select/types.ts b/registry/components/multi-select/types.ts index 7d6abbb..4fedf04 100644 --- a/registry/components/multi-select/types.ts +++ b/registry/components/multi-select/types.ts @@ -29,6 +29,7 @@ export interface MultiSelectGroup { export type MultiSelectOptions = MultiSelectOption[] | MultiSelectGroup[] 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 closeOnSelect?: boolean preventDeselect?: boolean hideOptionCheck?: boolean + optionTooltip?: MultiSelectOptionTooltip + optionTooltipClassName?: string } export interface MultiSelectRef { diff --git a/registry/components/registry.json b/registry/components/registry.json index 5be1e08..c06260d 100644 --- a/registry/components/registry.json +++ b/registry/components/registry.json @@ -205,7 +205,8 @@ "badge", "button", "command", - "popover" + "popover", + "tooltip" ], "dependencies": [ "lucide-react"