@conscience-technology/ovenn 0.6.7 → 0.7.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/assets/components/AIMessage/AIMessage.module.css +2 -1
- package/assets/components/Accordion/Accordion.module.css +3 -0
- package/assets/components/AppFrame/AppFrame.module.css +2 -0
- package/assets/components/AttachmentItem/AttachmentItem.module.css +9 -3
- package/assets/components/AttachmentThumb/AttachmentThumb.module.css +4 -0
- package/assets/components/Avatar/Avatar.module.css +26 -11
- package/assets/components/Avatar/Avatar.tsx +1 -1
- package/assets/components/AvatarUpload/AvatarUpload.module.css +4 -3
- package/assets/components/Badge/Badge.module.css +96 -70
- package/assets/components/Badge/Badge.tsx +33 -25
- package/assets/components/Breadcrumb/Breadcrumb.module.css +8 -4
- package/assets/components/Breadcrumb/Breadcrumb.tsx +1 -1
- package/assets/components/Bubble/Bubble.module.css +6 -0
- package/assets/components/Button/Button.module.css +6 -0
- package/assets/components/Calendar/Calendar.module.css +244 -0
- package/assets/components/Calendar/Calendar.tsx +419 -0
- package/assets/components/Calendar/index.ts +2 -0
- package/assets/components/Callout/Callout.module.css +1 -0
- package/assets/components/Canvas/Canvas.module.css +75 -0
- package/assets/components/Canvas/Canvas.tsx +699 -0
- package/assets/components/Canvas/alignment.ts +34 -0
- package/assets/components/Canvas/clipboard.ts +30 -0
- package/assets/components/Canvas/collision.ts +67 -0
- package/assets/components/Canvas/edgeOptions.ts +11 -0
- package/assets/components/Canvas/graph.ts +11 -0
- package/assets/components/Canvas/history.ts +41 -0
- package/assets/components/Canvas/index.ts +4 -0
- package/assets/components/Canvas/selection.ts +56 -0
- package/assets/components/Canvas/tokens.css +61 -0
- package/assets/components/Canvas/types.ts +27 -0
- package/assets/components/Canvas/useCanvasSettlement.ts +79 -0
- package/assets/components/CanvasEdge/CanvasEdge.module.css +62 -0
- package/assets/components/CanvasEdge/CanvasEdge.tsx +121 -0
- package/assets/components/CanvasEdge/geometry.ts +350 -0
- package/assets/components/CanvasEdge/index.ts +4 -0
- package/assets/components/CanvasEdge/interactions.ts +14 -0
- package/assets/components/CanvasEdge/tokens.css +29 -0
- package/assets/components/CanvasNode/CanvasNode.module.css +234 -30
- package/assets/components/CanvasNode/CanvasNode.tsx +95 -28
- package/assets/components/CanvasNode/index.ts +1 -1
- package/assets/components/CanvasNode/runningOutline.ts +59 -0
- package/assets/components/CanvasNode/tokens.css +76 -13
- package/assets/components/Card/Card.module.css +5 -0
- package/assets/components/Chart/Chart.module.css +278 -0
- package/assets/components/Chart/Chart.tsx +385 -0
- package/assets/components/Chart/entrance.tsx +57 -0
- package/assets/components/Chart/index.ts +14 -0
- package/assets/components/ChatInput/ChatInput.module.css +5 -0
- package/assets/components/Checkbox/Checkbox.module.css +39 -0
- package/assets/components/Checkbox/Checkbox.tsx +99 -14
- package/assets/components/Checkbox/index.ts +1 -1
- package/assets/components/CheckboxCard/CheckboxCard.module.css +1 -177
- package/assets/components/CheckboxCard/CheckboxCard.tsx +6 -72
- package/assets/components/Chip/Chip.module.css +20 -30
- package/assets/components/Code/Code.module.css +1 -0
- package/assets/components/CodeBlock/CodeBlock.module.css +7 -3
- package/assets/components/ColorArea/ColorArea.module.css +3 -0
- package/assets/components/ColorField/ColorField.module.css +6 -0
- package/assets/components/ColorField/ColorField.tsx +3 -1
- package/assets/components/ColorPicker/ColorPicker.module.css +310 -0
- package/assets/components/ColorPicker/ColorPicker.tsx +387 -0
- package/assets/components/ColorPicker/index.ts +16 -0
- package/assets/components/ColorSlider/ColorSlider.module.css +15 -12
- package/assets/components/ColorSlider/ColorSlider.tsx +3 -3
- package/assets/components/ColorSwatch/ColorSwatch.module.css +2 -2
- package/assets/components/ColorSwatchPicker/ColorSwatchPicker.module.css +4 -3
- package/assets/components/Combobox/Combobox.module.css +1 -1
- package/assets/components/Combobox/Combobox.tsx +1 -1
- package/assets/components/CommandPalette/CommandPalette.module.css +18 -23
- package/assets/components/CommandPalette/CommandPalette.tsx +7 -5
- package/assets/components/Comment/Comment.module.css +25 -0
- package/assets/components/Comment/Comment.tsx +44 -0
- package/assets/components/Comment/CommentComposer.module.css +26 -0
- package/assets/components/Comment/CommentComposer.tsx +56 -0
- package/assets/components/Comment/CommentEditor.module.css +8 -0
- package/assets/components/Comment/CommentEditor.tsx +43 -0
- package/assets/components/Comment/CommentMentionInput.module.css +9 -0
- package/assets/components/Comment/CommentMentionInput.tsx +150 -0
- package/assets/components/Comment/index.ts +9 -0
- package/assets/components/Comment/types.ts +1 -0
- package/assets/components/ContextMenu/ContextMenu.module.css +5 -2
- package/assets/components/ContextMenu/ContextMenu.tsx +5 -0
- package/assets/components/ControlGroup/ControlGroup.module.css +7 -1
- package/assets/components/DataTable/DataTable.module.css +2 -0
- package/assets/components/DatePicker/DatePicker.module.css +36 -3
- package/assets/components/DatePicker/DatePicker.tsx +11 -1
- package/assets/components/DatePicker/TimeSelector.tsx +1 -1
- package/assets/components/Disclosure/Disclosure.module.css +1 -0
- package/assets/components/Drawer/Drawer.module.css +11 -4
- package/assets/components/Drawer/Drawer.tsx +5 -1
- package/assets/components/DropdownMenu/DropdownMenu.tsx +5 -0
- package/assets/components/EventChip/EventChip.module.css +120 -53
- package/assets/components/EventChip/EventChip.tsx +54 -6
- package/assets/components/EventChip/index.ts +1 -1
- package/assets/components/EventListItem/EventListItem.module.css +3 -0
- package/assets/components/EventListItem/EventListItem.tsx +15 -8
- package/assets/components/FileIcon/FileIcon.module.css +2 -0
- package/assets/components/FileUpload/FileUpload.module.css +10 -3
- package/assets/components/FileUpload/FileUpload.tsx +5 -9
- package/assets/components/FileUpload/FileUploadItem.tsx +34 -0
- package/assets/components/GalleryItem/GalleryItem.module.css +16 -19
- package/assets/components/GeneratedImage/GeneratedImage.module.css +2 -0
- package/assets/components/Icon/Icon.tsx +264 -1088
- package/assets/components/Icon/LucideFamilyIcon.tsx +434 -0
- package/assets/components/Icon/MissingIcon.tsx +25 -0
- package/assets/components/Icon/SolarFamilyIcon.tsx +439 -0
- package/assets/components/Icon/catalogNames.ts +8 -0
- package/assets/components/Icon/context.tsx +1 -1
- package/assets/components/Icon/index.ts +2 -0
- package/assets/components/Icon/lucideCatalog.ts +11358 -0
- package/assets/components/Icon/phosphorCatalog.ts +3052 -0
- package/assets/components/Icon/solarCatalog.ts +16064 -0
- package/assets/components/IconButton/IconButton.module.css +3 -2
- package/assets/components/Input/Input.module.css +30 -12
- package/assets/components/Input/Input.tsx +1 -1
- package/assets/components/Kanban/Kanban.module.css +6 -0
- package/assets/components/ListItem/ListItem.module.css +9 -6
- package/assets/components/MenuItem/MenuItem.module.css +24 -22
- package/assets/components/MenuItem/MenuItem.tsx +12 -12
- package/assets/components/MessageActions/MessageActions.module.css +36 -0
- package/assets/components/MessageActions/MessageActions.tsx +53 -28
- package/assets/components/MessageQuote/MessageQuote.module.css +1 -0
- package/assets/components/MessageSources/MessageSources.module.css +2 -0
- package/assets/components/MessageState/MessageState.module.css +1 -1
- package/assets/components/MetricCard/MetricCard.module.css +96 -108
- package/assets/components/MetricCard/MetricCard.tsx +45 -23
- package/assets/components/MetricCard/tokens.css +10 -0
- package/assets/components/MiniCalendar/MiniCalendar.module.css +130 -0
- package/assets/components/MiniCalendar/MiniCalendar.tsx +161 -0
- package/assets/components/MiniCalendar/index.ts +2 -0
- package/assets/components/Modal/Modal.module.css +13 -4
- package/assets/components/Modal/Modal.tsx +4 -0
- package/assets/components/Onboarding/LayoutBuilder.tsx +12 -50
- package/assets/components/Onboarding/Onboarding.module.css +211 -278
- package/assets/components/Onboarding/OnboardingAxisPanel.tsx +81 -125
- package/assets/components/Onboarding/OnboardingPage.tsx +244 -467
- package/assets/components/Onboarding/actions.ts +5 -0
- package/assets/components/Onboarding/palette.css +8 -0
- package/assets/components/Onboarding/wizardData.ts +8 -8
- package/assets/components/ProgressBar/ProgressBar.module.css +8 -8
- package/assets/components/ProgressBar/ProgressBar.tsx +0 -5
- package/assets/components/ProgressBar/index.ts +0 -1
- package/assets/components/QuotationBar/QuotationBar.module.css +2 -0
- package/assets/components/Radio/Radio.module.css +2 -0
- package/assets/components/RadioCard/RadioCard.module.css +78 -3
- package/assets/components/RadioCard/RadioCard.tsx +34 -12
- package/assets/components/RadioCard/index.ts +1 -1
- package/assets/components/SegmentedChart/SegmentedChart.module.css +16 -0
- package/assets/components/SegmentedChart/SegmentedChart.tsx +25 -8
- package/assets/components/Select/Select.tsx +7 -4
- package/assets/components/Shortcut/Shortcut.module.css +2 -0
- package/assets/components/Sidebar/Sidebar.module.css +1 -0
- package/assets/components/Sidebar/Sidebar.tsx +2 -2
- package/assets/components/Skeleton/Skeleton.module.css +33 -0
- package/assets/components/Skeleton/Skeleton.tsx +20 -0
- package/assets/components/Skeleton/index.ts +2 -0
- package/assets/components/Skeleton/tokens.css +11 -0
- package/assets/components/Slider/Slider.module.css +3 -0
- package/assets/components/Slider/Slider.tsx +7 -2
- package/assets/components/Spinner/LottiePlayer.tsx +4 -4
- package/assets/components/Spinner/Spinner.module.css +3 -0
- package/assets/components/Spinner/lottieManifest.ts +3 -0
- package/assets/components/Stepper/Stepper.module.css +56 -8
- package/assets/components/Stepper/Stepper.tsx +13 -4
- package/assets/components/Switch/Switch.module.css +55 -42
- package/assets/components/Switch/Switch.tsx +6 -2
- package/assets/components/Switch/index.ts +1 -1
- package/assets/components/TabStrip/TabStrip.module.css +5 -1
- package/assets/components/TableCell/TableCell.module.css +8 -1
- package/assets/components/TableCell/TableCellBadge.tsx +7 -3
- package/assets/components/TableCell/TableCellImage.tsx +1 -1
- package/assets/components/TableCell/TableCellTag.tsx +23 -0
- package/assets/components/TableCell/index.ts +3 -0
- package/assets/components/TableHeader/TableHeader.module.css +4 -0
- package/assets/components/TableRow/TableRow.module.css +3 -0
- package/assets/components/TableRowEdit/TableRowEdit.module.css +2 -0
- package/assets/components/TableToolbar/TableToolbar.module.css +1 -0
- package/assets/components/Tabs/Tabs.module.css +22 -7
- package/assets/components/Tabs/Tabs.tsx +2 -1
- package/assets/components/Tag/Tag.module.css +101 -0
- package/assets/components/Tag/Tag.tsx +55 -0
- package/assets/components/Tag/index.ts +2 -0
- package/assets/components/TemplateBoundary/TemplateBoundary.tsx +22 -18
- package/assets/components/TemplateBoundary/types.ts +2 -0
- package/assets/components/Textarea/Textarea.module.css +7 -0
- package/assets/components/ThemeController.tsx +30 -3
- package/assets/components/TimePicker/TimePicker.module.css +1 -0
- package/assets/components/TimePicker/TimePicker.tsx +37 -16
- package/assets/components/TimelineView/TimelineEventBar.tsx +109 -0
- package/assets/components/TimelineView/TimelineView.module.css +203 -0
- package/assets/components/TimelineView/TimelineView.tsx +137 -0
- package/assets/components/TimelineView/axis.ts +62 -0
- package/assets/components/TimelineView/index.ts +3 -0
- package/assets/components/TimelineView/layout.ts +56 -0
- package/assets/components/TimelineView/move.ts +51 -0
- package/assets/components/TimelineView/useTimelineDrag.ts +215 -0
- package/assets/components/TimelineView/useTimelineZoom.ts +92 -0
- package/assets/components/Toast/Toast.module.css +2 -0
- package/assets/components/Toolbar/Toolbar.module.css +31 -24
- package/assets/components/Toolbar/Toolbar.tsx +4 -3
- package/assets/components/Tooltip/Tooltip.module.css +10 -0
- package/assets/components/Tooltip/Tooltip.tsx +17 -8
- package/assets/components/TopLoader/TopLoader.module.css +1 -0
- package/assets/components/TreeNav/TreeNav.module.css +1 -0
- package/assets/components/_color.ts +2 -2
- package/assets/components/_data.ts +33 -32
- package/assets/components/_utils.css +5 -0
- package/assets/components/axisOptions.ts +2 -0
- package/assets/components/component-registry.json +151 -2
- package/assets/components/index.ts +16 -0
- package/assets/components/materialScope.tsx +11 -0
- package/assets/components/reset.css +1 -0
- package/assets/components/themeBootScript.ts +3 -2
- package/assets/components/tokens.css +225 -71
- package/assets/components/useChartEntrance.ts +119 -0
- package/assets/prompts/ASSEMBLY.md +9 -7
- package/assets/prompts/CATALOG.md +18 -4
- package/assets/prompts/FEEDBACK_PROCESS.md +19 -0
- package/assets/prompts/PRINCIPLES.md +14 -0
- package/assets/prompts/WORKFLOW_DESIGN.md +46 -70
- package/assets/prompts/axes/font.md +6 -1
- package/assets/prompts/axes/icon.md +6 -4
- package/assets/prompts/axes/material.md +40 -0
- package/assets/prompts/axes/palette.md +2 -1
- package/assets/prompts/axes/shape.md +8 -0
- package/assets/prompts/components/attachment-item.md +2 -1
- package/assets/prompts/components/badge.md +32 -97
- package/assets/prompts/components/breadcrumb.md +1 -0
- package/assets/prompts/components/calendar.md +151 -0
- package/assets/prompts/components/canvas-edge.md +67 -0
- package/assets/prompts/components/canvas-node.md +25 -8
- package/assets/prompts/components/canvas.md +82 -0
- package/assets/prompts/components/card.md +10 -10
- package/assets/prompts/components/chart-bar.md +77 -0
- package/assets/prompts/components/chart-pie.md +63 -0
- package/assets/prompts/components/chart-radar.md +56 -0
- package/assets/prompts/components/chart-radial.md +56 -0
- package/assets/prompts/components/chart.md +129 -0
- package/assets/prompts/components/checkbox-card.md +26 -45
- package/assets/prompts/components/checkbox.md +23 -0
- package/assets/prompts/components/chip.md +6 -6
- package/assets/prompts/components/code-block.md +1 -0
- package/assets/prompts/components/color-picker.md +173 -0
- package/assets/prompts/components/color-slider.md +7 -7
- package/assets/prompts/components/command-palette.md +7 -6
- package/assets/prompts/components/comment.md +72 -0
- package/assets/prompts/components/context-menu.md +6 -3
- package/assets/prompts/components/data-table.md +9 -0
- package/assets/prompts/components/date-picker.md +10 -0
- package/assets/prompts/components/drawer.md +10 -0
- package/assets/prompts/components/dropdown-menu.md +3 -1
- package/assets/prompts/components/event-chip.md +60 -18
- package/assets/prompts/components/event-list-item.md +14 -10
- package/assets/prompts/components/file-upload.md +1 -1
- package/assets/prompts/components/gallery-item.md +5 -4
- package/assets/prompts/components/icon.md +30 -8
- package/assets/prompts/components/kanban.md +1 -1
- package/assets/prompts/components/list-item.md +11 -2
- package/assets/prompts/components/menu-item.md +8 -3
- package/assets/prompts/components/message-actions.md +9 -0
- package/assets/prompts/components/metric-card.md +57 -109
- package/assets/prompts/components/mini-calendar.md +72 -0
- package/assets/prompts/components/modal.md +1 -0
- package/assets/prompts/components/onboarding.md +11 -7
- package/assets/prompts/components/page-header.md +11 -2
- package/assets/prompts/components/progress-bar.md +12 -2
- package/assets/prompts/components/radio-card.md +33 -117
- package/assets/prompts/components/segmented-chart.md +19 -5
- package/assets/prompts/components/select.md +1 -0
- package/assets/prompts/components/sidebar.md +12 -3
- package/assets/prompts/components/skeleton.md +44 -0
- package/assets/prompts/components/stepper.md +15 -1
- package/assets/prompts/components/switch.md +15 -10
- package/assets/prompts/components/tab-strip.md +1 -0
- package/assets/prompts/components/table-cell.md +6 -4
- package/assets/prompts/components/table-row.md +12 -3
- package/assets/prompts/components/table-toolbar.md +9 -0
- package/assets/prompts/components/tabs.md +4 -2
- package/assets/prompts/components/tag.md +54 -0
- package/assets/prompts/components/time-picker.md +1 -0
- package/assets/prompts/components/timeline-view.md +129 -0
- package/assets/prompts/components/toast.md +1 -1
- package/assets/prompts/components/toolbar.md +17 -4
- package/assets/prompts/components/tooltip.md +21 -3
- package/assets/prompts/components/top-loader.md +1 -1
- package/assets/prompts/components/topbar.md +9 -0
- package/assets/prompts/components/tree-nav.md +1 -1
- package/assets/prompts/templates/ains.md +2 -1
- package/assets/prompts/templates/aurora.md +5 -4
- package/assets/prompts/templates/glass-button.md +6 -5
- package/assets/prompts/templates/minimal.md +8 -6
- package/assets/prompts/templates/workspace.md +3 -3
- package/assets/prompts/tokens/color.md +4 -2
- package/assets/prompts/tokens/material.md +51 -0
- package/assets/prompts/tokens/radius.md +12 -0
- package/assets/prompts/tokens/typography.md +24 -2
- package/assets/prompts/use-cases/chart-chart-area.md +1334 -0
- package/assets/prompts/use-cases/chart-chart-bar.md +1886 -0
- package/assets/prompts/use-cases/chart-chart-pie.md +1031 -0
- package/assets/prompts/use-cases/chart-chart-radar.md +785 -0
- package/assets/prompts/use-cases/chart-chart-radial.md +988 -0
- package/assets/prompts/use-cases/chart-segmented-chart.md +262 -0
- package/assets/prompts/use-cases/data-comment.md +360 -0
- package/assets/prompts/use-cases/data-data-table.md +249 -0
- package/assets/prompts/use-cases/data-list-item.md +1056 -0
- package/assets/prompts/use-cases/data-metric-card.md +673 -0
- package/assets/prompts/use-cases/data-table-row.md +966 -0
- package/assets/prompts/use-cases/data-table-toolbar.md +481 -0
- package/assets/prompts/use-cases/feedback-drawer.md +1163 -0
- package/assets/prompts/use-cases/feedback-progress-bar.md +427 -0
- package/assets/prompts/use-cases/general-toolbar.md +854 -0
- package/assets/prompts/use-cases/general-tooltip.md +652 -0
- package/assets/prompts/use-cases/input-checkbox.md +443 -0
- package/assets/prompts/use-cases/structure-card.md +603 -0
- package/assets/prompts/use-cases/structure-page-header.md +755 -0
- package/assets/prompts/use-cases/structure-sidebar.md +1132 -0
- package/assets/prompts/use-cases/structure-topbar.md +1200 -0
- package/assets/public/ovenn-wordmark.svg +19 -0
- package/package.json +6 -2
- package/src/commands/info.js +1 -1
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
/* ColorPicker — RAC ColorPicker + Popover 어댑터.
|
|
2
|
+
|
|
3
|
+
Anatomy (DatePicker 톤 참고 체계적 조립)
|
|
4
|
+
─ .trigger : 자유 slot. 기본은 투명 button — 사용자가 Button·Input·Swatch 자유 조립.
|
|
5
|
+
─ .popover : 고정 폭 overlay 쉘. 내부는 100% 폭 — SwatchPicker가 넓어져도 레이아웃 안 흔들림.
|
|
6
|
+
─ .dialog : popover 안쪽 세로 flex (section/divider 쌓임).
|
|
7
|
+
─ .section : 논리 그룹 — label(선택) + body. padding은 section이 담당.
|
|
8
|
+
─ .divider : section 사이 hairline.
|
|
9
|
+
|
|
10
|
+
Popover 폭 정책 — ColorArea의 lg 토큰 + 안쪽 여백, 좁은 화면에 반응.
|
|
11
|
+
SwatchPicker 등 가변 자식은 section 안에서 100% 폭(wrap)으로 자동 수용.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/* ── Trigger ─ 투명 쉘 (사용자가 자유 조립) */
|
|
15
|
+
.trigger:where(:not([data-slot="button-root"], [data-appearance="input"])) {
|
|
16
|
+
display: inline-flex;
|
|
17
|
+
align-items: center;
|
|
18
|
+
gap: var(--space-2);
|
|
19
|
+
padding: 0;
|
|
20
|
+
background: transparent;
|
|
21
|
+
border: 0;
|
|
22
|
+
color: inherit;
|
|
23
|
+
font-family: inherit;
|
|
24
|
+
cursor: pointer;
|
|
25
|
+
corner-shape: var(--corner-shape);
|
|
26
|
+
border-radius: var(--radius-sm);
|
|
27
|
+
transition: var(--transition-ring);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.trigger[data-focus-visible] {
|
|
31
|
+
outline: none;
|
|
32
|
+
box-shadow: var(--ring-shadow-action);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.trigger[data-disabled] {
|
|
36
|
+
cursor: not-allowed;
|
|
37
|
+
opacity: 0.5;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/* ── Popover ─ 고정 폭 overlay 쉘.
|
|
41
|
+
RAC Popover는 inline style로 `height: var(--trigger-anchor-available-height)` 같은 높이 변수를
|
|
42
|
+
꽂을 수 있음 — overlay가 viewport 하단까지 뻗는 사고 방지하려면 명시적으로 height:auto. */
|
|
43
|
+
.popover {
|
|
44
|
+
--material-floating-bg: var(--material-glass-enabled) var(--surface-glass-picker-bg);
|
|
45
|
+
--material-floating-filter: var(--material-glass-enabled) blur(var(--surface-glass-picker-blur));
|
|
46
|
+
--material-border: var(--material-glass-enabled) var(--surface-glass-picker-border);
|
|
47
|
+
--picker-width: 288px; /* lint-hardcoded: ignore */
|
|
48
|
+
--picker-viewport-edge: 12px; /* lint-hardcoded: ignore */
|
|
49
|
+
--picker-inset: var(--space-3);
|
|
50
|
+
--picker-radius: var(--radius-lg);
|
|
51
|
+
--picker-plane-radius: var(--radius-md);
|
|
52
|
+
--picker-plane-ratio: 1.91;
|
|
53
|
+
--picker-gap: var(--space-3);
|
|
54
|
+
--picker-format-width: calc(var(--size-2) * 10);
|
|
55
|
+
--picker-alpha-width: calc(var(--size-2) * 9);
|
|
56
|
+
--picker-field-gap: var(--space-2);
|
|
57
|
+
--picker-font-size: var(--text-sm);
|
|
58
|
+
--picker-track-height: var(--size-2);
|
|
59
|
+
--picker-thumb-size: var(--size-4);
|
|
60
|
+
--picker-plane-clamp-size: max(var(--size-5), calc(var(--picker-plane-radius) * 1.5));
|
|
61
|
+
--picker-thumb-ring: calc(var(--hairline) * 2);
|
|
62
|
+
--picker-swatch-size: var(--size-4);
|
|
63
|
+
--picker-swatch-radius: min(var(--radius-xs), 25%);
|
|
64
|
+
--picker-swatch-row-gap: 0px;
|
|
65
|
+
--picker-control-border: var(--material-border, color-mix(in oklab, var(--fg) 10%, var(--bg)));
|
|
66
|
+
width: var(--picker-width);
|
|
67
|
+
max-width: calc(100vw - var(--size-4) * 2);
|
|
68
|
+
height: auto;
|
|
69
|
+
background: var(--material-floating-bg, var(--bg));
|
|
70
|
+
border: var(--hairline) solid var(--material-border, var(--picker-control-border));
|
|
71
|
+
corner-shape: var(--corner-shape);
|
|
72
|
+
border-radius: var(--picker-radius);
|
|
73
|
+
box-shadow: var(--shadow-sm);
|
|
74
|
+
/* Nested menus escape the surface; only scrollBody clips long content. */
|
|
75
|
+
overflow: visible;
|
|
76
|
+
outline: none;
|
|
77
|
+
backdrop-filter: var(--material-floating-filter, none);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.popover[data-entering] {
|
|
81
|
+
animation: colorPickerEnter var(--duration-base) var(--ease-emphasized);
|
|
82
|
+
}
|
|
83
|
+
.popover[data-exiting] {
|
|
84
|
+
animation: colorPickerEnter var(--duration-fast) var(--ease-out) reverse;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
@keyframes colorPickerEnter {
|
|
88
|
+
from { opacity: 0; transform: translateY(calc(var(--size-1) * -1)) scale(0.98); }
|
|
89
|
+
to { opacity: 1; transform: translateY(0) scale(1); }
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/* ── Dialog ─ 세로 쌓임 (section + divider) */
|
|
93
|
+
.dialog {
|
|
94
|
+
display: flex;
|
|
95
|
+
flex-direction: column;
|
|
96
|
+
outline: none;
|
|
97
|
+
max-height: inherit;
|
|
98
|
+
border-radius: inherit;
|
|
99
|
+
min-height: 0;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.scrollBody {
|
|
103
|
+
min-height: 0;
|
|
104
|
+
max-height: inherit;
|
|
105
|
+
overflow: auto;
|
|
106
|
+
scrollbar-width: thin;
|
|
107
|
+
border-radius: inherit;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/* ── Section ─ 논리 그룹 */
|
|
111
|
+
.section {
|
|
112
|
+
display: flex;
|
|
113
|
+
flex-direction: column;
|
|
114
|
+
gap: var(--space-2);
|
|
115
|
+
padding: var(--space-4);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.sectionLabel {
|
|
119
|
+
font-size: var(--text-sm);
|
|
120
|
+
font-weight: var(--font-weight-regular);
|
|
121
|
+
color: var(--fg);
|
|
122
|
+
line-height: var(--lh-sm);
|
|
123
|
+
letter-spacing: var(--tracking-normal);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/* Section body — 자식이 width 100%로 채워져도 부모 폭을 넘지 않도록. */
|
|
127
|
+
.sectionBody {
|
|
128
|
+
display: flex;
|
|
129
|
+
flex-direction: column;
|
|
130
|
+
gap: var(--space-2);
|
|
131
|
+
min-width: 0;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/* 내부 자식 전부 popover 폭에 자동 맞춤. */
|
|
135
|
+
.sectionBody > * {
|
|
136
|
+
width: 100%;
|
|
137
|
+
max-width: 100%;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/* ColorArea만 — 평면이니 100% 폭 + 정사각 유지. (data-size는 Swatch에도 있어서 selector 좁힘) */
|
|
141
|
+
.sectionBody > [data-slot="color-area"] {
|
|
142
|
+
display: block;
|
|
143
|
+
width: 100%;
|
|
144
|
+
height: auto;
|
|
145
|
+
aspect-ratio: 1 / 1;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/* ── Divider ─ section 사이 hairline */
|
|
149
|
+
.divider {
|
|
150
|
+
height: var(--hairline);
|
|
151
|
+
background: var(--material-border, var(--border));
|
|
152
|
+
flex: 0 0 auto;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
@media (prefers-reduced-motion: reduce) {
|
|
156
|
+
.popover[data-entering],
|
|
157
|
+
.popover[data-exiting] {
|
|
158
|
+
animation: none;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
.popover:has(.editor) {
|
|
164
|
+
max-height: calc(100dvh - var(--picker-viewport-edge) * 2) !important;
|
|
165
|
+
overflow: visible;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.editor {
|
|
169
|
+
display: flex;
|
|
170
|
+
flex-direction: column;
|
|
171
|
+
min-width: 0;
|
|
172
|
+
padding: var(--picker-inset);
|
|
173
|
+
padding-bottom: var(--picker-inset);
|
|
174
|
+
gap: var(--picker-gap);
|
|
175
|
+
color: var(--fg);
|
|
176
|
+
font-family: var(--font-sans);
|
|
177
|
+
}
|
|
178
|
+
.editor > * { flex-shrink: 0; }
|
|
179
|
+
.editor > [data-slot="color-area"] {
|
|
180
|
+
width: 100%;
|
|
181
|
+
height: auto;
|
|
182
|
+
aspect-ratio: var(--picker-plane-ratio);
|
|
183
|
+
corner-shape: var(--corner-shape);
|
|
184
|
+
border-radius: var(--picker-plane-radius);
|
|
185
|
+
box-shadow: none;
|
|
186
|
+
--_thumb-size: var(--picker-plane-clamp-size);
|
|
187
|
+
--_thumb-ring: var(--picker-thumb-ring);
|
|
188
|
+
}
|
|
189
|
+
.editor > [data-slot="color-area"] > [role="presentation"] {
|
|
190
|
+
width: var(--picker-thumb-size);
|
|
191
|
+
height: var(--picker-thumb-size);
|
|
192
|
+
}
|
|
193
|
+
.editorTitle { color: var(--fg-muted); font-size: var(--text-sm); }
|
|
194
|
+
.channelRow {
|
|
195
|
+
display: grid;
|
|
196
|
+
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
197
|
+
gap: var(--space-2);
|
|
198
|
+
}
|
|
199
|
+
.channelLabel { color: var(--fg-muted); }
|
|
200
|
+
.sliderRow {
|
|
201
|
+
display: flex;
|
|
202
|
+
align-items: center;
|
|
203
|
+
gap: var(--space-3);
|
|
204
|
+
position: relative;
|
|
205
|
+
}
|
|
206
|
+
.sliders {
|
|
207
|
+
display: flex;
|
|
208
|
+
flex-direction: column;
|
|
209
|
+
flex: 1;
|
|
210
|
+
min-width: 0;
|
|
211
|
+
gap: var(--space-3);
|
|
212
|
+
padding-inline-end: calc(var(--picker-thumb-size) / 2);
|
|
213
|
+
}
|
|
214
|
+
.sliders > * {
|
|
215
|
+
min-width: 0;
|
|
216
|
+
--_track-h: var(--picker-track-height);
|
|
217
|
+
--_thumb-size: var(--picker-thumb-size);
|
|
218
|
+
--_thumb-ring: var(--picker-thumb-ring);
|
|
219
|
+
}
|
|
220
|
+
.eyeDropper {
|
|
221
|
+
flex: 0 0 var(--control-h-sm);
|
|
222
|
+
width: var(--control-h-sm);
|
|
223
|
+
height: var(--control-h-sm);
|
|
224
|
+
color: var(--fg-muted);
|
|
225
|
+
}
|
|
226
|
+
.sliderRow .eyeDropper > svg { width: var(--icon-size-lg); height: var(--icon-size-lg); }
|
|
227
|
+
.valueRow {
|
|
228
|
+
display: grid;
|
|
229
|
+
grid-template-columns: var(--picker-format-width) minmax(0, 1fr);
|
|
230
|
+
gap: var(--picker-field-gap);
|
|
231
|
+
}
|
|
232
|
+
.valueGroup {
|
|
233
|
+
display: grid;
|
|
234
|
+
grid-template-columns: minmax(0, 1fr);
|
|
235
|
+
gap: var(--picker-field-gap);
|
|
236
|
+
min-width: 0;
|
|
237
|
+
}
|
|
238
|
+
.valueGroup[data-format="hex"] { grid-template-columns: minmax(0, 1fr) var(--picker-alpha-width); }
|
|
239
|
+
.valueGroup[data-format="channels"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
|
240
|
+
/* Keep format/alpha and their channel inputs in one compact control group. */
|
|
241
|
+
.valueRow + .valueGroup[data-format="channels"] {
|
|
242
|
+
margin-top: calc(var(--space-1) * -1);
|
|
243
|
+
}
|
|
244
|
+
.joinedField > div { padding-inline: var(--space-2); gap: 0; }
|
|
245
|
+
.joinedField input { flex: 1 1 0; width: 0; padding: 0; text-align: center; font-size: var(--picker-font-size); min-width: 0; }
|
|
246
|
+
.joinedField:has(input[type="text"]) { min-width: 0; }
|
|
247
|
+
.valueGroup[data-format="hex"] .joinedField:last-child input { text-align: end; }
|
|
248
|
+
.valueGroup[data-format="hex"] .joinedField:last-child > div { padding-inline: var(--space-2); gap: var(--space-1); }
|
|
249
|
+
.editorControls { display: flex; flex-direction: column; gap: var(--space-2); }
|
|
250
|
+
.valueRow + .editorControls,
|
|
251
|
+
.valueGroup + .editorControls { margin-top: calc(var(--space-1) * -1); }
|
|
252
|
+
.editor .presetGrid {
|
|
253
|
+
display: grid;
|
|
254
|
+
grid-template-columns: repeat(8, minmax(0, 1fr));
|
|
255
|
+
gap: var(--picker-swatch-row-gap) 0;
|
|
256
|
+
width: 100%;
|
|
257
|
+
}
|
|
258
|
+
.presetGrid .presetItem {
|
|
259
|
+
display: flex;
|
|
260
|
+
align-items: center;
|
|
261
|
+
justify-content: center;
|
|
262
|
+
width: 100%;
|
|
263
|
+
min-width: 0;
|
|
264
|
+
height: var(--control-h-sm);
|
|
265
|
+
border-radius: var(--picker-swatch-radius);
|
|
266
|
+
}
|
|
267
|
+
.presetGrid .presetItem .presetSwatch {
|
|
268
|
+
width: var(--picker-swatch-size);
|
|
269
|
+
height: var(--picker-swatch-size);
|
|
270
|
+
corner-shape: var(--corner-shape);
|
|
271
|
+
border-radius: var(--picker-swatch-radius);
|
|
272
|
+
}
|
|
273
|
+
.presetGrid .presetItem[data-selected] { box-shadow: none; background: var(--bg-subtle); }
|
|
274
|
+
.presetGrid .presetItem[data-focus-visible] { outline: none; box-shadow: inset 0 0 0 var(--hairline) var(--border-strong); }
|
|
275
|
+
.pickError {
|
|
276
|
+
position: absolute;
|
|
277
|
+
top: 100%;
|
|
278
|
+
inset-inline: 0;
|
|
279
|
+
z-index: var(--z-popover);
|
|
280
|
+
padding: var(--space-2);
|
|
281
|
+
border-radius: var(--radius-sm);
|
|
282
|
+
background: var(--bg);
|
|
283
|
+
color: var(--fg);
|
|
284
|
+
font-size: var(--text-xs);
|
|
285
|
+
box-shadow: var(--shadow-sm);
|
|
286
|
+
}
|
|
287
|
+
.inputTrigger { width: calc(var(--size-10) * 4); cursor: pointer; text-align: start; }
|
|
288
|
+
/* Trigger and nested swatch share the active Shape curve. */
|
|
289
|
+
.trigger { --color-swatch-corner-shape: var(--corner-shape); }
|
|
290
|
+
.trigger[data-radius="none"] { --color-swatch-radius: 0; }
|
|
291
|
+
.trigger[data-radius="sm"] { --color-swatch-radius: min(var(--radius-sm), 12.5%); }
|
|
292
|
+
.trigger[data-radius="md"] { --color-swatch-radius: min(var(--radius-md), 25%); }
|
|
293
|
+
.trigger[data-radius="lg"] { --color-swatch-radius: min(var(--radius-lg), 37.5%); }
|
|
294
|
+
.trigger[data-radius="full"] { --color-swatch-radius: var(--radius-full); }
|
|
295
|
+
.trigger[data-radius] { corner-shape: var(--corner-shape); border-radius: var(--color-swatch-radius); }
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
.popover[data-fit-viewport] {
|
|
299
|
+
--picker-viewport-top: auto;
|
|
300
|
+
--picker-viewport-left: auto;
|
|
301
|
+
position: fixed !important;
|
|
302
|
+
top: var(--picker-viewport-top) !important;
|
|
303
|
+
left: var(--picker-viewport-left) !important;
|
|
304
|
+
bottom: auto !important;
|
|
305
|
+
right: auto !important;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/* Opaque-only consumers share the editor without an opacity column. */
|
|
309
|
+
.valueGroup[data-format="hex"]:not([data-alpha]) { grid-template-columns: minmax(0, 1fr); }
|
|
310
|
+
.valueGroup[data-format="hex"]:not([data-alpha]) .joinedField input { text-align: start; }
|
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ColorPicker — react-aria-components ColorPicker 어댑터.
|
|
5
|
+
*
|
|
6
|
+
* 색 피커 전체 묶음의 상위 compound. Root가 value/onChange를 소유하고 자식들(ColorArea,
|
|
7
|
+
* ColorSlider, ColorField, ColorSwatch, ColorSwatchPicker)이 RAC context로 자동 바인딩.
|
|
8
|
+
*
|
|
9
|
+
* compound:
|
|
10
|
+
* `<ColorPicker>`
|
|
11
|
+
* `.Trigger` — 자유 slot (Button·Input·Swatch 등 사용자가 조립)
|
|
12
|
+
* `.Popover` — 고정 폭 overlay 쉘
|
|
13
|
+
* `.Section` + `.SectionLabel` + `.Divider` — DatePicker 톤의 체계적 조립
|
|
14
|
+
*
|
|
15
|
+
* API 핵심
|
|
16
|
+
* ─ value / defaultValue / onChange : Color
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { useMaterialScope } from "../materialScope";
|
|
20
|
+
import {
|
|
21
|
+
ColorPicker as AriaColorPicker,
|
|
22
|
+
DialogTrigger as AriaDialogTrigger,
|
|
23
|
+
Popover as AriaPopover,
|
|
24
|
+
Dialog as AriaDialog,
|
|
25
|
+
Button as AriaButton,
|
|
26
|
+
ColorPickerStateContext,
|
|
27
|
+
parseColor,
|
|
28
|
+
type ColorPickerProps as AriaColorPickerProps,
|
|
29
|
+
type PopoverProps as AriaPopoverProps,
|
|
30
|
+
type ButtonProps as AriaButtonProps,
|
|
31
|
+
} from "react-aria-components";
|
|
32
|
+
import { createContext, forwardRef, useContext, useState, useEffect, useLayoutEffect, useRef, type ReactNode } from "react";
|
|
33
|
+
import { ColorArea } from "../ColorArea";
|
|
34
|
+
import { ColorSlider } from "../ColorSlider";
|
|
35
|
+
import { ColorField } from "../ColorField";
|
|
36
|
+
import { ColorSwatch } from "../ColorSwatch";
|
|
37
|
+
import { ColorSwatchPicker } from "../ColorSwatchPicker";
|
|
38
|
+
import { IconButton } from "../IconButton";
|
|
39
|
+
import { Icon, useIconAxis } from "../Icon";
|
|
40
|
+
import { Select } from "../Select";
|
|
41
|
+
import inputStyles from "../Input/Input.module.css";
|
|
42
|
+
import styles from "./ColorPicker.module.css";
|
|
43
|
+
|
|
44
|
+
/* ────────────────── Root ────────────────── */
|
|
45
|
+
|
|
46
|
+
export type ColorPickerProps = AriaColorPickerProps & {
|
|
47
|
+
children?: ReactNode;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const ColorPickerRoot = ({ children, ...rest }: ColorPickerProps) => {
|
|
51
|
+
return (
|
|
52
|
+
<AriaColorPicker {...rest}>
|
|
53
|
+
<AriaDialogTrigger>{children}</AriaDialogTrigger>
|
|
54
|
+
</AriaColorPicker>
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/* ────────────────── Trigger ──────────────────
|
|
59
|
+
자유 slot. 기본 쉘은 투명·padding 없음 — 사용자가 Button·Input·Swatch 등 어떤 조합이든 넣을 수 있도록.
|
|
60
|
+
Trigger 자체는 RAC Button primitive라 접근성·키보드만 담당. */
|
|
61
|
+
|
|
62
|
+
export type ColorPickerTriggerRadius = "none" | "sm" | "md" | "lg" | "full";
|
|
63
|
+
export type ColorPickerTriggerProps = AriaButtonProps & {
|
|
64
|
+
/** Radius of the trigger and its color swatch. Omit to retain the child's shape. */
|
|
65
|
+
radius?: ColorPickerTriggerRadius;
|
|
66
|
+
/** Input-shaped button containing a swatch and color code. */
|
|
67
|
+
appearance?: "bare" | "input";
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const ColorPickerTrigger = forwardRef<HTMLButtonElement, ColorPickerTriggerProps>(
|
|
71
|
+
function ColorPickerTrigger({ className, children, radius, appearance = "bare", ...rest }, ref) {
|
|
72
|
+
const cls = [styles.trigger, appearance === "input" ? [inputStyles.root, inputStyles.outline, inputStyles.sizeMd, styles.inputTrigger].join(" ") : "", className ?? ""].filter(Boolean).join(" ");
|
|
73
|
+
return (
|
|
74
|
+
<AriaButton ref={ref} className={cls} data-radius={radius} data-appearance={appearance} {...rest}>
|
|
75
|
+
{children}
|
|
76
|
+
</AriaButton>
|
|
77
|
+
);
|
|
78
|
+
},
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
/* ────────────────── Popover ──────────────────
|
|
82
|
+
색상 영역과 입력부를 담는 반응형 폭. 내부 요소(Area·Slider·SwatchPicker)는 자동으로 100% 폭. */
|
|
83
|
+
|
|
84
|
+
export type ColorPickerPopoverProps = Omit<AriaPopoverProps, "children"> & {
|
|
85
|
+
children?: ReactNode;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const NestedSelectContext = createContext<{
|
|
89
|
+
onOpenChange: (open: boolean) => void;
|
|
90
|
+
container: HTMLDivElement | null;
|
|
91
|
+
}>({ onOpenChange: () => {}, container: null });
|
|
92
|
+
|
|
93
|
+
const ColorPickerPopover = ({
|
|
94
|
+
className,
|
|
95
|
+
children,
|
|
96
|
+
placement = "bottom start",
|
|
97
|
+
isKeyboardDismissDisabled,
|
|
98
|
+
shouldCloseOnInteractOutside,
|
|
99
|
+
...rest
|
|
100
|
+
}: ColorPickerPopoverProps) => {
|
|
101
|
+
const materialScope = useMaterialScope();
|
|
102
|
+
const [nestedSelectOpen, setNestedSelectOpen] = useState(false);
|
|
103
|
+
const nestedCloseFrame = useRef<number | null>(null);
|
|
104
|
+
const handleNestedSelectOpen = (open: boolean) => {
|
|
105
|
+
if (nestedCloseFrame.current !== null) cancelAnimationFrame(nestedCloseFrame.current);
|
|
106
|
+
if (open) setNestedSelectOpen(true);
|
|
107
|
+
else {
|
|
108
|
+
// Radix closes before RAC processes the same pointer/Escape event.
|
|
109
|
+
// Keep the parent protected through dismissal and focus restoration.
|
|
110
|
+
nestedCloseFrame.current = requestAnimationFrame(() => {
|
|
111
|
+
setNestedSelectOpen(false);
|
|
112
|
+
nestedCloseFrame.current = null;
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
useEffect(() => () => {
|
|
117
|
+
if (nestedCloseFrame.current !== null) cancelAnimationFrame(nestedCloseFrame.current);
|
|
118
|
+
}, []);
|
|
119
|
+
const [menuContainer, setMenuContainer] = useState<HTMLDivElement | null>(null);
|
|
120
|
+
const [surface, setSurface] = useState<HTMLElement | null>(null);
|
|
121
|
+
useLayoutEffect(() => {
|
|
122
|
+
if (!surface?.querySelector(`.${styles.editor}`)) return;
|
|
123
|
+
const fit = () => {
|
|
124
|
+
const edge = parseFloat(getComputedStyle(surface).getPropertyValue("--picker-viewport-edge"));
|
|
125
|
+
const bounds = surface.getBoundingClientRect();
|
|
126
|
+
surface.style.setProperty("--picker-viewport-top", `${Math.max(edge, Math.min(bounds.top, window.innerHeight - bounds.height - edge))}px`);
|
|
127
|
+
surface.style.setProperty("--picker-viewport-left", `${Math.max(edge, Math.min(bounds.left, window.innerWidth - bounds.width - edge))}px`);
|
|
128
|
+
surface.dataset.fitViewport = "true";
|
|
129
|
+
};
|
|
130
|
+
const observer = new ResizeObserver(fit);
|
|
131
|
+
observer.observe(surface);
|
|
132
|
+
window.addEventListener("resize", fit);
|
|
133
|
+
fit();
|
|
134
|
+
return () => { observer.disconnect(); window.removeEventListener("resize", fit); };
|
|
135
|
+
}, [surface]);
|
|
136
|
+
const cls = [styles.popover, className ?? ""].filter(Boolean).join(" ");
|
|
137
|
+
return (
|
|
138
|
+
<AriaPopover data-nested-select-open={nestedSelectOpen || undefined} data-material={materialScope} ref={setSurface} className={cls} placement={placement}
|
|
139
|
+
isKeyboardDismissDisabled={nestedSelectOpen || isKeyboardDismissDisabled}
|
|
140
|
+
shouldCloseOnInteractOutside={(target) => !nestedSelectOpen && (shouldCloseOnInteractOutside?.(target) ?? true)}
|
|
141
|
+
{...rest}>
|
|
142
|
+
<NestedSelectContext.Provider value={{ onOpenChange: handleNestedSelectOpen, container: menuContainer }}>
|
|
143
|
+
<AriaDialog className={styles.dialog} aria-label="Color picker">
|
|
144
|
+
<div className={styles.scrollBody}>{children}</div>
|
|
145
|
+
{/* Owned by the dialog but outside its scroll clip. */}
|
|
146
|
+
<div ref={setMenuContainer} />
|
|
147
|
+
</AriaDialog>
|
|
148
|
+
</NestedSelectContext.Provider>
|
|
149
|
+
</AriaPopover>
|
|
150
|
+
);
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
/* ────────────────── Section ──────────────────
|
|
154
|
+
하나의 논리 그룹. label(선택) + content. DatePicker의 panelMain 톤 재현.
|
|
155
|
+
SwatchPicker처럼 폭을 가변으로 먹는 자식도 section 안에서 100% 폭. */
|
|
156
|
+
|
|
157
|
+
export type ColorPickerSectionProps = {
|
|
158
|
+
label?: ReactNode;
|
|
159
|
+
children?: ReactNode;
|
|
160
|
+
className?: string;
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
const ColorPickerSection = ({ label, children, className }: ColorPickerSectionProps) => {
|
|
164
|
+
const cls = [styles.section, className ?? ""].filter(Boolean).join(" ");
|
|
165
|
+
return (
|
|
166
|
+
<div className={cls}>
|
|
167
|
+
{label ? <div className={styles.sectionLabel}>{label}</div> : null}
|
|
168
|
+
<div className={styles.sectionBody}>{children}</div>
|
|
169
|
+
</div>
|
|
170
|
+
);
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
/* ────────────────── Divider ──────────────────
|
|
174
|
+
section 사이 hairline 구분선. */
|
|
175
|
+
|
|
176
|
+
const ColorPickerDivider = () => <div className={styles.divider} aria-hidden="true" />;
|
|
177
|
+
|
|
178
|
+
export type ColorPickerEditorProps = {
|
|
179
|
+
/** UI language; color format names remain standard abbreviations. */
|
|
180
|
+
locale?: "en" | "ko";
|
|
181
|
+
/** Colors shown in the optional frequently used section. */
|
|
182
|
+
presetColors?: readonly string[];
|
|
183
|
+
showPresets?: boolean;
|
|
184
|
+
showGuides?: boolean;
|
|
185
|
+
showChannels?: boolean;
|
|
186
|
+
/** @deprecated The custom color heading has been removed. */
|
|
187
|
+
showHeader?: boolean;
|
|
188
|
+
showSliders?: boolean;
|
|
189
|
+
showValueFields?: boolean;
|
|
190
|
+
/** Show opacity controls. Hide for opaque-only values such as brand colors. */
|
|
191
|
+
showAlpha?: boolean;
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
type ScreenEyeDropper = new () => {
|
|
195
|
+
open(options: { signal: AbortSignal }): Promise<{ sRGBHex: string }>;
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
function ScreenColorPicker({ ko, onPick }: { ko: boolean; onPick: (color: string) => void }) {
|
|
199
|
+
const { weight } = useIconAxis();
|
|
200
|
+
const [supported, setSupported] = useState(false);
|
|
201
|
+
const [busy, setBusy] = useState(false);
|
|
202
|
+
const [error, setError] = useState(false);
|
|
203
|
+
const pending = useRef<AbortController | null>(null);
|
|
204
|
+
useEffect(() => {
|
|
205
|
+
setSupported("EyeDropper" in window);
|
|
206
|
+
return () => pending.current?.abort();
|
|
207
|
+
}, []);
|
|
208
|
+
const pick = async () => {
|
|
209
|
+
const Picker = (window as Window & { EyeDropper?: ScreenEyeDropper }).EyeDropper;
|
|
210
|
+
if (!Picker || pending.current) return;
|
|
211
|
+
const controller = new AbortController();
|
|
212
|
+
pending.current = controller;
|
|
213
|
+
setBusy(true);
|
|
214
|
+
setError(false);
|
|
215
|
+
try {
|
|
216
|
+
const result = await new Picker().open({ signal: controller.signal });
|
|
217
|
+
if (!controller.signal.aborted) onPick(result.sRGBHex);
|
|
218
|
+
} catch (failure) {
|
|
219
|
+
if (!controller.signal.aborted && !(failure instanceof DOMException && failure.name === "AbortError")) {
|
|
220
|
+
setError(true);
|
|
221
|
+
}
|
|
222
|
+
} finally {
|
|
223
|
+
pending.current = null;
|
|
224
|
+
if (!controller.signal.aborted) setBusy(false);
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
const label = ko ? "화면에서 색상 선택" : "Pick color from screen";
|
|
228
|
+
return (
|
|
229
|
+
<>
|
|
230
|
+
<IconButton size="sm" variant="ghost" icon={<Icon name="eyedropper" weight={weight} />}
|
|
231
|
+
className={styles.eyeDropper} aria-label={label} aria-busy={busy || undefined}
|
|
232
|
+
disabled={!supported || busy} onClick={pick}
|
|
233
|
+
title={supported ? label : (ko ? "이 브라우저는 화면 색상 선택을 지원하지 않습니다" : "Screen color picking is unavailable in this browser")} />
|
|
234
|
+
{error && <span className={styles.pickError} role="status">
|
|
235
|
+
{ko ? "색상을 선택하지 못했습니다. 다시 시도해 주세요." : "Could not pick a color. Please try again."}
|
|
236
|
+
</span>}
|
|
237
|
+
</>
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/** Ready-to-use editor. Custom compositions can continue using Section/Divider. */
|
|
242
|
+
const ColorPickerEditor = ({
|
|
243
|
+
locale = "en", presetColors = [], showPresets = true, showGuides = false, showChannels = false,
|
|
244
|
+
showSliders = true, showValueFields = true, showAlpha = true,
|
|
245
|
+
}: ColorPickerEditorProps) => {
|
|
246
|
+
const state = useContext(ColorPickerStateContext);
|
|
247
|
+
const { onOpenChange: setNestedSelectOpen, container: menuContainer } = useContext(NestedSelectContext);
|
|
248
|
+
const formatTriggerRef = useRef<HTMLButtonElement>(null);
|
|
249
|
+
const paletteTriggerRef = useRef<HTMLButtonElement>(null);
|
|
250
|
+
const [format, setFormat] = useState("hex");
|
|
251
|
+
const [palette, setPalette] = useState("presets");
|
|
252
|
+
const [recentColors, setRecentColors] = useState<string[]>([]);
|
|
253
|
+
const currentHex = state?.color.toString("hex");
|
|
254
|
+
useEffect(() => {
|
|
255
|
+
if (!currentHex) return;
|
|
256
|
+
const timer = window.setTimeout(() => {
|
|
257
|
+
setRecentColors((previous) => [currentHex, ...previous.filter((entry) => entry !== currentHex)].slice(0, 16));
|
|
258
|
+
}, 250);
|
|
259
|
+
return () => window.clearTimeout(timer);
|
|
260
|
+
}, [currentHex]);
|
|
261
|
+
if (!state) throw new Error("ColorPicker.Editor must be used inside ColorPicker.");
|
|
262
|
+
const ko = locale === "ko";
|
|
263
|
+
const channels = format === "rgb"
|
|
264
|
+
? (["red", "green", "blue"] as const)
|
|
265
|
+
: (["hue", "saturation", "brightness"] as const);
|
|
266
|
+
const channelNames = format === "rgb" ? ["R", "G", "B"] : ["H", "S", "B"];
|
|
267
|
+
const update = (color: Parameters<typeof state.setColor>[0]) => {
|
|
268
|
+
if (color) state.setColor(color);
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
const channelFields = channels.map((channel, i) => (
|
|
272
|
+
<ColorField className={styles.joinedField} key={channel} channel={channel} colorSpace={format === "rgb" ? "rgb" : "hsb"}
|
|
273
|
+
value={state.color} onChange={update} variant="outline" size="sm"
|
|
274
|
+
leading={channelNames[i]} aria-label={channel} />
|
|
275
|
+
));
|
|
276
|
+
|
|
277
|
+
return (
|
|
278
|
+
<div className={styles.editor}>
|
|
279
|
+
{showChannels && <div className={styles.channelRow}>
|
|
280
|
+
{(["hue", "saturation", "brightness"] as const).map((channel, i) => (
|
|
281
|
+
<ColorField className={styles.channelField} key={channel} channel={channel} colorSpace="hsb"
|
|
282
|
+
value={state.color} onChange={update} variant="outline" size="sm"
|
|
283
|
+
leading={<span className={styles.channelLabel}>{["H", "S", "B"][i]}</span>} aria-label={channel} />
|
|
284
|
+
))}
|
|
285
|
+
</div>}
|
|
286
|
+
<ColorArea size="fill" showGuides={showGuides} colorSpace="hsb"
|
|
287
|
+
xChannel="saturation" yChannel="brightness"
|
|
288
|
+
aria-label={ko ? "채도 및 밝기" : "Saturation and brightness"} />
|
|
289
|
+
{showSliders && <div className={styles.sliderRow}>
|
|
290
|
+
<ScreenColorPicker ko={ko} onPick={(color) => {
|
|
291
|
+
state.setColor(parseColor(color).withChannelValue("alpha", state.color.getChannelValue("alpha")));
|
|
292
|
+
}} />
|
|
293
|
+
<div className={styles.sliders}>
|
|
294
|
+
<ColorSlider size="sm" channel="hue" colorSpace="hsb" aria-label={ko ? "색조" : "Hue"}>
|
|
295
|
+
<ColorSlider.Track />
|
|
296
|
+
</ColorSlider>
|
|
297
|
+
{showAlpha && <ColorSlider size="sm" channel="alpha" aria-label={ko ? "불투명도" : "Opacity"}>
|
|
298
|
+
<ColorSlider.Track />
|
|
299
|
+
</ColorSlider>}
|
|
300
|
+
</div>
|
|
301
|
+
</div>}
|
|
302
|
+
{showValueFields && <>
|
|
303
|
+
<div className={styles.valueRow} data-format={format}>
|
|
304
|
+
<Select value={format} onValueChange={setFormat} onOpenChange={setNestedSelectOpen} variant="outline" size="sm">
|
|
305
|
+
<Select.Trigger ref={formatTriggerRef} className={styles.formatTrigger} aria-label={ko ? "색상 형식" : "Color format"}>
|
|
306
|
+
<Select.Value />
|
|
307
|
+
</Select.Trigger>
|
|
308
|
+
<Select.Content container={menuContainer} side="top" onKeyDown={(event) => { if (event.key === "Escape") event.stopPropagation(); }} onCloseAutoFocus={(event) => {
|
|
309
|
+
event.preventDefault();
|
|
310
|
+
formatTriggerRef.current?.focus();
|
|
311
|
+
}}>
|
|
312
|
+
<Select.Item value="hex">Hex</Select.Item>
|
|
313
|
+
<Select.Item value="rgb">RGB</Select.Item>
|
|
314
|
+
<Select.Item value="hsb">HSB</Select.Item>
|
|
315
|
+
</Select.Content>
|
|
316
|
+
</Select>
|
|
317
|
+
<div className={styles.valueGroup} data-format={format !== "hex" && !showAlpha ? "channels" : format} data-alpha={showAlpha || undefined}>
|
|
318
|
+
{format === "hex" && (
|
|
319
|
+
<ColorField className={styles.joinedField} slot={null} value={state.color} onChange={(color) => {
|
|
320
|
+
if (color) state.setColor(color.withChannelValue("alpha", state.color.getChannelValue("alpha")));
|
|
321
|
+
}} variant="outline" size="sm"
|
|
322
|
+
aria-label={ko ? "HEX 색상 코드" : "Hex color code"} />
|
|
323
|
+
)}
|
|
324
|
+
{format !== "hex" && !showAlpha && channelFields}
|
|
325
|
+
{showAlpha && <ColorField className={styles.joinedField} channel="alpha" value={state.color} onChange={update}
|
|
326
|
+
variant="outline" size="sm" aria-label={ko ? "불투명도 값" : "Opacity value"} />}
|
|
327
|
+
</div>
|
|
328
|
+
</div>
|
|
329
|
+
{format !== "hex" && showAlpha && (
|
|
330
|
+
<div className={styles.valueGroup} data-format="channels">{channelFields}</div>
|
|
331
|
+
)}
|
|
332
|
+
</>}
|
|
333
|
+
{showPresets && presetColors.length > 0 && (
|
|
334
|
+
<div className={styles.editorControls}>
|
|
335
|
+
<Select value={palette} onValueChange={setPalette} onOpenChange={setNestedSelectOpen} variant="outline" size="sm">
|
|
336
|
+
<Select.Trigger ref={paletteTriggerRef} className={styles.paletteTrigger} aria-label={ko ? "색상 팔레트" : "Color palette"}>
|
|
337
|
+
<Select.Value />
|
|
338
|
+
</Select.Trigger>
|
|
339
|
+
<Select.Content container={menuContainer} onKeyDown={(event) => { if (event.key === "Escape") event.stopPropagation(); }} onCloseAutoFocus={(event) => {
|
|
340
|
+
event.preventDefault();
|
|
341
|
+
paletteTriggerRef.current?.focus();
|
|
342
|
+
}}>
|
|
343
|
+
<Select.Item value="presets">{ko ? "자주 쓰는 색" : "Frequently used"}</Select.Item>
|
|
344
|
+
<Select.Item value="recent">{ko ? "최근 색상" : "Last Colors"}</Select.Item>
|
|
345
|
+
</Select.Content>
|
|
346
|
+
</Select>
|
|
347
|
+
{palette === "recent" && recentColors.length === 0 ? (
|
|
348
|
+
<span className={styles.editorTitle}>{ko ? "최근 색상이 없습니다" : "No recent colors"}</span>
|
|
349
|
+
) : (
|
|
350
|
+
<ColorSwatchPicker className={styles.presetGrid} shape="square" aria-label={ko ? "색상 팔레트" : "Color palette"}>
|
|
351
|
+
{(palette === "recent" ? recentColors : presetColors).map((color) => (
|
|
352
|
+
<ColorSwatchPicker.Item className={styles.presetItem} key={color} color={color}>
|
|
353
|
+
<ColorSwatchPicker.Swatch className={styles.presetSwatch} />
|
|
354
|
+
<ColorSwatchPicker.Indicator />
|
|
355
|
+
</ColorSwatchPicker.Item>
|
|
356
|
+
))}
|
|
357
|
+
</ColorSwatchPicker>
|
|
358
|
+
)}
|
|
359
|
+
</div>
|
|
360
|
+
)}
|
|
361
|
+
</div>
|
|
362
|
+
);
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
type ColorPickerCompound = typeof ColorPickerRoot & {
|
|
366
|
+
Trigger: typeof ColorPickerTrigger;
|
|
367
|
+
Popover: typeof ColorPickerPopover;
|
|
368
|
+
Section: typeof ColorPickerSection;
|
|
369
|
+
Divider: typeof ColorPickerDivider;
|
|
370
|
+
Editor: typeof ColorPickerEditor;
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
const ColorPicker = ColorPickerRoot as ColorPickerCompound;
|
|
374
|
+
ColorPicker.Trigger = ColorPickerTrigger;
|
|
375
|
+
ColorPicker.Popover = ColorPickerPopover;
|
|
376
|
+
ColorPicker.Section = ColorPickerSection;
|
|
377
|
+
ColorPicker.Divider = ColorPickerDivider;
|
|
378
|
+
ColorPicker.Editor = ColorPickerEditor;
|
|
379
|
+
|
|
380
|
+
export {
|
|
381
|
+
ColorPicker,
|
|
382
|
+
ColorPickerTrigger,
|
|
383
|
+
ColorPickerPopover,
|
|
384
|
+
ColorPickerSection,
|
|
385
|
+
ColorPickerDivider,
|
|
386
|
+
ColorPickerEditor,
|
|
387
|
+
};
|