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.
- package/esm/__internal__/input/input.component.d.ts +6 -0
- package/esm/__internal__/input/input.component.js +3 -0
- package/esm/components/date/date.component.js +3 -1
- package/esm/components/date/date.style.js +18 -1
- package/esm/components/decimal/decimal.component.js +1 -0
- package/esm/components/grouped-character/grouped-character.component.js +1 -0
- package/esm/components/textarea/index.d.ts +2 -1
- package/esm/components/textarea/textarea.component.d.ts +94 -0
- package/esm/components/textarea/textarea.component.js +570 -162
- package/esm/components/textarea/textarea.style.d.ts +8 -2
- package/esm/components/textbox/textbox.component.js +41 -36
- package/esm/components/textbox/textbox.style.js +1 -1
- package/lib/__internal__/input/input.component.d.ts +6 -0
- package/lib/__internal__/input/input.component.js +3 -0
- package/lib/components/date/date.component.js +3 -1
- package/lib/components/date/date.style.js +25 -1
- package/lib/components/decimal/decimal.component.js +1 -0
- package/lib/components/grouped-character/grouped-character.component.js +1 -0
- package/lib/components/textarea/index.d.ts +2 -1
- package/lib/components/textarea/textarea.component.d.ts +94 -0
- package/lib/components/textarea/textarea.component.js +574 -166
- package/lib/components/textarea/textarea.style.d.ts +8 -2
- package/lib/components/textbox/textbox.component.js +44 -36
- package/lib/components/textbox/textbox.style.js +1 -1
- package/package.json +1 -1
- package/esm/components/textarea/textarea.d.ts +0 -81
- package/lib/components/textarea/textarea.d.ts +0 -81
|
@@ -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
|
}
|
|
@@ -208,6 +208,7 @@ Input.propTypes = {
|
|
|
208
208
|
"aria-valuemin": PropTypes.number,
|
|
209
209
|
"aria-valuenow": PropTypes.number,
|
|
210
210
|
"aria-valuetext": PropTypes.string,
|
|
211
|
+
"as": PropTypes.elementType,
|
|
211
212
|
"autoCapitalize": PropTypes.string,
|
|
212
213
|
"autoComplete": PropTypes.string,
|
|
213
214
|
"autoCorrect": PropTypes.string,
|
|
@@ -218,6 +219,7 @@ Input.propTypes = {
|
|
|
218
219
|
"children": PropTypes.node,
|
|
219
220
|
"className": PropTypes.string,
|
|
220
221
|
"color": PropTypes.string,
|
|
222
|
+
"cols": PropTypes.number,
|
|
221
223
|
"contentEditable": PropTypes.oneOfType([PropTypes.oneOf(["false", "inherit", "true"]), PropTypes.bool]),
|
|
222
224
|
"contextMenu": PropTypes.string,
|
|
223
225
|
"crossOrigin": PropTypes.string,
|
|
@@ -482,6 +484,7 @@ Input.propTypes = {
|
|
|
482
484
|
"trimStart": PropTypes.func.isRequired,
|
|
483
485
|
"valueOf": PropTypes.func.isRequired
|
|
484
486
|
})]),
|
|
487
|
+
"rows": PropTypes.number,
|
|
485
488
|
"security": PropTypes.string,
|
|
486
489
|
"size": PropTypes.number,
|
|
487
490
|
"slot": PropTypes.string,
|
|
@@ -289,7 +289,9 @@ const DateInput = ({
|
|
|
289
289
|
"data-component": dataComponent || "date",
|
|
290
290
|
"data-element": dataElement,
|
|
291
291
|
"data-role": dataRole
|
|
292
|
-
}, filterStyledSystemMarginProps(rest)
|
|
292
|
+
}, filterStyledSystemMarginProps(rest), {
|
|
293
|
+
applyDateRangeStyling: !!inputRefMap
|
|
294
|
+
}), /*#__PURE__*/React.createElement(Textbox, _extends({}, filterOutStyledSystemSpacingProps(rest), {
|
|
293
295
|
value: computedValue(),
|
|
294
296
|
onBlur: handleBlur,
|
|
295
297
|
onChange: handleChange,
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import styled from "styled-components";
|
|
1
|
+
import styled, { css } from "styled-components";
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
3
|
import { margin } from "styled-system";
|
|
4
4
|
import baseTheme from "../../style/themes/base";
|
|
5
5
|
import StyledInput from "../../__internal__/input/input.style";
|
|
6
6
|
import StyledInputPresentation from "../../__internal__/input/input-presentation.style";
|
|
7
|
+
import { FieldLineStyle } from "../../__internal__/form-field/form-field.style";
|
|
8
|
+
import StyledValidationMessage from "../../__internal__/validation-message/validation-message.style";
|
|
9
|
+
import StyledLabel from "../../__internal__/label/label.style";
|
|
7
10
|
const datePickerWidth = {
|
|
8
11
|
large: "140px",
|
|
9
12
|
medium: "135px",
|
|
@@ -22,6 +25,20 @@ const StyledDateInput = styled.div`
|
|
|
22
25
|
margin-right: -8px;
|
|
23
26
|
}
|
|
24
27
|
}
|
|
28
|
+
|
|
29
|
+
${({
|
|
30
|
+
applyDateRangeStyling,
|
|
31
|
+
size,
|
|
32
|
+
labelInline
|
|
33
|
+
}) => applyDateRangeStyling && !labelInline && css`
|
|
34
|
+
${FieldLineStyle} {
|
|
35
|
+
max-width: ${datePickerWidth[size]};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
${StyledValidationMessage}, ${StyledLabel} {
|
|
39
|
+
overflow-wrap: anywhere;
|
|
40
|
+
}
|
|
41
|
+
`}
|
|
25
42
|
`;
|
|
26
43
|
StyledDateInput.propTypes = {
|
|
27
44
|
size: PropTypes.oneOf(["small", "medium", "large"])
|
|
@@ -259,6 +259,7 @@ Decimal.propTypes = {
|
|
|
259
259
|
"aria-valuemin": PropTypes.number,
|
|
260
260
|
"aria-valuenow": PropTypes.number,
|
|
261
261
|
"aria-valuetext": PropTypes.string,
|
|
262
|
+
"as": PropTypes.elementType,
|
|
262
263
|
"autoCapitalize": PropTypes.string,
|
|
263
264
|
"autoComplete": PropTypes.string,
|
|
264
265
|
"autoCorrect": PropTypes.string,
|
|
@@ -174,6 +174,7 @@ GroupedCharacter.propTypes = {
|
|
|
174
174
|
"aria-valuemin": PropTypes.number,
|
|
175
175
|
"aria-valuenow": PropTypes.number,
|
|
176
176
|
"aria-valuetext": PropTypes.string,
|
|
177
|
+
"as": PropTypes.elementType,
|
|
177
178
|
"autoCapitalize": PropTypes.string,
|
|
178
179
|
"autoComplete": PropTypes.string,
|
|
179
180
|
"autoCorrect": PropTypes.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;
|