@wandelbots/wandelbots-js-react-components 1.11.3 → 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.
Files changed (88) hide show
  1. package/dist/index.cjs +28 -28
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +10637 -10836
  4. package/dist/index.js.map +1 -1
  5. package/dist/src/components/CopyableText.d.ts +1 -1
  6. package/dist/src/components/LoadingButton.d.ts +1 -1
  7. package/dist/src/components/modal/NoMotionGroupModal.d.ts +3 -2
  8. package/dist/src/components/modal/NoMotionGroupModal.d.ts.map +1 -1
  9. package/dist/src/externalizeComponent.d.ts.map +1 -1
  10. package/dist/src/index.d.ts +1 -0
  11. package/dist/src/index.d.ts.map +1 -1
  12. package/dist/src/themes/theming.d.ts +10 -22
  13. package/dist/src/themes/theming.d.ts.map +1 -1
  14. package/dist/stories/JoggingPanel.stories.d.ts.map +1 -1
  15. package/dist/stories/MuiSamples/Accordion.d.ts +2 -0
  16. package/dist/stories/MuiSamples/Accordion.d.ts.map +1 -0
  17. package/dist/stories/MuiSamples/Alert.d.ts +3 -0
  18. package/dist/stories/MuiSamples/Alert.d.ts.map +1 -0
  19. package/dist/stories/MuiSamples/AppBar.d.ts +7 -0
  20. package/dist/stories/MuiSamples/AppBar.d.ts.map +1 -0
  21. package/dist/stories/MuiSamples/Avatar.d.ts +2 -0
  22. package/dist/stories/MuiSamples/Avatar.d.ts.map +1 -0
  23. package/dist/stories/MuiSamples/Badge.d.ts +2 -0
  24. package/dist/stories/MuiSamples/Badge.d.ts.map +1 -0
  25. package/dist/stories/MuiSamples/BottomNavigation.d.ts +2 -0
  26. package/dist/stories/MuiSamples/BottomNavigation.d.ts.map +1 -0
  27. package/dist/stories/MuiSamples/Button.d.ts +2 -0
  28. package/dist/stories/MuiSamples/Button.d.ts.map +1 -0
  29. package/dist/stories/MuiSamples/Card.d.ts +2 -0
  30. package/dist/stories/MuiSamples/Card.d.ts.map +1 -0
  31. package/dist/stories/MuiSamples/Checkboxes.d.ts +2 -0
  32. package/dist/stories/MuiSamples/Checkboxes.d.ts.map +1 -0
  33. package/dist/stories/MuiSamples/Chip.d.ts +2 -0
  34. package/dist/stories/MuiSamples/Chip.d.ts.map +1 -0
  35. package/dist/stories/MuiSamples/Dialog.d.ts +7 -0
  36. package/dist/stories/MuiSamples/Dialog.d.ts.map +1 -0
  37. package/dist/stories/MuiSamples/FAB.d.ts +2 -0
  38. package/dist/stories/MuiSamples/FAB.d.ts.map +1 -0
  39. package/dist/stories/MuiSamples/Icon.d.ts +2 -0
  40. package/dist/stories/MuiSamples/Icon.d.ts.map +1 -0
  41. package/dist/stories/MuiSamples/List.d.ts +2 -0
  42. package/dist/stories/MuiSamples/List.d.ts.map +1 -0
  43. package/dist/stories/MuiSamples/Menu.d.ts +2 -0
  44. package/dist/stories/MuiSamples/Menu.d.ts.map +1 -0
  45. package/dist/stories/MuiSamples/Progress.d.ts +2 -0
  46. package/dist/stories/MuiSamples/Progress.d.ts.map +1 -0
  47. package/dist/stories/MuiSamples/RadioGroup.d.ts +2 -0
  48. package/dist/stories/MuiSamples/RadioGroup.d.ts.map +1 -0
  49. package/dist/stories/MuiSamples/Select.d.ts +2 -0
  50. package/dist/stories/MuiSamples/Select.d.ts.map +1 -0
  51. package/dist/stories/MuiSamples/Slider.d.ts +2 -0
  52. package/dist/stories/MuiSamples/Slider.d.ts.map +1 -0
  53. package/dist/stories/MuiSamples/Snackbar.d.ts +2 -0
  54. package/dist/stories/MuiSamples/Snackbar.d.ts.map +1 -0
  55. package/dist/stories/MuiSamples/Stepper.d.ts +2 -0
  56. package/dist/stories/MuiSamples/Stepper.d.ts.map +1 -0
  57. package/dist/stories/MuiSamples/Switch.d.ts +2 -0
  58. package/dist/stories/MuiSamples/Switch.d.ts.map +1 -0
  59. package/dist/stories/MuiSamples/Table.d.ts +2 -0
  60. package/dist/stories/MuiSamples/Table.d.ts.map +1 -0
  61. package/dist/stories/MuiSamples/Tabs.d.ts +2 -0
  62. package/dist/stories/MuiSamples/Tabs.d.ts.map +1 -0
  63. package/dist/stories/MuiSamples/TextField.d.ts +2 -0
  64. package/dist/stories/MuiSamples/TextField.d.ts.map +1 -0
  65. package/dist/stories/MuiSamples/Tooltip.d.ts +2 -0
  66. package/dist/stories/MuiSamples/Tooltip.d.ts.map +1 -0
  67. package/dist/stories/MuiSamples/Typography.d.ts +2 -0
  68. package/dist/stories/MuiSamples/Typography.d.ts.map +1 -0
  69. package/dist/stories/MuiSamples/index.d.ts +8 -0
  70. package/dist/stories/MuiSamples/index.d.ts.map +1 -0
  71. package/dist/stories/defaultTheme.stories.d.ts +7 -0
  72. package/dist/stories/defaultTheme.stories.d.ts.map +1 -0
  73. package/dist/stories/theming.stories.d.ts +7 -0
  74. package/dist/stories/theming.stories.d.ts.map +1 -0
  75. package/package.json +13 -14
  76. package/src/components/CopyableText.tsx +1 -1
  77. package/src/components/jogging/JoggingCartesianValues.tsx +1 -1
  78. package/src/components/jogging/JoggingJointValues.tsx +1 -1
  79. package/src/components/modal/NoMotionGroupModal.tsx +69 -71
  80. package/src/externalizeComponent.tsx +2 -14
  81. package/src/index.ts +1 -0
  82. package/src/themes/themeTypes.d.ts +4 -4
  83. package/src/themes/theming.ts +28 -30
  84. package/dist/src/themes/color.d.ts +0 -10
  85. package/dist/src/themes/color.d.ts.map +0 -1
  86. package/dist/stories/novaTheme.stories.d.ts +0 -5
  87. package/dist/stories/novaTheme.stories.d.ts.map +0 -1
  88. package/src/themes/color.tsx +0 -84
