@t3q-ui/design-system 1.69.3 → 1.69.5
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 +16 -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/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/components/toast.cjs +12 -1
- package/dist/components/toast.cjs.map +1 -1
- package/dist/components/toast.js +12 -1
- package/dist/components/toast.js.map +1 -1
- package/dist/index.d.cts +81 -11
- package/dist/index.d.ts +81 -11
- package/mcp/manifests/components.json +406 -74
- package/package.json +2 -1
- package/skills/tds/reference/components.md +17 -5
|
@@ -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"],"mappings":";;;;;;;;;;;;;;AAkCO,SAAS,WAAW;AAAA,EACzB,kBAAkB;AAAA,EAClB,cAAc;AAAA,EACd,eAAe;AAAA,EACf,GAAG;AACL,GAAoB;AAClB,QAAM,YAAY,OAAuB,IAAI;AAC7C,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,EAAE;AAE/C,QAAM,aAAa,iBAAiB,UAAU;AAC9C,QAAM,CA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AAA;AAAA,kBAG3C,UAAA;AAAA,oBAAC;AAAA,oBAAA;AAAA,sBACC,WAAW,GAAG,kBAAkB;AAAA,sBAChC,OAAO,EAAE,qBAAqB,UAAU,oBAAoB,SAAA;AAAA,sBAE3D,UAAA,SAAS,IAAI,CAAC,6BACZ,iBAAA,EAAgB,eAAe,GAC9B,UAAA,qBAAC,SAAA,EACC,UAAA;AAAA,wBAAA,oBAAC,gBAAA,EAAe,SAAO,MACrB,UAAA;AAAA,0BAAC;AAAA,0BAAA;AAAA,4BACC,SAAS;AAAA,4BACT,WAAW;AAAA,8BACT;AAAA,8BACA,KAAK,SAAS,MAAM,SAAS;AAAA,8BAC7B;AAAA,4BAAA;AAAA,4BAEF,SAAS,MAAM,MAAM,gBAAgB,KAAK,IAAI;AAAA,4BAC9C,MAAK;AAAA,4BACL,cAAY,KAAK;AAAA,4BACjB,gBAAc,KAAK,SAAS,MAAM;AAAA,4BAElC,8BAAC,YAAA,EAAW,mBAAmB,KAAK,MAAa,MAAM,GAAA,CAAI;AAAA,0BAAA;AAAA,wBAAA,GAE/D;AAAA,wBACA,oBAAC,gBAAA,EAAgB,UAAA,KAAK,KAAA,CAAK;AAAA,sBAAA,GAC7B,EAAA,GAnBsC,KAAK,IAoB7C,CACD;AAAA,oBAAA;AAAA,kBAAA;AAAA,gBACH;AAAA,gBArCK,WAAW;AAAA,cAAA;AAAA,YAwCtB,CAAC;AAAA,UAAA;AAAA,QAAA;AAAA,MACH,EAAA,CACF;AAAA,IAAA,EAAA,CACF;AAAA,EAAA,GACF;AAEJ;"}
|
|
1
|
+
{"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,kB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AAAA,MAAA,EAAA,CACF;AAAA,IAAA,GACF;AAAA,EAEJ;AACF;AACA,WAAW,cAAc;"}
|
|
@@ -5,6 +5,7 @@ const jsxRuntime = require("react/jsx-runtime");
|
|
|
5
5
|
const React = require("react");
|
|
6
6
|
const lucide = require("lucide-react");
|
|
7
7
|
const cn = require("../../utils/cn.cjs");
|
|
8
|
+
const formControlTarget = require("../_internal/formControlTarget.cjs");
|
|
8
9
|
const iconButton = require("../iconButton.cjs");
|
|
9
10
|
const textField = require("../textField.cjs");
|
|
10
11
|
const rangeSlider = require("./rangeSlider.cjs");
|
|
@@ -49,9 +50,20 @@ const Range = React__namespace.forwardRef(
|
|
|
49
50
|
marks,
|
|
50
51
|
className,
|
|
51
52
|
"aria-label": ariaLabel,
|
|
52
|
-
"aria-labelledby":
|
|
53
|
-
name
|
|
53
|
+
"aria-labelledby": ariaLabelledbyProp,
|
|
54
|
+
name,
|
|
55
|
+
onBlur,
|
|
56
|
+
...formProps
|
|
54
57
|
}, ref) => {
|
|
58
|
+
const {
|
|
59
|
+
inForm,
|
|
60
|
+
ariaLabelledby,
|
|
61
|
+
targetProps: { id, ...described }
|
|
62
|
+
} = formControlTarget.useFormControlTarget({
|
|
63
|
+
...formProps,
|
|
64
|
+
"aria-label": ariaLabel,
|
|
65
|
+
"aria-labelledby": ariaLabelledbyProp
|
|
66
|
+
});
|
|
55
67
|
const {
|
|
56
68
|
value: current,
|
|
57
69
|
setValue,
|
|
@@ -63,68 +75,81 @@ const Range = React__namespace.forwardRef(
|
|
|
63
75
|
const numberInput = useNumberInput.useNumberInput({ value: current, onCommit: setValue, min, max, step });
|
|
64
76
|
const iconShape = shape === "rounded" ? "rounded" : "normal";
|
|
65
77
|
const iconOverride = shape === "angled" ? "!rounded-none" : void 0;
|
|
66
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
78
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
79
|
+
"div",
|
|
80
|
+
{
|
|
81
|
+
ref,
|
|
82
|
+
className: cn.cn("flex w-full items-center gap-[16px]", className),
|
|
83
|
+
tabIndex: inForm ? -1 : void 0,
|
|
84
|
+
onFocus: inForm ? formControlTarget.focusSliderThumb : void 0,
|
|
85
|
+
onBlur: formControlTarget.blurOnLeave(onBlur),
|
|
86
|
+
children: [
|
|
87
|
+
hasButtonControl && /* @__PURE__ */ jsxRuntime.jsx(
|
|
88
|
+
iconButton.IconButton,
|
|
89
|
+
{
|
|
90
|
+
variant: "primary",
|
|
91
|
+
spacing: "normal",
|
|
92
|
+
shape: iconShape,
|
|
93
|
+
className: iconOverride,
|
|
94
|
+
disabled: disabled || !canDecrement,
|
|
95
|
+
onClick: decrement,
|
|
96
|
+
"aria-label": "값 감소",
|
|
97
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucide.Minus, { size: 24 })
|
|
98
|
+
}
|
|
99
|
+
),
|
|
100
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
101
|
+
rangeSlider.RangeSlider,
|
|
102
|
+
{
|
|
103
|
+
className: "min-w-0 flex-1",
|
|
104
|
+
type,
|
|
105
|
+
showLabels,
|
|
106
|
+
marks,
|
|
107
|
+
min,
|
|
108
|
+
max,
|
|
109
|
+
step,
|
|
110
|
+
value: [current],
|
|
111
|
+
onValueChange: ([v]) => setValue(v),
|
|
112
|
+
disabled,
|
|
113
|
+
"aria-label": ariaLabel,
|
|
114
|
+
"aria-labelledby": ariaLabelledby,
|
|
115
|
+
...described
|
|
116
|
+
}
|
|
117
|
+
),
|
|
118
|
+
hasCustomInput && /* @__PURE__ */ jsxRuntime.jsx(
|
|
119
|
+
textField.TextField,
|
|
120
|
+
{
|
|
121
|
+
...described,
|
|
122
|
+
id,
|
|
123
|
+
appearance: "standard",
|
|
124
|
+
className: cn.cn("w-[58px] shrink-0", SHAPE_RADIUS[shape]),
|
|
125
|
+
role: "spinbutton",
|
|
126
|
+
inputMode: "decimal",
|
|
127
|
+
name,
|
|
128
|
+
"aria-label": ariaLabelledby ? void 0 : ariaLabel ?? "값",
|
|
129
|
+
"aria-labelledby": ariaLabelledby,
|
|
130
|
+
"aria-valuenow": current,
|
|
131
|
+
"aria-valuemin": min,
|
|
132
|
+
"aria-valuemax": max,
|
|
133
|
+
disabled,
|
|
134
|
+
...numberInput
|
|
135
|
+
}
|
|
136
|
+
),
|
|
137
|
+
hasButtonControl && /* @__PURE__ */ jsxRuntime.jsx(
|
|
138
|
+
iconButton.IconButton,
|
|
139
|
+
{
|
|
140
|
+
variant: "primary",
|
|
141
|
+
spacing: "normal",
|
|
142
|
+
shape: iconShape,
|
|
143
|
+
className: iconOverride,
|
|
144
|
+
disabled: disabled || !canIncrement,
|
|
145
|
+
onClick: increment,
|
|
146
|
+
"aria-label": "값 증가",
|
|
147
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucide.Plus, { size: 24 })
|
|
148
|
+
}
|
|
149
|
+
)
|
|
150
|
+
]
|
|
151
|
+
}
|
|
152
|
+
);
|
|
128
153
|
}
|
|
129
154
|
);
|
|
130
155
|
Range.displayName = "Range";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"range.cjs","sources":["../../../src/components/range/range.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport { Minus, Plus } from 'lucide-react'\n\nimport { cn } from '../../utils/cn'\nimport { IconButton } from '../iconButton'\nimport { TextField } from '../textField'\nimport { RangeSlider } from './rangeSlider'\nimport { type RangeMark } from './ticks'\nimport { useNumberInput } from './useNumberInput'\nimport { useRangeValue } from './useRangeValue'\n\nexport interface RangeProps {\n min?: number\n max?: number\n step?: number\n /** controlled 값. 주던 값을 `undefined` 로 바꾸면 `min` 이 된다(defaultValue 로 돌아가지 않는다) */\n value?: number\n /** uncontrolled 초기값 */\n defaultValue?: number\n onValueChange?: (value: number) => void\n /** ±버튼·숫자입력 모서리 형태 (트랙/썸/눈금엔 영향 없음) */\n shape?: 'rounded' | 'normal' | 'angled'\n /** discrete: step 눈금/숫자, continuous: 양끝 라벨만 */\n type?: 'discrete' | 'continuous'\n disabled?: boolean\n /** ± 스테퍼 버튼 표시 (기본 true) */\n hasButtonControl?: boolean\n /** 숫자 입력박스 표시 (기본 true) */\n hasCustomInput?: boolean\n /** 눈금 숫자/양끝 라벨 표시 (기본 true) */\n showLabels?: boolean\n /** 명시적 눈금/라벨 위치. 지정 시 step 기반 기본 눈금을 대체 */\n marks?: RangeMark[]\n className?: string\n /** 슬라이더 thumb 과 숫자 입력의 접근 가능한 이름 (예: '학습률') */\n 'aria-label'?: string\n /** 외부 라벨 요소의 id. 지정 시 thumb 과 숫자 입력이 그 요소로 이름을 얻는다 */\n 'aria-labelledby'?: string\n /** 숫자 입력의 name (폼 전송용) */\n name?: string\n}\n\nconst SHAPE_RADIUS = {\n rounded: 'rounded-full',\n normal: 'rounded-small',\n angled: 'rounded-none',\n} as const\n\n/**\n * ± 버튼·슬라이더·숫자 입력을 묶은 값 하나짜리 범위 입력.\n *\n * 언제 쓰나: 정해진 범위 안의 숫자 하나를 끌어서 맞추되 정확한 값도 넣어야 할 때(GPU 수·배치 크기·임계값). 눈금은 `step`(discrete) 또는 양끝 라벨(continuous).\n * 언제 안 쓰나: 구간의 두 끝(→ RangeSlider 두 thumb), 범위가 넓거나 정확한 값만 중요한 숫자(→ TextField 숫자 입력), 진행률 표시(→ Progress).\n * 대신/함께: 필요 없는 부분은 `hasButtonControl`(± 버튼)·`hasCustomInput`(숫자칸)으로 끈다.\n *\n * 구현 메모: Figma \"Range\" 합성 컴포넌트 — ± 스테퍼(IconButton) + 슬라이더(RangeSlider) + 숫자 입력박스(DS TextField). 숫자 입력 검증은 useNumberInput 훅이 담당. 단일값 전용 — 두 thumb 범위는 저수준 `RangeSlider`를 직접 쓴다.\n */\nexport const Range = React.forwardRef<HTMLDivElement, RangeProps>(\n (\n {\n min = 0,\n max = 100,\n step = 1,\n value,\n defaultValue,\n onValueChange,\n shape = 'rounded',\n type = 'discrete',\n disabled,\n hasButtonControl = true,\n hasCustomInput = true,\n showLabels = true,\n marks,\n className,\n 'aria-label': ariaLabel,\n 'aria-labelledby':
|
|
1
|
+
{"version":3,"file":"range.cjs","sources":["../../../src/components/range/range.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport { Minus, Plus } from 'lucide-react'\n\nimport { cn } from '../../utils/cn'\nimport {\n blurOnLeave,\n focusSliderThumb,\n type FormControlTargetProps,\n useFormControlTarget,\n} from '../_internal/formControlTarget'\nimport { IconButton } from '../iconButton'\nimport { TextField } from '../textField'\nimport { RangeSlider } from './rangeSlider'\nimport { type RangeMark } from './ticks'\nimport { useNumberInput } from './useNumberInput'\nimport { useRangeValue } from './useRangeValue'\n\nexport interface RangeProps extends FormControlTargetProps<HTMLDivElement> {\n min?: number\n max?: number\n step?: number\n /** controlled 값. 주던 값을 `undefined` 로 바꾸면 `min` 이 된다(defaultValue 로 돌아가지 않는다) */\n value?: number\n /** uncontrolled 초기값 */\n defaultValue?: number\n onValueChange?: (value: number) => void\n /** ±버튼·숫자입력 모서리 형태 (트랙/썸/눈금엔 영향 없음) */\n shape?: 'rounded' | 'normal' | 'angled'\n /** discrete: step 눈금/숫자, continuous: 양끝 라벨만 */\n type?: 'discrete' | 'continuous'\n disabled?: boolean\n /** ± 스테퍼 버튼 표시 (기본 true) */\n hasButtonControl?: boolean\n /** 숫자 입력박스 표시 (기본 true) */\n hasCustomInput?: boolean\n /** 눈금 숫자/양끝 라벨 표시 (기본 true) */\n showLabels?: boolean\n /** 명시적 눈금/라벨 위치. 지정 시 step 기반 기본 눈금을 대체 */\n marks?: RangeMark[]\n className?: string\n /** 슬라이더 thumb 과 숫자 입력의 접근 가능한 이름 (예: '학습률') */\n 'aria-label'?: string\n /** 외부 라벨 요소의 id. 지정 시 thumb 과 숫자 입력이 그 요소로 이름을 얻는다 */\n 'aria-labelledby'?: string\n /** 숫자 입력의 name (폼 전송용) */\n name?: string\n}\n\nconst SHAPE_RADIUS = {\n rounded: 'rounded-full',\n normal: 'rounded-small',\n angled: 'rounded-none',\n} as const\n\n/**\n * ± 버튼·슬라이더·숫자 입력을 묶은 값 하나짜리 범위 입력.\n *\n * 언제 쓰나: 정해진 범위 안의 숫자 하나를 끌어서 맞추되 정확한 값도 넣어야 할 때(GPU 수·배치 크기·임계값). 눈금은 `step`(discrete) 또는 양끝 라벨(continuous).\n * 언제 안 쓰나: 구간의 두 끝(→ RangeSlider 두 thumb), 범위가 넓거나 정확한 값만 중요한 숫자(→ TextField 숫자 입력), 진행률 표시(→ Progress).\n * 대신/함께: 필요 없는 부분은 `hasButtonControl`(± 버튼)·`hasCustomInput`(숫자칸)으로 끈다.\n *\n * 구현 메모: Figma \"Range\" 합성 컴포넌트 — ± 스테퍼(IconButton) + 슬라이더(RangeSlider) + 숫자 입력박스(DS TextField). 숫자 입력 검증은 useNumberInput 훅이 담당. 단일값 전용 — 두 thumb 범위는 저수준 `RangeSlider`를 직접 쓴다.\n */\nexport const Range = React.forwardRef<HTMLDivElement, RangeProps>(\n (\n {\n min = 0,\n max = 100,\n step = 1,\n value,\n defaultValue,\n onValueChange,\n shape = 'rounded',\n type = 'discrete',\n disabled,\n hasButtonControl = true,\n hasCustomInput = true,\n showLabels = true,\n marks,\n className,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledbyProp,\n name,\n onBlur,\n ...formProps\n },\n ref,\n ) => {\n // 라벨을 누르면 숫자 입력으로(id), 도움말·오류는 thumb 와 숫자 입력이 함께 든다. 오류 모양은 둘이 FormControl 에서 직접 읽는다\n const {\n inForm,\n ariaLabelledby,\n targetProps: { id, ...described },\n } = useFormControlTarget({\n ...formProps,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledbyProp,\n })\n const {\n value: current,\n setValue,\n increment,\n decrement,\n canIncrement,\n canDecrement,\n } = useRangeValue({ value, defaultValue, min, max, step, onValueChange })\n\n // 숫자 입력란 검증 로직(타이핑 버퍼 + blur/Enter 커밋·롤백·clamp·snap) — TextField에 spread.\n const numberInput = useNumberInput({ value: current, onCommit: setValue, min, max, step })\n\n // IconButton은 shape가 normal/rounded만 지원 → angled(0px 각진 모서리)는 className으로 rounded-none 오버라이드.\n const iconShape = shape === 'rounded' ? 'rounded' : 'normal'\n const iconOverride = shape === 'angled' ? '!rounded-none' : undefined\n\n return (\n <div\n ref={ref}\n className={cn('flex w-full items-center gap-[16px]', className)}\n // 폼 안에서 ref(틀) 로 오는 포커스(react-hook-form setFocus·제출 오류)를 thumb 로 넘긴다\n tabIndex={inForm ? -1 : undefined}\n onFocus={inForm ? focusSliderThumb : undefined}\n onBlur={blurOnLeave(onBlur)}\n >\n {hasButtonControl && (\n <IconButton\n variant='primary'\n spacing='normal'\n shape={iconShape}\n className={iconOverride}\n disabled={disabled || !canDecrement}\n onClick={decrement}\n aria-label='값 감소'\n >\n <Minus size={24} />\n </IconButton>\n )}\n\n <RangeSlider\n className='min-w-0 flex-1'\n type={type}\n showLabels={showLabels}\n marks={marks}\n min={min}\n max={max}\n step={step}\n value={[current]}\n onValueChange={([v]) => setValue(v)}\n disabled={disabled}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n {...described}\n />\n\n {hasCustomInput && (\n <TextField\n {...described}\n id={id}\n appearance='standard'\n // 58×36, 값 좌측정렬(TextField 기본) — 시안과 동일. 모서리만 shape별 오버라이드.\n className={cn('w-[58px] shrink-0', SHAPE_RADIUS[shape])}\n role='spinbutton'\n inputMode='decimal'\n name={name}\n // 숫자 입력도 라벨이 필요하다(axe label). 외부 라벨이 없으면 aria-label 로, 그것도 없으면 '값'\n aria-label={ariaLabelledby ? undefined : (ariaLabel ?? '값')}\n aria-labelledby={ariaLabelledby}\n aria-valuenow={current}\n aria-valuemin={min}\n aria-valuemax={max}\n disabled={disabled}\n {...numberInput}\n />\n )}\n\n {hasButtonControl && (\n <IconButton\n variant='primary'\n spacing='normal'\n shape={iconShape}\n className={iconOverride}\n disabled={disabled || !canIncrement}\n onClick={increment}\n aria-label='값 증가'\n >\n <Plus size={24} />\n </IconButton>\n )}\n </div>\n )\n },\n)\nRange.displayName = 'Range'\n"],"names":["React","useFormControlTarget","useRangeValue","useNumberInput","jsxs","cn","focusSliderThumb","blurOnLeave","jsx","IconButton","Minus","RangeSlider","TextField","Plus"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,MAAM,eAAe;AAAA,EACnB,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AACV;AAWO,MAAM,QAAQA,iBAAM;AAAA,EACzB,CACE;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,OAAO;AAAA,IACP;AAAA,IACA,mBAAmB;AAAA,IACnB,iBAAiB;AAAA,IACjB,aAAa;AAAA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