@conscience-technology/ovenn 0.7.0 → 0.7.3
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 +21 -0
- package/assets/components/AIMessage/AIMessage.tsx +27 -7
- package/assets/components/AttachmentItem/AttachmentItem.module.css +41 -10
- package/assets/components/AttachmentItem/AttachmentItem.tsx +25 -8
- package/assets/components/AttachmentThumb/AttachmentThumb.module.css +9 -10
- package/assets/components/Button/Button.module.css +19 -0
- package/assets/components/Callout/Callout.module.css +53 -7
- package/assets/components/Callout/Callout.tsx +26 -2
- package/assets/components/Callout/index.ts +1 -1
- package/assets/components/ChatComposer/ChatComposer.module.css +17 -0
- package/assets/components/ChatComposer/ChatComposer.tsx +131 -0
- package/assets/components/ChatComposer/index.ts +2 -0
- package/assets/components/ChatInput/ChatInput.module.css +192 -30
- package/assets/components/ChatInput/ChatInput.tsx +137 -45
- package/assets/components/ChatInput/SendButton.tsx +4 -1
- package/assets/components/ChatInput/index.ts +5 -0
- package/assets/components/ChatMessage/ChatMessage.module.css +19 -0
- package/assets/components/ChatMessage/ChatMessage.tsx +63 -0
- package/assets/components/ChatMessage/index.ts +2 -0
- package/assets/components/ChatReactions/ChatReactions.module.css +15 -0
- package/assets/components/ChatReactions/ChatReactions.tsx +58 -0
- package/assets/components/ChatReactions/index.ts +2 -0
- package/assets/components/CodeBlock/CodeBlock.module.css +106 -10
- package/assets/components/CodeBlock/CodeBlock.tsx +114 -29
- package/assets/components/CodeBlock/SyntaxHighlight.tsx +20 -0
- package/assets/components/CodeBlock/diff-lines.ts +21 -0
- package/assets/components/CodeBlock/index.ts +2 -1
- package/assets/components/CodeBlock/line-preview.ts +7 -0
- package/assets/components/CodeBlock/syntax-highlighter.ts +96 -0
- package/assets/components/CodeBlock/use-syntax-tokens.ts +17 -0
- package/assets/components/ColorField/ColorField.module.css +19 -196
- package/assets/components/ColorField/ColorField.tsx +116 -109
- package/assets/components/Combobox/Combobox.module.css +21 -4
- package/assets/components/Combobox/Combobox.tsx +37 -21
- package/assets/components/CommandPalette/CommandPalette.module.css +1 -1
- package/assets/components/ControlGroup/ControlGroup.module.css +13 -6
- package/assets/components/DatePicker/DateField.tsx +72 -25
- package/assets/components/DatePicker/DatePicker.module.css +28 -59
- package/assets/components/DatePicker/DatePicker.tsx +76 -40
- package/assets/components/Drawer/Drawer.module.css +12 -15
- package/assets/components/Drawer/Drawer.tsx +15 -23
- package/assets/components/EmojiPicker/EmojiGlyph.module.css +2 -0
- package/assets/components/EmojiPicker/EmojiGlyph.tsx +12 -0
- package/assets/components/EmojiPicker/EmojiPicker.module.css +43 -0
- package/assets/components/EmojiPicker/EmojiPicker.tsx +143 -0
- package/assets/components/EmojiPicker/UNICODE-LICENSE.txt +39 -0
- package/assets/components/EmojiPicker/data.ts +41 -0
- package/assets/components/EmojiPicker/emojiData-0.json +1 -0
- package/assets/components/EmojiPicker/emojiData-1.json +1 -0
- package/assets/components/EmojiPicker/emojiData-2.json +1 -0
- package/assets/components/EmojiPicker/emojiData-3.json +1 -0
- package/assets/components/EmojiPicker/emojiData.sources.json +35 -0
- package/assets/components/EmojiPicker/emojiData.ts +8 -0
- package/assets/components/EmojiPicker/emojiFallbacks.json +1 -0
- package/assets/components/EmojiPicker/index.ts +4 -0
- package/assets/components/EmptyState/EmptyState.module.css +2 -2
- package/assets/components/FileIcon/FileIcon.module.css +4 -6
- package/assets/components/Icon/LucideFamilyIcon.tsx +2 -0
- package/assets/components/Icon/SolarFamilyIcon.tsx +4 -0
- package/assets/components/Input/Input.module.css +33 -10
- package/assets/components/Input/Input.tsx +20 -9
- package/assets/components/MessageActions/MessageActions.module.css +2 -2
- package/assets/components/Onboarding/Onboarding.module.css +1 -1
- package/assets/components/ProgressBar/ProgressBar.module.css +38 -4
- package/assets/components/ProgressBar/ProgressBar.tsx +5 -1
- package/assets/components/RadioCard/RadioCard.module.css +18 -0
- package/assets/components/RadioCard/RadioCard.tsx +48 -7
- package/assets/components/Select/Select.module.css +9 -7
- package/assets/components/Select/Select.tsx +15 -2
- package/assets/components/Tabs/Tabs.module.css +1 -1
- package/assets/components/Tabs/Tabs.tsx +2 -2
- package/assets/components/Textarea/Textarea.module.css +28 -231
- package/assets/components/Textarea/Textarea.tsx +2 -2
- package/assets/components/TimePicker/TimePicker.module.css +16 -4
- package/assets/components/TimePicker/TimePicker.tsx +66 -8
- package/assets/components/Toast/Toast.module.css +18 -0
- package/assets/components/Toast/Toast.tsx +1 -1
- package/assets/components/Tooltip/Tooltip.tsx +33 -7
- package/assets/components/UserMessage/UserMessage.module.css +110 -1
- package/assets/components/UserMessage/UserMessage.tsx +138 -16
- package/assets/components/UserMessage/index.ts +4 -0
- package/assets/components/_data.ts +10 -5
- package/assets/components/_utils.css +31 -5
- package/assets/components/component-registry.json +1595 -107
- package/assets/components/index.ts +7 -0
- package/assets/components/tokens.css +83 -0
- package/assets/prompts/ASSEMBLY.md +11 -0
- package/assets/prompts/CATALOG.md +110 -106
- package/assets/prompts/PRINCIPLES.md +11 -1
- package/assets/prompts/TEMPLATE_PREVIEWS.md +21 -0
- package/assets/prompts/WORKFLOW_DESIGN.md +2 -0
- package/assets/prompts/axes/font.md +6 -0
- package/assets/prompts/axes/material.md +1 -1
- package/assets/prompts/axes/motion.md +2 -0
- package/assets/prompts/axes/palette.md +9 -2
- package/assets/prompts/axes/voice.md +4 -0
- package/assets/prompts/components/README.md +3 -3
- package/assets/prompts/components/_variants.md +35 -35
- package/assets/prompts/components/accordion.md +15 -15
- package/assets/prompts/components/ai-message.md +14 -12
- package/assets/prompts/components/app-frame.md +16 -16
- package/assets/prompts/components/attachment-item.md +36 -30
- package/assets/prompts/components/attachment-thumb.md +14 -12
- package/assets/prompts/components/avatar-upload.md +10 -10
- package/assets/prompts/components/avatar.md +16 -16
- package/assets/prompts/components/badge.md +4 -4
- package/assets/prompts/components/breadcrumb.md +24 -24
- package/assets/prompts/components/bubble.md +13 -13
- package/assets/prompts/components/button-group.md +1 -1
- package/assets/prompts/components/button.md +37 -36
- package/assets/prompts/components/calendar.md +29 -29
- package/assets/prompts/components/callout.md +39 -23
- package/assets/prompts/components/canvas-edge.md +5 -2
- package/assets/prompts/components/canvas-node.md +3 -3
- package/assets/prompts/components/canvas.md +5 -2
- package/assets/prompts/components/card.md +21 -21
- package/assets/prompts/components/chart-bar.md +7 -7
- package/assets/prompts/components/chart-pie.md +3 -3
- package/assets/prompts/components/chart-radar.md +3 -3
- package/assets/prompts/components/chart-radial.md +4 -4
- package/assets/prompts/components/chat-composer.md +71 -0
- package/assets/prompts/components/chat-input.md +82 -27
- package/assets/prompts/components/chat-message.md +48 -0
- package/assets/prompts/components/chat-reactions.md +38 -0
- package/assets/prompts/components/checkbox-card.md +3 -3
- package/assets/prompts/components/checkbox.md +17 -17
- package/assets/prompts/components/chip.md +32 -32
- package/assets/prompts/components/code-block.md +109 -66
- package/assets/prompts/components/code.md +4 -4
- package/assets/prompts/components/color-area.md +9 -9
- package/assets/prompts/components/color-field.md +17 -13
- package/assets/prompts/components/color-picker.md +6 -6
- package/assets/prompts/components/color-slider.md +8 -8
- package/assets/prompts/components/color-swatch-picker.md +8 -8
- package/assets/prompts/components/color-swatch.md +9 -9
- package/assets/prompts/components/combobox.md +5 -2
- package/assets/prompts/components/command-palette.md +26 -26
- package/assets/prompts/components/comment.md +5 -2
- package/assets/prompts/components/context-menu.md +22 -22
- package/assets/prompts/components/control-group.md +4 -4
- package/assets/prompts/components/date-picker.md +31 -23
- package/assets/prompts/components/disclosure.md +10 -10
- package/assets/prompts/components/drawer.md +19 -18
- package/assets/prompts/components/dropdown-menu.md +21 -21
- package/assets/prompts/components/emoji-picker.md +45 -0
- package/assets/prompts/components/empty-state.md +20 -18
- package/assets/prompts/components/event-chip.md +11 -11
- package/assets/prompts/components/event-list-item.md +21 -21
- package/assets/prompts/components/file-icon.md +18 -19
- package/assets/prompts/components/gallery-item.md +19 -19
- package/assets/prompts/components/generated-image.md +10 -10
- package/assets/prompts/components/hint.md +19 -19
- package/assets/prompts/components/icon-button.md +16 -16
- package/assets/prompts/components/icon.md +12 -9
- package/assets/prompts/components/input.md +49 -46
- package/assets/prompts/components/kanban.md +34 -34
- package/assets/prompts/components/list-item.md +39 -39
- package/assets/prompts/components/menu-item.md +41 -41
- package/assets/prompts/components/message-actions.md +6 -6
- package/assets/prompts/components/message-quote.md +7 -7
- package/assets/prompts/components/message-sources.md +10 -10
- package/assets/prompts/components/message-state.md +17 -17
- package/assets/prompts/components/message-table.md +5 -5
- package/assets/prompts/components/mini-calendar.md +6 -1
- package/assets/prompts/components/modal.md +39 -39
- package/assets/prompts/components/multi-select.md +4 -1
- package/assets/prompts/components/onboarding.md +19 -19
- package/assets/prompts/components/page-header.md +31 -31
- package/assets/prompts/components/pagination.md +17 -17
- package/assets/prompts/components/progress-bar.md +14 -11
- package/assets/prompts/components/quotation-bar.md +10 -10
- package/assets/prompts/components/radio-card.md +7 -6
- package/assets/prompts/components/radio.md +9 -9
- package/assets/prompts/components/select.md +28 -25
- package/assets/prompts/components/shortcut.md +11 -11
- package/assets/prompts/components/sidebar.md +56 -56
- package/assets/prompts/components/skeleton.md +7 -4
- package/assets/prompts/components/slider.md +18 -18
- package/assets/prompts/components/spinner.md +16 -16
- package/assets/prompts/components/stepper.md +14 -14
- package/assets/prompts/components/switch.md +19 -20
- package/assets/prompts/components/tab-strip.md +31 -31
- package/assets/prompts/components/table-cell.md +4 -4
- package/assets/prompts/components/table-header.md +16 -16
- package/assets/prompts/components/table-row-edit.md +19 -19
- package/assets/prompts/components/table-row-select.md +9 -9
- package/assets/prompts/components/table-row.md +18 -18
- package/assets/prompts/components/tabs.md +26 -25
- package/assets/prompts/components/tag.md +6 -6
- package/assets/prompts/components/textarea.md +16 -15
- package/assets/prompts/components/time-picker.md +21 -14
- package/assets/prompts/components/timeline-view.md +4 -4
- package/assets/prompts/components/toast.md +42 -41
- package/assets/prompts/components/toolbar.md +23 -23
- package/assets/prompts/components/tooltip.md +15 -14
- package/assets/prompts/components/top-loader.md +11 -11
- package/assets/prompts/components/topbar.md +35 -35
- package/assets/prompts/components/tree-nav.md +9 -9
- package/assets/prompts/components/user-message.md +23 -12
- package/assets/prompts/design-examples/README.md +1 -1
- package/assets/prompts/design-examples/ai-chat-full-page.png +0 -0
- package/assets/prompts/design-examples/catalog.json +124 -1
- package/assets/prompts/design-examples/sources/ai-chat-full-page/ChatExperience.module.css +346 -0
- package/assets/prompts/design-examples/sources/ai-chat-full-page/ChatExperience.tsx +375 -0
- package/assets/prompts/design-examples/sources/ai-chat-full-page/FullPageChat.tsx +8 -0
- package/assets/prompts/design-examples/sources/ai-chat-full-page/REFERENCE.md +19 -0
- package/assets/prompts/design-examples/sources/ai-chat-full-page/useChatDemo.ts +139 -0
- package/assets/prompts/design-examples/sources/ai-chat-full-page/useDemoTextStream.ts +30 -0
- package/assets/prompts/primitives/emerge.md +2 -0
- package/assets/prompts/templates/README.md +1 -1
- package/assets/prompts/templates/ains.md +7 -0
- package/assets/prompts/templates/minimal.md +6 -0
- package/assets/prompts/templates/onboarding.md +156 -0
- package/assets/prompts/templates/workspace.md +13 -8
- package/assets/prompts/tokens/color.md +7 -2
- package/assets/prompts/tokens/radius.md +22 -0
- package/assets/prompts/use-cases/chart-chart-area.md +40 -40
- package/assets/prompts/use-cases/chart-chart-bar.md +34 -34
- package/assets/prompts/use-cases/chart-chart-pie.md +14 -14
- package/assets/prompts/use-cases/chart-chart-radar.md +24 -24
- package/assets/prompts/use-cases/chart-chart-radial.md +14 -14
- package/assets/prompts/use-cases/chart-segmented-chart.md +32 -32
- package/assets/prompts/use-cases/chat-chat-composer.md +529 -0
- package/assets/prompts/use-cases/chat-chat-input.md +1766 -0
- package/assets/prompts/use-cases/data-comment.md +39 -39
- package/assets/prompts/use-cases/data-data-table.md +34 -34
- package/assets/prompts/use-cases/data-list-item.md +16 -16
- package/assets/prompts/use-cases/data-metric-card.md +18 -18
- package/assets/prompts/use-cases/data-table-row.md +19 -19
- package/assets/prompts/use-cases/data-table-toolbar.md +10 -10
- package/assets/prompts/use-cases/feedback-drawer.md +35 -30
- package/assets/prompts/use-cases/feedback-progress-bar.md +23 -18
- package/assets/prompts/use-cases/general-toolbar.md +16 -16
- package/assets/prompts/use-cases/general-tooltip.md +26 -26
- package/assets/prompts/use-cases/input-checkbox.md +27 -27
- package/assets/prompts/use-cases/structure-card.md +9 -9
- package/assets/prompts/use-cases/structure-page-header.md +17 -17
- package/assets/prompts/use-cases/structure-sidebar.md +20 -20
- package/assets/prompts/use-cases/structure-topbar.md +38 -42
- package/assets/skills/ovenn-wireframe/SKILL.md +17 -4
- package/package.json +6 -2
- package/src/utils/design-examples.js +3 -4
- package/assets/prompts/templates/glass-button.md +0 -337
|
@@ -1,176 +1,32 @@
|
|
|
1
|
-
/*
|
|
1
|
+
/* Shared Input shell; multiline content owns its padding and natural height. */
|
|
2
2
|
.root {
|
|
3
|
-
|
|
3
|
+
composes: root from "../Input/Input.module.css";
|
|
4
4
|
align-items: stretch;
|
|
5
5
|
gap: var(--space-2);
|
|
6
|
-
font-family: var(--font-normal);
|
|
7
|
-
color: var(--fg);
|
|
8
|
-
border: 1px solid var(--border);
|
|
9
|
-
corner-shape: var(--corner-shape);
|
|
10
|
-
border-radius: var(--radius-sm);
|
|
11
|
-
cursor: text;
|
|
12
|
-
/* tokens.css 룰: 인터랙티브 컴포넌트는 반드시 --transition-* 토큰 경유. */
|
|
13
|
-
transition: var(--transition-colors), var(--transition-ring);
|
|
14
|
-
min-width: 0;
|
|
15
6
|
position: relative;
|
|
16
|
-
/* scroll clip이 root border-radius에서 끊기도록. textarea 상·하 padding이
|
|
17
|
-
content box에 있어 scroll 시 글이 자연스레 흐르고, root 경계 밖은 숨김. */
|
|
18
7
|
overflow: hidden;
|
|
19
8
|
}
|
|
20
|
-
|
|
21
|
-
.
|
|
22
|
-
.
|
|
23
|
-
.
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.
|
|
28
|
-
.root:has(:focus-visible) {
|
|
29
|
-
outline: none;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/* Variants ──────────────────────────────────────────────── */
|
|
33
|
-
.outline {
|
|
34
|
-
background: transparent;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.filled {
|
|
38
|
-
background: var(--bg-subtle);
|
|
39
|
-
border-color: transparent;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.filled:hover:not([data-disabled]):not([data-readonly]),
|
|
43
|
-
.filled:focus-visible,
|
|
44
|
-
.filled:has(:focus-visible) {
|
|
45
|
-
background: var(--bg-muted);
|
|
46
|
-
border-color: transparent;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/* line — 아래 선만. */
|
|
50
|
-
.root.line {
|
|
51
|
-
background: transparent;
|
|
52
|
-
border-color: transparent;
|
|
53
|
-
border-bottom-color: var(--border);
|
|
54
|
-
corner-shape: var(--corner-shape);
|
|
55
|
-
border-radius: 0;
|
|
56
|
-
padding-inline: 0;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.root.line:hover:not([data-disabled]):not([data-readonly]),
|
|
60
|
-
.root.line:focus-visible,
|
|
61
|
-
.root.line:has(:focus-visible) {
|
|
62
|
-
border-color: transparent;
|
|
63
|
-
border-bottom-color: var(--border-strong);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
.root.line[data-invalid],
|
|
67
|
-
.root.line[data-invalid]:hover:not([data-disabled]):not([data-readonly]),
|
|
68
|
-
.root.line[data-invalid]:focus-visible,
|
|
69
|
-
.root.line[data-invalid]:has(:focus-visible) {
|
|
70
|
-
border-color: transparent;
|
|
71
|
-
border-bottom-color: var(--destructive);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/* States ────────────────────────────────────────────────── */
|
|
75
|
-
.root[data-invalid] {
|
|
76
|
-
border-color: var(--destructive);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
.root[data-invalid]:hover:not([data-disabled]):not([data-readonly]),
|
|
80
|
-
.root[data-invalid]:focus-visible,
|
|
81
|
-
.root[data-invalid]:has(:focus-visible) {
|
|
82
|
-
border-color: var(--destructive);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
.root[data-disabled] {
|
|
86
|
-
cursor: not-allowed;
|
|
87
|
-
opacity: 0.5;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
.root[data-readonly] {
|
|
91
|
-
background: var(--bg-subtle);
|
|
92
|
-
cursor: default;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
.root[data-readonly].filled {
|
|
96
|
-
background: var(--bg-muted);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/* Width fill */
|
|
100
|
-
.fill {
|
|
101
|
-
width: 100%;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/* Sizes ─────────────────────────────────────────────────────
|
|
105
|
-
Scroll 규칙 ([[project_scroll_rule]]): root에 상·하 padding이 있으면 textarea 스크롤 시
|
|
106
|
-
padding이 "비어있는 띠"로 고정돼 글이 그 안쪽에서 끊긴 것처럼 보임.
|
|
107
|
-
→ root는 padding 0 + overflow hidden + border-radius로 scroll clip 담당,
|
|
108
|
-
textarea 자체가 상·하·좌·우 padding 전부 가져서 scrollable content box에 포함.
|
|
109
|
-
스크롤바는 전역에서 하이드([[feedback_scrollbar_always_hidden]])라 폭 고민 없음. */
|
|
110
|
-
.sizeSm {
|
|
111
|
-
padding: 0;
|
|
112
|
-
font-size: var(--text-sm);
|
|
113
|
-
corner-shape: var(--corner-shape);
|
|
114
|
-
border-radius: var(--radius-xs);
|
|
115
|
-
gap: var(--space-1);
|
|
116
|
-
}
|
|
117
|
-
.sizeSm .textarea { padding: var(--space-1_5) var(--space-2); }
|
|
118
|
-
|
|
119
|
-
.sizeMd {
|
|
120
|
-
padding: 0;
|
|
121
|
-
font-size: var(--text-sm);
|
|
122
|
-
corner-shape: var(--corner-shape);
|
|
123
|
-
border-radius: var(--radius-sm);
|
|
124
|
-
}
|
|
9
|
+
.outline { composes: outline from "../Input/Input.module.css"; }
|
|
10
|
+
.filled { composes: filled from "../Input/Input.module.css"; }
|
|
11
|
+
.line { composes: line from "../Input/Input.module.css"; }
|
|
12
|
+
.fill { composes: fill from "../Input/Input.module.css"; }
|
|
13
|
+
.sizeSm { composes: sizeSm from "../Input/Input.module.css"; height: auto; padding: 0; }
|
|
14
|
+
.sizeMd { composes: sizeMd from "../Input/Input.module.css"; height: auto; padding: 0; }
|
|
15
|
+
.sizeLg { composes: sizeLg from "../Input/Input.module.css"; height: auto; padding: 0; }
|
|
16
|
+
.sizeSm .textarea { padding: var(--space-1_5) var(--space-3); }
|
|
125
17
|
.sizeMd .textarea { padding: var(--space-2) var(--space-3); }
|
|
126
|
-
|
|
127
|
-
.
|
|
128
|
-
padding: 0;
|
|
129
|
-
font-size: var(--text-base);
|
|
130
|
-
corner-shape: var(--corner-shape);
|
|
131
|
-
border-radius: var(--radius-md);
|
|
132
|
-
}
|
|
133
|
-
.sizeLg .textarea { padding: var(--space-2_5) var(--space-3); }
|
|
134
|
-
|
|
135
|
-
/* line variant는 좌우 padding 없음 — textarea도 좌우 0, 상하만 유지. */
|
|
136
|
-
.root.line .sizeSm .textarea,
|
|
137
|
-
.root.line.sizeSm .textarea { padding-inline: 0; }
|
|
138
|
-
.root.line .sizeMd .textarea,
|
|
139
|
-
.root.line.sizeMd .textarea { padding-inline: 0; }
|
|
140
|
-
.root.line .sizeLg .textarea,
|
|
141
|
-
.root.line.sizeLg .textarea { padding-inline: 0; }
|
|
142
|
-
|
|
143
|
-
/* Inner textarea ────────────────────────────────────────── */
|
|
18
|
+
.sizeLg .textarea { padding: var(--space-2_5) calc(var(--space-3) + var(--space-0_5)); }
|
|
19
|
+
.root.line .textarea { padding-inline: 0; }
|
|
144
20
|
.textarea {
|
|
145
|
-
|
|
146
|
-
min-width: 0;
|
|
21
|
+
composes: input from "../Input/Input.module.css";
|
|
147
22
|
width: 100%;
|
|
148
|
-
|
|
149
|
-
border: 0;
|
|
150
|
-
background: transparent;
|
|
151
|
-
color: inherit;
|
|
152
|
-
font-family: inherit;
|
|
153
|
-
font-size: inherit;
|
|
23
|
+
height: auto;
|
|
154
24
|
line-height: var(--lh-base);
|
|
155
|
-
outline: none;
|
|
156
|
-
/* 브라우저 기본 그립 대신 커스텀 핸들 사용. */
|
|
157
25
|
resize: none;
|
|
158
26
|
display: block;
|
|
27
|
+
box-sizing: border-box;
|
|
159
28
|
}
|
|
160
|
-
|
|
161
|
-
.textarea::placeholder {
|
|
162
|
-
color: var(--fg-subtle);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
.textarea:disabled {
|
|
166
|
-
cursor: not-allowed;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/* autoResize 모드 — 사용자 조작 없이 컨텐츠 높이 따라감. */
|
|
170
|
-
.autoResize .textarea {
|
|
171
|
-
overflow: hidden;
|
|
172
|
-
}
|
|
173
|
-
|
|
29
|
+
.autoResize .textarea { overflow: hidden; }
|
|
174
30
|
/* Custom resize handle ─────────────────────────────────────
|
|
175
31
|
Minimalist grabber — bottom-center에 걸치는 얇은 캡슐 하나.
|
|
176
32
|
- hit-area는 넉넉하게(--space-6 × --space-3), 시각 요소는 매우 얇게
|
|
@@ -225,7 +81,8 @@
|
|
|
225
81
|
outline: none;
|
|
226
82
|
corner-shape: var(--corner-shape);
|
|
227
83
|
border-radius: var(--radius-full);
|
|
228
|
-
box-shadow:
|
|
84
|
+
box-shadow: none;
|
|
85
|
+
background: var(--hover);
|
|
229
86
|
}
|
|
230
87
|
.handle:focus-visible::before {
|
|
231
88
|
opacity: 1;
|
|
@@ -278,73 +135,13 @@
|
|
|
278
135
|
color: var(--destructive);
|
|
279
136
|
}
|
|
280
137
|
|
|
281
|
-
/*
|
|
282
|
-
.field {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
.
|
|
290
|
-
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
.label {
|
|
294
|
-
display: inline-flex;
|
|
295
|
-
align-items: center;
|
|
296
|
-
gap: var(--space-1);
|
|
297
|
-
font-family: var(--font-normal);
|
|
298
|
-
font-weight: var(--font-weight-medium);
|
|
299
|
-
color: var(--fg-muted);
|
|
300
|
-
transition: color var(--duration-fast) var(--ease-out);
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
.labelSm { font-size: var(--text-xs); }
|
|
304
|
-
.labelMd,
|
|
305
|
-
.labelLg { font-size: var(--text-sm); }
|
|
306
|
-
|
|
307
|
-
.field:focus-within .label {
|
|
308
|
-
color: var(--fg);
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
.requiredMark {
|
|
312
|
-
color: var(--destructive);
|
|
313
|
-
font-weight: var(--font-weight-medium);
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
.description,
|
|
317
|
-
.errorText {
|
|
318
|
-
margin: 0;
|
|
319
|
-
display: inline-flex;
|
|
320
|
-
align-items: center;
|
|
321
|
-
gap: var(--space-1);
|
|
322
|
-
font-family: var(--font-normal);
|
|
323
|
-
font-size: var(--text-xs);
|
|
324
|
-
line-height: var(--lh-xs);
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
.description {
|
|
328
|
-
color: var(--fg-muted);
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
.errorText {
|
|
332
|
-
color: var(--destructive);
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
.messageIcon {
|
|
336
|
-
flex: 0 0 auto;
|
|
337
|
-
display: inline-flex;
|
|
338
|
-
align-items: center;
|
|
339
|
-
justify-content: center;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
/* Keyboard focus must remain visible independently of hover and field variant. */
|
|
343
|
-
.root:focus-visible,
|
|
344
|
-
.root:has(:focus-visible) {
|
|
345
|
-
box-shadow: var(--ring-shadow-field);
|
|
346
|
-
}
|
|
347
|
-
.root[data-invalid]:focus-visible,
|
|
348
|
-
.root[data-invalid]:has(:focus-visible) {
|
|
349
|
-
box-shadow: var(--ring-shadow-field-invalid);
|
|
350
|
-
}
|
|
138
|
+
/* Shared field labels and messages. */
|
|
139
|
+
.field { composes: field from "../Input/Input.module.css"; }
|
|
140
|
+
.label { composes: label from "../Input/Input.module.css"; }
|
|
141
|
+
.labelSm { composes: labelSm from "../Input/Input.module.css"; }
|
|
142
|
+
.labelMd { composes: labelMd from "../Input/Input.module.css"; }
|
|
143
|
+
.labelLg { composes: labelLg from "../Input/Input.module.css"; }
|
|
144
|
+
.requiredMark { composes: requiredMark from "../Input/Input.module.css"; }
|
|
145
|
+
.description { composes: description from "../Input/Input.module.css"; }
|
|
146
|
+
.errorText { composes: errorText from "../Input/Input.module.css"; }
|
|
147
|
+
.messageIcon { composes: messageIcon from "../Input/Input.module.css"; }
|
|
@@ -133,7 +133,7 @@ export const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
|
133
133
|
|
|
134
134
|
const autoId = useId();
|
|
135
135
|
const textareaId = id ?? autoId;
|
|
136
|
-
const descriptionId = description != null ? `${textareaId}-desc` : undefined;
|
|
136
|
+
const descriptionId = description != null && !hasWarning ? `${textareaId}-desc` : undefined;
|
|
137
137
|
const warningId = hasWarning ? `${textareaId}-warn` : undefined;
|
|
138
138
|
const describedBy =
|
|
139
139
|
[props["aria-describedby"], warningId, descriptionId].filter(Boolean).join(" ") || undefined;
|
|
@@ -342,8 +342,8 @@ export const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
|
342
342
|
readOnly={readOnly}
|
|
343
343
|
required={required}
|
|
344
344
|
maxLength={maxLength}
|
|
345
|
-
aria-invalid={invalid || undefined}
|
|
346
345
|
{...props}
|
|
346
|
+
aria-invalid={invalid || props["aria-invalid"] || undefined}
|
|
347
347
|
aria-describedby={describedBy}
|
|
348
348
|
/>
|
|
349
349
|
|
|
@@ -31,10 +31,21 @@
|
|
|
31
31
|
position: relative;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
/*
|
|
34
|
+
/* Custom placeholder spans the field until a segment receives focus. */
|
|
35
|
+
.segments:has(.placeholder) { flex: 1; }
|
|
35
36
|
.placeholder {
|
|
36
|
-
|
|
37
|
+
position: absolute;
|
|
38
|
+
inset: 0;
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
color: var(--fg-placeholder);
|
|
42
|
+
pointer-events: none;
|
|
43
|
+
overflow: hidden;
|
|
44
|
+
white-space: nowrap;
|
|
37
45
|
}
|
|
46
|
+
.segments:focus-within .placeholder { display: none; }
|
|
47
|
+
.segments:has(.placeholder):not(:focus-within) .segment::placeholder,
|
|
48
|
+
.segments:has(.placeholder):not(:focus-within) .separator { color: transparent; }
|
|
38
49
|
|
|
39
50
|
/* 개별 세그먼트 input — 숫자만 보이게 고정 폭 + 중앙 정렬. */
|
|
40
51
|
.segment {
|
|
@@ -52,7 +63,7 @@
|
|
|
52
63
|
caret-color: var(--primary);
|
|
53
64
|
}
|
|
54
65
|
.segment::placeholder {
|
|
55
|
-
color: var(--fg-
|
|
66
|
+
color: var(--fg-placeholder);
|
|
56
67
|
}
|
|
57
68
|
.segment:focus::selection,
|
|
58
69
|
.segment::selection {
|
|
@@ -97,7 +108,8 @@
|
|
|
97
108
|
}
|
|
98
109
|
.meridiemBtn:focus-visible {
|
|
99
110
|
outline: none;
|
|
100
|
-
|
|
111
|
+
background: var(--hover);
|
|
112
|
+
color: var(--fg);
|
|
101
113
|
}
|
|
102
114
|
.meridiemBtn:disabled {
|
|
103
115
|
cursor: not-allowed;
|
|
@@ -17,12 +17,17 @@ import {
|
|
|
17
17
|
forwardRef,
|
|
18
18
|
useCallback,
|
|
19
19
|
useEffect,
|
|
20
|
+
useId,
|
|
20
21
|
useRef,
|
|
21
22
|
useState,
|
|
22
23
|
type KeyboardEvent,
|
|
23
24
|
type ReactNode,
|
|
24
25
|
} from "react";
|
|
25
26
|
|
|
27
|
+
import { Icon } from "../Icon";
|
|
28
|
+
import type { InputWidth } from "../Input";
|
|
29
|
+
import { useControlGroupSize } from "../ControlGroup/context";
|
|
30
|
+
import { resolveControlGroupSize } from "../ControlGroup/size";
|
|
26
31
|
import inputStyles from "../Input/Input.module.css";
|
|
27
32
|
import { useTheme } from "../ThemeController";
|
|
28
33
|
import styles from "./TimePicker.module.css";
|
|
@@ -65,6 +70,13 @@ export interface TimePickerProps {
|
|
|
65
70
|
maxTime?: string;
|
|
66
71
|
|
|
67
72
|
disabled?: boolean;
|
|
73
|
+
readOnly?: boolean;
|
|
74
|
+
required?: boolean;
|
|
75
|
+
width?: InputWidth;
|
|
76
|
+
label?: ReactNode;
|
|
77
|
+
description?: ReactNode;
|
|
78
|
+
warning?: ReactNode;
|
|
79
|
+
"aria-describedby"?: string;
|
|
68
80
|
/** 폼 검증 실패 — border·ring destructive 톤. */
|
|
69
81
|
invalid?: boolean;
|
|
70
82
|
size?: TimePickerSize;
|
|
@@ -122,8 +134,10 @@ export const TimePicker = forwardRef<HTMLDivElement, TimePickerProps>(
|
|
|
122
134
|
minTime,
|
|
123
135
|
maxTime,
|
|
124
136
|
disabled = false,
|
|
125
|
-
invalid = false,
|
|
126
|
-
size
|
|
137
|
+
invalid: invalidProp = false,
|
|
138
|
+
size: sizeProp,
|
|
139
|
+
readOnly, required, width = "fill", label, description, warning,
|
|
140
|
+
"aria-describedby": externalDescription,
|
|
127
141
|
variant = "outline",
|
|
128
142
|
prefix,
|
|
129
143
|
suffix,
|
|
@@ -136,6 +150,17 @@ export const TimePicker = forwardRef<HTMLDivElement, TimePickerProps>(
|
|
|
136
150
|
) {
|
|
137
151
|
const { lang } = useTheme();
|
|
138
152
|
const L = TIMEPICKER_LABELS[lang];
|
|
153
|
+
const groupSize = useControlGroupSize();
|
|
154
|
+
const size = resolveControlGroupSize(groupSize, sizeProp, "md");
|
|
155
|
+
const autoId = useId();
|
|
156
|
+
const fieldId = id ?? autoId;
|
|
157
|
+
const hasWarning = warning != null && warning !== false;
|
|
158
|
+
const invalid = Boolean(invalidProp || hasWarning);
|
|
159
|
+
const warningId = `${fieldId}-warning`;
|
|
160
|
+
const descriptionId = `${fieldId}-description`;
|
|
161
|
+
const labelId = `${fieldId}-label`;
|
|
162
|
+
const describedBy = [externalDescription, hasWarning ? warningId : description != null ? descriptionId : null].filter(Boolean).join(" ") || undefined;
|
|
163
|
+
const fieldStyle = { width: width === "fill" ? "100%" : width === "md" ? "var(--input-w-md)" : width === "lg" ? "var(--input-w-lg)" : `${width}px`, maxWidth: "100%" };
|
|
139
164
|
const stepMinutes = clampStep(step);
|
|
140
165
|
const minMin = parseHHMM(minTime);
|
|
141
166
|
const maxMin = parseHHMM(maxTime);
|
|
@@ -168,13 +193,14 @@ export const TimePicker = forwardRef<HTMLDivElement, TimePickerProps>(
|
|
|
168
193
|
|
|
169
194
|
const commit = useCallback(
|
|
170
195
|
(next: TimeValue | null, fromTyping = false) => {
|
|
196
|
+
if (disabled || readOnly) return;
|
|
171
197
|
const normalized = next ? clampToRange(next, minMin, maxMin) : null;
|
|
172
198
|
typedEcho.current = fromTyping
|
|
173
199
|
? { key: normalized ? `${normalized.hours}:${normalized.minutes}` : "empty", is12h }
|
|
174
200
|
: null;
|
|
175
201
|
onChange?.(normalized);
|
|
176
202
|
},
|
|
177
|
-
[onChange, minMin, maxMin, is12h],
|
|
203
|
+
[onChange, minMin, maxMin, is12h, disabled, readOnly],
|
|
178
204
|
);
|
|
179
205
|
|
|
180
206
|
const focusSeg = (seg: Seg) => {
|
|
@@ -210,6 +236,7 @@ export const TimePicker = forwardRef<HTMLDivElement, TimePickerProps>(
|
|
|
210
236
|
);
|
|
211
237
|
|
|
212
238
|
const onHourChange = (raw: string) => {
|
|
239
|
+
if (disabled || readOnly) return;
|
|
213
240
|
const digits = raw.replace(/\D/g, "").slice(-2);
|
|
214
241
|
setDraft((d) => ({ ...d, h: digits }));
|
|
215
242
|
if (digits.length === 2 || (digits.length === 1 && Number(digits) > (is12h ? 1 : 2))) {
|
|
@@ -221,6 +248,7 @@ export const TimePicker = forwardRef<HTMLDivElement, TimePickerProps>(
|
|
|
221
248
|
};
|
|
222
249
|
|
|
223
250
|
const onMinuteChange = (raw: string) => {
|
|
251
|
+
if (disabled || readOnly) return;
|
|
224
252
|
const digits = raw.replace(/\D/g, "").slice(-2);
|
|
225
253
|
setDraft((d) => ({ ...d, m: digits }));
|
|
226
254
|
if (digits.length === 2 || (digits.length === 1 && Number(digits) > 5)) {
|
|
@@ -232,6 +260,7 @@ export const TimePicker = forwardRef<HTMLDivElement, TimePickerProps>(
|
|
|
232
260
|
};
|
|
233
261
|
|
|
234
262
|
const onMeridiemChange = (raw: string) => {
|
|
263
|
+
if (disabled || readOnly) return;
|
|
235
264
|
const char = raw.toUpperCase().replace(/[^AP]/g, "").slice(-1);
|
|
236
265
|
if (!char) return;
|
|
237
266
|
const next: "AM" | "PM" = char === "P" ? "PM" : "AM";
|
|
@@ -239,7 +268,7 @@ export const TimePicker = forwardRef<HTMLDivElement, TimePickerProps>(
|
|
|
239
268
|
};
|
|
240
269
|
|
|
241
270
|
const onSegKeyDown = (seg: Seg) => (e: KeyboardEvent<HTMLInputElement>) => {
|
|
242
|
-
if (disabled) return;
|
|
271
|
+
if (disabled || readOnly) return;
|
|
243
272
|
|
|
244
273
|
if (e.key === "ArrowLeft") {
|
|
245
274
|
const target = e.target as HTMLInputElement;
|
|
@@ -305,6 +334,7 @@ export const TimePicker = forwardRef<HTMLDivElement, TimePickerProps>(
|
|
|
305
334
|
|
|
306
335
|
const rootClass = [
|
|
307
336
|
inputStyles.root,
|
|
337
|
+
inputStyles.fill,
|
|
308
338
|
variantClass,
|
|
309
339
|
sizeClass,
|
|
310
340
|
styles.root,
|
|
@@ -315,16 +345,27 @@ export const TimePicker = forwardRef<HTMLDivElement, TimePickerProps>(
|
|
|
315
345
|
|
|
316
346
|
const empty = !draft.h && !draft.m;
|
|
317
347
|
|
|
318
|
-
|
|
348
|
+
const control = (
|
|
319
349
|
<div
|
|
320
350
|
ref={ref}
|
|
321
|
-
id={
|
|
351
|
+
id={fieldId}
|
|
352
|
+
style={fieldStyle}
|
|
353
|
+
data-control-group-segment={groupSize ? "" : undefined}
|
|
354
|
+
data-readonly={readOnly || undefined}
|
|
355
|
+
aria-describedby={describedBy}
|
|
356
|
+
onClick={(event) => {
|
|
357
|
+
const target = event.target as Element;
|
|
358
|
+
if (disabled || target.closest('input, button, a, [role="button"], [role="link"], [contenteditable="true"]')) return;
|
|
359
|
+
hourRef.current?.focus();
|
|
360
|
+
}}
|
|
322
361
|
className={rootClass}
|
|
362
|
+
data-slot="time-picker"
|
|
323
363
|
data-size={size}
|
|
324
364
|
data-disabled={disabled || undefined}
|
|
325
365
|
data-invalid={invalid || undefined}
|
|
326
366
|
role="group"
|
|
327
|
-
aria-label={ariaLabel ?? L.group}
|
|
367
|
+
aria-label={ariaLabel ?? (label == null ? L.group : undefined)}
|
|
368
|
+
aria-labelledby={ariaLabel == null && label != null ? labelId : undefined}
|
|
328
369
|
>
|
|
329
370
|
{prefix && (
|
|
330
371
|
<div className={styles.slot} data-slot="prefix">
|
|
@@ -339,6 +380,7 @@ export const TimePicker = forwardRef<HTMLDivElement, TimePickerProps>(
|
|
|
339
380
|
)}
|
|
340
381
|
<input
|
|
341
382
|
ref={hourRef}
|
|
383
|
+
id={`${fieldId}-hour`}
|
|
342
384
|
className={styles.segment}
|
|
343
385
|
type="text"
|
|
344
386
|
inputMode="numeric"
|
|
@@ -346,6 +388,10 @@ export const TimePicker = forwardRef<HTMLDivElement, TimePickerProps>(
|
|
|
346
388
|
value={draft.h}
|
|
347
389
|
placeholder="00"
|
|
348
390
|
disabled={disabled}
|
|
391
|
+
readOnly={readOnly}
|
|
392
|
+
required={required}
|
|
393
|
+
aria-invalid={invalid || undefined}
|
|
394
|
+
aria-describedby={describedBy}
|
|
349
395
|
aria-label={L.hour}
|
|
350
396
|
onChange={(e) => onHourChange(e.target.value)}
|
|
351
397
|
onBlur={() => setDraft((current) => ({ ...current,
|
|
@@ -359,6 +405,7 @@ export const TimePicker = forwardRef<HTMLDivElement, TimePickerProps>(
|
|
|
359
405
|
</span>
|
|
360
406
|
<input
|
|
361
407
|
ref={minuteRef}
|
|
408
|
+
id={`${fieldId}-minute`}
|
|
362
409
|
className={styles.segment}
|
|
363
410
|
type="text"
|
|
364
411
|
inputMode="numeric"
|
|
@@ -366,6 +413,10 @@ export const TimePicker = forwardRef<HTMLDivElement, TimePickerProps>(
|
|
|
366
413
|
value={draft.m}
|
|
367
414
|
placeholder="00"
|
|
368
415
|
disabled={disabled}
|
|
416
|
+
readOnly={readOnly}
|
|
417
|
+
required={required}
|
|
418
|
+
aria-invalid={invalid || undefined}
|
|
419
|
+
aria-describedby={describedBy}
|
|
369
420
|
aria-label={L.minute}
|
|
370
421
|
onChange={(e) => onMinuteChange(e.target.value)}
|
|
371
422
|
onBlur={() => setDraft((current) => ({ ...current,
|
|
@@ -379,7 +430,8 @@ export const TimePicker = forwardRef<HTMLDivElement, TimePickerProps>(
|
|
|
379
430
|
ref={meridiemRef}
|
|
380
431
|
type="button"
|
|
381
432
|
className={styles.meridiemBtn}
|
|
382
|
-
disabled={disabled}
|
|
433
|
+
disabled={disabled || readOnly}
|
|
434
|
+
aria-describedby={describedBy}
|
|
383
435
|
aria-label={L.toggleMeridiem}
|
|
384
436
|
onClick={() => {
|
|
385
437
|
const toggled: "AM" | "PM" = meridiem === "PM" ? "AM" : "PM";
|
|
@@ -416,6 +468,12 @@ export const TimePicker = forwardRef<HTMLDivElement, TimePickerProps>(
|
|
|
416
468
|
)}
|
|
417
469
|
</div>
|
|
418
470
|
);
|
|
471
|
+
if (label == null && description == null && !hasWarning) return control;
|
|
472
|
+
return <div data-slot="time-picker-field-wrapper" className={inputStyles.field} style={fieldStyle} data-disabled={disabled || undefined}>
|
|
473
|
+
{label != null && <label data-slot="time-picker-label" id={labelId} htmlFor={`${fieldId}-hour`} className={[inputStyles.label, inputStyles[size === "sm" ? "labelSm" : "labelMd"]].join(" ")}>{label}{required && <span aria-hidden className={inputStyles.requiredMark}>*</span>}</label>}
|
|
474
|
+
{control}
|
|
475
|
+
{hasWarning ? <p data-slot="time-picker-warning" id={warningId} role="alert" className={inputStyles.errorText}><span className={inputStyles.messageIcon} aria-hidden><Icon name="warning-circle" size={14} /></span>{warning}</p> : description != null && <p data-slot="time-picker-description" id={descriptionId} className={inputStyles.description}><span className={inputStyles.messageIcon} aria-hidden><Icon name="info" size={14} /></span>{description}</p>}
|
|
476
|
+
</div>;
|
|
419
477
|
},
|
|
420
478
|
);
|
|
421
479
|
|
|
@@ -162,6 +162,24 @@
|
|
|
162
162
|
color: var(--toast-fg-muted);
|
|
163
163
|
margin-top: calc((var(--lh-sm) - var(--iconbtn-h-sm)) / 2);
|
|
164
164
|
}
|
|
165
|
+
|
|
166
|
+
.action + .close {
|
|
167
|
+
margin-inline-start: calc(-1 * var(--space-2));
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/* Single-line feedback centers every item; first-line offsets are only for descriptions. */
|
|
171
|
+
.root:not(:has(.description)),
|
|
172
|
+
.placement-top-center .root {
|
|
173
|
+
align-items: center;
|
|
174
|
+
padding-block: var(--space-2);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.root:not(:has(.description)) .action,
|
|
178
|
+
.root:not(:has(.description)) .close,
|
|
179
|
+
.placement-top-center .action,
|
|
180
|
+
.placement-top-center .close {
|
|
181
|
+
margin-top: 0;
|
|
182
|
+
}
|
|
165
183
|
.surface-inverse .close { color: var(--bg-muted); }
|
|
166
184
|
.surface-inverse .close:hover:not(:disabled) {
|
|
167
185
|
color: var(--bg);
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
import * as RadixTooltip from "@radix-ui/react-tooltip";
|
|
4
4
|
import {
|
|
5
|
+
createContext,
|
|
5
6
|
forwardRef,
|
|
7
|
+
useContext,
|
|
8
|
+
useId,
|
|
6
9
|
useEffect,
|
|
7
10
|
useLayoutEffect,
|
|
8
11
|
useRef,
|
|
@@ -11,6 +14,9 @@ import {
|
|
|
11
14
|
} from "react";
|
|
12
15
|
import styles from "./Tooltip.module.css";
|
|
13
16
|
|
|
17
|
+
type TooltipHandoff = { id: string; close: () => void };
|
|
18
|
+
const TooltipHandoffContext = createContext<{ current: TooltipHandoff | null } | null>(null);
|
|
19
|
+
|
|
14
20
|
type Side = "top" | "right" | "bottom" | "left";
|
|
15
21
|
type Align = "start" | "center" | "end";
|
|
16
22
|
|
|
@@ -271,6 +277,23 @@ export const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(
|
|
|
271
277
|
},
|
|
272
278
|
ref
|
|
273
279
|
) => {
|
|
280
|
+
const handoff = useContext(TooltipHandoffContext);
|
|
281
|
+
const tooltipId = useId();
|
|
282
|
+
const [uncontrolledOpen, setUncontrolledOpen] = useState(false);
|
|
283
|
+
const isOpen = open ?? uncontrolledOpen;
|
|
284
|
+
const changeOpen = (next: boolean) => {
|
|
285
|
+
if (open === undefined) setUncontrolledOpen(next);
|
|
286
|
+
onOpenChange?.(next);
|
|
287
|
+
};
|
|
288
|
+
const closeRef = useRef<() => void>(() => {});
|
|
289
|
+
useLayoutEffect(() => { closeRef.current = () => changeOpen(false); });
|
|
290
|
+
useLayoutEffect(() => {
|
|
291
|
+
if (!handoff || !isOpen) return;
|
|
292
|
+
const previous = handoff.current;
|
|
293
|
+
if (previous && previous.id !== tooltipId) previous.close();
|
|
294
|
+
handoff.current = { id: tooltipId, close: () => closeRef.current() };
|
|
295
|
+
return () => { if (handoff.current?.id === tooltipId) handoff.current = null; };
|
|
296
|
+
}, [handoff, isOpen, tooltipId]);
|
|
274
297
|
const triggerRef = useRef<HTMLElement | null>(null);
|
|
275
298
|
const [mouseOffset, setMouseOffset] = useState(0);
|
|
276
299
|
|
|
@@ -298,10 +321,12 @@ export const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(
|
|
|
298
321
|
return (
|
|
299
322
|
<RadixTooltip.Root
|
|
300
323
|
delayDuration={delayDuration}
|
|
301
|
-
open={
|
|
302
|
-
onOpenChange={
|
|
324
|
+
open={isOpen}
|
|
325
|
+
onOpenChange={changeOpen}
|
|
303
326
|
>
|
|
304
|
-
<RadixTooltip.Trigger asChild ref={triggerRef as React.RefObject<HTMLButtonElement>}
|
|
327
|
+
<RadixTooltip.Trigger asChild ref={triggerRef as React.RefObject<HTMLButtonElement>} onPointerEnter={event => {
|
|
328
|
+
if (!event.defaultPrevented && event.pointerType !== "touch" && handoff?.current && handoff.current.id !== tooltipId) changeOpen(true);
|
|
329
|
+
}}>
|
|
305
330
|
{children}
|
|
306
331
|
</RadixTooltip.Trigger>
|
|
307
332
|
<RadixTooltip.Portal>
|
|
@@ -331,11 +356,12 @@ export const TooltipProvider = ({
|
|
|
331
356
|
delayDuration?: number;
|
|
332
357
|
skipDelayDuration?: number;
|
|
333
358
|
children: ReactNode;
|
|
334
|
-
}) =>
|
|
335
|
-
<
|
|
359
|
+
}) => {
|
|
360
|
+
const activeTooltip = useRef<TooltipHandoff | null>(null);
|
|
361
|
+
return <TooltipHandoffContext.Provider value={activeTooltip}><RadixTooltip.Provider
|
|
336
362
|
delayDuration={delayDuration}
|
|
337
363
|
skipDelayDuration={skipDelayDuration}
|
|
338
364
|
>
|
|
339
365
|
{children}
|
|
340
|
-
</RadixTooltip.Provider
|
|
341
|
-
|
|
366
|
+
</RadixTooltip.Provider></TooltipHandoffContext.Provider>;
|
|
367
|
+
};
|