@@ -7,8 +7,6 @@ import {
7
7
  Stack,
8
8
  Typography,
9
9
  } from "@mui/material"
10
- import { observer } from "mobx-react-lite"
11
- import { externalizeComponent } from "../../externalizeComponent"
12
10
 
13
11
  function getBaseUrl(): string {
14
12
  const currentUrl = window.location.href
@@ -18,77 +16,77 @@ function getBaseUrl(): string {
18
16
  )
19
17
  }
20
18
 
21
- export const NoMotionGroupModal = externalizeComponent(
22
- observer((baseUrl: string = getBaseUrl()) => {
23
- return (
24
- <Dialog
25
- aria-labelledby="no-motion-group-modal-title"
26
- open={true}
27
- fullWidth
28
- sx={{
29
- "& .MuiModal-backdrop": {
30
- backdropFilter: "blur(10px)",
31
- },
32
- "& .MuiDialog-paper": {
33
- "::before": {
34
- content: '""',
35
- height: "8px",
36
- width: "100%",
37
- background: "linear-gradient(90deg, #FF0E65 0%, #47D3FF 100%)",
38
- },
39
- background: "#101629",
19
+ export type NoMotionGroupModalProps = {
20
+ baseUrl: string
21
+ }
22
+
23
+ export function NoMotionGroupModal({
24
+ baseUrl = getBaseUrl(),
25
+ ...props
26
+ }: NoMotionGroupModalProps) {
27
+ return (
28
+ <Dialog
29
+ aria-labelledby="no-motion-group-modal-title"
30
+ open={true}
31
+ fullWidth
32
+ sx={{
33
+ "& .MuiModal-backdrop": {
34
+ backdropFilter: "blur(10px)",
35
+ },
36
+ "& .MuiDialog-paper": {
37
+ "::before": {
38
+ content: '""',
39
+ height: "8px",
40
+ width: "100%",
41
+ background: "linear-gradient(90deg, #FF0E65 0%, #47D3FF 100%)",
40
42
  },
43
+ background: "#101629",
44
+ },
45
+ }}
46
+ >
47
+ <DialogTitle id="no-motion-group-modal-title">
48
+ No motion group found
49
+ </DialogTitle>
50
+
51
+ <DialogContent
52
+ sx={{
53
+ marginTop: "3rem",
54
+ marginBottom: "1.5rem",
55
+ textAlign: "center",
41
56
  }}
42
57
  >
43
- <DialogTitle id="no-motion-group-modal-title">
44
- No motion group found
45
- </DialogTitle>
46
-
47
- <DialogContent
48
- sx={{
49
- marginTop: "3rem",
50
- marginBottom: "1.5rem",
51
- textAlign: "center",
52
- }}
53
- >
54
- <Typography color="#fff">Found no devices to connect to.</Typography>
55
- <Typography color="#fff">
56
- Please ensure a motion group has been created.
57
- </Typography>
58
- </DialogContent>
58
+ <Typography color="#fff">Found no devices to connect to.</Typography>
59
+ <Typography color="#fff">
60
+ Please ensure a motion group has been created.
61
+ </Typography>
62
+ </DialogContent>
59
63
 
60
- <DialogActions>
61
- <Stack
62
- width="100%"
63
- maxWidth="300px"
64
- margin="auto"
65
- marginBottom="2rem"
64
+ <DialogActions>
65
+ <Stack width="100%" maxWidth="300px" margin="auto" marginBottom="2rem">
66
+ <Button
67
+ href={`${baseUrl}/settings`}
68
+ variant="contained"
69
+ sx={{
70
+ borderRadius: "8px",
71
+ width: "100%",
72
+ }}
66
73
  >
67
- <Button
68
- href={`${baseUrl}/settings`}
69
- variant="contained"
70
- sx={{
71
- borderRadius: "8px",
72
- width: "100%",
73
- }}
74
- >
75
- Go to settings app
76
- </Button>
77
- <Button
78
- href={`${baseUrl}`}
79
- variant="text"
80
- sx={{
81
- marginTop: "1rem",
82
- color: "#fff",
83
- textDecoration: "underline",
84
- fontSize: "0.75rem",
85
- }}
86
- >
87
- Back to Homescreen
88
- </Button>
89
- </Stack>
90
- </DialogActions>
91
- </Dialog>
92
- )
93
- }),
94
- )
74
+ Go to settings app
75
+ </Button>
76
+ <Button
77
+ href={`${baseUrl}`}
78
+ variant="text"
79
+ sx={{
80
+ marginTop: "1rem",
81
+ color: "#fff",
82
+ textDecoration: "underline",
83
+ fontSize: "0.75rem",
84
+ }}
85
+ >
86
+ Back to Homescreen
87
+ </Button>
88
+ </Stack>
89
+ </DialogActions>
90
+ </Dialog>
91
+ )
92
+ }
@@ -1,7 +1,4 @@
1
- import { ThemeProvider } from "@emotion/react"
2
- import { createMUIThemeFromNova, createNovaTheme } from "./themes/theming"
3
- import type { FC } from "react"
4
- import { useTheme } from "@mui/material"
1
+ import { type FC } from "react"
5
2
  import { I18nextProvider } from "react-i18next"
6
3
  // @ts-expect-error invalid type-only import error
7
4
  import i18n from "./i18n/config"
@@ -26,14 +23,5 @@ export function externalizeComponent<T extends JSX.ElementType>(
26
23
  const NovaComponentsProvider: FC<{ children: React.ReactNode }> = ({
27
24
  children,
28
25
  }) => {
29
- const theme = useTheme()
30
- const defaultNovaTheme = createNovaTheme({
31
- mode: theme.palette.mode,
32
- })
33
- const defaultTheme = createMUIThemeFromNova(defaultNovaTheme)
34
- return (
35
- <ThemeProvider theme={defaultTheme}>
36
- <I18nextProvider i18n={i18n}>{children}</I18nextProvider>
37
- </ThemeProvider>
38
- )
26
+ return <I18nextProvider i18n={i18n}>{children}</I18nextProvider>
39
27
  }
package/src/index.ts CHANGED
@@ -11,3 +11,4 @@ export * from "./components/VelocitySlider"
11
11
  export * from "./components/modal/NoMotionGroupModal"
12
12
  export * from "./components/utils/hooks"
13
13
  export * from "./components/robots/AxisConfig"
14
+ export { createNovaMuiTheme } from "./themes/theming"
@@ -1,11 +1,11 @@
1
- import { NovaTheme } from "./novaTheme";
1
+ import type { NovaThemeSettings } from "./novaTheme"
2
2
 
3
3
  declare module "@mui/material/styles" {
4
4
  interface Theme {
5
- nova: NovaTheme
5
+ nova: NovaThemeSettings
6
6
  }
7
7
 
8
8
  interface ThemeOptions {
9
- nova?: NovaTheme
9
+ nova?: NovaThemeSettings
10
10
  }
11
- }
11
+ }
@@ -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
- * A Nova components theme is a collection of Nova-specific settings that is
30
- * not specifically MUI-related, but can be used to construct a MUI
31
- * theme in turn.
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 novaDarkTheme = {
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 NovaTheme = typeof novaDarkTheme
45
+ export type NovaThemeSettings = typeof novaDarkSettings
50
46
 
51
- export const novaLightTheme = {
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 NovaTheme
58
+ } satisfies NovaThemeSettings
63
59
 
64
60
  /**
65
- * Configure a Nova theme with the given options.
66
- * If no options are provided, the default dark theme is used.
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 createNovaTheme(opts: Partial<NovaTheme> = {}): NovaTheme {
71
- const defaults = opts.mode === "light" ? novaLightTheme : novaDarkTheme
72
- return defaultsDeep(opts, defaults)
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
- return createTheme({
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,5 +0,0 @@
1
- import type { Meta } from "@storybook/react";
2
- declare const ColorPalette: () => import("react/jsx-runtime").JSX.Element;
3
- declare const meta: Meta<typeof ColorPalette>;
4
- export default meta;
5
- //# sourceMappingURL=novaTheme.stories.d.ts.map
@@ -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"}
@@ -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
- }