carbon-react 144.9.11 → 144.10.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 (35) hide show
  1. package/esm/__internal__/fieldset/fieldset.component.d.ts +5 -1
  2. package/esm/__internal__/fieldset/fieldset.component.js +27 -7
  3. package/esm/__internal__/fieldset/fieldset.style.d.ts +2 -1
  4. package/esm/__internal__/fieldset/fieldset.style.js +4 -1
  5. package/esm/components/date/date.component.js +1 -0
  6. package/esm/components/decimal/decimal.component.js +1 -0
  7. package/esm/components/grouped-character/grouped-character.component.js +1 -0
  8. package/esm/components/number/number.component.js +1 -0
  9. package/esm/components/numeral-date/numeral-date.component.js +142 -105
  10. package/esm/components/numeral-date/numeral-date.style.d.ts +4 -2
  11. package/esm/components/numeral-date/numeral-date.style.js +46 -38
  12. package/esm/components/select/__internal__/select-textbox/select-textbox.component.js +1 -0
  13. package/esm/components/select/filterable-select/filterable-select.component.js +1 -0
  14. package/esm/components/select/multi-select/multi-select.component.js +1 -0
  15. package/esm/components/select/simple-select/simple-select.component.js +1 -0
  16. package/esm/components/textbox/textbox.component.d.ts +2 -0
  17. package/esm/components/textbox/textbox.component.js +4 -2
  18. package/lib/__internal__/fieldset/fieldset.component.d.ts +5 -1
  19. package/lib/__internal__/fieldset/fieldset.component.js +26 -6
  20. package/lib/__internal__/fieldset/fieldset.style.d.ts +2 -1
  21. package/lib/__internal__/fieldset/fieldset.style.js +4 -1
  22. package/lib/components/date/date.component.js +1 -0
  23. package/lib/components/decimal/decimal.component.js +1 -0
  24. package/lib/components/grouped-character/grouped-character.component.js +1 -0
  25. package/lib/components/number/number.component.js +1 -0
  26. package/lib/components/numeral-date/numeral-date.component.js +141 -104
  27. package/lib/components/numeral-date/numeral-date.style.d.ts +4 -2
  28. package/lib/components/numeral-date/numeral-date.style.js +47 -39
  29. package/lib/components/select/__internal__/select-textbox/select-textbox.component.js +1 -0
  30. package/lib/components/select/filterable-select/filterable-select.component.js +1 -0
  31. package/lib/components/select/multi-select/multi-select.component.js +1 -0
  32. package/lib/components/select/simple-select/simple-select.component.js +1 -0
  33. package/lib/components/textbox/textbox.component.d.ts +2 -0
  34. package/lib/components/textbox/textbox.component.js +4 -2
  35. package/package.json +1 -1
@@ -34,6 +34,10 @@ export interface FieldsetProps extends MarginProps {
34
34
  name?: string;
35
35
  /** Set an id value on the component */
36
36
  id?: string;
37
+ /** Content for the Help tooltip */
38
+ labelHelp?: React.ReactNode;
39
+ /** Id for the validation icon tooltip */
40
+ validationId?: string;
37
41
  }
38
- declare const Fieldset: ({ legend, children, inline, legendWidth, legendAlign, legendSpacing, error, warning, info, isRequired, blockGroupBehaviour, legendMargin, isDisabled, isOptional, ...rest }: FieldsetProps) => React.JSX.Element;
42
+ declare const Fieldset: ({ legend, children, inline, legendWidth, legendAlign, legendSpacing, error, warning, info, isRequired, blockGroupBehaviour, legendMargin, isDisabled, isOptional, labelHelp, validationId, ...rest }: FieldsetProps) => React.JSX.Element;
39
43
  export default Fieldset;
@@ -1,11 +1,12 @@
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, { useContext, useEffect, useState } from "react";
3
3
  import PropTypes from "prop-types";
4
- import { StyledFieldset, StyledLegend, StyledLegendContent } from "./fieldset.style";
4
+ import { StyledFieldset, StyledLegend, StyledLegendContent, StyledIconWrapper } from "./fieldset.style";
5
5
  import ValidationIcon from "../validations/validation-icon.component";
6
6
  import NewValidationContext from "../../components/carbon-provider/__internal__/new-validation.context";
