@evoke-platform/ui-components 1.5.0-dev.6 → 1.5.0-dev.7

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.
@@ -35,7 +35,7 @@ export declare class FormFieldComponent extends ReactComponent {
35
35
  */
36
36
  manageFormErrors(): void;
37
37
  beforeSubmit(): void;
38
- handleComponentChange: (components: any, value: any) => void;
38
+ handleAddressChange: (components: any, value: any) => void;
39
39
  handleChange: (key: string, value: any) => void;
40
40
  attachReact(element: Element): void;
41
41
  }
@@ -61,7 +61,7 @@ export class FormFieldComponent extends ReactComponent {
61
61
  selectOptions,
62
62
  inputMaskPlaceholderChar: component.inputMaskPlaceholderChar || '_',
63
63
  }, options, data);
64
- this.handleComponentChange = (components, value) => {
64
+ this.handleAddressChange = (components, value) => {
65
65
  if (isArray(components)) {
66
66
  if (components.filter((component) => Object.hasOwnProperty.call(component, 'components'))) {
67
67
  components
@@ -93,12 +93,7 @@ export class FormFieldComponent extends ReactComponent {
93
93
  else {
94
94
  selectedValue = value.line1;
95
95
  label = value.line1;
96
- this.handleComponentChange(this.root.components, value);
97
- this.root.components
98
- .filter((component) => Object.prototype.hasOwnProperty.call(component, 'components'))
99
- .forEach((section) => {
100
- this.handleComponentChange(section.components, value);
101
- });
96
+ this.handleAddressChange(this.root.components, value);
102
97
  }
103
98
  }
104
99
  else if (this.component.property.type === 'choices' || this.component.property.type === 'array') {
@@ -152,7 +147,9 @@ export class FormFieldComponent extends ReactComponent {
152
147
  this.on('changed-' + this.component.key, (value) => {
153
148
  this.setValue(value ?? '');
154
149
  this.updateValue(value, { modified: true });
155
- this.attach(this.element);
150
+ if (this.element) {
151
+ this.attach(this.element);
152
+ }
156
153
  });
157
154
  }
158
155
  if (this.component.type === 'Date') {
@@ -1,9 +1,22 @@
1
1
  import React, { ReactNode } from 'react';
2
2
  export type MenuBarProps = {
3
- showNotifications: boolean;
3
+ /** The URL of the logo image to display. */
4
4
  logo: string;
5
+ /** Alternative text for the logo image. */
5
6
  logoAltText?: string;
7
+ /** Navigation items to display on the right side of the menu bar. */
6
8
  navItems?: ReactNode;
9
+ /** The name of the environment to display instead of the logo. */
7
10
  envName?: string;
11
+ /** Navigation item to display before the logo. */
12
+ navBeforeLogo?: ReactNode;
13
+ /** Indicates whether to show notifications. Currently not supported. */
14
+ showNotifications?: boolean;
8
15
  };
16
+ /**
17
+ * Renders a customizable menu bar with navigation items, logo, etc.
18
+ *
19
+ * @param {MenuBarProps} props - Configuration props for the MenuBar component.
20
+ * @returns {JSX.Element} A menu bar component.
21
+ */
9
22
  export default function MenuBar(props: MenuBarProps): React.JSX.Element;
@@ -1,6 +1,12 @@
1
1
  import { AppBar, Box, CardMedia, Toolbar, Typography } from '@mui/material';
2
2
  import React from 'react';
3
3
  import UIThemeProvider, { useResponsive } from '../../../theme';
4
+ /**
5
+ * Renders a customizable menu bar with navigation items, logo, etc.
6
+ *
7
+ * @param {MenuBarProps} props - Configuration props for the MenuBar component.
8
+ * @returns {JSX.Element} A menu bar component.
9
+ */
4
10
  export default function MenuBar(props) {
5
11
  const { isXs: isMobileView } = useResponsive();
6
12
  const classes = {
@@ -9,7 +15,7 @@ export default function MenuBar(props) {
9
15
  flexGrow: 1,
10
16
  },
11
17
  logo: {
12
- paddingRight: '16px',
18
+ padding: '0 16px',
13
19
  height: '70px',
14
20
  maxWidth: isMobileView ? '220px' : null,
15
21
  objectFit: 'contain',
@@ -18,7 +24,8 @@ export default function MenuBar(props) {
18
24
  };
19
25
  return (React.createElement(UIThemeProvider, null,
20
26
  React.createElement(AppBar, { color: "inherit", position: "fixed", elevation: 0, sx: { zIndex: (theme) => theme.zIndex.drawer + 1, borderBottom: '1px solid #919EAB3D' } },
21
- React.createElement(Toolbar, { sx: { justifyContent: 'space-between' } },
27
+ React.createElement(Toolbar, { disableGutters: true, sx: { justifyContent: 'space-between', overflow: 'hidden', paddingRight: '14px' } },
28
+ props.navBeforeLogo && (React.createElement(Box, { sx: { height: '70px', borderRight: '1px solid #919EAB3D' } }, props.navBeforeLogo)),
22
29
  React.createElement(Box, { sx: classes.title }, !props.envName ? (React.createElement(CardMedia, { component: 'img', src: props.logo, alt: props.logoAltText, sx: classes.logo })) : (React.createElement(Box, { mt: 2 },
23
30
  React.createElement(Typography, { variant: "h5" },
24
31
  props?.envName,
@@ -11,3 +11,8 @@ it('render Menubar component without crashing', () => {
11
11
  render(React.createElement(Menubar, { showNotifications: true, navItems: navItems, logo: "" }));
12
12
  expect(screen.getAllByRole('link')).toHaveLength(3);
13
13
  });
14
+ it('renders navBeforeLogo correctly', () => {
15
+ const navBeforeLogo = React.createElement(Link, { href: "#" }, "Before");
16
+ render(React.createElement(Menubar, { showNotifications: true, navItems: null, navBeforeLogo: navBeforeLogo, logo: "" }));
17
+ expect(screen.getAllByRole('link')).toHaveLength(1);
18
+ });
@@ -1,25 +1,20 @@
1
- import { Link } from '@mui/material';
2
1
  import React from 'react';
3
2
  import { MenuBar as CustomMenuBar } from '../index';
4
3
  // eslint-disable-next-line @typescript-eslint/no-var-requires
5
4
  const logo = require('../assets/SA_logo.jpeg');
6
5
  export default {
7
- title: 'Data Display/MenuBar',
6
+ title: 'Custom/MenuBar',
8
7
  component: CustomMenuBar,
9
- argTypes: {
10
- navItems: {
11
- control: 'object',
12
- defaultValue: React.createElement(Link, null, "Object"),
13
- },
14
- showNotifications: {
15
- defaultValue: true,
16
- type: 'boolean',
17
- },
18
- logo: {
19
- defaultValue: logo,
20
- },
21
- envName: { defaultValue: 'System Automation' },
22
- },
23
8
  };
24
- const Template = (props) => React.createElement(CustomMenuBar, { ...props });
25
- export const MenuBar = Template.bind({});
9
+ const MenuBarTemplate = (args) => React.createElement(CustomMenuBar, { ...args });
10
+ export const MenuBar = MenuBarTemplate.bind({});
11
+ MenuBar.args = {
12
+ logo: logo,
13
+ logoAltText: 'System Automation',
14
+ navItems: (React.createElement(React.Fragment, null,
15
+ React.createElement("a", { href: "#" }, "Object1"),
16
+ React.createElement("a", { href: "#" }, "Object2"),
17
+ React.createElement("a", { href: "#" }, "Object3"))),
18
+ envName: 'System Automation',
19
+ showNotifications: true,
20
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evoke-platform/ui-components",
3
- "version": "1.5.0-dev.6",
3
+ "version": "1.5.0-dev.7",
4
4
  "description": "",
5
5
  "main": "dist/published/index.js",
6
6
  "module": "dist/published/index.js",