carbon-react 147.0.1 → 147.1.0

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__/fieldset/fieldset.component.js +10 -2
  2. package/esm/__internal__/fieldset/fieldset.style.d.ts +1 -1
  3. package/esm/__internal__/fieldset/fieldset.style.js +13 -2
  4. package/esm/components/checkbox/checkbox-group/checkbox-group.component.js +1 -1
  5. package/esm/components/numeral-date/numeral-date.component.d.ts +4 -2
  6. package/esm/components/numeral-date/numeral-date.component.js +14 -4
  7. package/esm/components/numeral-date/numeral-date.style.d.ts +6 -1
  8. package/esm/components/numeral-date/numeral-date.style.js +16 -7
  9. package/esm/components/radio-button/radio-button-group/radio-button-group.component.js +1 -1
  10. package/esm/components/time/time.component.d.ts +4 -0
  11. package/esm/components/time/time.component.js +14 -5
  12. package/esm/components/time/time.style.js +1 -1
  13. package/lib/__internal__/fieldset/fieldset.component.js +10 -2
  14. package/lib/__internal__/fieldset/fieldset.style.d.ts +1 -1
  15. package/lib/__internal__/fieldset/fieldset.style.js +13 -2
  16. package/lib/components/checkbox/checkbox-group/checkbox-group.component.js +1 -1
  17. package/lib/components/numeral-date/numeral-date.component.d.ts +4 -2
  18. package/lib/components/numeral-date/numeral-date.component.js +14 -4
  19. package/lib/components/numeral-date/numeral-date.style.d.ts +6 -1
  20. package/lib/components/numeral-date/numeral-date.style.js +16 -7
  21. package/lib/components/radio-button/radio-button-group/radio-button-group.component.js +1 -1
  22. package/lib/components/time/time.component.d.ts +4 -0
  23. package/lib/components/time/time.component.js +14 -5
  24. package/lib/components/time/time.style.js +1 -1
  25. package/package.json +1 -1
