carbon-react 146.2.1 → 146.3.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.
Files changed (25) hide show
  1. package/esm/__internal__/form-field/form-field.component.d.ts +3 -1
  2. package/esm/__internal__/form-field/form-field.component.js +3 -1
  3. package/esm/__internal__/form-field/form-field.style.d.ts +1 -0
  4. package/esm/__internal__/form-field/form-field.style.js +3 -1
  5. package/esm/__internal__/label/label.component.js +10 -2
  6. package/esm/__internal__/label/label.style.js +6 -2
  7. package/esm/components/menu/menu.style.js +1 -0
  8. package/esm/components/numeral-date/numeral-date.component.js +1 -0
  9. package/esm/components/textarea/textarea.component.d.ts +1 -1
  10. package/esm/components/textarea/textarea.component.js +1 -1
  11. package/esm/components/textbox/textbox.component.d.ts +1 -1
  12. package/esm/components/textbox/textbox.component.js +3 -2
  13. package/lib/__internal__/form-field/form-field.component.d.ts +3 -1
  14. package/lib/__internal__/form-field/form-field.component.js +3 -1
  15. package/lib/__internal__/form-field/form-field.style.d.ts +1 -0
  16. package/lib/__internal__/form-field/form-field.style.js +3 -1
  17. package/lib/__internal__/label/label.component.js +10 -2
  18. package/lib/__internal__/label/label.style.js +6 -2
  19. package/lib/components/menu/menu.style.js +1 -0
  20. package/lib/components/numeral-date/numeral-date.component.js +1 -0
  21. package/lib/components/textarea/textarea.component.d.ts +1 -1
  22. package/lib/components/textarea/textarea.component.js +1 -1
  23. package/lib/components/textbox/textbox.component.d.ts +1 -1
  24. package/lib/components/textbox/textbox.component.js +3 -2
  25. package/package.json +1 -1
@@ -59,9 +59,11 @@ export interface FormFieldProps extends CommonFormFieldProps, TagProps {
59
59
  isRequired?: boolean;
60
60
  /** Whether to show the validation icon */
61
61
  useValidationIcon?: boolean;
62
+ /** String value for max-width of `field-line` element */
63
+ maxWidth?: string;
62
64
  }
63
65
  declare const FormField: {
64
- ({ children, "data-component": dataComponent, disabled, loading, fieldHelp: fieldHelpContent, fieldHelpInline, error, warning, info, tooltipId, fieldHelpId, label, labelId, labelAlign, labelHelp, labelHelpIcon, labelInline, labelSpacing, labelWidth, labelAs, id, reverse, isOptional, useValidationIcon, adaptiveLabelBreakpoint, isRequired, validationIconId, validationRedesignOptIn, ...rest }: FormFieldProps): React.JSX.Element;
66
+ ({ maxWidth, children, "data-component": dataComponent, disabled, loading, fieldHelp: fieldHelpContent, fieldHelpInline, error, warning, info, tooltipId, fieldHelpId, label, labelId, labelAlign, labelHelp, labelHelpIcon, labelInline, labelSpacing, labelWidth, labelAs, id, reverse, isOptional, useValidationIcon, adaptiveLabelBreakpoint, isRequired, validationIconId, validationRedesignOptIn, ...rest }: FormFieldProps): React.JSX.Element;
65
67
  displayName: string;
66
68
  };
67
69
  export default FormField;
@@ -10,6 +10,7 @@ import TabContext from "../../components/tabs/tab/__internal__/tab.context";
10
10
  import useIsAboveBreakpoint from "../../hooks/__internal__/useIsAboveBreakpoint";
11
11
  import useFormSpacing from "../../hooks/__internal__/useFormSpacing";
