@conscience-technology/ctds 0.0.0-stage โ 0.1.0
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/README.md +128 -2
- package/assets/components/AppFrame/AppFrame.module.css +177 -0
- package/assets/components/AppFrame/AppFrame.tsx +93 -0
- package/assets/components/AppFrame/index.ts +6 -0
- package/assets/components/AttachmentChip/AttachmentChip.module.css +71 -0
- package/assets/components/AttachmentChip/AttachmentChip.tsx +74 -0
- package/assets/components/AttachmentChip/index.ts +2 -0
- package/assets/components/AttachmentThumb/AttachmentThumb.module.css +107 -0
- package/assets/components/AttachmentThumb/AttachmentThumb.tsx +91 -0
- package/assets/components/AttachmentThumb/index.ts +2 -0
- package/assets/components/Avatar/Avatar.module.css +167 -0
- package/assets/components/Avatar/Avatar.tsx +228 -0
- package/assets/components/Avatar/index.ts +2 -0
- package/assets/components/AvatarUpload/AvatarUpload.module.css +130 -0
- package/assets/components/AvatarUpload/AvatarUpload.tsx +139 -0
- package/assets/components/AvatarUpload/index.ts +2 -0
- package/assets/components/Badge/Badge.module.css +76 -0
- package/assets/components/Badge/Badge.tsx +68 -0
- package/assets/components/Badge/index.ts +2 -0
- package/assets/components/Breadcrumb/Breadcrumb.module.css +213 -0
- package/assets/components/Breadcrumb/Breadcrumb.tsx +279 -0
- package/assets/components/Breadcrumb/index.ts +8 -0
- package/assets/components/Button/Button.module.css +216 -0
- package/assets/components/Button/Button.tsx +149 -0
- package/assets/components/Button/index.ts +2 -0
- package/assets/components/Callout/Callout.module.css +146 -0
- package/assets/components/Callout/Callout.tsx +138 -0
- package/assets/components/Callout/index.ts +2 -0
- package/assets/components/ChatInput/ChatInput.module.css +241 -0
- package/assets/components/ChatInput/ChatInput.tsx +322 -0
- package/assets/components/ChatInput/ModelSelector.tsx +40 -0
- package/assets/components/ChatInput/SendButton.tsx +41 -0
- package/assets/components/ChatInput/index.ts +10 -0
- package/assets/components/Checkbox/Checkbox.module.css +66 -0
- package/assets/components/Checkbox/Checkbox.tsx +36 -0
- package/assets/components/Checkbox/index.ts +2 -0
- package/assets/components/Chip/Chip.module.css +128 -0
- package/assets/components/Chip/Chip.tsx +103 -0
- package/assets/components/Chip/index.ts +2 -0
- package/assets/components/ChoiceCard/ChoiceCard.module.css +142 -0
- package/assets/components/ChoiceCard/ChoiceCard.tsx +132 -0
- package/assets/components/ChoiceCard/index.ts +2 -0
- package/assets/components/ContextMenu/ContextMenu.module.css +102 -0
- package/assets/components/ContextMenu/ContextMenu.tsx +392 -0
- package/assets/components/ContextMenu/index.ts +9 -0
- package/assets/components/DatePicker/Calendar.tsx +234 -0
- package/assets/components/DatePicker/DESIGN_NOTES.md +106 -0
- package/assets/components/DatePicker/DESIGN_NOTES_TIME.md +125 -0
- package/assets/components/DatePicker/DatePicker.module.css +295 -0
- package/assets/components/DatePicker/DatePicker.tsx +387 -0
- package/assets/components/DatePicker/TimeSelector.tsx +69 -0
- package/assets/components/DatePicker/index.ts +8 -0
- package/assets/components/DatePicker/presets.ts +80 -0
- package/assets/components/DatePicker/utils.ts +148 -0
- package/assets/components/Disclosure/Disclosure.module.css +73 -0
- package/assets/components/Disclosure/Disclosure.tsx +129 -0
- package/assets/components/Disclosure/index.ts +6 -0
- package/assets/components/Drawer/Drawer.module.css +257 -0
- package/assets/components/Drawer/Drawer.tsx +126 -0
- package/assets/components/Drawer/index.ts +7 -0
- package/assets/components/EmptyState/EmptyState.module.css +102 -0
- package/assets/components/EmptyState/EmptyState.tsx +80 -0
- package/assets/components/EmptyState/index.ts +2 -0
- package/assets/components/FileIcon/FileIcon.module.css +66 -0
- package/assets/components/FileIcon/FileIcon.tsx +84 -0
- package/assets/components/FileIcon/fileExtMap.ts +112 -0
- package/assets/components/FileIcon/index.ts +9 -0
- package/assets/components/FilterButton/FilterButton.module.css +130 -0
- package/assets/components/FilterButton/FilterButton.tsx +94 -0
- package/assets/components/FilterButton/index.ts +2 -0
- package/assets/components/GalleryItem/GalleryItem.module.css +220 -0
- package/assets/components/GalleryItem/GalleryItem.tsx +163 -0
- package/assets/components/GalleryItem/index.ts +7 -0
- package/assets/components/Icon/Icon.tsx +616 -0
- package/assets/components/Icon/context.tsx +39 -0
- package/assets/components/Icon/index.ts +4 -0
- package/assets/components/IconButton/IconButton.module.css +109 -0
- package/assets/components/IconButton/IconButton.tsx +110 -0
- package/assets/components/IconButton/index.ts +2 -0
- package/assets/components/Input/Input.module.css +338 -0
- package/assets/components/Input/Input.tsx +371 -0
- package/assets/components/Input/index.ts +2 -0
- package/assets/components/ListItem/ListItem.module.css +318 -0
- package/assets/components/ListItem/ListItem.tsx +262 -0
- package/assets/components/ListItem/index.ts +9 -0
- package/assets/components/MenuItem/MenuItem.module.css +437 -0
- package/assets/components/MenuItem/MenuItem.tsx +529 -0
- package/assets/components/MenuItem/index.ts +8 -0
- package/assets/components/MetricCard/MetricCard.module.css +153 -0
- package/assets/components/MetricCard/MetricCard.tsx +140 -0
- package/assets/components/MetricCard/index.ts +2 -0
- package/assets/components/Modal/Modal.module.css +175 -0
- package/assets/components/Modal/Modal.tsx +98 -0
- package/assets/components/Modal/index.ts +2 -0
- package/assets/components/Onboarding/DocsIndex.tsx +82 -0
- package/assets/components/Onboarding/LayoutBuilder.tsx +160 -0
- package/assets/components/Onboarding/Onboarding.module.css +1394 -0
- package/assets/components/Onboarding/OnboardingAxisPanel.tsx +515 -0
- package/assets/components/Onboarding/OnboardingPage.tsx +1193 -0
- package/assets/components/Onboarding/PresetsGallery.tsx +65 -0
- package/assets/components/Onboarding/actions.ts +250 -0
- package/assets/components/Onboarding/index.ts +8 -0
- package/assets/components/Onboarding/palette.css +40 -0
- package/assets/components/Onboarding/wizardData.ts +265 -0
- package/assets/components/Pagination/Pagination.module.css +82 -0
- package/assets/components/Pagination/Pagination.tsx +248 -0
- package/assets/components/Pagination/index.ts +6 -0
- package/assets/components/ProgressBar/ProgressBar.module.css +64 -0
- package/assets/components/ProgressBar/ProgressBar.tsx +54 -0
- package/assets/components/ProgressBar/index.ts +2 -0
- package/assets/components/QuotationBar/QuotationBar.module.css +61 -0
- package/assets/components/QuotationBar/QuotationBar.tsx +48 -0
- package/assets/components/QuotationBar/index.ts +2 -0
- package/assets/components/Radio/Radio.module.css +63 -0
- package/assets/components/Radio/Radio.tsx +33 -0
- package/assets/components/Radio/index.ts +2 -0
- package/assets/components/Select/Select.module.css +151 -0
- package/assets/components/Select/Select.tsx +425 -0
- package/assets/components/Select/index.ts +10 -0
- package/assets/components/SelectableCard/SelectableCard.module.css +177 -0
- package/assets/components/SelectableCard/SelectableCard.tsx +83 -0
- package/assets/components/SelectableCard/index.ts +2 -0
- package/assets/components/Shortcut/Shortcut.module.css +56 -0
- package/assets/components/Shortcut/Shortcut.tsx +156 -0
- package/assets/components/Shortcut/index.ts +2 -0
- package/assets/components/Sidebar/Sidebar.module.css +242 -0
- package/assets/components/Sidebar/Sidebar.tsx +264 -0
- package/assets/components/Sidebar/index.ts +7 -0
- package/assets/components/SidebarSplit/SidebarSplit.module.css +126 -0
- package/assets/components/SidebarSplit/SidebarSplit.tsx +222 -0
- package/assets/components/SidebarSplit/index.ts +6 -0
- package/assets/components/Slider/Slider.module.css +120 -0
- package/assets/components/Slider/Slider.tsx +88 -0
- package/assets/components/Slider/index.ts +2 -0
- package/assets/components/SplitButton/SplitButton.module.css +190 -0
- package/assets/components/SplitButton/SplitButton.tsx +145 -0
- package/assets/components/SplitButton/index.ts +6 -0
- package/assets/components/Stepper/Stepper.module.css +182 -0
- package/assets/components/Stepper/Stepper.tsx +185 -0
- package/assets/components/Stepper/index.ts +2 -0
- package/assets/components/Switch/Switch.module.css +116 -0
- package/assets/components/Switch/Switch.tsx +58 -0
- package/assets/components/Switch/index.ts +2 -0
- package/assets/components/TableCell/TableCell.module.css +137 -0
- package/assets/components/TableCell/TableCellAvatar.tsx +42 -0
- package/assets/components/TableCell/TableCellBadge.tsx +23 -0
- package/assets/components/TableCell/TableCellIcon.tsx +39 -0
- package/assets/components/TableCell/TableCellImage.tsx +49 -0
- package/assets/components/TableCell/TableCellLink.tsx +33 -0
- package/assets/components/TableCell/TableCellMeter.tsx +55 -0
- package/assets/components/TableCell/TableCellNumber.tsx +43 -0
- package/assets/components/TableCell/TableCellText.tsx +30 -0
- package/assets/components/TableCell/index.ts +23 -0
- package/assets/components/TableHeader/TableHeader.module.css +287 -0
- package/assets/components/TableHeader/TableHeader.tsx +590 -0
- package/assets/components/TableHeader/index.ts +9 -0
- package/assets/components/TableRow/TableRow.module.css +290 -0
- package/assets/components/TableRow/TableRow.tsx +253 -0
- package/assets/components/TableRow/index.ts +8 -0
- package/assets/components/TableRowEdit/TableRowEdit.module.css +126 -0
- package/assets/components/TableRowEdit/TableRowEdit.tsx +247 -0
- package/assets/components/TableRowEdit/index.ts +2 -0
- package/assets/components/TableRowSelect/TableRowSelect.module.css +23 -0
- package/assets/components/TableRowSelect/TableRowSelect.tsx +175 -0
- package/assets/components/TableRowSelect/index.ts +2 -0
- package/assets/components/Tabs/Tabs.module.css +234 -0
- package/assets/components/Tabs/Tabs.tsx +426 -0
- package/assets/components/Tabs/index.ts +9 -0
- package/assets/components/Textarea/Textarea.module.css +318 -0
- package/assets/components/Textarea/Textarea.tsx +426 -0
- package/assets/components/Textarea/index.ts +7 -0
- package/assets/components/ThemeController.tsx +271 -0
- package/assets/components/TimePicker/TimePicker.module.css +317 -0
- package/assets/components/TimePicker/TimePicker.tsx +821 -0
- package/assets/components/TimePicker/index.ts +8 -0
- package/assets/components/TimePicker/utils.ts +115 -0
- package/assets/components/Toast/Toast.module.css +264 -0
- package/assets/components/Toast/Toast.tsx +243 -0
- package/assets/components/Toast/index.ts +15 -0
- package/assets/components/Toolbar/Toolbar.module.css +72 -0
- package/assets/components/Toolbar/Toolbar.tsx +75 -0
- package/assets/components/Toolbar/index.ts +2 -0
- package/assets/components/Tooltip/Tooltip.module.css +42 -0
- package/assets/components/Tooltip/Tooltip.tsx +332 -0
- package/assets/components/Tooltip/index.ts +2 -0
- package/assets/components/Topbar/Topbar.module.css +26 -0
- package/assets/components/Topbar/Topbar.tsx +47 -0
- package/assets/components/Topbar/index.ts +2 -0
- package/assets/components/_cn.ts +3 -0
- package/assets/components/_color.ts +48 -0
- package/assets/components/_data.ts +659 -0
- package/assets/components/_utils.css +19 -0
- package/assets/components/axisOptions.ts +24 -0
- package/assets/components/tokens.css +742 -0
- package/assets/prompts/GUIDE.md +251 -0
- package/assets/prompts/OVERRIDE.md +170 -0
- package/assets/prompts/PRINCIPLES.md +130 -0
- package/assets/prompts/axes/density.md +38 -0
- package/assets/prompts/axes/font.md +36 -0
- package/assets/prompts/axes/hue.md +36 -0
- package/assets/prompts/axes/icon.md +48 -0
- package/assets/prompts/axes/mode.md +50 -0
- package/assets/prompts/axes/motion.md +77 -0
- package/assets/prompts/axes/palette.md +35 -0
- package/assets/prompts/axes/shape.md +33 -0
- package/assets/prompts/axes/voice.md +54 -0
- package/assets/prompts/components/README.md +84 -0
- package/assets/prompts/components/app-frame.md +94 -0
- package/assets/prompts/components/attachment-chip.md +46 -0
- package/assets/prompts/components/attachment-thumb.md +49 -0
- package/assets/prompts/components/avatar.md +86 -0
- package/assets/prompts/components/badge.md +104 -0
- package/assets/prompts/components/breadcrumb.md +77 -0
- package/assets/prompts/components/button.md +99 -0
- package/assets/prompts/components/callout.md +81 -0
- package/assets/prompts/components/chat-input.md +84 -0
- package/assets/prompts/components/checkbox.md +46 -0
- package/assets/prompts/components/chip.md +84 -0
- package/assets/prompts/components/choice-card.md +127 -0
- package/assets/prompts/components/context-menu.md +145 -0
- package/assets/prompts/components/date-picker.md +104 -0
- package/assets/prompts/components/drawer.md +152 -0
- package/assets/prompts/components/empty-state.md +69 -0
- package/assets/prompts/components/file-icon.md +73 -0
- package/assets/prompts/components/filter-button.md +42 -0
- package/assets/prompts/components/form-field.md +74 -0
- package/assets/prompts/components/gallery-item.md +158 -0
- package/assets/prompts/components/icon-button.md +82 -0
- package/assets/prompts/components/icon.md +68 -0
- package/assets/prompts/components/input.md +95 -0
- package/assets/prompts/components/list-item.md +235 -0
- package/assets/prompts/components/menu-item.md +234 -0
- package/assets/prompts/components/metric-card.md +132 -0
- package/assets/prompts/components/modal.md +131 -0
- package/assets/prompts/components/pagination.md +92 -0
- package/assets/prompts/components/progress-bar.md +61 -0
- package/assets/prompts/components/quotation-bar.md +39 -0
- package/assets/prompts/components/radio.md +41 -0
- package/assets/prompts/components/select.md +104 -0
- package/assets/prompts/components/selectable-card.md +67 -0
- package/assets/prompts/components/shortcut.md +76 -0
- package/assets/prompts/components/sidebar.md +107 -0
- package/assets/prompts/components/slider.md +89 -0
- package/assets/prompts/components/split-button.md +71 -0
- package/assets/prompts/components/stepper.md +93 -0
- package/assets/prompts/components/switch.md +86 -0
- package/assets/prompts/components/table-cell.md +87 -0
- package/assets/prompts/components/table-header.md +157 -0
- package/assets/prompts/components/table-row-edit.md +129 -0
- package/assets/prompts/components/table-row-select.md +82 -0
- package/assets/prompts/components/table-row.md +156 -0
- package/assets/prompts/components/tabs.md +122 -0
- package/assets/prompts/components/textarea.md +105 -0
- package/assets/prompts/components/toast.md +149 -0
- package/assets/prompts/components/tooltip.md +71 -0
- package/assets/prompts/components/topbar.md +148 -0
- package/assets/prompts/primitives/emerge.md +43 -0
- package/assets/prompts/primitives/fade.md +31 -0
- package/assets/prompts/primitives/scale.md +32 -0
- package/assets/prompts/primitives/scroll.md +75 -0
- package/assets/prompts/primitives/slide.md +31 -0
- package/assets/prompts/themes/_SCHEMA.md +135 -0
- package/assets/prompts/themes/_TEMPLATE.md +73 -0
- package/assets/prompts/themes/expressive.md +118 -0
- package/assets/prompts/themes/pure.md +87 -0
- package/assets/prompts/themes/spare.md +73 -0
- package/assets/prompts/tokens/breakpoint.md +29 -0
- package/assets/prompts/tokens/color.md +78 -0
- package/assets/prompts/tokens/radius.md +33 -0
- package/assets/prompts/tokens/shadow.md +35 -0
- package/assets/prompts/tokens/spacing.md +86 -0
- package/assets/prompts/tokens/typography.md +76 -0
- package/assets/prompts/tokens/z-index.md +35 -0
- package/assets/public/expressive.png +0 -0
- package/assets/public/pure.png +0 -0
- package/assets/public/spare.png +0 -0
- package/assets/skill/SKILL.md +36 -0
- package/bin/ctds.js +76 -0
- package/package.json +35 -4
- package/src/commands/init.js +215 -0
- package/src/commands/update.js +275 -0
- package/src/utils/assets.js +78 -0
- package/src/utils/deps.js +51 -0
- package/src/utils/detect.js +47 -0
- package/src/utils/diff.js +52 -0
- package/src/utils/hash.js +16 -0
- package/src/utils/log.js +41 -0
- package/src/utils/meta.js +73 -0
- package/src/utils/prompt.js +28 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/* Select โ Radix Select ์์ ์น์ ์๊ฐ ๋ ์ด์ด.
|
|
2
|
+
Trigger ์๊ฐ์ Input.module.css์์ ์ฌ์ฌ์ฉํ๊ณ , ์ฌ๊ธฐ์๋ Select ์ ์ฉ ์์ฌ๋ง ์ ์ํ๋ค.
|
|
3
|
+
Content/Item ์๊ฐ์ ContextMenu์ ํ์ค๋ฒ ํ๋ฉด๊ณผ MenuItem ์ด๋ํฐ ํจํด์ ๊ทธ๋๋ก ๋ฐ๋ฅธ๋ค. */
|
|
4
|
+
|
|
5
|
+
/* Trigger ์์ฌ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
6
|
+
Input.root์ ์๊ฐ ๊ท์น(border/bg/height/padding/font-size/radius)์ ๊ทธ๋๋ก ์์.
|
|
7
|
+
์ฌ๊ธฐ์๋ <button> UA ์คํ์ผ(marginยทpaddingยทfontยทtext-alignยทcolor)์ ์์ ํ ๋ฆฌ์
ํด
|
|
8
|
+
<input>์ผ ๋์ ์๊ฐ์ ์ผ๋ก 1:1 ์ผ์น์ํจ๋ค.
|
|
9
|
+
ํนํ button์ ๊ธฐ๋ณธ font๋ ์์คํ
ํฐํธ(-apple-system-body)๋ก ๋ถ๋ชจ ์์์ ๋์ผ๋ฏ๋ก
|
|
10
|
+
font: inherit ํ์. padding: 0์ผ๋ก UA ์ฌ๋ฐฑ์ ์ง์ฐ๊ณ root์ padding-inline๋ง ์ด๋ฆฐ๋ค. */
|
|
11
|
+
.trigger {
|
|
12
|
+
margin: 0;
|
|
13
|
+
padding-block: 0;
|
|
14
|
+
/* font-family๋ง ๋ถ๋ชจ ์์์ผ๋ก ๋ฆฌ์
โ <button> UA๋ ์์คํ
ํฐํธ(-apple-system-body)๋ก
|
|
15
|
+
๋ถ๋ชจ ์์์ ๋๋๋ค. shorthand `font: inherit`์ font-size๊น์ง ๋ฎ์ด์จ์ ์ฌ์ด์ฆ ํด๋์ค(sizeSm/Md/Lg)์
|
|
16
|
+
font-size ์ง์ ์ ๋ฌดํจํํ๋ฏ๋ก ์ ๋ ๊ธ์ง. font-family๋ง inheritํ๊ณ font-size/font-weight/
|
|
17
|
+
line-height๋ Input.root/size ํด๋์ค๊ฐ ์ ํ ๊ฐ์ ๊ทธ๋๋ก ์ฌ์ฉ. */
|
|
18
|
+
font-family: inherit;
|
|
19
|
+
font-weight: inherit;
|
|
20
|
+
color: inherit;
|
|
21
|
+
text-align: start;
|
|
22
|
+
cursor: pointer;
|
|
23
|
+
appearance: none;
|
|
24
|
+
/* gap ยท border ยท border-radius ยท height ยท font-size ยท padding-inline ยท background์
|
|
25
|
+
๋ชจ๋ Input.root/variant/size ํด๋์ค์์ ์ด๋ฏธ ์ง์ โ ์ฌ๊ธฐ์ ์ฌ์ ์ธํ์ง ์๋๋ค. */
|
|
26
|
+
}
|
|
27
|
+
.trigger[data-disabled] {
|
|
28
|
+
cursor: not-allowed;
|
|
29
|
+
}
|
|
30
|
+
/* Input.root์ hover/focus ๊ท์น์ `:has(:focus-visible)` ๊ธฐ๋ฐ์ด๋ผ button ํธ๋ฆฌ๊ฑฐ์์๋
|
|
31
|
+
์์ฐ์ค๋ฝ๊ฒ ๊ฑธ๋ฆฌ์ง ์๋๋ค. Input๊ณผ ๋์ผํ ์๊ฐ(border-strong ยท outline ์ ๊ฑฐ, ring ์์)์
|
|
32
|
+
button ์์ ์ focus-visible๊ณผ ์ด๋ฆผ ์ํ์ ๋ํด ์ฌ์ ์ธ. */
|
|
33
|
+
.trigger:focus-visible,
|
|
34
|
+
.trigger[data-state="open"] {
|
|
35
|
+
border-color: var(--border-strong);
|
|
36
|
+
outline: none;
|
|
37
|
+
}
|
|
38
|
+
/* invalid ์ํ์์๋ ์ด๋ฆผ/ํฌ์ปค์ค์์๋ destructive๋ฅผ ์ ์ง โ Input๊ณผ ๋์ผ ๊ท์น. */
|
|
39
|
+
.trigger[data-invalid]:focus-visible,
|
|
40
|
+
.trigger[data-invalid][data-state="open"] {
|
|
41
|
+
border-color: var(--destructive);
|
|
42
|
+
}
|
|
43
|
+
/* line variant๋ ์๋์ชฝ border๋ง ๊ฐ์กฐ โ Input.line์ focus ๊ท์น๊ณผ ๋์ผ.
|
|
44
|
+
.line ํด๋์ค๋ Input.module.css์ hashed ํด๋์ค๋ผ ์ง์ ์ฐธ์กฐ ๋ถ๊ฐ โ
|
|
45
|
+
.trigger์ data-variant ์ดํธ๋ฆฌ๋ทฐํธ๋ก ์ปค๋ฒ. */
|
|
46
|
+
.trigger[data-variant="line"]:focus-visible,
|
|
47
|
+
.trigger[data-variant="line"][data-state="open"] {
|
|
48
|
+
border-color: transparent;
|
|
49
|
+
border-bottom-color: var(--border-strong);
|
|
50
|
+
}
|
|
51
|
+
.trigger[data-variant="line"][data-invalid]:focus-visible,
|
|
52
|
+
.trigger[data-variant="line"][data-invalid][data-state="open"] {
|
|
53
|
+
border-color: transparent;
|
|
54
|
+
border-bottom-color: var(--destructive);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/* ์ ํ๋ ๊ฐ ํ
์คํธ ์ฌ๋กฏ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
58
|
+
Input์ .input๊ณผ ๋์ผํ line-height + font-size ์์ ๊ท์น์ ๋ฐ๋ฅธ๋ค.
|
|
59
|
+
flex:1๋ก ๋จ์ ๊ณต๊ฐ์ ์ฐจ์งํ๋ ๊ธด ๋ผ๋ฒจ์ ellipsis.
|
|
60
|
+
placeholder ์์ Radix๊ฐ ์์ span[data-placeholder]์ ๋ถ์ฌ. */
|
|
61
|
+
.value {
|
|
62
|
+
flex: 1 1 auto;
|
|
63
|
+
min-width: 0;
|
|
64
|
+
overflow: hidden;
|
|
65
|
+
text-overflow: ellipsis;
|
|
66
|
+
white-space: nowrap;
|
|
67
|
+
font-size: inherit;
|
|
68
|
+
line-height: var(--lh-sm);
|
|
69
|
+
color: var(--fg);
|
|
70
|
+
}
|
|
71
|
+
.value :global([data-placeholder]) {
|
|
72
|
+
color: var(--fg-subtle);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/* Chevron โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
76
|
+
์ด๋ฆผ ์ 180๋ ํ์ . transition-transform์ ์ปฌ๋ฌ ํ๋ฆฌ์
์ ์์ด duration/easing ํ ํฐ ์กฐํฉ.
|
|
77
|
+
Icon ์ปดํฌ๋ํธ๊ฐ svg ํฌ๊ธฐ๋ฅผ em์ผ๋ก ํ๋์ฝ๋ฉํ๋ฏ๋ก ๋ถ๋ชจ font-size์ ์๋ ์ค์ผ์ผ. */
|
|
78
|
+
.chevron {
|
|
79
|
+
display: inline-flex;
|
|
80
|
+
align-items: center;
|
|
81
|
+
justify-content: center;
|
|
82
|
+
color: var(--fg-subtle);
|
|
83
|
+
transition: transform var(--duration-fast) var(--ease-out);
|
|
84
|
+
flex: 0 0 auto;
|
|
85
|
+
}
|
|
86
|
+
.trigger[data-state="open"] .chevron {
|
|
87
|
+
transform: rotate(180deg);
|
|
88
|
+
}
|
|
89
|
+
/* size๋ณ chevron ์์ด์ฝ ํฌ๊ธฐ โ Input์ .icon ๊ท์น๊ณผ ๋์ผํ ์คํ
.
|
|
90
|
+
trigger์ size๋ Input.module.css hashed ํด๋์ค๋ผ ์ฌ๊ธฐ์ ์ง์ ์ฐธ์กฐ ๋ถ๊ฐ โ
|
|
91
|
+
chevron ์์ฒด์ data-size๋ฅผ ๋ถ์ฌํด ์ฐธ์กฐ. */
|
|
92
|
+
.chevron[data-size="sm"] > svg { width: var(--icon-size-xs); height: var(--icon-size-xs); }
|
|
93
|
+
.chevron[data-size="md"] > svg { width: var(--icon-size-sm); height: var(--icon-size-sm); }
|
|
94
|
+
.chevron[data-size="lg"] > svg { width: var(--icon-size-md); height: var(--icon-size-md); }
|
|
95
|
+
|
|
96
|
+
/* Content panel โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
97
|
+
ContextMenu.Content์ ํ๋ฉด(surface) ์๊ฐ์ ๊ณต์ . bgยทborderยทradiusยทshadowยทpaddingยทoutline์
|
|
98
|
+
ContextMenu.module.css์ .surface์์ composes๋ก ๊ฐ์ ธ์จ๋ค.
|
|
99
|
+
Select ์ ์ฉ ์์ฌ๋ง ์ฌ๊ธฐ์:
|
|
100
|
+
- ํญ ๊ท์น: ํธ๋ฆฌ๊ฑฐ ํญ ์ด์์ผ๋ก ๋ฒ์ด์ง๋๋ก --radix-select-trigger-width ์ฌ์ฉ
|
|
101
|
+
- ๋์ด ์ ํ: Radix๊ฐ ๊ณ์ฐํ available-height
|
|
102
|
+
- transform-origin: Select primitive์ฉ ๋ณ์
|
|
103
|
+
- overflow hidden: ์คํฌ๋กค ๋ฒํผ๊ณผ viewport๊ฐ content ๊ฒฝ๊ณ ์์ ๋จธ๋ฌผ๋๋ก */
|
|
104
|
+
.content {
|
|
105
|
+
composes: surface from "../ContextMenu/ContextMenu.module.css";
|
|
106
|
+
--select-menu-w: calc(var(--space-2) * 28);
|
|
107
|
+
width: max-content;
|
|
108
|
+
min-width: max(var(--radix-select-trigger-width), var(--select-menu-w));
|
|
109
|
+
max-width: min(
|
|
110
|
+
calc(var(--select-menu-w) + var(--space-2) * 8),
|
|
111
|
+
calc(100vw - var(--space-6))
|
|
112
|
+
);
|
|
113
|
+
max-height: min(
|
|
114
|
+
var(--radix-select-content-available-height),
|
|
115
|
+
calc(100vh - var(--space-6))
|
|
116
|
+
);
|
|
117
|
+
z-index: var(--z-popover);
|
|
118
|
+
transform-origin: var(--radix-select-content-transform-origin);
|
|
119
|
+
overflow: hidden;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/* In ยท Out ์ ๋๋ฉ์ด์
์ ์ ์ญ ์ ํธ `.m-float`๊ฐ ๋ด๋น. Select.tsx์์ Content className์
|
|
123
|
+
"m-float"์ concatํด ๋ฐ๋. globals.css์ .m-float ์ ์ ์ฐธ๊ณ . */
|
|
124
|
+
|
|
125
|
+
/* Viewport โ Radix์ ์ค์ ์คํฌ๋กค ์์ญ. ์์ฒด padding ์์ด content padding๋ง ์ฌ์ฉ
|
|
126
|
+
(์คํฌ๋กค ์ปจํ
์ด๋์ padding ๊ธ์ง ๊ท์น). scrollbar ์๊ฐ์ globals.css์ overlay ์ ์ฑ
. */
|
|
127
|
+
|
|
128
|
+
/* Scroll buttons โ ๋ฆฌ์คํธ๊ฐ ๊ธธ์ด ์คํฌ๋กค ํ์ ์ ์/์๋ ๋
ธ์ถ๋๋ ํํธ ๋ฒํผ. */
|
|
129
|
+
.scrollButton {
|
|
130
|
+
display: flex;
|
|
131
|
+
align-items: center;
|
|
132
|
+
justify-content: center;
|
|
133
|
+
height: var(--control-h-sm);
|
|
134
|
+
color: var(--fg-muted);
|
|
135
|
+
cursor: default;
|
|
136
|
+
background: linear-gradient(to bottom, var(--bg), transparent);
|
|
137
|
+
}
|
|
138
|
+
.scrollButton:last-child {
|
|
139
|
+
background: linear-gradient(to top, var(--bg), transparent);
|
|
140
|
+
}
|
|
141
|
+
.scrollButton > svg {
|
|
142
|
+
width: var(--icon-size-sm);
|
|
143
|
+
height: var(--icon-size-sm);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/* Separator โ ContextMenu์ ๋์ผ ๊ท์น, ์๋ณธ์ composes๋ก ๊ทธ๋๋ก ์ฌ์ฌ์ฉ.
|
|
147
|
+
Select ์์ดํ
์ selected checkmark๋ฅผ ์ฐ์ง ์๋๋ค(๋ฐฐ๊ฒฝ ํ์ด๋ผ์ดํธ๋ก๋ง ํ์) โ
|
|
148
|
+
leading ์ฌ๋กฏ์ ๊ตญ๊ธฐยท์์ด์ฝ ๊ฐ์ ์๊ฐ ์ฝํ
์ธ ์ ์ฉ์ผ๋ก ์ด์ด๋๋ค. */
|
|
149
|
+
.separator {
|
|
150
|
+
composes: separator from "../ContextMenu/ContextMenu.module.css";
|
|
151
|
+
}
|
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Select โ ๋จ์ผ ๊ฐ ์ ํ ์ฝค๋ณด. Radix Select ์์ ์น์ compound ์ปดํฌ๋ํธ.
|
|
5
|
+
*
|
|
6
|
+
* ๊ตฌ์กฐ ์์น
|
|
7
|
+
* - Trigger ์๊ฐ์ Input๊ณผ ์์ ํ ๋์ผํ ์คํ์ผ(variant/size/invalid/label/description/warning)์ ๊ณต์ ํ๋ค.
|
|
8
|
+
* ์ค์ ํด๋์ค๋ Input.module.css์์ ์ฌ์ฌ์ฉํด ์๊ฐ ๊ท์น์ด ๋ ๊ฐ๋๋ก ๊ฐ๋ผ์ง์ง ์๊ฒ ํ๋ค.
|
|
9
|
+
* - Content/Item ์๊ฐ์ ContextMenu์ ๋์ผํ ํ์ค๋ฒ ํ๋ฉด๊ณผ MenuItem ์ด๋ํฐ ํจํด์ ๊ทธ๋๋ก ๋ฐ๋ฅธ๋ค.
|
|
10
|
+
* - ์ด ํ์ผ์ ๋ ๊ณ์ธต์ ์๋ ์์ ์ด๋ํฐ. ์ ๊ท ์๊ฐ ๊ท์น ยท ๋ก์ง ยท ์ํ๋ฅผ ์ฌ๊ธฐ์ ๋ง๋ค์ง ์๋๋ค.
|
|
11
|
+
*
|
|
12
|
+
* ์๋น ํ๋ฉด
|
|
13
|
+
* <Select value={v} onValueChange={setV} label="๊ตญ๊ฐ" placeholder="์ ํํ์ธ์">
|
|
14
|
+
* <Select.Item value="kr">ํ๊ตญ</Select.Item>
|
|
15
|
+
* <Select.Item value="us" leadingActions={[<Icon name="flag" />]}>๋ฏธ๊ตญ</Select.Item>
|
|
16
|
+
* <Select.Separator />
|
|
17
|
+
* <Select.Group>
|
|
18
|
+
* <Select.Label>์ ๋ฝ</Select.Label>
|
|
19
|
+
* <Select.Item value="de">๋
์ผ</Select.Item>
|
|
20
|
+
* </Select.Group>
|
|
21
|
+
* </Select>
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import * as RS from "@radix-ui/react-select";
|
|
25
|
+
import {
|
|
26
|
+
createContext,
|
|
27
|
+
forwardRef,
|
|
28
|
+
useContext,
|
|
29
|
+
useId,
|
|
30
|
+
type ComponentPropsWithoutRef,
|
|
31
|
+
type ReactNode,
|
|
32
|
+
} from "react";
|
|
33
|
+
|
|
34
|
+
import { Icon, IconAxisProvider, useIconAxis } from "../Icon";
|
|
35
|
+
import inputStyles from "../Input/Input.module.css";
|
|
36
|
+
import { MenuItem, type MenuItemAction, type MenuItemSize } from "../MenuItem";
|
|
37
|
+
import styles from "./Select.module.css";
|
|
38
|
+
|
|
39
|
+
export type SelectSize = "sm" | "md" | "lg";
|
|
40
|
+
export type SelectVariant = "outline" | "filled" | "line";
|
|
41
|
+
/**
|
|
42
|
+
* ๊ฐ๋ก ํญ ์ ์ฑ
โ Input์ InputWidth์ ๋์ผ ๊ท์ฝ. ๋ ์ปดํฌ๋ํธ๋ฅผ ํผ์์ ๋๋ํ ๋์ ๋
|
|
43
|
+
* ํญ ๋ฌธ๋ฒ์ ํ๋๋ก ํต์ผํด ์ธ์ง ๋ถ๋ด์ ์ค์ธ๋ค.
|
|
44
|
+
* - "fill"(๊ธฐ๋ณธ): ๋ถ๋ชจ ํญ ์ฑ์
|
|
45
|
+
* - "md" | "lg": --input-w-md=280px ยท --input-w-lg=400px ํ ํฐ์ ๊ณ ์
|
|
46
|
+
* - number: ์์ ํฝ์
|
|
47
|
+
*/
|
|
48
|
+
export type SelectWidth = "fill" | "md" | "lg" | number;
|
|
49
|
+
|
|
50
|
+
/* Size context โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
51
|
+
Trigger์ size๋ฅผ Content ํ์ Item๋ค์ด ์ด์ด๋ฐ๋๋ก ๊ณต์ .
|
|
52
|
+
Trigger๋ 3๋จ(sm/md/lg)์ด์ง๋ง ๋๋กญ๋ค์ด MenuItem์ ์กฐ๋ฐํ๊ฒ ์ฌ๋ ๊ฒ ์ค์ ์์ ์์ฐ์ค๋ฌ์ โ
|
|
53
|
+
lg ํธ๋ฆฌ๊ฑฐ๋ง md ์์ดํ
์ผ๋ก ์ด๊ณ , sm/md ํธ๋ฆฌ๊ฑฐ๋ ๋ชจ๋ sm ์์ดํ
์ผ๋ก ์ฐ๋ค. */
|
|
54
|
+
const menuSizeFor: Record<SelectSize, MenuItemSize> = {
|
|
55
|
+
sm: "sm",
|
|
56
|
+
md: "sm",
|
|
57
|
+
lg: "md",
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const SizeContext = createContext<SelectSize>("md");
|
|
61
|
+
function useSelectSize(): SelectSize {
|
|
62
|
+
return useContext(SizeContext);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* Root โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
66
|
+
Radix Select.Root๋ฅผ ๊ทธ๋๋ก ๋
ธ์ถ. label/description/warning์ ํ์ Trigger๊ฐ ์์์ผ ํ๋ฏ๋ก
|
|
67
|
+
FieldContext๋ก ๊ณต์ ํ๋ค. */
|
|
68
|
+
|
|
69
|
+
type FieldContextValue = {
|
|
70
|
+
size: SelectSize;
|
|
71
|
+
variant: SelectVariant;
|
|
72
|
+
invalid: boolean;
|
|
73
|
+
disabled: boolean;
|
|
74
|
+
width: SelectWidth;
|
|
75
|
+
triggerId: string;
|
|
76
|
+
describedBy?: string;
|
|
77
|
+
};
|
|
78
|
+
const FieldContext = createContext<FieldContextValue | null>(null);
|
|
79
|
+
|
|
80
|
+
export interface SelectRootProps
|
|
81
|
+
extends Omit<ComponentPropsWithoutRef<typeof RS.Root>, "children"> {
|
|
82
|
+
size?: SelectSize;
|
|
83
|
+
variant?: SelectVariant;
|
|
84
|
+
/** ํผ ๊ฒ์ฆ ์คํจ. warning์ด ์์ผ๋ฉด ์๋์ผ๋ก true. */
|
|
85
|
+
invalid?: boolean;
|
|
86
|
+
/** ๊ฐ๋ก ํญ. ๊ธฐ๋ณธ "fill" (๋ถ๋ชจ ํญ ์ฑ์). "md"=280px ยท "lg"=400px ยท number=px. */
|
|
87
|
+
width?: SelectWidth;
|
|
88
|
+
/** ๋ผ๋ฒจ ํ
์คํธ. ์์ผ๋ฉด <label>์ด ์์ ๋ ๋๋ง๋๊ณ aria๋ก ์๋ ์ฐ๊ฒฐ. */
|
|
89
|
+
label?: ReactNode;
|
|
90
|
+
/** ์ค๋ฆฝ ํค์ ์ค๋ช
. ํธ๋ฆฌ๊ฑฐ ์๋ ํ์. */
|
|
91
|
+
description?: ReactNode;
|
|
92
|
+
/** ๊ฒฝ๊ณ ๋ฉ์์ง. ์์ผ๋ฉด invalid๋ก ์ทจ๊ธ๋์ด ๋ณด๋๊ฐ destructive๋ก ๋ฐ๋๋ค. */
|
|
93
|
+
warning?: ReactNode;
|
|
94
|
+
/** ๋ผ๋ฒจ์ htmlFor๋ฅผ ์ํ id (Radix Trigger์ ๋ถ์ฌ). */
|
|
95
|
+
id?: string;
|
|
96
|
+
children?: ReactNode;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** width ๊ฐ์ CSS width ๋ฌธ์์ด๋ก ๋ณํ. Input์ ์ ์ฑ
๊ณผ ์์ ํ ๋์ผ. */
|
|
100
|
+
function resolveWidth(w: SelectWidth): string | undefined {
|
|
101
|
+
if (w === "fill") return undefined;
|
|
102
|
+
if (w === "md") return "var(--input-w-md)";
|
|
103
|
+
if (w === "lg") return "var(--input-w-lg)";
|
|
104
|
+
return `${w}px`;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const Root = ({
|
|
108
|
+
size = "md",
|
|
109
|
+
variant = "outline",
|
|
110
|
+
invalid: invalidProp,
|
|
111
|
+
width = "fill",
|
|
112
|
+
disabled = false,
|
|
113
|
+
label,
|
|
114
|
+
description,
|
|
115
|
+
warning,
|
|
116
|
+
id,
|
|
117
|
+
children,
|
|
118
|
+
...rest
|
|
119
|
+
}: SelectRootProps) => {
|
|
120
|
+
const hasWarning = warning != null && warning !== false;
|
|
121
|
+
const invalid = invalidProp ?? hasWarning;
|
|
122
|
+
|
|
123
|
+
const autoId = useId();
|
|
124
|
+
const triggerId = id ?? autoId;
|
|
125
|
+
const descriptionId = description != null ? `${triggerId}-desc` : undefined;
|
|
126
|
+
const warningId = hasWarning ? `${triggerId}-warn` : undefined;
|
|
127
|
+
const describedBy =
|
|
128
|
+
[warningId, descriptionId].filter(Boolean).join(" ") || undefined;
|
|
129
|
+
|
|
130
|
+
const field: FieldContextValue = {
|
|
131
|
+
size,
|
|
132
|
+
variant,
|
|
133
|
+
invalid,
|
|
134
|
+
disabled,
|
|
135
|
+
width,
|
|
136
|
+
triggerId,
|
|
137
|
+
describedBy,
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const bare = label == null && description == null && !hasWarning;
|
|
141
|
+
const widthValue = resolveWidth(width);
|
|
142
|
+
|
|
143
|
+
return (
|
|
144
|
+
<FieldContext.Provider value={field}>
|
|
145
|
+
<SizeContext.Provider value={size}>
|
|
146
|
+
<RS.Root disabled={disabled} {...rest}>
|
|
147
|
+
{bare ? (
|
|
148
|
+
children
|
|
149
|
+
) : (
|
|
150
|
+
<div
|
|
151
|
+
className={inputStyles.field}
|
|
152
|
+
data-disabled={disabled || undefined}
|
|
153
|
+
/* field ๋ํผ๋ width๋ฅผ ๋ฐ๋ผ์ผ label ยท description ยท warning ๋ผ์ธ์ด trigger์ ์ ๋ ฌ๋๋ค.
|
|
154
|
+
width="fill"์ด๋ฉด style ์์ โ .field๋ block-level flex๋ผ ๋ถ๋ชจ ํญ์ ์๋์ผ๋ก ๋ฐ๋ฅธ๋ค. */
|
|
155
|
+
style={widthValue ? { width: widthValue } : undefined}
|
|
156
|
+
>
|
|
157
|
+
{label != null && (
|
|
158
|
+
<label
|
|
159
|
+
htmlFor={triggerId}
|
|
160
|
+
className={[
|
|
161
|
+
inputStyles.label,
|
|
162
|
+
size === "sm"
|
|
163
|
+
? inputStyles.labelSm
|
|
164
|
+
: size === "lg"
|
|
165
|
+
? inputStyles.labelLg
|
|
166
|
+
: inputStyles.labelMd,
|
|
167
|
+
].join(" ")}
|
|
168
|
+
>
|
|
169
|
+
{label}
|
|
170
|
+
{rest.required && (
|
|
171
|
+
<span aria-hidden className={inputStyles.requiredMark}>
|
|
172
|
+
*
|
|
173
|
+
</span>
|
|
174
|
+
)}
|
|
175
|
+
</label>
|
|
176
|
+
)}
|
|
177
|
+
|
|
178
|
+
{children}
|
|
179
|
+
|
|
180
|
+
{hasWarning && (
|
|
181
|
+
<p id={warningId} role="alert" className={inputStyles.errorText}>
|
|
182
|
+
<span className={inputStyles.messageIcon} aria-hidden>
|
|
183
|
+
<Icon name="warning-circle" size={14} />
|
|
184
|
+
</span>
|
|
185
|
+
{warning}
|
|
186
|
+
</p>
|
|
187
|
+
)}
|
|
188
|
+
|
|
189
|
+
{description != null && !hasWarning && (
|
|
190
|
+
<p id={descriptionId} className={inputStyles.description}>
|
|
191
|
+
<span className={inputStyles.messageIcon} aria-hidden>
|
|
192
|
+
<Icon name="info" size={14} />
|
|
193
|
+
</span>
|
|
194
|
+
{description}
|
|
195
|
+
</p>
|
|
196
|
+
)}
|
|
197
|
+
</div>
|
|
198
|
+
)}
|
|
199
|
+
</RS.Root>
|
|
200
|
+
</SizeContext.Provider>
|
|
201
|
+
</FieldContext.Provider>
|
|
202
|
+
);
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
/* Trigger โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
206
|
+
์๊ฐ์ Input๊ณผ ์์ ํ ๊ณต์ . Input.module.css์ root/variant/size ํด๋์ค๋ฅผ ๊ทธ๋๋ก ์ฌ์ฉํ๊ณ ,
|
|
207
|
+
๋ด๋ถ ํ
์คํธ/์์ด์ฝ ์ฌ๋กฏ ์๊ฐ๋ ์ฌ์ฌ์ฉํ๋ค. Select ์ ์ฉ ์์ฌ(placeholder ์, chevron ํ์ ๋ฑ)๋ง
|
|
208
|
+
Select.module.css์์ ์ ์. */
|
|
209
|
+
|
|
210
|
+
const sizeClass: Record<SelectSize, string> = {
|
|
211
|
+
sm: inputStyles.sizeSm,
|
|
212
|
+
md: inputStyles.sizeMd,
|
|
213
|
+
lg: inputStyles.sizeLg,
|
|
214
|
+
};
|
|
215
|
+
const variantClass: Record<SelectVariant, string> = {
|
|
216
|
+
outline: inputStyles.outline,
|
|
217
|
+
filled: inputStyles.filled,
|
|
218
|
+
line: inputStyles.line,
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
export interface TriggerProps
|
|
222
|
+
extends Omit<ComponentPropsWithoutRef<typeof RS.Trigger>, "asChild"> {
|
|
223
|
+
/** placeholder๋ Value์์ ์ฒ๋ฆฌํ์ง๋ง, Trigger์์ ์ง์ ์ง์ ํ ์๋ ์๋ค. */
|
|
224
|
+
placeholder?: ReactNode;
|
|
225
|
+
/** ์ผ์ชฝ ์ฌ๋กฏ ์์ด์ฝ (์ ํ๋ ๊ฐ ์). */
|
|
226
|
+
leftIcon?: ReactNode;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const Trigger = forwardRef<HTMLButtonElement, TriggerProps>(function SelectTrigger(
|
|
230
|
+
{ className, placeholder, leftIcon, children, ...rest },
|
|
231
|
+
ref
|
|
232
|
+
) {
|
|
233
|
+
const field = useContext(FieldContext);
|
|
234
|
+
const size: SelectSize = field?.size ?? "md";
|
|
235
|
+
const variant: SelectVariant = field?.variant ?? "outline";
|
|
236
|
+
const invalid = field?.invalid ?? false;
|
|
237
|
+
const disabled = field?.disabled ?? rest.disabled ?? false;
|
|
238
|
+
const width: SelectWidth = field?.width ?? "fill";
|
|
239
|
+
const widthValue = resolveWidth(width);
|
|
240
|
+
|
|
241
|
+
const rootClass = [
|
|
242
|
+
inputStyles.root,
|
|
243
|
+
variantClass[variant],
|
|
244
|
+
sizeClass[size],
|
|
245
|
+
width === "fill" ? inputStyles.fill : "",
|
|
246
|
+
styles.trigger,
|
|
247
|
+
className ?? "",
|
|
248
|
+
]
|
|
249
|
+
.filter(Boolean)
|
|
250
|
+
.join(" ");
|
|
251
|
+
|
|
252
|
+
return (
|
|
253
|
+
<RS.Trigger
|
|
254
|
+
ref={ref}
|
|
255
|
+
id={field?.triggerId}
|
|
256
|
+
className={rootClass}
|
|
257
|
+
style={widthValue ? { width: widthValue } : undefined}
|
|
258
|
+
data-invalid={invalid || undefined}
|
|
259
|
+
data-disabled={disabled || undefined}
|
|
260
|
+
data-variant={variant}
|
|
261
|
+
aria-invalid={invalid || undefined}
|
|
262
|
+
aria-describedby={field?.describedBy}
|
|
263
|
+
disabled={disabled}
|
|
264
|
+
{...rest}
|
|
265
|
+
>
|
|
266
|
+
{leftIcon && (
|
|
267
|
+
<span className={inputStyles.icon} aria-hidden>
|
|
268
|
+
{leftIcon}
|
|
269
|
+
</span>
|
|
270
|
+
)}
|
|
271
|
+
<span className={styles.value}>
|
|
272
|
+
{children ?? <RS.Value placeholder={placeholder} />}
|
|
273
|
+
</span>
|
|
274
|
+
<RS.Icon asChild>
|
|
275
|
+
<span className={styles.chevron} data-size={size} aria-hidden>
|
|
276
|
+
<Icon name="caret-down" />
|
|
277
|
+
</span>
|
|
278
|
+
</RS.Icon>
|
|
279
|
+
</RS.Trigger>
|
|
280
|
+
);
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
/* Value โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ */
|
|
284
|
+
|
|
285
|
+
const Value = RS.Value;
|
|
286
|
+
|
|
287
|
+
/* Content โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
288
|
+
ContextMenu.Content์ ๋์ผํ ํ์ค๋ฒ ํ๋ฉด ์๊ฐ์ ๊ณต์ ํ๋(๊ฐ์ ํ ํฐ ์กฐํฉ), Select ์ ์ฉ์
|
|
289
|
+
position/side-offset ๊ท์น์ด ์์ด ์คํ์ผ์ Select.module.css์์ ๋ณ๋ ์ ์. */
|
|
290
|
+
|
|
291
|
+
export interface ContentProps
|
|
292
|
+
extends Omit<ComponentPropsWithoutRef<typeof RS.Content>, "asChild"> {}
|
|
293
|
+
|
|
294
|
+
const Content = forwardRef<HTMLDivElement, ContentProps>(function SelectContent(
|
|
295
|
+
{
|
|
296
|
+
className,
|
|
297
|
+
position = "popper",
|
|
298
|
+
sideOffset = 6,
|
|
299
|
+
collisionPadding = 8,
|
|
300
|
+
children,
|
|
301
|
+
...rest
|
|
302
|
+
},
|
|
303
|
+
ref
|
|
304
|
+
) {
|
|
305
|
+
/* Radix Portal์ด Content๋ฅผ document.body๋ก ์ฎ๊ธฐ๋ฉฐ ์์ React Provider๊ฐ ํ๋ฌ๊ฐ์ง ์๋๋ค.
|
|
306
|
+
Icon ์ถ์ ์บก์ฒํด Portal ํ์์ ์ฌ์ฃผ์
โ ๋ด๋ถ Icon๊ณผ Item ์์ด์ฝ๊น์ง ์ถ ์ค์ ๋ฐ์. */
|
|
307
|
+
const iconAxis = useIconAxis();
|
|
308
|
+
return (
|
|
309
|
+
<RS.Portal>
|
|
310
|
+
<RS.Content
|
|
311
|
+
ref={ref}
|
|
312
|
+
position={position}
|
|
313
|
+
sideOffset={sideOffset}
|
|
314
|
+
collisionPadding={collisionPadding}
|
|
315
|
+
className={[styles.content, "m-float", className ?? ""].filter(Boolean).join(" ")}
|
|
316
|
+
{...rest}
|
|
317
|
+
>
|
|
318
|
+
<IconAxisProvider value={iconAxis}>
|
|
319
|
+
<RS.ScrollUpButton className={styles.scrollButton}>
|
|
320
|
+
<Icon name="caret-up" />
|
|
321
|
+
</RS.ScrollUpButton>
|
|
322
|
+
<RS.Viewport className={styles.viewport}>{children}</RS.Viewport>
|
|
323
|
+
<RS.ScrollDownButton className={styles.scrollButton}>
|
|
324
|
+
<Icon name="caret-down" />
|
|
325
|
+
</RS.ScrollDownButton>
|
|
326
|
+
</IconAxisProvider>
|
|
327
|
+
</RS.Content>
|
|
328
|
+
</RS.Portal>
|
|
329
|
+
);
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
/* Item โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
333
|
+
MenuItem์ Radix Select.Item์ asChild๋ก ์์. ๋๋กญ๋ค์ด ์์ดํ
์ ์ธ ํํ๋ง ํ์ฉ:
|
|
334
|
+
1) ํ
์คํธ๋ง
|
|
335
|
+
2) leading ์ด๋ฏธ์งยท์์ด์ฝ(๊ตญ๊ธฐ ๋ฑ) โ leadingActions๋ก ์์ ๋กญ๊ฒ
|
|
336
|
+
3) ๋ณต์์ ํ ์ฒดํฌ๋ฐ์ค โ ์ด๊ฑด ๋ณ๋ ์ปดํฌ๋ํธ ๋ชซ(๋จ์ผ Select๋ ์ฌ๊ธฐ ์์)
|
|
337
|
+
์ ํ ํ์๋ ์์ดํ
์์ checkmark๋ฅผ ์น์ง ์๊ณ , ๋ฐฐ๊ฒฝ ํ์ด๋ผ์ดํธ๋ก๋ง ๋ํ๋ธ๋ค.
|
|
338
|
+
Radix๊ฐ ์ ํ๋ Item์ data-state="checked"๋ฅผ ๋ถ์ฌ โ asChild๋ก MenuItem ๋ฃจํธ์
|
|
339
|
+
์ ํ๋์ด MenuItem.module.css์ .root[data-state="checked"] ๊ท์น์ด ๋ฐฐ๊ฒฝ์ ๊ทธ๋ฆฐ๋ค. */
|
|
340
|
+
|
|
341
|
+
export interface ItemProps
|
|
342
|
+
extends Omit<ComponentPropsWithoutRef<typeof RS.Item>, "asChild" | "children"> {
|
|
343
|
+
leadingActions?: MenuItemAction[];
|
|
344
|
+
trailingActions?: MenuItemAction[];
|
|
345
|
+
children?: ReactNode;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
const Item = forwardRef<HTMLDivElement, ItemProps>(function SelectItem(
|
|
349
|
+
{ leadingActions, trailingActions, children, disabled, ...rest },
|
|
350
|
+
ref
|
|
351
|
+
) {
|
|
352
|
+
const size = menuSizeFor[useSelectSize()];
|
|
353
|
+
|
|
354
|
+
return (
|
|
355
|
+
<RS.Item asChild disabled={disabled} {...rest}>
|
|
356
|
+
<MenuItem
|
|
357
|
+
ref={ref}
|
|
358
|
+
size={size}
|
|
359
|
+
leadingActions={leadingActions}
|
|
360
|
+
trailingActions={trailingActions}
|
|
361
|
+
disabled={disabled}
|
|
362
|
+
/* role์ asChild ๋ณํฉ์์ ์์(MenuItem)์ด ์ฐ์ โ ๋ช
์์ ์ผ๋ก "option"์ ๋๊ฒจ
|
|
363
|
+
Radix Select.Item์ role="option"์ ์ด์ด๋ฐ๊ฒ ํ๋ค. ์ด role์ MenuItem CSS์
|
|
364
|
+
.root[role="option"][data-state="checked"] ๊ท์น์ด ์ ํ ์ํ ๋ฐฐ๊ฒฝ์ ๊ทธ๋ฆฌ๋
|
|
365
|
+
์ค์ฝํ ์
๋ ํฐ๋ก๋ ์ฐ์ธ๋ค. */
|
|
366
|
+
role="option"
|
|
367
|
+
>
|
|
368
|
+
<RS.ItemText>{children}</RS.ItemText>
|
|
369
|
+
</MenuItem>
|
|
370
|
+
</RS.Item>
|
|
371
|
+
);
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
/* Group ยท Label ยท Separator โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ */
|
|
375
|
+
|
|
376
|
+
const Group = RS.Group;
|
|
377
|
+
|
|
378
|
+
const Label = forwardRef<HTMLDivElement, ComponentPropsWithoutRef<typeof RS.Label>>(
|
|
379
|
+
function SelectLabel({ className, children, ...rest }, ref) {
|
|
380
|
+
const size = menuSizeFor[useSelectSize()];
|
|
381
|
+
return (
|
|
382
|
+
<RS.Label ref={ref} asChild {...rest}>
|
|
383
|
+
<MenuItem variant="section" size={size} className={className}>
|
|
384
|
+
{children}
|
|
385
|
+
</MenuItem>
|
|
386
|
+
</RS.Label>
|
|
387
|
+
);
|
|
388
|
+
}
|
|
389
|
+
);
|
|
390
|
+
|
|
391
|
+
const Separator = forwardRef<
|
|
392
|
+
HTMLDivElement,
|
|
393
|
+
ComponentPropsWithoutRef<typeof RS.Separator>
|
|
394
|
+
>(function SelectSeparator({ className, ...rest }, ref) {
|
|
395
|
+
return (
|
|
396
|
+
<RS.Separator
|
|
397
|
+
ref={ref}
|
|
398
|
+
className={[styles.separator, className ?? ""].filter(Boolean).join(" ")}
|
|
399
|
+
{...rest}
|
|
400
|
+
/>
|
|
401
|
+
);
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
/* Compound export โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ */
|
|
405
|
+
|
|
406
|
+
type SelectComponent = typeof Root & {
|
|
407
|
+
Trigger: typeof Trigger;
|
|
408
|
+
Value: typeof Value;
|
|
409
|
+
Content: typeof Content;
|
|
410
|
+
Item: typeof Item;
|
|
411
|
+
Group: typeof Group;
|
|
412
|
+
Label: typeof Label;
|
|
413
|
+
Separator: typeof Separator;
|
|
414
|
+
};
|
|
415
|
+
|
|
416
|
+
const Select = Root as SelectComponent;
|
|
417
|
+
Select.Trigger = Trigger;
|
|
418
|
+
Select.Value = Value;
|
|
419
|
+
Select.Content = Content;
|
|
420
|
+
Select.Item = Item;
|
|
421
|
+
Select.Group = Group;
|
|
422
|
+
Select.Label = Label;
|
|
423
|
+
Select.Separator = Separator;
|
|
424
|
+
|
|
425
|
+
export { Select };
|