carbon-react 153.4.0 → 153.5.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 (31) hide show
  1. package/esm/__internal__/fieldset/fieldset.component.js +4 -0
  2. package/esm/__internal__/fieldset/fieldset.style.d.ts +1 -0
  3. package/esm/__internal__/fieldset/fieldset.style.js +3 -2
  4. package/esm/__internal__/label/label.component.js +5 -1
  5. package/esm/__internal__/label/label.style.d.ts +2 -0
  6. package/esm/__internal__/label/label.style.js +3 -2
  7. package/esm/components/fieldset/fieldset.component.js +5 -1
  8. package/esm/components/fieldset/fieldset.style.d.ts +2 -0
  9. package/esm/components/fieldset/fieldset.style.js +3 -2
  10. package/esm/locales/de-de.js +3 -0
  11. package/esm/locales/en-gb.js +3 -0
  12. package/esm/locales/es-es.js +3 -0
  13. package/esm/locales/fr-ca.js +3 -0
  14. package/esm/locales/fr-fr.js +3 -0
  15. package/esm/locales/locale.d.ts +3 -0
  16. package/lib/__internal__/fieldset/fieldset.component.js +4 -0
  17. package/lib/__internal__/fieldset/fieldset.style.d.ts +1 -0
  18. package/lib/__internal__/fieldset/fieldset.style.js +3 -2
  19. package/lib/__internal__/label/label.component.js +5 -1
  20. package/lib/__internal__/label/label.style.d.ts +2 -0
  21. package/lib/__internal__/label/label.style.js +3 -2
  22. package/lib/components/fieldset/fieldset.component.js +5 -1
  23. package/lib/components/fieldset/fieldset.style.d.ts +2 -0
  24. package/lib/components/fieldset/fieldset.style.js +3 -2
  25. package/lib/locales/de-de.js +3 -0
  26. package/lib/locales/en-gb.js +3 -0
  27. package/lib/locales/es-es.js +3 -0
  28. package/lib/locales/fr-ca.js +3 -0
  29. package/lib/locales/fr-fr.js +3 -0
  30. package/lib/locales/locale.d.ts +3 -0
  31. package/package.json +1 -1
@@ -7,6 +7,7 @@ import { InputGroupBehaviour, InputGroupContext } from "../input-behaviour";
7
7
  import Help from "../../components/help";
8
8
  import Typography from "../../components/typography";
9
9
  import { filterStyledSystemMarginProps } from "../../style/utils";
