mywhy-ui 0.3.1 → 0.5.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/dist/index.cjs +222 -134
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +68 -60
- package/dist/index.d.ts +68 -60
- package/dist/index.js +168 -80
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
-
var
|
|
4
|
+
var React10 = require('react');
|
|
5
5
|
var lucideReact = require('lucide-react');
|
|
6
6
|
var rosmsg = require('@foxglove/rosmsg');
|
|
7
7
|
var rosmsg2Serialization = require('@foxglove/rosmsg2-serialization');
|
|
@@ -11,7 +11,7 @@ var WebSocket = require('isomorphic-ws');
|
|
|
11
11
|
|
|
12
12
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var React10__default = /*#__PURE__*/_interopDefault(React10);
|
|
15
15
|
var WebSocket__default = /*#__PURE__*/_interopDefault(WebSocket);
|
|
16
16
|
|
|
17
17
|
var __typeError = (msg) => {
|
|
@@ -185,43 +185,117 @@ function Input({
|
|
|
185
185
|
error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-danger-text", children: error })
|
|
186
186
|
] });
|
|
187
187
|
}
|
|
188
|
-
var
|
|
189
|
-
sm: "h-7 px-2 text-sm",
|
|
190
|
-
md: "h-8 px-2.5 text-base",
|
|
191
|
-
lg: "h-9 px-3 text-md"
|
|
192
|
-
};
|
|
193
|
-
function Select({
|
|
188
|
+
var Select = ({
|
|
194
189
|
size = "md",
|
|
195
|
-
|
|
196
|
-
|
|
190
|
+
variant = "outline",
|
|
191
|
+
disabled = false,
|
|
192
|
+
value,
|
|
193
|
+
placeholder = "Select option",
|
|
197
194
|
options,
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}) {
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
195
|
+
onChange,
|
|
196
|
+
htmlId,
|
|
197
|
+
prefix
|
|
198
|
+
}) => {
|
|
199
|
+
const selectOptions = React10.useMemo(() => {
|
|
200
|
+
return options?.map((option) => {
|
|
201
|
+
if (typeof option === "string") {
|
|
202
|
+
return {
|
|
203
|
+
label: option,
|
|
204
|
+
value: option
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
return option;
|
|
208
|
+
}).filter(Boolean) || [];
|
|
209
|
+
}, [options]);
|
|
210
|
+
const handleChange = React10.useCallback(
|
|
211
|
+
(e) => {
|
|
212
|
+
onChange?.(e);
|
|
213
|
+
},
|
|
214
|
+
[onChange]
|
|
215
|
+
);
|
|
216
|
+
const heightClasses = React10.useMemo(() => {
|
|
217
|
+
return {
|
|
218
|
+
sm: "h-8",
|
|
219
|
+
md: "h-9",
|
|
220
|
+
lg: "h-10",
|
|
221
|
+
xl: "h-11"
|
|
222
|
+
}[size];
|
|
223
|
+
}, [size]);
|
|
224
|
+
const fontSizeClasses = React10.useMemo(() => {
|
|
225
|
+
return {
|
|
226
|
+
sm: "text-sm",
|
|
227
|
+
md: "text-sm",
|
|
228
|
+
lg: "text-base",
|
|
229
|
+
xl: "text-base"
|
|
230
|
+
}[size];
|
|
231
|
+
}, [size]);
|
|
232
|
+
const paddingClasses2 = React10.useMemo(() => {
|
|
233
|
+
return {
|
|
234
|
+
sm: "px-3 py-1.5",
|
|
235
|
+
md: "px-3 py-2",
|
|
236
|
+
lg: "px-4 py-2.5",
|
|
237
|
+
xl: "px-4 py-3"
|
|
238
|
+
}[size];
|
|
239
|
+
}, [size]);
|
|
240
|
+
const variantClasses2 = React10.useMemo(() => {
|
|
241
|
+
if (disabled) {
|
|
242
|
+
return "opacity-50 cursor-not-allowed";
|
|
243
|
+
}
|
|
244
|
+
return {
|
|
245
|
+
subtle: "border border-outline-gray-2 bg-surface-gray-2 hover:bg-surface-gray-3 hover:border-outline-gray-3",
|
|
246
|
+
outline: "border border-outline-gray-2 bg-surface-white hover:border-outline-gray-3",
|
|
247
|
+
ghost: "border border-transparent bg-transparent hover:bg-surface-gray-3"
|
|
248
|
+
}[variant];
|
|
249
|
+
}, [variant, disabled]);
|
|
250
|
+
const selectClass = React10.useMemo(() => {
|
|
251
|
+
return `
|
|
252
|
+
relative w-full ${heightClasses} ${fontSizeClasses} ${paddingClasses2}
|
|
253
|
+
rounded pr-10
|
|
254
|
+
${variantClasses2}
|
|
255
|
+
text-ink-gray-8 transition-colors cursor-pointer
|
|
256
|
+
focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-brand-light
|
|
257
|
+
`;
|
|
258
|
+
}, [heightClasses, fontSizeClasses, paddingClasses2, variantClasses2]);
|
|
259
|
+
const selectedOption = selectOptions.find((opt) => opt.value === value);
|
|
260
|
+
selectedOption?.label || placeholder;
|
|
261
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative w-full", children: [
|
|
262
|
+
prefix && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-y-0 left-0 flex items-center pl-2.5 pointer-events-none text-ink-gray-6", children: prefix?.(size) }),
|
|
263
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
264
|
+
"select",
|
|
265
|
+
{
|
|
266
|
+
id: htmlId,
|
|
267
|
+
className: selectClass,
|
|
268
|
+
disabled,
|
|
269
|
+
value: value || "",
|
|
270
|
+
onChange: handleChange,
|
|
271
|
+
"data-testid": "select",
|
|
272
|
+
style: {
|
|
273
|
+
WebkitAppearance: "none",
|
|
274
|
+
MozAppearance: "none",
|
|
275
|
+
appearance: "none",
|
|
276
|
+
backgroundImage: `url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%235a6c7d' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e")`,
|
|
277
|
+
backgroundRepeat: "no-repeat",
|
|
278
|
+
backgroundPosition: "right 0.5rem center",
|
|
279
|
+
backgroundSize: "1.5em 1.5em",
|
|
280
|
+
paddingRight: "2.5rem"
|
|
281
|
+
},
|
|
282
|
+
children: [
|
|
283
|
+
!value && /* @__PURE__ */ jsxRuntime.jsx("option", { value: "", children: placeholder }),
|
|
284
|
+
selectOptions.map((option) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
285
|
+
"option",
|
|
286
|
+
{
|
|
287
|
+
value: option.value,
|
|
288
|
+
disabled: option.disabled,
|
|
289
|
+
children: option.label
|
|
290
|
+
},
|
|
291
|
+
option.value
|
|
292
|
+
))
|
|
293
|
+
]
|
|
294
|
+
}
|
|
295
|
+
)
|
|
223
296
|
] });
|
|
224
|
-
}
|
|
297
|
+
};
|
|
298
|
+
var Select_default = Select;
|
|
225
299
|
function Switch({
|
|
226
300
|
label,
|
|
227
301
|
description,
|
|
@@ -325,7 +399,7 @@ function Badge({
|
|
|
325
399
|
}
|
|
326
400
|
);
|
|
327
401
|
}
|
|
328
|
-
var
|
|
402
|
+
var sizeClasses4 = {
|
|
329
403
|
xs: "w-5 h-5 text-2xs",
|
|
330
404
|
sm: "w-6 h-6 text-xs",
|
|
331
405
|
md: "w-8 h-8 text-sm",
|
|
@@ -338,10 +412,17 @@ var shapeClasses = {
|
|
|
338
412
|
};
|
|
339
413
|
var themeClasses = {
|
|
340
414
|
brand: "bg-brand text-white",
|
|
341
|
-
admin: "
|
|
342
|
-
operator: "
|
|
343
|
-
viewer: "
|
|
344
|
-
gray: "
|
|
415
|
+
admin: "text-white",
|
|
416
|
+
operator: "text-white",
|
|
417
|
+
viewer: "text-ink-light",
|
|
418
|
+
gray: "text-ink-light"
|
|
419
|
+
};
|
|
420
|
+
var themeStyles = {
|
|
421
|
+
brand: { backgroundColor: "#1A4B8C" },
|
|
422
|
+
admin: { backgroundColor: "#7C3AED" },
|
|
423
|
+
operator: { backgroundColor: "#0EA5E9" },
|
|
424
|
+
viewer: { backgroundColor: "#F8FAFC" },
|
|
425
|
+
gray: { backgroundColor: "#F1F5F9" }
|
|
345
426
|
};
|
|
346
427
|
function Avatar({
|
|
347
428
|
src,
|
|
@@ -352,7 +433,7 @@ function Avatar({
|
|
|
352
433
|
theme = "brand",
|
|
353
434
|
className = ""
|
|
354
435
|
}) {
|
|
355
|
-
const baseClass = `inline-flex items-center justify-center shrink-0 font-semibold overflow-hidden ${
|
|
436
|
+
const baseClass = `inline-flex items-center justify-center shrink-0 font-semibold overflow-hidden ${sizeClasses4[size]} ${shapeClasses[shape]}`;
|
|
356
437
|
if (src) {
|
|
357
438
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
358
439
|
"img",
|
|
@@ -364,7 +445,14 @@ function Avatar({
|
|
|
364
445
|
);
|
|
365
446
|
}
|
|
366
447
|
const displayInitials = initials ? initials.slice(0, 2).toUpperCase() : alt ? alt.slice(0, 2).toUpperCase() : "?";
|
|
367
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
448
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
449
|
+
"span",
|
|
450
|
+
{
|
|
451
|
+
className: `${baseClass} ${themeClasses[theme]} ${className}`,
|
|
452
|
+
style: themeStyles[theme],
|
|
453
|
+
children: displayInitials
|
|
454
|
+
}
|
|
455
|
+
);
|
|
368
456
|
}
|
|
369
457
|
var paddingClasses = {
|
|
370
458
|
none: "",
|
|
@@ -424,7 +512,7 @@ function Checkbox({
|
|
|
424
512
|
error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-danger-text ml-6", children: error })
|
|
425
513
|
] });
|
|
426
514
|
}
|
|
427
|
-
var
|
|
515
|
+
var sizeClasses5 = {
|
|
428
516
|
sm: "px-2 py-1.5 text-sm",
|
|
429
517
|
md: "px-2.5 py-2 text-base",
|
|
430
518
|
lg: "px-3 py-2.5 text-md"
|
|
@@ -451,7 +539,7 @@ function Textarea({
|
|
|
451
539
|
"disabled:opacity-50 disabled:cursor-not-allowed",
|
|
452
540
|
"transition-colors",
|
|
453
541
|
error ? "border-danger-border focus:ring-danger-icon" : "border-outline hover:border-outline-strong",
|
|
454
|
-
|
|
542
|
+
sizeClasses5[size],
|
|
455
543
|
resizeClasses[resize],
|
|
456
544
|
className
|
|
457
545
|
].filter(Boolean).join(" ");
|
|
@@ -489,7 +577,7 @@ function Alert({
|
|
|
489
577
|
className = "",
|
|
490
578
|
...props
|
|
491
579
|
}) {
|
|
492
|
-
const [isVisible, setIsVisible] =
|
|
580
|
+
const [isVisible, setIsVisible] = React10__default.default.useState(true);
|
|
493
581
|
const handleClose = () => {
|
|
494
582
|
setIsVisible(false);
|
|
495
583
|
onClose?.();
|
|
@@ -535,10 +623,10 @@ function MultiSelect({
|
|
|
535
623
|
className = "",
|
|
536
624
|
...props
|
|
537
625
|
}) {
|
|
538
|
-
const [isOpen, setIsOpen] =
|
|
539
|
-
const [searchTerm, setSearchTerm] =
|
|
540
|
-
const containerRef =
|
|
541
|
-
const inputRef =
|
|
626
|
+
const [isOpen, setIsOpen] = React10__default.default.useState(false);
|
|
627
|
+
const [searchTerm, setSearchTerm] = React10__default.default.useState("");
|
|
628
|
+
const containerRef = React10.useRef(null);
|
|
629
|
+
const inputRef = React10.useRef(null);
|
|
542
630
|
const filteredOptions = searchable ? options.filter(
|
|
543
631
|
(opt) => opt.label.toLowerCase().includes(searchTerm.toLowerCase())
|
|
544
632
|
) : options;
|
|
@@ -554,7 +642,7 @@ function MultiSelect({
|
|
|
554
642
|
onChange?.([]);
|
|
555
643
|
setSearchTerm("");
|
|
556
644
|
};
|
|
557
|
-
|
|
645
|
+
React10.useEffect(() => {
|
|
558
646
|
const handleClickOutside = (event) => {
|
|
559
647
|
if (containerRef.current && !containerRef.current.contains(event.target)) {
|
|
560
648
|
setIsOpen(false);
|
|
@@ -567,7 +655,7 @@ function MultiSelect({
|
|
|
567
655
|
document.removeEventListener("mousedown", handleClickOutside);
|
|
568
656
|
};
|
|
569
657
|
}, [isOpen]);
|
|
570
|
-
const
|
|
658
|
+
const sizeClasses12 = {
|
|
571
659
|
sm: "h-7 px-2 text-sm",
|
|
572
660
|
md: "h-8 px-3 text-base",
|
|
573
661
|
lg: "h-9 px-4 text-base"
|
|
@@ -585,7 +673,7 @@ function MultiSelect({
|
|
|
585
673
|
"focus-within:ring-2 focus-within:ring-brand focus-within:ring-offset-1",
|
|
586
674
|
disabled ? "bg-surface-gray opacity-50 cursor-not-allowed" : "bg-white",
|
|
587
675
|
error ? "border-danger-border" : "border-outline",
|
|
588
|
-
|
|
676
|
+
sizeClasses12[size]
|
|
589
677
|
].join(" "),
|
|
590
678
|
onClick: () => !disabled && setIsOpen(!isOpen),
|
|
591
679
|
children: [
|
|
@@ -708,7 +796,7 @@ function Tabs({
|
|
|
708
796
|
tabsClassName = "",
|
|
709
797
|
contentClassName = ""
|
|
710
798
|
}) {
|
|
711
|
-
const [internalActiveTab, setInternalActiveTab] =
|
|
799
|
+
const [internalActiveTab, setInternalActiveTab] = React10__default.default.useState(activeTab || tabs[0]?.value || "");
|
|
712
800
|
const active = activeTab !== void 0 ? activeTab : internalActiveTab;
|
|
713
801
|
const handleTabChange = (value) => {
|
|
714
802
|
setInternalActiveTab(value);
|
|
@@ -765,7 +853,7 @@ function Breadcrumbs({
|
|
|
765
853
|
className = "",
|
|
766
854
|
...props
|
|
767
855
|
}) {
|
|
768
|
-
return /* @__PURE__ */ jsxRuntime.jsx("nav", { className: `flex items-center gap-0 text-sm ${className}`, ...props, children: items.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
856
|
+
return /* @__PURE__ */ jsxRuntime.jsx("nav", { className: `flex items-center gap-0 text-sm ${className}`, ...props, children: items.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs(React10__default.default.Fragment, { children: [
|
|
769
857
|
index > 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-ink-light px-1.5", children: separator }),
|
|
770
858
|
item.href ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
771
859
|
"a",
|
|
@@ -807,16 +895,16 @@ function Dropdown({
|
|
|
807
895
|
triggerClassName = "",
|
|
808
896
|
menuClassName = ""
|
|
809
897
|
}) {
|
|
810
|
-
const [internalIsOpen, setInternalIsOpen] =
|
|
811
|
-
const containerRef =
|
|
812
|
-
const menuRef =
|
|
898
|
+
const [internalIsOpen, setInternalIsOpen] = React10__default.default.useState(false);
|
|
899
|
+
const containerRef = React10.useRef(null);
|
|
900
|
+
const menuRef = React10.useRef(null);
|
|
813
901
|
const isOpen = controlledIsOpen !== void 0 ? controlledIsOpen : internalIsOpen;
|
|
814
902
|
const toggleOpen = () => {
|
|
815
903
|
const newState = !isOpen;
|
|
816
904
|
setInternalIsOpen(newState);
|
|
817
905
|
onOpenChange?.(newState);
|
|
818
906
|
};
|
|
819
|
-
|
|
907
|
+
React10.useEffect(() => {
|
|
820
908
|
const handleClickOutside = (event) => {
|
|
821
909
|
if (containerRef.current && !containerRef.current.contains(event.target)) {
|
|
822
910
|
setInternalIsOpen(false);
|
|
@@ -874,7 +962,7 @@ function Dropdown({
|
|
|
874
962
|
)
|
|
875
963
|
] });
|
|
876
964
|
}
|
|
877
|
-
var
|
|
965
|
+
var sizeClasses6 = {
|
|
878
966
|
sm: "max-w-sm",
|
|
879
967
|
md: "max-w-md",
|
|
880
968
|
lg: "max-w-lg",
|
|
@@ -889,8 +977,8 @@ function Dialog({
|
|
|
889
977
|
footer,
|
|
890
978
|
className = ""
|
|
891
979
|
}) {
|
|
892
|
-
const overlayRef =
|
|
893
|
-
|
|
980
|
+
const overlayRef = React10.useRef(null);
|
|
981
|
+
React10.useEffect(() => {
|
|
894
982
|
if (!open) return;
|
|
895
983
|
const onKey = (e) => {
|
|
896
984
|
if (e.key === "Escape") onClose();
|
|
@@ -898,7 +986,7 @@ function Dialog({
|
|
|
898
986
|
document.addEventListener("keydown", onKey);
|
|
899
987
|
return () => document.removeEventListener("keydown", onKey);
|
|
900
988
|
}, [open, onClose]);
|
|
901
|
-
|
|
989
|
+
React10.useEffect(() => {
|
|
902
990
|
document.body.style.overflow = open ? "hidden" : "";
|
|
903
991
|
return () => {
|
|
904
992
|
document.body.style.overflow = "";
|
|
@@ -921,7 +1009,7 @@ function Dialog({
|
|
|
921
1009
|
role: "dialog",
|
|
922
1010
|
"aria-modal": "true",
|
|
923
1011
|
"aria-labelledby": title ? "dialog-title" : void 0,
|
|
924
|
-
className: `relative w-full ${
|
|
1012
|
+
className: `relative w-full ${sizeClasses6[size]} bg-surface rounded-xl shadow-dialog border border-outline flex flex-col max-h-[90vh] ${className}`,
|
|
925
1013
|
children: [
|
|
926
1014
|
title && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between px-5 py-4 border-b border-outline shrink-0", children: [
|
|
927
1015
|
/* @__PURE__ */ jsxRuntime.jsx("h2", { id: "dialog-title", className: "text-md font-semibold text-ink", children: title }),
|
|
@@ -982,7 +1070,7 @@ function Toast({
|
|
|
982
1070
|
onClose,
|
|
983
1071
|
className = ""
|
|
984
1072
|
}) {
|
|
985
|
-
|
|
1073
|
+
React10.useEffect(() => {
|
|
986
1074
|
if (!duration || !onClose) return;
|
|
987
1075
|
const timer = setTimeout(onClose, duration);
|
|
988
1076
|
return () => clearTimeout(timer);
|
|
@@ -1029,8 +1117,8 @@ function Tooltip({
|
|
|
1029
1117
|
children,
|
|
1030
1118
|
className = ""
|
|
1031
1119
|
}) {
|
|
1032
|
-
const [visible, setVisible] =
|
|
1033
|
-
const timerRef =
|
|
1120
|
+
const [visible, setVisible] = React10.useState(false);
|
|
1121
|
+
const timerRef = React10.useRef(null);
|
|
1034
1122
|
const show = () => {
|
|
1035
1123
|
timerRef.current = setTimeout(() => setVisible(true), delay);
|
|
1036
1124
|
};
|
|
@@ -1038,7 +1126,7 @@ function Tooltip({
|
|
|
1038
1126
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
1039
1127
|
setVisible(false);
|
|
1040
1128
|
};
|
|
1041
|
-
|
|
1129
|
+
React10.useEffect(() => () => {
|
|
1042
1130
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
1043
1131
|
}, []);
|
|
1044
1132
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -1099,9 +1187,9 @@ function FileUploader({
|
|
|
1099
1187
|
className = "",
|
|
1100
1188
|
...props
|
|
1101
1189
|
}) {
|
|
1102
|
-
const [dragActive, setDragActive] =
|
|
1103
|
-
const [files, setFiles] =
|
|
1104
|
-
const inputRef =
|
|
1190
|
+
const [dragActive, setDragActive] = React10__default.default.useState(false);
|
|
1191
|
+
const [files, setFiles] = React10__default.default.useState([]);
|
|
1192
|
+
const inputRef = React10__default.default.useRef(null);
|
|
1105
1193
|
const handleFiles = (fileList) => {
|
|
1106
1194
|
if (!fileList) return;
|
|
1107
1195
|
let newFiles = Array.from(fileList);
|
|
@@ -1251,12 +1339,12 @@ function DatePicker({
|
|
|
1251
1339
|
className = "",
|
|
1252
1340
|
...props
|
|
1253
1341
|
}) {
|
|
1254
|
-
const [isOpen, setIsOpen] =
|
|
1255
|
-
const containerRef =
|
|
1342
|
+
const [isOpen, setIsOpen] = React10__default.default.useState(false);
|
|
1343
|
+
const containerRef = React10.useRef(null);
|
|
1256
1344
|
const handleDateChange = (e) => {
|
|
1257
1345
|
onChange?.(e.target.value);
|
|
1258
1346
|
};
|
|
1259
|
-
|
|
1347
|
+
React10.useEffect(() => {
|
|
1260
1348
|
const handleClickOutside = (event) => {
|
|
1261
1349
|
if (containerRef.current && !containerRef.current.contains(event.target)) {
|
|
1262
1350
|
setIsOpen(false);
|
|
@@ -1342,12 +1430,12 @@ function TimePicker({
|
|
|
1342
1430
|
className = "",
|
|
1343
1431
|
...props
|
|
1344
1432
|
}) {
|
|
1345
|
-
const [isOpen, setIsOpen] =
|
|
1346
|
-
const containerRef =
|
|
1433
|
+
const [isOpen, setIsOpen] = React10__default.default.useState(false);
|
|
1434
|
+
const containerRef = React10.useRef(null);
|
|
1347
1435
|
const handleTimeChange = (e) => {
|
|
1348
1436
|
onChange?.(e.target.value);
|
|
1349
1437
|
};
|
|
1350
|
-
|
|
1438
|
+
React10.useEffect(() => {
|
|
1351
1439
|
const handleClickOutside = (event) => {
|
|
1352
1440
|
if (containerRef.current && !containerRef.current.contains(event.target)) {
|
|
1353
1441
|
setIsOpen(false);
|
|
@@ -1421,7 +1509,7 @@ function TimePicker({
|
|
|
1421
1509
|
error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-danger-text mt-1", children: error })
|
|
1422
1510
|
] });
|
|
1423
1511
|
}
|
|
1424
|
-
var
|
|
1512
|
+
var sizeClasses7 = {
|
|
1425
1513
|
sm: "h-1.5",
|
|
1426
1514
|
md: "h-2.5",
|
|
1427
1515
|
lg: "h-4"
|
|
@@ -1452,11 +1540,11 @@ function Progress({
|
|
|
1452
1540
|
"%"
|
|
1453
1541
|
] })
|
|
1454
1542
|
] }),
|
|
1455
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: `w-full bg-surface-gray rounded-full overflow-hidden ${
|
|
1543
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: `w-full bg-surface-gray rounded-full overflow-hidden ${sizeClasses7[size]}`, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1456
1544
|
"div",
|
|
1457
1545
|
{
|
|
1458
1546
|
className: [
|
|
1459
|
-
`${themeClasses3[theme]} ${
|
|
1547
|
+
`${themeClasses3[theme]} ${sizeClasses7[size]} rounded-full transition-all duration-300`,
|
|
1460
1548
|
striped ? "bg-gradient-to-r from-transparent to-white opacity-30" : "",
|
|
1461
1549
|
animated ? "animate-pulse" : ""
|
|
1462
1550
|
].join(" "),
|
|
@@ -1465,7 +1553,7 @@ function Progress({
|
|
|
1465
1553
|
) })
|
|
1466
1554
|
] });
|
|
1467
1555
|
}
|
|
1468
|
-
var
|
|
1556
|
+
var sizeClasses8 = {
|
|
1469
1557
|
sm: "w-4 h-4",
|
|
1470
1558
|
md: "w-5 h-5",
|
|
1471
1559
|
lg: "w-6 h-6"
|
|
@@ -1486,7 +1574,7 @@ function Rating({
|
|
|
1486
1574
|
className = "",
|
|
1487
1575
|
...props
|
|
1488
1576
|
}) {
|
|
1489
|
-
const [hoverValue, setHoverValue] =
|
|
1577
|
+
const [hoverValue, setHoverValue] = React10__default.default.useState(0);
|
|
1490
1578
|
const displayValue = hoverValue || value;
|
|
1491
1579
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, ...props, children: [
|
|
1492
1580
|
label && /* @__PURE__ */ jsxRuntime.jsx("label", { className: "block text-sm font-medium text-ink mb-2", children: label }),
|
|
@@ -1501,7 +1589,7 @@ function Rating({
|
|
|
1501
1589
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1502
1590
|
"svg",
|
|
1503
1591
|
{
|
|
1504
|
-
className: `${
|
|
1592
|
+
className: `${sizeClasses8[size]} ${starValue <= displayValue ? `fill-current ${colorClasses2[color]}` : "text-outline"}`,
|
|
1505
1593
|
viewBox: "0 0 20 20",
|
|
1506
1594
|
fill: "currentColor",
|
|
1507
1595
|
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z" })
|
|
@@ -1794,7 +1882,7 @@ function EmptyState({
|
|
|
1794
1882
|
}
|
|
1795
1883
|
var ChevronUpIcon = ({ size }) => /* @__PURE__ */ jsxRuntime.jsx("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "18 15 12 9 6 15" }) });
|
|
1796
1884
|
var ChevronDownIcon = ({ size }) => /* @__PURE__ */ jsxRuntime.jsx("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "6 9 12 15 18 9" }) });
|
|
1797
|
-
var
|
|
1885
|
+
var sizeClasses9 = {
|
|
1798
1886
|
sm: "text-xs px-2 py-1 h-8",
|
|
1799
1887
|
md: "text-sm px-3 py-2 h-10",
|
|
1800
1888
|
lg: "text-base px-4 py-2.5 h-12"
|
|
@@ -1810,7 +1898,7 @@ function NumberInput({
|
|
|
1810
1898
|
placeholder,
|
|
1811
1899
|
className = ""
|
|
1812
1900
|
}) {
|
|
1813
|
-
const [isEditing, setIsEditing] =
|
|
1901
|
+
const [isEditing, setIsEditing] = React10.useState(false);
|
|
1814
1902
|
const handleIncrement = () => {
|
|
1815
1903
|
const newValue = value + step;
|
|
1816
1904
|
if (max === void 0 || newValue <= max) {
|
|
@@ -1848,7 +1936,7 @@ function NumberInput({
|
|
|
1848
1936
|
max,
|
|
1849
1937
|
className: `
|
|
1850
1938
|
flex-1 bg-transparent outline-none text-ink disabled:text-ink-faint disabled:cursor-not-allowed
|
|
1851
|
-
${
|
|
1939
|
+
${sizeClasses9[size]}
|
|
1852
1940
|
`
|
|
1853
1941
|
}
|
|
1854
1942
|
),
|
|
@@ -1889,7 +1977,7 @@ function CodeBlock({
|
|
|
1889
1977
|
maxHeight = "max-h-96",
|
|
1890
1978
|
className = ""
|
|
1891
1979
|
}) {
|
|
1892
|
-
const [copied, setCopied] =
|
|
1980
|
+
const [copied, setCopied] = React10.useState(false);
|
|
1893
1981
|
const handleCopy = async () => {
|
|
1894
1982
|
try {
|
|
1895
1983
|
await navigator.clipboard.writeText(code);
|
|
@@ -2008,7 +2096,7 @@ function Timeline({
|
|
|
2008
2096
|
] }, item.id);
|
|
2009
2097
|
}) });
|
|
2010
2098
|
}
|
|
2011
|
-
var
|
|
2099
|
+
var sizeClasses10 = {
|
|
2012
2100
|
xs: "text-xs px-1.5 py-0.5 min-w-5 h-5",
|
|
2013
2101
|
sm: "text-xs px-2 py-1 min-w-6 h-6",
|
|
2014
2102
|
md: "text-sm px-2.5 py-1.5 min-w-8 h-8"
|
|
@@ -2025,14 +2113,14 @@ function Kbd({
|
|
|
2025
2113
|
className = ""
|
|
2026
2114
|
}) {
|
|
2027
2115
|
const keyArray = Array.isArray(keys) ? keys : [keys];
|
|
2028
|
-
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: `inline-flex items-center gap-1 ${className}`, children: keyArray.map((key, i) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2116
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: `inline-flex items-center gap-1 ${className}`, children: keyArray.map((key, i) => /* @__PURE__ */ jsxRuntime.jsxs(React10__default.default.Fragment, { children: [
|
|
2029
2117
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2030
2118
|
"kbd",
|
|
2031
2119
|
{
|
|
2032
2120
|
className: `
|
|
2033
2121
|
inline-flex items-center justify-center rounded font-mono font-medium
|
|
2034
2122
|
border border-b-2 shadow-sm
|
|
2035
|
-
${
|
|
2123
|
+
${sizeClasses10[size]}
|
|
2036
2124
|
${themeClasses5[theme]}
|
|
2037
2125
|
`,
|
|
2038
2126
|
children: key
|
|
@@ -2115,7 +2203,7 @@ function StatusBadge({
|
|
|
2115
2203
|
}
|
|
2116
2204
|
);
|
|
2117
2205
|
}
|
|
2118
|
-
var
|
|
2206
|
+
var sizeClasses11 = {
|
|
2119
2207
|
sm: "text-xs gap-1.5",
|
|
2120
2208
|
md: "text-sm gap-2",
|
|
2121
2209
|
lg: "text-base gap-2"
|
|
@@ -2134,7 +2222,7 @@ function ConnectionIndicator({
|
|
|
2134
2222
|
className = ""
|
|
2135
2223
|
}) {
|
|
2136
2224
|
const status = connected ? "online" : "offline";
|
|
2137
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `inline-flex items-center ${
|
|
2225
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `inline-flex items-center ${sizeClasses11[size]} ${className}`, children: [
|
|
2138
2226
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2139
2227
|
StatusBadge,
|
|
2140
2228
|
{
|
|
@@ -2713,9 +2801,9 @@ var RosConnectionManager = ({
|
|
|
2713
2801
|
onConnectionStatusChange,
|
|
2714
2802
|
onClearHistory
|
|
2715
2803
|
}) => {
|
|
2716
|
-
const staleTimeoutId =
|
|
2717
|
-
const retryTimeoutId =
|
|
2718
|
-
|
|
2804
|
+
const staleTimeoutId = React10.useRef(0);
|
|
2805
|
+
const retryTimeoutId = React10.useRef(0);
|
|
2806
|
+
React10.useEffect(() => {
|
|
2719
2807
|
if (!url) {
|
|
2720
2808
|
console.warn("WebSocket URL is not set correctly. Skipping WebSocket configuration.");
|
|
2721
2809
|
return;
|
|
@@ -2736,7 +2824,7 @@ var RosConnectionManager = ({
|
|
|
2736
2824
|
ros.connect(url);
|
|
2737
2825
|
ros.on("connection", () => {
|
|
2738
2826
|
onClearHistory();
|
|
2739
|
-
console.log("Connected to
|
|
2827
|
+
console.log("Connected to mRobotic server at " + url);
|
|
2740
2828
|
onConnectionStatusChange(true);
|
|
2741
2829
|
diagnosticsTopic.subscribe((message) => {
|
|
2742
2830
|
clearTimeout(staleTimeoutId.current);
|
|
@@ -2776,12 +2864,12 @@ var RosConnectionManager = ({
|
|
|
2776
2864
|
console.log(`Subscribed to topic: ${diagnosticsTopic.name}`);
|
|
2777
2865
|
});
|
|
2778
2866
|
ros.on("error", (error) => {
|
|
2779
|
-
console.error("Error connecting to
|
|
2867
|
+
console.error("Error connecting to mRobotic server:", error);
|
|
2780
2868
|
ros.close();
|
|
2781
2869
|
});
|
|
2782
2870
|
ros.on("close", () => {
|
|
2783
2871
|
onConnectionStatusChange(false);
|
|
2784
|
-
console.log("Connection to
|
|
2872
|
+
console.log("Connection to mRobotic server closed");
|
|
2785
2873
|
onClearHistory();
|
|
2786
2874
|
clearTimeout(staleTimeoutId.current);
|
|
2787
2875
|
clearTimeout(retryTimeoutId.current);
|
|
@@ -2822,15 +2910,15 @@ var sameNamespace = (ns1, ns2) => {
|
|
|
2822
2910
|
// src/components/ROS2Diagnostics/hooks/useNamespace.ts
|
|
2823
2911
|
var NAMESPACE_STORAGE_KEY = "ros2_diag_namespace";
|
|
2824
2912
|
var useNamespace = (initialNamespace = "/robot") => {
|
|
2825
|
-
const [namespace, setNamespace] =
|
|
2826
|
-
const [invalidNamespaceMessage, setInvalidNamespaceMessage] =
|
|
2827
|
-
const [manualEntryRequired, setManualEntryRequired] =
|
|
2828
|
-
const setManualNamespace =
|
|
2913
|
+
const [namespace, setNamespace] = React10.useState("");
|
|
2914
|
+
const [invalidNamespaceMessage, setInvalidNamespaceMessage] = React10.useState(null);
|
|
2915
|
+
const [manualEntryRequired, setManualEntryRequired] = React10.useState(false);
|
|
2916
|
+
const setManualNamespace = React10.useCallback((ns) => {
|
|
2829
2917
|
const ns_temp = sanitizeNamespace(ns);
|
|
2830
2918
|
setNamespace(ns_temp);
|
|
2831
2919
|
localStorage.setItem(NAMESPACE_STORAGE_KEY, ns_temp);
|
|
2832
2920
|
}, []);
|
|
2833
|
-
|
|
2921
|
+
React10.useEffect(() => {
|
|
2834
2922
|
const savedNamespace = localStorage.getItem(NAMESPACE_STORAGE_KEY);
|
|
2835
2923
|
if (savedNamespace) {
|
|
2836
2924
|
console.log("Using namespace from storage:", savedNamespace);
|
|
@@ -2854,8 +2942,8 @@ var useNamespace = (initialNamespace = "/robot") => {
|
|
|
2854
2942
|
return { namespace, setManualNamespace, invalidNamespaceMessage, manualEntryRequired };
|
|
2855
2943
|
};
|
|
2856
2944
|
var useWebSocketUrl = (customUrl) => {
|
|
2857
|
-
const [url, setUrl] =
|
|
2858
|
-
|
|
2945
|
+
const [url, setUrl] = React10.useState(customUrl || null);
|
|
2946
|
+
React10.useEffect(() => {
|
|
2859
2947
|
if (customUrl) {
|
|
2860
2948
|
setUrl(customUrl);
|
|
2861
2949
|
return;
|
|
@@ -2894,15 +2982,15 @@ var ManualNamespace = ({
|
|
|
2894
2982
|
setManualNamespace,
|
|
2895
2983
|
namespace
|
|
2896
2984
|
}) => {
|
|
2897
|
-
const [value, setValue] =
|
|
2898
|
-
const [unsaved, setUnsaved] =
|
|
2899
|
-
const [invalidNamespaceMessage, setInvalidNamespaceMessage] =
|
|
2900
|
-
const [isError, setIsError] =
|
|
2901
|
-
|
|
2985
|
+
const [value, setValue] = React10.useState(namespace);
|
|
2986
|
+
const [unsaved, setUnsaved] = React10.useState(false);
|
|
2987
|
+
const [invalidNamespaceMessage, setInvalidNamespaceMessage] = React10.useState("");
|
|
2988
|
+
const [isError, setIsError] = React10.useState(false);
|
|
2989
|
+
React10.useEffect(() => {
|
|
2902
2990
|
const isSame = sameNamespace(namespace, sanitizeNamespace(value));
|
|
2903
2991
|
setUnsaved(!isSame);
|
|
2904
2992
|
}, [namespace, value]);
|
|
2905
|
-
|
|
2993
|
+
React10.useEffect(() => {
|
|
2906
2994
|
const sanitizedValue = sanitizeNamespace(value);
|
|
2907
2995
|
const isSame = sameNamespace(value, sanitizedValue);
|
|
2908
2996
|
setIsError(!isSame);
|
|
@@ -2958,8 +3046,8 @@ var HistorySelection = ({
|
|
|
2958
3046
|
isPaused,
|
|
2959
3047
|
setIsPaused
|
|
2960
3048
|
}) => {
|
|
2961
|
-
const [negIndex, setNegIndex] =
|
|
2962
|
-
|
|
3049
|
+
const [negIndex, setNegIndex] = React10.useState(-1);
|
|
3050
|
+
React10.useEffect(() => {
|
|
2963
3051
|
if (!isPaused) {
|
|
2964
3052
|
setNegIndex(-1);
|
|
2965
3053
|
if (diagHistory.length > 0) {
|
|
@@ -3020,15 +3108,15 @@ var HistorySelection = ({
|
|
|
3020
3108
|
};
|
|
3021
3109
|
var HISTORY_SIZE2 = 30;
|
|
3022
3110
|
var useDiagHistory = (isPaused) => {
|
|
3023
|
-
const [diagHistory, setDiagHistory] =
|
|
3024
|
-
const isPausedRef =
|
|
3025
|
-
|
|
3111
|
+
const [diagHistory, setDiagHistory] = React10.useState([]);
|
|
3112
|
+
const isPausedRef = React10.useRef(isPaused);
|
|
3113
|
+
React10.useEffect(() => {
|
|
3026
3114
|
isPausedRef.current = isPaused;
|
|
3027
3115
|
}, [isPaused]);
|
|
3028
|
-
const clearDiagHistory =
|
|
3116
|
+
const clearDiagHistory = React10.useCallback(() => {
|
|
3029
3117
|
setDiagHistory([]);
|
|
3030
3118
|
}, []);
|
|
3031
|
-
const updateDiagHistory =
|
|
3119
|
+
const updateDiagHistory = React10.useCallback((diagStatusLatest) => {
|
|
3032
3120
|
if (!isPausedRef.current && diagStatusLatest && diagStatusLatest.diagnostics.length > 0) {
|
|
3033
3121
|
setDiagHistory((prevItems) => {
|
|
3034
3122
|
const updatedItems = [...prevItems, diagStatusLatest];
|
|
@@ -3042,7 +3130,7 @@ var useDiagHistory = (isPaused) => {
|
|
|
3042
3130
|
return { diagHistory, updateDiagHistory, clearDiagHistory };
|
|
3043
3131
|
};
|
|
3044
3132
|
var ROS2Diagnostics = ({
|
|
3045
|
-
|
|
3133
|
+
mroboticServerUrl,
|
|
3046
3134
|
namespace: initialNamespace = "/robot",
|
|
3047
3135
|
onDiagnosticUpdate
|
|
3048
3136
|
}) => {
|
|
@@ -3052,11 +3140,11 @@ var ROS2Diagnostics = ({
|
|
|
3052
3140
|
invalidNamespaceMessage,
|
|
3053
3141
|
manualEntryRequired
|
|
3054
3142
|
} = useNamespace(initialNamespace);
|
|
3055
|
-
const wsUrl = useWebSocketUrl(
|
|
3056
|
-
const [diagStatusDisplay, setDiagStatusDisplay] =
|
|
3057
|
-
const [bridgeConnected, setBridgeConnected] =
|
|
3058
|
-
const [selectedRawName, setSelectedRawName] =
|
|
3059
|
-
const [isPaused, setIsPaused] =
|
|
3143
|
+
const wsUrl = useWebSocketUrl(mroboticServerUrl);
|
|
3144
|
+
const [diagStatusDisplay, setDiagStatusDisplay] = React10.useState(null);
|
|
3145
|
+
const [bridgeConnected, setBridgeConnected] = React10.useState(false);
|
|
3146
|
+
const [selectedRawName, setSelectedRawName] = React10.useState(null);
|
|
3147
|
+
const [isPaused, setIsPaused] = React10.useState(false);
|
|
3060
3148
|
const {
|
|
3061
3149
|
diagHistory,
|
|
3062
3150
|
updateDiagHistory,
|
|
@@ -3076,7 +3164,7 @@ var ROS2Diagnostics = ({
|
|
|
3076
3164
|
{
|
|
3077
3165
|
variant: isPaused ? "solid" : "subtle",
|
|
3078
3166
|
theme: "brand",
|
|
3079
|
-
size: "
|
|
3167
|
+
size: "md",
|
|
3080
3168
|
onClick: () => {
|
|
3081
3169
|
if (isPaused) clearDiagHistory();
|
|
3082
3170
|
setIsPaused(!isPaused);
|
|
@@ -3121,7 +3209,7 @@ var ROS2Diagnostics = ({
|
|
|
3121
3209
|
theme: "warning",
|
|
3122
3210
|
title: "Waiting for connection...",
|
|
3123
3211
|
children: [
|
|
3124
|
-
"Attempting to connect to
|
|
3212
|
+
"Attempting to connect to mRobotic server at ",
|
|
3125
3213
|
wsUrl
|
|
3126
3214
|
]
|
|
3127
3215
|
}
|
|
@@ -3159,21 +3247,21 @@ var ROS2Diagnostics = ({
|
|
|
3159
3247
|
] });
|
|
3160
3248
|
};
|
|
3161
3249
|
function useDisclosure(initial = false) {
|
|
3162
|
-
const [isOpen, setIsOpen] =
|
|
3163
|
-
const open =
|
|
3164
|
-
const close =
|
|
3165
|
-
const toggle =
|
|
3250
|
+
const [isOpen, setIsOpen] = React10.useState(initial);
|
|
3251
|
+
const open = React10.useCallback(() => setIsOpen(true), []);
|
|
3252
|
+
const close = React10.useCallback(() => setIsOpen(false), []);
|
|
3253
|
+
const toggle = React10.useCallback(() => setIsOpen((v) => !v), []);
|
|
3166
3254
|
return { isOpen, open, close, toggle };
|
|
3167
3255
|
}
|
|
3168
3256
|
var counter = 0;
|
|
3169
3257
|
function useToast() {
|
|
3170
|
-
const [toasts, setToasts] =
|
|
3171
|
-
const addToast =
|
|
3258
|
+
const [toasts, setToasts] = React10.useState([]);
|
|
3259
|
+
const addToast = React10.useCallback((props) => {
|
|
3172
3260
|
const id = `toast-${++counter}`;
|
|
3173
3261
|
setToasts((prev) => [...prev, { ...props, id }]);
|
|
3174
3262
|
return id;
|
|
3175
3263
|
}, []);
|
|
3176
|
-
const removeToast =
|
|
3264
|
+
const removeToast = React10.useCallback((id) => {
|
|
3177
3265
|
setToasts((prev) => prev.filter((t) => t.id !== id));
|
|
3178
3266
|
}, []);
|
|
3179
3267
|
return { toasts, addToast, removeToast };
|
|
@@ -3204,7 +3292,7 @@ exports.Pagination = Pagination;
|
|
|
3204
3292
|
exports.Progress = Progress;
|
|
3205
3293
|
exports.ROS2Diagnostics = ROS2Diagnostics;
|
|
3206
3294
|
exports.Rating = Rating;
|
|
3207
|
-
exports.Select =
|
|
3295
|
+
exports.Select = Select_default;
|
|
3208
3296
|
exports.Sidebar = Sidebar;
|
|
3209
3297
|
exports.Slider = Slider;
|
|
3210
3298
|
exports.Spinner = Spinner;
|