@transferwise/components 46.43.0 → 46.44.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.mjs CHANGED
@@ -2145,6 +2145,7 @@ const Carousel = ({
2145
2145
  }
2146
2146
  },
2147
2147
  href: card.href,
2148
+ target: card.hrefTarget,
2148
2149
  rel: "noreferrer",
2149
2150
  onKeyDown: event => handleOnKeyDown(event, index),
2150
2151
  children: cardContent
@@ -2227,28 +2228,62 @@ const Card = /*#__PURE__*/forwardRef(function Card({
2227
2228
  });
2228
2229
  });
2229
2230
 
2230
- const CheckboxButton = /*#__PURE__*/forwardRef(({
2231
+ const FieldLabelIdContext = /*#__PURE__*/createContext(undefined);
2232
+ const FieldLabelIdContextProvider = FieldLabelIdContext.Provider;
2233
+ const InputIdContext = /*#__PURE__*/createContext(undefined);
2234
+ const InputIdContextProvider = InputIdContext.Provider;
2235
+ const InputDescribedByContext = /*#__PURE__*/createContext(undefined);
2236
+ const InputDescribedByProvider = InputDescribedByContext.Provider;
2237
+ const InputInvalidContext = /*#__PURE__*/createContext(undefined);
2238
+ const InputInvalidProvider = InputInvalidContext.Provider;
2239
+ function useInputAttributes({
2240
+ nonLabelable
2241
+ } = {}) {
2242
+ const labelId = useContext(FieldLabelIdContext);
2243
+ return {
2244
+ id: useContext(InputIdContext),
2245
+ 'aria-labelledby': nonLabelable ? labelId : undefined,
2246
+ 'aria-describedby': useContext(InputDescribedByContext),
2247
+ 'aria-invalid': useContext(InputInvalidContext)
2248
+ };
2249
+ }
2250
+ function withInputAttributes(Component, args) {
2251
+ function ComponentWithInputAttributes(props) {
2252
+ return /*#__PURE__*/jsx(Component, {
2253
+ inputAttributes: useInputAttributes(args),
2254
+ ...props
2255
+ });
2256
+ }
2257
+ ComponentWithInputAttributes.displayName = `withInputAttributes(${Component.displayName || Component.name || 'Component'})`;
2258
+ return ComponentWithInputAttributes;
2259
+ }
2260
+
2261
+ const CheckboxButton = /*#__PURE__*/forwardRef(function CheckboxButton({
2231
2262
  checked,
2232
2263
  className,
2233
2264
  disabled,
2234
2265
  onChange,
2235
2266
  ...rest
2236
- }, reference) => /*#__PURE__*/jsxs("span", {
2237
- className: classNames('np-checkbox-button', className, disabled && 'disabled'),
2238
- children: [/*#__PURE__*/jsx("input", {
2239
- ...rest,
2240
- ref: reference,
2241
- type: "checkbox",
2242
- disabled: disabled,
2243
- checked: checked,
2244
- onChange: onChange
2245
- }), /*#__PURE__*/jsx("span", {
2246
- className: "tw-checkbox-button",
2247
- children: /*#__PURE__*/jsx("span", {
2248
- className: "tw-checkbox-check"
2249
- })
2250
- })]
2251
- }));
2267
+ }, reference) {
2268
+ const inputAttributes = useInputAttributes();
2269
+ return /*#__PURE__*/jsxs("span", {
2270
+ className: classNames('np-checkbox-button', className, disabled && 'disabled'),
2271
+ children: [/*#__PURE__*/jsx("input", {
2272
+ ...inputAttributes,
2273
+ ...rest,
2274
+ ref: reference,
2275
+ type: "checkbox",
2276
+ disabled: disabled,
2277
+ checked: checked,
2278
+ onChange: onChange
2279
+ }), /*#__PURE__*/jsx("span", {
2280
+ className: "tw-checkbox-button",
2281
+ children: /*#__PURE__*/jsx("span", {
2282
+ className: "tw-checkbox-check"
2283
+ })
2284
+ })]
2285
+ });
2286
+ });
2252
2287
 
