vzcode 2.36.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -0
- package/dist/assets/index-5qf102c2.css +1 -0
- package/dist/assets/index-dSJDl5x9.js +356 -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/index.tsx +7 -0
- package/src/client/App/initialSidebarView.ts +14 -0
- 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 +24 -21
- package/src/client/VZSidebar/styles.scss +134 -125
- package/src/client/main.jsx +1 -0
- package/src/client/standalone.scss +6 -0
- package/src/client/ui.scss +324 -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,324 @@
|
|
|
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
|
+
/* The embedded VZSidebar is also mounted directly by VizHub Cloud,
|
|
10
|
+
* without VZCode's standalone .app wrapper. Scope tokens to that root too. */
|
|
11
|
+
:where(
|
|
12
|
+
.app,
|
|
13
|
+
.vz-sidebar,
|
|
14
|
+
.ai-chat-container,
|
|
15
|
+
.vz-ui-modal
|
|
16
|
+
) {
|
|
17
|
+
--vz-color-neutral-01: #1f2022;
|
|
18
|
+
--vz-color-neutral-02: #202e46;
|
|
19
|
+
--vz-color-neutral-03: #576786;
|
|
20
|
+
--vz-color-neutral-04: #bdc7dc;
|
|
21
|
+
--vz-color-action-01: #3866e9;
|
|
22
|
+
--vz-color-action-02: #022a9f;
|
|
23
|
+
--vz-color-action-03: #e0e8ff;
|
|
24
|
+
--vz-color-warning-01: #eb1c69;
|
|
25
|
+
--vz-color-warning-02: #ffeff2;
|
|
26
|
+
--vz-color-caution-01: #ffa800;
|
|
27
|
+
--vz-color-caution-02: #fff4df;
|
|
28
|
+
--vz-color-success-01: #36bb4a;
|
|
29
|
+
--vz-color-success-02: #d7f6dc;
|
|
30
|
+
--vz-color-hover-dark: rgba(255, 255, 255, 0.1);
|
|
31
|
+
--vz-color-active-dark: rgba(255, 255, 255, 0.2);
|
|
32
|
+
/* VZCode-only aliases for colors used by recent components. */
|
|
33
|
+
--vz-color-primary-01: var(--vz-color-action-01);
|
|
34
|
+
--vz-color-primary-02: var(--vz-color-action-02);
|
|
35
|
+
--vz-color-primary-03: var(--vz-color-action-01);
|
|
36
|
+
--vz-color-primary-04: var(--vz-color-action-03);
|
|
37
|
+
--vz-color-success-03: #36bb4a;
|
|
38
|
+
--vz-color-success-04: #d7f6dc;
|
|
39
|
+
--vz-color-danger-03: #eb1c69;
|
|
40
|
+
--vz-color-danger-04: #ffeff2;
|
|
41
|
+
--vz-font-body: Inter, sans-serif;
|
|
42
|
+
--vz-font-heading: Poppins, sans-serif;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/* Scoped equivalent of Bootstrap's typography/reboot defaults. */
|
|
46
|
+
.app {
|
|
47
|
+
font-family: var(--vz-font-body);
|
|
48
|
+
font-size: 16px;
|
|
49
|
+
font-weight: 400;
|
|
50
|
+
line-height: 1.5;
|
|
51
|
+
color: var(--vz-color-neutral-04);
|
|
52
|
+
}
|
|
53
|
+
.app,
|
|
54
|
+
.app *,
|
|
55
|
+
.app *::before,
|
|
56
|
+
.app *::after,
|
|
57
|
+
.vz-ui-modal,
|
|
58
|
+
.vz-ui-modal *,
|
|
59
|
+
.vz-ui-modal *::before,
|
|
60
|
+
.vz-ui-modal *::after {
|
|
61
|
+
box-sizing: border-box;
|
|
62
|
+
}
|
|
63
|
+
:where(.app) :is(button, input, select, textarea) {
|
|
64
|
+
font: inherit;
|
|
65
|
+
}
|
|
66
|
+
:where(.app) :is(h1, h2, h3, h4, h5, h6) {
|
|
67
|
+
font-family: var(--vz-font-heading);
|
|
68
|
+
font-weight: 600;
|
|
69
|
+
line-height: 1.2;
|
|
70
|
+
margin-top: 0;
|
|
71
|
+
margin-bottom: 0.5rem;
|
|
72
|
+
}
|
|
73
|
+
:where(.app) h1 {
|
|
74
|
+
font-size: 3rem;
|
|
75
|
+
font-weight: 700;
|
|
76
|
+
}
|
|
77
|
+
:where(.app) h2 {
|
|
78
|
+
font-size: 2.125rem;
|
|
79
|
+
}
|
|
80
|
+
:where(.app) h3 {
|
|
81
|
+
font-size: 1.875rem;
|
|
82
|
+
}
|
|
83
|
+
:where(.app) h4 {
|
|
84
|
+
font-size: 1.25rem;
|
|
85
|
+
}
|
|
86
|
+
:where(.app) h5 {
|
|
87
|
+
font-size: 1.125rem;
|
|
88
|
+
}
|
|
89
|
+
:where(.app) h6 {
|
|
90
|
+
font-size: 1rem;
|
|
91
|
+
}
|
|
92
|
+
:where(.app) p {
|
|
93
|
+
margin-top: 0;
|
|
94
|
+
margin-bottom: 1rem;
|
|
95
|
+
}
|
|
96
|
+
:where(.app) a {
|
|
97
|
+
color: var(--vz-color-action-01);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.app .vz-icon-button {
|
|
101
|
+
display: inline-flex;
|
|
102
|
+
align-items: center;
|
|
103
|
+
justify-content: center;
|
|
104
|
+
padding: 4px;
|
|
105
|
+
border-radius: 4px;
|
|
106
|
+
color: var(--vz-color-neutral-04);
|
|
107
|
+
cursor: pointer;
|
|
108
|
+
min-width: 28px;
|
|
109
|
+
min-height: 28px;
|
|
110
|
+
}
|
|
111
|
+
.app .vz-icon-button:hover {
|
|
112
|
+
background: var(--vz-color-hover-dark);
|
|
113
|
+
}
|
|
114
|
+
.app .vz-icon-button:active {
|
|
115
|
+
background: var(--vz-color-active-dark);
|
|
116
|
+
}
|
|
117
|
+
.app .vz-icon-button:focus-visible {
|
|
118
|
+
outline: 2px solid var(--vz-color-action-01);
|
|
119
|
+
outline-offset: 2px;
|
|
120
|
+
}
|
|
121
|
+
.app .vz-color-success-01 {
|
|
122
|
+
color: var(--vz-color-success-01);
|
|
123
|
+
}
|
|
124
|
+
.app .file-or-directory {
|
|
125
|
+
user-select: none;
|
|
126
|
+
}
|
|
127
|
+
.vz-ui-button {
|
|
128
|
+
appearance: none;
|
|
129
|
+
display: inline-flex;
|
|
130
|
+
justify-content: center;
|
|
131
|
+
align-items: center;
|
|
132
|
+
gap: 6px;
|
|
133
|
+
border: 1px solid transparent;
|
|
134
|
+
border-radius: 4px;
|
|
135
|
+
padding: 6px 12px;
|
|
136
|
+
background: #e0e8ff;
|
|
137
|
+
color: #3866e9;
|
|
138
|
+
cursor: pointer;
|
|
139
|
+
font:
|
|
140
|
+
500 16px/1.5 Inter,
|
|
141
|
+
sans-serif;
|
|
142
|
+
}
|
|
143
|
+
.vz-ui-button:hover {
|
|
144
|
+
filter: brightness(0.95);
|
|
145
|
+
}
|
|
146
|
+
.vz-ui-button:focus-visible,
|
|
147
|
+
.vz-ui-control:focus-visible,
|
|
148
|
+
.vz-ui-close:focus-visible {
|
|
149
|
+
outline: 2px solid #3866e9;
|
|
150
|
+
outline-offset: 2px;
|
|
151
|
+
}
|
|
152
|
+
.vz-ui-button:disabled {
|
|
153
|
+
opacity: 0.5;
|
|
154
|
+
cursor: not-allowed;
|
|
155
|
+
}
|
|
156
|
+
.vz-ui-button--primary {
|
|
157
|
+
background: #3866e9;
|
|
158
|
+
color: #fff;
|
|
159
|
+
}
|
|
160
|
+
.vz-ui-button--danger {
|
|
161
|
+
background: #eb1c69;
|
|
162
|
+
color: #fff;
|
|
163
|
+
}
|
|
164
|
+
.vz-ui-button--outline-secondary {
|
|
165
|
+
background: transparent;
|
|
166
|
+
border-color: #576786;
|
|
167
|
+
color: #576786;
|
|
168
|
+
}
|
|
169
|
+
.vz-ui-button--outline-primary {
|
|
170
|
+
background: transparent;
|
|
171
|
+
border-color: #3866e9;
|
|
172
|
+
color: #3866e9;
|
|
173
|
+
}
|
|
174
|
+
.vz-ui-button--sm {
|
|
175
|
+
padding: 4px 8px;
|
|
176
|
+
font-size: 12px;
|
|
177
|
+
}
|
|
178
|
+
.vz-ui-field {
|
|
179
|
+
display: flex;
|
|
180
|
+
flex-direction: column;
|
|
181
|
+
gap: 5px;
|
|
182
|
+
margin-bottom: 16px;
|
|
183
|
+
}
|
|
184
|
+
.vz-ui-label {
|
|
185
|
+
font-size: 16px;
|
|
186
|
+
font-weight: 500;
|
|
187
|
+
color: #161514;
|
|
188
|
+
}
|
|
189
|
+
.vz-ui-control,
|
|
190
|
+
.vz-ui-select {
|
|
191
|
+
box-sizing: border-box;
|
|
192
|
+
width: 100%;
|
|
193
|
+
border: 1px solid #dee2e6;
|
|
194
|
+
border-radius: 4px;
|
|
195
|
+
background: transparent;
|
|
196
|
+
color: #161514;
|
|
197
|
+
padding: 6px 12px;
|
|
198
|
+
font:
|
|
199
|
+
400 16px/1.5 Inter,
|
|
200
|
+
sans-serif;
|
|
201
|
+
}
|
|
202
|
+
.vz-ui-help {
|
|
203
|
+
color: #797979;
|
|
204
|
+
font-size: 14px;
|
|
205
|
+
}
|
|
206
|
+
/* The same native field is also used in the dark file-search sidebar.
|
|
207
|
+
* Modal controls are light; editor controls remain legible on navy. */
|
|
208
|
+
.app .vz-ui-control {
|
|
209
|
+
background-color: var(--vz-color-neutral-02);
|
|
210
|
+
color: var(--vz-color-neutral-04);
|
|
211
|
+
border-color: var(--vz-color-neutral-03);
|
|
212
|
+
}
|
|
213
|
+
.app .vz-ui-control::placeholder {
|
|
214
|
+
color: var(--vz-color-neutral-04);
|
|
215
|
+
opacity: 0.65;
|
|
216
|
+
}
|
|
217
|
+
.vz-ui-modal {
|
|
218
|
+
box-sizing: border-box;
|
|
219
|
+
width: min(500px, calc(100vw - 32px));
|
|
220
|
+
max-height: calc(100dvh - 32px);
|
|
221
|
+
padding: 0;
|
|
222
|
+
border: 0;
|
|
223
|
+
border-radius: 4px;
|
|
224
|
+
background: white;
|
|
225
|
+
color: #161514;
|
|
226
|
+
box-shadow:
|
|
227
|
+
rgba(0, 0, 0, 0.15) 0 1px 4px,
|
|
228
|
+
0 16px 40px #0004;
|
|
229
|
+
font:
|
|
230
|
+
400 16px/1.5 Inter,
|
|
231
|
+
sans-serif;
|
|
232
|
+
}
|
|
233
|
+
.vz-ui-modal::backdrop {
|
|
234
|
+
background: rgba(0, 0, 0, 0.5);
|
|
235
|
+
}
|
|
236
|
+
.vz-ui-modal-content {
|
|
237
|
+
display: flex;
|
|
238
|
+
flex-direction: column;
|
|
239
|
+
}
|
|
240
|
+
.vz-ui-modal-header {
|
|
241
|
+
display: flex;
|
|
242
|
+
align-items: center;
|
|
243
|
+
justify-content: space-between;
|
|
244
|
+
gap: 16px;
|
|
245
|
+
padding: 16px 20px;
|
|
246
|
+
border-bottom: 1px solid #e6eaf2;
|
|
247
|
+
}
|
|
248
|
+
.vz-ui-modal-title {
|
|
249
|
+
font:
|
|
250
|
+
600 20px/1.2 Poppins,
|
|
251
|
+
sans-serif;
|
|
252
|
+
margin: 0;
|
|
253
|
+
}
|
|
254
|
+
.vz-ui-close {
|
|
255
|
+
border: 0;
|
|
256
|
+
border-radius: 4px;
|
|
257
|
+
background: none;
|
|
258
|
+
color: #576786;
|
|
259
|
+
cursor: pointer;
|
|
260
|
+
font-size: 24px;
|
|
261
|
+
padding: 0 5px;
|
|
262
|
+
line-height: 1;
|
|
263
|
+
}
|
|
264
|
+
.vz-ui-modal-body {
|
|
265
|
+
padding: 20px;
|
|
266
|
+
overflow: auto;
|
|
267
|
+
}
|
|
268
|
+
.vz-ui-modal-body p {
|
|
269
|
+
margin: 0 0 12px;
|
|
270
|
+
}
|
|
271
|
+
.vz-ui-modal-body ul {
|
|
272
|
+
padding-left: 22px;
|
|
273
|
+
}
|
|
274
|
+
.vz-ui-modal-body li {
|
|
275
|
+
margin: 8px 0;
|
|
276
|
+
}
|
|
277
|
+
.vz-ui-modal-body kbd {
|
|
278
|
+
padding: 2px 5px;
|
|
279
|
+
border-radius: 4px;
|
|
280
|
+
background: #e6eaf2;
|
|
281
|
+
}
|
|
282
|
+
.vz-ui-modal-footer {
|
|
283
|
+
display: flex;
|
|
284
|
+
justify-content: flex-end;
|
|
285
|
+
align-items: center;
|
|
286
|
+
gap: 10px;
|
|
287
|
+
padding: 14px 20px;
|
|
288
|
+
border-top: 1px solid #e6eaf2;
|
|
289
|
+
}
|
|
290
|
+
.vz-ui-tooltip-anchor {
|
|
291
|
+
display: inline-flex;
|
|
292
|
+
position: relative;
|
|
293
|
+
align-items: center;
|
|
294
|
+
}
|
|
295
|
+
.vz-ui-tooltip {
|
|
296
|
+
position: absolute;
|
|
297
|
+
pointer-events: none;
|
|
298
|
+
z-index: 30;
|
|
299
|
+
width: max-content;
|
|
300
|
+
max-width: 240px;
|
|
301
|
+
padding: 5px 9px;
|
|
302
|
+
border-radius: 6px;
|
|
303
|
+
background: #161514;
|
|
304
|
+
border: 1px solid #161514;
|
|
305
|
+
color: #fff;
|
|
306
|
+
font:
|
|
307
|
+
14px/1.5 Inter,
|
|
308
|
+
sans-serif;
|
|
309
|
+
white-space: normal;
|
|
310
|
+
box-shadow: 0 8px 20px #0006;
|
|
311
|
+
opacity: 0;
|
|
312
|
+
visibility: hidden;
|
|
313
|
+
}
|
|
314
|
+
.vz-ui-tooltip-floating {
|
|
315
|
+
position: fixed;
|
|
316
|
+
z-index: 10050;
|
|
317
|
+
pointer-events: none;
|
|
318
|
+
}
|
|
319
|
+
.vz-ui-tooltip-floating .vz-ui-tooltip {
|
|
320
|
+
position: static;
|
|
321
|
+
display: block;
|
|
322
|
+
opacity: 1;
|
|
323
|
+
visibility: visible;
|
|
324
|
+
}
|
|
@@ -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
|