carbon-react 142.4.1 → 142.5.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.
@@ -102,6 +102,8 @@ export interface TextareaProps extends ValidationProps, MarginProps, Omit<Common
102
102
  borderRadius?: BorderRadiusType | BorderRadiusType[];
103
103
  /** Hides the borders for the component. Please note that validation and focus styling will still be applied */
104
104
  hideBorders?: boolean;
105
+ /** Specify the minimum height */
106
+ minHeight?: number;
105
107
  }
106
108
  export declare const Textarea: React.ForwardRefExoticComponent<TextareaProps & React.RefAttributes<HTMLTextAreaElement>>;
107
109
  export { Textarea as OriginalTextarea };
@@ -8,7 +8,7 @@ import Input from "../../__internal__/input/input.component";
8
8
  import { InputBehaviour } from "../../__internal__/input-behaviour";
9
9
  import InputIconToggle from "../../__internal__/input-icon-toggle";
10
10
  import guid from "../../__internal__/utils/helpers/guid";
11
- import StyledTextarea, { MIN_HEIGHT } from "./textarea.style";
11
+ import StyledTextarea, { DEFAULT_MIN_HEIGHT } from "./textarea.style";
12
12
  import { TooltipProvider } from "../../__internal__/tooltip-provider";
13
13
  import useInputAccessibility from "../../hooks/__internal__/useInputAccessibility";
14
14
  import NewValidationContext from "../carbon-provider/__internal__/new-validation.context";
