@transferwise/components 46.30.1 → 46.31.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 (58) hide show
  1. package/build/index.js +190 -57
  2. package/build/index.js.map +1 -1
  3. package/build/index.mjs +189 -58
  4. package/build/index.mjs.map +1 -1
  5. package/build/types/dateInput/DateInput.d.ts +5 -4
  6. package/build/types/dateInput/DateInput.d.ts.map +1 -1
  7. package/build/types/dateLookup/DateLookup.d.ts +11 -4
  8. package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
  9. package/build/types/field/Field.d.ts +12 -0
  10. package/build/types/field/Field.d.ts.map +1 -0
  11. package/build/types/index.d.ts +4 -0
  12. package/build/types/index.d.ts.map +1 -1
  13. package/build/types/inputs/Input.d.ts.map +1 -1
  14. package/build/types/inputs/SelectInput.d.ts +1 -1
  15. package/build/types/inputs/SelectInput.d.ts.map +1 -1
  16. package/build/types/inputs/TextArea.d.ts.map +1 -1
  17. package/build/types/inputs/_common.d.ts +2 -2
  18. package/build/types/inputs/_common.d.ts.map +1 -1
  19. package/build/types/inputs/contexts.d.ts +24 -0
  20. package/build/types/inputs/contexts.d.ts.map +1 -0
  21. package/build/types/label/Label.d.ts +9 -0
  22. package/build/types/label/Label.d.ts.map +1 -0
  23. package/build/types/phoneNumberInput/PhoneNumberInput.d.ts +1 -1
  24. package/build/types/phoneNumberInput/PhoneNumberInput.d.ts.map +1 -1
  25. package/build/types/radioGroup/RadioGroup.d.ts.map +1 -1
  26. package/build/types/switch/Switch.d.ts +6 -3
  27. package/build/types/switch/Switch.d.ts.map +1 -1
  28. package/package.json +2 -2
  29. package/src/dateInput/DateInput.rtl.spec.tsx +17 -0
  30. package/src/dateInput/DateInput.tsx +28 -22
  31. package/src/dateLookup/DateLookup.keyboardEvents.spec.js +2 -2
  32. package/src/dateLookup/DateLookup.rtl.spec.tsx +21 -0
  33. package/src/dateLookup/DateLookup.state.spec.js +5 -5
  34. package/src/dateLookup/DateLookup.tests.story.tsx +4 -11
  35. package/src/dateLookup/DateLookup.tsx +24 -9
  36. package/src/dateLookup/DateLookup.view.spec.js +11 -11
  37. package/src/field/Field.spec.tsx +95 -0
  38. package/src/field/Field.story.tsx +59 -0
  39. package/src/field/Field.tsx +70 -0
  40. package/src/index.ts +4 -0
  41. package/src/inputs/Input.tsx +5 -3
  42. package/src/inputs/SelectInput.spec.tsx +10 -0
  43. package/src/inputs/SelectInput.tsx +9 -4
  44. package/src/inputs/TextArea.tsx +6 -3
  45. package/src/inputs/_ButtonInput.tsx +2 -2
  46. package/src/inputs/_common.ts +2 -2
  47. package/src/inputs/contexts.tsx +45 -0
  48. package/src/label/Label.spec.tsx +26 -0
  49. package/src/label/Label.story.tsx +37 -0
  50. package/src/label/Label.tsx +20 -0
  51. package/src/phoneNumberInput/PhoneNumberInput.story.tsx +16 -22
  52. package/src/phoneNumberInput/PhoneNumberInput.tsx +14 -2
  53. package/src/radioGroup/RadioGroup.rtl.spec.tsx +14 -0
  54. package/src/radioGroup/RadioGroup.story.tsx +26 -0
  55. package/src/radioGroup/RadioGroup.tsx +4 -1
  56. package/src/switch/Switch.spec.tsx +10 -0
  57. package/src/switch/Switch.tsx +22 -13
  58. package/src/utilities/logActionRequired.js +1 -1
