carbon-react 123.11.2 → 124.0.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 (28) hide show
  1. package/esm/components/menu/menu-item/menu-item.component.js +0 -2
  2. package/esm/components/menu/menu-item/menu-item.style.js +1 -0
  3. package/esm/components/menu/menu-segment-title/menu-segment-title.component.d.ts +6 -1
  4. package/esm/components/menu/menu-segment-title/menu-segment-title.component.js +11 -4
  5. package/esm/components/menu/menu-segment-title/menu-segment-title.style.d.ts +3 -2
  6. package/esm/components/menu/menu-segment-title/menu-segment-title.style.js +18 -3
  7. package/esm/components/menu/menu.style.js +2 -7
  8. package/lib/components/menu/menu-item/menu-item.component.js +0 -2
  9. package/lib/components/menu/menu-item/menu-item.style.js +1 -0
  10. package/lib/components/menu/menu-segment-title/menu-segment-title.component.d.ts +6 -1
  11. package/lib/components/menu/menu-segment-title/menu-segment-title.component.js +11 -4
  12. package/lib/components/menu/menu-segment-title/menu-segment-title.style.d.ts +3 -2
  13. package/lib/components/menu/menu-segment-title/menu-segment-title.style.js +20 -5
  14. package/lib/components/menu/menu.style.js +2 -7
  15. package/package.json +1 -1
  16. package/esm/components/show-edit-pod/index.d.ts +0 -1
  17. package/esm/components/show-edit-pod/index.js +0 -1
  18. package/esm/components/show-edit-pod/show-edit-pod.component.js +0 -217
  19. package/esm/components/show-edit-pod/show-edit-pod.config.js +0 -2
  20. package/esm/components/show-edit-pod/show-edit-pod.d.ts +0 -57
  21. package/esm/components/show-edit-pod/show-edit-pod.style.js +0 -32
  22. package/lib/components/show-edit-pod/index.d.ts +0 -1
  23. package/lib/components/show-edit-pod/index.js +0 -13
  24. package/lib/components/show-edit-pod/package.json +0 -6
  25. package/lib/components/show-edit-pod/show-edit-pod.component.js +0 -227
  26. package/lib/components/show-edit-pod/show-edit-pod.config.js +0 -10
  27. package/lib/components/show-edit-pod/show-edit-pod.d.ts +0 -57
  28. package/lib/components/show-edit-pod/show-edit-pod.style.js +0 -40