2253
2288
  function Checkbox({
2254
2289
  id,
@@ -3049,36 +3084,6 @@ const isMonthAndYearFormat = dateString => validDateString(dateString) && dateSt
3049
3084
  const MDY = new Set(['en-US']);
3050
3085
  const YMD = new Set(['hu', 'hu-HU', 'zh-HK', 'zh-CN', 'ja', 'ja-JP']);
3051
3086
 
3052
- const FieldLabelIdContext = /*#__PURE__*/createContext(undefined);
3053
- const FieldLabelIdContextProvider = FieldLabelIdContext.Provider;
3054
- const InputIdContext = /*#__PURE__*/createContext(undefined);
3055
- const InputIdContextProvider = InputIdContext.Provider;
3056
- const InputDescribedByContext = /*#__PURE__*/createContext(undefined);
3057
- const InputDescribedByProvider = InputDescribedByContext.Provider;
3058
- const InputInvalidContext = /*#__PURE__*/createContext(undefined);
3059
- const InputInvalidProvider = InputInvalidContext.Provider;
3060
- function useInputAttributes({
3061
- nonLabelable
3062
- } = {}) {
3063
- const labelId = useContext(FieldLabelIdContext);
3064
- return {
3065
- id: useContext(InputIdContext),
3066
- 'aria-labelledby': nonLabelable ? labelId : undefined,
3067
- 'aria-describedby': useContext(InputDescribedByContext),
3068
- 'aria-invalid': useContext(InputInvalidContext)
3069
- };
3070
- }
3071
- function withInputAttributes(Component, args) {
3072
- function ComponentWithInputAttributes(props) {
3073
- return /*#__PURE__*/jsx(Component, {
3074
- inputAttributes: useInputAttributes(args),
3075
- ...props
3076
- });
3077
- }
3078
- ComponentWithInputAttributes.displayName = `withInputAttributes(${Component.displayName || Component.name || 'Component'})`;
3079
- return ComponentWithInputAttributes;
3080
- }
3081
-
3082
3087
  var messages$9 = defineMessages({
3083
3088
  monthLabel: {
3084
3089
  id: "neptune.DateInput.month.label"
@@ -4831,6 +4836,7 @@ const Emphasis = ({
4831
4836
  }) : null;
4832
4837
  };
4833
4838
 
4839
+ const iconTypes = new Set([Sentiment.NEGATIVE, Sentiment.ERROR, Sentiment.POSITIVE, Sentiment.SUCCESS, Sentiment.WARNING]);
4834
4840
  function InlineAlert({
4835
4841
  id,
4836
4842
  type = 'neutral',
@@ -4841,7 +4847,7 @@ function InlineAlert({
4841
4847
  role: "alert",
4842
4848
  id: id,
4843
4849
  className: classNames('alert alert-detach', `alert-${type === Sentiment.NEGATIVE || type === Sentiment.ERROR ? 'danger' : type}`, className),
4844
- children: [type !== Sentiment.NEUTRAL && type !== Sentiment.PENDING && /*#__PURE__*/jsx(StatusIcon, {
4850
+ children: [iconTypes.has(type) && /*#__PURE__*/jsx(StatusIcon, {
4845
4851
  sentiment: type,
4846
4852
  size: Size.SMALL
4847
4853
  }), /*#__PURE__*/jsx("div", {
@@ -4896,11 +4902,11 @@ const Field = ({
4896
4902
  'has-error': hasError,
4897
4903
  'has-info': sentiment === Sentiment.NEUTRAL
4898
4904
  }, className),
4899
- children: [/*#__PURE__*/jsxs(Label, {
4905
+ children: [label != null ? /*#__PURE__*/jsxs(Label, {
4900
4906
  id: labelId,
4901
4907
  htmlFor: inputId,
4902
4908
  children: [label, children]
4903
- }), message && /*#__PURE__*/jsx(InlineAlert, {
4909
+ }) : children, message && /*#__PURE__*/jsx(InlineAlert, {
4904
4910
  type: sentiment,
4905
4911
  id: descriptionId,
4906
4912
  children: message