@wandelbots/wandelbots-js-react-components 2.35.0-pr.feature-replace-forwardref.376.d3a302b → 2.35.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 +1 -1
- package/dist/components/CopyableText.d.ts +2 -3
- package/dist/components/CopyableText.d.ts.map +1 -1
- package/dist/components/SelectableFab.d.ts +1 -2
- package/dist/components/SelectableFab.d.ts.map +1 -1
- package/dist/components/TabBar.d.ts +0 -2
- package/dist/components/TabBar.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +208 -208
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/components/CopyableText.tsx +73 -70
- package/src/components/LogViewer.tsx +1 -1
- package/src/components/SelectableFab.tsx +15 -14
- package/src/components/TabBar.tsx +1 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wandelbots/wandelbots-js-react-components",
|
|
3
|
-
"version": "2.35.0
|
|
3
|
+
"version": "2.35.0",
|
|
4
4
|
"description": "React UI toolkit for building applications on top of the Wandelbots platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
"@rollup/plugin-node-resolve": "^16.0.0",
|
|
60
60
|
"@rollup/plugin-terser": "^0.4.4",
|
|
61
61
|
"@rollup/plugin-typescript": "^12.1.2",
|
|
62
|
-
"@storybook/addon-docs": "^9.1.
|
|
63
|
-
"@storybook/react-vite": "^9.1.
|
|
62
|
+
"@storybook/addon-docs": "^9.1.2",
|
|
63
|
+
"@storybook/react-vite": "^9.1.2",
|
|
64
64
|
"@storybook/test-runner": "^0.23.0",
|
|
65
65
|
"@svgr/rollup": "^8.1.0",
|
|
66
66
|
"@testing-library/jest-dom": "^6.6.3",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"@vitejs/plugin-react": "^4.3.4",
|
|
73
73
|
"@wandelbots/nova-js": "^2.1.0",
|
|
74
74
|
"add": "^2.0.6",
|
|
75
|
-
"eslint-plugin-storybook": "^9.1.
|
|
75
|
+
"eslint-plugin-storybook": "^9.1.2",
|
|
76
76
|
"glob": "^11.0.1",
|
|
77
77
|
"http-server": "^14.1.1",
|
|
78
78
|
"husky": "^9.1.7",
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
96
96
|
"rollup-plugin-postcss": "^4.0.2",
|
|
97
97
|
"semantic-release": "^24.2.3",
|
|
98
|
-
"storybook": "^9.1.
|
|
98
|
+
"storybook": "^9.1.2",
|
|
99
99
|
"storybook-preset-inline-svg": "^1.0.1",
|
|
100
100
|
"three": "^0.174.0",
|
|
101
101
|
"three-stdlib": "^2.35.14",
|
|
@@ -1,84 +1,87 @@
|
|
|
1
1
|
import { Stack, Tooltip, Typography, useTheme } from "@mui/material"
|
|
2
|
-
import { useEffect, useState } from "react"
|
|
2
|
+
import { forwardRef, useEffect, useState } from "react"
|
|
3
3
|
|
|
4
|
-
export const CopyableText = (
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
export const CopyableText = forwardRef(
|
|
5
|
+
(
|
|
6
|
+
{
|
|
7
|
+
label,
|
|
8
|
+
value,
|
|
9
|
+
}: {
|
|
10
|
+
label?: string
|
|
11
|
+
value: string
|
|
12
|
+
},
|
|
13
|
+
ref: React.ForwardedRef<HTMLDivElement>,
|
|
14
|
+
) => {
|
|
15
|
+
const theme = useTheme()
|
|
16
|
+
const [tooltipOpen, setTooltipOpen] = useState(false)
|
|
13
17
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
async function onCopyText(): Promise<boolean> {
|
|
19
|
+
if (!ref || !("current" in ref)) {
|
|
20
|
+
console.warn("No copy target found")
|
|
21
|
+
return false
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
await navigator.clipboard.writeText(value)
|
|
25
|
+
console.log("Copied!")
|
|
26
|
+
setTooltipOpen(true)
|
|
27
|
+
return true
|
|
28
|
+
} catch (err) {
|
|
29
|
+
// Direct clipboard copy is not available in non-secure contexts
|
|
30
|
+
console.error(err)
|
|
27
31
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (selection && ref && "current" in ref && ref.current) {
|
|
32
|
+
// Let's fall back to selecting the text so the user can manually copy easily
|
|
33
|
+
const selection = window.getSelection()!
|
|
31
34
|
const range = document.createRange()
|
|
32
|
-
range.selectNodeContents(ref.current)
|
|
35
|
+
range.selectNodeContents(ref.current as any)
|
|
33
36
|
selection.removeAllRanges()
|
|
34
37
|
selection.addRange(range)
|
|
35
38
|
}
|
|
39
|
+
return false
|
|
36
40
|
}
|
|
37
|
-
return false
|
|
38
|
-
}
|
|
39
41
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (!tooltipOpen) {
|
|
44
|
+
return
|
|
45
|
+
}
|
|
46
|
+
const timeoutId = setTimeout(() => setTooltipOpen(false), 3000)
|
|
47
|
+
return () => {
|
|
48
|
+
timeoutId ? clearTimeout(timeoutId) : {}
|
|
49
|
+
}
|
|
50
|
+
}, [tooltipOpen])
|
|
49
51
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
sx={{
|
|
55
|
-
height: "100%",
|
|
56
|
-
boxSizing: "border-box",
|
|
57
|
-
padding: "6px 12px",
|
|
58
|
-
background: theme.palette.backgroundPaperElevation?.[8],
|
|
59
|
-
borderRadius: "10px",
|
|
60
|
-
minWidth: "0",
|
|
61
|
-
cursor: "pointer",
|
|
62
|
-
}}
|
|
63
|
-
onClick={() => onCopyText()}
|
|
64
|
-
>
|
|
65
|
-
<Typography
|
|
66
|
-
ref={ref}
|
|
67
|
-
align="center"
|
|
52
|
+
return (
|
|
53
|
+
<Tooltip open={tooltipOpen} title="Copied!">
|
|
54
|
+
<Stack
|
|
55
|
+
justifyContent="center"
|
|
68
56
|
sx={{
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
overflow: "hidden",
|
|
57
|
+
height: "100%",
|
|
58
|
+
boxSizing: "border-box",
|
|
59
|
+
padding: "6px 12px",
|
|
60
|
+
background: theme.palette.backgroundPaperElevation?.[8],
|
|
61
|
+
borderRadius: "10px",
|
|
62
|
+
minWidth: "0",
|
|
63
|
+
cursor: "pointer",
|
|
77
64
|
}}
|
|
65
|
+
onClick={() => onCopyText()}
|
|
78
66
|
>
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
67
|
+
<Typography
|
|
68
|
+
ref={ref}
|
|
69
|
+
align="center"
|
|
70
|
+
sx={{
|
|
71
|
+
pointerEvents: "none",
|
|
72
|
+
fontSize: "12px",
|
|
73
|
+
color: theme.palette.text.primary,
|
|
74
|
+
whiteSpace: "nowrap",
|
|
75
|
+
minWidth: 0,
|
|
76
|
+
textOverflow: "ellipsis",
|
|
77
|
+
width: "100%",
|
|
78
|
+
overflow: "hidden",
|
|
79
|
+
}}
|
|
80
|
+
>
|
|
81
|
+
{value}
|
|
82
|
+
</Typography>
|
|
83
|
+
</Stack>
|
|
84
|
+
</Tooltip>
|
|
85
|
+
)
|
|
86
|
+
},
|
|
87
|
+
)
|
|
@@ -45,7 +45,7 @@ export const createLogMessage = (
|
|
|
45
45
|
level: LogLevel,
|
|
46
46
|
id?: string,
|
|
47
47
|
): LogMessage => ({
|
|
48
|
-
id: id || `${Date.now()}-${Math.random().toString(36).
|
|
48
|
+
id: id || `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
|
|
49
49
|
timestamp: new Date(),
|
|
50
50
|
message,
|
|
51
51
|
level,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Fab, type FabProps
|
|
1
|
+
import { Fab, styled, type FabProps } from "@mui/material"
|
|
2
|
+
import { forwardRef, type Ref } from "react"
|
|
2
3
|
|
|
3
4
|
const StyledSelectableFab = styled(Fab, {
|
|
4
5
|
shouldForwardProp: (prop) => prop !== "selected",
|
|
@@ -33,18 +34,18 @@ const StyledSelectableFab = styled(Fab, {
|
|
|
33
34
|
|
|
34
35
|
type CodeFabProps = {
|
|
35
36
|
selected?: boolean
|
|
36
|
-
ref?: React.Ref<HTMLButtonElement>
|
|
37
37
|
} & Omit<FabProps, "variant" | "color">
|
|
38
38
|
|
|
39
|
-
export const SelectableFab = (
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
39
|
+
export const SelectableFab = forwardRef(
|
|
40
|
+
(props: CodeFabProps, ref: Ref<HTMLButtonElement>) => {
|
|
41
|
+
return (
|
|
42
|
+
<StyledSelectableFab
|
|
43
|
+
ref={ref}
|
|
44
|
+
selected={props.selected}
|
|
45
|
+
{...props}
|
|
46
|
+
color={"secondary"}
|
|
47
|
+
variant="circular"
|
|
48
|
+
/>
|
|
49
|
+
)
|
|
50
|
+
},
|
|
51
|
+
)
|
|
@@ -24,8 +24,6 @@ export interface TabBarProps {
|
|
|
24
24
|
onTabChange?: (index: number) => void
|
|
25
25
|
/** Additional styling */
|
|
26
26
|
sx?: SxProps
|
|
27
|
-
/** Ref to the root container element */
|
|
28
|
-
ref?: React.Ref<HTMLDivElement>
|
|
29
27
|
}
|
|
30
28
|
|
|
31
29
|
interface TabPanelProps {
|
|
@@ -57,7 +55,7 @@ function TabPanel(props: TabPanelProps) {
|
|
|
57
55
|
*/
|
|
58
56
|
export const TabBar = externalizeComponent(
|
|
59
57
|
observer((props: TabBarProps) => {
|
|
60
|
-
const { items, defaultActiveTab = 0, onTabChange, sx
|
|
58
|
+
const { items, defaultActiveTab = 0, onTabChange, sx } = props
|
|
61
59
|
const [activeTab, setActiveTab] = useState(defaultActiveTab)
|
|
62
60
|
|
|
63
61
|
const handleTabChange = (
|
|
@@ -70,7 +68,6 @@ export const TabBar = externalizeComponent(
|
|
|
70
68
|
|
|
71
69
|
return (
|
|
72
70
|
<Box
|
|
73
|
-
ref={ref}
|
|
74
71
|
sx={{ height: "100%", display: "flex", flexDirection: "column", ...sx }}
|
|
75
72
|
>
|
|
76
73
|
{/* Tabs */}
|