@@ -12,7 +12,7 @@ const Fieldset = ({
12
12
  children,
13
13
  inline = false,
14
14
  legendWidth,
15
- legendAlign = "right",
15
+ legendAlign,
16
16
  legendSpacing = 2,
17
17
  error,
18
18
  warning,
@@ -60,6 +60,14 @@ const Fieldset = ({
60
60
  }
61
61
  return null;
62
62
  };
63
+ let legendAlignment;
64
+ if (inline && !legendAlign) {
65
+ legendAlignment = "right";
66
+ } else if (!legendAlign) {
67
+ legendAlignment = "left";
68
+ } else {
69
+ legendAlignment = legendAlign;
70
+ }
63
71
  return /*#__PURE__*/React.createElement(InputGroupBehaviour, {
64
72
  blockGroupBehaviour: blockGroupBehaviour
65
73
  }, /*#__PURE__*/React.createElement(StyledFieldset, _extends({
@@ -73,7 +81,7 @@ const Fieldset = ({
73
81
  onMouseLeave: onMouseLeave,
74
82
  inline: inline,
75
83
  width: legendWidth,
76
- align: legendAlign,
84
+ align: legendAlignment,
77
85
  rightPadding: legendSpacing
78
86
  }, legendMargin, {
79
87
  "data-element": "legend",
@@ -8,7 +8,7 @@ declare type StyledLegendContentProps = {
8
8
  isDisabled?: boolean;
9
9
  };
10
10
  declare const StyledLegendContent: import("styled-components").StyledComponent<"span", any, StyledLegendContentProps, never>;
11
- declare type StyledLegendProps = {
11
+ export declare type StyledLegendProps = {
12
12
  inline?: boolean;
13
13
  width?: number;
14
14
  align?: "left" | "right";
@@ -60,17 +60,28 @@ const StyledLegend = styled.legend`
60
60
  padding: 0;
61
61
  font-weight: var(--fontWeights500);
62
62
  color: var(--colorsUtilityYin090);
63
+
64
+ ${({
65
+ align,
66
+ inline
67
+ }) => align && css`
68
+ text-align: ${align};
69
+ justify-content: ${align === "right" ? "flex-end" : "flex-start"};
70
+
71
+ ${!inline && css`
72
+ width: -moz-available;
73
+ `}
74
+ `};
75
+
63
76
  ${({
64
77
  inline,
65
78
  width,
66
- align,
67
79
  rightPadding
68
80
  }) => inline && css`
69
81
  float: left;
70
82
  box-sizing: border-box;
71
83
  margin: 0;
72
84
  ${width && `width: ${width}%`};
73
- justify-content: ${align === "right" ? "flex-end" : "flex-start"};
74
85
  padding-right: ${rightPadding === 1 ? "var(--spacing100)" : "var(--spacing200)"};
75
86
  `}
76
87
  ${margin}
@@ -26,7 +26,7 @@ export const CheckboxGroup = props => {
26
26
  isOptional,
27
27
  legendInline,
28
28
  legendWidth,
29
- legendAlign,
29
+ legendAlign = "left",
30
30
  legendSpacing,
31
31
  legendHelp,
32
32
  tooltipPosition,
@@ -51,8 +51,10 @@ export interface NumeralDateProps<DateType extends NumeralDateObject = FullDate>
51
51
  name?: string;
52
52
  /** Label */
53
53
  label?: string;
54
- /** [Legacy] Label alignment. Works only when labelInline is true */
54
+ /** Label alignment */
55
55
  labelAlign?: "left" | "right";
56
+ /** Field labels alignment */
57
+ fieldLabelsAlign?: "left" | "right";
56
58
  /**
57
59
  * Text applied to label help tooltip, will be rendered as
58
60
  * hint text when `validationRedesignOptIn` is true.
@@ -94,5 +96,5 @@ export interface NumeralDateProps<DateType extends NumeralDateObject = FullDate>
94
96
  isOptional?: boolean;
95
97
  }
96
98
  export declare type ValidDateFormat = (typeof ALLOWED_DATE_FORMATS)[number];
97
- export declare const NumeralDate: <DateType extends NumeralDateObject = FullDate>({ dateFormat, defaultValue, disabled, error, warning, "data-component": dataComponent, "data-element": dataElement, "data-role": dataRole, info, id, name, onBlur, onChange, value, validationOnLabel, label, labelInline, labelWidth, labelAlign, labelHelp, labelSpacing, fieldHelp, adaptiveLabelBreakpoint, required, isOptional, readOnly, size, enableInternalError, enableInternalWarning, tooltipPosition, helpAriaLabel, dayRef, monthRef, yearRef, ...rest }: NumeralDateProps<DateType>) => React.JSX.Element;
99
+ export declare const NumeralDate: <DateType extends NumeralDateObject = FullDate>({ dateFormat, defaultValue, disabled, error, warning, "data-component": dataComponent, "data-element": dataElement, "data-role": dataRole, info, id, name, onBlur, onChange, value, validationOnLabel, label, labelInline, labelWidth, labelAlign, fieldLabelsAlign, labelHelp, labelSpacing, fieldHelp, adaptiveLabelBreakpoint, required, isOptional, readOnly, size, enableInternalError, enableInternalWarning, tooltipPosition, helpAriaLabel, dayRef, monthRef, yearRef, ...rest }: NumeralDateProps<DateType>) => React.JSX.Element;
98
100
  export default NumeralDate;
@@ -97,6 +97,7 @@ export const NumeralDate = ({
97
97
  labelInline,
98
98
  labelWidth,
99
99
  labelAlign,
100
+ fieldLabelsAlign,
100
101
  labelHelp,
101
102
  labelSpacing,
102
103
  fieldHelp,
@@ -262,9 +263,9 @@ export const NumeralDate = ({
262
263
  isYearInput: datePart.length === 4,
263
264
  hasValidationIconInField: !validationOnLabel && isEnd && validationInField
264
265
  }, /*#__PURE__*/React.createElement(Textbox, _extends({
265
- maxWidth: "fit-content",
266
266
  id: inputIds.current[datePart],
267
267
  label: getDateLabel(datePart, locale),
268
+ labelAlign: fieldLabelsAlign,
268
269
  disabled: disabled,
269
270
  readOnly: readOnly,
270
271
  error: !!internalError,
@@ -294,6 +295,9 @@ export const NumeralDate = ({
294
295
  "data-role": dataRole,
295
296
  id: uniqueId,
296
297
  legend: label,
298
+ legendMargin: {
299
+ mb: 0
300
+ },
297
301
  isRequired: required,
298
302
  isOptional: isOptional,
299
303
  isDisabled: disabled,
@@ -302,6 +306,7 @@ export const NumeralDate = ({
302
306
  warning: validationOnLabel && internalWarning,
303
307
  info: validationOnLabel && info,
304
308
  inline: inline,
309
+ size: size,
305
310
  labelHelp: labelHelp,
306
311
  legendAlign: labelAlign,
307
312
  legendWidth: labelWidth,
@@ -309,8 +314,9 @@ export const NumeralDate = ({
309
314
  validationId: validationId,
310
315
  "aria-describedby": ariaDescribedBy
311
316
  }, filterStyledSystemMarginProps(rest)), /*#__PURE__*/React.createElement(Box, {
312
- display: "block",
313
- mt: 1
317
+ display: "flex",
318
+ flexDirection: "column",
319
+ mt: inline ? 0 : 1
314
320
  }, renderInputs(), fieldHelp && /*#__PURE__*/React.createElement(FieldHelp, {
315
321
  id: fieldHelpId
316
322
  }, fieldHelp))));
@@ -321,6 +327,10 @@ export const NumeralDate = ({
321
327
  "data-role": dataRole,
322
328
  id: uniqueId,
323
329
  legend: label,
330
+ legendMargin: {
331
+ mb: 0
332
+ },
333
+ legendAlign: labelAlign,
324
334
  isRequired: required,
325
335
  isOptional: isOptional,
326
336
  isDisabled: disabled,
@@ -330,7 +340,7 @@ export const NumeralDate = ({
330
340
  id: inputHintId.current
331
341
  }, labelHelp), /*#__PURE__*/React.createElement(Box, {
332
342
  position: "relative",
333
- mt: 1
343
+ mt: labelHelp ? 0 : 1
334
344
  }, (internalError || internalWarning) && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ValidationMessage, {
335
345
  error: internalError,
336
346
  warning: internalWarning,
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ import { FieldsetProps } from "../../__internal__/fieldset";
2
3
  interface StyledDateFieldProps {
3
4
  isYearInput?: boolean;
4
5
  hasValidationIconInField: boolean;
@@ -8,5 +9,9 @@ export declare const StyledNumeralDate: import("styled-components").StyledCompon
8
9
  name?: string | undefined;
9
10
  }, never>;
10
11
  export declare const StyledDateField: import("styled-components").StyledComponent<"div", any, StyledDateFieldProps, never>;
11
- export declare const StyledFieldset: import("styled-components").StyledComponent<({ legend, children, inline, legendWidth, legendAlign, legendSpacing, error, warning, info, isRequired, blockGroupBehaviour, legendMargin, isDisabled, isOptional, labelHelp, validationId, ...rest }: import("../../__internal__/fieldset").FieldsetProps) => import("react").JSX.Element, any, {}, never>;
12
+ interface StyledFieldsetProps extends FieldsetProps {
13
+ inline?: boolean;
14
+ size?: "small" | "medium" | "large";
15
+ }
16
+ export declare const StyledFieldset: import("styled-components").StyledComponent<({ legend, children, inline, legendWidth, legendAlign, legendSpacing, error, warning, info, isRequired, blockGroupBehaviour, legendMargin, isDisabled, isOptional, labelHelp, validationId, ...rest }: FieldsetProps) => import("react").JSX.Element, any, StyledFieldsetProps, never>;
12
17
  export {};
@@ -46,17 +46,26 @@ export const StyledDateField = styled.div`
46
46
  }
47
47
  `}
48
48
  `;
49
+ // We need to match height of the legend to the input container when it is inline to center it vertically,
50
+ // as Safari does not support display: flex on fieldset elements.
51
+ const sizeHeight = {
52
+ small: "57px",
53
+ medium: "65px",
54
+ large: "73px"
55
+ };
49
56
  export const StyledFieldset = styled(Fieldset)`
50
57
  ${({
51
- inline
58
+ inline,
59
+ size
52
60
  }) => css`
53
61
  ${inline && css`
54
- display: flex;
55
- align-items: center;
62
+ ${StyledLegend} {
63
+ height: ${size && sizeHeight[size]};
64
+ }
56
65
  `}
57
- `}
58
66
 
59
- ${StyledLegend} {
60
- margin-bottom: 0;
61
- }
67
+ ${!inline && css`
68
+ width: min-content;
69
+ `}
70
+ `}
62
71
  `;
@@ -29,7 +29,7 @@ export const RadioButtonGroup = props => {
29
29
  inline = false,
30
30
  legendInline = false,
31
31
  legendWidth,
32
- legendAlign,
32
+ legendAlign = "left",
33
33
  legendSpacing,
34
34
  labelSpacing = 1,
35
35
  adaptiveLegendBreakpoint,
@@ -28,6 +28,10 @@ interface TimeInputProps extends Omit<TagProps, "data-component">, Omit<Validati
28
28
  export interface TimeProps extends Omit<TagProps, "data-component">, MarginProps {
29
29
  /** Label text for the component */
30
30
  label?: string;
31
+ /** Label alignment */
32
+ labelAlign?: "left" | "right";
33
+ /** Field labels alignment */
34
+ fieldLabelsAlign?: "left" | "right";
31
35
  /** Sets the size of the inputs */
32
36
  size?: Sizes;
33
37
  /** Additional hint text rendered above the input elements */
@@ -15,6 +15,8 @@ import { StyledLabel as Label, StyledHintText as Hint } from "./time.style";
15
15
  import { TimeToggle } from "./__internal__/time-toggle";
16
16
  const Time = /*#__PURE__*/React.forwardRef(({
17
17
  label,
18
+ labelAlign,
19
+ fieldLabelsAlign,
18
20
  size = "medium",
19
21
  inputHint,
20
22
  hoursInputProps = {},
@@ -141,7 +143,8 @@ const Time = /*#__PURE__*/React.forwardRef(({
141
143
  legendMargin: {
142
144
  mb: 0
143
145
  },
144
- width: "fit-content",
146
+ width: "min-content",
147
+ legendAlign: labelAlign,
145
148
  isRequired: required,
146
149
  isOptional: isOptional,
147
150
  isDisabled: disabled,
@@ -153,7 +156,8 @@ const Time = /*#__PURE__*/React.forwardRef(({
153
156
  id: inputHintId.current,
154
157
  isDisabled: disabled
155
158
  }, inputHint), /*#__PURE__*/React.createElement(Box, {
156
- position: "relative"
159
+ position: "relative",
160
+ mt: inputHint ? 0 : 1
157
161
  }, /*#__PURE__*/React.createElement(ValidationMessage, {
158
162
  validationId: validationId,
159
163
  error: error,
@@ -165,7 +169,8 @@ const Time = /*#__PURE__*/React.forwardRef(({
165
169
  }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Label, {
166
170
  "aria-label": hrsAriaLabel,
167
171
  htmlFor: internalHrsId.current,
168
- disabled: disabled
172
+ disabled: disabled,
173
+ align: fieldLabelsAlign
169
174
  }, hrsLabel), /*#__PURE__*/React.createElement(Number, _extends({}, hoursInputProps, {
170
175
  label: undefined,
171
176
  "data-component": "hours",
@@ -192,7 +197,8 @@ const Time = /*#__PURE__*/React.forwardRef(({
192
197
  }, ":")), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Label, {
193
198
  "aria-label": minsAriaLabel,
194
199
  htmlFor: internalMinsId.current,
195
- disabled: disabled
200
+ disabled: disabled,
201
+ align: fieldLabelsAlign
196
202
  }, minsLabel), /*#__PURE__*/React.createElement(Number, _extends({}, minutesInputProps, {
197
203
  label: undefined,
198
204
  "data-component": "minutes",
@@ -209,7 +215,8 @@ const Time = /*#__PURE__*/React.forwardRef(({
209
215
  }))), showToggle && /*#__PURE__*/React.createElement(Box, {
210
216
  display: "flex",
211
217
  flexDirection: "column",
212
- justifyContent: "flex-end"
218
+ justifyContent: "flex-end",
219
+ width: "max-content"
213
220
  }, /*#__PURE__*/React.createElement(TimeToggle, {
214
221
  toggleProps: toggleProps,
215
222
  size: size,
@@ -224,6 +231,7 @@ if (process.env.NODE_ENV !== "production") {
224
231
  "data-element": PropTypes.string,
225
232
  "data-role": PropTypes.string,
226
233
  "disabled": PropTypes.bool,
234
+ "fieldLabelsAlign": PropTypes.oneOf(["left", "right"]),
227
235
  "hoursInputProps": PropTypes.shape({
228
236
  "aria-label": PropTypes.string,
229
237
  "data-element": PropTypes.string,
@@ -236,6 +244,7 @@ if (process.env.NODE_ENV !== "production") {
236
244
  "inputHint": PropTypes.string,
237
245
  "isOptional": PropTypes.bool,
238
246
  "label": PropTypes.string,
247
+ "labelAlign": PropTypes.oneOf(["left", "right"]),
239
248
  "m": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
240
249
  "__@toStringTag": PropTypes.string.isRequired,
241
250
  "description": PropTypes.string,
@@ -11,7 +11,7 @@ export const StyledHintText = styled.div`
11
11
  }
12
12
 
13
13
  margin-top: var(--spacing000);
14
- margin-bottom: var(--spacing150);
14
+ margin-bottom: var(--spacing100);
15
15
  color: ${({
16
16
  isDisabled
17
17
  }) => isDisabled ? "var(--colorsUtilityYin030)" : "var(--colorsUtilityYin055)"};
@@ -21,7 +21,7 @@ const Fieldset = ({
21
21
  children,
22
22
  inline = false,
23
23
  legendWidth,
24
- legendAlign = "right",
24
+ legendAlign,
25
25
  legendSpacing = 2,
26
26
  error,
27
27
  warning,
@@ -69,6 +69,14 @@ const Fieldset = ({
69
69
  }
70
70
  return null;
71
71
  };
72
+ let legendAlignment;
73
+ if (inline && !legendAlign) {
74
+ legendAlignment = "right";
75
+ } else if (!legendAlign) {
76
+ legendAlignment = "left";
77
+ } else {
78
+ legendAlignment = legendAlign;
79
+ }
72
80
  return /*#__PURE__*/_react.default.createElement(_inputBehaviour.InputGroupBehaviour, {
73
81
  blockGroupBehaviour: blockGroupBehaviour
74
82
  }, /*#__PURE__*/_react.default.createElement(_fieldset.StyledFieldset, _extends({
@@ -82,7 +90,7 @@ const Fieldset = ({
82
90
  onMouseLeave: onMouseLeave,
83
91
  inline: inline,
84
92
  width: legendWidth,
85
- align: legendAlign,
93
+ align: legendAlignment,
86
94
  rightPadding: legendSpacing
87
95
  }, legendMargin, {
88
96
  "data-element": "legend",
@@ -8,7 +8,7 @@ declare type StyledLegendContentProps = {
8
8
  isDisabled?: boolean;
9
9
  };
10
10
  declare const StyledLegendContent: import("styled-components").StyledComponent<"span", any, StyledLegendContentProps, never>;
11
- declare type StyledLegendProps = {
11
+ export declare type StyledLegendProps = {
12
12
  inline?: boolean;
13
13
  width?: number;
14
14
  align?: "left" | "right";
@@ -69,17 +69,28 @@ const StyledLegend = exports.StyledLegend = _styledComponents.default.legend`
69
69
  padding: 0;
70
70
  font-weight: var(--fontWeights500);
71
71
  color: var(--colorsUtilityYin090);
72
+
73
+ ${({
74
+ align,
75
+ inline
76
+ }) => align && (0, _styledComponents.css)`
77
+ text-align: ${align};
78
+ justify-content: ${align === "right" ? "flex-end" : "flex-start"};
79
+
80
+ ${!inline && (0, _styledComponents.css)`
81
+ width: -moz-available;
82
+ `}
83
+ `};
84
+
72
85
  ${({
73
86
  inline,
74
87
  width,
75
- align,
76
88
  rightPadding
77
89
  }) => inline && (0, _styledComponents.css)`
78
90
  float: left;
79
91
  box-sizing: border-box;
80
92
  margin: 0;
81
93
  ${width && `width: ${width}%`};
82
- justify-content: ${align === "right" ? "flex-end" : "flex-start"};
83
94
  padding-right: ${rightPadding === 1 ? "var(--spacing100)" : "var(--spacing200)"};
84
95
  `}
85
96
  ${_styledSystem.margin}
@@ -35,7 +35,7 @@ const CheckboxGroup = props => {
35
35
  isOptional,
36
36
  legendInline,
37
37
  legendWidth,
38
- legendAlign,
38
+ legendAlign = "left",
39
39
  legendSpacing,
40
40
  legendHelp,
41
41
  tooltipPosition,
@@ -51,8 +51,10 @@ export interface NumeralDateProps<DateType extends NumeralDateObject = FullDate>
51
51
  name?: string;
52
52
  /** Label */
53
53
  label?: string;
54
- /** [Legacy] Label alignment. Works only when labelInline is true */
54
+ /** Label alignment */
55
55
  labelAlign?: "left" | "right";
56
+ /** Field labels alignment */
57
+ fieldLabelsAlign?: "left" | "right";
56
58
  /**
57
59
  * Text applied to label help tooltip, will be rendered as
58
60
  * hint text when `validationRedesignOptIn` is true.
@@ -94,5 +96,5 @@ export interface NumeralDateProps<DateType extends NumeralDateObject = FullDate>
94
96
  isOptional?: boolean;
95
97
  }
96
98
  export declare type ValidDateFormat = (typeof ALLOWED_DATE_FORMATS)[number];
97
- export declare const NumeralDate: <DateType extends NumeralDateObject = FullDate>({ dateFormat, defaultValue, disabled, error, warning, "data-component": dataComponent, "data-element": dataElement, "data-role": dataRole, info, id, name, onBlur, onChange, value, validationOnLabel, label, labelInline, labelWidth, labelAlign, labelHelp, labelSpacing, fieldHelp, adaptiveLabelBreakpoint, required, isOptional, readOnly, size, enableInternalError, enableInternalWarning, tooltipPosition, helpAriaLabel, dayRef, monthRef, yearRef, ...rest }: NumeralDateProps<DateType>) => React.JSX.Element;
99
+ export declare const NumeralDate: <DateType extends NumeralDateObject = FullDate>({ dateFormat, defaultValue, disabled, error, warning, "data-component": dataComponent, "data-element": dataElement, "data-role": dataRole, info, id, name, onBlur, onChange, value, validationOnLabel, label, labelInline, labelWidth, labelAlign, fieldLabelsAlign, labelHelp, labelSpacing, fieldHelp, adaptiveLabelBreakpoint, required, isOptional, readOnly, size, enableInternalError, enableInternalWarning, tooltipPosition, helpAriaLabel, dayRef, monthRef, yearRef, ...rest }: NumeralDateProps<DateType>) => React.JSX.Element;
98
100
  export default NumeralDate;
@@ -106,6 +106,7 @@ const NumeralDate = ({
106
106
  labelInline,
107
107
  labelWidth,
108
108
  labelAlign,
109
+ fieldLabelsAlign,
109
110
  labelHelp,
110
111
  labelSpacing,
111
112
  fieldHelp,
@@ -271,9 +272,9 @@ const NumeralDate = ({
271
272
  isYearInput: datePart.length === 4,
272
273
  hasValidationIconInField: !validationOnLabel && isEnd && validationInField
273
274
  }, /*#__PURE__*/_react.default.createElement(_textbox.default, _extends({
274
- maxWidth: "fit-content",
275
275
  id: inputIds.current[datePart],
276
276
  label: getDateLabel(datePart, locale),
277
+ labelAlign: fieldLabelsAlign,
277
278
  disabled: disabled,
278
279
  readOnly: readOnly,
279
280
  error: !!internalError,
@@ -303,6 +304,9 @@ const NumeralDate = ({
303
304
  "data-role": dataRole,
304
305
  id: uniqueId,
305
306
  legend: label,
307
+ legendMargin: {
308
+ mb: 0
309
+ },
306
310
  isRequired: required,
307
311
  isOptional: isOptional,
308
312
  isDisabled: disabled,
@@ -311,6 +315,7 @@ const NumeralDate = ({
311
315
  warning: validationOnLabel && internalWarning,
312
316
  info: validationOnLabel && info,
313
317
  inline: inline,
318
+ size: size,
314
319
  labelHelp: labelHelp,
315
320
  legendAlign: labelAlign,
316
321
  legendWidth: labelWidth,
@@ -318,8 +323,9 @@ const NumeralDate = ({
318
323
  validationId: validationId,
319
324
  "aria-describedby": ariaDescribedBy
320
325
  }, (0, _utils.filterStyledSystemMarginProps)(rest)), /*#__PURE__*/_react.default.createElement(_box.default, {
321
- display: "block",
322
- mt: 1
326
+ display: "flex",
327
+ flexDirection: "column",
328
+ mt: inline ? 0 : 1
323
329
  }, renderInputs(), fieldHelp && /*#__PURE__*/_react.default.createElement(_fieldHelp.default, {
324
330
  id: fieldHelpId
325
331
  }, fieldHelp))));
@@ -330,6 +336,10 @@ const NumeralDate = ({
330
336
  "data-role": dataRole,
331
337
  id: uniqueId,
332
338
  legend: label,
339
+ legendMargin: {
340
+ mb: 0
341
+ },
342
+ legendAlign: labelAlign,
333
343
  isRequired: required,
334
344
  isOptional: isOptional,
335
345
  isDisabled: disabled,
@@ -339,7 +349,7 @@ const NumeralDate = ({
339
349
  id: inputHintId.current
340
350
  }, labelHelp), /*#__PURE__*/_react.default.createElement(_box.default, {
341
351
  position: "relative",
342
- mt: 1
352
+ mt: labelHelp ? 0 : 1
343
353
  }, (internalError || internalWarning) && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_validationMessage.default, {
344
354
  error: internalError,
345
355
  warning: internalWarning,
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ import { FieldsetProps } from "../../__internal__/fieldset";
2
3
  interface StyledDateFieldProps {
3
4
  isYearInput?: boolean;
4
5
  hasValidationIconInField: boolean;
@@ -8,5 +9,9 @@ export declare const StyledNumeralDate: import("styled-components").StyledCompon
8
9
  name?: string | undefined;
9
10
  }, never>;
10
11
  export declare const StyledDateField: import("styled-components").StyledComponent<"div", any, StyledDateFieldProps, never>;
11
- export declare const StyledFieldset: import("styled-components").StyledComponent<({ legend, children, inline, legendWidth, legendAlign, legendSpacing, error, warning, info, isRequired, blockGroupBehaviour, legendMargin, isDisabled, isOptional, labelHelp, validationId, ...rest }: import("../../__internal__/fieldset").FieldsetProps) => import("react").JSX.Element, any, {}, never>;
12
+ interface StyledFieldsetProps extends FieldsetProps {
13
+ inline?: boolean;
14
+ size?: "small" | "medium" | "large";
15
+ }
16
+ export declare const StyledFieldset: import("styled-components").StyledComponent<({ legend, children, inline, legendWidth, legendAlign, legendSpacing, error, warning, info, isRequired, blockGroupBehaviour, legendMargin, isDisabled, isOptional, labelHelp, validationId, ...rest }: FieldsetProps) => import("react").JSX.Element, any, StyledFieldsetProps, never>;
12
17
  export {};
@@ -55,17 +55,26 @@ const StyledDateField = exports.StyledDateField = _styledComponents.default.div`
55
55
  }
56
56
  `}
57
57
  `;
58
+ // We need to match height of the legend to the input container when it is inline to center it vertically,
59
+ // as Safari does not support display: flex on fieldset elements.
60
+ const sizeHeight = {
61
+ small: "57px",
62
+ medium: "65px",
63
+ large: "73px"
64
+ };
58
65
  const StyledFieldset = exports.StyledFieldset = (0, _styledComponents.default)(_fieldset.default)`
59
66
  ${({
60
- inline
67
+ inline,
68
+ size
61
69
  }) => (0, _styledComponents.css)`
62
70
  ${inline && (0, _styledComponents.css)`
63
- display: flex;
64
- align-items: center;
71
+ ${_fieldset2.StyledLegend} {
72
+ height: ${size && sizeHeight[size]};
73
+ }
65
74
  `}
66
- `}
67
75
 
68
- ${_fieldset2.StyledLegend} {
69
- margin-bottom: 0;
70
- }
76
+ ${!inline && (0, _styledComponents.css)`
77
+ width: min-content;
78
+ `}
79
+ `}
71
80
  `;
@@ -38,7 +38,7 @@ const RadioButtonGroup = props => {
38
38
  inline = false,
39
39
  legendInline = false,
40
40
  legendWidth,
41
- legendAlign,
41
+ legendAlign = "left",
42
42
  legendSpacing,
43
43
  labelSpacing = 1,
44
44
  adaptiveLegendBreakpoint,
@@ -28,6 +28,10 @@ interface TimeInputProps extends Omit<TagProps, "data-component">, Omit<Validati
28
28
  export interface TimeProps extends Omit<TagProps, "data-component">, MarginProps {
29
29
  /** Label text for the component */
30
30
  label?: string;
31
+ /** Label alignment */
32
+ labelAlign?: "left" | "right";
33
+ /** Field labels alignment */
34
+ fieldLabelsAlign?: "left" | "right";
31
35
  /** Sets the size of the inputs */
32
36
  size?: Sizes;
33
37
  /** Additional hint text rendered above the input elements */
@@ -24,6 +24,8 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
24
24
  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); }
25
25
  const Time = /*#__PURE__*/_react.default.forwardRef(({
26
26
  label,
27
+ labelAlign,
28
+ fieldLabelsAlign,
27
29
  size = "medium",
28
30
  inputHint,
29
31
  hoursInputProps = {},
@@ -150,7 +152,8 @@ const Time = /*#__PURE__*/_react.default.forwardRef(({
150
152
  legendMargin: {
151
153
  mb: 0
152
154
  },
153
- width: "fit-content",
155
+ width: "min-content",
156
+ legendAlign: labelAlign,
154
157
  isRequired: required,
155
158
  isOptional: isOptional,
156
159
  isDisabled: disabled,
@@ -162,7 +165,8 @@ const Time = /*#__PURE__*/_react.default.forwardRef(({
162
165
  id: inputHintId.current,
163
166
  isDisabled: disabled
164
167
  }, inputHint), /*#__PURE__*/_react.default.createElement(_box.default, {
165
- position: "relative"
168
+ position: "relative",
169
+ mt: inputHint ? 0 : 1
166
170
  }, /*#__PURE__*/_react.default.createElement(_validationMessage.default, {
167
171
  validationId: validationId,
168
172
  error: error,
@@ -174,7 +178,8 @@ const Time = /*#__PURE__*/_react.default.forwardRef(({
174
178
  }, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_time.StyledLabel, {
175
179
  "aria-label": hrsAriaLabel,
176
180
  htmlFor: internalHrsId.current,
177
- disabled: disabled
181
+ disabled: disabled,
182
+ align: fieldLabelsAlign
178
183
  }, hrsLabel), /*#__PURE__*/_react.default.createElement(_number.default, _extends({}, hoursInputProps, {
179
184
  label: undefined,
180
185
  "data-component": "hours",
@@ -201,7 +206,8 @@ const Time = /*#__PURE__*/_react.default.forwardRef(({
201
206
  }, ":")), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_time.StyledLabel, {
202
207
  "aria-label": minsAriaLabel,
203
208
  htmlFor: internalMinsId.current,
204
- disabled: disabled
209
+ disabled: disabled,
210
+ align: fieldLabelsAlign
205
211
  }, minsLabel), /*#__PURE__*/_react.default.createElement(_number.default, _extends({}, minutesInputProps, {
206
212
  label: undefined,
207
213
  "data-component": "minutes",
@@ -218,7 +224,8 @@ const Time = /*#__PURE__*/_react.default.forwardRef(({
218
224
  }))), showToggle && /*#__PURE__*/_react.default.createElement(_box.default, {
219
225
  display: "flex",
220
226
  flexDirection: "column",
221
- justifyContent: "flex-end"
227
+ justifyContent: "flex-end",
228
+ width: "max-content"
222
229
  }, /*#__PURE__*/_react.default.createElement(_timeToggle.TimeToggle, {
223
230
  toggleProps: toggleProps,
224
231
  size: size,
@@ -233,6 +240,7 @@ if (process.env.NODE_ENV !== "production") {
233
240
  "data-element": _propTypes.default.string,
234
241
  "data-role": _propTypes.default.string,
235
242
  "disabled": _propTypes.default.bool,
243
+ "fieldLabelsAlign": _propTypes.default.oneOf(["left", "right"]),
236
244
  "hoursInputProps": _propTypes.default.shape({
237
245
  "aria-label": _propTypes.default.string,
238
246
  "data-element": _propTypes.default.string,
@@ -245,6 +253,7 @@ if (process.env.NODE_ENV !== "production") {
245
253
  "inputHint": _propTypes.default.string,
246
254
  "isOptional": _propTypes.default.bool,
247
255
  "label": _propTypes.default.string,
256
+ "labelAlign": _propTypes.default.oneOf(["left", "right"]),
248
257
  "m": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
249
258
  "__@toStringTag": _propTypes.default.string.isRequired,
250
259
  "description": _propTypes.default.string,
@@ -18,7 +18,7 @@ const StyledHintText = exports.StyledHintText = _styledComponents.default.div`
18
18
  }
19
19
 
20
20
  margin-top: var(--spacing000);
21
- margin-bottom: var(--spacing150);
21
+ margin-bottom: var(--spacing100);
22
22
  color: ${({
23
23
  isDisabled
24
24
  }) => isDisabled ? "var(--colorsUtilityYin030)" : "var(--colorsUtilityYin055)"};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "147.0.1",
3
+ "version": "147.1.0",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",