package/build/index.mjs CHANGED
@@ -3,7 +3,7 @@ import React__default, { forwardRef, cloneElement, useState, useEffect, useRef,
3
3
  import { useId } from '@radix-ui/react-id';
4
4
  import classNames from 'classnames';
5
5
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
6
- import { ChevronUp, CrossCircleFill, Cross, NavigateAway, Check, Info as Info$1, Alert as Alert$1, ClockBorderless, Briefcase, Person, AlertCircleFill, ArrowLeft, QuestionMarkCircle, AlertCircle, Search, CrossCircle, ChevronDown, CheckCircleFill, ArrowRight, Download, ClockFill, Upload as Upload$2, Document, Plus, PlusCircle } from '@transferwise/icons';
6
+ import { ChevronUp, CrossCircleFill, Cross, NavigateAway, Check, Info as Info$1, Alert as Alert$1, ClockBorderless, Briefcase, Person, AlertCircleFill, ArrowLeft, AlertCircle, QuestionMarkCircle, Search, CrossCircle, ChevronDown, CheckCircleFill, ArrowRight, Download, ClockFill, Upload as Upload$2, Document, Plus, PlusCircle } from '@transferwise/icons';
7
7
  import { defineMessages, useIntl, injectIntl, IntlProvider } from 'react-intl';
8
8
  import PropTypes from 'prop-types';
9
9
  import commonmark from 'commonmark';
@@ -796,7 +796,7 @@ function Title({
796
796
  }
797
797
 
798
798
  function logActionRequired(message) {
799
- if (['development', 'test'].includes(process?.env?.NODE_ENV)) {
799
+ if (typeof process !== 'undefined' && process.env?.NODE_ENV !== 'production') {
800
800
  // eslint-disable-next-line no-console
801
801
  console.warn(message);
802
802
  }
@@ -2592,6 +2592,36 @@ const isMonthAndYearFormat = dateString => validDateString(dateString) && dateSt
2592
2592
  const MDY = new Set(['en-US']);
2593
2593
  const YMD = new Set(['hu', 'hu-HU', 'zh-HK', 'zh-CN', 'ja', 'ja-JP']);
2594
2594
 
2595
+ const FieldLabelIdContext = /*#__PURE__*/createContext(undefined);
2596
+ const FieldLabelIdContextProvider = FieldLabelIdContext.Provider;
2597
+ const InputIdContext = /*#__PURE__*/createContext(undefined);
2598
+ const InputIdContextProvider = InputIdContext.Provider;
2599
+ const InputDescribedByContext = /*#__PURE__*/createContext(undefined);
2600
+ const InputDescribedByProvider = InputDescribedByContext.Provider;
2601
+ const InputInvalidContext = /*#__PURE__*/createContext(undefined);
2602
+ const InputInvalidProvider = InputInvalidContext.Provider;
2603
+ function useInputAttributes({
2604
+ nonLabelable
2605
+ } = {}) {
2606
+ const labelId = useContext(FieldLabelIdContext);
2607
+ return {
2608
+ id: useContext(InputIdContext),
2609
+ 'aria-labelledby': nonLabelable ? labelId : undefined,
2610
+ 'aria-describedby': useContext(InputDescribedByContext),
2611
+ 'aria-invalid': useContext(InputInvalidContext)
2612
+ };
2613
+ }
2614
+ function withInputAttributes(Component, args) {
2615
+ function ComponentWithInputAttributes(props) {
2616
+ return /*#__PURE__*/jsx(Component, {
2617
+ inputAttributes: useInputAttributes(args),
2618
+ ...props
2619
+ });
2620
+ }
2621
+ ComponentWithInputAttributes.displayName = `withInputAttributes(${Component.displayName || Component.name || 'Component'})`;
2622
+ return ComponentWithInputAttributes;
2623
+ }
2624
+
2595
2625
  var messages$9 = defineMessages({
2596
2626
  monthLabel: {
2597
2627
  id: "neptune.DateInput.month.label"
@@ -2616,7 +2646,7 @@ const convertToLocalMidnight = date => {
2616
2646
  };
2617
2647
 
2618
2648
  const DateInput = ({
2619
- 'aria-labelledby': ariaLabelledBy,
2649
+ 'aria-labelledby': ariaLabelledByProp,
2620
2650
  'aria-label': ariaLabel,
2621
2651
  disabled = false,
2622
2652
  size = Size.MEDIUM,
@@ -2632,9 +2662,14 @@ const DateInput = ({
2632
2662
  onFocus,
2633
2663
  onBlur,
2634
2664
  placeholders,
2635
- id,
2665
+ id: idProp,
2636
2666
  selectProps = {}
2637
2667
  }) => {
2668
+ const inputAttributes = useInputAttributes({
2669
+ nonLabelable: true
2670
+ });
2671
+ const id = idProp ?? inputAttributes.id;
2672
+ const ariaLabelledBy = ariaLabelledByProp ?? inputAttributes['aria-labelledby'];
2638
2673
  const {
2639
2674
  locale,
2640
2675
  formatMessage
@@ -2671,9 +2706,9 @@ const DateInput = ({
2671
2706
  const [year, setYear] = useState(() => getInitialDate('year'));
2672
2707
  const [lastBroadcastedValue, setLastBroadcastedValue] = useState(getDateObject);
2673
2708
  const monthNames = getMonthNames(locale, monthFormat);
2674
- dayLabel = dayLabel || formatMessage(messages$9.dayLabel);
2675
- monthLabel = monthLabel || formatMessage(messages$9.monthLabel);
2676
- yearLabel = yearLabel || formatMessage(messages$9.yearLabel);
2709
+ dayLabel ||= formatMessage(messages$9.dayLabel);
2710
+ monthLabel ||= formatMessage(messages$9.monthLabel);
2711
+ yearLabel ||= formatMessage(messages$9.yearLabel);
2677
2712
  placeholders = {
2678
2713
  day: placeholders?.day || formatMessage(messages$9.dayPlaceholder),
2679
2714
  month: placeholders?.month || formatMessage(messages$9.monthLabel),
@@ -2864,6 +2899,7 @@ const DateInput = ({
2864
2899
  const yearFirst = YMD.has(locale);
2865
2900
  return /*#__PURE__*/jsx("div", {
2866
2901
  className: "tw-date",
2902
+ ...inputAttributes,
2867
2903
  id: id,
2868
2904
  "aria-labelledby": ariaLabelledBy,
2869
2905
  "aria-label": ariaLabel,
@@ -2883,15 +2919,15 @@ const DateInput = ({
2883
2919
  return /*#__PURE__*/jsxs(Fragment, {
2884
2920
  children: [getMonth(), getDay(), getYear()]
2885
2921
  });
2886
- } else if (yearFirst) {
2922
+ }
2923
+ if (yearFirst) {
2887
2924
  return /*#__PURE__*/jsxs(Fragment, {
2888
2925
  children: [getYear(), getMonth(), getDay()]
2889
2926
  });
2890
- } else {
2891
- return /*#__PURE__*/jsxs(Fragment, {
2892
- children: [getDay(), getMonth(), getYear()]
2893
- });
2894
2927
  }
2928
+ return /*#__PURE__*/jsxs(Fragment, {
2929
+ children: [getDay(), getMonth(), getYear()]
2930
+ });
2895
2931
  })()
2896
2932
  })
2897
2933
  });
@@ -3992,18 +4028,23 @@ class DateLookup extends PureComponent {
3992
4028
  open
3993
4029
  } = this.state;
3994
4030
  const {
4031
+ inputAttributes,
4032
+ id: idProp,
4033
+ 'aria-labelledby': ariaLabelledByProp,
3995
4034
  size,
3996
4035
  placeholder,
3997
4036
  label,
3998
- 'aria-labelledby': ariaLabelledBy,
3999
4037
  monthFormat,
4000
4038
  disabled,
4001
4039
  clearable,
4002
4040
  value
4003
4041
  } = this.props;
4042
+ const id = idProp ?? inputAttributes?.id;
4043
+ const ariaLabelledBy = ariaLabelledByProp ?? inputAttributes?.['aria-labelledby'];
4004
4044
  return /*#__PURE__*/jsxs("div", {
4005
4045
  ref: this.element,
4006
- id: this.props.id,
4046
+ ...inputAttributes,
4047
+ id: id,
4007
4048
  "aria-labelledby": ariaLabelledBy,
4008
4049
  className: "input-group",
4009
4050
  onKeyDown: this.handleKeyDown,
@@ -4027,6 +4068,9 @@ class DateLookup extends PureComponent {
4027
4068
  });
4028
4069
  }
4029
4070
  }
4071
+ var DateLookup$1 = withInputAttributes(DateLookup, {
4072
+ nonLabelable: true
4073
+ });
4030
4074
 
4031
4075
  const NavigationOption = /*#__PURE__*/forwardRef(({
4032
4076
  as: component = 'button',
@@ -4873,6 +4917,84 @@ const FlowNavigation = ({
4873
4917
  });
4874
4918
  };
4875
4919
 
4920
+ function InlineAlert({
4921
+ id,
4922
+ type = 'neutral',
4923
+ className,
4924
+ children
4925
+ }) {
4926
+ const danger = type === 'negative' || type === 'error';
4927
+ return /*#__PURE__*/jsxs("div", {
4928
+ role: "alert",
4929
+ id: id,
4930
+ className: classNames('alert alert-detach', `alert-${danger ? 'danger' : type}`, className),
4931
+ children: [danger && /*#__PURE__*/jsx(AlertCircle, {}), /*#__PURE__*/jsx("div", {
4932
+ children: children
4933
+ })]
4934
+ });
4935
+ }
4936
+
4937
+ const Label = ({
4938
+ id,
4939
+ htmlFor,
4940
+ className,
4941
+ children
4942
+ }) => {
4943
+ return /*#__PURE__*/jsx("label", {
4944
+ id: id,
4945
+ htmlFor: htmlFor,
4946
+ className: classNames('control-label d-flex flex-column gap-y-1 m-b-0', className),
4947
+ children: children
4948
+ });
4949
+ };
4950
+
4951
+ const Field = ({
4952
+ id,
4953
+ label,
4954
+ hint,
4955
+ error,
4956
+ className,
4957
+ children
4958
+ }) => {
4959
+ const hasError = Boolean(error);
4960
+ const hasHint = Boolean(hint) && !hasError;
4961
+ const labelId = useId();
4962
+ const fallbackInputId = useId(); // TODO: Use `React.useId()` when react>=18
4963
+ const inputId = id !== null ? id ?? fallbackInputId : undefined;
4964
+ const descriptionId = useId(); // TODO: Use `React.useId()` when react>=18
4965
+ return /*#__PURE__*/jsx(FieldLabelIdContextProvider, {
4966
+ value: labelId,
4967
+ children: /*#__PURE__*/jsx(InputIdContextProvider, {
4968
+ value: inputId,
4969
+ children: /*#__PURE__*/jsx(InputDescribedByProvider, {
4970
+ value: hasError || hasHint ? descriptionId : undefined,
4971
+ children: /*#__PURE__*/jsx(InputInvalidProvider, {
4972
+ value: hasError,
4973
+ children: /*#__PURE__*/jsxs("div", {
4974
+ className: classNames('form-group d-block', {
4975
+ 'has-error': hasError,
4976
+ 'has-info': hasHint
4977
+ }, className),
4978
+ children: [/*#__PURE__*/jsxs(Label, {
4979
+ id: labelId,
4980
+ htmlFor: inputId,
4981
+ children: [label, children]
4982
+ }), hasHint && /*#__PURE__*/jsx(InlineAlert, {
4983
+ type: Sentiment.NEUTRAL,
4984
+ id: descriptionId,
4985
+ children: hint
4986
+ }), hasError && /*#__PURE__*/jsx(InlineAlert, {
4987
+ type: Sentiment.NEGATIVE,
4988
+ id: descriptionId,
4989
+ children: error
4990
+ })]
4991
+ })
4992
+ })
4993
+ })
4994
+ })
4995
+ });
4996
+ };
4997
+
4876
4998
  const HeaderAction = ({
4877
4999
  action
4878
5000
  }) => {
@@ -5205,20 +5327,16 @@ const Info = ({
5205
5327
  });
5206
5328
  };
5207
5329
 
5208
- function InlineAlert({
5209
- id,
5210
- type = 'neutral',
5211
- className,
5212
- children
5213
- }) {
5214
- const danger = type === 'negative' || type === 'error';
5215
- return /*#__PURE__*/jsxs("div", {
5216
- role: "alert",
5217
- id: id,
5218
- className: classNames('alert alert-detach', `alert-${danger ? 'danger' : type}`, className),
5219
- children: [danger && /*#__PURE__*/jsx(AlertCircle, {}), /*#__PURE__*/jsx("div", {
5220
- children: children
5221
- })]
5330
+ function inputClassNameBase({
5331
+ size = 'auto'
5332
+ } = {}) {
5333
+ return classNames('form-control',
5334
+ // TODO: Deprecate
5335
+ 'np-form-control', {
5336
+ 'np-form-control--size-auto': size === 'auto',
5337
+ 'np-form-control--size-sm': size === 'sm',
5338
+ 'np-form-control--size-md': size === 'md',
5339
+ 'np-form-control--size-lg': size === 'lg'
5222
5340
  });
5223
5341
  }
5224
5342
 
@@ -5340,29 +5458,17 @@ function InputAddon({
5340
5458
  });
5341
5459
  }
5342
5460
 
5343
- function formControlClassNameBase({
5344
- size = 'auto'
5345
- } = {}) {
5346
- return classNames('form-control',
5347
- // TODO: Deprecate
5348
- 'np-form-control', {
5349
- 'np-form-control--size-auto': size === 'auto',
5350
- 'np-form-control--size-sm': size === 'sm',
5351
- 'np-form-control--size-md': size === 'md',
5352
- 'np-form-control--size-lg': size === 'lg'
5353
- });
5354
- }
5355
-
5356
5461
  const Input = /*#__PURE__*/forwardRef(function Input({
5357
5462
  size = 'auto',
5358
5463
  shape = 'rectangle',
5359
5464
  className,
5360
5465
  ...restProps
5361
5466
  }, reference) {
5467
+ const inputAttributes = useInputAttributes();
5362
5468
  const inputPaddings = useInputPaddings();
5363
5469
  return /*#__PURE__*/jsx("input", {
5364
5470
  ref: reference,
5365
- className: classNames(className, formControlClassNameBase({
5471
+ className: classNames(className, inputClassNameBase({
5366
5472
  size
5367
5473
  }), 'np-input', {
5368
5474
  'np-input--shape-rectangle': shape === 'rectangle',
@@ -5371,6 +5477,7 @@ const Input = /*#__PURE__*/forwardRef(function Input({
5371
5477
  // eslint-disable-next-line react/forbid-dom-props
5372
5478
  ,
5373
5479
  style: inputPaddings,
5480
+ ...inputAttributes,
5374
5481
  ...restProps
5375
5482
  });
5376
5483
  });
@@ -5792,12 +5899,6 @@ const PolymorphicWithOverrides = /*#__PURE__*/forwardRef(function PolymorphicWit
5792
5899
  });
5793
5900
  });
5794
5901
 
5795
- var messages$5 = defineMessages({
5796
- noResultsFound: {
5797
- id: "neptune.SelectInput.noResultsFound"
5798
- }
5799
- });
5800
-
5801
5902
  function PreventScroll() {
5802
5903
  usePreventScroll();
5803
5904
  return null;
@@ -5917,7 +6018,7 @@ const ButtonInput = /*#__PURE__*/forwardRef(function ButtonInput({
5917
6018
  return /*#__PURE__*/jsx("button", {
5918
6019
  ref: ref,
5919
6020
  type: "button",
5920
- className: classNames(className, formControlClassNameBase({
6021
+ className: classNames(className, inputClassNameBase({
5921
6022
  size
5922
6023
  }), 'np-button-input')
5923
6024
  // eslint-disable-next-line react/forbid-dom-props
@@ -6033,6 +6134,12 @@ function Popover({
6033
6134
  });
6034
6135
  }
6035
6136
 
6137
+ var messages$5 = defineMessages({
6138
+ noResultsFound: {
6139
+ id: "neptune.SelectInput.noResultsFound"
6140
+ }
6141
+ });
6142
+
6036
6143
  function searchableString(value) {
6037
6144
  return value.trim().replace(/\s+/gu, ' ').normalize('NFKC').toLowerCase();
6038
6145
  }
@@ -6152,7 +6259,7 @@ function SelectInputClearButton({
6152
6259
  }
6153
6260
  const noop = () => {};
6154
6261
  function SelectInput({
6155
- id,
6262
+ id: idProp,
6156
6263
  name,
6157
6264
  multiple,
6158
6265
  placeholder,
@@ -6173,6 +6280,8 @@ function SelectInput({
6173
6280
  onClose,
6174
6281
  onClear
6175
6282
  }) {
6283
+ const inputAttributes = useInputAttributes();
6284
+ const id = idProp ?? inputAttributes.id;
6176
6285
  const [open, setOpen] = useState(false);
6177
6286
  const initialized = useRef(false);
6178
6287
  const handleClose = useEffectEvent(onClose ?? (() => {}));
@@ -6233,6 +6342,7 @@ function SelectInput({
6233
6342
  ref(node);
6234
6343
  triggerRef.current = node;
6235
6344
  },
6345
+ ...inputAttributes,
6236
6346
  id,
6237
6347
  ...mergeProps({
6238
6348
  onClick: () => {
@@ -6586,9 +6696,11 @@ const TextArea = /*#__PURE__*/forwardRef(function TextArea({
6586
6696
  className,
6587
6697
  ...restProps
6588
6698
  }, reference) {
6699
+ const inputAttributes = useInputAttributes();
6589
6700
  return /*#__PURE__*/jsx("textarea", {
6590
6701
  ref: reference,
6591
- className: classNames(className, formControlClassNameBase(), 'np-text-area'),
6702
+ className: classNames(className, inputClassNameBase(), 'np-text-area'),
6703
+ ...inputAttributes,
6592
6704
  ...restProps
6593
6705
  });
6594
6706
  });
@@ -8705,6 +8817,12 @@ const PhoneNumberInput = ({
8705
8817
  return explodeNumberModel(cleanValue);
8706
8818
  });
8707
8819
  const [broadcastedValue, setBroadcastedValue] = useState(null);
8820
+ const [suffixDirty, setSuffixDirty] = useState(false);
8821
+ useEffect(() => {
8822
+ if (internalValue.suffix) {
8823
+ setSuffixDirty(true);
8824
+ }
8825
+ }, [internalValue.suffix]);
8708
8826
  const countriesByPrefix = useMemo(() => groupCountriesByPrefix(sortArrayByProperty(excludeCountries(countries, disabledCountries), 'iso3')), [disabledCountries]);
8709
8827
  const onSuffixChange = event => {
8710
8828
  const suffix = event.target.value;
@@ -8768,6 +8886,11 @@ const PhoneNumberInput = ({
8768
8886
  format: country?.phoneFormat
8769
8887
  }));
8770
8888
  },
8889
+ onClose: () => {
8890
+ if (suffixDirty) {
8891
+ onBlur?.();
8892
+ }
8893
+ },
8771
8894
  ...selectProps
8772
8895
  })
8773
8896
  }), /*#__PURE__*/jsx("div", {
@@ -8787,7 +8910,7 @@ const PhoneNumberInput = ({
8787
8910
  onChange: onSuffixChange,
8788
8911
  onPaste: onPaste,
8789
8912
  onFocus: onFocus,
8790
- onBlur: onBlur
8913
+ onBlur: () => onBlur?.()
8791
8914
  })
8792
8915
  })
8793
8916
  })]
@@ -9334,9 +9457,13 @@ function RadioGroup({
9334
9457
  selectedValue: controlledValue,
9335
9458
  onChange
9336
9459
  }) {
9460
+ const inputAttributes = useInputAttributes({
9461
+ nonLabelable: true
9462
+ });
9337
9463
  const [uncontrolledValue, setUncontrolledValue] = useState(controlledValue);
9338
9464
  return radios.length > 0 ? /*#__PURE__*/jsx("div", {
9339
9465
  role: "radiogroup",
9466
+ ...inputAttributes,
9340
9467
  children: radios.map(({
9341
9468
  value = '',
9342
9469
  ...restProps
@@ -10448,13 +10575,18 @@ const Summary = ({
10448
10575
  };
10449
10576
 
10450
10577
  const Switch = props => {
10578
+ const inputAttributes = useInputAttributes({
10579
+ nonLabelable: true
10580
+ });
10451
10581
  const {
10452
10582
  isModern
10453
10583
  } = useTheme();
10454
10584
  const {
10455
10585
  checked,
10456
10586
  className,
10457
- id,
10587
+ id = inputAttributes.id,
10588
+ 'aria-label': ariaLabel,
10589
+ 'aria-labelledby': ariaLabelledbyProp,
10458
10590
  onClick,
10459
10591
  disabled
10460
10592
  } = props;
@@ -10485,19 +10617,18 @@ const Switch = props => {
10485
10617
  })
10486
10618
  });
10487
10619
  };
10488
- const ariaLabel = props['aria-label'];
10489
- const ariaLabelledby = ariaLabel ? undefined : props['aria-labelledby'];
10490
- logActionRequiredIf('Switch now expects either `aria-label` or `aria-labelledby`, and will soon make these props required. Please update your usage to provide one or the other.', !ariaLabel && !ariaLabelledby);
10620
+ const ariaLabelledby = (ariaLabel ? undefined : ariaLabelledbyProp) ?? inputAttributes['aria-labelledby'];
10491
10621
  return /*#__PURE__*/jsxs("span", {
10492
10622
  className: classNames('np-switch', {
10493
10623
  'np-switch--unchecked': !checked,
10494
10624
  'np-switch--checked': checked,
10495
- disabled: disabled
10625
+ disabled
10496
10626
  }, className),
10497
10627
  tabIndex: 0,
10498
10628
  role: "switch",
10499
10629
  "aria-checked": checked,
10500
10630
  "aria-label": ariaLabel,
10631
+ ...inputAttributes,
10501
10632
  "aria-labelledby": ariaLabelledby,
10502
10633
  id: id,
10503
10634
  "aria-disabled": disabled,
@@ -14353,5 +14484,5 @@ const translations = {
14353
14484
  'zh-HK': zhHK
14354
14485
  };
14355
14486
 
14356
- export { Accordion, ActionButton, ActionOption, Alert, AlertArrowPosition, Avatar, AvatarType, AvatarWrapper, Badge, Card as BaseCard, Body, BottomSheet$1 as BottomSheet, Breakpoint, Button, Card$2 as Card, Checkbox, CheckboxButton$1 as CheckboxButton, CheckboxOption, Chevron, Chip, Chips, CircularButton, ControlType, CriticalCommsBanner, DEFAULT_LANG, DEFAULT_LOCALE, DateInput, DateLookup, DateMode, Decision, DecisionPresentation, DecisionType, DefinitionList$1 as DefinitionList, Dimmer$1 as Dimmer, Direction, DirectionProvider, Display, Drawer$1 as Drawer, DropFade, Emphasis, FileType, FlowNavigation, Header, Image, Info, InfoPresentation, InlineAlert, Input, InputGroup, InputWithDisplayFormat, InstructionsList, LanguageProvider, Layout, Link, ListItem$1 as ListItem, Loader, Logo$1 as Logo, LogoType, Markdown, MarkdownNodeType, Modal, Money, MoneyInput$1 as MoneyInput, MonthFormat, NavigationOption, NavigationOptionList as NavigationOptionsList, Nudge, Option$2 as Option, OverlayHeader$1 as OverlayHeader, PhoneNumberInput, Popover$1 as Popover, Position, Priority, ProcessIndicator$1 as ProcessIndicator, ProfileType, Progress, ProgressBar, PromoCard$1 as PromoCard, PromoCardGroup$1 as PromoCardGroup, Provider, RTL_LANGUAGES, Radio, RadioGroup, RadioOption, SUPPORTED_LANGUAGES, Scroll, SearchInput, Section, SegmentedControl, Select, SelectInput, SelectInputOptionContent, SelectInputTriggerButton, Sentiment, Size, SlidingPanel, SnackbarConsumer, SnackbarContext, SnackbarPortal, SnackbarProvider, Status, StatusIcon, Stepper, Sticky, Summary, Switch, SwitchOption, Tabs$1 as Tabs, TextArea, TextareaWithDisplayFormat, Theme, Title, Tooltip, Type, Typeahead, Typography, Upload$1 as Upload, UploadInput, UploadStep, Variant, Width, adjustLocale, getCountryFromLocale, getDirectionFromLocale, getLangFromLocale, isBrowser, isServerSide, translations, useDirection, useLayout, useScreenSize, useSnackbar };
14487
+ export { Accordion, ActionButton, ActionOption, Alert, AlertArrowPosition, Avatar, AvatarType, AvatarWrapper, Badge, Card as BaseCard, Body, BottomSheet$1 as BottomSheet, Breakpoint, Button, Card$2 as Card, Checkbox, CheckboxButton$1 as CheckboxButton, CheckboxOption, Chevron, Chip, Chips, CircularButton, ControlType, CriticalCommsBanner, DEFAULT_LANG, DEFAULT_LOCALE, DateInput, DateLookup$1 as DateLookup, DateMode, Decision, DecisionPresentation, DecisionType, DefinitionList$1 as DefinitionList, Dimmer$1 as Dimmer, Direction, DirectionProvider, Display, Drawer$1 as Drawer, DropFade, Emphasis, Field, FileType, FlowNavigation, Header, Image, Info, InfoPresentation, InlineAlert, Input, InputGroup, InputWithDisplayFormat, InstructionsList, Label, LanguageProvider, Layout, Link, ListItem$1 as ListItem, Loader, Logo$1 as Logo, LogoType, Markdown, MarkdownNodeType, Modal, Money, MoneyInput$1 as MoneyInput, MonthFormat, NavigationOption, NavigationOptionList as NavigationOptionsList, Nudge, Option$2 as Option, OverlayHeader$1 as OverlayHeader, PhoneNumberInput, Popover$1 as Popover, Position, Priority, ProcessIndicator$1 as ProcessIndicator, ProfileType, Progress, ProgressBar, PromoCard$1 as PromoCard, PromoCardGroup$1 as PromoCardGroup, Provider, RTL_LANGUAGES, Radio, RadioGroup, RadioOption, SUPPORTED_LANGUAGES, Scroll, SearchInput, Section, SegmentedControl, Select, SelectInput, SelectInputOptionContent, SelectInputTriggerButton, Sentiment, Size, SlidingPanel, SnackbarConsumer, SnackbarContext, SnackbarPortal, SnackbarProvider, Status, StatusIcon, Stepper, Sticky, Summary, Switch, SwitchOption, Tabs$1 as Tabs, TextArea, TextareaWithDisplayFormat, Theme, Title, Tooltip, Type, Typeahead, Typography, Upload$1 as Upload, UploadInput, UploadStep, Variant, Width, adjustLocale, getCountryFromLocale, getDirectionFromLocale, getLangFromLocale, isBrowser, isServerSide, translations, useDirection, useLayout, useScreenSize, useSnackbar };
14357
14488
  //# sourceMappingURL=index.mjs.map