@@ -60,11 +60,13 @@ const Textarea = /*#__PURE__*/React.forwardRef(({
60
60
  hideBorders = false,
61
61
  required,
62
62
  isOptional,
63
+ minHeight = DEFAULT_MIN_HEIGHT,
63
64
  ...rest
64
65
  }, ref) => {
65
66
  const {
66
67
  validationRedesignOptIn
67
68
  } = useContext(NewValidationContext);
69
+ const [textareaMinHeight, setTextareaMinHeight] = useState(DEFAULT_MIN_HEIGHT);
68
70
  const computeLabelPropValues = prop => validationRedesignOptIn ? undefined : prop;
69
71
  const {
70
72
  current: id
@@ -105,10 +107,9 @@ const Textarea = /*#__PURE__*/React.forwardRef(({
105
107
  console.warn("The `borderRadius` prop in `Textarea` component only supports up to 4 values.");
106
108
  warnBorderRadiusArrayTooLarge = true;
107
109
  }
108
- const minHeight = useRef(MIN_HEIGHT);
109
- const expandTextarea = () => {
110
+ const expandTextarea = useCallback(() => {
110
111
  const textarea = internalRef.current;
111
- if (textarea?.scrollHeight && textarea?.scrollHeight > minHeight.current) {
112
+ if (textarea?.scrollHeight && textarea?.scrollHeight > textareaMinHeight) {
112
113
  // need to reset scroll position of the nearest parent which scrolls
113
114
  let scrollElement = textarea;
114
115
  while (scrollElement && !scrollElement?.scrollTop) {
@@ -117,12 +118,12 @@ const Textarea = /*#__PURE__*/React.forwardRef(({
117
118
  const scrollPosition = scrollElement?.scrollTop;
118
119
  textarea.style.height = "0px";
119
120
  // Set the height so all content is shown
120
- textarea.style.height = `${Math.max(textarea.scrollHeight, minHeight.current)}px`;
121
+ textarea.style.height = `${Math.max(textarea.scrollHeight, textareaMinHeight)}px`;
121
122
  if (scrollElement && scrollPosition) {
122
123
  scrollElement.scrollTop = scrollPosition;
123
124
  }
124
125
  }
125
- };
126
+ }, [textareaMinHeight]);
126
127
  const {
127
128
  labelId,
128
129
  validationId,
@@ -140,9 +141,11 @@ const Textarea = /*#__PURE__*/React.forwardRef(({
140
141
  const [characterCount, visuallyHiddenHintId] = useCharacterCount(value, characterLimit, characterCountAriaLive);
141
142
  useEffect(() => {
142
143
  if (rows) {
143
- minHeight.current = internalRef?.current?.scrollHeight || 0;
144
+ setTextareaMinHeight(internalRef?.current?.scrollHeight || 0);
145
+ } else {
146
+ setTextareaMinHeight(minHeight > DEFAULT_MIN_HEIGHT ? minHeight : DEFAULT_MIN_HEIGHT);
144
147
  }
145
- }, [rows]);
148
+ }, [minHeight, rows]);
146
149
  useEffect(() => {
147
150
  if (expandable) {
148
151
  expandTextarea();
@@ -151,7 +154,7 @@ const Textarea = /*#__PURE__*/React.forwardRef(({
151
154
  useEffect(() => {
152
155
  if (expandable) {
153
156
  window.addEventListener("resize", expandTextarea);
154
- minHeight.current = internalRef?.current?.clientHeight || 0;
157
+ setTextareaMinHeight(internalRef?.current?.clientHeight || 0);
155
158
  // need to also run expandTextarea when the Sage UI font completes loading, to prevent strange scroll
156
159
  // behaviour when it only loads after the component is rendered
157
160
  document.fonts?.addEventListener("loadingdone", expandTextarea);
@@ -162,7 +165,7 @@ const Textarea = /*#__PURE__*/React.forwardRef(({
162
165
  document.fonts?.removeEventListener("loadingdone", expandTextarea);
163
166
  }
164
167
  };
165
- }, [expandable]);
168
+ }, [expandTextarea, expandable]);
166
169
  const hasIconInside = !!(inputIcon || validationId && !validationOnLabel);
167
170
  const hintId = useRef(guid());
168
171
  const inputHintId = inputHint ? hintId.current : undefined;
@@ -216,7 +219,8 @@ const Textarea = /*#__PURE__*/React.forwardRef(({
216
219
  "data-component": dataComponent,
217
220
  "data-role": dataRole,
218
221
  "data-element": dataElement,
219
- hasIcon: hasIconInside
222
+ hasIcon: hasIconInside,
223
+ minHeight: textareaMinHeight
220
224
  }, marginProps), /*#__PURE__*/React.createElement(FormField, {
221
225
  fieldHelp: computeLabelPropValues(fieldHelp),
222
226
  fieldHelpId: fieldHelpId,
@@ -475,6 +479,7 @@ if (process.env.NODE_ENV !== "production") {
475
479
  "valueOf": PropTypes.func.isRequired
476
480
  }), PropTypes.string]),
477
481
  "min": PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
482
+ "minHeight": PropTypes.number,
478
483
  "minLength": PropTypes.number,
479
484
  "ml": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
480
485
  "__@toStringTag": PropTypes.string.isRequired,
@@ -1,5 +1,6 @@
1
- export declare const MIN_HEIGHT = 64;
2
- export interface StyledTextAreaProps {
1
+ import { TextareaProps } from "./textarea.component";
2
+ export declare const DEFAULT_MIN_HEIGHT = 64;
3
+ export interface StyledTextAreaProps extends Pick<TextareaProps, "minHeight"> {
3
4
  /** When true, label is placed in line an input */
4
5
  labelInline?: boolean;
5
6
  /** When true, adjusts padding for icon */
@@ -4,14 +4,16 @@ import StyledInput from "../../__internal__/input/input.style";
4
4
  import { StyledLabelContainer } from "../../__internal__/label/label.style";
5
5
  import InputIconToggleStyle from "../../__internal__/input-icon-toggle/input-icon-toggle.style";
6
6
  import BaseTheme from "../../style/themes/base";
7
- export const MIN_HEIGHT = 64;
7
+ export const DEFAULT_MIN_HEIGHT = 64;
8
8
  const StyledTextarea = styled.div`
9
9
  ${margin};
10
10
 
11
11
  ${StyledInput} {
12
12
  box-sizing: border-box;
13
13
  resize: none;
14
- min-height: ${MIN_HEIGHT}px;
14
+ ${({
15
+ minHeight
16
+ }) => `min-height: ${minHeight || DEFAULT_MIN_HEIGHT}px;`}
15
17
  padding: var(--spacing150) var(--spacing200);
16
18
 
17
19
  ${({
@@ -2,7 +2,9 @@ import React from "react";
2
2
  import * as DesignTokens from "@sage/design-tokens/js/base/common";
3
3
  import { SpaceProps, WidthProps } from "styled-system";
4
4
  import { TagProps } from "../../__internal__/utils/helpers/tags";
5
+ import { TILE_HIGHLIGHT_VARIANTS } from "./tile.config";
5
6
  declare type DesignTokensType = keyof typeof DesignTokens;
7
+ declare type HighlightVariantType = typeof TILE_HIGHLIGHT_VARIANTS[number];
6
8
  export interface TileProps extends SpaceProps, WidthProps, TagProps {
7
9
  /** Sets the theme of the tile */
8
10
  variant?: "tile" | "transparent" | "active" | "grey";
@@ -31,6 +33,8 @@ export interface TileProps extends SpaceProps, WidthProps, TagProps {
31
33
  * Set a percentage-based height for the whole Tile component, relative to its parent.
32
34
  */
33
35
  height?: string | number;
36
+ /** Sets the highlight variant */
37
+ highlightVariant?: HighlightVariantType;
34
38
  }
35
- export declare const Tile: ({ variant, p, children, orientation, width, roundness, height, borderWidth, borderVariant, ...rest }: TileProps) => React.JSX.Element;
39
+ export declare const Tile: ({ variant, p, children, orientation, width, roundness, height, borderWidth, borderVariant, highlightVariant, ...rest }: TileProps) => React.JSX.Element;
36
40
  export default Tile;
@@ -1,7 +1,7 @@
1
1
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
2
  import React from "react";
3
3
  import PropTypes from "prop-types";
4
- import StyledTile from "./tile.style";
4
+ import StyledTile, { StyledHighlight } from "./tile.style";
5
5
  import TileContext from "./__internal__/tile.context";
6
6
  import filterStyledSystemPaddingProps from "../../style/utils/filter-styled-system-padding-props";
7
7
  import filterStyledSystemMarginProps from "../../style/utils/filter-styled-system-margin-props";
@@ -17,6 +17,7 @@ export const Tile = ({
17
17
  height,
18
18
  borderWidth,
19
19
  borderVariant,
20
+ highlightVariant,
20
21
  ...rest
21
22
  }) => {
22
23
  const isHorizontal = orientation === "horizontal";
@@ -26,7 +27,7 @@ export const Tile = ({
26
27
  });
27
28
  const marginProps = filterStyledSystemMarginProps(rest);
28
29
  const contentPaddingProps = computeContentPadding(paddingProps, isHorizontal);
29
- return /*#__PURE__*/React.createElement(StyledTile, _extends({
30
+ const tile = /*#__PURE__*/React.createElement(StyledTile, _extends({
30
31
  variant: variant,
31
32
  width: width,
32
33
  height: height,
@@ -41,5 +42,14 @@ export const Tile = ({
41
42
  paddingPropsFromTile: contentPaddingProps
42
43
  }
43
44
  }, children));
45
+ if (highlightVariant) {
46
+ return /*#__PURE__*/React.createElement(StyledHighlight, {
47
+ variant: highlightVariant,
48
+ roundness: roundness,
49
+ "aria-hidden": true,
50
+ "data-role": `tile-${highlightVariant}-highlight`
51
+ }, tile);
52
+ }
53
+ return tile;
44
54
  };
45
55
  export default Tile;
@@ -1,3 +1,4 @@
1
1
  export declare const TILE_ORIENTATIONS: string[];
2
2
  export declare const TILE_THEMES: string[];
3
3
  export declare const TILE_BORDER_VARIANTS: string[];
4
+ export declare const TILE_HIGHLIGHT_VARIANTS: string[];
@@ -1,3 +1,4 @@
1
1
  export const TILE_ORIENTATIONS = ["horizontal", "vertical"];
2
2
  export const TILE_THEMES = ["tile", "transparent", "active", "grey"];
3
- export const TILE_BORDER_VARIANTS = ["default", "info", "selected", "negative", "positive", "caution"];
3
+ export const TILE_BORDER_VARIANTS = ["default", "info", "selected", "negative", "positive", "caution"];
4
+ export const TILE_HIGHLIGHT_VARIANTS = ["gradient", "success", "neutral", "error", "warning", "info"];
@@ -1,6 +1,10 @@
1
1
  import { SpaceProps } from "styled-system";
2
2
  import { TileProps } from "./tile.component";
3
- declare const StyledTile: import("styled-components").StyledComponent<"div", any, Pick<TileProps, "width" | "height" | "variant" | "roundness" | "borderWidth" | "borderVariant"> & {
3
+ declare const StyledTile: import("styled-components").StyledComponent<"div", any, Pick<TileProps, "width" | "height" | "variant" | "roundness" | "borderWidth" | "borderVariant" | "highlightVariant"> & {
4
4
  isHorizontal?: boolean | undefined;
5
5
  } & SpaceProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol>, never>;
6
+ export declare const StyledHighlight: import("styled-components").StyledComponent<"div", any, {
7
+ variant: Required<TileProps["highlightVariant"]>;
8
+ roundness: TileProps["roundness"];
9
+ }, never>;
6
10
  export default StyledTile;
@@ -2,6 +2,7 @@ import styled, { css } from "styled-components";
2
2
  import { space } from "styled-system";
3
3
  import baseTheme from "../../style/themes/base";
4
4
  import computeSizing from "../../style/utils/element-sizing";
5
+ import StyledTileContent from "./tile-content/tile-content.style";
5
6
  const getBorderColor = (borderVariant, variant) => {
6
7
  switch (borderVariant) {
7
8
  case "selected":
@@ -35,6 +36,23 @@ const getBorderRadius = roundness => {
35
36
  return "var(--borderRadius100)";
36
37
  }
37
38
  };
39
+ const getHeighlightVariant = variant => {
40
+ switch (variant) {
41
+ case "success":
42
+ return "var(--colorsSemanticPositive500)";
43
+ case "neutral":
44
+ return "var(--colorsSemanticNeutral500)";
45
+ case "error":
46
+ return "var(--colorsSemanticNegative500)";
47
+ case "warning":
48
+ return "var(--colorsSemanticCaution500)";
49
+ case "info":
50
+ return "var(--colorsSemanticInfo500)";
51
+ default:
52
+ // gradient is default
53
+ return "linear-gradient(0deg, rgb(143, 73, 254) 5%, rgb(0, 146, 219) 50%, rgb(19, 160, 56) 95%)";
54
+ }
55
+ };
38
56
  const StyledTile = styled.div`
39
57
  ${({
40
58
  borderVariant,
@@ -53,12 +71,12 @@ const StyledTile = styled.div`
53
71
  border-radius: ${getBorderRadius(roundness)};
54
72
  --tileBorderRadius: ${getBorderRadius(roundness)};
55
73
 
56
- > *:first-child {
74
+ > *:first-child:not(${StyledTileContent}) {
57
75
  border-top-left-radius: calc(${getBorderRadius(roundness)} - 1px);
58
76
  border-top-right-radius: calc(${getBorderRadius(roundness)} - 1px);
59
77
  }
60
78
 
61
- > *:last-child {
79
+ > *:last-child:not(${StyledTileContent}) {
62
80
  border-bottom-left-radius: calc(${getBorderRadius(roundness)} - 1px);
63
81
  border-bottom-right-radius: calc(${getBorderRadius(roundness)} - 1px);
64
82
  }
@@ -91,4 +109,21 @@ const StyledTile = styled.div`
91
109
  StyledTile.defaultProps = {
92
110
  theme: baseTheme
93
111
  };
112
+ export const StyledHighlight = styled.div`
113
+ height: 100%;
114
+ width: 100%;
115
+ position: relative;
116
+ background: ${({
117
+ variant
118
+ }) => getHeighlightVariant(variant)};
119
+ border-radius: ${({
120
+ roundness
121
+ }) => getBorderRadius(roundness)};
122
+
123
+ ${StyledTile} {
124
+ border-left: 0;
125
+ left: 4px;
126
+ width: calc(100% - 4px);
127
+ }
128
+ `;
94
129
  export default StyledTile;
@@ -102,6 +102,8 @@ export interface TextareaProps extends ValidationProps, MarginProps, Omit<Common
102
102
  borderRadius?: BorderRadiusType | BorderRadiusType[];
103
103
  /** Hides the borders for the component. Please note that validation and focus styling will still be applied */
104
104
  hideBorders?: boolean;
105
+ /** Specify the minimum height */
106
+ minHeight?: number;
105
107
  }
106
108
  export declare const Textarea: React.ForwardRefExoticComponent<TextareaProps & React.RefAttributes<HTMLTextAreaElement>>;
107
109
  export { Textarea as OriginalTextarea };
@@ -69,11 +69,13 @@ const Textarea = exports.OriginalTextarea = exports.Textarea = /*#__PURE__*/_rea
69
69
  hideBorders = false,
70
70
  required,
71
71
  isOptional,
72
+ minHeight = _textarea.DEFAULT_MIN_HEIGHT,
72
73
  ...rest
73
74
  }, ref) => {
74
75
  const {
75
76
  validationRedesignOptIn
76
77
  } = (0, _react.useContext)(_newValidation.default);
78
+ const [textareaMinHeight, setTextareaMinHeight] = (0, _react.useState)(_textarea.DEFAULT_MIN_HEIGHT);
77
79
  const computeLabelPropValues = prop => validationRedesignOptIn ? undefined : prop;
78
80
  const {
79
81
  current: id
@@ -114,10 +116,9 @@ const Textarea = exports.OriginalTextarea = exports.Textarea = /*#__PURE__*/_rea
114
116
  console.warn("The `borderRadius` prop in `Textarea` component only supports up to 4 values.");
115
117
  warnBorderRadiusArrayTooLarge = true;
116
118
  }
117
- const minHeight = (0, _react.useRef)(_textarea.MIN_HEIGHT);
118
- const expandTextarea = () => {
119
+ const expandTextarea = (0, _react.useCallback)(() => {
119
120
  const textarea = internalRef.current;
120
- if (textarea?.scrollHeight && textarea?.scrollHeight > minHeight.current) {
121
+ if (textarea?.scrollHeight && textarea?.scrollHeight > textareaMinHeight) {
121
122
  // need to reset scroll position of the nearest parent which scrolls
122
123
  let scrollElement = textarea;
123
124
  while (scrollElement && !scrollElement?.scrollTop) {
@@ -126,12 +127,12 @@ const Textarea = exports.OriginalTextarea = exports.Textarea = /*#__PURE__*/_rea
126
127
  const scrollPosition = scrollElement?.scrollTop;
127
128
  textarea.style.height = "0px";
128
129
  // Set the height so all content is shown
129
- textarea.style.height = `${Math.max(textarea.scrollHeight, minHeight.current)}px`;
130
+ textarea.style.height = `${Math.max(textarea.scrollHeight, textareaMinHeight)}px`;
130
131
  if (scrollElement && scrollPosition) {
131
132
  scrollElement.scrollTop = scrollPosition;
132
133
  }
133
134
  }
134
- };
135
+ }, [textareaMinHeight]);
135
136
  const {
136
137
  labelId,
137
138
  validationId,
@@ -149,9 +150,11 @@ const Textarea = exports.OriginalTextarea = exports.Textarea = /*#__PURE__*/_rea
149
150
  const [characterCount, visuallyHiddenHintId] = (0, _useCharacterCount.default)(value, characterLimit, characterCountAriaLive);
150
151
  (0, _react.useEffect)(() => {
151
152
  if (rows) {
152
- minHeight.current = internalRef?.current?.scrollHeight || 0;
153
+ setTextareaMinHeight(internalRef?.current?.scrollHeight || 0);
154
+ } else {
155
+ setTextareaMinHeight(minHeight > _textarea.DEFAULT_MIN_HEIGHT ? minHeight : _textarea.DEFAULT_MIN_HEIGHT);
153
156
  }
154
- }, [rows]);
157
+ }, [minHeight, rows]);
155
158
  (0, _react.useEffect)(() => {
156
159
  if (expandable) {
157
160
  expandTextarea();
@@ -160,7 +163,7 @@ const Textarea = exports.OriginalTextarea = exports.Textarea = /*#__PURE__*/_rea
160
163
  (0, _react.useEffect)(() => {
161
164
  if (expandable) {
162
165
  window.addEventListener("resize", expandTextarea);
163
- minHeight.current = internalRef?.current?.clientHeight || 0;
166
+ setTextareaMinHeight(internalRef?.current?.clientHeight || 0);
164
167
  // need to also run expandTextarea when the Sage UI font completes loading, to prevent strange scroll
165
168
  // behaviour when it only loads after the component is rendered
166
169
  document.fonts?.addEventListener("loadingdone", expandTextarea);
@@ -171,7 +174,7 @@ const Textarea = exports.OriginalTextarea = exports.Textarea = /*#__PURE__*/_rea
171
174
  document.fonts?.removeEventListener("loadingdone", expandTextarea);
172
175
  }
173
176
  };
174
- }, [expandable]);
177
+ }, [expandTextarea, expandable]);
175
178
  const hasIconInside = !!(inputIcon || validationId && !validationOnLabel);
176
179
  const hintId = (0, _react.useRef)((0, _guid.default)());
177
180
  const inputHintId = inputHint ? hintId.current : undefined;
@@ -225,7 +228,8 @@ const Textarea = exports.OriginalTextarea = exports.Textarea = /*#__PURE__*/_rea
225
228
  "data-component": dataComponent,
226
229
  "data-role": dataRole,
227
230
  "data-element": dataElement,
228
- hasIcon: hasIconInside
231
+ hasIcon: hasIconInside,
232
+ minHeight: textareaMinHeight
229
233
  }, marginProps), /*#__PURE__*/_react.default.createElement(_formField.default, {
230
234
  fieldHelp: computeLabelPropValues(fieldHelp),
231
235
  fieldHelpId: fieldHelpId,
@@ -484,6 +488,7 @@ if (process.env.NODE_ENV !== "production") {
484
488
  "valueOf": _propTypes.default.func.isRequired
485
489
  }), _propTypes.default.string]),
486
490
  "min": _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
491
+ "minHeight": _propTypes.default.number,
487
492
  "minLength": _propTypes.default.number,
488
493
  "ml": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
489
494
  "__@toStringTag": _propTypes.default.string.isRequired,
@@ -1,5 +1,6 @@
1
- export declare const MIN_HEIGHT = 64;
2
- export interface StyledTextAreaProps {
1
+ import { TextareaProps } from "./textarea.component";
2
+ export declare const DEFAULT_MIN_HEIGHT = 64;
3
+ export interface StyledTextAreaProps extends Pick<TextareaProps, "minHeight"> {
3
4
  /** When true, label is placed in line an input */
4
5
  labelInline?: boolean;
5
6
  /** When true, adjusts padding for icon */
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = exports.MIN_HEIGHT = void 0;
6
+ exports.default = exports.DEFAULT_MIN_HEIGHT = void 0;
7
7
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
8
8
  var _styledSystem = require("styled-system");
9
9
  var _input = _interopRequireDefault(require("../../__internal__/input/input.style"));
@@ -13,14 +13,16 @@ var _base = _interopRequireDefault(require("../../style/themes/base"));
13
13
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
14
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
15
15
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
16
- const MIN_HEIGHT = exports.MIN_HEIGHT = 64;
16
+ const DEFAULT_MIN_HEIGHT = exports.DEFAULT_MIN_HEIGHT = 64;
17
17
  const StyledTextarea = _styledComponents.default.div`
18
18
  ${_styledSystem.margin};
19
19
 
20
20
  ${_input.default} {
21
21
  box-sizing: border-box;
22
22
  resize: none;
23
- min-height: ${MIN_HEIGHT}px;
23
+ ${({
24
+ minHeight
25
+ }) => `min-height: ${minHeight || DEFAULT_MIN_HEIGHT}px;`}
24
26
  padding: var(--spacing150) var(--spacing200);
25
27
 
26
28
  ${({
@@ -2,7 +2,9 @@ import React from "react";
2
2
  import * as DesignTokens from "@sage/design-tokens/js/base/common";
3
3
  import { SpaceProps, WidthProps } from "styled-system";
4
4
  import { TagProps } from "../../__internal__/utils/helpers/tags";
5
+ import { TILE_HIGHLIGHT_VARIANTS } from "./tile.config";
5
6
  declare type DesignTokensType = keyof typeof DesignTokens;
7
+ declare type HighlightVariantType = typeof TILE_HIGHLIGHT_VARIANTS[number];
6
8
  export interface TileProps extends SpaceProps, WidthProps, TagProps {
7
9
  /** Sets the theme of the tile */
8
10
  variant?: "tile" | "transparent" | "active" | "grey";
@@ -31,6 +33,8 @@ export interface TileProps extends SpaceProps, WidthProps, TagProps {
31
33
  * Set a percentage-based height for the whole Tile component, relative to its parent.
32
34
  */
33
35
  height?: string | number;
36
+ /** Sets the highlight variant */
37
+ highlightVariant?: HighlightVariantType;
34
38
  }
35
- export declare const Tile: ({ variant, p, children, orientation, width, roundness, height, borderWidth, borderVariant, ...rest }: TileProps) => React.JSX.Element;
39
+ export declare const Tile: ({ variant, p, children, orientation, width, roundness, height, borderWidth, borderVariant, highlightVariant, ...rest }: TileProps) => React.JSX.Element;
36
40
  export default Tile;
@@ -6,12 +6,14 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = exports.Tile = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
- var _tile = _interopRequireDefault(require("./tile.style"));
9
+ var _tile = _interopRequireWildcard(require("./tile.style"));
10
10
  var _tile2 = _interopRequireDefault(require("./__internal__/tile.context"));
11
11
  var _filterStyledSystemPaddingProps = _interopRequireDefault(require("../../style/utils/filter-styled-system-padding-props"));
12
12
  var _filterStyledSystemMarginProps = _interopRequireDefault(require("../../style/utils/filter-styled-system-margin-props"));
13
13
  var _computeContentPadding = _interopRequireDefault(require("./__internal__/compute-content-padding"));
14
14
  var _tags = _interopRequireDefault(require("../../__internal__/utils/helpers/tags"));
15
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
16
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15
17
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
18
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
17
19
  const Tile = ({
@@ -24,6 +26,7 @@ const Tile = ({
24
26
  height,
25
27
  borderWidth,
26
28
  borderVariant,
29
+ highlightVariant,
27
30
  ...rest
28
31
  }) => {
29
32
  const isHorizontal = orientation === "horizontal";
@@ -33,7 +36,7 @@ const Tile = ({
33
36
  });
34
37
  const marginProps = (0, _filterStyledSystemMarginProps.default)(rest);
35
38
  const contentPaddingProps = (0, _computeContentPadding.default)(paddingProps, isHorizontal);
36
- return /*#__PURE__*/_react.default.createElement(_tile.default, _extends({
39
+ const tile = /*#__PURE__*/_react.default.createElement(_tile.default, _extends({
37
40
  variant: variant,
38
41
  width: width,
39
42
  height: height,
@@ -48,6 +51,15 @@ const Tile = ({
48
51
  paddingPropsFromTile: contentPaddingProps
49
52
  }
50
53
  }, children));
54
+ if (highlightVariant) {
55
+ return /*#__PURE__*/_react.default.createElement(_tile.StyledHighlight, {
56
+ variant: highlightVariant,
57
+ roundness: roundness,
58
+ "aria-hidden": true,
59
+ "data-role": `tile-${highlightVariant}-highlight`
60
+ }, tile);
61
+ }
62
+ return tile;
51
63
  };
52
64
  exports.Tile = Tile;
53
65
  var _default = exports.default = Tile;
@@ -1,3 +1,4 @@
1
1
  export declare const TILE_ORIENTATIONS: string[];
2
2
  export declare const TILE_THEMES: string[];
3
3
  export declare const TILE_BORDER_VARIANTS: string[];
4
+ export declare const TILE_HIGHLIGHT_VARIANTS: string[];
@@ -3,7 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.TILE_THEMES = exports.TILE_ORIENTATIONS = exports.TILE_BORDER_VARIANTS = void 0;
6
+ exports.TILE_THEMES = exports.TILE_ORIENTATIONS = exports.TILE_HIGHLIGHT_VARIANTS = exports.TILE_BORDER_VARIANTS = void 0;
7
7
  const TILE_ORIENTATIONS = exports.TILE_ORIENTATIONS = ["horizontal", "vertical"];
8
8
  const TILE_THEMES = exports.TILE_THEMES = ["tile", "transparent", "active", "grey"];
9
- const TILE_BORDER_VARIANTS = exports.TILE_BORDER_VARIANTS = ["default", "info", "selected", "negative", "positive", "caution"];
9
+ const TILE_BORDER_VARIANTS = exports.TILE_BORDER_VARIANTS = ["default", "info", "selected", "negative", "positive", "caution"];
10
+ const TILE_HIGHLIGHT_VARIANTS = exports.TILE_HIGHLIGHT_VARIANTS = ["gradient", "success", "neutral", "error", "warning", "info"];
@@ -1,6 +1,10 @@
1
1
  import { SpaceProps } from "styled-system";
2
2
  import { TileProps } from "./tile.component";
3
- declare const StyledTile: import("styled-components").StyledComponent<"div", any, Pick<TileProps, "width" | "height" | "variant" | "roundness" | "borderWidth" | "borderVariant"> & {
3
+ declare const StyledTile: import("styled-components").StyledComponent<"div", any, Pick<TileProps, "width" | "height" | "variant" | "roundness" | "borderWidth" | "borderVariant" | "highlightVariant"> & {
4
4
  isHorizontal?: boolean | undefined;
5
5
  } & SpaceProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol>, never>;
6
+ export declare const StyledHighlight: import("styled-components").StyledComponent<"div", any, {
7
+ variant: Required<TileProps["highlightVariant"]>;
8
+ roundness: TileProps["roundness"];
9
+ }, never>;
6
10
  export default StyledTile;
@@ -3,11 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.default = exports.StyledHighlight = void 0;
7
7
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
8
8
  var _styledSystem = require("styled-system");
9
9
  var _base = _interopRequireDefault(require("../../style/themes/base"));
10
10
  var _elementSizing = _interopRequireDefault(require("../../style/utils/element-sizing"));
11
+ var _tileContent = _interopRequireDefault(require("./tile-content/tile-content.style"));
11
12
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
13
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
13
14
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -44,6 +45,23 @@ const getBorderRadius = roundness => {
44
45
  return "var(--borderRadius100)";
45
46
  }
46
47
  };
48
+ const getHeighlightVariant = variant => {
49
+ switch (variant) {
50
+ case "success":
51
+ return "var(--colorsSemanticPositive500)";
52
+ case "neutral":
53
+ return "var(--colorsSemanticNeutral500)";
54
+ case "error":
55
+ return "var(--colorsSemanticNegative500)";
56
+ case "warning":
57
+ return "var(--colorsSemanticCaution500)";
58
+ case "info":
59
+ return "var(--colorsSemanticInfo500)";
60
+ default:
61
+ // gradient is default
62
+ return "linear-gradient(0deg, rgb(143, 73, 254) 5%, rgb(0, 146, 219) 50%, rgb(19, 160, 56) 95%)";
63
+ }
64
+ };
47
65
  const StyledTile = _styledComponents.default.div`
48
66
  ${({
49
67
  borderVariant,
@@ -62,12 +80,12 @@ const StyledTile = _styledComponents.default.div`
62
80
  border-radius: ${getBorderRadius(roundness)};
63
81
  --tileBorderRadius: ${getBorderRadius(roundness)};
64
82
 
65
- > *:first-child {
83
+ > *:first-child:not(${_tileContent.default}) {
66
84
  border-top-left-radius: calc(${getBorderRadius(roundness)} - 1px);
67
85
  border-top-right-radius: calc(${getBorderRadius(roundness)} - 1px);
68
86
  }
69
87
 
70
- > *:last-child {
88
+ > *:last-child:not(${_tileContent.default}) {
71
89
  border-bottom-left-radius: calc(${getBorderRadius(roundness)} - 1px);
72
90
  border-bottom-right-radius: calc(${getBorderRadius(roundness)} - 1px);
73
91
  }
@@ -100,4 +118,21 @@ const StyledTile = _styledComponents.default.div`
100
118
  StyledTile.defaultProps = {
101
119
  theme: _base.default
102
120
  };
121
+ const StyledHighlight = exports.StyledHighlight = _styledComponents.default.div`
122
+ height: 100%;
123
+ width: 100%;
124
+ position: relative;
125
+ background: ${({
126
+ variant
127
+ }) => getHeighlightVariant(variant)};
128
+ border-radius: ${({
129
+ roundness
130
+ }) => getBorderRadius(roundness)};
131
+
132
+ ${StyledTile} {
133
+ border-left: 0;
134
+ left: 4px;
135
+ width: calc(100% - 4px);
136
+ }
137
+ `;
103
138
  var _default = exports.default = StyledTile;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "142.4.1",
3
+ "version": "142.5.1",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",