@wandelbots/wandelbots-js-react-components 1.11.4 → 1.12.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 +28 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10718 -10912
- package/dist/index.js.map +1 -1
- package/dist/src/components/CopyableText.d.ts +1 -1
- package/dist/src/components/LoadingButton.d.ts +1 -1
- package/dist/src/externalizeComponent.d.ts.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/themes/theming.d.ts +10 -22
- package/dist/src/themes/theming.d.ts.map +1 -1
- package/dist/stories/JoggingPanel.stories.d.ts.map +1 -1
- package/dist/stories/MuiSamples/Accordion.d.ts +2 -0
- package/dist/stories/MuiSamples/Accordion.d.ts.map +1 -0
- package/dist/stories/MuiSamples/Alert.d.ts +3 -0
- package/dist/stories/MuiSamples/Alert.d.ts.map +1 -0
- package/dist/stories/MuiSamples/AppBar.d.ts +7 -0
- package/dist/stories/MuiSamples/AppBar.d.ts.map +1 -0
- package/dist/stories/MuiSamples/Avatar.d.ts +2 -0
- package/dist/stories/MuiSamples/Avatar.d.ts.map +1 -0
- package/dist/stories/MuiSamples/Badge.d.ts +2 -0
- package/dist/stories/MuiSamples/Badge.d.ts.map +1 -0
- package/dist/stories/MuiSamples/BottomNavigation.d.ts +2 -0
- package/dist/stories/MuiSamples/BottomNavigation.d.ts.map +1 -0
- package/dist/stories/MuiSamples/Button.d.ts +2 -0
- package/dist/stories/MuiSamples/Button.d.ts.map +1 -0
- package/dist/stories/MuiSamples/Card.d.ts +2 -0
- package/dist/stories/MuiSamples/Card.d.ts.map +1 -0
- package/dist/stories/MuiSamples/Checkboxes.d.ts +2 -0
- package/dist/stories/MuiSamples/Checkboxes.d.ts.map +1 -0
- package/dist/stories/MuiSamples/Chip.d.ts +2 -0
- package/dist/stories/MuiSamples/Chip.d.ts.map +1 -0
- package/dist/stories/MuiSamples/Dialog.d.ts +7 -0
- package/dist/stories/MuiSamples/Dialog.d.ts.map +1 -0
- package/dist/stories/MuiSamples/FAB.d.ts +2 -0
- package/dist/stories/MuiSamples/FAB.d.ts.map +1 -0
- package/dist/stories/MuiSamples/Icon.d.ts +2 -0
- package/dist/stories/MuiSamples/Icon.d.ts.map +1 -0
- package/dist/stories/MuiSamples/List.d.ts +2 -0
- package/dist/stories/MuiSamples/List.d.ts.map +1 -0
- package/dist/stories/MuiSamples/Menu.d.ts +2 -0
- package/dist/stories/MuiSamples/Menu.d.ts.map +1 -0
- package/dist/stories/MuiSamples/Progress.d.ts +2 -0
- package/dist/stories/MuiSamples/Progress.d.ts.map +1 -0
- package/dist/stories/MuiSamples/RadioGroup.d.ts +2 -0
- package/dist/stories/MuiSamples/RadioGroup.d.ts.map +1 -0
- package/dist/stories/MuiSamples/Select.d.ts +2 -0
- package/dist/stories/MuiSamples/Select.d.ts.map +1 -0
- package/dist/stories/MuiSamples/Slider.d.ts +2 -0
- package/dist/stories/MuiSamples/Slider.d.ts.map +1 -0
- package/dist/stories/MuiSamples/Snackbar.d.ts +2 -0
- package/dist/stories/MuiSamples/Snackbar.d.ts.map +1 -0
- package/dist/stories/MuiSamples/Stepper.d.ts +2 -0
- package/dist/stories/MuiSamples/Stepper.d.ts.map +1 -0
- package/dist/stories/MuiSamples/Switch.d.ts +2 -0
- package/dist/stories/MuiSamples/Switch.d.ts.map +1 -0
- package/dist/stories/MuiSamples/Table.d.ts +2 -0
- package/dist/stories/MuiSamples/Table.d.ts.map +1 -0
- package/dist/stories/MuiSamples/Tabs.d.ts +2 -0
- package/dist/stories/MuiSamples/Tabs.d.ts.map +1 -0
- package/dist/stories/MuiSamples/TextField.d.ts +2 -0
- package/dist/stories/MuiSamples/TextField.d.ts.map +1 -0
- package/dist/stories/MuiSamples/Tooltip.d.ts +2 -0
- package/dist/stories/MuiSamples/Tooltip.d.ts.map +1 -0
- package/dist/stories/MuiSamples/Typography.d.ts +2 -0
- package/dist/stories/MuiSamples/Typography.d.ts.map +1 -0
- package/dist/stories/MuiSamples/index.d.ts +8 -0
- package/dist/stories/MuiSamples/index.d.ts.map +1 -0
- package/dist/stories/defaultTheme.stories.d.ts +7 -0
- package/dist/stories/defaultTheme.stories.d.ts.map +1 -0
- package/dist/stories/theming.stories.d.ts +7 -0
- package/dist/stories/theming.stories.d.ts.map +1 -0
- package/package.json +13 -14
- package/src/components/CopyableText.tsx +1 -1
- package/src/components/jogging/JoggingCartesianValues.tsx +1 -1
- package/src/components/jogging/JoggingJointValues.tsx +1 -1
- package/src/externalizeComponent.tsx +2 -14
- package/src/index.ts +1 -0
- package/src/themes/themeTypes.d.ts +4 -4
- package/src/themes/theming.ts +28 -30
- package/dist/src/themes/color.d.ts +0 -10
- package/dist/src/themes/color.d.ts.map +0 -1
- package/dist/stories/novaTheme.stories.d.ts +0 -5
- package/dist/stories/novaTheme.stories.d.ts.map +0 -1
- package/src/themes/color.tsx +0 -84
package/src/themes/theming.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
-
import type { Theme } from "@mui/material/styles"
|
|
3
|
+
import type { Theme, ThemeOptions } from "@mui/material/styles"
|
|
4
4
|
import { createTheme } from "@mui/material/styles"
|
|
5
|
-
import defaultsDeep from "lodash-es/defaultsDeep"
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* The palette of named colors we pick from for
|
|
@@ -26,14 +25,11 @@ const colors = {
|
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* This object defines the default Nova theme settings, and the structure
|
|
34
|
-
* of the options here is used to validate alternative themes.
|
|
28
|
+
* Settings used to construct the Nova default theme.
|
|
29
|
+
* The dark theme is the default and defines the structure of the
|
|
30
|
+
* settings.
|
|
35
31
|
*/
|
|
36
|
-
export const
|
|
32
|
+
export const novaDarkSettings = {
|
|
37
33
|
mode: "dark" as "dark" | "light",
|
|
38
34
|
colors: {
|
|
39
35
|
primary: colors.skyblue500,
|
|
@@ -46,9 +42,9 @@ export const novaDarkTheme = {
|
|
|
46
42
|
},
|
|
47
43
|
}
|
|
48
44
|
|
|
49
|
-
export type
|
|
45
|
+
export type NovaThemeSettings = typeof novaDarkSettings
|
|
50
46
|
|
|
51
|
-
export const
|
|
47
|
+
export const novaLightSettings = {
|
|
52
48
|
mode: "light",
|
|
53
49
|
colors: {
|
|
54
50
|
primary: colors.skyblue500,
|
|
@@ -59,30 +55,26 @@ export const novaLightTheme = {
|
|
|
59
55
|
panel: colors.white,
|
|
60
56
|
},
|
|
61
57
|
},
|
|
62
|
-
} satisfies
|
|
58
|
+
} satisfies NovaThemeSettings
|
|
63
59
|
|
|
64
60
|
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* Otherwise, the default dark or light theme is extended with
|
|
68
|
-
* the overrides provided as appropriate.
|
|
61
|
+
* Create the default Wandelbots Nova Material UI theme, overriding
|
|
62
|
+
* any defaults with the provided theme options.
|
|
69
63
|
*/
|
|
70
|
-
export function
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
64
|
+
export function createNovaMuiTheme(opts: ThemeOptions): Theme {
|
|
65
|
+
let isDark = true
|
|
66
|
+
if (opts.palette?.mode === "light") {
|
|
67
|
+
isDark = false
|
|
68
|
+
} else if (opts.palette?.mode !== "dark") {
|
|
69
|
+
const browserPrefersLight =
|
|
70
|
+
typeof window !== "undefined" &&
|
|
71
|
+
window.matchMedia?.("(prefers-color-scheme: light)")?.matches
|
|
72
|
+
isDark = !browserPrefersLight
|
|
73
|
+
}
|
|
74
74
|
|
|
75
|
-
|
|
76
|
-
* Turn a set of Nova theme settings into a Material UI theme.
|
|
77
|
-
*
|
|
78
|
-
* The original Nova settings are available on the resulting MUI
|
|
79
|
-
* theme object under the `nova` key, if needed.
|
|
80
|
-
*/
|
|
81
|
-
export function createMUIThemeFromNova(novaTheme: NovaTheme): Theme {
|
|
82
|
-
const nova = novaTheme
|
|
83
|
-
const isDark = nova.mode === "dark"
|
|
75
|
+
const nova = isDark ? novaDarkSettings : novaLightSettings
|
|
84
76
|
|
|
85
|
-
|
|
77
|
+
const theme = createTheme({
|
|
86
78
|
palette: {
|
|
87
79
|
mode: nova.mode,
|
|
88
80
|
primary: {
|
|
@@ -171,4 +163,10 @@ export function createMUIThemeFromNova(novaTheme: NovaTheme): Theme {
|
|
|
171
163
|
},
|
|
172
164
|
nova,
|
|
173
165
|
})
|
|
166
|
+
|
|
167
|
+
if (opts) {
|
|
168
|
+
return createTheme(theme, opts)
|
|
169
|
+
} else {
|
|
170
|
+
return theme
|
|
171
|
+
}
|
|
174
172
|
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from "react";
|
|
2
|
-
export declare function ColorSection(props: {
|
|
3
|
-
name: string;
|
|
4
|
-
children: ReactNode;
|
|
5
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
6
|
-
export declare function Color({ name, color }: {
|
|
7
|
-
name: string;
|
|
8
|
-
color: string;
|
|
9
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
10
|
-
//# sourceMappingURL=color.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../../src/themes/color.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAC,MAAM,OAAO,CAAC;AAGtC,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,SAAS,CAAA;CAAE,2CAsBxE;AAED,wBAAgB,KAAK,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,2CAuDrE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"novaTheme.stories.d.ts","sourceRoot":"","sources":["../../stories/novaTheme.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAY,MAAM,kBAAkB,CAAA;AAItD,QAAA,MAAM,YAAY,+CAuDjB,CAAA;AAED,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,YAAY,CASnC,CAAA;AAED,eAAe,IAAI,CAAA"}
|
package/src/themes/color.tsx
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { Box, Typography, useTheme } from "@mui/material"
|
|
2
|
-
import type { ReactNode} from "react";
|
|
3
|
-
import { useEffect, useState } from "react"
|
|
4
|
-
|
|
5
|
-
export function ColorSection(props: { name: string; children: ReactNode }) {
|
|
6
|
-
return (
|
|
7
|
-
<>
|
|
8
|
-
<Typography
|
|
9
|
-
component="h2"
|
|
10
|
-
sx={{
|
|
11
|
-
marginTop: "1rem",
|
|
12
|
-
}}
|
|
13
|
-
>
|
|
14
|
-
{props.name}
|
|
15
|
-
</Typography>
|
|
16
|
-
<Box
|
|
17
|
-
sx={{
|
|
18
|
-
display: "grid",
|
|
19
|
-
gridTemplateColumns: "repeat(auto-fill, minmax(200px, 1fr))",
|
|
20
|
-
gap: "20px",
|
|
21
|
-
}}
|
|
22
|
-
>
|
|
23
|
-
{props.children}
|
|
24
|
-
</Box>
|
|
25
|
-
</>
|
|
26
|
-
)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function Color({ name, color }: { name: string; color: string }) {
|
|
30
|
-
const theme = useTheme()
|
|
31
|
-
const [showCopied, setShowCopied] = useState(false)
|
|
32
|
-
|
|
33
|
-
function handleClick(value: string) {
|
|
34
|
-
if (!navigator.clipboard) {
|
|
35
|
-
console.error("can't send value to clipboard")
|
|
36
|
-
return
|
|
37
|
-
}
|
|
38
|
-
navigator.clipboard.writeText(value)
|
|
39
|
-
setShowCopied(true)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
useEffect(() => {
|
|
43
|
-
if (showCopied) {
|
|
44
|
-
setTimeout(() => {
|
|
45
|
-
setShowCopied(false)
|
|
46
|
-
}, 2000)
|
|
47
|
-
}
|
|
48
|
-
}, [showCopied])
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<li
|
|
52
|
-
onClick={() => handleClick(color)}
|
|
53
|
-
style={{
|
|
54
|
-
borderRadius: "5px",
|
|
55
|
-
border: "1px solid lightgray",
|
|
56
|
-
padding: "5px",
|
|
57
|
-
listStyleType: "none",
|
|
58
|
-
width: "200px",
|
|
59
|
-
}}
|
|
60
|
-
>
|
|
61
|
-
<span
|
|
62
|
-
style={{
|
|
63
|
-
backgroundColor: color,
|
|
64
|
-
display: "block",
|
|
65
|
-
height: "4em",
|
|
66
|
-
marginBottom: "0.3em",
|
|
67
|
-
borderRadius: "5px",
|
|
68
|
-
// border: "1px solid lightgray",
|
|
69
|
-
}}
|
|
70
|
-
/>
|
|
71
|
-
<Typography component="span">{name}</Typography>
|
|
72
|
-
<br />
|
|
73
|
-
<Typography
|
|
74
|
-
style={{
|
|
75
|
-
opacity: 0.7,
|
|
76
|
-
fontSize: "0.9em",
|
|
77
|
-
fontFamily: "monospace",
|
|
78
|
-
}}
|
|
79
|
-
>
|
|
80
|
-
{showCopied ? "Copied ✔︎" : color}
|
|
81
|
-
</Typography>
|
|
82
|
-
</li>
|
|
83
|
-
)
|
|
84
|
-
}
|