12
12
  const FormField = ({
13
+ maxWidth,
13
14
  children,
14
15
  "data-component": dataComponent,
15
16
  disabled,
@@ -88,7 +89,8 @@ const FormField = ({
88
89
  }, fieldHelpContent) : null;
89
90
  return /*#__PURE__*/React.createElement(FormFieldStyle, _extends({}, tagComponent(dataComponent, rest), marginProps), /*#__PURE__*/React.createElement(FieldLineStyle, {
90
91
  "data-role": "field-line",
91
- inline: inlineLabel
92
+ inline: inlineLabel,
93
+ maxWidth: maxWidth
92
94
  }, reverse && children, label && /*#__PURE__*/React.createElement(Label, {
93
95
  labelId: labelId,
94
96
  align: labelAlign,
@@ -1,6 +1,7 @@
1
1
  declare const FormFieldStyle: import("styled-components").StyledComponent<"div", any, {}, never>;
2
2
  export interface FieldLineStyleProps {
3
3
  inline?: boolean;
4
+ maxWidth?: string;
4
5
  }
5
6
  declare const FieldLineStyle: import("styled-components").StyledComponent<"div", any, FieldLineStyleProps, never>;
6
7
  export { FieldLineStyle };
@@ -15,9 +15,11 @@ FormFieldStyle.defaultProps = {
15
15
  };
16
16
  const FieldLineStyle = styled.div`
17
17
  ${({
18
- inline
18
+ inline,
19
+ maxWidth
19
20
  }) => css`
20
21
  display: ${inline ? "flex" : "block"};
22
+ ${maxWidth && `max-width: ${maxWidth};`}
21
23
  `}
22
24
  `;
23
25
  export { FieldLineStyle };
@@ -24,7 +24,7 @@ const tooltipPosition = ({
24
24
  return (error || warning || info) && inline ? "top" : "right";
25
25
  };
26
26
  export const Label = ({
27
- align = "right",
27
+ align,
28
28
  as = "label",
29
29
  children,
30
30
  disabled,
@@ -65,6 +65,14 @@ export const Label = ({
65
65
  if (onMouseLeave) onMouseLeave();
66
66
  if (onGroupMouseLeave) onGroupMouseLeave();
67
67
  };
68
+ let alignment;
69
+ if (inline && !align) {
70
+ alignment = "right";
71
+ } else if (!align) {
72
+ alignment = "left";
73
+ } else {
74
+ alignment = align;
75
+ }
68
76
  const icon = () => {
69
77
  const wrapperProps = {
70
78
  onFocus: () => setFocus(true),
@@ -99,7 +107,7 @@ export const Label = ({
99
107
  };
100
108
  return /*#__PURE__*/React.createElement(StyledLabelContainer, {
101
109
  "data-role": "label-container",
102
- align: align,
110
+ align: alignment,
103
111
  inline: inline,
104
112
  width: width,
105
113
  optional: optional,
@@ -31,7 +31,12 @@ export const StyledLabelContainer = styled.div`
31
31
  margin-bottom: 8px;
32
32
 
33
33
  ${({
34
- align,
34
+ align
35
+ }) => css`
36
+ justify-content: ${align !== "right" ? "flex-start" : "flex-end"};
37
+ `}
38
+
39
+ ${({
35
40
  inline,
36
41
  pr,
37
42
  pl,
@@ -45,7 +50,6 @@ export const StyledLabelContainer = styled.div`
45
50
  ${pl && css`
46
51
  padding-left: var(${pl === 1 ? "--spacing100" : "--spacing200"});
47
52
  `};
48
- justify-content: ${align === "right" ? "flex-end" : "flex-start"};
49
53
  width: ${width}%;
50
54
  `}
51
55
 
@@ -35,6 +35,7 @@ const StyledMenuWrapper = styled.ul`
35
35
  `;
36
36
  const StyledMenuItem = styled.li`
37
37
  display: flex;
38
+ list-style: none;
38
39
  ${({
39
40
  maxWidth
40
41
  }) => maxWidth && css`
@@ -262,6 +262,7 @@ export const NumeralDate = ({
262
262
  isYearInput: datePart.length === 4,
263
263
  hasValidationIconInField: !validationOnLabel && isEnd && validationInField
264
264
  }, /*#__PURE__*/React.createElement(Textbox, _extends({
265
+ maxWidth: "fit-content",
265
266
  id: inputIds.current[datePart],
266
267
  label: getDateLabel(datePart, locale),
267
268
  disabled: disabled,
@@ -60,7 +60,7 @@ export interface TextareaProps extends ValidationProps, MarginProps, Omit<Common
60
60
  maxWidth?: string;
61
61
  /** The content of the label for the input */
62
62
  label?: string;
63
- /** [Legacy] Inline label alignment */
63
+ /** Label alignment */
64
64
  labelAlign?: "left" | "right";
65
65
  /**
66
66
  * [Legacy] Text applied to label help tooltip. When opted into new design validations
@@ -235,7 +235,7 @@ const Textarea = /*#__PURE__*/React.forwardRef(({
235
235
  disabled: disabled,
236
236
  id: id,
237
237
  labelInline: computeLabelPropValues(labelInlineWithNewValidation),
238
- labelAlign: computeLabelPropValues(labelAlign),
238
+ labelAlign: labelAlign,
239
239
  labelWidth: computeLabelPropValues(labelWidth),
240
240
  labelHelp: computeLabelPropValues(labelHelp),
241
241
  labelSpacing: labelSpacing,
@@ -54,7 +54,7 @@ export interface CommonTextboxProps extends ValidationProps, MarginProps, Omit<C
54
54
  leftChildren?: React.ReactNode;
55
55
  /** Label content */
56
56
  label?: string;
57
- /** [Legacy] Inline label alignment */
57
+ /** Label alignment */
58
58
  labelAlign?: "left" | "right";
59
59
  /**
60
60
  * [Legacy] Text applied to label help tooltip. When opted into new design validations
@@ -134,7 +134,7 @@ const Textbox = /*#__PURE__*/React.forwardRef(({
134
134
  info: info,
135
135
  prefix: prefix,
136
136
  inputWidth: inputWidth || 100 - labelWidth,
137
- maxWidth: maxWidth,
137
+ maxWidth: labelInline || labelAlign !== "right" ? maxWidth : undefined,
138
138
  positionedChildren: positionedChildren,
139
139
  hasIcon: hasIconInside
140
140
  }, leftChildren, prefix && /*#__PURE__*/React.createElement(StyledPrefix, {
@@ -182,6 +182,7 @@ const Textbox = /*#__PURE__*/React.forwardRef(({
182
182
  helpAriaLabel: helpAriaLabel,
183
183
  tooltipPosition: tooltipPosition
184
184
  }, /*#__PURE__*/React.createElement(InputBehaviour, null, /*#__PURE__*/React.createElement(FormField, _extends({
185
+ maxWidth: !labelInline && labelAlign === "right" ? maxWidth : undefined,
185
186
  disabled: disabled,
186
187
  fieldHelpId: fieldHelpId,
187
188
  fieldHelp: computeLabelPropValues(fieldHelp),
@@ -190,7 +191,7 @@ const Textbox = /*#__PURE__*/React.forwardRef(({
190
191
  info: info,
191
192
  label: label,
192
193
  labelId: labelId,
193
- labelAlign: computeLabelPropValues(labelAlign),
194
+ labelAlign: labelAlign,
194
195
  labelHelp: computeLabelPropValues(labelHelp),
195
196
  labelInline: computeLabelPropValues(labelInline),
196
197
  labelSpacing: labelSpacing,
@@ -59,9 +59,11 @@ export interface FormFieldProps extends CommonFormFieldProps, TagProps {
59
59
  isRequired?: boolean;
60
60
  /** Whether to show the validation icon */
61
61
  useValidationIcon?: boolean;
62
+ /** String value for max-width of `field-line` element */
63
+ maxWidth?: string;
62
64
  }
63
65
  declare const FormField: {
64
- ({ children, "data-component": dataComponent, disabled, loading, fieldHelp: fieldHelpContent, fieldHelpInline, error, warning, info, tooltipId, fieldHelpId, label, labelId, labelAlign, labelHelp, labelHelpIcon, labelInline, labelSpacing, labelWidth, labelAs, id, reverse, isOptional, useValidationIcon, adaptiveLabelBreakpoint, isRequired, validationIconId, validationRedesignOptIn, ...rest }: FormFieldProps): React.JSX.Element;
66
+ ({ maxWidth, children, "data-component": dataComponent, disabled, loading, fieldHelp: fieldHelpContent, fieldHelpInline, error, warning, info, tooltipId, fieldHelpId, label, labelId, labelAlign, labelHelp, labelHelpIcon, labelInline, labelSpacing, labelWidth, labelAs, id, reverse, isOptional, useValidationIcon, adaptiveLabelBreakpoint, isRequired, validationIconId, validationRedesignOptIn, ...rest }: FormFieldProps): React.JSX.Element;
65
67
  displayName: string;
66
68
  };
67
69
  export default FormField;
@@ -19,6 +19,7 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
19
19
  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; }
20
20
  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); }
21
21
  const FormField = ({
22
+ maxWidth,
22
23
  children,
23
24
  "data-component": dataComponent,
24
25
  disabled,
@@ -97,7 +98,8 @@ const FormField = ({
97
98
  }, fieldHelpContent) : null;
98
99
  return /*#__PURE__*/_react.default.createElement(_formField.default, _extends({}, (0, _tags.default)(dataComponent, rest), marginProps), /*#__PURE__*/_react.default.createElement(_formField.FieldLineStyle, {
99
100
  "data-role": "field-line",
100
- inline: inlineLabel
101
+ inline: inlineLabel,
102
+ maxWidth: maxWidth
101
103
  }, reverse && children, label && /*#__PURE__*/_react.default.createElement(_label.default, {
102
104
  labelId: labelId,
103
105
  align: labelAlign,
@@ -1,6 +1,7 @@
1
1
  declare const FormFieldStyle: import("styled-components").StyledComponent<"div", any, {}, never>;
2
2
  export interface FieldLineStyleProps {
3
3
  inline?: boolean;
4
+ maxWidth?: string;
4
5
  }
5
6
  declare const FieldLineStyle: import("styled-components").StyledComponent<"div", any, FieldLineStyleProps, never>;
6
7
  export { FieldLineStyle };
@@ -23,9 +23,11 @@ FormFieldStyle.defaultProps = {
23
23
  };
24
24
  const FieldLineStyle = exports.FieldLineStyle = _styledComponents.default.div`
25
25
  ${({
26
- inline
26
+ inline,
27
+ maxWidth
27
28
  }) => (0, _styledComponents.css)`
28
29
  display: ${inline ? "flex" : "block"};
30
+ ${maxWidth && `max-width: ${maxWidth};`}
29
31
  `}
30
32
  `;
31
33
  var _default = exports.default = FormFieldStyle;
@@ -33,7 +33,7 @@ const tooltipPosition = ({
33
33
  return (error || warning || info) && inline ? "top" : "right";
34
34
  };
35
35
  const Label = ({
36
- align = "right",
36
+ align,
37
37
  as = "label",
38
38
  children,
39
39
  disabled,
@@ -74,6 +74,14 @@ const Label = ({
74
74
  if (onMouseLeave) onMouseLeave();
75
75
  if (onGroupMouseLeave) onGroupMouseLeave();
76
76
  };
77
+ let alignment;
78
+ if (inline && !align) {
79
+ alignment = "right";
80
+ } else if (!align) {
81
+ alignment = "left";
82
+ } else {
83
+ alignment = align;
84
+ }
77
85
  const icon = () => {
78
86
  const wrapperProps = {
79
87
  onFocus: () => setFocus(true),
@@ -108,7 +116,7 @@ const Label = ({
108
116
  };
109
117
  return /*#__PURE__*/_react.default.createElement(_label.StyledLabelContainer, {
110
118
  "data-role": "label-container",
111
- align: align,
119
+ align: alignment,
112
120
  inline: inline,
113
121
  width: width,
114
122
  optional: optional,
@@ -39,7 +39,12 @@ const StyledLabelContainer = exports.StyledLabelContainer = _styledComponents.de
39
39
  margin-bottom: 8px;
40
40
 
41
41
  ${({
42
- align,
42
+ align
43
+ }) => (0, _styledComponents.css)`
44
+ justify-content: ${align !== "right" ? "flex-start" : "flex-end"};
45
+ `}
46
+
47
+ ${({
43
48
  inline,
44
49
  pr,
45
50
  pl,
@@ -53,7 +58,6 @@ const StyledLabelContainer = exports.StyledLabelContainer = _styledComponents.de
53
58
  ${pl && (0, _styledComponents.css)`
54
59
  padding-left: var(${pl === 1 ? "--spacing100" : "--spacing200"});
55
60
  `};
56
- justify-content: ${align === "right" ? "flex-end" : "flex-start"};
57
61
  width: ${width}%;
58
62
  `}
59
63
 
@@ -44,6 +44,7 @@ const StyledMenuWrapper = exports.StyledMenuWrapper = _styledComponents.default.
44
44
  `;
45
45
  const StyledMenuItem = exports.StyledMenuItem = _styledComponents.default.li`
46
46
  display: flex;
47
+ list-style: none;
47
48
  ${({
48
49
  maxWidth
49
50
  }) => maxWidth && (0, _styledComponents.css)`
@@ -271,6 +271,7 @@ const NumeralDate = ({
271
271
  isYearInput: datePart.length === 4,
272
272
  hasValidationIconInField: !validationOnLabel && isEnd && validationInField
273
273
  }, /*#__PURE__*/_react.default.createElement(_textbox.default, _extends({
274
+ maxWidth: "fit-content",
274
275
  id: inputIds.current[datePart],
275
276
  label: getDateLabel(datePart, locale),
276
277
  disabled: disabled,
@@ -60,7 +60,7 @@ export interface TextareaProps extends ValidationProps, MarginProps, Omit<Common
60
60
  maxWidth?: string;
61
61
  /** The content of the label for the input */
62
62
  label?: string;
63
- /** [Legacy] Inline label alignment */
63
+ /** Label alignment */
64
64
  labelAlign?: "left" | "right";
65
65
  /**
66
66
  * [Legacy] Text applied to label help tooltip. When opted into new design validations
@@ -244,7 +244,7 @@ const Textarea = exports.OriginalTextarea = exports.Textarea = /*#__PURE__*/_rea
244
244
  disabled: disabled,
245
245
  id: id,
246
246
  labelInline: computeLabelPropValues(labelInlineWithNewValidation),
247
- labelAlign: computeLabelPropValues(labelAlign),
247
+ labelAlign: labelAlign,
248
248
  labelWidth: computeLabelPropValues(labelWidth),
249
249
  labelHelp: computeLabelPropValues(labelHelp),
250
250
  labelSpacing: labelSpacing,
@@ -54,7 +54,7 @@ export interface CommonTextboxProps extends ValidationProps, MarginProps, Omit<C
54
54
  leftChildren?: React.ReactNode;
55
55
  /** Label content */
56
56
  label?: string;
57
- /** [Legacy] Inline label alignment */
57
+ /** Label alignment */
58
58
  labelAlign?: "left" | "right";
59
59
  /**
60
60
  * [Legacy] Text applied to label help tooltip. When opted into new design validations
@@ -143,7 +143,7 @@ const Textbox = exports.Textbox = /*#__PURE__*/_react.default.forwardRef(({
143
143
  info: info,
144
144
  prefix: prefix,
145
145
  inputWidth: inputWidth || 100 - labelWidth,
146
- maxWidth: maxWidth,
146
+ maxWidth: labelInline || labelAlign !== "right" ? maxWidth : undefined,
147
147
  positionedChildren: positionedChildren,
148
148
  hasIcon: hasIconInside
149
149
  }, leftChildren, prefix && /*#__PURE__*/_react.default.createElement(_prefix.default, {
@@ -191,6 +191,7 @@ const Textbox = exports.Textbox = /*#__PURE__*/_react.default.forwardRef(({
191
191
  helpAriaLabel: helpAriaLabel,
192
192
  tooltipPosition: tooltipPosition
193
193
  }, /*#__PURE__*/_react.default.createElement(_inputBehaviour.InputBehaviour, null, /*#__PURE__*/_react.default.createElement(_formField.default, _extends({
194
+ maxWidth: !labelInline && labelAlign === "right" ? maxWidth : undefined,
194
195
  disabled: disabled,
195
196
  fieldHelpId: fieldHelpId,
196
197
  fieldHelp: computeLabelPropValues(fieldHelp),
@@ -199,7 +200,7 @@ const Textbox = exports.Textbox = /*#__PURE__*/_react.default.forwardRef(({
199
200
  info: info,
200
201
  label: label,
201
202
  labelId: labelId,
202
- labelAlign: computeLabelPropValues(labelAlign),
203
+ labelAlign: labelAlign,
203
204
  labelHelp: computeLabelPropValues(labelHelp),
204
205
  labelInline: computeLabelPropValues(labelInline),
205
206
  labelSpacing: labelSpacing,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "146.2.1",
3
+ "version": "146.3.1",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",