carbon-react 111.12.5 → 111.12.6

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 (27) hide show
  1. package/esm/__internal__/input/input.component.d.ts +6 -0
  2. package/esm/__internal__/input/input.component.js +3 -0
  3. package/esm/components/date/date.component.js +3 -1
  4. package/esm/components/date/date.style.js +18 -1
  5. package/esm/components/decimal/decimal.component.js +1 -0
  6. package/esm/components/grouped-character/grouped-character.component.js +1 -0
  7. package/esm/components/textarea/index.d.ts +2 -1
  8. package/esm/components/textarea/textarea.component.d.ts +94 -0
  9. package/esm/components/textarea/textarea.component.js +570 -162
  10. package/esm/components/textarea/textarea.style.d.ts +8 -2
  11. package/esm/components/textbox/textbox.component.js +41 -36
  12. package/esm/components/textbox/textbox.style.js +1 -1
  13. package/lib/__internal__/input/input.component.d.ts +6 -0
  14. package/lib/__internal__/input/input.component.js +3 -0
  15. package/lib/components/date/date.component.js +3 -1
  16. package/lib/components/date/date.style.js +25 -1
  17. package/lib/components/decimal/decimal.component.js +1 -0
  18. package/lib/components/grouped-character/grouped-character.component.js +1 -0
  19. package/lib/components/textarea/index.d.ts +2 -1
  20. package/lib/components/textarea/textarea.component.d.ts +94 -0
  21. package/lib/components/textarea/textarea.component.js +574 -166
  22. package/lib/components/textarea/textarea.style.d.ts +8 -2
  23. package/lib/components/textbox/textbox.component.js +44 -36
  24. package/lib/components/textbox/textbox.style.js +1 -1
  25. package/package.json +1 -1
  26. package/esm/components/textarea/textarea.d.ts +0 -81
  27. package/lib/components/textarea/textarea.d.ts +0 -81
@@ -1,3 +1,9 @@
1
- export const MIN_HEIGHT: 64;
1
+ export declare const MIN_HEIGHT = 64;
2
+ export interface StyledTextAreaProps {
3
+ /** When true, label is placed in line an input */
4
+ labelInline?: boolean;
5
+ /** When true, adjusts padding for icon */
6
+ hasIcon?: boolean;
7
+ }
8
+ declare const StyledTextarea: import("styled-components").StyledComponent<"div", any, StyledTextAreaProps, never>;
2
9
  export default StyledTextarea;
3
- declare const StyledTextarea: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -16,6 +16,7 @@ import { ErrorBorder, StyledHintText } from "./textbox.style";
16
16
  import ValidationMessage from "../../__internal__/validation-message";
17
17
  import { NewValidationContext } from "../carbon-provider/carbon-provider.component";
18
18
  import NumeralDateContext from "../numeral-date/numeral-date-context";
19
+ import Box from "../box";
19
20
 
