carbon-react 94.6.0 → 94.7.1

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.
@@ -19,8 +19,6 @@ var _events = _interopRequireDefault(require("../../__internal__/utils/helpers/e
19
19
 
20
20
  var _accordion = require("./accordion.style");
21
21
 
22
- var _button = _interopRequireDefault(require("../button"));
23
-
24
22
  var _validations = _interopRequireDefault(require("../../__internal__/validations"));
25
23
 
26
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -71,7 +69,10 @@ const Accordion = /*#__PURE__*/_react.default.forwardRef(({
71
69
  setContentHeight(accordionContent.current.scrollHeight);
72
70
  }, [isExpanded, children]);
73
71
  const toggleAccordion = (0, _react.useCallback)(ev => {
74
- if (!isControlled) setIsExpandedInternal(!isExpanded);
72
+ if (!isControlled) {
73
+ setIsExpandedInternal(!isExpanded);
74
+ }
75
+
75
76
  if (onChange) onChange(ev, !isExpanded);
76
77
  }, [isControlled, isExpanded, onChange]);
77
78
  const handleKeyDown = (0, _react.useCallback)(ev => {
@@ -88,6 +89,9 @@ const Accordion = /*#__PURE__*/_react.default.forwardRef(({
88
89
  const headerId = `AccordionHeader_${guid.current}`;
89
90
  const contentId = `AccordionContent_${guid.current}`;
90
91
  const showValidationIcon = !!(error || warning || info);
92
+
93
+ const getTitle = () => isExpanded ? openTitle || title : title;
94
+
91
95
  return /*#__PURE__*/_react.default.createElement(_accordion.StyledAccordionContainer, _extends({
92
96
  id: accordionId,
93
97
  "data-component": "accordion",
@@ -100,39 +104,39 @@ const Accordion = /*#__PURE__*/_react.default.forwardRef(({
100
104
  id: headerId,
101
105
  "aria-expanded": isExpanded,
102
106
  "aria-controls": contentId,
103
- onClick: buttonHeading ? undefined : toggleAccordion,
104
- onKeyDown: buttonHeading ? undefined : handleKeyDown,
107
+ onClick: toggleAccordion,
108
+ onKeyDown: handleKeyDown,
109
+ tabIndex: 0,
105
110
  iconAlign: iconAlign,
106
111
  ref: ref,
107
- tabIndex: buttonHeading ? "-1" : "0",
108
112
  size: size,
109
113
  isExpanded: isExpanded,
110
114
  buttonHeading: buttonHeading,
111
- buttonWidth: buttonWidth
112
- }, headerSpacing), buttonHeading && /*#__PURE__*/_react.default.createElement(_button.default, {
113
- buttonType: "tertiary",
114
- iconType: "chevron_down",
115
- iconPosition: "after",
116
- onClick: toggleAccordion
117
- }, isExpanded ? openTitle || title : title), !buttonHeading && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_accordion.StyledAccordionHeadingsContainer, {
115
+ buttonWidth: buttonWidth,
116
+ hasButtonProps: buttonHeading && headerSpacing
117
+ }, buttonHeading && {
118
+ role: "button",
119
+ p: 0
120
+ }, headerSpacing), /*#__PURE__*/_react.default.createElement(_accordion.StyledAccordionHeadingsContainer, {
118
121
  "data-element": "accordion-headings-container",
119
- hasValidationIcon: showValidationIcon
120
- }, typeof title === "string" ? /*#__PURE__*/_react.default.createElement(_accordion.StyledAccordionTitle, {
122
+ hasValidationIcon: showValidationIcon,
123
+ buttonHeading: buttonHeading
124
+ }, !buttonHeading && typeof title === "string" ? /*#__PURE__*/_react.default.createElement(_accordion.StyledAccordionTitle, {
121
125
  "data-element": "accordion-title",
122
126
  size: size
123
- }, title) : title, showValidationIcon && /*#__PURE__*/_react.default.createElement(_validations.default, {
127
+ }, title) : getTitle(), !buttonHeading && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, showValidationIcon && /*#__PURE__*/_react.default.createElement(_validations.default, {
124
128
  error: error,
125
129
  warning: warning,
126
130
  info: info,
127
131
  tooltipPosition: "top",
128
132
  tabIndex: 0,
129
133
  ml: 1
130
- }), subTitle && size === "large" && /*#__PURE__*/_react.default.createElement(_accordion.StyledAccordionSubTitle, null, subTitle)), /*#__PURE__*/_react.default.createElement(_accordion.StyledAccordionIcon, {
134
+ }), subTitle && size === "large" && /*#__PURE__*/_react.default.createElement(_accordion.StyledAccordionSubTitle, null, subTitle))), /*#__PURE__*/_react.default.createElement(_accordion.StyledAccordionIcon, {
131
135
  "data-element": "accordion-icon",
132
136
  type: iconType,
133
137
  isExpanded: isExpanded,
134
138
  iconAlign: iconAlign
135
- }))), /*#__PURE__*/_react.default.createElement(_accordion.StyledAccordionContentContainer, {
139
+ })), /*#__PURE__*/_react.default.createElement(_accordion.StyledAccordionContentContainer, {
136
140
  isExpanded: isExpanded,
137
141
  maxHeight: contentHeight
138
142
  }, /*#__PURE__*/_react.default.createElement(_accordion.StyledAccordionContent, {
@@ -22,11 +22,11 @@ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return
22
22
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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; }
23
23
 
24
24
  const StyledAccordionGroup = _styledComponents.default.div`
25
- ${_styledSystem.margin};
25
+ ${_styledSystem.margin}
26
26
  `;
27
27
  exports.StyledAccordionGroup = StyledAccordionGroup;
28
28
  const StyledAccordionContainer = _styledComponents.default.div`
29
- ${_styledSystem.space};
29
+ ${_styledSystem.space}
30
30
  display: flex;
31
31
  align-items: ${({
32
32
  buttonHeading
@@ -48,18 +48,18 @@ const StyledAccordionContainer = _styledComponents.default.div`
48
48
  theme
49
49
  }) => (0, _styledComponents.css)`
50
50
  border: 1px solid ${theme.accordion.border};
51
- `};
51
+ `}
52
52
  ${({
53
53
  borders
54
54
  }) => borders === "default" && (0, _styledComponents.css)`
55
55
  border-left: none;
56
56
  border-right: none;
57
- `};
57
+ `}
58
58
  ${({
59
59
  borders
60
60
  }) => borders === "none" && (0, _styledComponents.css)`
61
61
  border: none;
62
- `};
62
+ `}
63
63
 
64
64
  & + & {
65
65
  margin-top: -1px;
@@ -103,28 +103,29 @@ const StyledAccordionIcon = (0, _styledComponents.default)(_icon.default)`
103
103
  `;
104
104
  exports.StyledAccordionIcon = StyledAccordionIcon;
105
105
  const StyledAccordionHeadingsContainer = _styledComponents.default.div`
106
- display: grid;
107
106
  ${({
107
+ buttonHeading,
108
108
  hasValidationIcon
109
- }) => hasValidationIcon && (0, _styledComponents.css)`
110
- grid-template-columns: min-content auto;
109
+ }) => !buttonHeading && (0, _styledComponents.css)`
110
+ display: grid;
111
+ ${hasValidationIcon && (0, _styledComponents.css)`
112
+ grid-template-columns: min-content auto;
113
+
114
+ ${StyledAccordionSubTitle} {
115
+ grid-column: span 3;
116
+ }
117
+ `}
111
118
 
112
- ${StyledAccordionSubTitle} {
113
- grid-column: span 3;
114
- }
115
- `}
119
+ ${!hasValidationIcon && (0, _styledComponents.css)`
120
+ grid-template-rows: auto auto;
121
+ `}
116
122
 
117
- ${({
118
- hasValidationIcon
119
- }) => !hasValidationIcon && (0, _styledComponents.css)`
120
- grid-template-rows: auto auto;
123
+ ${_validationIcon.default} {
124
+ height: 20px;
125
+ position: relative;
126
+ top: 2px;
127
+ }
121
128
  `}
122
-
123
- ${_validationIcon.default} {
124
- height: 20px;
125
- position: relative;
126
- top: 2px;
127
- }
128
129
  `;
129
130
  exports.StyledAccordionHeadingsContainer = StyledAccordionHeadingsContainer;
130
131
  const StyledAccordionTitleContainer = _styledComponents.default.div`
@@ -132,13 +133,12 @@ const StyledAccordionTitleContainer = _styledComponents.default.div`
132
133
  buttonHeading,
133
134
  buttonWidth,
134
135
  iconAlign,
135
- isExpanded,
136
136
  size,
137
- theme
137
+ theme,
138
+ hasButtonProps
138
139
  }) => (0, _styledComponents.css)`
139
140
  padding: ${size === "small" ? theme.spacing * 2 : theme.spacing * 3}px;
140
- ${_styledSystem.space};
141
- ${buttonHeading && "padding: 0"}
141
+ ${_styledSystem.space}
142
142
  display: flex;
143
143
  align-items: center;
144
144
  justify-content: space-between;
@@ -152,7 +152,7 @@ const StyledAccordionTitleContainer = _styledComponents.default.div`
152
152
  z-index: 1;
153
153
 
154
154
  &:focus {
155
- outline: ${buttonHeading ? "none" : `2px solid ${theme.colors.focus}`};
155
+ outline: ${buttonHeading ? "3px" : "2px"} solid ${theme.colors.focus};
156
156
  }
157
157
 
158
158
  ${!buttonHeading && (0, _styledComponents.css)`
@@ -161,24 +161,40 @@ const StyledAccordionTitleContainer = _styledComponents.default.div`
161
161
  }
162
162
  `}
163
163
 
164
- button {
165
- position: relative;
166
- ${buttonWidth && (0, _styledComponents.css)`
167
- width: ${buttonWidth}px;
164
+ ${buttonHeading && (0, _styledComponents.css)`
165
+ box-sizing: border-box;
166
+ font-weight: 600;
167
+ text-decoration: none;
168
+ font-size: ${theme.text.size};
169
+ min-height: ${theme.spacing * 5}px;
170
+
171
+ color: ${theme.colors.primary};
172
+
173
+ ${!hasButtonProps && (0, _styledComponents.css)`
174
+ ${StyledAccordionHeadingsContainer} {
175
+ margin-left: ${iconAlign === "right" ? "64px" : "32px"};
176
+ }
168
177
  `}
169
- }
170
178
 
171
- button > span:first-child {
172
- position: absolute;
173
- margin-left: -16px;
174
- }
179
+ ${StyledAccordionIcon} {
180
+ color: ${theme.colors.primary};
181
+ ${!hasButtonProps && (0, _styledComponents.css)`
182
+ position: relative;
183
+ ${iconAlign}: 16px;
184
+ `}
185
+ }
175
186
 
176
- button > span[data-component="icon"] {
177
- position: absolute;
178
- right: 16px;
179
- transition: transform 0.3s;
180
- ${!isExpanded && "transform: rotate(90deg)"};
181
- }
187
+ &:hover {
188
+ color: ${theme.colors.secondary};
189
+ ${StyledAccordionIcon} {
190
+ color: ${theme.colors.secondary};
191
+ }
192
+ }
193
+
194
+ ${buttonWidth && (0, _styledComponents.css)`
195
+ width: ${buttonWidth}px;
196
+ `}
197
+ `}
182
198
  `}
183
199
  `;
184
200
  exports.StyledAccordionTitleContainer = StyledAccordionTitleContainer;
@@ -95,7 +95,8 @@ const FlatTableBodyDraggable = ({
95
95
  id: `${item.props.id}`,
96
96
  moveItem,
97
97
  findItem,
98
- draggable: true
98
+ draggable: true,
99
+ key: `${item.props.id}`
99
100
  }, [/*#__PURE__*/_react.default.createElement(_flatTableCell.default, {
100
101
  key: item.props.id
101
102
  }, /*#__PURE__*/_react.default.createElement(_icon.default, {
@@ -242,7 +242,7 @@ const StyledFlatTableRow = _styledComponents.default.tr`
242
242
  ${_flatTableCell.StyledFlatTableCell}:first-child > div,
243
243
  ${_flatTableRowHeader.StyledFlatTableRowHeader}:first-child > div,
244
244
  ${_flatTableCheckbox.default} + ${_flatTableCell.StyledFlatTableCell} > div {
245
- ${_icon.default} {
245
+ ${_icon.default}[type="chevron_down_thick"]:first-of-type {
246
246
  transition: transform 0.3s;
247
247
  ${!isExpanded && (0, _styledComponents.css)`
248
248
  transform: rotate(-90deg);
@@ -42,6 +42,9 @@ const PopoverContainer = ({
42
42
  renderCloseComponent,
43
43
  shouldCoverButton,
44
44
  ariaDescribedBy,
45
+ openButtonAriaLabel,
46
+ closeButtonAriaLabel = "close",
47
+ containerAriaLabel,
45
48
  ...rest
46
49
  }) => {
47
50
  const isControlled = open !== undefined;
@@ -49,7 +52,7 @@ const PopoverContainer = ({
49
52
  const closeButtonRef = (0, _react.useRef)();
50
53
  const openButtonRef = (0, _react.useRef)();
51
54
  const guid = (0, _react.useRef)((0, _guid.default)());
52
- const popoverContainerId = `PopoverContainer_${guid.current}`;
55
+ const popoverContainerId = title ? `PopoverContainer_${guid.current}` : undefined;
53
56
  const isOpen = isControlled ? open : isOpenInternal;
54
57
  (0, _react.useEffect)(() => {
55
58
  if (isOpen && closeButtonRef.current) closeButtonRef.current.focus();
@@ -75,18 +78,19 @@ const PopoverContainer = ({
75
78
  dataElement: "popover-container-open-component",
76
79
  onClick: handleOpenButtonClick,
77
80
  ref: openButtonRef,
78
- ariaLabel: title
81
+ ariaLabel: openButtonAriaLabel || title
79
82
  };
80
83
  const renderCloseComponentProps = {
81
84
  dataElement: "popover-container-close-component",
82
85
  tabIndex: 0,
83
86
  onClick: handleCloseButtonClick,
84
87
  ref: closeButtonRef,
85
- ariaLabel: "close"
88
+ ariaLabel: closeButtonAriaLabel
86
89
  };
87
90
  return /*#__PURE__*/_react.default.createElement(_popoverContainer.PopoverContainerWrapperStyle, {
88
91
  "data-component": "popover-container",
89
- "aria-labelledby": popoverContainerId
92
+ role: "region",
93
+ "aria-labelledby": isOpen ? popoverContainerId : undefined
90
94
  }, renderOpenComponent(renderOpenComponentProps), /*#__PURE__*/_react.default.createElement(_reactTransitionGroup.Transition, {
91
95
  in: isOpen,
92
96
  timeout: {
@@ -102,6 +106,7 @@ const PopoverContainer = ({
102
106
  position: position,
103
107
  shouldCoverButton: shouldCoverButton,
104
108
  "aria-labelledby": popoverContainerId,
109
+ "aria-label": containerAriaLabel,
105
110
  "aria-describedby": ariaDescribedBy,
106
111
  p: "16px 24px"
107
112
  }, (0, _utils.filterStyledSystemPaddingProps)(rest)), /*#__PURE__*/_react.default.createElement(_popoverContainer.PopoverContainerHeaderStyle, null, /*#__PURE__*/_react.default.createElement(_popoverContainer.PopoverContainerTitleStyle, {
@@ -148,18 +153,29 @@ PopoverContainer.propTypes = { ...paddingPropTypes,
148
153
  children: _propTypes.default.node,
149
154
 
150
155
  /** The id of the element that describes the dialog */
151
- ariaDescribedBy: _propTypes.default.string
156
+ ariaDescribedBy: _propTypes.default.string,
157
+
158
+ /** Open button aria label */
159
+ openButtonAriaLabel: _propTypes.default.string,
160
+
161
+ /** Close button aria label */
162
+ closeButtonAriaLabel: _propTypes.default.string,
163
+
164
+ /** Container aria label */
165
+ containerAriaLabel: _propTypes.default.string
152
166
  };
153
167
  PopoverContainer.defaultProps = {
154
168
  position: "right",
155
169
  shouldCoverButton: false,
156
170
  renderOpenComponent: ({
157
- // eslint-disable-next-line react/prop-types
171
+ /* eslint-disable react/prop-types */
158
172
  tabIndex,
159
173
  onClick,
160
174
  dataElement,
161
175
  ref,
162
176
  ariaLabel
177
+ /* eslint-enable react/prop-types */
178
+
163
179
  }) => /*#__PURE__*/_react.default.createElement(_popoverContainer.PopoverContainerOpenIcon, {
164
180
  tabIndex: tabIndex,
165
181
  onAction: onClick,
@@ -171,12 +187,14 @@ PopoverContainer.defaultProps = {
171
187
  type: "settings"
172
188
  })),
173
189
  renderCloseComponent: ({
174
- // eslint-disable-next-line react/prop-types
190
+ /* eslint-disable react/prop-types */
175
191
  dataElement,
176
192
  tabIndex,
177
193
  onClick,
178
194
  ref,
179
195
  ariaLabel
196
+ /* eslint-enable react/prop-types */
197
+
180
198
  }) => /*#__PURE__*/_react.default.createElement(_popoverContainer.PopoverContainerCloseIcon, {
181
199
  "data-element": dataElement,
182
200
  tabIndex: tabIndex,
@@ -22,6 +22,12 @@ export interface PopoverContainerProps extends PaddingProps {
22
22
  shouldCoverButton?: boolean;
23
23
  /** The id of the element that describe the dialog. */
24
24
  ariaDescribedBy?: string;
25
+ /** Open button aria label */
26
+ openButtonAriaLabel?: string;
27
+ /** Close button aria label */
28
+ closeButtonAriaLabel?: string;
29
+ /** Container aria label */
30
+ containerAriaLabel?: string;
25
31
  }
26
32
 
27
33
  declare function PopoverContainer(props: PopoverContainerProps): JSX.Element;
@@ -27,7 +27,7 @@ const PopoverContainerIcon = (0, _styledComponents.default)(_iconButton.default)
27
27
  color: ${({
28
28
  theme
29
29
  }) => theme.popoverContainer.iconColor};
30
- } ;
30
+ }
31
31
  `;
32
32
  exports.PopoverContainerIcon = PopoverContainerIcon;
33
33
  const PopoverContainerHeaderStyle = _styledComponents.default.div`
@@ -107,7 +107,7 @@ const PopoverContainerCloseIcon = (0, _styledComponents.default)(_iconButton.def
107
107
  color: ${({
108
108
  theme
109
109
  }) => theme.popoverContainer.iconColor};
110
- } ;
110
+ }
111
111
  `;
112
112
  exports.PopoverContainerCloseIcon = PopoverContainerCloseIcon;
113
113
  const PopoverContainerTitleStyle = _styledComponents.default.div`
@@ -23,6 +23,10 @@ var _default = theme => ({ ...theme,
23
23
  metaName: "Base Theme",
24
24
  metaPublic: "true",
25
25
  colorsLogo: "#00D639",
26
+ colorsYin030: "rgba(0,0,0,0.3)",
27
+ colorsYin055: "rgba(0,0,0,0.55)",
28
+ colorsYin065: "rgba(0,0,0,0.65)",
29
+ colorsYin090: "rgba(0,0,0,0.9)",
26
30
  colorsComponentsNavigation500: "#008146",
27
31
  colorsComponentsNavigation600: "#006738",
28
32
  colorsComponentsNavigation700: "#004D2A",
@@ -126,31 +130,31 @@ var _default = theme => ({ ...theme,
126
130
  sizing050: "4px",
127
131
  sizing075: "6px",
128
132
  sizingLogowidth: "40px",
129
- spacing000: theme.space[0],
133
+ spacing000: `${theme.space[0]}px`,
130
134
  // 0px
131
135
  spacing025: "2px",
132
136
  spacing050: "4px",
133
137
  spacing075: "6px",
134
- spacing100: theme.space[1],
138
+ spacing100: `${theme.space[1]}px`,
135
139
  // 8px
136
140
  spacing125: "10px",
137
141
  spacing150: "12px",
138
- spacing200: theme.space[2],
142
+ spacing200: `${theme.space[2]}px`,
139
143
  // 16px
140
144
  spacing250: "20px",
141
- spacing300: theme.space[3],
145
+ spacing300: `${theme.space[3]}px`,
142
146
  // 24px
143
- spacing400: theme.space[4],
147
+ spacing400: `${theme.space[4]}px`,
144
148
  // 32px
145
- spacing500: theme.space[5],
149
+ spacing500: `${theme.space[5]}px`,
146
150
  // 40px
147
- spacing600: theme.space[6],
151
+ spacing600: `${theme.space[6]}px`,
148
152
  // 48px
149
- spacing700: theme.space[7],
153
+ spacing700: `${theme.space[7]}px`,
150
154
  // 56px
151
- spacing800: theme.space[8],
155
+ spacing800: `${theme.space[8]}px`,
152
156
  // 64px
153
- spacing900: theme.space[9],
157
+ spacing900: `${theme.space[9]}px`,
154
158
  // 72px
155
159
  borderWidth100: "1px",
156
160
  borderWidth200: "2px",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "94.6.0",
3
+ "version": "94.7.1",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "engineStrict": true,
6
6
  "engines": {
@@ -133,7 +133,7 @@
133
133
  },
134
134
  "dependencies": {
135
135
  "@popperjs/core": "^2.9.0",
136
- "@sage/design-tokens": "^1.65.0",
136
+ "@sage/design-tokens": "^1.73.0",
137
137
  "@styled-system/prop-types": "^5.1.5",
138
138
  "@tippyjs/react": "^4.2.5",
139
139
  "classnames": "~2.2.6",