7
7
  import { InputGroupBehaviour, InputGroupContext } from "../input-behaviour";
8
8
  import useFormSpacing from "../../hooks/__internal__/useFormSpacing";
9
+ import Help from "../../components/help";
9
10
  const Fieldset = ({
10
11
  legend,
11
12
  children,
@@ -21,6 +22,8 @@ const Fieldset = ({
21
22
  legendMargin = {},
22
23
  isDisabled,
23
24
  isOptional,
25
+ labelHelp,
26
+ validationId,
24
27
  ...rest
25
28
  }) => {
26
29
  const {
@@ -28,6 +31,7 @@ const Fieldset = ({
28
31
  } = useContext(NewValidationContext);
29
32
  const marginProps = useFormSpacing(rest);
30
33
  const [ref, setRef] = useState(null);
34
+ const [isFocused, setFocus] = useState(false);
31
35
  useEffect(() => {
32
36
  if (ref && isRequired) {
33
37
  Array.from(ref.querySelectorAll("input") || /* istanbul ignore next */[]).forEach(el => {
@@ -35,6 +39,27 @@ const Fieldset = ({
35
39
  });
36
40
  }
37
41
  }, [ref, isRequired]);
42
+ const tooltipIcon = () => {
43
+ if (error || warning || info) {
44
+ return /*#__PURE__*/React.createElement(StyledIconWrapper, null, /*#__PURE__*/React.createElement(ValidationIcon, {
45
+ error: error,
46
+ warning: warning,
47
+ info: info,
48
+ tooltipFlipOverrides: ["top", "bottom"],
49
+ tooltipId: validationId
50
+ }));
51
+ }
52
+ const helpProps = {
53
+ onFocus: () => setFocus(true),
54
+ onBlur: () => setFocus(false)
55
+ };
56
+ if (labelHelp) {
57
+ return /*#__PURE__*/React.createElement(StyledIconWrapper, helpProps, /*#__PURE__*/React.createElement(Help, {
58
+ isFocused: isFocused
59
+ }, labelHelp));
60
+ }
61
+ return null;
62
+ };
38
63
  return /*#__PURE__*/React.createElement(InputGroupBehaviour, {
39
64
  blockGroupBehaviour: blockGroupBehaviour
40
65
  }, /*#__PURE__*/React.createElement(StyledFieldset, _extends({
@@ -57,11 +82,6 @@ const Fieldset = ({
57
82
  isRequired: isRequired,
58
83
  isOptional: isOptional,
59
84
  isDisabled: isDisabled
60
- }, legend, !validationRedesignOptIn && /*#__PURE__*/React.createElement(ValidationIcon, {
61
- error: error,
62
- warning: warning,
63
- info: info,
64
- tooltipFlipOverrides: ["top", "bottom"]
65
- })))), children));
85
+ }, legend, !validationRedesignOptIn && tooltipIcon()))), children));
66
86
  };
67
87
  export default Fieldset;
@@ -15,4 +15,5 @@ declare type StyledLegendProps = {
15
15
  rightPadding?: 1 | 2;
16
16
  };
17
17
  declare const StyledLegend: import("styled-components").StyledComponent<"legend", any, StyledLegendProps, never>;
18
- export { StyledFieldset, StyledLegend, StyledLegendContent };
18
+ declare const StyledIconWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
19
+ export { StyledFieldset, StyledLegend, StyledLegendContent, StyledIconWrapper };
@@ -75,4 +75,7 @@ const StyledLegend = styled.legend`
75
75
  `}
76
76
  ${margin}