20
21
  const Textbox = ({
21
22
  align = "left",
@@ -99,38 +100,7 @@ const Textbox = ({
99
100
  });
100
101
  const labelId = label ? externalLabelId || internalLabelId : "";
101
102
  const hasIconInside = !!(inputIcon || validationIconId && !validationOnLabel);
102
- return /*#__PURE__*/React.createElement(TooltipProvider, {
103
- helpAriaLabel: helpAriaLabel,
104
- tooltipPosition: tooltipPosition
105
- }, /*#__PURE__*/React.createElement(InputBehaviour, null, /*#__PURE__*/React.createElement(FormField, _extends({
106
- disabled: disabled,
107
- fieldHelpId: fieldHelpId,
108
- fieldHelp: computeLabelPropValues(fieldHelp),
109
- error: error,
110
- warning: warning,
111
- info: info,
112
- label: label,
113
- labelId: labelId,
114
- labelAlign: computeLabelPropValues(labelAlign),
115
- labelHelp: computeLabelPropValues(labelHelp),
116
- labelInline: computeLabelPropValues(labelInline),
117
- labelSpacing: labelSpacing,
118
- labelWidth: computeLabelPropValues(labelWidth),
119
- id: uniqueId,
120
- reverse: computeLabelPropValues(reverse),
121
- isOptional: isOptional,
122
- useValidationIcon: computeLabelPropValues(validationOnLabel),
123
- adaptiveLabelBreakpoint: adaptiveLabelBreakpoint,
124
- isRequired: required,
125
- "data-component": dataComponent,
126
- "data-role": dataRole,
127
- "data-element": dataElement,
128
- validationIconId: validationRedesignOptIn ? undefined : validationIconId,
129
- validationRedesignOptIn: validationRedesignOptIn
130
- }, filterStyledSystemMarginProps(props)), validationRedesignOptIn && labelHelp && /*#__PURE__*/React.createElement(StyledHintText, null, labelHelp), validationRedesignOptIn && /*#__PURE__*/React.createElement(ValidationMessage, {
131
- error: error,
132
- warning: warning
133
- }), /*#__PURE__*/React.createElement(InputPresentation, {
103
+ const input = /*#__PURE__*/React.createElement(InputPresentation, {
134
104
  align: align,
135
105
  disabled: disabled,
136
106
  readOnly: readOnly,
@@ -143,9 +113,7 @@ const Textbox = ({
143
113
  hasIcon: hasIconInside
144
114
  }, leftChildren, prefix && /*#__PURE__*/React.createElement(StyledPrefix, {
145
115
  "data-element": "textbox-prefix"
146
- }, prefix), validationRedesignOptIn && !disableErrorBorder && (error || warning) && /*#__PURE__*/React.createElement(ErrorBorder, {
147
- warning: !!(!error && warning)
148
- }), /*#__PURE__*/React.createElement(Input, _extends({}, required && {
116
+ }, prefix), /*#__PURE__*/React.createElement(Input, _extends({}, required && {
149
117
  required
150
118
  }, {
151
119
  align: align,
@@ -182,7 +150,43 @@ const Textbox = ({
182
150
  useValidationIcon: !(validationRedesignOptIn || validationOnLabel),
183
151
  warning: warning,
184
152
  validationIconId: validationRedesignOptIn ? undefined : validationIconId
185
- }))), characterCount));
153
+ }));
154
+ return /*#__PURE__*/React.createElement(TooltipProvider, {
155
+ helpAriaLabel: helpAriaLabel,
156
+ tooltipPosition: tooltipPosition
157
+ }, /*#__PURE__*/React.createElement(InputBehaviour, null, /*#__PURE__*/React.createElement(FormField, _extends({
158
+ disabled: disabled,
159
+ fieldHelpId: fieldHelpId,
160
+ fieldHelp: computeLabelPropValues(fieldHelp),
161
+ error: error,
162
+ warning: warning,
163
+ info: info,
164
+ label: label,
165
+ labelId: labelId,
166
+ labelAlign: computeLabelPropValues(labelAlign),
167
+ labelHelp: computeLabelPropValues(labelHelp),
168
+ labelInline: computeLabelPropValues(labelInline),
169
+ labelSpacing: labelSpacing,
170
+ labelWidth: computeLabelPropValues(labelWidth),
171
+ id: uniqueId,
172
+ reverse: computeLabelPropValues(reverse),
173
+ isOptional: isOptional,
174
+ useValidationIcon: computeLabelPropValues(validationOnLabel),
175
+ adaptiveLabelBreakpoint: adaptiveLabelBreakpoint,
176
+ isRequired: required,
177
+ "data-component": dataComponent,
178
+ "data-role": dataRole,
179
+ "data-element": dataElement,
180
+ validationIconId: validationRedesignOptIn ? undefined : validationIconId,
181
+ validationRedesignOptIn: validationRedesignOptIn
182
+ }, filterStyledSystemMarginProps(props)), validationRedesignOptIn && labelHelp && /*#__PURE__*/React.createElement(StyledHintText, null, labelHelp), validationRedesignOptIn ? /*#__PURE__*/React.createElement(Box, {
183
+ position: "relative"
184
+ }, /*#__PURE__*/React.createElement(ValidationMessage, {
185
+ error: error,
186
+ warning: warning
187
+ }), !disableErrorBorder && (error || warning) && /*#__PURE__*/React.createElement(ErrorBorder, {
188
+ warning: !!(!error && warning)
189
+ }), input) : input), characterCount));
186
190
  };
187
191
 
188
192
  Textbox.propTypes = {
@@ -240,6 +244,7 @@ Textbox.propTypes = {
240
244
  "aria-valuemin": PropTypes.number,
241
245
  "aria-valuenow": PropTypes.number,
242
246
  "aria-valuetext": PropTypes.string,
247
+ "as": PropTypes.elementType,
243
248
  "autoCapitalize": PropTypes.string,
244
249
  "autoComplete": PropTypes.string,
245
250
  "autoCorrect": PropTypes.string,
@@ -6,10 +6,10 @@ const ErrorBorder = styled.span`
6
6
  position: absolute;
7
7
  z-index: 6;
8
8
  width: 2px;
9
- height: calc(100% + var(--spacing300));
10
9
  background-color: ${warning ? "var(--colorsSemanticCaution500)" : "var(--colorsSemanticNegative500)"};
11
10
  left: -12px;
12
11
  bottom: 0px;
12
+ top: 0px;
13
13
  `}
14
14
  `;
15
15
  const StyledHintText = styled.p`
@@ -1,6 +1,8 @@
1
1
  import React from "react";
2
2
  export interface CommonInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "type"> {
3
3
  align?: "right" | "left";
4
+ /** Override the variant component */
5
+ as?: React.ElementType;
4
6
  /** If true the Component will be focused when rendered */
5
7
  autoFocus?: boolean;
6
8
  /** If true, the component will be disabled */
@@ -29,10 +31,14 @@ export interface CommonInputProps extends Omit<React.InputHTMLAttributes<HTMLInp
29
31
  required?: boolean;
30
32
  }
31
33
  export interface InputProps extends CommonInputProps {
34
+ /** The visible width of the text control, in average character widths */
35
+ cols?: number;
32
36
  /** Integer to determine a timeout for the defered callback */
33
37
  deferTimeout?: number;
34
38
  /** Defered callback to be called after the onChange event */
35
39
  onChangeDeferred?: (ev: React.ChangeEvent<HTMLInputElement>) => void;
40
+ /** The number of visible text lines for the control */
41
+ rows?: number;
36
42
  /** HTML type attribute of the input */
37
43
  type?: string;
38
44
  }
@@ -225,6 +225,7 @@ Input.propTypes = {
225
225
  "aria-valuemin": _propTypes.default.number,
226
226
  "aria-valuenow": _propTypes.default.number,
227
227
  "aria-valuetext": _propTypes.default.string,
228
+ "as": _propTypes.default.elementType,
228
229
  "autoCapitalize": _propTypes.default.string,
229
230
  "autoComplete": _propTypes.default.string,
230
231
  "autoCorrect": _propTypes.default.string,
@@ -235,6 +236,7 @@ Input.propTypes = {
235
236
  "children": _propTypes.default.node,
236
237
  "className": _propTypes.default.string,
237
238
  "color": _propTypes.default.string,
239
+ "cols": _propTypes.default.number,
238
240
  "contentEditable": _propTypes.default.oneOfType([_propTypes.default.oneOf(["false", "inherit", "true"]), _propTypes.default.bool]),
239
241
  "contextMenu": _propTypes.default.string,
240
242
  "crossOrigin": _propTypes.default.string,
@@ -499,6 +501,7 @@ Input.propTypes = {
499
501
  "trimStart": _propTypes.default.func.isRequired,
500
502
  "valueOf": _propTypes.default.func.isRequired
501
503
  })]),
504
+ "rows": _propTypes.default.number,
502
505
  "security": _propTypes.default.string,
503
506
  "size": _propTypes.default.number,
504
507
  "slot": _propTypes.default.string,
@@ -315,7 +315,9 @@ const DateInput = ({
315
315
  "data-component": dataComponent || "date",
316
316
  "data-element": dataElement,
317
317
  "data-role": dataRole
318
- }, (0, _utils2.filterStyledSystemMarginProps)(rest)), /*#__PURE__*/_react.default.createElement(_textbox.default, _extends({}, (0, _utils2.filterOutStyledSystemSpacingProps)(rest), {
318
+ }, (0, _utils2.filterStyledSystemMarginProps)(rest), {
319
+ applyDateRangeStyling: !!inputRefMap
320
+ }), /*#__PURE__*/_react.default.createElement(_textbox.default, _extends({}, (0, _utils2.filterOutStyledSystemSpacingProps)(rest), {
319
321
  value: computedValue(),
320
322
  onBlur: handleBlur,
321
323
  onChange: handleChange,
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _styledComponents = _interopRequireDefault(require("styled-components"));
8
+ var _styledComponents = _interopRequireWildcard(require("styled-components"));
9
9
 
10
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
@@ -17,8 +17,18 @@ var _input = _interopRequireDefault(require("../../__internal__/input/input.styl
17
17
 
18
18
  var _inputPresentation = _interopRequireDefault(require("../../__internal__/input/input-presentation.style"));
19
19
 
20
+ var _formField = require("../../__internal__/form-field/form-field.style");
21
+
22
+ var _validationMessage = _interopRequireDefault(require("../../__internal__/validation-message/validation-message.style"));
23
+
24
+ var _label = _interopRequireDefault(require("../../__internal__/label/label.style"));
25
+
20
26
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
27
 
28
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
29
+
30
+ 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; }
31
+
22
32
  const datePickerWidth = {
23
33
  large: "140px",
24
34
  medium: "135px",
@@ -37,6 +47,20 @@ const StyledDateInput = _styledComponents.default.div`
37
47
  margin-right: -8px;
38
48
  }
39
49
  }
50
+
51
+ ${({
52
+ applyDateRangeStyling,
53
+ size,
54
+ labelInline
55
+ }) => applyDateRangeStyling && !labelInline && (0, _styledComponents.css)`
56
+ ${_formField.FieldLineStyle} {
57
+ max-width: ${datePickerWidth[size]};
58
+ }
59
+
60
+ ${_validationMessage.default}, ${_label.default} {
61
+ overflow-wrap: anywhere;
62
+ }
63
+ `}
40
64
  `;
41
65
  StyledDateInput.propTypes = {
42
66
  size: _propTypes.default.oneOf(["small", "medium", "large"])
@@ -278,6 +278,7 @@ Decimal.propTypes = {
278
278
  "aria-valuemin": _propTypes.default.number,
279
279
  "aria-valuenow": _propTypes.default.number,
280
280
  "aria-valuetext": _propTypes.default.string,
281
+ "as": _propTypes.default.elementType,
281
282
  "autoCapitalize": _propTypes.default.string,
282
283
  "autoComplete": _propTypes.default.string,
283
284
  "autoCorrect": _propTypes.default.string,
@@ -191,6 +191,7 @@ GroupedCharacter.propTypes = {
191
191
  "aria-valuemin": _propTypes.default.number,
192
192
  "aria-valuenow": _propTypes.default.number,
193
193
  "aria-valuetext": _propTypes.default.string,
194
+ "as": _propTypes.default.elementType,
194
195
  "autoCapitalize": _propTypes.default.string,
195
196
  "autoComplete": _propTypes.default.string,
196
197
  "autoCorrect": _propTypes.default.string,
@@ -1 +1,2 @@
1
- export { default } from "./textarea";
1
+ export { default } from "./textarea.component";
2
+ export type { TextareaProps } from "./textarea.component";
@@ -0,0 +1,94 @@
1
+ import React from "react";
2
+ import { MarginProps } from "styled-system";
3
+ import { IconType } from "../icon";
4
+ import { ValidationProps } from "../../__internal__/validations";
5
+ import { CommonInputProps } from "../../__internal__/input";
6
+ export interface TextareaProps extends ValidationProps, MarginProps, Omit<CommonInputProps, "size"> {
7
+ /** Identifier used for testing purposes, applied to the root element of the component. */
8
+ "data-component"?: string;
9
+ /** Identifier used for testing purposes, applied to the root element of the component. */
10
+ "data-element"?: string;
11
+ /** Identifier used for testing purposes, applied to the root element of the component. */
12
+ "data-role"?: string;
13
+ /** id of the input */
14
+ id?: string;
15
+ /** Breakpoint for adaptive label (inline labels change to top aligned). Enables the adaptive behaviour when set */
16
+ adaptiveLabelBreakpoint?: number;
17
+ /** Automatically focus the input on component mount */
18
+ autoFocus?: boolean;
19
+ /** Character limit of the textarea */
20
+ characterLimit?: string | number;
21
+ /** Type of the icon that will be rendered next to the input */
22
+ children?: React.ReactNode;
23
+ /** The visible width of the text control, in average character widths */
24
+ cols?: number;
25
+ /** If true, the component will be disabled */
26
+ disabled?: boolean;
27
+ /** Stop the user typing over the characterLimit */
28
+ enforceCharacterLimit?: boolean;
29
+ /** Indicate that error has occurred
30
+ Pass string to display icon, tooltip and red border
31
+ Pass true boolean to only display red border */
32
+ error?: boolean | string;
33
+ /** Allows the Textareas Height to change based on user input */
34
+ expandable?: boolean;
35
+ /** Help content to be displayed under an input */
36
+ fieldHelp?: React.ReactNode;
37
+ /** Aria label for rendered help component */
38
+ helpAriaLabel?: string;
39
+ /** Indicate additional information
40
+ Pass string to display icon, tooltip and blue border
41
+ Pass true boolean to only display blue border */
42
+ info?: boolean | string;
43
+ /**
44
+ * <a href="https://brand.sage.com/d/NdbrveWvNheA/foundations#/icons/icons" target="_blank">List of supported icons</a>
45
+ *
46
+ * Icon to display inside of the Textarea
47
+ */
48
+ inputIcon?: IconType;
49
+ /** Width of an input in percentage. Works only when labelInline is true */
50
+ inputWidth?: number;
51
+ /** The content of the label for the input */
52
+ label?: string;
53
+ /** Inline label alignment */
54
+ labelAlign?: "left" | "right";
55
+ /** Text applied to label help tooltip */
56
+ labelHelp?: React.ReactNode;
57
+ /** When true, label is placed in line an input */
58
+ labelInline?: boolean;
59
+ /** Spacing between label and a field for inline label, given number will be multiplied by base spacing unit (8) */
60
+ labelSpacing?: 1 | 2;
61
+ /** Width of a label in percentage. Works only when labelInline is true */
62
+ labelWidth?: number;
63
+ /** Name of the input */
64
+ name?: string;
65
+ /** Callback fired when the user types in the Textarea */
66
+ onChange?: (ev: React.ChangeEvent<HTMLInputElement>) => void;
67
+ /** Placeholder text for the component */
68
+ placeholder?: string;
69
+ /** Adds readOnly property */
70
+ readOnly?: boolean;
71
+ /** Flag to configure component as mandatory */
72
+ required?: boolean;
73
+ /** The number of visible text lines for the control */
74
+ rows?: number;
75
+ /** One of type of size to apply to the textarea */
76
+ size?: "small" | "medium" | "large";
77
+ /** Message to be displayed in a Tooltip when the user hovers over the help icon */
78
+ tooltipMessage?: string;
79
+ /** Overrides the default tooltip position */
80
+ tooltipPosition?: "top" | "bottom" | "left" | "right";
81
+ /** When true, validation icon will be placed on label instead of being placed on the input */
82
+ validationOnLabel?: boolean;
83
+ /** The value of the Textbox */
84
+ value?: string;
85
+ /** Whether to display the character count message in red */
86
+ warnOverLimit?: boolean;
87
+ /** Indicate that warning has occurred
88
+ Pass string to display icon, tooltip and orange border
89
+ Pass true boolean to only display orange border */
90
+ warning?: boolean | string;
91
+ }
92
+ export declare const Textarea: ({ autoFocus, fieldHelp, label, size, children, characterLimit, enforceCharacterLimit, warnOverLimit, onChange, disabled, labelInline, labelAlign, labelHelp, labelSpacing, inputIcon, id: idProp, error, warning, info, name, readOnly, placeholder, expandable, rows, cols, validationOnLabel, adaptiveLabelBreakpoint, inputWidth, labelWidth, tooltipPosition, value, "data-component": dataComponent, "data-element": dataElement, "data-role": dataRole, helpAriaLabel, ...props }: TextareaProps) => JSX.Element;
93
+ export { Textarea as OriginalTextarea };
94
+ export default Textarea;