@t3q-ui/design-system 1.69.2 → 1.69.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/README.md +2 -0
- package/dist/components/_internal/formControlTarget.cjs +34 -0
- package/dist/components/_internal/formControlTarget.cjs.map +1 -0
- package/dist/components/_internal/formControlTarget.js +34 -0
- package/dist/components/_internal/formControlTarget.js.map +1 -0
- package/dist/components/datePicker.cjs +148 -131
- package/dist/components/datePicker.cjs.map +1 -1
- package/dist/components/datePicker.js +148 -131
- package/dist/components/datePicker.js.map +1 -1
- package/dist/components/form.cjs +29 -8
- package/dist/components/form.cjs.map +1 -1
- package/dist/components/form.js +29 -8
- package/dist/components/form.js.map +1 -1
- package/dist/components/iconSelect/index.cjs +137 -135
- package/dist/components/iconSelect/index.cjs.map +1 -1
- package/dist/components/iconSelect/index.js +138 -136
- package/dist/components/iconSelect/index.js.map +1 -1
- package/dist/components/parameterTable/ParameterTable.cjs +1 -0
- package/dist/components/parameterTable/ParameterTable.cjs.map +1 -1
- package/dist/components/parameterTable/ParameterTable.js +1 -0
- package/dist/components/parameterTable/ParameterTable.js.map +1 -1
- package/dist/components/parameterTable/ParameterTableRow.cjs +14 -17
- package/dist/components/parameterTable/ParameterTableRow.cjs.map +1 -1
- package/dist/components/parameterTable/ParameterTableRow.js +14 -17
- package/dist/components/parameterTable/ParameterTableRow.js.map +1 -1
- package/dist/components/range/range.cjs +89 -64
- package/dist/components/range/range.cjs.map +1 -1
- package/dist/components/range/range.js +89 -64
- package/dist/components/range/range.js.map +1 -1
- package/dist/components/range/rangeSlider.cjs +35 -4
- package/dist/components/range/rangeSlider.cjs.map +1 -1
- package/dist/components/range/rangeSlider.js +35 -4
- package/dist/components/range/rangeSlider.js.map +1 -1
- package/dist/components/timePicker.cjs +15 -9
- package/dist/components/timePicker.cjs.map +1 -1
- package/dist/components/timePicker.js +15 -9
- package/dist/components/timePicker.js.map +1 -1
- package/dist/design-system.css +9 -3
- package/dist/index.d.cts +81 -11
- package/dist/index.d.ts +81 -11
- package/dist/styles.css +22 -3
- package/mcp/manifests/components.json +343 -11
- package/package.json +1 -1
- package/skills/tds/reference/components.md +17 -1
|
@@ -1,163 +1,165 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
3
|
-
import { useRef, useState, useDeferredValue, useMemo } from "react";
|
|
3
|
+
import { forwardRef, useRef, useState, useDeferredValue, useMemo } from "react";
|
|
4
4
|
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
5
5
|
import { uniqWith } from "es-toolkit";
|
|
6
6
|
import { Info } from "lucide-react";
|
|
7
7
|
import { cn } from "../../utils/cn.js";
|
|
8
8
|
import message from "../../utils/message.js";
|
|
9
|
+
import { useFormControlTarget, blurOnLeave } from "../_internal/formControlTarget.js";
|
|
9
10
|
import { Button } from "../button.js";
|
|
10
11
|
import { LucideIcon } from "../lucideIcon.js";
|
|
11
12
|
import { Stack } from "../stack/index.js";
|
|
12
13
|
import { TextField } from "../textField.js";
|
|
13
14
|
import { TooltipProvider, Tooltip, TooltipTrigger, TooltipContent } from "../tooltip.js";
|
|
14
15
|
import iconList from "./icons.json.js";
|
|
15
|
-
|
|
16
|
-
iconColumnCount = 8,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
result = iconList.icons.filter((icon) => icon.category === selectedCategory);
|
|
35
|
-
} else {
|
|
36
|
-
result = iconList.icons;
|
|
37
|
-
}
|
|
38
|
-
return result;
|
|
39
|
-
}, [searchTerm, selectedCategory]);
|
|
40
|
-
const rowVirtualizer = useVirtualizer({
|
|
41
|
-
count: Math.ceil(filteredIcons.length / iconColumnCountValue),
|
|
42
|
-
getScrollElement: () => parentRef.current,
|
|
43
|
-
estimateSize: () => 50,
|
|
44
|
-
// 각 행의 실제 높이에 맞게 조정
|
|
45
|
-
overscan: 10
|
|
46
|
-
// 더 많은 항목을 미리 로드
|
|
47
|
-
});
|
|
48
|
-
return /* @__PURE__ */ jsxs(Stack, { direction: "column", spacing: 16, children: [
|
|
49
|
-
!hiddenSearch && /* @__PURE__ */ jsx(
|
|
50
|
-
TextField,
|
|
51
|
-
{
|
|
52
|
-
"aria-label": "아이콘 검색",
|
|
53
|
-
placeholder: "검색어를 입력해주세요",
|
|
54
|
-
value: inputValue,
|
|
55
|
-
onChange: (e) => {
|
|
56
|
-
setInputValue(e.target.value);
|
|
57
|
-
setSelectedCategory(iconList.categories[0]);
|
|
58
|
-
}
|
|
16
|
+
const IconSelect = forwardRef(
|
|
17
|
+
({ iconColumnCount = 8, hasCategory = false, hiddenSearch = false, onBlur, ...props }, ref) => {
|
|
18
|
+
const { targetProps } = useFormControlTarget(props);
|
|
19
|
+
const parentRef = useRef(null);
|
|
20
|
+
const [inputValue, setInputValue] = useState("");
|
|
21
|
+
const searchTerm = useDeferredValue(inputValue);
|
|
22
|
+
const [selectedCategory, setSelectedCategory] = useState(iconList.categories[0]);
|
|
23
|
+
const [iconColumnCountValue] = useState(iconColumnCount);
|
|
24
|
+
const filteredIcons = useMemo(() => {
|
|
25
|
+
let result;
|
|
26
|
+
if (searchTerm) {
|
|
27
|
+
const filteredIcons2 = iconList.icons.filter(
|
|
28
|
+
(icon) => icon.name.toLowerCase().includes(searchTerm.toLowerCase())
|
|
29
|
+
);
|
|
30
|
+
result = uniqWith(filteredIcons2, (a, b) => a.name === b.name);
|
|
31
|
+
} else if (selectedCategory !== iconList.categories[0]) {
|
|
32
|
+
result = iconList.icons.filter((icon) => icon.category === selectedCategory);
|
|
33
|
+
} else {
|
|
34
|
+
result = iconList.icons;
|
|
59
35
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
36
|
+
return result;
|
|
37
|
+
}, [searchTerm, selectedCategory]);
|
|
38
|
+
const rowVirtualizer = useVirtualizer({
|
|
39
|
+
count: Math.ceil(filteredIcons.length / iconColumnCountValue),
|
|
40
|
+
getScrollElement: () => parentRef.current,
|
|
41
|
+
estimateSize: () => 50,
|
|
42
|
+
// 각 행의 실제 높이에 맞게 조정
|
|
43
|
+
overscan: 10
|
|
44
|
+
// 더 많은 항목을 미리 로드
|
|
45
|
+
});
|
|
46
|
+
return /* @__PURE__ */ jsxs(Stack, { direction: "column", spacing: 16, onBlur: blurOnLeave(onBlur), children: [
|
|
47
|
+
!hiddenSearch && /* @__PURE__ */ jsx(
|
|
48
|
+
TextField,
|
|
64
49
|
{
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
category === selectedCategory && "bg-primary-o10"
|
|
75
|
-
),
|
|
76
|
-
onClick: () => {
|
|
77
|
-
setSelectedCategory(category);
|
|
78
|
-
if (iconList.categories[0] !== category) {
|
|
79
|
-
setInputValue("");
|
|
80
|
-
}
|
|
81
|
-
},
|
|
82
|
-
children: category
|
|
83
|
-
},
|
|
84
|
-
category
|
|
85
|
-
))
|
|
50
|
+
...targetProps,
|
|
51
|
+
ref,
|
|
52
|
+
"aria-label": "아이콘 검색",
|
|
53
|
+
placeholder: "검색어를 입력해주세요",
|
|
54
|
+
value: inputValue,
|
|
55
|
+
onChange: (e) => {
|
|
56
|
+
setInputValue(e.target.value);
|
|
57
|
+
setSelectedCategory(iconList.categories[0]);
|
|
58
|
+
}
|
|
86
59
|
}
|
|
87
60
|
),
|
|
88
|
-
/* @__PURE__ */ jsxs(
|
|
89
|
-
|
|
61
|
+
/* @__PURE__ */ jsxs(Stack, { direction: "row", spacing: 8, children: [
|
|
62
|
+
hasCategory && /* @__PURE__ */ jsx(
|
|
90
63
|
Stack,
|
|
91
64
|
{
|
|
92
|
-
|
|
93
|
-
|
|
65
|
+
direction: "column",
|
|
66
|
+
className: "w-[150px] h-[300px] max-h-[300px] overflow-auto",
|
|
94
67
|
spacing: 6,
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
68
|
+
children: iconList.categories.map((category) => /* @__PURE__ */ jsx(
|
|
69
|
+
Button,
|
|
70
|
+
{
|
|
71
|
+
variant: "secondaryLink",
|
|
72
|
+
className: cn(
|
|
73
|
+
"text-small-regular-h text-sys-text-main",
|
|
74
|
+
category === selectedCategory && "bg-primary-o10"
|
|
75
|
+
),
|
|
76
|
+
onClick: () => {
|
|
77
|
+
setSelectedCategory(category);
|
|
78
|
+
if (iconList.categories[0] !== category) {
|
|
79
|
+
setInputValue("");
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
children: category
|
|
83
|
+
},
|
|
84
|
+
category
|
|
85
|
+
))
|
|
100
86
|
}
|
|
101
87
|
),
|
|
102
|
-
/* @__PURE__ */
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
88
|
+
/* @__PURE__ */ jsxs("div", { ref: parentRef, className: cn("max-h-[300px] overflow-auto flex-1"), children: [
|
|
89
|
+
filteredIcons.length === 0 && /* @__PURE__ */ jsxs(
|
|
90
|
+
Stack,
|
|
91
|
+
{
|
|
92
|
+
justifyContent: "center",
|
|
93
|
+
alignItems: "center",
|
|
94
|
+
spacing: 6,
|
|
95
|
+
className: "text-sys-text-subtler text-small-medium h-full",
|
|
96
|
+
children: [
|
|
97
|
+
/* @__PURE__ */ jsx(Info, { size: 16, className: "text-sys-text-subtler shrink-0" }),
|
|
98
|
+
message.common.notice_search_result_empty
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
),
|
|
102
|
+
/* @__PURE__ */ jsx(
|
|
103
|
+
"div",
|
|
104
|
+
{
|
|
105
|
+
style: {
|
|
106
|
+
height: `${rowVirtualizer.getTotalSize()}px`,
|
|
107
|
+
width: "100%",
|
|
108
|
+
position: "relative"
|
|
109
|
+
},
|
|
110
|
+
children: rowVirtualizer.getVirtualItems().map((virtualRow) => {
|
|
111
|
+
const startIndex = virtualRow.index * iconColumnCountValue;
|
|
112
|
+
const endIndex = Math.min(startIndex + iconColumnCountValue, filteredIcons.length);
|
|
113
|
+
const rowIcons = filteredIcons.slice(startIndex, endIndex);
|
|
114
|
+
return /* @__PURE__ */ jsx(
|
|
115
|
+
"div",
|
|
116
|
+
{
|
|
117
|
+
style: {
|
|
118
|
+
position: "absolute",
|
|
119
|
+
top: 0,
|
|
120
|
+
left: 0,
|
|
121
|
+
width: "100%",
|
|
122
|
+
height: `${virtualRow.size}px`,
|
|
123
|
+
transform: `translateY(${virtualRow.start}px)`
|
|
124
|
+
},
|
|
125
|
+
children: /* @__PURE__ */ jsx(
|
|
126
|
+
"div",
|
|
127
|
+
{
|
|
128
|
+
className: cn("grid grid-cols-8"),
|
|
129
|
+
style: { gridTemplateColumns: `repeat(${iconColumnCountValue}, 1fr)` },
|
|
130
|
+
children: rowIcons.map((item) => /* @__PURE__ */ jsx(TooltipProvider, { delayDuration: 0, children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
131
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
132
|
+
Button,
|
|
133
|
+
{
|
|
134
|
+
variant: "secondary",
|
|
135
|
+
className: cn(
|
|
136
|
+
"flex items-center justify-center bg-sys-background py-[10px]",
|
|
137
|
+
item.name === props.value && "!bg-secondary-o20",
|
|
138
|
+
"hover:bg-primary10"
|
|
139
|
+
),
|
|
140
|
+
onClick: () => props.onValueChange?.(item.name),
|
|
141
|
+
type: "button",
|
|
142
|
+
"aria-label": item.name,
|
|
143
|
+
"aria-pressed": item.name === props.value,
|
|
144
|
+
children: /* @__PURE__ */ jsx(LucideIcon, { iconComponentName: item.name, size: 24 })
|
|
145
|
+
}
|
|
146
|
+
) }),
|
|
147
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: item.name })
|
|
148
|
+
] }) }, item.name))
|
|
149
|
+
}
|
|
150
|
+
)
|
|
124
151
|
},
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
132
|
-
Button,
|
|
133
|
-
{
|
|
134
|
-
variant: "secondary",
|
|
135
|
-
className: cn(
|
|
136
|
-
"flex items-center justify-center bg-sys-background py-[10px]",
|
|
137
|
-
item.name === props.value && "!bg-secondary-o20",
|
|
138
|
-
"hover:bg-primary10"
|
|
139
|
-
),
|
|
140
|
-
onClick: () => props.onValueChange?.(item.name),
|
|
141
|
-
type: "button",
|
|
142
|
-
"aria-label": item.name,
|
|
143
|
-
"aria-pressed": item.name === props.value,
|
|
144
|
-
children: /* @__PURE__ */ jsx(LucideIcon, { iconComponentName: item.name, size: 24 })
|
|
145
|
-
}
|
|
146
|
-
) }),
|
|
147
|
-
/* @__PURE__ */ jsx(TooltipContent, { children: item.name })
|
|
148
|
-
] }) }, item.name))
|
|
149
|
-
}
|
|
150
|
-
)
|
|
151
|
-
},
|
|
152
|
-
virtualRow.index
|
|
153
|
-
);
|
|
154
|
-
})
|
|
155
|
-
}
|
|
156
|
-
)
|
|
152
|
+
virtualRow.index
|
|
153
|
+
);
|
|
154
|
+
})
|
|
155
|
+
}
|
|
156
|
+
)
|
|
157
|
+
] })
|
|
157
158
|
] })
|
|
158
|
-
] })
|
|
159
|
-
|
|
160
|
-
|
|
159
|
+
] });
|
|
160
|
+
}
|
|
161
|
+
);
|
|
162
|
+
IconSelect.displayName = "IconSelect";
|
|
161
163
|
export {
|
|
162
164
|
IconSelect
|
|
163
165
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/iconSelect/index.tsx"],"sourcesContent":["import { ChangeEvent, useDeferredValue, useMemo, useRef, useState } from 'react'\nimport { useVirtualizer } from '@tanstack/react-virtual'\nimport { uniqWith } from 'es-toolkit'\nimport { Info } from 'lucide-react'\n\nimport { cn } from '../../utils/cn'\nimport message from '../../utils/message'\nimport { Button } from '../button'\nimport { LucideIcon } from '../lucideIcon'\nimport { Stack } from '../stack'\nimport { TextField } from '../textField'\nimport { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../tooltip'\nimport iconList from './icons.json'\n\nexport type IconSelectProps = {\n /** 선택된 아이콘 이름 (lucide kebab-case, 예: 'calendar-days') */\n value?: string | null\n /** 아이콘을 클릭하면 그 아이콘 이름으로 호출된다 */\n onValueChange?: (value: string) => void\n /** 한 줄에 보여줄 아이콘 수 @default 8 */\n iconColumnCount?: number\n /** 왼쪽에 카테고리 목록 표시 @default false */\n hasCategory?: boolean\n /** 검색 입력 숨김 @default false */\n hiddenSearch?: boolean\n}\n\n/**\n * 아이콘을 검색·분류로 골라 그 이름(lucide)을 돌려주는 아이콘 선택기.\n *\n * 언제 쓰나: 사용자가 항목(카테고리·바로가기·위젯)에 표시할 아이콘을 직접 고를 때. 분류 목록은 `hasCategory`, 한 줄 아이콘 수는 `iconColumnCount`.\n * 언제 안 쓰나: 개발자가 화면에 아이콘을 넣을 때(→ LucideIcon 에 이름을 바로), 일반 값 고르기(→ Select).\n * 대신/함께: 폼에서는 `FormField` + `FormControl` 안에 둔다.\n */\nexport function IconSelect({\n iconColumnCount = 8,\n hasCategory = false,\n hiddenSearch = false,\n ...props\n}: IconSelectProps) {\n const parentRef = useRef<HTMLDivElement>(null)\n const [inputValue, setInputValue] = useState('') // 검색어 입력값\n // 아이콘 검색어 — 목록 거르기·다시 그리기를 지연 값으로 미뤄 입력이 먼저 반영되게 한다(화면 안에서 거르는 일이라 타이머로 늦출 이유가 없다)\n const searchTerm = useDeferredValue(inputValue)\n const [selectedCategory, setSelectedCategory] = useState<string>(iconList.categories[0]) // 선택된 카테고리\n\n const [iconColumnCountValue] = useState<number>(iconColumnCount)\n\n /**\n * 아이콘 필터링\n * searchTerm이 있으면 searchTerm에 맞는 아이콘 필터링\n * selectedCategory가 '전체'이 아니면 selectedCategory에 맞는 아이콘 필터링\n */\n const filteredIcons = useMemo(() => {\n let result\n\n if (searchTerm) {\n const filteredIcons = iconList.icons.filter((icon) =>\n icon.name.toLowerCase().includes(searchTerm.toLowerCase()),\n )\n\n // 중복 아이콘 제거\n result = uniqWith(filteredIcons, (a, b) => a.name === b.name)\n } else if (selectedCategory !== iconList.categories[0]) {\n result = iconList.icons.filter((icon) => icon.category === selectedCategory)\n } else {\n result = iconList.icons\n }\n\n return result\n }, [searchTerm, selectedCategory])\n\n // 아이콘 리스트 최적화\n // eslint-disable-next-line react-hooks/incompatible-library\n const rowVirtualizer = useVirtualizer({\n count: Math.ceil(filteredIcons.length / iconColumnCountValue),\n getScrollElement: () => parentRef.current,\n estimateSize: () => 50, // 각 행의 실제 높이에 맞게 조정\n overscan: 10, // 더 많은 항목을 미리 로드\n })\n\n return (\n <Stack direction='column' spacing={16}>\n {!hiddenSearch && (\n <TextField\n aria-label='아이콘 검색'\n placeholder='검색어를 입력해주세요'\n value={inputValue}\n onChange={(e: ChangeEvent<HTMLInputElement>) => {\n setInputValue(e.target.value)\n\n setSelectedCategory(iconList.categories[0])\n }}\n />\n )}\n <Stack direction='row' spacing={8}>\n {hasCategory && (\n <Stack\n direction='column'\n className='w-[150px] h-[300px] max-h-[300px] overflow-auto'\n spacing={6}\n >\n {iconList.categories.map((category) => (\n <Button\n key={category}\n variant='secondaryLink'\n className={cn(\n 'text-small-regular-h text-sys-text-main',\n category === selectedCategory && 'bg-primary-o10',\n )}\n onClick={() => {\n setSelectedCategory(category)\n\n // '전체'이외의 카테고리 선택 시 입력값 초기화\n if (iconList.categories[0] !== category) {\n setInputValue('')\n }\n }}\n >\n {category}\n </Button>\n ))}\n </Stack>\n )}\n <div ref={parentRef} className={cn('max-h-[300px] overflow-auto flex-1')}>\n {filteredIcons.length === 0 && (\n <Stack\n justifyContent='center'\n alignItems='center'\n spacing={6}\n className='text-sys-text-subtler text-small-medium h-full'\n >\n <Info size={16} className='text-sys-text-subtler shrink-0' />\n {message.common.notice_search_result_empty}\n </Stack>\n )}\n\n <div\n style={{\n height: `${rowVirtualizer.getTotalSize()}px`,\n width: '100%',\n position: 'relative',\n }}\n >\n {rowVirtualizer.getVirtualItems().map((virtualRow) => {\n const startIndex = virtualRow.index * iconColumnCountValue\n const endIndex = Math.min(startIndex + iconColumnCountValue, filteredIcons.length)\n const rowIcons = filteredIcons.slice(startIndex, endIndex)\n\n return (\n <div\n key={virtualRow.index}\n style={{\n position: 'absolute',\n top: 0,\n left: 0,\n width: '100%',\n height: `${virtualRow.size}px`,\n transform: `translateY(${virtualRow.start}px)`,\n }}\n >\n <div\n className={cn('grid grid-cols-8')}\n style={{ gridTemplateColumns: `repeat(${iconColumnCountValue}, 1fr)` }}\n >\n {rowIcons.map((item) => (\n <TooltipProvider delayDuration={0} key={item.name}>\n <Tooltip>\n <TooltipTrigger asChild>\n <Button\n variant={'secondary'}\n className={cn(\n 'flex items-center justify-center bg-sys-background py-[10px]',\n item.name === props.value && '!bg-secondary-o20',\n 'hover:bg-primary10',\n )}\n onClick={() => props.onValueChange?.(item.name)}\n type='button'\n aria-label={item.name}\n aria-pressed={item.name === props.value}\n >\n <LucideIcon iconComponentName={item.name as any} size={24} />\n </Button>\n </TooltipTrigger>\n <TooltipContent>{item.name}</TooltipContent>\n </Tooltip>\n </TooltipProvider>\n ))}\n </div>\n </div>\n )\n })}\n </div>\n </div>\n </Stack>\n </Stack>\n )\n}\n"],"names":["filteredIcons"],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
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/iconSelect/index.tsx"],"sourcesContent":["import { ChangeEvent, forwardRef, useDeferredValue, useMemo, useRef, useState } from 'react'\nimport { useVirtualizer } from '@tanstack/react-virtual'\nimport { uniqWith } from 'es-toolkit'\nimport { Info } from 'lucide-react'\n\nimport { cn } from '../../utils/cn'\nimport message from '../../utils/message'\nimport {\n blurOnLeave,\n type FormControlTargetProps,\n useFormControlTarget,\n} from '../_internal/formControlTarget'\nimport { Button } from '../button'\nimport { LucideIcon } from '../lucideIcon'\nimport { Stack } from '../stack'\nimport { TextField } from '../textField'\nimport { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../tooltip'\nimport iconList from './icons.json'\n\nexport type IconSelectProps = {\n /** 선택된 아이콘 이름 (lucide kebab-case, 예: 'calendar-days') */\n value?: string | null\n /** 아이콘을 클릭하면 그 아이콘 이름으로 호출된다 */\n onValueChange?: (value: string) => void\n /** 한 줄에 보여줄 아이콘 수 @default 8 */\n iconColumnCount?: number\n /** 왼쪽에 카테고리 목록 표시 @default false */\n hasCategory?: boolean\n /** 검색 입력 숨김 @default false */\n hiddenSearch?: boolean\n} & FormControlTargetProps<HTMLDivElement>\n\n/**\n * 아이콘을 검색·분류로 골라 그 이름(lucide)을 돌려주는 아이콘 선택기.\n *\n * 언제 쓰나: 사용자가 항목(카테고리·바로가기·위젯)에 표시할 아이콘을 직접 고를 때. 분류 목록은 `hasCategory`, 한 줄 아이콘 수는 `iconColumnCount`.\n * 언제 안 쓰나: 개발자가 화면에 아이콘을 넣을 때(→ LucideIcon 에 이름을 바로), 일반 값 고르기(→ Select).\n * 대신/함께: 폼에서는 `FormField` + `FormControl` 안에 둔다 — 라벨·오류는 검색 칸에 이어진다(ref 도 검색 칸).\n */\nexport const IconSelect = forwardRef<HTMLInputElement, IconSelectProps>(\n ({ iconColumnCount = 8, hasCategory = false, hiddenSearch = false, onBlur, ...props }, ref) => {\n // 라벨·오류 연결은 검색 칸이 받는다(오류 모양은 TextField 가 FormControl 에서 직접 읽는다)\n const { targetProps } = useFormControlTarget(props)\n const parentRef = useRef<HTMLDivElement>(null)\n const [inputValue, setInputValue] = useState('') // 검색어 입력값\n // 아이콘 검색어 — 목록 거르기·다시 그리기를 지연 값으로 미뤄 입력이 먼저 반영되게 한다(화면 안에서 거르는 일이라 타이머로 늦출 이유가 없다)\n const searchTerm = useDeferredValue(inputValue)\n const [selectedCategory, setSelectedCategory] = useState<string>(iconList.categories[0]) // 선택된 카테고리\n\n const [iconColumnCountValue] = useState<number>(iconColumnCount)\n\n /**\n * 아이콘 필터링\n * searchTerm이 있으면 searchTerm에 맞는 아이콘 필터링\n * selectedCategory가 '전체'이 아니면 selectedCategory에 맞는 아이콘 필터링\n */\n const filteredIcons = useMemo(() => {\n let result\n\n if (searchTerm) {\n const filteredIcons = iconList.icons.filter((icon) =>\n icon.name.toLowerCase().includes(searchTerm.toLowerCase()),\n )\n\n // 중복 아이콘 제거\n result = uniqWith(filteredIcons, (a, b) => a.name === b.name)\n } else if (selectedCategory !== iconList.categories[0]) {\n result = iconList.icons.filter((icon) => icon.category === selectedCategory)\n } else {\n result = iconList.icons\n }\n\n return result\n }, [searchTerm, selectedCategory])\n\n // 아이콘 리스트 최적화\n // eslint-disable-next-line react-hooks/incompatible-library\n const rowVirtualizer = useVirtualizer({\n count: Math.ceil(filteredIcons.length / iconColumnCountValue),\n getScrollElement: () => parentRef.current,\n estimateSize: () => 50, // 각 행의 실제 높이에 맞게 조정\n overscan: 10, // 더 많은 항목을 미리 로드\n })\n\n return (\n <Stack direction='column' spacing={16} onBlur={blurOnLeave(onBlur)}>\n {!hiddenSearch && (\n <TextField\n {...targetProps}\n ref={ref}\n aria-label='아이콘 검색'\n placeholder='검색어를 입력해주세요'\n value={inputValue}\n onChange={(e: ChangeEvent<HTMLInputElement>) => {\n setInputValue(e.target.value)\n\n setSelectedCategory(iconList.categories[0])\n }}\n />\n )}\n <Stack direction='row' spacing={8}>\n {hasCategory && (\n <Stack\n direction='column'\n className='w-[150px] h-[300px] max-h-[300px] overflow-auto'\n spacing={6}\n >\n {iconList.categories.map((category) => (\n <Button\n key={category}\n variant='secondaryLink'\n className={cn(\n 'text-small-regular-h text-sys-text-main',\n category === selectedCategory && 'bg-primary-o10',\n )}\n onClick={() => {\n setSelectedCategory(category)\n\n // '전체'이외의 카테고리 선택 시 입력값 초기화\n if (iconList.categories[0] !== category) {\n setInputValue('')\n }\n }}\n >\n {category}\n </Button>\n ))}\n </Stack>\n )}\n <div ref={parentRef} className={cn('max-h-[300px] overflow-auto flex-1')}>\n {filteredIcons.length === 0 && (\n <Stack\n justifyContent='center'\n alignItems='center'\n spacing={6}\n className='text-sys-text-subtler text-small-medium h-full'\n >\n <Info size={16} className='text-sys-text-subtler shrink-0' />\n {message.common.notice_search_result_empty}\n </Stack>\n )}\n\n <div\n style={{\n height: `${rowVirtualizer.getTotalSize()}px`,\n width: '100%',\n position: 'relative',\n }}\n >\n {rowVirtualizer.getVirtualItems().map((virtualRow) => {\n const startIndex = virtualRow.index * iconColumnCountValue\n const endIndex = Math.min(startIndex + iconColumnCountValue, filteredIcons.length)\n const rowIcons = filteredIcons.slice(startIndex, endIndex)\n\n return (\n <div\n key={virtualRow.index}\n style={{\n position: 'absolute',\n top: 0,\n left: 0,\n width: '100%',\n height: `${virtualRow.size}px`,\n transform: `translateY(${virtualRow.start}px)`,\n }}\n >\n <div\n className={cn('grid grid-cols-8')}\n style={{ gridTemplateColumns: `repeat(${iconColumnCountValue}, 1fr)` }}\n >\n {rowIcons.map((item) => (\n <TooltipProvider delayDuration={0} key={item.name}>\n <Tooltip>\n <TooltipTrigger asChild>\n <Button\n variant={'secondary'}\n className={cn(\n 'flex items-center justify-center bg-sys-background py-[10px]',\n item.name === props.value && '!bg-secondary-o20',\n 'hover:bg-primary10',\n )}\n onClick={() => props.onValueChange?.(item.name)}\n type='button'\n aria-label={item.name}\n aria-pressed={item.name === props.value}\n >\n <LucideIcon iconComponentName={item.name as any} size={24} />\n </Button>\n </TooltipTrigger>\n <TooltipContent>{item.name}</TooltipContent>\n </Tooltip>\n </TooltipProvider>\n ))}\n </div>\n </div>\n )\n })}\n </div>\n </div>\n </Stack>\n </Stack>\n )\n },\n)\nIconSelect.displayName = 'IconSelect'\n"],"names":["filteredIcons"],"mappings":";;;;;;;;;;;;;;;AAuCO,MAAM,aAAa;AAAA,EACxB,CAAC,EAAE,kBAAkB,GAAG,cAAc,OAAO,eAAe,OAAO,QAAQ,GAAG,MAAA,GAAS,QAAQ;AAE7F,UAAM,EAAE,YAAA,IAAgB,qBAAqB,KAAK;AAClD,UAAM,YAAY,OAAuB,IAAI;AAC7C,UAAM,CAAC,YAAY,aAAa,IAAI,SAAS,EAAE;AAE/C,UAAM,aAAa,iBAAiB,UAAU;AAC9C,UAAM,CAAC,kBAAkB,mBAAmB,IAAI,SAAiB,SAAS,WAAW,CAAC,CAAC;AAEvF,UAAM,CAAC,oBAAoB,IAAI,SAAiB,eAAe;AAO/D,UAAM,gBAAgB,QAAQ,MAAM;AAClC,UAAI;AAEJ,UAAI,YAAY;AACd,cAAMA,iBAAgB,SAAS,MAAM;AAAA,UAAO,CAAC,SAC3C,KAAK,KAAK,cAAc,SAAS,WAAW,YAAA,CAAa;AAAA,QAAA;AAI3D,iBAAS,SAASA,gBAAe,CAAC,GAAG,MAAM,EAAE,SAAS,EAAE,IAAI;AAAA,MAC9D,WAAW,qBAAqB,SAAS,WAAW,CAAC,GAAG;AACtD,iBAAS,SAAS,MAAM,OAAO,CAAC,SAAS,KAAK,aAAa,gBAAgB;AAAA,MAC7E,OAAO;AACL,iBAAS,SAAS;AAAA,MACpB;AAEA,aAAO;AAAA,IACT,GAAG,CAAC,YAAY,gBAAgB,CAAC;AAIjC,UAAM,iBAAiB,eAAe;AAAA,MACpC,OAAO,KAAK,KAAK,cAAc,SAAS,oBAAoB;AAAA,MAC5D,kBAAkB,MAAM,UAAU;AAAA,MAClC,cAAc,MAAM;AAAA;AAAA,MACpB,UAA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GAE/D;AAAA,0BACA,oBAAC,gBAAA,EAAgB,UAAA,KAAK,KAAA,CAAK;AAAA,wBAAA,GAC7B,EAAA,GAnBsC,KAAK,IAoB7C,CACD;AAAA,sBAAA;AAAA,oBAAA;AAAA,kBACH;AAAA,kBArCK,WAAW;AAAA,gBAAA;AAAA,cAwCtB,CAAC;AAAA,YAAA;AAAA,UAAA;AAAA,QACH,EAAA,CACF;AAAA,MAAA,EAAA,CACF;AAAA,IAAA,GACF;AAAA,EAEJ;AACF;AACA,WAAW,cAAc;"}
|
|
@@ -879,6 +879,7 @@ const ParameterTable = React__namespace.forwardRef(
|
|
|
879
879
|
className
|
|
880
880
|
),
|
|
881
881
|
"data-disabled": disabled || void 0,
|
|
882
|
+
onPointerDownCapture: () => setKeyboardMode(false),
|
|
882
883
|
"aria-disabled": disabled || void 0,
|
|
883
884
|
children: [
|
|
884
885
|
caption && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-[8px] text-base-medium text-sys-text-main", children: caption }),
|