@@ -126,7 +126,6 @@ export const MenuItem = ({
126
126
  if (submenu) {
127
127
  return /*#__PURE__*/React.createElement(StyledMenuItem, _extends({}, tagComponent("menu-item", rest), {
128
128
  menuType: menuType,
129
- display: "inline-block",
130
129
  title: getTitle(submenu),
131
130
  maxWidth: itemMaxWidth,
132
131
  onClick: updateFocusOnClick
@@ -151,7 +150,6 @@ export const MenuItem = ({
151
150
  return /*#__PURE__*/React.createElement(StyledMenuItem, _extends({}, tagComponent("menu-item", rest), {
152
151
  menuType: menuType,
153
152
  inSubmenu: !!handleSubmenuKeyDown,
154
- display: "inline-block",
155
153
  title: getTitle(children),
156
154
  maxWidth: itemMaxWidth
157
155
  }, rest, {
@@ -151,6 +151,7 @@ const StyledMenuItemWrapper = styled.a.attrs({
151
151
 
152
152
  ${StyledIcon} {
153
153
  bottom: 3px;
154
+ display: inline-block;
154
155
  }
155
156
  }
156
157
 
@@ -1,10 +1,15 @@
1
1
  import React from "react";
2
2
  import { VariantType } from "../menu-item";
3
3
  import { TagProps } from "../../../__internal__/utils/helpers/tags";
4
+ declare const AS_VALUES: readonly ["h2", "h3", "h4", "h5", "h6"];
5
+ declare type AllowedAsValues = typeof AS_VALUES[number];
4
6
  export interface MenuTitleProps extends TagProps {
5
- children: string;
7
+ children?: React.ReactNode;
8
+ text: string;
6
9
  /** Set the colour variant for a menuType */
7
10
  variant?: VariantType;
11
+ /** Set the heading level for the segment title */
12
+ as?: AllowedAsValues;
8
13
  }
9
14
  declare const MenuSegmentTitle: React.ForwardRefExoticComponent<MenuTitleProps & React.RefAttributes<HTMLDivElement>>;
10
15
  export default MenuSegmentTitle;
@@ -1,29 +1,36 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
2
  import React, { useContext } from "react";
3
3
  import PropTypes from "prop-types";
4
- import StyledTitle from "./menu-segment-title.style";
4
+ import { StyledTitle, StyledSegmentChildren } from "./menu-segment-title.style";
5
5
  import MenuContext from "../menu.context";
6
6
  import { StyledMenuItem } from "../menu.style";
7
7
  import tagComponent from "../../../__internal__/utils/helpers/tags";
8
+ const AS_VALUES = ["h2", "h3", "h4", "h5", "h6"];
8
9
  const MenuSegmentTitle = /*#__PURE__*/React.forwardRef(({
9
10
  children,
10
11
  variant = "default",
12
+ text,
13
+ as = "h2",
11
14
  ...rest
12
15
  }, ref) => {
13
16
  const menuContext = useContext(MenuContext);
14
17
  return /*#__PURE__*/React.createElement(StyledMenuItem, {
15
18
  inSubmenu: true
16
- }, /*#__PURE__*/React.createElement(StyledTitle, _extends({}, tagComponent("menu-segment-title", rest), {
19
+ }, /*#__PURE__*/React.createElement(StyledTitle, _extends({
20
+ as: AS_VALUES.includes(as) ? as : /* istanbul ignore next */"h2"
21
+ }, tagComponent("menu-segment-title", rest), {
17
22
  menuType: menuContext.menuType,
18
23
  ref: ref,
19
24
  variant: variant
20
- }), children));
25
+ }), text), children && /*#__PURE__*/React.createElement(StyledSegmentChildren, null, children));
21
26
  });
22
27
  MenuSegmentTitle.propTypes = {
23
- "children": PropTypes.string.isRequired,
28
+ "as": PropTypes.oneOf(["h2", "h3", "h4", "h5", "h6"]),
29
+ "children": PropTypes.node,
24
30
  "data-component": PropTypes.string,
25
31
  "data-element": PropTypes.string,
26
32
  "data-role": PropTypes.string,
33
+ "text": PropTypes.string.isRequired,
27
34
  "variant": PropTypes.oneOf(["alternate", "default"])
28
35
  };
29
36
  MenuSegmentTitle.displayName = "MenuSegmentTitle";
@@ -4,5 +4,6 @@ interface StyledTitleProps {
4
4
  variant?: VariantType;
5
5
  menuType: MenuType;
6
6
  }
7
- declare const StyledTitle: import("styled-components").StyledComponent<"div", any, StyledTitleProps, never>;
8
- export default StyledTitle;
7
+ declare const StyledTitle: import("styled-components").StyledComponent<"h2", any, StyledTitleProps, never>;
8
+ declare const StyledSegmentChildren: import("styled-components").StyledComponent<"ul", any, {}, never>;
9
+ export { StyledTitle, StyledSegmentChildren };
@@ -1,10 +1,11 @@
1
1
  import styled, { css } from "styled-components";
2
2
  import menuConfigVariants from "../menu.config";
3
- const StyledTitle = styled.div`
3
+ const StyledTitle = styled.h2`
4
4
  ${({
5
5
  menuType,
6
6
  variant
7
7
  }) => css`
8
+ margin: 0px;
8
9
  padding: 16px 16px 8px;
9
10
  font-size: 12px;
10
11
  font-weight: 700;
@@ -12,7 +13,21 @@ const StyledTitle = styled.div`
12
13
  line-height: 12px;
13
14
  cursor: default;
14
15
  color: ${menuConfigVariants[menuType].title};
15
- ${variant === "alternate" && `background-color: ${menuConfigVariants[menuType].alternate};`};
16
+ ${variant === "alternate" && `background-color: ${menuConfigVariants[menuType].alternate};`}
16
17
  `}
17
18
  `;
18
- export default StyledTitle;
19
+ const StyledSegmentChildren = styled.ul`
20
+ padding: 0;
21
+
22
+ li {
23
+ list-style: none;
24
+
25
+ &:not(&:last-child) a,
26
+ &:not(&:last-child) button,
27
+ &:not(&:last-child) > span,
28
+ &:not(&:last-child) > div {
29
+ border-radius: var(--borderRadius000);
30
+ }
31
+ }
32
+ `;
33
+ export { StyledTitle, StyledSegmentChildren };
@@ -10,6 +10,7 @@ const StyledMenuWrapper = styled.ul`
10
10
  margin: 0;
11
11
  padding: 0;
12
12
  outline: none;
13
+ display: flex;
13
14
 
14
15
  ${layout}
15
16
  ${flexbox}
@@ -22,13 +23,7 @@ const StyledMenuWrapper = styled.ul`
22
23
  vertical-align: bottom;
23
24
  background-color: ${menuConfigVariants[menuType].background};
24
25
  ${menuType === "dark" && css`
25
- display: inline-block;
26
- vertical-align: bottom;
27
- background-color: ${menuConfigVariants[menuType].background};
28
-
29
- ${menuType === "dark" && css`
30
- color: ${menuConfigVariants[menuType].color};
31
- `}
26
+ color: ${menuConfigVariants[menuType].color};
32
27
  `}
33
28
  `}
34
29
  ${StyledDivider} {
@@ -135,7 +135,6 @@ const MenuItem = ({
135
135
  if (submenu) {
136
136
  return /*#__PURE__*/_react.default.createElement(_menu2.StyledMenuItem, _extends({}, (0, _tags.default)("menu-item", rest), {
137
137
  menuType: menuType,
138
- display: "inline-block",
139
138
  title: getTitle(submenu),
140
139
  maxWidth: itemMaxWidth,
141
140
  onClick: updateFocusOnClick
@@ -160,7 +159,6 @@ const MenuItem = ({
160
159
  return /*#__PURE__*/_react.default.createElement(_menu2.StyledMenuItem, _extends({}, (0, _tags.default)("menu-item", rest), {
161
160
  menuType: menuType,
162
161
  inSubmenu: !!handleSubmenuKeyDown,
163
- display: "inline-block",
164
162
  title: getTitle(children),
165
163
  maxWidth: itemMaxWidth
166
164
  }, rest, {
@@ -160,6 +160,7 @@ const StyledMenuItemWrapper = _styledComponents.default.a.attrs({
160
160
 
161
161
  ${_icon.default} {
162
162
  bottom: 3px;
163
+ display: inline-block;
163
164
  }
164
165
  }
165
166
 
@@ -1,10 +1,15 @@
1
1
  import React from "react";
2
2
  import { VariantType } from "../menu-item";
3
3
  import { TagProps } from "../../../__internal__/utils/helpers/tags";
4
+ declare const AS_VALUES: readonly ["h2", "h3", "h4", "h5", "h6"];
5
+ declare type AllowedAsValues = typeof AS_VALUES[number];
4
6
  export interface MenuTitleProps extends TagProps {
5
- children: string;
7
+ children?: React.ReactNode;
8
+ text: string;
6
9
  /** Set the colour variant for a menuType */
7
10
  variant?: VariantType;
11
+ /** Set the heading level for the segment title */
12
+ as?: AllowedAsValues;
8
13
  }
9
14
  declare const MenuSegmentTitle: React.ForwardRefExoticComponent<MenuTitleProps & React.RefAttributes<HTMLDivElement>>;
10
15
  export default MenuSegmentTitle;
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
- var _menuSegmentTitle = _interopRequireDefault(require("./menu-segment-title.style"));
9
+ var _menuSegmentTitle = require("./menu-segment-title.style");
10
10
  var _menu = _interopRequireDefault(require("../menu.context"));
11
11
  var _menu2 = require("../menu.style");
12
12
  var _tags = _interopRequireDefault(require("../../../__internal__/utils/helpers/tags"));
@@ -14,25 +14,32 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
14
14
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
15
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
16
16
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
17
+ const AS_VALUES = ["h2", "h3", "h4", "h5", "h6"];
17
18
  const MenuSegmentTitle = /*#__PURE__*/_react.default.forwardRef(({
18
19
  children,
19
20
  variant = "default",
21
+ text,
22
+ as = "h2",
20
23
  ...rest
21
24
  }, ref) => {
22
25
  const menuContext = (0, _react.useContext)(_menu.default);
23
26
  return /*#__PURE__*/_react.default.createElement(_menu2.StyledMenuItem, {
24
27
  inSubmenu: true
25
- }, /*#__PURE__*/_react.default.createElement(_menuSegmentTitle.default, _extends({}, (0, _tags.default)("menu-segment-title", rest), {
28
+ }, /*#__PURE__*/_react.default.createElement(_menuSegmentTitle.StyledTitle, _extends({
29
+ as: AS_VALUES.includes(as) ? as : /* istanbul ignore next */"h2"
30
+ }, (0, _tags.default)("menu-segment-title", rest), {
26
31
  menuType: menuContext.menuType,
27
32
  ref: ref,
28
33
  variant: variant
29
- }), children));
34
+ }), text), children && /*#__PURE__*/_react.default.createElement(_menuSegmentTitle.StyledSegmentChildren, null, children));
30
35
  });
31
36
  MenuSegmentTitle.propTypes = {
32
- "children": _propTypes.default.string.isRequired,
37
+ "as": _propTypes.default.oneOf(["h2", "h3", "h4", "h5", "h6"]),
38
+ "children": _propTypes.default.node,
33
39
  "data-component": _propTypes.default.string,
34
40
  "data-element": _propTypes.default.string,
35
41
  "data-role": _propTypes.default.string,
42
+ "text": _propTypes.default.string.isRequired,
36
43
  "variant": _propTypes.default.oneOf(["alternate", "default"])
37
44
  };
38
45
  MenuSegmentTitle.displayName = "MenuSegmentTitle";
@@ -4,5 +4,6 @@ interface StyledTitleProps {
4
4
  variant?: VariantType;
5
5
  menuType: MenuType;
6
6
  }
7
- declare const StyledTitle: import("styled-components").StyledComponent<"div", any, StyledTitleProps, never>;
8
- export default StyledTitle;
7
+ declare const StyledTitle: import("styled-components").StyledComponent<"h2", any, StyledTitleProps, never>;
8
+ declare const StyledSegmentChildren: import("styled-components").StyledComponent<"ul", any, {}, never>;
9
+ export { StyledTitle, StyledSegmentChildren };
@@ -3,17 +3,18 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.StyledTitle = exports.StyledSegmentChildren = void 0;
7
7
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
8
8
  var _menu = _interopRequireDefault(require("../menu.config"));
9
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
10
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
11
11
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
12
- const StyledTitle = _styledComponents.default.div`
12
+ const StyledTitle = _styledComponents.default.h2`
13
13
  ${({
14
14
  menuType,
15
15
  variant
16
16
  }) => (0, _styledComponents.css)`
17
+ margin: 0px;
17
18
  padding: 16px 16px 8px;
18
19
  font-size: 12px;
19
20
  font-weight: 700;
@@ -21,8 +22,22 @@ const StyledTitle = _styledComponents.default.div`
21
22
  line-height: 12px;
22
23
  cursor: default;
23
24
  color: ${_menu.default[menuType].title};
24
- ${variant === "alternate" && `background-color: ${_menu.default[menuType].alternate};`};
25
+ ${variant === "alternate" && `background-color: ${_menu.default[menuType].alternate};`}
25
26
  `}
26
27
  `;
27
- var _default = StyledTitle;
28
- exports.default = _default;
28
+ exports.StyledTitle = StyledTitle;
29
+ const StyledSegmentChildren = _styledComponents.default.ul`
30
+ padding: 0;
31
+
32
+ li {
33
+ list-style: none;
34
+
35
+ &:not(&:last-child) a,
36
+ &:not(&:last-child) button,
37
+ &:not(&:last-child) > span,
38
+ &:not(&:last-child) > div {
39
+ border-radius: var(--borderRadius000);
40
+ }
41
+ }
42
+ `;
43
+ exports.StyledSegmentChildren = StyledSegmentChildren;
@@ -19,6 +19,7 @@ const StyledMenuWrapper = _styledComponents.default.ul`
19
19
  margin: 0;
20
20
  padding: 0;
21
21
  outline: none;
22
+ display: flex;
22
23
 
23
24
  ${_styledSystem.layout}
24
25
  ${_styledSystem.flexbox}
@@ -31,13 +32,7 @@ const StyledMenuWrapper = _styledComponents.default.ul`
31
32
  vertical-align: bottom;
32
33
  background-color: ${_menu.default[menuType].background};
33
34
  ${menuType === "dark" && (0, _styledComponents.css)`
34
- display: inline-block;
35
- vertical-align: bottom;
36
- background-color: ${_menu.default[menuType].background};
37
-
38
- ${menuType === "dark" && (0, _styledComponents.css)`
39
- color: ${_menu.default[menuType].color};
40
- `}
35
+ color: ${_menu.default[menuType].color};
41
36
  `}
42
37
  `}
43
38
  ${_verticalDivider.StyledDivider} {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "123.11.2",
3
+ "version": "124.0.0",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",
@@ -1 +0,0 @@
1
- export { default } from "./show-edit-pod";
@@ -1 +0,0 @@
1
- export { default } from "./show-edit-pod.component";
@@ -1,217 +0,0 @@
1
- import React, { useState, useEffect, useContext, useRef } from "react";
2
- import PropTypes from "prop-types";
3
- import { TransitionGroup, CSSTransition } from "react-transition-group";
4
- import styledSystemPropTypes from "@styled-system/prop-types";
5
- import { filterStyledSystemMarginProps } from "../../style/utils";
6
- import Form from "../form";
7
- import Button from "../button";
8
- import Events from "../../__internal__/utils/helpers/events";
9
- import tagComponent from "../../__internal__/utils/helpers/tags/tags";
10
- import LocaleContext from "../../__internal__/i18n-context";
11
- import StyledPod from "./show-edit-pod.style";
12
- import Logger from "../../__internal__/utils/logger";
13
- const marginPropTypes = filterStyledSystemMarginProps(styledSystemPropTypes.space);
14
- let deprecateWarnTriggered = false;
15
- const ShowEditPod = ({
16
- border = false,
17
- className,
18
- children,
19
- saving = false,
20
- editFields,
21
- editing,
22
- onEdit,
23
- onSave,
24
- onCancel,
25
- onUndo,
26
- cancel = true,
27
- cancelText,
28
- saveText,
29
- onDelete,
30
- deleteText,
31
- softDelete,
32
- buttonAlign = "right",
33
- transitionName = "carbon-show-edit-pod__transition",
34
- title,
35
- hideDeleteButtonInViewMode = false,
36
- variant = "transparent",
37
- ...rest
38
- }) => {
39
- if (!deprecateWarnTriggered) {
40
- deprecateWarnTriggered = true;
41
- Logger.deprecate("The ShowEditPod component is deprecated and will soon be removed. Please use alternatives such as the Fieldset, Form or Pod components instead.");
42
- }
43
- const locale = useContext(LocaleContext);
44
- const ref = useRef();
45
- const editModeNodeRef = useRef();
46
- const showModeNodeRef = useRef();
47
- const [isEditing, setIsEditingState] = useState(false);
48
- const isControlled = editing !== undefined;
49
- const focusPod = () => {
50
- ref.current.focus();
51
- };
52
- useEffect(() => {
53
- if (editing) {
54
- focusPod();
55
- }
56
- }, [editing]);
57
- const isInEditMode = isControlled ? editing : isEditing;
58
- const toggleEditingState = newState => {
59
- if (!isControlled) {
60
- setIsEditingState(newState);
61
- }
62
- };
63
- const handleEdit = ev => {
64
- onEdit(ev);
65
- toggleEditingState(true);
66
- focusPod();
67
- };
68
- const onSaveEditForm = ev => {
69
- ev.preventDefault();
70
- onSave(ev);
71
- toggleEditingState(false);
72
- };
73
- const onCancelEditForm = ev => {
74
- if (onCancel) {
75
- onCancel(ev);
76
- }
77
- toggleEditingState(false);
78
- };
79
- const onKeyDown = ev => {
80
- if (Events.isEscKey(ev)) {
81
- onCancelEditForm(ev);
82
- }
83
- };
84
- const deleteButton = () => {
85
- const label = deleteText || locale.actions.delete();
86
- return /*#__PURE__*/React.createElement(Button, {
87
- buttonType: "tertiary",
88
- destructive: true,
89
- "data-element": "delete-button",
90
- size: "small",
91
- onClick: onDelete
92
- }, label);
93
- };
94
- const editContent = () => /*#__PURE__*/React.createElement(Form, {
95
- onSubmit: onSaveEditForm,
96
- buttonAlignment: buttonAlign,
97
- "data-element": "edit-form",
98
- leftSideButtons: cancel && /*#__PURE__*/React.createElement(Button, {
99
- "data-element": "cancel-button",
100
- onClick: onCancelEditForm,
101
- size: "small"
102
- }, cancelText),
103
- saveButton: /*#__PURE__*/React.createElement(Button, {
104
- disabled: saving,
105
- "data-element": "submit-button",
106
- buttonType: "primary",
107
- type: "submit",
108
- size: "small"
109
- }, saveText),
110
- rightSideButtons: onDelete ? deleteButton() : null,
111
- saving: saving
112
- }, editFields);
113
- const content = () => {
114
- if (isInEditMode) {
115
- return /*#__PURE__*/React.createElement(CSSTransition, {
116
- key: "1",
117
- classNames: transitionName,
118
- timeout: {
119
- enter: 300,
120
- exit: 50
121
- },
122
- nodeRef: editModeNodeRef
123
- }, /*#__PURE__*/React.createElement("div", {
124
- key: "edit",
125
- ref: editModeNodeRef
126
- }, editContent()));
127
- }
128
- return /*#__PURE__*/React.createElement(CSSTransition, {
129
- key: "2",
130
- classNames: transitionName,
131
- timeout: {
132
- enter: 300,
133
- exit: 50
134
- },
135
- nodeRef: showModeNodeRef
136
- }, /*#__PURE__*/React.createElement("div", {
137
- key: "show",
138
- ref: showModeNodeRef
139
- }, children));
140
- };
141
- const universalProps = () => ({
142
- size: "small",
143
- tabIndex: "-1",
144
- title,
145
- ref,
146
- className,
147
- border,
148
- onUndo,
149
- softDelete,
150
- variant,
151
- ...rest,
152
- ...tagComponent("show-edit-pod", rest)
153
- });
154
- const contentProps = () => ({
155
- ...universalProps(),
156
- ...(!hideDeleteButtonInViewMode && {
157
- onDelete
158
- }),
159
- ...(onEdit && {
160
- onEdit: handleEdit
161
- })
162
- });
163
- const editingProps = () => ({
164
- ...universalProps(),
165
- onKeyDown
166
- });
167
- const podProps = () => isInEditMode ? editingProps() : contentProps();
168
- return /*#__PURE__*/React.createElement(StyledPod, podProps(), /*#__PURE__*/React.createElement(TransitionGroup, null, content()));
169
- };
170
- ShowEditPod.propTypes = {
171
- ...marginPropTypes,
172
- /** Pod theme variant. */
173
- variant: PropTypes.oneOf(["primary", "secondary", "tertiary", "tile", "transparent"]),
174
- /** Enable/disable the border on the Pod. */
175
- border: PropTypes.bool,
176
- /** This component supports children. */
177
- children: PropTypes.node,
178
- /** Classes to apply to the component. */
179
- className: PropTypes.string,
180
- /** Allows developers to control the editing state manually. */
181
- editing: PropTypes.bool,
182
- /** Callback when edit button is clicked. */
183
- onEdit: PropTypes.func,
184
- /** A callback triggered when the delete action is clicked. */
185
- onDelete: PropTypes.func,
186
- /** A callback triggered when the undo action is clicked. */
187
- onUndo: PropTypes.func,
188
- /** Sets soft delete state. */
189
- softDelete: PropTypes.bool,
190
- /** Hide delete button in view mode. */
191
- hideDeleteButtonInViewMode: PropTypes.bool,
192
- /** Define fields to be rendered in the edit state */
193
- editFields: PropTypes.node,
194
- /** Define a custom transition between show and edit states */
195
- transitionName: PropTypes.string,
196
- // Props passed to Form
197
- /** A callback triggered after clicking the save button */
198
- onSave: PropTypes.func,
199
- /** Controls which direction the form buttons align */
200
- buttonAlign: PropTypes.oneOf(["left", "right"]),
201
- /** Set to false to hide the cancel button */
202
- cancel: PropTypes.bool,
203
- /** Supply custom text for the cancel button */
204
- cancelText: PropTypes.string,
205
- /** A callback triggered when the form is cancelled */
206
- onCancel: PropTypes.func,
207
- /** Supply custom text for the save button */
208
- saveText: PropTypes.string,
209
- /** Supply custom text for the delete button */
210
- deleteText: PropTypes.string,
211
- /** Can inform if the form is in a saving state (disables the save button) */
212
- saving: PropTypes.bool,
213
- /** Title to be displayed */
214
- title: PropTypes.node
215
- };
216
- export default ShowEditPod;
217
- export { ShowEditPod as BaseShowEditPod };
@@ -1,2 +0,0 @@
1
- export const SHOW_EDIT_POD_ALIGNMENTS = ["left", "right"];
2
- export const SHOW_EDIT_POD_THEMES = ["primary", "secondary", "tertiary", "tile", "transparent"];
@@ -1,57 +0,0 @@
1
- import * as React from "react";
2
-
3
- export interface ShowEditPodProps {
4
- /** Enable/disable the border on the Pod. */
5
- border?: boolean;
6
- /** Controls which direction the form buttons align */
7
- buttonAlign?: string;
8
- /** Set to false to hide the cancel button */
9
- cancel?: boolean;
10
- /** Supply custom text for the cancel button */
11
- cancelText?: string;
12
- /** This component supports children. */
13
- children?: React.ReactNode;
14
- /** Classes to apply to the component. */
15
- className?: string;
16
- /** Supply custom text for the delete button */
17
- deleteText?: string;
18
- /** Define fields to be rendered in the edit state */
19
- editFields?: React.ReactNode;
20
- /** Allows developers to control the editing state manually. */
21
- editing?: boolean;
22
- /** Hide delete button in view mode. */
23
- hideDeleteButtonInViewMode?: boolean;
24
- /** Sets soft delete state. */
25
- softDelete?: boolean;
26
- /** A callback triggered when the form is cancelled */
27
- onCancel?: (ev: React.MouseEvent<HTMLElement>) => void;
28
- /** A callback triggered when the delete action is clicked. */
29
- onDelete?: (
30
- ev: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>
31
- ) => void;
32
- /** A callback triggered when the undo action is clicked. */
33
- onUndo?: (
34
- ev: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>
35
- ) => void;
36
- /** Callback when edit button is clicked. */
37
- onEdit?: (
38
- ev: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>
39
- ) => void;
40
- // Props passed to Form
41
- /** A callback triggered after clicking the save button */
42
- onSave?: (ev: React.FormEvent<HTMLFormElement>) => void;
43
- /** Define a custom transition between show and edit states */
44
- transitionName?: string;
45
- /** Pod theme variant. */
46
- variant?: string;
47
- /** Supply custom text for the save button */
48
- saveText?: string;
49
- /** Can inform if the form is in a saving state (disables the save button) */
50
- saving?: boolean;
51
- /** Title to be displayed */
52
- title?: React.ReactNode;
53
- }
54
-
55
- declare function ShowEditPod(props: ShowEditPodProps): JSX.Element;
56
-
57
- export default ShowEditPod;
@@ -1,32 +0,0 @@
1
- import styled from "styled-components";
2
- import { StyledFormFooter } from "../form/form.style";
3
- import { StyledContent } from "../pod/pod.style";
4
- import Pod from "../pod";
5
- const StyledPod = styled(Pod)`
6
- ${StyledFormFooter} {
7
- margin-top: 24px;
8
- }
9
-
10
- ${StyledContent} {
11
- padding: 16px;
12
- }
13
-
14
- .common-input__prefix {
15
- z-index: 5;
16
- }
17
-
18
- .carbon-show-edit-pod__transition-enter {
19
- opacity: 0;
20
- }
21
-
22
- .carbon-show-edit-pod__transition-enter.carbon-show-edit-pod__transition-enter-active {
23
- opacity: 1;
24
- transition: all 300ms ease-in;
25
- }
26
-
27
- .carbon-show-edit-pod__transition-exit {
28
- opacity: 0;
29
- position: absolute;
30
- }
31
- `;
32
- export default StyledPod;
@@ -1 +0,0 @@
1
- export { default } from "./show-edit-pod";
@@ -1,13 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "default", {
7
- enumerable: true,
8
- get: function () {
9
- return _showEditPod.default;
10
- }
11
- });
12
- var _showEditPod = _interopRequireDefault(require("./show-edit-pod.component"));
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -1,6 +0,0 @@
1
- {
2
- "sideEffects": false,
3
- "module": "../../../esm/components/show-edit-pod/index.js",
4
- "main": "./index.js",
5
- "types": "./index.d.ts"
6
- }
@@ -1,227 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = exports.BaseShowEditPod = void 0;
7
- var _react = _interopRequireWildcard(require("react"));
8
- var _propTypes = _interopRequireDefault(require("prop-types"));
9
- var _reactTransitionGroup = require("react-transition-group");
10
- var _propTypes2 = _interopRequireDefault(require("@styled-system/prop-types"));
11
- var _utils = require("../../style/utils");
12
- var _form = _interopRequireDefault(require("../form"));
13
- var _button = _interopRequireDefault(require("../button"));
14
- var _events = _interopRequireDefault(require("../../__internal__/utils/helpers/events"));
15
- var _tags = _interopRequireDefault(require("../../__internal__/utils/helpers/tags/tags"));
16
- var _i18nContext = _interopRequireDefault(require("../../__internal__/i18n-context"));
17
- var _showEditPod = _interopRequireDefault(require("./show-edit-pod.style"));
18
- var _logger = _interopRequireDefault(require("../../__internal__/utils/logger"));
19
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
21
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
22
- const marginPropTypes = (0, _utils.filterStyledSystemMarginProps)(_propTypes2.default.space);
23
- let deprecateWarnTriggered = false;
24
- const ShowEditPod = ({
25
- border = false,
26
- className,
27
- children,
28
- saving = false,
29
- editFields,
30
- editing,
31
- onEdit,
32
- onSave,
33
- onCancel,
34
- onUndo,
35
- cancel = true,
36
- cancelText,
37
- saveText,
38
- onDelete,
39
- deleteText,
40
- softDelete,
41
- buttonAlign = "right",
42
- transitionName = "carbon-show-edit-pod__transition",
43
- title,
44
- hideDeleteButtonInViewMode = false,
45
- variant = "transparent",
46
- ...rest
47
- }) => {
48
- if (!deprecateWarnTriggered) {
49
- deprecateWarnTriggered = true;
50
- _logger.default.deprecate("The ShowEditPod component is deprecated and will soon be removed. Please use alternatives such as the Fieldset, Form or Pod components instead.");
51
- }
52
- const locale = (0, _react.useContext)(_i18nContext.default);
53
- const ref = (0, _react.useRef)();
54
- const editModeNodeRef = (0, _react.useRef)();
55
- const showModeNodeRef = (0, _react.useRef)();
56
- const [isEditing, setIsEditingState] = (0, _react.useState)(false);
57
- const isControlled = editing !== undefined;
58
- const focusPod = () => {
59
- ref.current.focus();
60
- };
61
- (0, _react.useEffect)(() => {
62
- if (editing) {
63
- focusPod();
64
- }
65
- }, [editing]);
66
- const isInEditMode = isControlled ? editing : isEditing;
67
- const toggleEditingState = newState => {
68
- if (!isControlled) {
69
- setIsEditingState(newState);
70
- }
71
- };
72
- const handleEdit = ev => {
73
- onEdit(ev);
74
- toggleEditingState(true);
75
- focusPod();
76
- };
77
- const onSaveEditForm = ev => {
78
- ev.preventDefault();
79
- onSave(ev);
80
- toggleEditingState(false);
81
- };
82
- const onCancelEditForm = ev => {
83
- if (onCancel) {
84
- onCancel(ev);
85
- }
86
- toggleEditingState(false);
87
- };
88
- const onKeyDown = ev => {
89
- if (_events.default.isEscKey(ev)) {
90
- onCancelEditForm(ev);
91
- }
92
- };
93
- const deleteButton = () => {
94
- const label = deleteText || locale.actions.delete();
95
- return /*#__PURE__*/_react.default.createElement(_button.default, {
96
- buttonType: "tertiary",
97
- destructive: true,
98
- "data-element": "delete-button",
99
- size: "small",
100
- onClick: onDelete
101
- }, label);
102
- };
103
- const editContent = () => /*#__PURE__*/_react.default.createElement(_form.default, {
104
- onSubmit: onSaveEditForm,
105
- buttonAlignment: buttonAlign,
106
- "data-element": "edit-form",
107
- leftSideButtons: cancel && /*#__PURE__*/_react.default.createElement(_button.default, {
108
- "data-element": "cancel-button",
109
- onClick: onCancelEditForm,
110
- size: "small"
111
- }, cancelText),
112
- saveButton: /*#__PURE__*/_react.default.createElement(_button.default, {
113
- disabled: saving,
114
- "data-element": "submit-button",
115
- buttonType: "primary",
116
- type: "submit",
117
- size: "small"
118
- }, saveText),
119
- rightSideButtons: onDelete ? deleteButton() : null,
120
- saving: saving
121
- }, editFields);
122
- const content = () => {
123
- if (isInEditMode) {
124
- return /*#__PURE__*/_react.default.createElement(_reactTransitionGroup.CSSTransition, {
125
- key: "1",
126
- classNames: transitionName,
127
- timeout: {
128
- enter: 300,
129
- exit: 50
130
- },
131
- nodeRef: editModeNodeRef
132
- }, /*#__PURE__*/_react.default.createElement("div", {
133
- key: "edit",
134
- ref: editModeNodeRef
135
- }, editContent()));
136
- }
137
- return /*#__PURE__*/_react.default.createElement(_reactTransitionGroup.CSSTransition, {
138
- key: "2",
139
- classNames: transitionName,
140
- timeout: {
141
- enter: 300,
142
- exit: 50
143
- },
144
- nodeRef: showModeNodeRef
145
- }, /*#__PURE__*/_react.default.createElement("div", {
146
- key: "show",
147
- ref: showModeNodeRef
148
- }, children));
149
- };
150
- const universalProps = () => ({
151
- size: "small",
152
- tabIndex: "-1",
153
- title,
154
- ref,
155
- className,
156
- border,
157
- onUndo,
158
- softDelete,
159
- variant,
160
- ...rest,
161
- ...(0, _tags.default)("show-edit-pod", rest)
162
- });
163
- const contentProps = () => ({
164
- ...universalProps(),
165
- ...(!hideDeleteButtonInViewMode && {
166
- onDelete
167
- }),
168
- ...(onEdit && {
169
- onEdit: handleEdit
170
- })
171
- });
172
- const editingProps = () => ({
173
- ...universalProps(),
174
- onKeyDown
175
- });
176
- const podProps = () => isInEditMode ? editingProps() : contentProps();
177
- return /*#__PURE__*/_react.default.createElement(_showEditPod.default, podProps(), /*#__PURE__*/_react.default.createElement(_reactTransitionGroup.TransitionGroup, null, content()));
178
- };
179
- exports.BaseShowEditPod = ShowEditPod;
180
- ShowEditPod.propTypes = {
181
- ...marginPropTypes,
182
- /** Pod theme variant. */
183
- variant: _propTypes.default.oneOf(["primary", "secondary", "tertiary", "tile", "transparent"]),
184
- /** Enable/disable the border on the Pod. */
185
- border: _propTypes.default.bool,
186
- /** This component supports children. */
187
- children: _propTypes.default.node,
188
- /** Classes to apply to the component. */
189
- className: _propTypes.default.string,
190
- /** Allows developers to control the editing state manually. */
191
- editing: _propTypes.default.bool,
192
- /** Callback when edit button is clicked. */
193
- onEdit: _propTypes.default.func,
194
- /** A callback triggered when the delete action is clicked. */
195
- onDelete: _propTypes.default.func,
196
- /** A callback triggered when the undo action is clicked. */
197
- onUndo: _propTypes.default.func,
198
- /** Sets soft delete state. */
199
- softDelete: _propTypes.default.bool,
200
- /** Hide delete button in view mode. */
201
- hideDeleteButtonInViewMode: _propTypes.default.bool,
202
- /** Define fields to be rendered in the edit state */
203
- editFields: _propTypes.default.node,
204
- /** Define a custom transition between show and edit states */
205
- transitionName: _propTypes.default.string,
206
- // Props passed to Form
207
- /** A callback triggered after clicking the save button */
208
- onSave: _propTypes.default.func,
209
- /** Controls which direction the form buttons align */
210
- buttonAlign: _propTypes.default.oneOf(["left", "right"]),
211
- /** Set to false to hide the cancel button */
212
- cancel: _propTypes.default.bool,
213
- /** Supply custom text for the cancel button */
214
- cancelText: _propTypes.default.string,
215
- /** A callback triggered when the form is cancelled */
216
- onCancel: _propTypes.default.func,
217
- /** Supply custom text for the save button */
218
- saveText: _propTypes.default.string,
219
- /** Supply custom text for the delete button */
220
- deleteText: _propTypes.default.string,
221
- /** Can inform if the form is in a saving state (disables the save button) */
222
- saving: _propTypes.default.bool,
223
- /** Title to be displayed */
224
- title: _propTypes.default.node
225
- };
226
- var _default = ShowEditPod;
227
- exports.default = _default;
@@ -1,10 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.SHOW_EDIT_POD_THEMES = exports.SHOW_EDIT_POD_ALIGNMENTS = void 0;
7
- const SHOW_EDIT_POD_ALIGNMENTS = ["left", "right"];
8
- exports.SHOW_EDIT_POD_ALIGNMENTS = SHOW_EDIT_POD_ALIGNMENTS;
9
- const SHOW_EDIT_POD_THEMES = ["primary", "secondary", "tertiary", "tile", "transparent"];
10
- exports.SHOW_EDIT_POD_THEMES = SHOW_EDIT_POD_THEMES;
@@ -1,57 +0,0 @@
1
- import * as React from "react";
2
-
3
- export interface ShowEditPodProps {
4
- /** Enable/disable the border on the Pod. */
5
- border?: boolean;
6
- /** Controls which direction the form buttons align */
7
- buttonAlign?: string;
8
- /** Set to false to hide the cancel button */
9
- cancel?: boolean;
10
- /** Supply custom text for the cancel button */
11
- cancelText?: string;
12
- /** This component supports children. */
13
- children?: React.ReactNode;
14
- /** Classes to apply to the component. */
15
- className?: string;
16
- /** Supply custom text for the delete button */
17
- deleteText?: string;
18
- /** Define fields to be rendered in the edit state */
19
- editFields?: React.ReactNode;
20
- /** Allows developers to control the editing state manually. */
21
- editing?: boolean;
22
- /** Hide delete button in view mode. */
23
- hideDeleteButtonInViewMode?: boolean;
24
- /** Sets soft delete state. */
25
- softDelete?: boolean;
26
- /** A callback triggered when the form is cancelled */
27
- onCancel?: (ev: React.MouseEvent<HTMLElement>) => void;
28
- /** A callback triggered when the delete action is clicked. */
29
- onDelete?: (
30
- ev: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>
31
- ) => void;
32
- /** A callback triggered when the undo action is clicked. */
33
- onUndo?: (
34
- ev: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>
35
- ) => void;
36
- /** Callback when edit button is clicked. */
37
- onEdit?: (
38
- ev: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>
39
- ) => void;
40
- // Props passed to Form
41
- /** A callback triggered after clicking the save button */
42
- onSave?: (ev: React.FormEvent<HTMLFormElement>) => void;
43
- /** Define a custom transition between show and edit states */
44
- transitionName?: string;
45
- /** Pod theme variant. */
46
- variant?: string;
47
- /** Supply custom text for the save button */
48
- saveText?: string;
49
- /** Can inform if the form is in a saving state (disables the save button) */
50
- saving?: boolean;
51
- /** Title to be displayed */
52
- title?: React.ReactNode;
53
- }
54
-
55
- declare function ShowEditPod(props: ShowEditPodProps): JSX.Element;
56
-
57
- export default ShowEditPod;
@@ -1,40 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _styledComponents = _interopRequireDefault(require("styled-components"));
8
- var _form = require("../form/form.style");
9
- var _pod = require("../pod/pod.style");
10
- var _pod2 = _interopRequireDefault(require("../pod"));
11
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
- const StyledPod = (0, _styledComponents.default)(_pod2.default)`
13
- ${_form.StyledFormFooter} {
14
- margin-top: 24px;
15
- }
16
-
17
- ${_pod.StyledContent} {
18
- padding: 16px;
19
- }
20
-
21
- .common-input__prefix {
22
- z-index: 5;
23
- }
24
-
25
- .carbon-show-edit-pod__transition-enter {
26
- opacity: 0;
27
- }
28
-
29
- .carbon-show-edit-pod__transition-enter.carbon-show-edit-pod__transition-enter-active {
30
- opacity: 1;
31
- transition: all 300ms ease-in;
32
- }
33
-
34
- .carbon-show-edit-pod__transition-exit {
35
- opacity: 0;
36
- position: absolute;
37
- }
38
- `;
39
- var _default = StyledPod;
40
- exports.default = _default;