77
77
  `;
78
- export { StyledFieldset, StyledLegend, StyledLegendContent };
78
+ const StyledIconWrapper = styled.div`
79
+ margin-left: var(--spacing050);
80
+ `;
81
+ export { StyledFieldset, StyledLegend, StyledLegendContent, StyledIconWrapper };
@@ -1131,6 +1131,7 @@ if (process.env.NODE_ENV !== "production") {
1131
1131
  "suppressHydrationWarning": PropTypes.bool,
1132
1132
  "tabIndex": PropTypes.number,
1133
1133
  "title": PropTypes.string,
1134
+ "tooltipId": PropTypes.string,
1134
1135
  "tooltipPosition": PropTypes.oneOf(["bottom", "left", "right", "top"]),
1135
1136
  "translate": PropTypes.oneOf(["no", "yes"]),
1136
1137
  "typeof": PropTypes.string,
@@ -758,6 +758,7 @@ if (process.env.NODE_ENV !== "production") {
758
758
  "suppressHydrationWarning": PropTypes.bool,
759
759
  "tabIndex": PropTypes.number,
760
760
  "title": PropTypes.string,
761
+ "tooltipId": PropTypes.string,
761
762
  "tooltipPosition": PropTypes.oneOf(["bottom", "left", "right", "top"]),
762
763
  "translate": PropTypes.oneOf(["no", "yes"]),
763
764
  "typeof": PropTypes.string,
@@ -685,6 +685,7 @@ if (process.env.NODE_ENV !== "production") {
685
685
  "suppressHydrationWarning": PropTypes.bool,
686
686
  "tabIndex": PropTypes.number,
687
687
  "title": PropTypes.string,
688
+ "tooltipId": PropTypes.string,
688
689
  "tooltipPosition": PropTypes.oneOf(["bottom", "left", "right", "top"]),
689
690
  "translate": PropTypes.oneOf(["no", "yes"]),
690
691
  "typeof": PropTypes.string,
@@ -624,6 +624,7 @@ if (process.env.NODE_ENV !== "production") {
624
624
  "suppressHydrationWarning": PropTypes.bool,
625
625
  "tabIndex": PropTypes.number,
626
626
  "title": PropTypes.string,
627
+ "tooltipId": PropTypes.string,
627
628
  "tooltipPosition": PropTypes.oneOf(["bottom", "left", "right", "top"]),
628
629
  "translate": PropTypes.oneOf(["no", "yes"]),
629
630
  "typeof": PropTypes.string,
@@ -4,21 +4,20 @@ import PropTypes from "prop-types";
4
4
  import invariant from "invariant";
5
5
  import { filterStyledSystemMarginProps } from "../../style/utils";
6
6
  import Events from "../../__internal__/utils/helpers/events";
7
- import { StyledNumeralDate, StyledDateField } from "./numeral-date.style";
7
+ import { StyledNumeralDate, StyledDateField, StyledFieldset } from "./numeral-date.style";
8
8
  import Textbox from "../textbox";
9
9
  import Box from "../box";
10
- import Typography from "../typography";
11
10
  import { ErrorBorder, StyledHintText } from "../textbox/textbox.style";
12
11
  import ValidationMessage from "../../__internal__/validation-message";
13
12
  import guid from "../../__internal__/utils/helpers/guid";
14
13
  import useLocale from "../../hooks/__internal__/useLocale";
15
- import FormField from "../../__internal__/form-field";
16
- import { InputGroupBehaviour } from "../../__internal__/input-behaviour";
17
14
  import { TooltipProvider } from "../../__internal__/tooltip-provider";
18
15
  import NewValidationContext from "../carbon-provider/__internal__/new-validation.context";
19
16
  import NumeralDateContext from "./__internal__/numeral-date.context";
20
- import FormSpacingProvider from "../../__internal__/form-spacing-provider";
21
17
  import Logger from "../../__internal__/utils/logger";
18
+ import FieldHelp from "../../__internal__/field-help";
19
+ import useIsAboveBreakpoint from "../../hooks/__internal__/useIsAboveBreakpoint";
20
+ import useInputAccessibility from "../../hooks/__internal__/useInputAccessibility";
22
21
  let deprecateUncontrolledWarnTriggered = false;
23
22
  export const ALLOWED_DATE_FORMATS = [["dd", "mm", "yyyy"], ["mm", "dd", "yyyy"], ["yyyy", "mm", "dd"], ["dd", "mm"], ["mm", "dd"], ["mm", "yyyy"]];
24
23
  const incorrectDateFormatMessage = "Forbidden prop dateFormat supplied to NumeralDate. " + "Only one of these date formats is allowed: " + "['dd', 'mm', 'yyyy'], " + "['mm', 'dd', 'yyyy'], " + "['yyyy', 'mm', 'dd'], " + "['dd', 'mm'], " + "['mm', 'dd'], " + "['mm', 'yyyy']";
@@ -105,7 +104,7 @@ export const NumeralDate = ({
105
104
  required,
106
105
  isOptional,
107
106
  readOnly,
108
- size,
107
+ size = "medium",
109
108
  enableInternalError,
110
109
  enableInternalWarning,
111
110
  tooltipPosition,
@@ -119,14 +118,18 @@ export const NumeralDate = ({
119
118
  const {
120
119
  validationRedesignOptIn
121
120
  } = useContext(NewValidationContext);
122
- const labelInlineWithNewValidation = validationRedesignOptIn ? false : labelInline;
123
121
  const {
124
122
  current: uniqueId
125
123
  } = useRef(id || guid());
124
+ const inputIds = useRef({
125
+ dd: guid(),
126
+ mm: guid(),
127
+ yyyy: guid()
128
+ });
129
+ const inputHintId = useRef(guid());
126
130
  const isControlled = useRef(value !== undefined);
127
131
  const initialValue = isControlled.current ? value : defaultValue;
128
132
  const refs = useRef(dateFormat.map(() => null));
129
- const labelIds = useRef([guid(), guid(), guid()]);
130
133
  const [internalMessages, setInternalMessages] = useState({
131
134
  ...Object.fromEntries(dateFormat.map(datePart => [datePart, ""]))
132
135
  });
@@ -196,109 +199,143 @@ export const NumeralDate = ({
196
199
  deprecateUncontrolledWarnTriggered = true;
197
200
  Logger.deprecate("Uncontrolled behaviour in `Numeral Date` is deprecated and support will soon be removed. Please make sure all your inputs are controlled.");
198
201
  }
199
- return /*#__PURE__*/React.createElement(TooltipProvider, {
200
- helpAriaLabel: helpAriaLabel
201
- }, /*#__PURE__*/React.createElement(InputGroupBehaviour, null, /*#__PURE__*/React.createElement(FormField, _extends({
202
- "data-component": dataComponent,
203
- "data-element": dataElement,
204
- "data-role": dataRole,
205
- disabled: disabled,
206
- useValidationIcon: validationOnLabel,
202
+ const largeScreen = useIsAboveBreakpoint(adaptiveLabelBreakpoint);
203
+ let inline = labelInline;
204
+ if (adaptiveLabelBreakpoint) {
205
+ inline = largeScreen;
206
+ }
207
+ const handleRef = (element, index, inputRef) => {
208
+ refs.current[index] = element;
209
+ if (!inputRef) {
210
+ return;
211
+ }
212
+ if (typeof inputRef === "function") {
213
+ inputRef(element);
214
+ } else {
215
+ inputRef.current = element;
216
+ }
217
+ };
218
+ const {
219
+ validationId,
220
+ fieldHelpId,
221
+ ariaDescribedBy
222
+ } = useInputAccessibility({
207
223
  id: uniqueId,
224
+ // we still want to add the validationId to aria-describedby with the legacy validation
225
+ validationRedesignOptIn: true,
208
226
  error: internalError,
209
227
  warning: internalWarning,
210
- info: info,
211
- label: label,
212
- labelInline: labelInlineWithNewValidation,
213
- labelWidth: labelWidth,
214
- labelAlign: labelAlign,
215
- labelHelp: !validationRedesignOptIn && labelHelp,
216
- labelSpacing: labelSpacing,
217
- fieldHelp: fieldHelp,
218
- adaptiveLabelBreakpoint: adaptiveLabelBreakpoint,
228
+ info,
229
+ fieldHelp
230
+ });
231
+ const combinedAriaDescribedBy = [ariaDescribedBy, inputHintId.current].filter(Boolean).join(" ");
232
+ const renderInputs = () => {
233
+ return /*#__PURE__*/React.createElement(StyledNumeralDate, {
234
+ onKeyDown: onKeyDown
235
+ }, dateFormat.map((datePart, index) => {
236
+ const isEnd = index === dateFormat.length - 1;
237
+ let inputRef;
238
+ const validation = internalError || internalWarning || info;
239
+ const validationInField = !validationRedesignOptIn && typeof validation === "string" && validation !== "";
240
+ switch (datePart.slice(0, 2)) {
241
+ case "dd":
242
+ inputRef = dayRef;
243
+ break;
244
+ case "mm":
245
+ inputRef = monthRef;
246
+ break;
247
+ case "yy":
248
+ inputRef = yearRef;
249
+ break;
250
+ /* istanbul ignore next */
251
+ default:
252
+ break;
253
+ }
254
+ return /*#__PURE__*/React.createElement(NumeralDateContext.Provider, {
255
+ value: {
256
+ disableErrorBorder: true
257
+ },
258
+ key: datePart
259
+ }, /*#__PURE__*/React.createElement(StyledDateField, {
260
+ key: datePart,
261
+ size: size,
262
+ isYearInput: datePart.length === 4,
263
+ hasValidationIconInField: !validationOnLabel && isEnd && validationInField
264
+ }, /*#__PURE__*/React.createElement(Textbox, _extends({
265
+ id: inputIds.current[datePart],
266
+ label: getDateLabel(datePart, locale),
267
+ disabled: disabled,
268
+ readOnly: readOnly,
269
+ error: !!internalError,
270
+ warning: !!internalWarning,
271
+ info: !!info,
272
+ size: size,
273
+ value: dateValue[datePart],
274
+ onChange: e => handleChange(e, datePart),
275
+ onBlur: handleBlur,
276
+ ref: element => handleRef(element, index, inputRef)
277
+ }, isEnd && !validationOnLabel && !validationRedesignOptIn && {
278
+ error: internalError,
279
+ warning: internalWarning,
280
+ info
281
+ }, {
282
+ tooltipPosition: tooltipPosition,
283
+ tooltipId: validationId
284
+ }))));
285
+ }));
286
+ };
287
+ if (!validationRedesignOptIn) {
288
+ return /*#__PURE__*/React.createElement(TooltipProvider, {
289
+ helpAriaLabel: helpAriaLabel
290
+ }, /*#__PURE__*/React.createElement(StyledFieldset, _extends({
291
+ "data-component": dataComponent || "numeral-date",
292
+ "data-element": dataElement,
293
+ "data-role": dataRole,
294
+ id: uniqueId,
295
+ legend: label,
296
+ isRequired: required,
297
+ isOptional: isOptional,
298
+ isDisabled: disabled,
299
+ name: name,
300
+ error: validationOnLabel && internalError,
301
+ warning: validationOnLabel && internalWarning,
302
+ info: validationOnLabel && info,
303
+ inline: inline,
304
+ labelHelp: labelHelp,
305
+ legendAlign: labelAlign,
306
+ legendWidth: labelWidth,
307
+ legendSpacing: labelSpacing,
308
+ validationId: validationId,
309
+ "aria-describedby": ariaDescribedBy
310
+ }, filterStyledSystemMarginProps(rest)), /*#__PURE__*/React.createElement(Box, {
311
+ display: "block",
312
+ mt: 1
313
+ }, renderInputs(), fieldHelp && /*#__PURE__*/React.createElement(FieldHelp, {
314
+ id: fieldHelpId
315
+ }, fieldHelp))));
316
+ }
317
+ return /*#__PURE__*/React.createElement(StyledFieldset, _extends({
318
+ "data-component": dataComponent || "numeral-date",
319
+ "data-element": dataElement,
320
+ "data-role": dataRole,
321
+ id: uniqueId,
322
+ legend: label,
219
323
  isRequired: required,
220
324
  isOptional: isOptional,
221
- validationRedesignOptIn: validationRedesignOptIn
222
- }, filterStyledSystemMarginProps(rest)), validationRedesignOptIn && labelHelp && /*#__PURE__*/React.createElement(StyledHintText, null, labelHelp), /*#__PURE__*/React.createElement(Box, {
223
- position: "relative"
224
- }, validationRedesignOptIn && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ValidationMessage, {
325
+ isDisabled: disabled,
326
+ name: name,
327
+ "aria-describedby": combinedAriaDescribedBy
328
+ }, filterStyledSystemMarginProps(rest)), labelHelp && /*#__PURE__*/React.createElement(StyledHintText, {
329
+ id: inputHintId.current
330
+ }, labelHelp), /*#__PURE__*/React.createElement(Box, {
331
+ position: "relative",
332
+ mt: 1
333
+ }, (internalError || internalWarning) && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ValidationMessage, {
225
334
  error: internalError,
226
- warning: internalWarning
227
- }), (internalError || internalWarning) && /*#__PURE__*/React.createElement(ErrorBorder, {
335
+ warning: internalWarning,
336
+ validationId: validationId
337
+ }), /*#__PURE__*/React.createElement(ErrorBorder, {
228
338
  warning: !!(!internalError && internalWarning)
229
- })), /*#__PURE__*/React.createElement(StyledNumeralDate, {
230
- name: name,
231
- onKeyDown: onKeyDown,
232
- "data-component": "numeral-date"
233
- }, dateFormat.map((datePart, index) => {
234
- const isEnd = index === dateFormat.length - 1;
235
- const labelId = labelIds.current[index];
236
- const validation = internalError || internalWarning || info;
237
- const isStringValidation = typeof validation === "string";
238
- const hasValidationIcon = isStringValidation && !!validation.length;
239
- let inputRef;
240
- switch (datePart.slice(0, 2)) {
241
- case "dd":
242
- inputRef = dayRef;
243
- break;
244
- case "mm":
245
- inputRef = monthRef;
246
- break;
247
- case "yy":
248
- inputRef = yearRef;
249
- break;
250
- /* istanbul ignore next */
251
- default:
252
- break;
253
- }
254
- return /*#__PURE__*/React.createElement(NumeralDateContext.Provider, {
255
- value: {
256
- disableErrorBorder: true
257
- },
258
- key: datePart
259
- }, /*#__PURE__*/React.createElement(StyledDateField, {
260
- key: datePart,
261
- isYearInput: datePart.length === 4,
262
- isEnd: isEnd,
263
- hasValidationIconInField: hasValidationIcon && !validationOnLabel && !validationRedesignOptIn
264
- }, /*#__PURE__*/React.createElement(FormSpacingProvider, {
265
- marginBottom: undefined
266
- }, /*#__PURE__*/React.createElement(Typography, {
267
- mb: "4px",
268
- id: labelId,
269
- "data-role": "numeral-date-input-text"
270
- }, getDateLabel(datePart, locale)), /*#__PURE__*/React.createElement(Textbox, _extends({}, index === 0 && {
271
- id: uniqueId
272
- }, {
273
- disabled: disabled,
274
- readOnly: readOnly,
275
- value: dateValue[datePart],
276
- onChange: e => handleChange(e, datePart),
277
- onBlur: handleBlur,
278
- ref: element => {
279
- refs.current[index] = element;
280
- if (!inputRef) {
281
- return;
282
- }
283
- if (typeof inputRef === "function") {
284
- inputRef(element);
285
- } else {
286
- inputRef.current = element;
287
- }
288
- },
289
- error: !!internalError,
290
- warning: !!internalWarning,
291
- info: !!info
292
- }, isEnd && !validationRedesignOptIn && !validationOnLabel && {
293
- error: internalError,
294
- warning: internalWarning,
295
- info
296
- }, {
297
- size: size,
298
- tooltipPosition: tooltipPosition,
299
- "aria-labelledby": labelId,
300
- required: required
301
- })))));
302
- }))))));
339
+ })), renderInputs()));
303
340
  };
304
341
  export default NumeralDate;
@@ -1,10 +1,12 @@
1
+ /// <reference types="react" />
1
2
  interface StyledDateFieldProps {
2
- isEnd?: boolean;
3
3
  isYearInput?: boolean;
4
- hasValidationIconInField?: boolean;
4
+ hasValidationIconInField: boolean;
5
+ size?: "small" | "medium" | "large";
5
6
  }
6
7
  export declare const StyledNumeralDate: import("styled-components").StyledComponent<"div", any, {
7
8
  name?: string | undefined;
8
9
  }, never>;
9
10
  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>;
10
12
  export {};
@@ -1,54 +1,62 @@
1
1
  import styled, { css } from "styled-components";
2
- import StyledValidationIcon from "../../__internal__/validations/validation-icon.style";
3
2
  import StyledIconSpan from "../../__internal__/input-icon-toggle/input-icon-toggle.style";
4
3
  import StyledInputPresentation from "../../__internal__/input/input-presentation.style";
5
4
  import StyledInput from "../../__internal__/input/input.style";
6
- import StyledFormField from "../../__internal__/form-field/form-field.style";
7
- import StyledLabel from "../../__internal__/label/label.style";
8
- import { StyledHintText } from "../textbox/textbox.style";
5
+ import Fieldset from "../../__internal__/fieldset";
6
+ import { StyledLegend } from "../../__internal__/fieldset/fieldset.style";
7
+ const inputWidth = {
8
+ small: "44px",
9
+ medium: "50px",
10
+ large: "64px"
11
+ };
12
+ const inputWidthYear = hasValidationIconInField => ({
13
+ small: hasValidationIconInField ? "75px" : "66px",
14
+ medium: "80px",
15
+ large: "84px"
16
+ });
9
17
  export const StyledNumeralDate = styled.div`