10
+ import useLocale from "../../hooks/__internal__/useLocale";
10
11
  const Fieldset = ({
11
12
  legend,
12
13
  children,
@@ -32,6 +33,8 @@ const Fieldset = ({
32
33
  const marginProps = filterStyledSystemMarginProps(rest);
33
34
  const [ref, setRef] = useState(null);
34
35
  const [isFocused, setFocus] = useState(false);
36
+ const locale = useLocale();
37
+ const optionalLabel = locale.label.optional();
35
38
  useEffect(() => {
36
39
  if (ref && isRequired) {
37
40
  Array.from(ref.querySelectorAll("input") || /* istanbul ignore next */[]).forEach(el => {
@@ -90,6 +93,7 @@ const Fieldset = ({
90
93
  }), /*#__PURE__*/React.createElement(StyledLegendContent, {
91
94
  isRequired: isRequired,
92
95
  isOptional: isOptional,
96
+ optionalLabel: optionalLabel,
93
97
  isDisabled: isDisabled
94
98
  }, legend, !validationRedesignOptIn && tooltipIcon()))), !validationRedesignOptIn && /*#__PURE__*/React.createElement(Typography, {
95
99
  screenReaderOnly: true,
@@ -6,6 +6,7 @@ type StyledLegendContentProps = {
6
6
  isRequired?: boolean;
7
7
  isOptional?: boolean;
8
8
  isDisabled?: boolean;
9
+ optionalLabel?: string;
9
10
  };
10
11
  declare const StyledLegendContent: import("styled-components").StyledComponent<"span", any, StyledLegendContentProps, never>;
11
12
  export type StyledLegendProps = {
@@ -35,10 +35,11 @@ const StyledLegendContent = styled.span`
35
35
  `}
36
36
 
37
37
  ${({
38
- isOptional
38
+ isOptional,
39
+ optionalLabel
39
40
  }) => isOptional && css`
40
41
  ::after {
41
- content: "(optional)";
42
+ content: "(${optionalLabel})";
42
43
  color: var(--colorsUtilityYin055);
43
44
  font-weight: var(--fontWeights400);
44
45
  margin-left: var(--spacing050);
@@ -6,6 +6,7 @@ import ValidationIcon from "../validations/validation-icon.component";
6
6
  import StyledIconWrapper from "./icon-wrapper.style";
7
7
  import { InputContext, InputGroupContext } from "../input-behaviour";
8
8
  import createGuid from "../../__internal__/utils/helpers/guid";
9
+ import useLocale from "../../hooks/__internal__/useLocale";
9
10
  const shouldDisplayValidationIcon = ({
10
11
  error,
11
12
  warning,
@@ -58,6 +59,8 @@ export const Label = ({
58
59
  onMouseLeave: onGroupMouseLeave
59
60
  } = useContext(InputGroupContext);
60
61
  const guid = useRef(createGuid());
62
+ const locale = useLocale();
63
+ const optionalLabel = locale.label.optional();
61
64
  const handleMouseEnter = () => {
62
65
  if (onMouseEnter) onMouseEnter();
63
66
  if (onGroupMouseEnter) onGroupMouseEnter();
@@ -115,7 +118,8 @@ export const Label = ({
115
118
  optional: optional,
116
119
  pr: pr,
117
120
  pl: pl,
118
- className: className
121
+ className: className,
122
+ optionalLabel: optionalLabel
119
123
  }, /*#__PURE__*/React.createElement(StyledLabel, _extends({
120
124
  "data-element": "label",
121
125
  disabled: disabled,
@@ -20,6 +20,8 @@ export interface StyledLabelContainerProps {
20
20
  pl?: 1 | 2;
21
21
  /** Label width */
22
22
  width?: number;
23
+ /** Text used for the optional label */
24
+ optionalLabel?: string;
23
25
  }
24
26
  export declare const StyledLabelContainer: import("styled-components").StyledComponent<"div", any, StyledLabelContainerProps, never>;
25
27
  export default StyledLabel;
@@ -54,10 +54,11 @@ export const StyledLabelContainer = styled.div`
54
54
  `}
55
55
 
56
56
  ${({
57
- optional
57
+ optional,
58
+ optionalLabel
58
59
  }) => optional && css`
59
60
  ::after {
60
- content: "(optional)";
61
+ content: "(${optionalLabel})";
61
62
  font-weight: var(--fontWeights400);
62
63
  margin-left: var(--spacing050);
63
64
  color: var(--colorsUtilityYin055);
@@ -4,6 +4,7 @@ import tagComponent from "../../__internal__/utils/helpers/tags";
4
4
  import { FieldsetStyle, StyledLegend } from "./fieldset.style";
5
5
  import NewValidationContext from "../carbon-provider/__internal__/new-validation.context";
6
6
  import { filterStyledSystemMarginProps } from "../../style/utils";
7
+ import useLocale from "../../hooks/__internal__/useLocale";
7
8
  export const Fieldset = ({
8
9
  children,
9
10
  legend,
@@ -16,6 +17,8 @@ export const Fieldset = ({
16
17
  const {
17
18
  validationRedesignOptIn
18
19
  } = useContext(NewValidationContext);
20
+ const locale = useLocale();
21
+ const optionalLabel = locale.label.optional();
19
22
  useEffect(() => {
20
23
  if (ref && required) {
21
24
  Array.from(ref.querySelectorAll("input") || /* istanbul ignore next */[]).forEach(el => {
@@ -29,7 +32,8 @@ export const Fieldset = ({
29
32
  }, rest, marginProps, tagComponent("fieldset", rest)), legend && /*#__PURE__*/React.createElement(StyledLegend, {
30
33
  "data-element": "legend",
31
34
  isRequired: required,
32
- isOptional: isOptional
35
+ isOptional: isOptional,
36
+ optionalLabel: optionalLabel
33
37
  }, legend), children);
34
38
  };
35
39
  Fieldset.displayName = "Fieldset";
@@ -7,6 +7,8 @@ export interface StyledLegendProps {
7
7
  isRequired?: boolean;
8
8
  /** Flag to configure fields as optional. */
9
9
  isOptional?: boolean;
10
+ /** Text used for the optional label */
11
+ optionalLabel?: string;
10
12
  }
11
13
  declare const StyledLegend: import("styled-components").StyledComponent<"legend", any, StyledLegendProps, never>;
12
14
  export { FieldsetStyle, StyledLegend };
@@ -56,10 +56,11 @@ const StyledLegend = styled.legend`
56
56
  `}
57
57
 
58
58
  ${({
59
- isOptional
59
+ isOptional,
60
+ optionalLabel
60
61
  }) => isOptional && css`
61
62
  ::after {
62
- content: "(optional)";
63
+ content: "(${optionalLabel})";
63
64
  color: var(--colorsUtilityYin055);
64
65
  font-weight: var(--fontWeights400);
65
66
  margin-left: var(--spacing050);
@@ -82,6 +82,9 @@ const deDE = {
82
82
  heading: {
83
83
  backLinkAriaLabel: () => "Zurück"
84
84
  },
85
+ label: {
86
+ optional: () => "optional"
87
+ },
85
88
  link: {
86
89
  skipLinkLabel: () => "Zum Hauptinhalt springen"
87
90
  },
@@ -86,6 +86,9 @@ const enGB = {
86
86
  heading: {
87
87
  backLinkAriaLabel: () => "Back"
88
88
  },
89
+ label: {
90
+ optional: () => "optional"
91
+ },
89
92
  link: {
90
93
  skipLinkLabel: () => "Skip to main content"
91
94
  },
@@ -83,6 +83,9 @@ const esES = {
83
83
  heading: {
84
84
  backLinkAriaLabel: () => "Volver"
85
85
  },
86
+ label: {
87
+ optional: () => "opcional"
88
+ },
86
89
  link: {
87
90
  skipLinkLabel: () => "Ir al contenido principal"
88
91
  },
@@ -83,6 +83,9 @@ const frCA = {
83
83
  heading: {
84
84
  backLinkAriaLabel: () => "Retour"
85
85
  },
86
+ label: {
87
+ optional: () => "facultatif"
88
+ },
86
89
  link: {
87
90
  skipLinkLabel: () => "Passer au contenu principal"
88
91
  },
@@ -83,6 +83,9 @@ const frFR = {
83
83
  heading: {
84
84
  backLinkAriaLabel: () => "Retour"
85
85
  },
86
+ label: {
87
+ optional: () => "facultatif"
88
+ },
86
89
  link: {
87
90
  skipLinkLabel: () => "Passer au contenu principal"
88
91
  },
@@ -69,6 +69,9 @@ interface Locale {
69
69
  heading: {
70
70
  backLinkAriaLabel: () => string;
71
71
  };
72
+ label: {
73
+ optional: () => string;
74
+ };
72
75
  link: {
73
76
  skipLinkLabel: () => string;
74
77
  };
@@ -12,6 +12,7 @@ var _inputBehaviour = require("../input-behaviour");
12
12
  var _help = _interopRequireDefault(require("../../components/help"));
13
13
  var _typography = _interopRequireDefault(require("../../components/typography"));
14
14
  var _utils = require("../../style/utils");
15
+ var _useLocale = _interopRequireDefault(require("../../hooks/__internal__/useLocale"));
15
16
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
17
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
17
18
  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; }
@@ -41,6 +42,8 @@ const Fieldset = ({
41
42
  const marginProps = (0, _utils.filterStyledSystemMarginProps)(rest);
42
43
  const [ref, setRef] = (0, _react.useState)(null);
43
44
  const [isFocused, setFocus] = (0, _react.useState)(false);
45
+ const locale = (0, _useLocale.default)();
46
+ const optionalLabel = locale.label.optional();
44
47
  (0, _react.useEffect)(() => {
45
48
  if (ref && isRequired) {
46
49
  Array.from(ref.querySelectorAll("input") || /* istanbul ignore next */[]).forEach(el => {
@@ -99,6 +102,7 @@ const Fieldset = ({
99
102
  }), /*#__PURE__*/_react.default.createElement(_fieldset.StyledLegendContent, {
100
103
  isRequired: isRequired,
101
104
  isOptional: isOptional,
105
+ optionalLabel: optionalLabel,
102
106
  isDisabled: isDisabled
103
107
  }, legend, !validationRedesignOptIn && tooltipIcon()))), !validationRedesignOptIn && /*#__PURE__*/_react.default.createElement(_typography.default, {
104
108
  screenReaderOnly: true,
@@ -6,6 +6,7 @@ type StyledLegendContentProps = {
6
6
  isRequired?: boolean;
7
7
  isOptional?: boolean;
8
8
  isDisabled?: boolean;
9
+ optionalLabel?: string;
9
10
  };
10
11
  declare const StyledLegendContent: import("styled-components").StyledComponent<"span", any, StyledLegendContentProps, never>;
11
12
  export type StyledLegendProps = {
@@ -44,10 +44,11 @@ const StyledLegendContent = exports.StyledLegendContent = _styledComponents.defa
44
44
  `}
45
45
 
46
46
  ${({
47
- isOptional
47
+ isOptional,
48
+ optionalLabel
48
49
  }) => isOptional && (0, _styledComponents.css)`
49
50
  ::after {
50
- content: "(optional)";
51
+ content: "(${optionalLabel})";
51
52
  color: var(--colorsUtilityYin055);
52
53
  font-weight: var(--fontWeights400);
53
54
  margin-left: var(--spacing050);
@@ -11,6 +11,7 @@ var _validationIcon = _interopRequireDefault(require("../validations/validation-
11
11
  var _iconWrapper = _interopRequireDefault(require("./icon-wrapper.style"));
12
12
  var _inputBehaviour = require("../input-behaviour");
13
13
  var _guid = _interopRequireDefault(require("../../__internal__/utils/helpers/guid"));
14
+ var _useLocale = _interopRequireDefault(require("../../hooks/__internal__/useLocale"));
14
15
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
16
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
16
17
  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; }
@@ -67,6 +68,8 @@ const Label = ({
67
68
  onMouseLeave: onGroupMouseLeave
68
69
  } = (0, _react.useContext)(_inputBehaviour.InputGroupContext);
69
70
  const guid = (0, _react.useRef)((0, _guid.default)());
71
+ const locale = (0, _useLocale.default)();
72
+ const optionalLabel = locale.label.optional();
70
73
  const handleMouseEnter = () => {
71
74
  if (onMouseEnter) onMouseEnter();
72
75
  if (onGroupMouseEnter) onGroupMouseEnter();
@@ -124,7 +127,8 @@ const Label = ({
124
127
  optional: optional,
125
128
  pr: pr,
126
129
  pl: pl,
127
- className: className
130
+ className: className,
131
+ optionalLabel: optionalLabel
128
132
  }, /*#__PURE__*/_react.default.createElement(_label.default, _extends({
129
133
  "data-element": "label",
130
134
  disabled: disabled,
@@ -20,6 +20,8 @@ export interface StyledLabelContainerProps {
20
20
  pl?: 1 | 2;
21
21
  /** Label width */
22
22
  width?: number;
23
+ /** Text used for the optional label */
24
+ optionalLabel?: string;
23
25
  }
24
26
  export declare const StyledLabelContainer: import("styled-components").StyledComponent<"div", any, StyledLabelContainerProps, never>;
25
27
  export default StyledLabel;
@@ -62,10 +62,11 @@ const StyledLabelContainer = exports.StyledLabelContainer = _styledComponents.de
62
62
  `}
63
63
 
64
64
  ${({
65
- optional
65
+ optional,
66
+ optionalLabel
66
67
  }) => optional && (0, _styledComponents.css)`
67
68
  ::after {
68
- content: "(optional)";
69
+ content: "(${optionalLabel})";
69
70
  font-weight: var(--fontWeights400);
70
71
  margin-left: var(--spacing050);
71
72
  color: var(--colorsUtilityYin055);
@@ -9,6 +9,7 @@ var _tags = _interopRequireDefault(require("../../__internal__/utils/helpers/tag
9
9
  var _fieldset = require("./fieldset.style");
10
10
  var _newValidation = _interopRequireDefault(require("../carbon-provider/__internal__/new-validation.context"));
11
11
  var _utils = require("../../style/utils");
12
+ var _useLocale = _interopRequireDefault(require("../../hooks/__internal__/useLocale"));
12
13
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
14
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
14
15
  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; }
@@ -25,6 +26,8 @@ const Fieldset = ({
25
26
  const {
26
27
  validationRedesignOptIn
27
28
  } = (0, _react.useContext)(_newValidation.default);
29
+ const locale = (0, _useLocale.default)();
30
+ const optionalLabel = locale.label.optional();
28
31
  (0, _react.useEffect)(() => {
29
32
  if (ref && required) {
30
33
  Array.from(ref.querySelectorAll("input") || /* istanbul ignore next */[]).forEach(el => {
@@ -38,7 +41,8 @@ const Fieldset = ({
38
41
  }, rest, marginProps, (0, _tags.default)("fieldset", rest)), legend && /*#__PURE__*/_react.default.createElement(_fieldset.StyledLegend, {
39
42
  "data-element": "legend",
40
43
  isRequired: required,
41
- isOptional: isOptional
44
+ isOptional: isOptional,
45
+ optionalLabel: optionalLabel
42
46
  }, legend), children);
43
47
  };
44
48
  exports.Fieldset = Fieldset;
@@ -7,6 +7,8 @@ export interface StyledLegendProps {
7
7
  isRequired?: boolean;
8
8
  /** Flag to configure fields as optional. */
9
9
  isOptional?: boolean;
10
+ /** Text used for the optional label */
11
+ optionalLabel?: string;
10
12
  }
11
13
  declare const StyledLegend: import("styled-components").StyledComponent<"legend", any, StyledLegendProps, never>;
12
14
  export { FieldsetStyle, StyledLegend };
@@ -65,10 +65,11 @@ const StyledLegend = exports.StyledLegend = _styledComponents.default.legend`
65
65
  `}
66
66
 
67
67
  ${({
68
- isOptional
68
+ isOptional,
69
+ optionalLabel
69
70
  }) => isOptional && (0, _styledComponents.css)`
70
71
  ::after {
71
- content: "(optional)";
72
+ content: "(${optionalLabel})";
72
73
  color: var(--colorsUtilityYin055);
73
74
  font-weight: var(--fontWeights400);
74
75
  margin-left: var(--spacing050);
@@ -88,6 +88,9 @@ const deDE = {
88
88
  heading: {
89
89
  backLinkAriaLabel: () => "Zurück"
90
90
  },
91
+ label: {
92
+ optional: () => "optional"
93
+ },
91
94
  link: {
92
95
  skipLinkLabel: () => "Zum Hauptinhalt springen"
93
96
  },
@@ -92,6 +92,9 @@ const enGB = {
92
92
  heading: {
93
93
  backLinkAriaLabel: () => "Back"
94
94
  },
95
+ label: {
96
+ optional: () => "optional"
97
+ },
95
98
  link: {
96
99
  skipLinkLabel: () => "Skip to main content"
97
100
  },
@@ -89,6 +89,9 @@ const esES = {
89
89
  heading: {
90
90
  backLinkAriaLabel: () => "Volver"
91
91
  },
92
+ label: {
93
+ optional: () => "opcional"
94
+ },
92
95
  link: {
93
96
  skipLinkLabel: () => "Ir al contenido principal"
94
97
  },
@@ -89,6 +89,9 @@ const frCA = {
89
89
  heading: {
90
90
  backLinkAriaLabel: () => "Retour"
91
91
  },
92
+ label: {
93
+ optional: () => "facultatif"
94
+ },
92
95
  link: {
93
96
  skipLinkLabel: () => "Passer au contenu principal"
94
97
  },
@@ -89,6 +89,9 @@ const frFR = {
89
89
  heading: {
90
90
  backLinkAriaLabel: () => "Retour"
91
91
  },
92
+ label: {
93
+ optional: () => "facultatif"
94
+ },
92
95
  link: {
93
96
  skipLinkLabel: () => "Passer au contenu principal"
94
97
  },
@@ -69,6 +69,9 @@ interface Locale {
69
69
  heading: {
70
70
  backLinkAriaLabel: () => string;
71
71
  };
72
+ label: {
73
+ optional: () => string;
74
+ };
72
75
  link: {
73
76
  skipLinkLabel: () => string;
74
77
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "153.4.0",
3
+ "version": "153.5.0",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",