@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
|
@@ -1,153 +1,141 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* MetricCard — 전부 Ovenn 토큰 경유.
|
|
3
|
-
* variant:
|
|
4
|
-
* line — border + 은은한 shadow-sm (조밀한 그리드, 기본)
|
|
5
|
-
* soft — bg-subtle 표면 (경계 대신 톤)
|
|
6
|
-
* bare — border·bg·padding 모두 제거. pure 좌표 전용.
|
|
7
|
-
* 부모 container가 hairline/톤으로 분리를 담당하는 자리에서만 쓴다.
|
|
8
|
-
* interactive: href 있을 때만 hover/focus ring.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
1
|
.root {
|
|
2
|
+
container: metric-card / inline-size;
|
|
12
3
|
display: flex;
|
|
13
4
|
flex-direction: column;
|
|
14
|
-
gap: var(--space-
|
|
15
|
-
text-decoration: none;
|
|
16
|
-
color: inherit;
|
|
5
|
+
gap: var(--space-4);
|
|
17
6
|
min-width: 0;
|
|
7
|
+
min-height: var(--metric-height);
|
|
8
|
+
color: var(--fg);
|
|
9
|
+
text-decoration: none;
|
|
10
|
+
box-sizing: border-box;
|
|
18
11
|
}
|
|
19
|
-
|
|
20
|
-
/* line/soft는 자체 chrome(padding+radius)을 가진다.
|
|
21
|
-
line = hairline만, soft = 톤 배경만 — 둘 다 섞지 않는다. */
|
|
22
12
|
.line,
|
|
23
13
|
.soft {
|
|
24
|
-
padding: var(--
|
|
25
|
-
|
|
14
|
+
padding: var(--metric-padding);
|
|
15
|
+
corner-shape: var(--card-corner-shape);
|
|
16
|
+
border-radius: var(--radius-lg);
|
|
26
17
|
}
|
|
27
|
-
|
|
28
18
|
.line {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.soft {
|
|
34
|
-
background: var(--bg-subtle);
|
|
19
|
+
background: var(--bg);
|
|
20
|
+
border: var(--hairline) solid var(--border);
|
|
35
21
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
부모가 hairline/톤 교대로 분리를 담당하는 pure 좌표에서만 사용.
|
|
39
|
-
interactive라도 bg 교체 없이 fg 톤 변화만. */
|
|
40
|
-
.bare {
|
|
41
|
-
padding: 0;
|
|
42
|
-
border: 0;
|
|
43
|
-
background: transparent;
|
|
44
|
-
}
|
|
45
|
-
|
|
22
|
+
.soft { background: var(--bg-subtle); }
|
|
23
|
+
.bare { min-height: 0; padding: 0; }
|
|
46
24
|
.interactive {
|
|
47
25
|
cursor: pointer;
|
|
48
|
-
transition: var(--transition-colors)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.line.interactive:hover {
|
|
52
|
-
background: var(--hover);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
.soft.interactive:hover {
|
|
56
|
-
background: var(--bg-subtle-hover, var(--hover));
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.bare.interactive:hover {
|
|
60
|
-
color: var(--fg-strong, var(--fg));
|
|
26
|
+
transition: var(--transition-colors);
|
|
61
27
|
}
|
|
62
|
-
|
|
28
|
+
.interactive:hover { background: var(--hover); }
|
|
29
|
+
.bare.interactive:hover { background: transparent; color: var(--fg-strong); }
|
|
63
30
|
.interactive:focus-visible {
|
|
64
31
|
outline: none;
|
|
65
|
-
|
|
32
|
+
background: var(--bg-muted);
|
|
33
|
+
box-shadow: inset 0 0 0 var(--hairline) var(--border-strong);
|
|
66
34
|
}
|
|
67
|
-
|
|
68
|
-
|
|
35
|
+
.header {
|
|
36
|
+
display: flex;
|
|
37
|
+
align-items: flex-start;
|
|
38
|
+
justify-content: space-between;
|
|
39
|
+
gap: var(--space-3);
|
|
40
|
+
min-width: 0;
|
|
41
|
+
}
|
|
42
|
+
.heading { min-width: 0; }
|
|
69
43
|
.head {
|
|
70
44
|
display: flex;
|
|
71
45
|
align-items: center;
|
|
72
46
|
gap: var(--space-2);
|
|
73
47
|
min-width: 0;
|
|
74
48
|
}
|
|
75
|
-
|
|
76
|
-
.
|
|
49
|
+
.icon,
|
|
50
|
+
.linkIcon {
|
|
77
51
|
display: inline-flex;
|
|
78
52
|
align-items: center;
|
|
79
53
|
justify-content: center;
|
|
80
|
-
|
|
81
|
-
font-size: var(--text-
|
|
54
|
+
flex-shrink: 0;
|
|
55
|
+
font-size: var(--text-base);
|
|
82
56
|
line-height: 1;
|
|
83
57
|
}
|
|
84
|
-
|
|
58
|
+
.icon { color: var(--metric-secondary-fg); }
|
|
59
|
+
.linkIcon { color: var(--metric-secondary-fg); }
|
|
85
60
|
.label {
|
|
86
|
-
|
|
87
|
-
|
|
61
|
+
min-width: 0;
|
|
62
|
+
font-size: var(--text-sm);
|
|
88
63
|
font-weight: var(--font-weight-medium);
|
|
89
|
-
|
|
64
|
+
line-height: var(--lh-sm);
|
|
65
|
+
overflow-wrap: anywhere;
|
|
66
|
+
}
|
|
67
|
+
.subtitle {
|
|
68
|
+
margin-top: var(--space-1);
|
|
69
|
+
color: var(--metric-secondary-fg);
|
|
70
|
+
font-size: var(--text-sm);
|
|
71
|
+
line-height: var(--lh-sm);
|
|
72
|
+
overflow-wrap: anywhere;
|
|
73
|
+
}
|
|
74
|
+
.body {
|
|
75
|
+
display: grid;
|
|
76
|
+
grid-template-columns: minmax(0, 1fr);
|
|
77
|
+
align-items: end;
|
|
78
|
+
gap: var(--space-3);
|
|
79
|
+
margin-top: 0;
|
|
90
80
|
min-width: 0;
|
|
91
|
-
overflow: hidden;
|
|
92
|
-
text-overflow: ellipsis;
|
|
93
|
-
white-space: nowrap;
|
|
94
81
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
82
|
+
.body:has(.chart) {
|
|
83
|
+
grid-template-columns: minmax(0, 1fr) minmax(0, 38%);
|
|
84
|
+
}
|
|
85
|
+
.metric {
|
|
98
86
|
display: flex;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
87
|
+
flex: 1 1 auto;
|
|
88
|
+
flex-direction: column;
|
|
89
|
+
align-items: flex-start;
|
|
90
|
+
gap: var(--space-2);
|
|
102
91
|
min-width: 0;
|
|
103
|
-
flex-wrap: wrap;
|
|
104
92
|
}
|
|
105
|
-
|
|
106
93
|
.value {
|
|
107
|
-
|
|
94
|
+
max-width: 100%;
|
|
95
|
+
font-size: var(--metric-value-size);
|
|
96
|
+
font-weight: var(--font-weight-medium);
|
|
97
|
+
letter-spacing: var(--metric-value-tracking);
|
|
108
98
|
line-height: var(--lh-tight);
|
|
109
|
-
font-
|
|
110
|
-
|
|
111
|
-
|
|
99
|
+
font-variant-numeric: tabular-nums lining-nums;
|
|
100
|
+
overflow-wrap: anywhere;
|
|
101
|
+
}
|
|
102
|
+
.valueRow {
|
|
103
|
+
display: flex;
|
|
104
|
+
align-items: baseline;
|
|
105
|
+
flex-wrap: wrap;
|
|
106
|
+
gap: var(--space-2);
|
|
112
107
|
min-width: 0;
|
|
108
|
+
max-width: 100%;
|
|
113
109
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
gap: calc(var(--space-unit) * 1);
|
|
110
|
+
.delta { flex-shrink: 0; font-variant-numeric: tabular-nums; }
|
|
111
|
+
.description {
|
|
112
|
+
letter-spacing: var(--tracking-normal);
|
|
113
|
+
font-variant-numeric: tabular-nums lining-nums;
|
|
114
|
+
color: var(--metric-secondary-fg);
|
|
120
115
|
font-size: var(--text-xs);
|
|
121
|
-
line-height: var(--lh-
|
|
122
|
-
|
|
123
|
-
font-variant-numeric: tabular-nums;
|
|
124
|
-
color: var(--fg-muted);
|
|
125
|
-
flex-shrink: 0;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
.delta[data-trend="up"] {
|
|
129
|
-
color: var(--success);
|
|
116
|
+
line-height: var(--lh-sm);
|
|
117
|
+
overflow-wrap: anywhere;
|
|
130
118
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
119
|
+
.chart {
|
|
120
|
+
width: 100%;
|
|
121
|
+
max-width: 100%;
|
|
122
|
+
min-width: 0;
|
|
123
|
+
height: var(--metric-chart-height);
|
|
134
124
|
}
|
|
125
|
+
.chart > * { width: 100%; height: 100%; min-width: 0; }
|
|
126
|
+
.footer { min-width: 0; }
|
|
135
127
|
|
|
136
|
-
|
|
137
|
-
|
|
128
|
+
@container metric-card (max-width: 280px) {
|
|
129
|
+
.value { font-size: min(var(--metric-value-size), var(--metric-narrow-value-size)); }
|
|
130
|
+
.body:has(.chart) { grid-template-columns: minmax(0, 1fr) minmax(0, 32%); }
|
|
138
131
|
}
|
|
139
132
|
|
|
140
|
-
.
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
/* description: value 아래 */
|
|
149
|
-
.description {
|
|
150
|
-
font-size: var(--text-xs);
|
|
151
|
-
line-height: var(--lh-xs);
|
|
152
|
-
color: var(--fg-muted);
|
|
133
|
+
.srOnly {
|
|
134
|
+
position: absolute;
|
|
135
|
+
width: var(--hairline);
|
|
136
|
+
height: var(--hairline);
|
|
137
|
+
padding: 0;
|
|
138
|
+
overflow: hidden;
|
|
139
|
+
clip-path: inset(50%);
|
|
140
|
+
white-space: nowrap;
|
|
153
141
|
}
|
|
@@ -8,15 +8,17 @@ import {
|
|
|
8
8
|
type Ref,
|
|
9
9
|
} from "react";
|
|
10
10
|
|
|
11
|
+
import { Tag, type TagStatus } from "../Tag";
|
|
11
12
|
import { Icon, type IconName } from "../Icon";
|
|
12
13
|
|
|
13
14
|
import styles from "./MetricCard.module.css";
|
|
15
|
+
import "./tokens.css";
|
|
14
16
|
|
|
15
17
|
/**
|
|
16
18
|
* MetricCard — 대시보드 상단 KPI/Stat 카드.
|
|
17
|
-
* label + value
|
|
19
|
+
* label/subtitle + value/delta + 선택적 작은 chart/footer.
|
|
18
20
|
*
|
|
19
|
-
* trend
|
|
21
|
+
* trend와 deltaLabel은 큰 수치 옆의 작은 Tag로 자동 생성.
|
|
20
22
|
* delta를 직접 ReactNode로 주면 수동 모드, trend 매핑은 무시된다.
|
|
21
23
|
*/
|
|
22
24
|
export type MetricCardVariant = "line" | "soft" | "bare";
|
|
@@ -31,6 +33,9 @@ type Common = {
|
|
|
31
33
|
delta?: ReactNode;
|
|
32
34
|
description?: ReactNode;
|
|
33
35
|
variant?: MetricCardVariant;
|
|
36
|
+
subtitle?: ReactNode;
|
|
37
|
+
chart?: ReactNode;
|
|
38
|
+
footer?: ReactNode;
|
|
34
39
|
};
|
|
35
40
|
|
|
36
41
|
type DivProps = Common &
|
|
@@ -51,10 +56,10 @@ const variantClass: Record<MetricCardVariant, string> = {
|
|
|
51
56
|
bare: styles.bare,
|
|
52
57
|
};
|
|
53
58
|
|
|
54
|
-
const
|
|
55
|
-
up: "
|
|
56
|
-
down: "
|
|
57
|
-
flat: "
|
|
59
|
+
const trendStatus: Record<MetricCardTrend, TagStatus> = {
|
|
60
|
+
up: "success",
|
|
61
|
+
down: "destructive",
|
|
62
|
+
flat: "neutral",
|
|
58
63
|
};
|
|
59
64
|
|
|
60
65
|
const MetricCard = forwardRef<HTMLElement, MetricCardProps>((props, ref) => {
|
|
@@ -68,6 +73,9 @@ const MetricCard = forwardRef<HTMLElement, MetricCardProps>((props, ref) => {
|
|
|
68
73
|
delta,
|
|
69
74
|
description,
|
|
70
75
|
variant = "line",
|
|
76
|
+
subtitle,
|
|
77
|
+
chart,
|
|
78
|
+
footer,
|
|
71
79
|
...rest
|
|
72
80
|
} = props as Common & { className?: string } & Record<string, unknown>;
|
|
73
81
|
|
|
@@ -82,32 +90,44 @@ const MetricCard = forwardRef<HTMLElement, MetricCardProps>((props, ref) => {
|
|
|
82
90
|
.filter(Boolean)
|
|
83
91
|
.join(" ");
|
|
84
92
|
|
|
93
|
+
const direction = trend === "up" ? "Increase" : trend === "down" ? "Decrease" : "No change";
|
|
94
|
+
const signedDelta = trend && (typeof deltaLabel === "string" || typeof deltaLabel === "number") && !/^[+−=\-]/.test(String(deltaLabel).trim())
|
|
95
|
+
? `${trend === "up" ? "+" : trend === "down" ? "−" : "="}${deltaLabel}`
|
|
96
|
+
: deltaLabel;
|
|
97
|
+
|
|
85
98
|
const resolvedDelta =
|
|
86
99
|
delta ??
|
|
87
100
|
(trend && deltaLabel !== undefined ? (
|
|
88
|
-
<
|
|
89
|
-
<span className={styles.
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
</span>
|
|
101
|
+
<Tag size="sm" variant="soft" status={trendStatus[trend]} className={styles.delta}>
|
|
102
|
+
<span className={styles.srOnly} lang="en">{direction}: </span>
|
|
103
|
+
{typeof deltaLabel !== "string" && typeof deltaLabel !== "number" && <span aria-hidden>{trend === "up" ? "↑" : trend === "down" ? "↓" : "↔"}</span>}
|
|
104
|
+
{signedDelta}
|
|
105
|
+
</Tag>
|
|
94
106
|
) : null);
|
|
95
107
|
|
|
96
108
|
const content = (
|
|
97
109
|
<>
|
|
98
|
-
<div className={styles.
|
|
99
|
-
{
|
|
100
|
-
<
|
|
101
|
-
<Icon name={icon}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
110
|
+
<div className={styles.header}>
|
|
111
|
+
<div className={styles.heading}>
|
|
112
|
+
<div className={styles.head}>
|
|
113
|
+
{icon && <span className={styles.icon} aria-hidden><Icon name={icon} /></span>}
|
|
114
|
+
<span className={styles.label}>{label}</span>
|
|
115
|
+
</div>
|
|
116
|
+
{subtitle != null && <div className={styles.subtitle}>{subtitle}</div>}
|
|
117
|
+
</div>
|
|
118
|
+
{isLink && <span className={styles.linkIcon} aria-hidden><Icon name="arrow-up-right" /></span>}
|
|
105
119
|
</div>
|
|
106
|
-
<div className={styles.
|
|
107
|
-
<
|
|
108
|
-
|
|
120
|
+
<div className={styles.body} data-slot="metric-card-body">
|
|
121
|
+
<div className={styles.metric}>
|
|
122
|
+
<div className={styles.valueRow} data-slot="metric-card-value-row">
|
|
123
|
+
<div className={styles.value}>{value}</div>
|
|
124
|
+
{resolvedDelta}
|
|
125
|
+
</div>
|
|
126
|
+
{description != null && <div className={styles.description}>{description}</div>}
|
|
127
|
+
</div>
|
|
128
|
+
{chart != null && <div className={styles.chart} data-slot="metric-card-chart">{chart}</div>}
|
|
109
129
|
</div>
|
|
110
|
-
{
|
|
130
|
+
{footer != null && <div className={styles.footer}>{footer}</div>}
|
|
111
131
|
</>
|
|
112
132
|
);
|
|
113
133
|
|
|
@@ -115,6 +135,7 @@ const MetricCard = forwardRef<HTMLElement, MetricCardProps>((props, ref) => {
|
|
|
115
135
|
return (
|
|
116
136
|
<a
|
|
117
137
|
ref={ref as Ref<HTMLAnchorElement>}
|
|
138
|
+
data-slot="metric-card"
|
|
118
139
|
className={rootClass}
|
|
119
140
|
{...(rest as AnchorHTMLAttributes<HTMLAnchorElement>)}
|
|
120
141
|
href={(props as AnchorProps).href}
|
|
@@ -127,6 +148,7 @@ const MetricCard = forwardRef<HTMLElement, MetricCardProps>((props, ref) => {
|
|
|
127
148
|
return (
|
|
128
149
|
<div
|
|
129
150
|
ref={ref as Ref<HTMLDivElement>}
|
|
151
|
+
data-slot="metric-card"
|
|
130
152
|
className={rootClass}
|
|
131
153
|
{...(rest as HTMLAttributes<HTMLDivElement>)}
|
|
132
154
|
>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/* Compact baseline. Scoped skins may customize these values. */
|
|
2
|
+
[data-slot="metric-card"] {
|
|
3
|
+
--metric-secondary-fg: color-mix(in oklab, var(--fg) 60%, var(--bg));
|
|
4
|
+
--metric-padding: var(--space-5);
|
|
5
|
+
--metric-height: 0;
|
|
6
|
+
--metric-value-size: 32px;
|
|
7
|
+
--metric-narrow-value-size: 28px;
|
|
8
|
+
--metric-chart-height: 64px;
|
|
9
|
+
--metric-value-tracking: -0.035em;
|
|
10
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
--mini-calendar-accent: var(--fg);
|
|
3
|
+
--mini-calendar-accent-fg: var(--bg);
|
|
4
|
+
--mini-calendar-width: calc(var(--size-24) * 4);
|
|
5
|
+
--mini-calendar-radius: var(--radius-xs);
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
width: 100%;
|
|
9
|
+
max-width: var(--mini-calendar-width);
|
|
10
|
+
min-width: 0;
|
|
11
|
+
gap: var(--space-2);
|
|
12
|
+
color: var(--fg);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.root[data-size="lg"] { --mini-calendar-width: calc(var(--size-24) * 5); }
|
|
16
|
+
.root[data-size="lg"] .heading { font-size: var(--text-xl); line-height: var(--lh-xl); }
|
|
17
|
+
.root[data-size="lg"] .days .day { font-size: var(--text-base); }
|
|
18
|
+
|
|
19
|
+
.root[data-color="primary"] {
|
|
20
|
+
--mini-calendar-accent: var(--primary);
|
|
21
|
+
--mini-calendar-accent-fg: var(--primary-fg);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.header {
|
|
25
|
+
display: flex;
|
|
26
|
+
align-items: center;
|
|
27
|
+
justify-content: space-between;
|
|
28
|
+
gap: var(--space-2);
|
|
29
|
+
margin-bottom: var(--space-2);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.heading {
|
|
33
|
+
display: flex;
|
|
34
|
+
align-items: baseline;
|
|
35
|
+
flex-wrap: wrap;
|
|
36
|
+
gap: var(--space-1_5);
|
|
37
|
+
min-width: 0;
|
|
38
|
+
font-size: var(--text-xl);
|
|
39
|
+
line-height: var(--lh-xl);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.month { font-weight: var(--font-weight-semibold); }
|
|
43
|
+
.year { font-weight: var(--font-weight-semibold); }
|
|
44
|
+
.navigation { display: flex; gap: var(--space-1); flex-shrink: 0; }
|
|
45
|
+
|
|
46
|
+
.weekdays,
|
|
47
|
+
.days {
|
|
48
|
+
display: grid;
|
|
49
|
+
grid-template-columns: repeat(7, minmax(0, 1fr));
|
|
50
|
+
gap: var(--space-1_5);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.weekday {
|
|
54
|
+
display: flex;
|
|
55
|
+
align-items: center;
|
|
56
|
+
justify-content: center;
|
|
57
|
+
min-height: var(--size-6);
|
|
58
|
+
color: var(--fg-subtle);
|
|
59
|
+
font-size: var(--text-2xs);
|
|
60
|
+
font-weight: var(--font-weight-regular);
|
|
61
|
+
line-height: var(--lh-2xs);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
/* Date geometry is a scoped Button skin, sized by the seven-column layout. */
|
|
66
|
+
.days .day,
|
|
67
|
+
.blank {
|
|
68
|
+
aspect-ratio: 1;
|
|
69
|
+
height: auto;
|
|
70
|
+
min-height: var(--size-10);
|
|
71
|
+
min-width: 0;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.days .day {
|
|
75
|
+
--button-bg: var(--bg-subtle);
|
|
76
|
+
--button-fg: var(--fg);
|
|
77
|
+
padding: var(--space-1);
|
|
78
|
+
--button-border: transparent;
|
|
79
|
+
border-radius: var(--mini-calendar-radius);
|
|
80
|
+
corner-shape: var(--corner-shape);
|
|
81
|
+
font-size: var(--text-sm);
|
|
82
|
+
font-weight: var(--font-weight-regular);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.days .day[data-outside],
|
|
86
|
+
.days .day[data-past] { --button-fg: var(--fg-subtle); }
|
|
87
|
+
.days .day[data-selected] {
|
|
88
|
+
--button-bg: var(--mini-calendar-accent);
|
|
89
|
+
--button-fg: var(--mini-calendar-accent-fg);
|
|
90
|
+
}
|
|
91
|
+
.root[data-variant="outline"] .days .day {
|
|
92
|
+
--button-bg: transparent;
|
|
93
|
+
--button-border: var(--border);
|
|
94
|
+
}
|
|
95
|
+
.root[data-variant="outline"] .days .day[data-selected] {
|
|
96
|
+
--button-fg: var(--mini-calendar-accent);
|
|
97
|
+
--button-border: var(--mini-calendar-accent);
|
|
98
|
+
}
|
|
99
|
+
.root[data-variant="outline"] .days .day[data-previous-month] {
|
|
100
|
+
--button-bg: var(--bg-subtle);
|
|
101
|
+
}
|
|
102
|
+
.root[data-variant="fill"] .days .day[data-outside] { opacity: var(--disabled-opacity); }
|
|
103
|
+
.root[data-color="primary"] .day:not([data-selected], [data-past], [data-outside]) .marker { color: var(--mini-calendar-accent); }
|
|
104
|
+
.root[data-color="primary"] .day[data-today]:not([data-selected]) .dayNumber { color: var(--mini-calendar-accent); }
|
|
105
|
+
.days .day:focus-visible { outline: none; box-shadow: inset 0 0 0 var(--hairline) var(--fg-muted); }
|
|
106
|
+
.root[data-variant="fill"] .days .day[data-selected]:focus-visible { box-shadow: inset 0 0 0 var(--hairline) var(--mini-calendar-accent-fg); }
|
|
107
|
+
|
|
108
|
+
.dayContent {
|
|
109
|
+
display: flex;
|
|
110
|
+
flex-direction: column;
|
|
111
|
+
align-items: center;
|
|
112
|
+
justify-content: center;
|
|
113
|
+
gap: var(--space-1);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.marker {
|
|
117
|
+
width: var(--size-1-5);
|
|
118
|
+
height: var(--size-1-5);
|
|
119
|
+
border-radius: var(--radius-full);
|
|
120
|
+
corner-shape: round;
|
|
121
|
+
background: currentColor;
|
|
122
|
+
visibility: hidden;
|
|
123
|
+
}
|
|
124
|
+
.marker[data-event] { visibility: visible; }
|
|
125
|
+
.dayNumber { line-height: var(--lh-xs); font-variant-numeric: tabular-nums; }
|
|
126
|
+
.day[data-today] .dayNumber {
|
|
127
|
+
font-weight: var(--font-weight-semibold);
|
|
128
|
+
text-decoration: underline;
|
|
129
|
+
text-underline-offset: var(--space-0_5);
|
|
130
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { forwardRef, useLayoutEffect, useMemo, useRef, useState, type HTMLAttributes, type KeyboardEvent } from "react";
|
|
4
|
+
import { Button } from "../Button";
|
|
5
|
+
import { Icon } from "../Icon";
|
|
6
|
+
import { IconButton } from "../IconButton";
|
|
7
|
+
import { useTheme } from "../ThemeController";
|
|
8
|
+
import { addDays, addMonths, buildMonthGrid, endOfMonth, formatDate, formatISODate, isSameDay, isSameMonth, startOfMonth, startOfWeek, weekdayLabels } from "../DatePicker/utils";
|
|
9
|
+
import styles from "./MiniCalendar.module.css";
|
|
10
|
+
|
|
11
|
+
export type MiniCalendarProps = Omit<HTMLAttributes<HTMLDivElement>, "onChange"> & {
|
|
12
|
+
/** Controlled visible month. */
|
|
13
|
+
month: Date;
|
|
14
|
+
selectedDate?: Date | null;
|
|
15
|
+
today?: Date;
|
|
16
|
+
/** Local yyyy-MM-dd values. Multiple events on one day still produce one dot. */
|
|
17
|
+
eventDates?: readonly string[];
|
|
18
|
+
weekStartsOn?: 0 | 1;
|
|
19
|
+
showOutsideDays?: boolean;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
/** md: compact (384px), lg: larger compositions (480px). */
|
|
22
|
+
size?: "md" | "lg";
|
|
23
|
+
/** Date tile surface; outline keeps tiles unfilled. */
|
|
24
|
+
variant?: "fill" | "outline";
|
|
25
|
+
/** Primary follows the active brand/theme color. */
|
|
26
|
+
color?: "neutral" | "primary";
|
|
27
|
+
onMonthChange?: (month: Date) => void;
|
|
28
|
+
onSelectedDateChange?: (date: Date) => void;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const LABELS = {
|
|
32
|
+
en: { previous: "Previous month", next: "Next month", hasEvents: "Has events" },
|
|
33
|
+
ko: { previous: "이전 달", next: "다음 달", hasEvents: "일정 있음" },
|
|
34
|
+
} as const;
|
|
35
|
+
|
|
36
|
+
/** Small-area date navigation and event presence; use Calendar for full schedule content. */
|
|
37
|
+
export const MiniCalendar = forwardRef<HTMLDivElement, MiniCalendarProps>(function MiniCalendar({
|
|
38
|
+
month, selectedDate = null, today: todayProp, eventDates = [], weekStartsOn = 0,
|
|
39
|
+
showOutsideDays = true, disabled = false, variant = "fill", color = "neutral", size = "md", onMonthChange, onSelectedDateChange, className, ...rest
|
|
40
|
+
}, ref) {
|
|
41
|
+
const { lang } = useTheme();
|
|
42
|
+
const labels = LABELS[lang];
|
|
43
|
+
const today = useMemo(() => todayProp ?? new Date(), [todayProp]);
|
|
44
|
+
const monthStart = useMemo(() => startOfMonth(month), [month]);
|
|
45
|
+
const days = useMemo(() => buildMonthGrid(monthStart, weekStartsOn), [monthStart, weekStartsOn]);
|
|
46
|
+
const todayKey = formatISODate(today);
|
|
47
|
+
const events = useMemo(() => new Set(eventDates), [eventDates]);
|
|
48
|
+
const weekdays = useMemo(() => {
|
|
49
|
+
const names = weekdayLabels(lang);
|
|
50
|
+
return [...names.slice(weekStartsOn), ...names.slice(0, weekStartsOn)];
|
|
51
|
+
}, [lang, weekStartsOn]);
|
|
52
|
+
const monthName = new Intl.DateTimeFormat(lang === "ko" ? "ko-KR" : "en-US", { month: "long" }).format(monthStart);
|
|
53
|
+
const year = monthStart.getFullYear();
|
|
54
|
+
const [focusedDate, setFocusedDate] = useState(selectedDate ?? today);
|
|
55
|
+
const buttons = useRef(new Map<string, HTMLButtonElement>());
|
|
56
|
+
const pendingFocus = useRef<string | null>(null);
|
|
57
|
+
const enabledDays = days.filter(day => showOutsideDays || isSameMonth(day, monthStart));
|
|
58
|
+
const canTabTo = (date: Date | null) => date && enabledDays.some(day => isSameDay(day, date));
|
|
59
|
+
const tabDate = canTabTo(focusedDate) ? focusedDate
|
|
60
|
+
: canTabTo(selectedDate) ? selectedDate
|
|
61
|
+
: isSameMonth(today, monthStart) ? today : monthStart;
|
|
62
|
+
|
|
63
|
+
useLayoutEffect(() => {
|
|
64
|
+
if (!pendingFocus.current) return;
|
|
65
|
+
const target = buttons.current.get(pendingFocus.current);
|
|
66
|
+
if (target) {
|
|
67
|
+
target.focus();
|
|
68
|
+
pendingFocus.current = null;
|
|
69
|
+
}
|
|
70
|
+
}, [monthStart, showOutsideDays, weekStartsOn]);
|
|
71
|
+
|
|
72
|
+
const focusDay = (date: Date) => {
|
|
73
|
+
setFocusedDate(date);
|
|
74
|
+
if (!isSameMonth(date, monthStart) && onMonthChange) {
|
|
75
|
+
pendingFocus.current = formatISODate(date);
|
|
76
|
+
onMonthChange(startOfMonth(date));
|
|
77
|
+
} else {
|
|
78
|
+
buttons.current.get(formatISODate(date))?.focus();
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const handleKey = (event: KeyboardEvent<HTMLButtonElement>, day: Date) => {
|
|
82
|
+
let next: Date;
|
|
83
|
+
switch (event.key) {
|
|
84
|
+
case "ArrowLeft": next = addDays(day, -1); break;
|
|
85
|
+
case "ArrowRight": next = addDays(day, 1); break;
|
|
86
|
+
case "ArrowUp": next = addDays(day, -7); break;
|
|
87
|
+
case "ArrowDown": next = addDays(day, 7); break;
|
|
88
|
+
case "Home": next = startOfWeek(day, weekStartsOn); break;
|
|
89
|
+
case "End": next = addDays(startOfWeek(day, weekStartsOn), 6); break;
|
|
90
|
+
case "PageUp":
|
|
91
|
+
case "PageDown": {
|
|
92
|
+
const target = addMonths(startOfMonth(day), event.key === "PageUp" ? -1 : 1);
|
|
93
|
+
next = new Date(target.getFullYear(), target.getMonth(), Math.min(day.getDate(), endOfMonth(target).getDate()));
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
default: return;
|
|
97
|
+
}
|
|
98
|
+
event.preventDefault();
|
|
99
|
+
focusDay(next);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
return (
|
|
103
|
+
<div ref={ref} className={[styles.root, className].filter(Boolean).join(" ")} data-slot="mini-calendar-root" data-variant={variant} data-color={color} data-size={size} role="group" aria-label={`${monthName} ${year}`} {...rest}>
|
|
104
|
+
<div className={styles.header}>
|
|
105
|
+
<div className={styles.heading} aria-live="polite">
|
|
106
|
+
<span className={styles.month}>{monthName}</span>
|
|
107
|
+
<span className={styles.year}>{year}</span>
|
|
108
|
+
</div>
|
|
109
|
+
<div className={styles.navigation}>
|
|
110
|
+
<IconButton size="sm" variant="ghost" icon={<Icon name="caret-left" />} aria-label={labels.previous} disabled={disabled} onClick={() => onMonthChange?.(addMonths(monthStart, -1))} />
|
|
111
|
+
<IconButton size="sm" variant="ghost" icon={<Icon name="caret-right" />} aria-label={labels.next} disabled={disabled} onClick={() => onMonthChange?.(addMonths(monthStart, 1))} />
|
|
112
|
+
</div>
|
|
113
|
+
</div>
|
|
114
|
+
<div className={styles.weekdays} aria-hidden="true">
|
|
115
|
+
{weekdays.map(name => <span key={name} className={styles.weekday}>{name}</span>)}
|
|
116
|
+
</div>
|
|
117
|
+
<div className={styles.days}>
|
|
118
|
+
{days.map(day => {
|
|
119
|
+
const key = formatISODate(day);
|
|
120
|
+
const outside = !isSameMonth(day, monthStart);
|
|
121
|
+
if (outside && !showOutsideDays) return <div key={key} className={styles.blank} aria-hidden="true" />;
|
|
122
|
+
const selected = isSameDay(day, selectedDate);
|
|
123
|
+
const isToday = isSameDay(day, today);
|
|
124
|
+
const hasEvents = events.has(key);
|
|
125
|
+
return (
|
|
126
|
+
<Button
|
|
127
|
+
key={key}
|
|
128
|
+
ref={node => { if (node) buttons.current.set(key, node); else buttons.current.delete(key); }}
|
|
129
|
+
variant="ghost"
|
|
130
|
+
size="lg"
|
|
131
|
+
className={styles.day}
|
|
132
|
+
data-date={key}
|
|
133
|
+
data-outside={outside || undefined}
|
|
134
|
+
data-previous-month={outside && day.getTime() < monthStart.getTime() || undefined}
|
|
135
|
+
data-past={key < todayKey || undefined}
|
|
136
|
+
data-selected={selected || undefined}
|
|
137
|
+
data-today={isToday || undefined}
|
|
138
|
+
aria-label={`${formatDate(day, "long", lang)}${hasEvents ? `, ${labels.hasEvents}` : ""}`}
|
|
139
|
+
aria-pressed={selected}
|
|
140
|
+
aria-current={isToday ? "date" : undefined}
|
|
141
|
+
disabled={disabled}
|
|
142
|
+
tabIndex={isSameDay(day, tabDate) ? 0 : -1}
|
|
143
|
+
onFocus={() => setFocusedDate(day)}
|
|
144
|
+
onKeyDown={event => handleKey(event, day)}
|
|
145
|
+
onClick={() => {
|
|
146
|
+
setFocusedDate(day);
|
|
147
|
+
onSelectedDateChange?.(day);
|
|
148
|
+
if (outside) onMonthChange?.(startOfMonth(day));
|
|
149
|
+
}}
|
|
150
|
+
>
|
|
151
|
+
<span className={styles.dayContent} aria-hidden="true">
|
|
152
|
+
<span className={styles.marker} data-event={hasEvents || undefined} />
|
|
153
|
+
<span className={styles.dayNumber}>{day.getDate()}</span>
|
|
154
|
+
</span>
|
|
155
|
+
</Button>
|
|
156
|
+
);
|
|
157
|
+
})}
|
|
158
|
+
</div>
|
|
159
|
+
</div>
|
|
160
|
+
);
|
|
161
|
+
});
|