carbon-react 111.8.2 → 111.8.3

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 (43) hide show
  1. package/esm/components/form/__internal__/form-summary.component.d.ts +18 -13
  2. package/esm/components/form/__internal__/form-summary.component.js +21 -20
  3. package/esm/components/form/__internal__/form-summary.style.d.ts +11 -3
  4. package/esm/components/form/__internal__/form-summary.style.js +5 -13
  5. package/esm/components/form/form.component.d.ts +35 -20
  6. package/esm/components/form/form.component.js +329 -47
  7. package/esm/components/form/form.config.d.ts +2 -1
  8. package/esm/components/form/form.config.js +0 -1
  9. package/esm/components/form/form.style.d.ts +21 -6
  10. package/esm/components/form/form.style.js +1 -17
  11. package/esm/components/form/index.d.ts +2 -1
  12. package/esm/components/menu/__internal__/spec-helper/index.js +4 -3
  13. package/esm/components/menu/__internal__/submenu/submenu.component.js +21 -4
  14. package/esm/components/menu/menu-item/menu-item.component.js +10 -2
  15. package/esm/components/menu/menu.component.js +19 -9
  16. package/esm/components/menu/menu.context.d.ts +2 -0
  17. package/esm/components/menu/menu.context.js +5 -1
  18. package/esm/components/show-edit-pod/show-edit-pod.style.js +1 -1
  19. package/esm/locales/en-gb.js +1 -1
  20. package/lib/components/form/__internal__/form-summary.component.d.ts +18 -13
  21. package/lib/components/form/__internal__/form-summary.component.js +22 -21
  22. package/lib/components/form/__internal__/form-summary.style.d.ts +11 -3
  23. package/lib/components/form/__internal__/form-summary.style.js +5 -14
  24. package/lib/components/form/form.component.d.ts +35 -20
  25. package/lib/components/form/form.component.js +330 -49
  26. package/lib/components/form/form.config.d.ts +2 -1
  27. package/lib/components/form/form.config.js +0 -1
  28. package/lib/components/form/form.style.d.ts +21 -6
  29. package/lib/components/form/form.style.js +1 -19
  30. package/lib/components/form/index.d.ts +2 -1
  31. package/lib/components/menu/__internal__/spec-helper/index.js +5 -3
  32. package/lib/components/menu/__internal__/submenu/submenu.component.js +21 -4
  33. package/lib/components/menu/menu-item/menu-item.component.js +10 -2
  34. package/lib/components/menu/menu.component.js +19 -9
  35. package/lib/components/menu/menu.context.d.ts +2 -0
  36. package/lib/components/menu/menu.context.js +5 -1
  37. package/lib/components/show-edit-pod/show-edit-pod.style.js +2 -2
  38. package/lib/locales/en-gb.js +1 -1
  39. package/package.json +1 -1
  40. package/esm/components/form/__internal__/form-summary.d.ts +0 -16
  41. package/esm/components/form/form.d.ts +0 -35
  42. package/lib/components/form/__internal__/form-summary.d.ts +0 -16
  43. package/lib/components/form/form.d.ts +0 -35
@@ -39,6 +39,7 @@ const Menu = ({
39
39
  ...rest
40
40
  }) => {
41
41
  const [focusedItemIndex, setFocusedItemIndex] = (0, _react.useState)(undefined);
42
+ const [openSubmenuIndex, setOpenSubmenuIndex] = (0, _react.useState)(null);
42
43
  const ref = (0, _react.useRef)();
43
44
  const handleKeyDown = (0, _react.useCallback)(event => {
44
45
  const newIndex = (0, _keyboardNavigation.menuKeyboardNavigation)(event, _react.default.Children.toArray(children));
@@ -63,17 +64,26 @@ const Menu = ({
63
64
  }, rest, {
64
65
  ref: ref,
65
66
  role: "list"
66
- }), _react.default.Children.map(children, (child, index) => {
67
+ }), /*#__PURE__*/_react.default.createElement(_menu2.default.Provider, {
68
+ value: {
69
+ menuType,
70
+ handleKeyDown,
71
+ inMenu: true,
72
+ openSubmenuIndex,
73
+ setOpenSubmenuIndex
74
+ }
75
+ }, _react.default.Children.map(children, (child, index) => {
67
76
  const isFocused = focusedItemIndex === index;
68
- return /*#__PURE__*/_react.default.createElement(_menu2.default.Provider, {
69
- value: {
70
- menuType,
71
- handleKeyDown: ev => handleKeyDown(ev, index),
77
+
78
+ if ( /*#__PURE__*/_react.default.isValidElement(child) && child.type.displayName === "MenuItem" && child.props.submenu) {
79
+ return /*#__PURE__*/_react.default.cloneElement(child, {
72
80
  isFocused,
73
- inMenu: true
74
- }
75
- }, child);
76
- }));
81
+ indexInMenu: index
82
+ });
83
+ }
84
+
85
+ return child;
86
+ })));
77
87
  };
78
88
 