10
18
  display: inline-flex;
11
- font-size: 14px;
12
- font-weight: 400;
13
-
14
- ${StyledFormField} {
15
- margin-top: 0px;
16
- }
17
- ${StyledLabel} {
18
- font-weight: 400;
19
- }
20
-
21
- ${StyledHintText} {
22
- color: var(--colorsUtilityYin090);
23
- }
19
+ gap: var(--spacing150);
24
20
  `;
25
21
  export const StyledDateField = styled.div`
26
22
  ${({
27
23
  isYearInput,
28
- isEnd,
29
- hasValidationIconInField
30
- }) => {
31
- return css`
24
+ hasValidationIconInField,
25
+ size
26
+ }) => css`
27
+ ${size && css`
32
28
  ${StyledInputPresentation} {
33
29
  position: relative;
34
- margin-right: ${isEnd ? "0" : "12px"};
35
- min-width: ${isYearInput ? "80px" : "55px"};
30
+ min-width: ${isYearInput ? inputWidthYear(hasValidationIconInField)[size] : inputWidth[size]};
31
+ }
32
+ `}
36
33
 
37
- ${StyledInput} {
38
- text-align: center;
39
- padding: 0 12px;
40
- ${hasValidationIconInField && isEnd && "padding-right: 0"}
41
- }
34
+ ${StyledInput} {
35
+ text-align: center;
36
+ ${hasValidationIconInField && "padding-right: 0"}
37
+ }
42
38
 
43
- ${StyledIconSpan} {
44
- width: 32px;
45
- z-index: 999;
46
- }
39
+ ${StyledIconSpan} {
40
+ width: var(--spacing400);
41
+ z-index: 999;
42
+ }
47
43
 
48
- ${StyledValidationIcon} {
49
- z-index: 9000;
50
- }
51
- }
52
- `;
53
- }}
44
+ label {
45
+ font-weight: var(--fontWeights400);
46
+ }
47
+ `}
48
+ `;
49
+ export const StyledFieldset = styled(Fieldset)`
50
+ ${({
51
+ inline
52
+ }) => css`
53
+ ${inline && css`
54
+ display: flex;
55
+ align-items: center;
56
+ `}
57
+ `}
58
+
59
+ ${StyledLegend} {
60
+ margin-bottom: 0;
61
+ }
54
62
  `;
@@ -677,6 +677,7 @@ if (process.env.NODE_ENV !== "production") {
677
677
  "suppressHydrationWarning": PropTypes.bool,
678
678
  "tabIndex": PropTypes.number,
679
679
  "title": PropTypes.string,
680
+ "tooltipId": PropTypes.string,
680
681
  "tooltipPosition": PropTypes.oneOf(["bottom", "left", "right", "top"]),
681
682
  "translate": PropTypes.oneOf(["no", "yes"]),
682
683
  "transparent": PropTypes.bool,
@@ -1058,6 +1058,7 @@ if (process.env.NODE_ENV !== "production") {
1058
1058
  "tabIndex": PropTypes.number,
1059
1059
  "tableHeader": PropTypes.node,
1060
1060
  "title": PropTypes.string,
1061
+ "tooltipId": PropTypes.string,
1061
1062
  "tooltipPosition": PropTypes.oneOf(["bottom", "left", "right", "top"]),
1062
1063
  "translate": PropTypes.oneOf(["no", "yes"]),
1063
1064
  "typeof": PropTypes.string,
@@ -1073,6 +1073,7 @@ if (process.env.NODE_ENV !== "production") {
1073
1073
  "tabIndex": PropTypes.number,
1074
1074
  "tableHeader": PropTypes.node,
1075
1075
  "title": PropTypes.string,
1076
+ "tooltipId": PropTypes.string,
1076
1077
  "tooltipPosition": PropTypes.oneOf(["bottom", "left", "right", "top"]),
1077
1078
  "translate": PropTypes.oneOf(["no", "yes"]),
1078
1079
  "typeof": PropTypes.string,
@@ -934,6 +934,7 @@ if (process.env.NODE_ENV !== "production") {
934
934
  "tabIndex": PropTypes.number,
935
935
  "tableHeader": PropTypes.node,
936
936
  "title": PropTypes.string,
937
+ "tooltipId": PropTypes.string,
937
938
  "tooltipPosition": PropTypes.oneOf(["bottom", "left", "right", "top"]),
938
939
  "translate": PropTypes.oneOf(["no", "yes"]),
939
940
  "transparent": PropTypes.bool,
@@ -94,6 +94,8 @@ export interface CommonTextboxProps extends ValidationProps, MarginProps, Omit<C
94
94
  helpAriaLabel?: string;
95
95
  /** Flag to configure component as optional. */
96
96
  isOptional?: boolean;
97
+ /** The id attribute for the validation tooltip */
98
+ tooltipId?: string;
97
99
  }
98
100
  export interface TextboxProps extends CommonTextboxProps {
99
101
  /** Content to be rendered next to the input */
@@ -74,6 +74,7 @@ const Textbox = /*#__PURE__*/React.forwardRef(({
74
74
  "data-role": dataRole,
75
75
  characterLimit,
76
76
  helpAriaLabel,
77
+ tooltipId,
77
78
  ...props
78
79
  }, ref) => {
79
80
  const characterCountValue = typeof value === "string" ? value : "";
@@ -161,7 +162,7 @@ const Textbox = /*#__PURE__*/React.forwardRef(({
161
162
  placeholder: disabled || readOnly ? "" : placeholder,
162
163
  readOnly: readOnly,
163
164
  value: typeof formattedValue === "string" ? formattedValue : value,
164
- validationIconId: validationRedesignOptIn ? undefined : validationId
165
+ validationIconId: validationRedesignOptIn ? undefined : tooltipId || validationId
165
166
  }, props)), children, /*#__PURE__*/React.createElement(InputIconToggle, {
166
167
  align: align,
167
168
  disabled: disabled,
@@ -175,7 +176,7 @@ const Textbox = /*#__PURE__*/React.forwardRef(({
175
176
  size: size,
176
177
  useValidationIcon: !(validationRedesignOptIn || validationOnLabel),
177
178
  warning: warning,
178
- validationIconId: validationRedesignOptIn ? undefined : validationId
179
+ validationIconId: validationRedesignOptIn ? undefined : tooltipId || validationId
179
180
  }));
180
181
  return /*#__PURE__*/React.createElement(TooltipProvider, {
181
182
  helpAriaLabel: helpAriaLabel,
@@ -790,6 +791,7 @@ if (process.env.NODE_ENV !== "production") {
790
791
  "suppressHydrationWarning": PropTypes.bool,
791
792
  "tabIndex": PropTypes.number,
792
793
  "title": PropTypes.string,
794
+ "tooltipId": PropTypes.string,
793
795
  "tooltipPosition": PropTypes.oneOf(["bottom", "left", "right", "top"]),
794
796
  "translate": PropTypes.oneOf(["no", "yes"]),
795
797
  "typeof": PropTypes.string,
@@ -34,6 +34,10 @@ export interface FieldsetProps extends MarginProps {
34
34
  name?: string;
35
35
  /** Set an id value on the component */
36
36
  id?: string;
37
+ /** Content for the Help tooltip */
38
+ labelHelp?: React.ReactNode;
39
+ /** Id for the validation icon tooltip */
40
+ validationId?: string;
37
41
  }
38
- declare const Fieldset: ({ legend, children, inline, legendWidth, legendAlign, legendSpacing, error, warning, info, isRequired, blockGroupBehaviour, legendMargin, isDisabled, isOptional, ...rest }: FieldsetProps) => React.JSX.Element;
42
+ declare const Fieldset: ({ legend, children, inline, legendWidth, legendAlign, legendSpacing, error, warning, info, isRequired, blockGroupBehaviour, legendMargin, isDisabled, isOptional, labelHelp, validationId, ...rest }: FieldsetProps) => React.JSX.Element;
39
43
  export default Fieldset;