vzcode 2.36.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -0
- package/dist/assets/index-DT8aFBKg.js +356 -0
- package/dist/assets/index-DyMLoJaw.css +1 -0
- package/dist/index.html +2 -2
- package/package.json +1 -4
- package/src/client/AIAssist/AIAssistWidget/index.tsx +2 -2
- package/src/client/AIAssist/AIAssistWidget/style.scss +8 -8
- package/src/client/AIAssist/Spinner.jsx +2 -2
- package/src/client/App/style.scss +6 -9
- package/src/client/CodeEditor/getOrCreateEditor.tsx +1 -1
- package/src/client/CodeEditor/style.scss +13 -13
- package/src/client/CodeErrorOverlay/index.tsx +1 -1
- package/src/client/CodeErrorOverlay/style.scss +3 -3
- package/src/client/ImageViewer/style.scss +6 -6
- package/src/client/RunCodeWidget/index.tsx +3 -3
- package/src/client/RunCodeWidget/style.scss +2 -2
- package/src/client/TabList/Tab.tsx +2 -2
- package/src/client/TabList/style.scss +6 -5
- package/src/client/VZKeyboardShortcutsDoc.tsx +4 -4
- package/src/client/VZSettings.tsx +27 -19
- package/src/client/VZSidebar/CreateDirModal.tsx +3 -3
- package/src/client/VZSidebar/CreateFileModal.tsx +3 -3
- package/src/client/VZSidebar/DeleteConfirmationModal.tsx +2 -2
- package/src/client/VZSidebar/Item.tsx +4 -4
- package/src/client/VZSidebar/Search.tsx +2 -2
- package/src/client/VZSidebar/VoiceChatModal.tsx +1 -1
- package/src/client/VZSidebar/index.tsx +23 -20
- package/src/client/VZSidebar/styles.scss +99 -98
- package/src/client/main.jsx +1 -0
- package/src/client/standalone.scss +6 -0
- package/src/client/ui.scss +317 -0
- package/src/client/ui.tsx +323 -0
- package/src/llm-streaming-ui/README.md +2 -2
- package/src/llm-streaming-ui/components/ChatInput.tsx +26 -49
- package/src/llm-streaming-ui/components/DiffView.scss +1 -1
- package/src/llm-streaming-ui/components/Spinner.scss +3 -3
- package/src/llm-streaming-ui/components/Spinner.tsx +2 -2
- package/src/llm-streaming-ui/components/styles.scss +127 -75
- package/dist/assets/bootstrap-icons-BeopsB42.woff +0 -0
- package/dist/assets/bootstrap-icons-mSm7cUeB.woff2 +0 -0
- package/dist/assets/index-Cj-ERpBu.css +0 -1
- package/dist/assets/index-DD7vzp4U.js +0 -364
- package/src/client/bootstrap.ts +0 -26
- package/src/llm-streaming-ui/components/bootstrap.ts +0 -16
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Original VizHub palette and typography, copied from vizhub-ui/scss:
|
|
3
|
+
* _variables.scss and _overrides.scss (v3.24.0).
|
|
4
|
+
* Retain the visual design without importing Bootstrap or vizhub-ui CSS.
|
|
5
|
+
* These variables belong to VZCode's containers, never :root or body.
|
|
6
|
+
*/
|
|
7
|
+
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Poppins:wght@400;600;700&display=swap');
|
|
8
|
+
|
|
9
|
+
:where(.app, .ai-chat-container, .vz-ui-modal) {
|
|
10
|
+
--vz-color-neutral-01: #1f2022;
|
|
11
|
+
--vz-color-neutral-02: #202e46;
|
|
12
|
+
--vz-color-neutral-03: #576786;
|
|
13
|
+
--vz-color-neutral-04: #bdc7dc;
|
|
14
|
+
--vz-color-action-01: #3866e9;
|
|
15
|
+
--vz-color-action-02: #022a9f;
|
|
16
|
+
--vz-color-action-03: #e0e8ff;
|
|
17
|
+
--vz-color-warning-01: #eb1c69;
|
|
18
|
+
--vz-color-warning-02: #ffeff2;
|
|
19
|
+
--vz-color-caution-01: #ffa800;
|
|
20
|
+
--vz-color-caution-02: #fff4df;
|
|
21
|
+
--vz-color-success-01: #36bb4a;
|
|
22
|
+
--vz-color-success-02: #d7f6dc;
|
|
23
|
+
--vz-color-hover-dark: rgba(255, 255, 255, 0.1);
|
|
24
|
+
--vz-color-active-dark: rgba(255, 255, 255, 0.2);
|
|
25
|
+
/* VZCode-only aliases for colors used by recent components. */
|
|
26
|
+
--vz-color-primary-01: var(--vz-color-action-01);
|
|
27
|
+
--vz-color-primary-02: var(--vz-color-action-02);
|
|
28
|
+
--vz-color-primary-03: var(--vz-color-action-01);
|
|
29
|
+
--vz-color-primary-04: var(--vz-color-action-03);
|
|
30
|
+
--vz-color-success-03: #36bb4a;
|
|
31
|
+
--vz-color-success-04: #d7f6dc;
|
|
32
|
+
--vz-color-danger-03: #eb1c69;
|
|
33
|
+
--vz-color-danger-04: #ffeff2;
|
|
34
|
+
--vz-font-body: Inter, sans-serif;
|
|
35
|
+
--vz-font-heading: Poppins, sans-serif;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* Scoped equivalent of Bootstrap's typography/reboot defaults. */
|
|
39
|
+
.app {
|
|
40
|
+
font-family: var(--vz-font-body);
|
|
41
|
+
font-size: 16px;
|
|
42
|
+
font-weight: 400;
|
|
43
|
+
line-height: 1.5;
|
|
44
|
+
color: var(--vz-color-neutral-04);
|
|
45
|
+
}
|
|
46
|
+
.app,
|
|
47
|
+
.app *,
|
|
48
|
+
.app *::before,
|
|
49
|
+
.app *::after,
|
|
50
|
+
.vz-ui-modal,
|
|
51
|
+
.vz-ui-modal *,
|
|
52
|
+
.vz-ui-modal *::before,
|
|
53
|
+
.vz-ui-modal *::after {
|
|
54
|
+
box-sizing: border-box;
|
|
55
|
+
}
|
|
56
|
+
:where(.app) :is(button, input, select, textarea) {
|
|
57
|
+
font: inherit;
|
|
58
|
+
}
|
|
59
|
+
:where(.app) :is(h1, h2, h3, h4, h5, h6) {
|
|
60
|
+
font-family: var(--vz-font-heading);
|
|
61
|
+
font-weight: 600;
|
|
62
|
+
line-height: 1.2;
|
|
63
|
+
margin-top: 0;
|
|
64
|
+
margin-bottom: 0.5rem;
|
|
65
|
+
}
|
|
66
|
+
:where(.app) h1 {
|
|
67
|
+
font-size: 3rem;
|
|
68
|
+
font-weight: 700;
|
|
69
|
+
}
|
|
70
|
+
:where(.app) h2 {
|
|
71
|
+
font-size: 2.125rem;
|
|
72
|
+
}
|
|
73
|
+
:where(.app) h3 {
|
|
74
|
+
font-size: 1.875rem;
|
|
75
|
+
}
|
|
76
|
+
:where(.app) h4 {
|
|
77
|
+
font-size: 1.25rem;
|
|
78
|
+
}
|
|
79
|
+
:where(.app) h5 {
|
|
80
|
+
font-size: 1.125rem;
|
|
81
|
+
}
|
|
82
|
+
:where(.app) h6 {
|
|
83
|
+
font-size: 1rem;
|
|
84
|
+
}
|
|
85
|
+
:where(.app) p {
|
|
86
|
+
margin-top: 0;
|
|
87
|
+
margin-bottom: 1rem;
|
|
88
|
+
}
|
|
89
|
+
:where(.app) a {
|
|
90
|
+
color: var(--vz-color-action-01);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.app .vz-icon-button {
|
|
94
|
+
display: inline-flex;
|
|
95
|
+
align-items: center;
|
|
96
|
+
justify-content: center;
|
|
97
|
+
padding: 4px;
|
|
98
|
+
border-radius: 4px;
|
|
99
|
+
color: var(--vz-color-neutral-04);
|
|
100
|
+
cursor: pointer;
|
|
101
|
+
min-width: 28px;
|
|
102
|
+
min-height: 28px;
|
|
103
|
+
}
|
|
104
|
+
.app .vz-icon-button:hover {
|
|
105
|
+
background: var(--vz-color-hover-dark);
|
|
106
|
+
}
|
|
107
|
+
.app .vz-icon-button:active {
|
|
108
|
+
background: var(--vz-color-active-dark);
|
|
109
|
+
}
|
|
110
|
+
.app .vz-icon-button:focus-visible {
|
|
111
|
+
outline: 2px solid var(--vz-color-action-01);
|
|
112
|
+
outline-offset: 2px;
|
|
113
|
+
}
|
|
114
|
+
.app .vz-color-success-01 {
|
|
115
|
+
color: var(--vz-color-success-01);
|
|
116
|
+
}
|
|
117
|
+
.app .file-or-directory {
|
|
118
|
+
user-select: none;
|
|
119
|
+
}
|
|
120
|
+
.vz-ui-button {
|
|
121
|
+
appearance: none;
|
|
122
|
+
display: inline-flex;
|
|
123
|
+
justify-content: center;
|
|
124
|
+
align-items: center;
|
|
125
|
+
gap: 6px;
|
|
126
|
+
border: 1px solid transparent;
|
|
127
|
+
border-radius: 4px;
|
|
128
|
+
padding: 6px 12px;
|
|
129
|
+
background: #e0e8ff;
|
|
130
|
+
color: #3866e9;
|
|
131
|
+
cursor: pointer;
|
|
132
|
+
font:
|
|
133
|
+
500 16px/1.5 Inter,
|
|
134
|
+
sans-serif;
|
|
135
|
+
}
|
|
136
|
+
.vz-ui-button:hover {
|
|
137
|
+
filter: brightness(0.95);
|
|
138
|
+
}
|
|
139
|
+
.vz-ui-button:focus-visible,
|
|
140
|
+
.vz-ui-control:focus-visible,
|
|
141
|
+
.vz-ui-close:focus-visible {
|
|
142
|
+
outline: 2px solid #3866e9;
|
|
143
|
+
outline-offset: 2px;
|
|
144
|
+
}
|
|
145
|
+
.vz-ui-button:disabled {
|
|
146
|
+
opacity: 0.5;
|
|
147
|
+
cursor: not-allowed;
|
|
148
|
+
}
|
|
149
|
+
.vz-ui-button--primary {
|
|
150
|
+
background: #3866e9;
|
|
151
|
+
color: #fff;
|
|
152
|
+
}
|
|
153
|
+
.vz-ui-button--danger {
|
|
154
|
+
background: #eb1c69;
|
|
155
|
+
color: #fff;
|
|
156
|
+
}
|
|
157
|
+
.vz-ui-button--outline-secondary {
|
|
158
|
+
background: transparent;
|
|
159
|
+
border-color: #576786;
|
|
160
|
+
color: #576786;
|
|
161
|
+
}
|
|
162
|
+
.vz-ui-button--outline-primary {
|
|
163
|
+
background: transparent;
|
|
164
|
+
border-color: #3866e9;
|
|
165
|
+
color: #3866e9;
|
|
166
|
+
}
|
|
167
|
+
.vz-ui-button--sm {
|
|
168
|
+
padding: 4px 8px;
|
|
169
|
+
font-size: 12px;
|
|
170
|
+
}
|
|
171
|
+
.vz-ui-field {
|
|
172
|
+
display: flex;
|
|
173
|
+
flex-direction: column;
|
|
174
|
+
gap: 5px;
|
|
175
|
+
margin-bottom: 16px;
|
|
176
|
+
}
|
|
177
|
+
.vz-ui-label {
|
|
178
|
+
font-size: 16px;
|
|
179
|
+
font-weight: 500;
|
|
180
|
+
color: #161514;
|
|
181
|
+
}
|
|
182
|
+
.vz-ui-control,
|
|
183
|
+
.vz-ui-select {
|
|
184
|
+
box-sizing: border-box;
|
|
185
|
+
width: 100%;
|
|
186
|
+
border: 1px solid #dee2e6;
|
|
187
|
+
border-radius: 4px;
|
|
188
|
+
background: transparent;
|
|
189
|
+
color: #161514;
|
|
190
|
+
padding: 6px 12px;
|
|
191
|
+
font:
|
|
192
|
+
400 16px/1.5 Inter,
|
|
193
|
+
sans-serif;
|
|
194
|
+
}
|
|
195
|
+
.vz-ui-help {
|
|
196
|
+
color: #797979;
|
|
197
|
+
font-size: 14px;
|
|
198
|
+
}
|
|
199
|
+
/* The same native field is also used in the dark file-search sidebar.
|
|
200
|
+
* Modal controls are light; editor controls remain legible on navy. */
|
|
201
|
+
.app .vz-ui-control {
|
|
202
|
+
background-color: var(--vz-color-neutral-02);
|
|
203
|
+
color: var(--vz-color-neutral-04);
|
|
204
|
+
border-color: var(--vz-color-neutral-03);
|
|
205
|
+
}
|
|
206
|
+
.app .vz-ui-control::placeholder {
|
|
207
|
+
color: var(--vz-color-neutral-04);
|
|
208
|
+
opacity: 0.65;
|
|
209
|
+
}
|
|
210
|
+
.vz-ui-modal {
|
|
211
|
+
box-sizing: border-box;
|
|
212
|
+
width: min(500px, calc(100vw - 32px));
|
|
213
|
+
max-height: calc(100dvh - 32px);
|
|
214
|
+
padding: 0;
|
|
215
|
+
border: 0;
|
|
216
|
+
border-radius: 4px;
|
|
217
|
+
background: white;
|
|
218
|
+
color: #161514;
|
|
219
|
+
box-shadow:
|
|
220
|
+
rgba(0, 0, 0, 0.15) 0 1px 4px,
|
|
221
|
+
0 16px 40px #0004;
|
|
222
|
+
font:
|
|
223
|
+
400 16px/1.5 Inter,
|
|
224
|
+
sans-serif;
|
|
225
|
+
}
|
|
226
|
+
.vz-ui-modal::backdrop {
|
|
227
|
+
background: rgba(0, 0, 0, 0.5);
|
|
228
|
+
}
|
|
229
|
+
.vz-ui-modal-content {
|
|
230
|
+
display: flex;
|
|
231
|
+
flex-direction: column;
|
|
232
|
+
}
|
|
233
|
+
.vz-ui-modal-header {
|
|
234
|
+
display: flex;
|
|
235
|
+
align-items: center;
|
|
236
|
+
justify-content: space-between;
|
|
237
|
+
gap: 16px;
|
|
238
|
+
padding: 16px 20px;
|
|
239
|
+
border-bottom: 1px solid #e6eaf2;
|
|
240
|
+
}
|
|
241
|
+
.vz-ui-modal-title {
|
|
242
|
+
font:
|
|
243
|
+
600 20px/1.2 Poppins,
|
|
244
|
+
sans-serif;
|
|
245
|
+
margin: 0;
|
|
246
|
+
}
|
|
247
|
+
.vz-ui-close {
|
|
248
|
+
border: 0;
|
|
249
|
+
border-radius: 4px;
|
|
250
|
+
background: none;
|
|
251
|
+
color: #576786;
|
|
252
|
+
cursor: pointer;
|
|
253
|
+
font-size: 24px;
|
|
254
|
+
padding: 0 5px;
|
|
255
|
+
line-height: 1;
|
|
256
|
+
}
|
|
257
|
+
.vz-ui-modal-body {
|
|
258
|
+
padding: 20px;
|
|
259
|
+
overflow: auto;
|
|
260
|
+
}
|
|
261
|
+
.vz-ui-modal-body p {
|
|
262
|
+
margin: 0 0 12px;
|
|
263
|
+
}
|
|
264
|
+
.vz-ui-modal-body ul {
|
|
265
|
+
padding-left: 22px;
|
|
266
|
+
}
|
|
267
|
+
.vz-ui-modal-body li {
|
|
268
|
+
margin: 8px 0;
|
|
269
|
+
}
|
|
270
|
+
.vz-ui-modal-body kbd {
|
|
271
|
+
padding: 2px 5px;
|
|
272
|
+
border-radius: 4px;
|
|
273
|
+
background: #e6eaf2;
|
|
274
|
+
}
|
|
275
|
+
.vz-ui-modal-footer {
|
|
276
|
+
display: flex;
|
|
277
|
+
justify-content: flex-end;
|
|
278
|
+
align-items: center;
|
|
279
|
+
gap: 10px;
|
|
280
|
+
padding: 14px 20px;
|
|
281
|
+
border-top: 1px solid #e6eaf2;
|
|
282
|
+
}
|
|
283
|
+
.vz-ui-tooltip-anchor {
|
|
284
|
+
display: inline-flex;
|
|
285
|
+
position: relative;
|
|
286
|
+
align-items: center;
|
|
287
|
+
}
|
|
288
|
+
.vz-ui-tooltip {
|
|
289
|
+
position: absolute;
|
|
290
|
+
pointer-events: none;
|
|
291
|
+
z-index: 30;
|
|
292
|
+
width: max-content;
|
|
293
|
+
max-width: 240px;
|
|
294
|
+
padding: 5px 9px;
|
|
295
|
+
border-radius: 6px;
|
|
296
|
+
background: #161514;
|
|
297
|
+
border: 1px solid #161514;
|
|
298
|
+
color: #fff;
|
|
299
|
+
font:
|
|
300
|
+
14px/1.5 Inter,
|
|
301
|
+
sans-serif;
|
|
302
|
+
white-space: normal;
|
|
303
|
+
box-shadow: 0 8px 20px #0006;
|
|
304
|
+
opacity: 0;
|
|
305
|
+
visibility: hidden;
|
|
306
|
+
}
|
|
307
|
+
.vz-ui-tooltip-floating {
|
|
308
|
+
position: fixed;
|
|
309
|
+
z-index: 10050;
|
|
310
|
+
pointer-events: none;
|
|
311
|
+
}
|
|
312
|
+
.vz-ui-tooltip-floating .vz-ui-tooltip {
|
|
313
|
+
position: static;
|
|
314
|
+
display: block;
|
|
315
|
+
opacity: 1;
|
|
316
|
+
visibility: visible;
|
|
317
|
+
}
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VZCode-local React primitives. They use native controls and editor-scoped CSS.
|
|
3
|
+
* Importing them never loads Bootstrap, VizHub UI, or a page-wide reset.
|
|
4
|
+
*/
|
|
5
|
+
import React, {
|
|
6
|
+
createContext,
|
|
7
|
+
forwardRef,
|
|
8
|
+
useContext,
|
|
9
|
+
useEffect,
|
|
10
|
+
useId,
|
|
11
|
+
useRef,
|
|
12
|
+
useState,
|
|
13
|
+
useCallback,
|
|
14
|
+
type ReactNode,
|
|
15
|
+
} from 'react';
|
|
16
|
+
import { createPortal } from 'react-dom';
|
|
17
|
+
import './ui.scss';
|
|
18
|
+
|
|
19
|
+
type ButtonProps =
|
|
20
|
+
React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
21
|
+
variant?:
|
|
22
|
+
| 'primary'
|
|
23
|
+
| 'secondary'
|
|
24
|
+
| 'danger'
|
|
25
|
+
| 'outline-secondary'
|
|
26
|
+
| 'outline-primary';
|
|
27
|
+
size?: 'sm' | 'lg';
|
|
28
|
+
};
|
|
29
|
+
export const Button = ({
|
|
30
|
+
variant = 'secondary',
|
|
31
|
+
size,
|
|
32
|
+
type = 'button',
|
|
33
|
+
className = '',
|
|
34
|
+
...props
|
|
35
|
+
}: ButtonProps) => (
|
|
36
|
+
<button
|
|
37
|
+
{...props}
|
|
38
|
+
type={type}
|
|
39
|
+
className={`vz-ui-button vz-ui-button--${variant} ${size ? `vz-ui-button--${size}` : ''} ${className}`}
|
|
40
|
+
/>
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const fieldContext = createContext<string | undefined>(
|
|
44
|
+
undefined,
|
|
45
|
+
);
|
|
46
|
+
const Group = ({
|
|
47
|
+
controlId,
|
|
48
|
+
className = '',
|
|
49
|
+
children,
|
|
50
|
+
}: {
|
|
51
|
+
controlId?: string;
|
|
52
|
+
className?: string;
|
|
53
|
+
children: ReactNode;
|
|
54
|
+
}) => {
|
|
55
|
+
const generatedId = useId();
|
|
56
|
+
return (
|
|
57
|
+
<fieldContext.Provider value={controlId || generatedId}>
|
|
58
|
+
<div className={`vz-ui-field ${className}`}>
|
|
59
|
+
{children}
|
|
60
|
+
</div>
|
|
61
|
+
</fieldContext.Provider>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
const Label = ({
|
|
65
|
+
children,
|
|
66
|
+
...props
|
|
67
|
+
}: React.LabelHTMLAttributes<HTMLLabelElement>) => {
|
|
68
|
+
const fieldId = useContext(fieldContext);
|
|
69
|
+
return (
|
|
70
|
+
<label
|
|
71
|
+
{...props}
|
|
72
|
+
htmlFor={props.htmlFor ?? fieldId}
|
|
73
|
+
className={`vz-ui-label ${props.className || ''}`}
|
|
74
|
+
>
|
|
75
|
+
{children}
|
|
76
|
+
</label>
|
|
77
|
+
);
|
|
78
|
+
};
|
|
79
|
+
const Control = forwardRef<
|
|
80
|
+
HTMLInputElement,
|
|
81
|
+
React.InputHTMLAttributes<HTMLInputElement>
|
|
82
|
+
>(({ className = '', id, ...props }, ref) => {
|
|
83
|
+
const fieldId = useContext(fieldContext);
|
|
84
|
+
return (
|
|
85
|
+
<input
|
|
86
|
+
{...props}
|
|
87
|
+
id={id ?? fieldId}
|
|
88
|
+
ref={ref}
|
|
89
|
+
className={`vz-ui-control ${className}`}
|
|
90
|
+
/>
|
|
91
|
+
);
|
|
92
|
+
});
|
|
93
|
+
Control.displayName = 'VZControl';
|
|
94
|
+
const FieldText = ({
|
|
95
|
+
children,
|
|
96
|
+
className = '',
|
|
97
|
+
}: {
|
|
98
|
+
children?: ReactNode;
|
|
99
|
+
className?: string;
|
|
100
|
+
}) => (
|
|
101
|
+
<small className={`vz-ui-help ${className}`}>
|
|
102
|
+
{children}
|
|
103
|
+
</small>
|
|
104
|
+
);
|
|
105
|
+
export const Form = Object.assign(
|
|
106
|
+
({ children }: { children?: ReactNode }) => (
|
|
107
|
+
<>{children}</>
|
|
108
|
+
),
|
|
109
|
+
{ Group, Label, Control, Text: FieldText },
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
const modalContext = createContext<{
|
|
113
|
+
close: () => void;
|
|
114
|
+
titleId: string;
|
|
115
|
+
} | null>(null);
|
|
116
|
+
type ModalProps = {
|
|
117
|
+
show: boolean;
|
|
118
|
+
onHide: () => void;
|
|
119
|
+
children: ReactNode;
|
|
120
|
+
className?: string;
|
|
121
|
+
centered?: boolean;
|
|
122
|
+
animation?: boolean;
|
|
123
|
+
onKeyDown?: React.KeyboardEventHandler<HTMLDialogElement>;
|
|
124
|
+
};
|
|
125
|
+
const ModalRoot = ({
|
|
126
|
+
show,
|
|
127
|
+
onHide,
|
|
128
|
+
children,
|
|
129
|
+
className = '',
|
|
130
|
+
onKeyDown,
|
|
131
|
+
}: ModalProps) => {
|
|
132
|
+
const ref = useRef<HTMLDialogElement>(null);
|
|
133
|
+
const titleId = useId();
|
|
134
|
+
useEffect(() => {
|
|
135
|
+
const dialog = ref.current;
|
|
136
|
+
if (!dialog || !show) return;
|
|
137
|
+
if (!dialog.open) dialog.showModal();
|
|
138
|
+
return () => {
|
|
139
|
+
if (dialog.open) dialog.close();
|
|
140
|
+
};
|
|
141
|
+
}, [show]);
|
|
142
|
+
if (!show || typeof document === 'undefined') return null;
|
|
143
|
+
return createPortal(
|
|
144
|
+
<modalContext.Provider
|
|
145
|
+
value={{ close: onHide, titleId }}
|
|
146
|
+
>
|
|
147
|
+
<dialog
|
|
148
|
+
ref={ref}
|
|
149
|
+
className={`vz-ui-modal ${className}`}
|
|
150
|
+
aria-labelledby={titleId}
|
|
151
|
+
onKeyDown={onKeyDown}
|
|
152
|
+
onCancel={(event) => {
|
|
153
|
+
event.preventDefault();
|
|
154
|
+
onHide();
|
|
155
|
+
}}
|
|
156
|
+
onClick={(event) => {
|
|
157
|
+
if (event.target === event.currentTarget)
|
|
158
|
+
onHide();
|
|
159
|
+
}}
|
|
160
|
+
>
|
|
161
|
+
<div className="vz-ui-modal-content">
|
|
162
|
+
{children}
|
|
163
|
+
</div>
|
|
164
|
+
</dialog>
|
|
165
|
+
</modalContext.Provider>,
|
|
166
|
+
document.body,
|
|
167
|
+
);
|
|
168
|
+
};
|
|
169
|
+
const ModalHeader = ({
|
|
170
|
+
children,
|
|
171
|
+
closeButton,
|
|
172
|
+
onClick,
|
|
173
|
+
}: {
|
|
174
|
+
children: ReactNode;
|
|
175
|
+
closeButton?: boolean;
|
|
176
|
+
onClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
177
|
+
}) => {
|
|
178
|
+
const dialog = useContext(modalContext);
|
|
179
|
+
return (
|
|
180
|
+
<div className="vz-ui-modal-header">
|
|
181
|
+
{children}
|
|
182
|
+
{closeButton && (
|
|
183
|
+
<button
|
|
184
|
+
type="button"
|
|
185
|
+
className="vz-ui-close"
|
|
186
|
+
aria-label="Close dialog"
|
|
187
|
+
onClick={onClick ?? dialog?.close}
|
|
188
|
+
>
|
|
189
|
+
×
|
|
190
|
+
</button>
|
|
191
|
+
)}
|
|
192
|
+
</div>
|
|
193
|
+
);
|
|
194
|
+
};
|
|
195
|
+
const ModalTitle = ({
|
|
196
|
+
children,
|
|
197
|
+
}: {
|
|
198
|
+
children: ReactNode;
|
|
199
|
+
}) => {
|
|
200
|
+
const dialog = useContext(modalContext);
|
|
201
|
+
return (
|
|
202
|
+
<h2 className="vz-ui-modal-title" id={dialog?.titleId}>
|
|
203
|
+
{children}
|
|
204
|
+
</h2>
|
|
205
|
+
);
|
|
206
|
+
};
|
|
207
|
+
const ModalBody = ({
|
|
208
|
+
children,
|
|
209
|
+
className = '',
|
|
210
|
+
}: {
|
|
211
|
+
children: ReactNode;
|
|
212
|
+
className?: string;
|
|
213
|
+
}) => (
|
|
214
|
+
<div className={`vz-ui-modal-body ${className}`}>
|
|
215
|
+
{children}
|
|
216
|
+
</div>
|
|
217
|
+
);
|
|
218
|
+
const ModalFooter = ({
|
|
219
|
+
children,
|
|
220
|
+
}: {
|
|
221
|
+
children: ReactNode;
|
|
222
|
+
}) => <div className="vz-ui-modal-footer">{children}</div>;
|
|
223
|
+
export const Modal = Object.assign(ModalRoot, {
|
|
224
|
+
Header: ModalHeader,
|
|
225
|
+
Title: ModalTitle,
|
|
226
|
+
Body: ModalBody,
|
|
227
|
+
Footer: ModalFooter,
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
export const Tooltip = ({
|
|
231
|
+
id,
|
|
232
|
+
children,
|
|
233
|
+
}: {
|
|
234
|
+
id: string;
|
|
235
|
+
children: ReactNode;
|
|
236
|
+
}) => (
|
|
237
|
+
<span id={id} role="tooltip" className="vz-ui-tooltip">
|
|
238
|
+
{children}
|
|
239
|
+
</span>
|
|
240
|
+
);
|
|
241
|
+
/**
|
|
242
|
+
* Tooltips render in a portal so the sidebar's overflow: hidden/auto does
|
|
243
|
+
* not crop them (as Bootstrap's overlays previously avoided).
|
|
244
|
+
*/
|
|
245
|
+
export const OverlayTrigger = ({
|
|
246
|
+
children,
|
|
247
|
+
overlay,
|
|
248
|
+
placement = 'top',
|
|
249
|
+
}: {
|
|
250
|
+
children: ReactNode;
|
|
251
|
+
overlay: ReactNode;
|
|
252
|
+
placement?: 'top' | 'right' | 'bottom' | 'left';
|
|
253
|
+
}) => {
|
|
254
|
+
const anchor = useRef<HTMLSpanElement>(null);
|
|
255
|
+
const [position, setPosition] =
|
|
256
|
+
useState<React.CSSProperties | null>(null);
|
|
257
|
+
const update = useCallback(() => {
|
|
258
|
+
const rect = anchor.current?.getBoundingClientRect();
|
|
259
|
+
if (!rect) return;
|
|
260
|
+
const centerX = rect.left + rect.width / 2;
|
|
261
|
+
const centerY = rect.top + rect.height / 2;
|
|
262
|
+
const offset = 8;
|
|
263
|
+
const next: React.CSSProperties =
|
|
264
|
+
placement === 'right'
|
|
265
|
+
? {
|
|
266
|
+
left: rect.right + offset,
|
|
267
|
+
top: centerY,
|
|
268
|
+
transform: 'translateY(-50%)',
|
|
269
|
+
}
|
|
270
|
+
: placement === 'left'
|
|
271
|
+
? {
|
|
272
|
+
left: rect.left - offset,
|
|
273
|
+
top: centerY,
|
|
274
|
+
transform: 'translate(-100%, -50%)',
|
|
275
|
+
}
|
|
276
|
+
: placement === 'bottom'
|
|
277
|
+
? {
|
|
278
|
+
left: centerX,
|
|
279
|
+
top: rect.bottom + offset,
|
|
280
|
+
transform: 'translateX(-50%)',
|
|
281
|
+
}
|
|
282
|
+
: {
|
|
283
|
+
left: centerX,
|
|
284
|
+
top: rect.top - offset,
|
|
285
|
+
transform: 'translate(-50%, -100%)',
|
|
286
|
+
};
|
|
287
|
+
setPosition(next);
|
|
288
|
+
}, [placement]);
|
|
289
|
+
useEffect(() => {
|
|
290
|
+
if (!position) return;
|
|
291
|
+
window.addEventListener('scroll', update, true);
|
|
292
|
+
window.addEventListener('resize', update);
|
|
293
|
+
return () => {
|
|
294
|
+
window.removeEventListener('scroll', update, true);
|
|
295
|
+
window.removeEventListener('resize', update);
|
|
296
|
+
};
|
|
297
|
+
}, [position, update]);
|
|
298
|
+
|
|
299
|
+
return (
|
|
300
|
+
<span
|
|
301
|
+
ref={anchor}
|
|
302
|
+
className="vz-ui-tooltip-anchor"
|
|
303
|
+
tabIndex={0}
|
|
304
|
+
onPointerEnter={update}
|
|
305
|
+
onPointerLeave={() => setPosition(null)}
|
|
306
|
+
onFocus={update}
|
|
307
|
+
onBlur={() => setPosition(null)}
|
|
308
|
+
>
|
|
309
|
+
{children}
|
|
310
|
+
{position &&
|
|
311
|
+
typeof document !== 'undefined' &&
|
|
312
|
+
createPortal(
|
|
313
|
+
<span
|
|
314
|
+
className="vz-ui-tooltip-floating"
|
|
315
|
+
style={position}
|
|
316
|
+
>
|
|
317
|
+
{overlay}
|
|
318
|
+
</span>,
|
|
319
|
+
document.body,
|
|
320
|
+
)}
|
|
321
|
+
</span>
|
|
322
|
+
);
|
|
323
|
+
};
|
|
@@ -51,7 +51,7 @@ VZCode binds those props using the `AIChatWrapper` component in
|
|
|
51
51
|
|
|
52
52
|
### Support Modules
|
|
53
53
|
|
|
54
|
-
- `components/
|
|
54
|
+
- `components/ChatInput.tsx` - native React buttons and textarea component wrappers
|
|
55
55
|
- `components/icons.tsx` - Self-contained microphone icons
|
|
56
56
|
- `utils/scrollUtils.ts` - Diff scrolling and accessibility helpers
|
|
57
57
|
- `props.ts` - Public prop and callback types
|
|
@@ -65,7 +65,7 @@ VZCode binds those props using the `AIChatWrapper` component in
|
|
|
65
65
|
## Dependencies
|
|
66
66
|
|
|
67
67
|
- React and React hooks
|
|
68
|
-
-
|
|
68
|
+
- native React buttons and textarea
|
|
69
69
|
- diff2html for diff rendering
|
|
70
70
|
- react-markdown for message rendering
|
|
71
71
|
- `@vizhub/viz-types` for chat/content types
|