79
89
  Menu.propTypes = {
@@ -1,6 +1,8 @@
1
1
  declare var _default: React.Context<{
2
2
  menuType: string;
3
3
  inMenu: boolean;
4
+ openSubmenuIndex: null;
5
+ setOpenSubmenuIndex: () => void;
4
6
  }>;
5
7
  export default _default;
6
8
  import React from "react";
@@ -11,7 +11,11 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
11
11
 
12
12
  var _default = /*#__PURE__*/_react.default.createContext({
13
13
  menuType: "light",
14
- inMenu: false
14
+ inMenu: false,
15
+ openSubmenuIndex: null,
16
+ setOpenSubmenuIndex:
17
+ /* istanbul ignore next */
18
+ () => {}
15
19
  });
16
20
 
17
21
  exports.default = _default;
@@ -7,7 +7,7 @@ exports.default = void 0;
7
7
 
8
8
  var _styledComponents = _interopRequireDefault(require("styled-components"));
9
9
 
10
- var _formStyle = require("../form/form.style.js");
10
+ var _form = require("../form/form.style");
11
11
 
12
12
  var _podStyle = require("../pod/pod.style.js");
13
13
 
@@ -16,7 +16,7 @@ var _pod = _interopRequireDefault(require("../pod"));
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
17
 
18
18
  const StyledPod = (0, _styledComponents.default)(_pod.default)`
19
- ${_formStyle.StyledFormFooter} {
19
+ ${_form.StyledFormFooter} {
20
20
  margin-top: 24px;
21
21
  }
22
22
 
@@ -48,7 +48,7 @@ const enGB = {
48
48
  const isErrorPlural = isSingular(errors) && !warnings ? "is" : "are";
49
49
  const isWarningPlural = isSingular(warnings) ? "is" : "are";
50
50
 
51
- if (errors && warnings && type === "warnings") {
51
+ if (errors && warnings && type === "warning") {
52
52
  return ["and", `${warnings} ${warningPlural}`];
53
53
  }
54
54
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "111.8.2",
3
+ "version": "111.8.3",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",
@@ -1,16 +0,0 @@
1
- import * as React from "react";
2
-
3
- export interface FormSummaryProps {
4
- /** Child elements */
5
- children?: React.ReactNode;
6
- /** The total number of errors present in the form */
7
- errors?: number;
8
- /** The total number of warnings present in the form */
9
- warnings?: number;
10
- /** Applies full width styling */
11
- fullWidth?: boolean;
12
- }
13
-
14
- declare function FormSummary(props: FormSummaryProps): JSX.Element;
15
-
16
- export default FormSummary;
@@ -1,35 +0,0 @@
1
- import * as React from "react";
2
- import { SpaceProps } from "styled-system";
3
-
4
- export interface FormProps extends SpaceProps {
5
- /** Alignment of buttons */
6
- buttonAlignment?: "left" | "right";
7
- /** Child elements */
8
- children?: React.ReactNode;
9
- /** The total number of errors present in the form */
10
- errorCount?: number;
11
- /** Spacing between form fields, given number will be multiplied by base spacing unit (8) */
12
- fieldSpacing?: 0 | 1 | 2 | 3 | 4 | 5 | 7;
13
- /** Additional buttons rendered on the left side of the save button */
14
- leftSideButtons?: React.ReactNode;
15
- /** Disable HTML5 validation */
16
- noValidate?: boolean;
17
- /** Callback passed to the form element */
18
- onSubmit?: (event: React.FormEvent<HTMLFormElement>) => any;
19
- /** Additional buttons rendered on the right side of the save button */
20
- rightSideButtons?: React.ReactNode;
21
- /** Save button to be rendered */
22
- saveButton?: React.ReactNode;
23
- /** Enables the sticky footer. */
24
- stickyFooter?: boolean;
25
- /** The total number of warnings present in the form */
26
- warningCount?: number;
27
- /** Height of the form (any valid CSS value) */
28
- height?: string;
29
- /** Applies styling for full width buttons. Please note that you will still need to pass the `fullWidth` prop to the button you compose */
30
- fullWidthButtons?: boolean;
31
- }
32
-
33
- declare function Form(props: FormProps): JSX.Element;
34
-
35
- export default Form;
@@ -1,16 +0,0 @@
1
- import * as React from "react";
2
-
3
- export interface FormSummaryProps {
4
- /** Child elements */
5
- children?: React.ReactNode;
6
- /** The total number of errors present in the form */
7
- errors?: number;
8
- /** The total number of warnings present in the form */
9
- warnings?: number;
10
- /** Applies full width styling */
11
- fullWidth?: boolean;
12
- }
13
-
14
- declare function FormSummary(props: FormSummaryProps): JSX.Element;
15
-
16
- export default FormSummary;
@@ -1,35 +0,0 @@
1
- import * as React from "react";
2
- import { SpaceProps } from "styled-system";
3
-
4
- export interface FormProps extends SpaceProps {
5
- /** Alignment of buttons */
6
- buttonAlignment?: "left" | "right";
7
- /** Child elements */
8
- children?: React.ReactNode;
9
- /** The total number of errors present in the form */
10
- errorCount?: number;
11
- /** Spacing between form fields, given number will be multiplied by base spacing unit (8) */
12
- fieldSpacing?: 0 | 1 | 2 | 3 | 4 | 5 | 7;
13
- /** Additional buttons rendered on the left side of the save button */
14
- leftSideButtons?: React.ReactNode;
15
- /** Disable HTML5 validation */
16
- noValidate?: boolean;
17
- /** Callback passed to the form element */
18
- onSubmit?: (event: React.FormEvent<HTMLFormElement>) => any;
19
- /** Additional buttons rendered on the right side of the save button */
20
- rightSideButtons?: React.ReactNode;
21
- /** Save button to be rendered */
22
- saveButton?: React.ReactNode;
23
- /** Enables the sticky footer. */
24
- stickyFooter?: boolean;
25
- /** The total number of warnings present in the form */
26
- warningCount?: number;
27
- /** Height of the form (any valid CSS value) */
28
- height?: string;
29
- /** Applies styling for full width buttons. Please note that you will still need to pass the `fullWidth` prop to the button you compose */
30
- fullWidthButtons?: boolean;
31
- }
32
-
33
- declare function Form(props: FormProps): JSX.Element;
34
-
35
- export default Form;