261116_02_ENH: 여러 줄 텍스트(98) 헤더 타입 추가 및 컨택 진행 화면 textarea 입력 적용
This commit is contained in:
248
src/components/common/KriColorPalette.tsx
Normal file
248
src/components/common/KriColorPalette.tsx
Normal file
@@ -0,0 +1,248 @@
|
||||
'use client'
|
||||
|
||||
import { useState, type CSSProperties, type KeyboardEvent } from 'react'
|
||||
import { Check } from 'lucide-react'
|
||||
import { Slider as SliderPrimitive } from 'radix-ui'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { ColorPicker, ColorPickerArea, ColorPickerHueSlider } from '@/components/ui/color-picker'
|
||||
import { Input } from '@/components/ui/input'
|
||||
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { formatHexColor, isLightHexColor, normalizeHexColor, parseHexColor } from '@/utils/color'
|
||||
|
||||
export const KRI_COLOR_PALETTE_DEFAULT_COLORS = [
|
||||
'#111827', '#4B5563', '#9CA3AF', '#E5E7EB', '#EF4444', '#F97316', '#F59E0B', '#EAB308',
|
||||
'#84CC16', '#22C55E', '#14B8A6', '#06B6D4', '#3B82F6', '#6366F1', '#A855F7', '#EC4899',
|
||||
] as const
|
||||
|
||||
const CUSTOM_PICKER_FALLBACK = '#3B82F6'
|
||||
const CHECKERBOARD = 'repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 0% 50% / 8px 8px'
|
||||
|
||||
export type KriColorPaletteProps = {
|
||||
/** `#RRGGBB` 또는 `#RRGGBBAA` 형식의 색상. 지정되지 않았으면 null */
|
||||
value: string | null
|
||||
onChange: (value: string | null) => void
|
||||
colors?: readonly string[]
|
||||
/** 색상 영역·색조 슬라이더·HEX 입력 노출 여부 */
|
||||
allowCustom?: boolean
|
||||
/**
|
||||
* 투명도 슬라이더 노출 및 `#RRGGBBAA` 입력 허용 여부.
|
||||
* false여도 전달받은 값의 투명도는 표시·보존하며, 사용자가 색을 바꾸면 불투명(`#RRGGBB`)으로 바뀐다.
|
||||
*/
|
||||
allowAlpha?: boolean
|
||||
allowClear?: boolean
|
||||
disabled?: boolean
|
||||
placeholder?: string
|
||||
className?: string
|
||||
'aria-label'?: string
|
||||
}
|
||||
|
||||
const swatchStyle = (color: string): CSSProperties => ({
|
||||
background: `linear-gradient(${color}, ${color}), ${CHECKERBOARD}`,
|
||||
})
|
||||
|
||||
export function KriColorPalette({
|
||||
value,
|
||||
onChange,
|
||||
colors = KRI_COLOR_PALETTE_DEFAULT_COLORS,
|
||||
allowCustom = true,
|
||||
allowAlpha = false,
|
||||
allowClear = true,
|
||||
disabled = false,
|
||||
placeholder = '색상 없음',
|
||||
className,
|
||||
'aria-label': ariaLabel = '색상 선택',
|
||||
}: KriColorPaletteProps) {
|
||||
const normalizedValue = normalizeHexColor(value)
|
||||
const parsedValue = parseHexColor(normalizedValue)
|
||||
const currentAlpha = parsedValue?.alpha ?? 255
|
||||
const [open, setOpen] = useState(false)
|
||||
// 프리셋·HEX 입력·제거로 값이 바뀌면 색상 영역을 새 값으로 다시 초기화한다.
|
||||
const [pickerKey, setPickerKey] = useState(0)
|
||||
const [hexDraft, setHexDraft] = useState(normalizedValue ?? '')
|
||||
const [hexDraftSource, setHexDraftSource] = useState(normalizedValue)
|
||||
const [hexInvalid, setHexInvalid] = useState(false)
|
||||
|
||||
if (hexDraftSource !== normalizedValue) {
|
||||
setHexDraftSource(normalizedValue)
|
||||
setHexDraft(normalizedValue ?? '')
|
||||
setHexInvalid(false)
|
||||
}
|
||||
|
||||
const withAlpha = (rgb: string) => formatHexColor(rgb, allowAlpha ? currentAlpha : 255)
|
||||
|
||||
const selectDiscrete = (next: string | null) => {
|
||||
onChange(next)
|
||||
setPickerKey((key) => key + 1)
|
||||
}
|
||||
|
||||
const handlePickerChange = (next: string) => {
|
||||
const parsed = parseHexColor(next)
|
||||
if (!parsed) return
|
||||
const nextValue = withAlpha(parsed.rgb)
|
||||
if (nextValue === normalizedValue) return
|
||||
onChange(nextValue)
|
||||
}
|
||||
|
||||
const handleAlphaChange = (values: number[]) => {
|
||||
const percent = values[0] ?? 100
|
||||
const nextValue = formatHexColor(parsedValue?.rgb ?? CUSTOM_PICKER_FALLBACK, (percent / 100) * 255)
|
||||
if (nextValue === normalizedValue) return
|
||||
onChange(nextValue)
|
||||
}
|
||||
|
||||
const commitHexDraft = () => {
|
||||
if (hexDraft.trim() === '') {
|
||||
setHexDraft(normalizedValue ?? '')
|
||||
setHexInvalid(false)
|
||||
return
|
||||
}
|
||||
// 전달받은 값을 그대로 두고 포커스만 이동한 경우(투명도 포함 값 포함)는 변경으로 보지 않는다.
|
||||
if (normalizeHexColor(hexDraft) === normalizedValue) {
|
||||
setHexDraft(normalizedValue ?? '')
|
||||
setHexInvalid(false)
|
||||
return
|
||||
}
|
||||
const parsed = parseHexColor(hexDraft)
|
||||
if (!parsed || (!allowAlpha && parsed.alpha !== 255)) {
|
||||
setHexInvalid(true)
|
||||
return
|
||||
}
|
||||
const nextValue = formatHexColor(parsed.rgb, parsed.alpha)
|
||||
setHexInvalid(false)
|
||||
setHexDraft(nextValue)
|
||||
if (nextValue !== normalizedValue) selectDiscrete(nextValue)
|
||||
}
|
||||
|
||||
const handleHexKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {
|
||||
if (event.key !== 'Enter') return
|
||||
event.preventDefault()
|
||||
commitHexDraft()
|
||||
}
|
||||
|
||||
const hexFormatLabel = allowAlpha ? '#RRGGBB 또는 #RRGGBBAA' : '#RRGGBB'
|
||||
const alphaPercent = Math.round((currentAlpha / 255) * 100)
|
||||
|
||||
// disabled이면 트리거 상태와 무관하게 팝오버가 열리지 않도록 한다(이미 열린 상태에서 disabled로 바뀐 경우 포함).
|
||||
const resolvedOpen = open && !disabled
|
||||
|
||||
return (
|
||||
<Popover open={resolvedOpen} onOpenChange={(nextOpen) => setOpen(nextOpen && !disabled)}>
|
||||
<PopoverTrigger asChild>
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
size="sm"
|
||||
disabled={disabled}
|
||||
aria-label={`${ariaLabel}: ${normalizedValue ?? placeholder}`}
|
||||
className={cn('w-full justify-start gap-2 px-2 font-normal', className)}
|
||||
>
|
||||
<span
|
||||
aria-hidden
|
||||
className={cn('size-4 shrink-0 rounded-sm border', !normalizedValue && 'bg-[linear-gradient(to_bottom_right,transparent_calc(50%-1px),var(--destructive)_calc(50%-1px)_calc(50%+1px),transparent_calc(50%+1px))]')}
|
||||
style={normalizedValue ? swatchStyle(normalizedValue) : undefined}
|
||||
/>
|
||||
<span className={cn('truncate font-mono text-xs', !normalizedValue && 'text-muted-foreground font-sans')}>
|
||||
{normalizedValue ?? placeholder}
|
||||
</span>
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent align="start" className="w-64 space-y-3 p-3">
|
||||
<div className="grid grid-cols-8 gap-1.5" role="group" aria-label="기본 색상">
|
||||
{colors.map((color) => {
|
||||
const parsedColor = parseHexColor(color)
|
||||
if (!parsedColor) return null
|
||||
const selected = parsedColor.rgb === parsedValue?.rgb
|
||||
return (
|
||||
<button
|
||||
key={parsedColor.rgb}
|
||||
type="button"
|
||||
className="focus-visible:ring-ring flex size-6 items-center justify-center rounded-sm border focus-visible:ring-2 focus-visible:outline-none"
|
||||
style={{ backgroundColor: parsedColor.rgb }}
|
||||
aria-label={`색상 ${parsedColor.rgb}`}
|
||||
aria-pressed={selected}
|
||||
title={parsedColor.rgb}
|
||||
onClick={() => selectDiscrete(withAlpha(parsedColor.rgb))}
|
||||
>
|
||||
{selected ? (
|
||||
<Check className={cn('size-3.5', isLightHexColor(parsedColor.rgb) ? 'text-black' : 'text-white')} />
|
||||
) : null}
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
|
||||
{allowCustom ? (
|
||||
<div className="space-y-3 border-t pt-3">
|
||||
<ColorPicker
|
||||
key={pickerKey}
|
||||
inline
|
||||
defaultValue={parsedValue?.rgb ?? CUSTOM_PICKER_FALLBACK}
|
||||
onValueChange={handlePickerChange}
|
||||
className="flex flex-col gap-3"
|
||||
>
|
||||
<ColorPickerArea className="h-32" />
|
||||
<ColorPickerHueSlider aria-label="색조" />
|
||||
</ColorPicker>
|
||||
{allowAlpha ? (
|
||||
<div className="flex items-center gap-2">
|
||||
<SliderPrimitive.Root
|
||||
className="relative flex w-full touch-none items-center select-none"
|
||||
min={0}
|
||||
max={100}
|
||||
step={1}
|
||||
value={[alphaPercent]}
|
||||
onValueChange={handleAlphaChange}
|
||||
aria-label="투명도"
|
||||
>
|
||||
<SliderPrimitive.Track
|
||||
className="relative h-3 w-full grow overflow-hidden rounded-full"
|
||||
style={{ background: CHECKERBOARD }}
|
||||
>
|
||||
<div
|
||||
className="absolute inset-0 rounded-full"
|
||||
style={{ background: `linear-gradient(to right, transparent, ${parsedValue?.rgb ?? CUSTOM_PICKER_FALLBACK})` }}
|
||||
/>
|
||||
</SliderPrimitive.Track>
|
||||
<SliderPrimitive.Thumb className="border-primary/50 bg-background focus-visible:ring-ring block size-4 rounded-full border shadow focus-visible:ring-1 focus-visible:outline-none" />
|
||||
</SliderPrimitive.Root>
|
||||
<span className="text-muted-foreground w-10 shrink-0 text-right font-mono text-xs">{alphaPercent}%</span>
|
||||
</div>
|
||||
) : null}
|
||||
<div className="space-y-1">
|
||||
<Input
|
||||
value={hexDraft}
|
||||
onChange={(event) => {
|
||||
setHexDraft(event.target.value)
|
||||
setHexInvalid(false)
|
||||
}}
|
||||
onBlur={commitHexDraft}
|
||||
onKeyDown={handleHexKeyDown}
|
||||
placeholder={allowAlpha ? '#RRGGBBAA' : '#RRGGBB'}
|
||||
maxLength={allowAlpha ? 9 : 7}
|
||||
aria-label="HEX 색상 코드"
|
||||
aria-invalid={hexInvalid}
|
||||
className="h-8 font-mono text-sm"
|
||||
/>
|
||||
{hexInvalid ? <p className="text-destructive text-xs">{hexFormatLabel} 형식으로 입력해 주세요.</p> : null}
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{allowClear ? (
|
||||
<div className="flex justify-end border-t pt-2">
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
disabled={!normalizedValue}
|
||||
onClick={() => selectDiscrete(null)}
|
||||
>
|
||||
색상 제거
|
||||
</Button>
|
||||
</div>
|
||||
) : null}
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
)
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
} from '@dnd-kit/sortable'
|
||||
import { CSS } from '@dnd-kit/utilities'
|
||||
import { GripVertical, Plus, Trash2 } from 'lucide-react'
|
||||
import { KriColorPalette } from '@/components/common/KriColorPalette'
|
||||
import { KriDialog } from '@/components/common/KriDialog'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Checkbox } from '@/components/ui/checkbox'
|
||||
@@ -44,6 +45,7 @@ export type ListHeaderManageDialogProps = {
|
||||
type ListHeaderRowProps = {
|
||||
row: listHeader
|
||||
activeId: number | null
|
||||
onHeaderColorChange: (id: number, color: string | null) => void
|
||||
onHeaderNameChange: (id: number, listHderNm: string) => void
|
||||
onHeaderTypeChange: (id: number, listHderTy: ListHeaderType) => void
|
||||
onFlagChange: (id: number, field: 'useColView' | 'useFilter' | 'useIntrvwerView' | 'useIntrvwerEdit', checked: boolean) => void
|
||||
@@ -62,13 +64,23 @@ const isInterviewerEditDisabled = (row: listHeader) =>
|
||||
row.listHderTy === ListHeaderConst.CONTACT_INTERVIEWER ||
|
||||
row.listHderTy === ListHeaderConst.FIELD_INTERVIEWER
|
||||
|
||||
const ListHeaderRow = ({ row, activeId, onHeaderNameChange, onHeaderTypeChange, onFlagChange, onDelete }: ListHeaderRowProps) => {
|
||||
const ListHeaderRow = ({
|
||||
row,
|
||||
activeId,
|
||||
onHeaderColorChange,
|
||||
onHeaderNameChange,
|
||||
onHeaderTypeChange,
|
||||
onFlagChange,
|
||||
onDelete,
|
||||
}: ListHeaderRowProps) => {
|
||||
const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({ id: row.listHderId })
|
||||
const canEditName = isCommonGrade(row.listHderGrad)
|
||||
const canEditType = isCommonGrade(row.listHderGrad)
|
||||
const canDelete = isCommonGrade(row.listHderGrad)
|
||||
const canEditFlags = !isImmutableGrade(row.listHderGrad)
|
||||
const canSort = isCommonGrade(row.listHderGrad)
|
||||
// IMMUTABLE 헤더의 색상은 서버가 저장하지 않으므로 선택을 막는다.
|
||||
const canEditColor = !isImmutableGrade(row.listHderGrad)
|
||||
|
||||
const style: CSSProperties = {
|
||||
transform: CSS.Transform.toString(transform),
|
||||
@@ -86,7 +98,7 @@ const ListHeaderRow = ({ row, activeId, onHeaderNameChange, onHeaderTypeChange,
|
||||
ref={setNodeRef}
|
||||
style={style}
|
||||
className={cn(
|
||||
'h-12 px-4 border-b last:border-b-0 grid grid-cols-[56px_1fr_150px_96px_96px_110px_110px_88px] items-center gap-2',
|
||||
'h-12 px-4 border-b last:border-b-0 grid grid-cols-[56px_1fr_150px_120px_96px_96px_110px_110px_88px] items-center gap-2',
|
||||
(activeId === row.listHderId || isDragging) && 'bg-muted',
|
||||
)}
|
||||
>
|
||||
@@ -131,6 +143,12 @@ const ListHeaderRow = ({ row, activeId, onHeaderNameChange, onHeaderTypeChange,
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<KriColorPalette
|
||||
value={row.listHderColor ?? null}
|
||||
onChange={(color) => onHeaderColorChange(row.listHderId, color)}
|
||||
disabled={!canEditColor}
|
||||
aria-label={`${row.listHderNm} 헤더 색상`}
|
||||
/>
|
||||
<div className="flex items-center gap-2 justify-center">
|
||||
<Checkbox
|
||||
id={`header-visible-${row.listHderId}`}
|
||||
@@ -256,6 +274,16 @@ const ListHeaderManageDialog = ({
|
||||
)
|
||||
}
|
||||
|
||||
const handleHeaderColorChange = (id: number, listHderColor: string | null) => {
|
||||
setLocalRows((prev) =>
|
||||
prev.map((row) => {
|
||||
if (row.listHderId !== id) return row
|
||||
if (isImmutableGrade(row.listHderGrad)) return row
|
||||
return { ...row, listHderColor }
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
const handleHeaderNameChange = (id: number, listHderNm: string) => {
|
||||
setLocalRows((prev) =>
|
||||
prev.map((row) => {
|
||||
@@ -302,6 +330,7 @@ const ListHeaderManageDialog = ({
|
||||
useColView: true,
|
||||
useIntrvwerView: false,
|
||||
useIntrvwerEdit: false,
|
||||
listHderColor: null,
|
||||
}
|
||||
|
||||
return [...prev, nextRow]
|
||||
@@ -388,10 +417,11 @@ const ListHeaderManageDialog = ({
|
||||
</div>
|
||||
|
||||
<div className="rounded-md border overflow-hidden">
|
||||
<div className="h-11 px-4 border-b bg-muted grid grid-cols-[56px_1fr_150px_96px_96px_110px_110px_88px] items-center gap-2 text-sm font-semibold">
|
||||
<div className="h-11 px-4 border-b bg-muted grid grid-cols-[56px_1fr_150px_120px_96px_96px_110px_110px_88px] items-center gap-2 text-sm font-semibold">
|
||||
<span>순서</span>
|
||||
<span>헤더명</span>
|
||||
<span>헤더 타입</span>
|
||||
<span>헤더 색상</span>
|
||||
<span>헤더 노출</span>
|
||||
<span>필터 사용</span>
|
||||
<span>면접원 노출</span>
|
||||
@@ -413,6 +443,7 @@ const ListHeaderManageDialog = ({
|
||||
key={row.listHderId}
|
||||
row={row}
|
||||
activeId={activeId}
|
||||
onHeaderColorChange={handleHeaderColorChange}
|
||||
onHeaderNameChange={handleHeaderNameChange}
|
||||
onHeaderTypeChange={handleHeaderTypeChange}
|
||||
onFlagChange={handleFlagChange}
|
||||
|
||||
@@ -17,6 +17,7 @@ import { formatKst } from '@kri/common'
|
||||
import { isListFieldEditableForContact, isListFieldVisibleForContact } from '@/utils/listAccess'
|
||||
import { substituteVariables } from '@/lib/variableSubstitution'
|
||||
import { formatKoreanPhoneNumber } from '@/utils/phone'
|
||||
import { isLightHexColor, normalizeHexColor } from '@/utils/color'
|
||||
import SurveyQrDialog from '@/components/dialog/SurveyQrDialog'
|
||||
import SingleMessageSendDialog from '@/components/dialog/SingleMessageSendDialog'
|
||||
import { ctiClient } from '@/lib/cti/ctiClient'
|
||||
@@ -52,12 +53,20 @@ export const buildInitialValues = (listHeaders: listHeader[], detail?: ListSearc
|
||||
for (const header of listHeaders) {
|
||||
if (header.listHderTy === ListHeaderConst.SID) continue
|
||||
if (!isListFieldVisibleForContact(header)) continue
|
||||
// 사용 허용은 저장 시 코드("0"/"1"/"9")로 보내야 하므로 폼 값은 코드로 둔다.
|
||||
// 문자·알림톡 변수 치환은 resolveListHeaderValue의 라벨을 그대로 사용한다.
|
||||
if (header.listHderTy === ListHeaderConst.IS_USE) {
|
||||
values[header.listHderId] = detail?.use != null ? String(detail.use) : ''
|
||||
continue
|
||||
}
|
||||
values[header.listHderId] = resolveListHeaderValue(header, detail)
|
||||
}
|
||||
|
||||
return values
|
||||
}
|
||||
|
||||
const IS_USE_OPTIONS = Object.entries(LIST_IS_USE_LABEL).map(([value, label]) => ({ value, label }))
|
||||
|
||||
const disabledContrastClass = 'bg-white disabled:opacity-100 disabled:text-foreground disabled:bg-muted/60'
|
||||
// Input/textarea는 수정 불가 상태에서도 드래그 선택/복사가 가능해야 해서 disabled 대신 readOnly를 쓴다.
|
||||
// disabled는 공용 Input 컴포넌트의 disabled:pointer-events-none 때문에 마우스 이벤트 자체를 못 받는다.
|
||||
@@ -77,19 +86,27 @@ const getCallButtonTitle = (isCtiReady: boolean, isDialing: boolean, isEnding: b
|
||||
return undefined
|
||||
}
|
||||
|
||||
const FieldRow = ({ label, editable, children }: { label: string; editable?: boolean; children: ReactNode }) => (
|
||||
<div className="flex items-center gap-3">
|
||||
<Label
|
||||
className={cn(
|
||||
'w-24 shrink-0 wrap-anywhere rounded-md px-2 py-2.5 text-sm leading-snug font-bold text-foreground',
|
||||
editable && 'bg-blue-100',
|
||||
)}
|
||||
>
|
||||
{label}
|
||||
</Label>
|
||||
<div className="min-w-0 flex-1">{children}</div>
|
||||
</div>
|
||||
)
|
||||
const FieldRow = ({ label, color, children }: { label: string; color?: string | null; children: ReactNode }) => {
|
||||
// 헤더에 지정한 색상(투명도 포함)이 기본색보다 우선한다. 형식이 잘못된 값은 기본색으로 표시한다.
|
||||
const headerColor = normalizeHexColor(color)
|
||||
const isDarkHeaderColor = headerColor !== null && !isLightHexColor(headerColor)
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-3">
|
||||
<Label
|
||||
className={cn(
|
||||
'w-24 shrink-0 wrap-anywhere rounded-md px-2 py-2.5 text-sm leading-snug font-bold',
|
||||
headerColor === null && 'bg-blue-100',
|
||||
isDarkHeaderColor ? 'text-white' : 'text-foreground',
|
||||
)}
|
||||
style={headerColor ? { backgroundColor: headerColor } : undefined}
|
||||
>
|
||||
{label}
|
||||
</Label>
|
||||
<div className="min-w-0 flex-1">{children}</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const ListContactInfoPanel = ({
|
||||
prjctIdx,
|
||||
@@ -202,9 +219,9 @@ const ListContactInfoPanel = ({
|
||||
const value = formValues[header.listHderId] ?? ''
|
||||
const onChange = (next: string) => onFieldChange(header.listHderId, next)
|
||||
|
||||
if (header.listHderTy === ListHeaderConst.MEMO) {
|
||||
if (header.listHderTy === ListHeaderConst.MEMO || header.listHderTy === ListHeaderConst.MULTILINE_TEXT) {
|
||||
return (
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm} editable={canEditField}>
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm} color={header.listHderColor}>
|
||||
<textarea
|
||||
className={`flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${readOnlyContrastClass}`}
|
||||
value={value}
|
||||
@@ -217,7 +234,7 @@ const ListContactInfoPanel = ({
|
||||
|
||||
if (header.listHderTy === ListHeaderConst.TEL_NUM) {
|
||||
return (
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm} editable={canEditField}>
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm} color={header.listHderColor}>
|
||||
{/* 모바일(md 미만)은 버튼을 입력란 아래 줄로 내린다. */}
|
||||
<div className="flex flex-col gap-2 md:flex-row">
|
||||
<Input
|
||||
@@ -271,7 +288,7 @@ const ListContactInfoPanel = ({
|
||||
|
||||
if (header.listHderTy === ListHeaderConst.EMAIL) {
|
||||
return (
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm} editable={canEditField}>
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm} color={header.listHderColor}>
|
||||
<div className="flex flex-col gap-2 md:flex-row">
|
||||
<Input
|
||||
value={value}
|
||||
@@ -298,7 +315,7 @@ const ListContactInfoPanel = ({
|
||||
|
||||
if (header.listHderTy === ListHeaderConst.FILE) {
|
||||
return (
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm} editable={canEditField}>
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm} color={header.listHderColor}>
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="min-w-0 flex-1 truncate text-sm">
|
||||
{value ? (
|
||||
@@ -339,14 +356,14 @@ const ListContactInfoPanel = ({
|
||||
|
||||
if (header.listHderTy === ListHeaderConst.IS_USE) {
|
||||
return (
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm} editable={canEditField}>
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm} color={header.listHderColor}>
|
||||
<KriSingleSelect
|
||||
items={Object.values(LIST_IS_USE_LABEL)}
|
||||
items={IS_USE_OPTIONS}
|
||||
value={value}
|
||||
disabled={!editable}
|
||||
onChange={onChange}
|
||||
getValue={(item) => item}
|
||||
getLabel={(item) => item}
|
||||
getValue={(item) => item.value}
|
||||
getLabel={(item) => item.label}
|
||||
searchable={false}
|
||||
preventDeselect
|
||||
widthClassName="w-full"
|
||||
@@ -359,7 +376,7 @@ const ListContactInfoPanel = ({
|
||||
|
||||
if (header.listHderTy === ListHeaderConst.CONTENT_ITEM && (header.filterContents?.length ?? 0) > 0) {
|
||||
return (
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm} editable={canEditField}>
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm} color={header.listHderColor}>
|
||||
<KriSingleSelect
|
||||
items={header.filterContents ?? []}
|
||||
value={value}
|
||||
@@ -376,7 +393,7 @@ const ListContactInfoPanel = ({
|
||||
}
|
||||
|
||||
return (
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm} editable={canEditField}>
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm} color={header.listHderColor}>
|
||||
<Input
|
||||
value={value}
|
||||
readOnly={!editable}
|
||||
|
||||
@@ -202,6 +202,17 @@ export const getListColumns = (
|
||||
};
|
||||
}
|
||||
|
||||
if (header.listHderTy === ListHeaderConst.MULTILINE_TEXT) {
|
||||
return {
|
||||
accessorKey: String(header.listHderId),
|
||||
header: header.listHderNm,
|
||||
meta: {
|
||||
maxWidth: 200,
|
||||
},
|
||||
enableSorting: true,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
accessorKey: String(header.listHderId),
|
||||
header: header.listHderNm,
|
||||
|
||||
1684
src/components/ui/color-picker.tsx
Normal file
1684
src/components/ui/color-picker.tsx
Normal file
File diff suppressed because it is too large
Load Diff
153
src/components/visually-hidden-input.tsx
Normal file
153
src/components/visually-hidden-input.tsx
Normal file
@@ -0,0 +1,153 @@
|
||||
"use client";
|
||||
|
||||
import * as React from "react";
|
||||
|
||||
type InputValue = string[] | string;
|
||||
|
||||
interface VisuallyHiddenInputProps<T = InputValue> extends Omit<
|
||||
React.InputHTMLAttributes<HTMLInputElement>,
|
||||
"value" | "checked" | "onReset"
|
||||
> {
|
||||
value?: T;
|
||||
checked?: boolean;
|
||||
control: HTMLElement | null;
|
||||
bubbles?: boolean;
|
||||
}
|
||||
|
||||
function VisuallyHiddenInput<T = InputValue>(
|
||||
props: VisuallyHiddenInputProps<T>,
|
||||
) {
|
||||
const {
|
||||
control,
|
||||
value,
|
||||
checked,
|
||||
bubbles = true,
|
||||
type = "hidden",
|
||||
style,
|
||||
...inputProps
|
||||
} = props;
|
||||
|
||||
const isCheckInput = React.useMemo(
|
||||
() => type === "checkbox" || type === "radio" || type === "switch",
|
||||
[type],
|
||||
);
|
||||
const inputRef = React.useRef<HTMLInputElement>(null);
|
||||
|
||||
const prevValueRef = React.useRef<T | boolean | undefined>(
|
||||
isCheckInput ? checked : value,
|
||||
);
|
||||
|
||||
const [measuredSize, setMeasuredSize] = React.useState<{
|
||||
control: HTMLElement;
|
||||
width: number;
|
||||
height: number;
|
||||
} | null>(null);
|
||||
|
||||
const controlSize = React.useMemo<{
|
||||
width?: number;
|
||||
height?: number;
|
||||
}>(
|
||||
() =>
|
||||
control && measuredSize?.control === control
|
||||
? { width: measuredSize.width, height: measuredSize.height }
|
||||
: {},
|
||||
[control, measuredSize],
|
||||
);
|
||||
|
||||
React.useLayoutEffect(() => {
|
||||
if (!control) return;
|
||||
|
||||
if (typeof window === "undefined") return;
|
||||
|
||||
const resizeObserver = new ResizeObserver((entries) => {
|
||||
if (!Array.isArray(entries) || !entries.length) return;
|
||||
|
||||
const entry = entries[0];
|
||||
if (!entry) return;
|
||||
|
||||
let width: number;
|
||||
let height: number;
|
||||
|
||||
if ("borderBoxSize" in entry) {
|
||||
const borderSizeEntry = entry.borderBoxSize;
|
||||
const borderSize = Array.isArray(borderSizeEntry)
|
||||
? borderSizeEntry[0]
|
||||
: borderSizeEntry;
|
||||
width = borderSize.inlineSize;
|
||||
height = borderSize.blockSize;
|
||||
} else {
|
||||
width = control.offsetWidth;
|
||||
height = control.offsetHeight;
|
||||
}
|
||||
|
||||
setMeasuredSize({ control, width, height });
|
||||
});
|
||||
|
||||
resizeObserver.observe(control, { box: "border-box" });
|
||||
return () => {
|
||||
resizeObserver.disconnect();
|
||||
};
|
||||
}, [control]);
|
||||
|
||||
React.useEffect(() => {
|
||||
const currentValue = isCheckInput ? checked : value;
|
||||
const prevValue = prevValueRef.current;
|
||||
prevValueRef.current = currentValue;
|
||||
|
||||
const input = inputRef.current;
|
||||
if (!input) return;
|
||||
|
||||
const inputProto = window.HTMLInputElement.prototype;
|
||||
const propertyKey = isCheckInput ? "checked" : "value";
|
||||
const eventType = isCheckInput ? "click" : "input";
|
||||
|
||||
const serializedCurrentValue = isCheckInput
|
||||
? checked
|
||||
: typeof value === "object" && value !== null
|
||||
? JSON.stringify(value)
|
||||
: value;
|
||||
|
||||
const descriptor = Object.getOwnPropertyDescriptor(inputProto, propertyKey);
|
||||
|
||||
const setter = descriptor?.set;
|
||||
|
||||
if (prevValue !== currentValue && setter) {
|
||||
const event = new Event(eventType, { bubbles });
|
||||
setter.call(input, serializedCurrentValue);
|
||||
input.dispatchEvent(event);
|
||||
}
|
||||
}, [value, checked, bubbles, isCheckInput]);
|
||||
|
||||
const composedStyle = React.useMemo<React.CSSProperties>(() => {
|
||||
return {
|
||||
...style,
|
||||
...(controlSize.width !== undefined && controlSize.height !== undefined
|
||||
? controlSize
|
||||
: {}),
|
||||
border: 0,
|
||||
clip: "rect(0 0 0 0)",
|
||||
clipPath: "inset(50%)",
|
||||
height: "1px",
|
||||
margin: "-1px",
|
||||
overflow: "hidden",
|
||||
padding: 0,
|
||||
position: "absolute",
|
||||
whiteSpace: "nowrap",
|
||||
width: "1px",
|
||||
};
|
||||
}, [style, controlSize]);
|
||||
|
||||
return (
|
||||
<input
|
||||
type={type}
|
||||
{...inputProps}
|
||||
ref={inputRef}
|
||||
aria-hidden={isCheckInput}
|
||||
tabIndex={-1}
|
||||
defaultChecked={isCheckInput ? checked : undefined}
|
||||
style={composedStyle}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export { VisuallyHiddenInput };
|
||||
Reference in New Issue
Block a user