@transferwise/components 0.0.0-experimental-7709e0e → 0.0.0-experimental-94569f6

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.js CHANGED
@@ -746,7 +746,7 @@ const StatusIcon = ({
746
746
  const iconColor = sentiment === 'warning' || sentiment === 'pending' ? 'dark' : 'light';
747
747
  return /*#__PURE__*/jsxRuntime.jsx("span", {
748
748
  "data-testid": "status-icon",
749
- className: classNames__default.default('status-circle', `status-circle-${size}`, sentiment),
749
+ className: classNames__default.default('status-circle', 'status-circle-' + size, sentiment),
750
750
  children: /*#__PURE__*/jsxRuntime.jsx(Icon, {
751
751
  className: classNames__default.default('status-icon', iconColor)
752
752
  })
@@ -4866,20 +4866,14 @@ function InlineAlert({
4866
4866
  className,
4867
4867
  children
4868
4868
  }) {
4869
- return /*#__PURE__*/jsxRuntime.jsx("div", {
4869
+ const danger = type === 'negative' || type === 'error';
4870
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
4870
4871
  role: "alert",
4871
4872
  id: id,
4872
- className: classNames__default.default('alert alert-detach', `alert-${[exports.Sentiment.NEGATIVE, exports.Sentiment.ERROR].includes(type) ? 'danger' : type}`, className),
4873
- children: /*#__PURE__*/jsxRuntime.jsxs("div", {
4874
- className: "d-inline-flex",
4875
- children: [type !== exports.Sentiment.NEUTRAL && type !== exports.Sentiment.PENDING && /*#__PURE__*/jsxRuntime.jsx(StatusIcon, {
4876
- sentiment: type,
4877
- size: exports.Size.SMALL
4878
- }), /*#__PURE__*/jsxRuntime.jsx("div", {
4879
- className: "np-text-body-default",
4880
- children: children
4881
- })]
4882
- })
4873
+ className: classNames__default.default('alert alert-detach', `alert-${danger ? 'danger' : type}`, className),
4874
+ children: [danger && /*#__PURE__*/jsxRuntime.jsx(icons.AlertCircle, {}), /*#__PURE__*/jsxRuntime.jsx("div", {
4875
+ children: children
4876
+ })]
4883
4877
  });
4884
4878
  }
4885
4879
 
@@ -4900,15 +4894,13 @@ const Label = ({
4900
4894
  const Field = ({
4901
4895
  id,
4902
4896
  label,
4903
- message: propMessage,
4904
- sentiment: propType,
4897
+ hint,
4898
+ error,
4905
4899
  className,
4906
- children,
4907
- ...props
4900
+ children
4908
4901
  }) => {
4909
- const sentiment = props.error ? exports.Sentiment.NEGATIVE : propType;
4910
- const message = props.error || props.hint || propMessage;
4911
- const hasError = sentiment === exports.Sentiment.NEGATIVE;
4902
+ const hasError = Boolean(error);
4903
+ const hasHint = Boolean(hint) && !hasError;
4912
4904
  const labelId = React.useId();
4913
4905
  const fallbackInputId = React.useId();
4914
4906
  const inputId = id !== null ? id ?? fallbackInputId : undefined;
@@ -4918,24 +4910,26 @@ const Field = ({
4918
4910
  children: /*#__PURE__*/jsxRuntime.jsx(InputIdContextProvider, {
4919
4911
  value: inputId,
4920
4912
  children: /*#__PURE__*/jsxRuntime.jsx(InputDescribedByProvider, {
4921
- value: message ? descriptionId : undefined,
4913
+ value: hasError || hasHint ? descriptionId : undefined,
4922
4914
  children: /*#__PURE__*/jsxRuntime.jsx(InputInvalidProvider, {
4923
4915
  value: hasError,
4924
4916
  children: /*#__PURE__*/jsxRuntime.jsxs("div", {
4925
4917
  className: classNames__default.default('form-group d-block', {
4926
- 'has-success': sentiment === exports.Sentiment.POSITIVE,
4927
- 'has-warning': sentiment === exports.Sentiment.WARNING,
4928
4918
  'has-error': hasError,
4929
- 'has-info': sentiment === exports.Sentiment.NEUTRAL
4919
+ 'has-info': hasHint
4930
4920
  }, className),
4931
4921
  children: [/*#__PURE__*/jsxRuntime.jsxs(Label, {
4932
4922
  id: labelId,
4933
4923
  htmlFor: inputId,
4934
4924
  children: [label, children]
4935
- }), message && /*#__PURE__*/jsxRuntime.jsx(InlineAlert, {
4936
- type: sentiment,
4925
+ }), hasHint && /*#__PURE__*/jsxRuntime.jsx(InlineAlert, {
4926
+ type: exports.Sentiment.NEUTRAL,
4937
4927
  id: descriptionId,
4938
- children: message
4928
+ children: hint
4929
+ }), hasError && /*#__PURE__*/jsxRuntime.jsx(InlineAlert, {
4930
+ type: exports.Sentiment.NEGATIVE,
4931
+ id: descriptionId,
4932
+ children: error
4939
4933
  })]
4940
4934
  })
4941
4935
  })
@@ -6265,6 +6259,21 @@ const PolymorphicWithOverrides = /*#__PURE__*/React.forwardRef(function Polymorp
6265
6259
  });
6266
6260
  });
6267
6261
 
6262
+ function useVirtualKeyboard() {
6263
+ React.useEffect(() => {
6264
+ /* eslint-disable @typescript-eslint/no-unsafe-member-access, functional/immutable-data */
6265
+ if ('virtualKeyboard' in navigator) {
6266
+ navigator.virtualKeyboard.overlaysContent = true;
6267
+ }
6268
+ return () => {
6269
+ if ('virtualKeyboard' in navigator) {
6270
+ navigator.virtualKeyboard.overlaysContent = false;
6271
+ }
6272
+ };
6273
+ /* eslint-enable @typescript-eslint/no-unsafe-member-access, functional/immutable-data */
6274
+ }, []);
6275
+ }
6276
+
6268
6277
  function PreventScroll() {
6269
6278
  overlays.usePreventScroll();
6270
6279
  return null;
@@ -6280,6 +6289,7 @@ function BottomSheet({
6280
6289
  onClose,
6281
6290
  onCloseEnd
6282
6291
  }) {
6292
+ useVirtualKeyboard();
6283
6293
  const {
6284
6294
  refs,
6285
6295
  context
@@ -6319,29 +6329,21 @@ function BottomSheet({
6319
6329
  },
6320
6330
  afterLeave: onCloseEnd,
6321
6331
  children: [/*#__PURE__*/jsxRuntime.jsx(react$1.Transition.Child, {
6322
- enter: "np-bottom-sheet-v2-backdrop-container--enter",
6323
- enterFrom: "np-bottom-sheet-v2-backdrop-container--enter-from",
6324
- leave: "np-bottom-sheet-v2-backdrop-container--leave",
6325
- leaveTo: "np-bottom-sheet-v2-backdrop-container--leave-to",
6326
- children: /*#__PURE__*/jsxRuntime.jsx("div", {
6327
- className: "np-bottom-sheet-v2-backdrop"
6328
- })
6332
+ className: "np-bottom-sheet-v2-backdrop",
6333
+ enterFrom: "np-bottom-sheet-v2-backdrop--closed",
6334
+ leaveTo: "np-bottom-sheet-v2-backdrop--closed"
6329
6335
  }), /*#__PURE__*/jsxRuntime.jsx("div", {
6330
6336
  className: "np-bottom-sheet-v2",
6331
- children: /*#__PURE__*/jsxRuntime.jsx(react$1.Transition.Child, {
6332
- className: "np-bottom-sheet-v2-content",
6333
- enter: "np-bottom-sheet-v2-content--enter",
6334
- enterFrom: "np-bottom-sheet-v2-content--enter-from",
6335
- leave: "np-bottom-sheet-v2-content--leave",
6336
- leaveTo: "np-bottom-sheet-v2-content--leave-to",
6337
- children: /*#__PURE__*/jsxRuntime.jsx(focus.FocusScope, {
6338
- children: /*#__PURE__*/jsxRuntime.jsx(react.FloatingFocusManager, {
6339
- context: context,
6340
- initialFocus: initialFocusRef,
6341
- children: /*#__PURE__*/jsxRuntime.jsxs("div", {
6342
- // Force inner state invalidation on open
6337
+ children: /*#__PURE__*/jsxRuntime.jsx(focus.FocusScope, {
6338
+ children: /*#__PURE__*/jsxRuntime.jsx(react.FloatingFocusManager, {
6339
+ context: context,
6340
+ initialFocus: initialFocusRef,
6341
+ children: /*#__PURE__*/jsxRuntime.jsx(React.Fragment, {
6342
+ children: /*#__PURE__*/jsxRuntime.jsxs(react$1.Transition.Child, {
6343
6343
  ref: refs.setFloating,
6344
- className: "np-bottom-sheet-v2-content-inner-container",
6344
+ className: "np-bottom-sheet-v2-content",
6345
+ enterFrom: "np-bottom-sheet-v2-content--closed",
6346
+ leaveTo: "np-bottom-sheet-v2-content--closed",
6345
6347
  ...getFloatingProps(),
6346
6348
  children: [/*#__PURE__*/jsxRuntime.jsx("div", {
6347
6349
  className: "np-bottom-sheet-v2-header",
@@ -6352,9 +6354,7 @@ function BottomSheet({
6352
6354
  }
6353
6355
  })
6354
6356
  }), /*#__PURE__*/jsxRuntime.jsxs("div", {
6355
- className: classNames__default.default('np-bottom-sheet-v2-content-inner', title && 'np-bottom-sheet-v2-content-inner--has-title', {
6356
- 'np-bottom-sheet-v2-content-inner--padding-md': padding === 'md'
6357
- }),
6357
+ className: classNames__default.default('np-bottom-sheet-v2-content-inner', padding === 'md' && 'np-bottom-sheet-v2-content-inner--padding-md'),
6358
6358
  children: [title ? /*#__PURE__*/jsxRuntime.jsx("h2", {
6359
6359
  className: "np-bottom-sheet-v2-title np-text-title-body",
6360
6360
  children: title
@@ -6363,8 +6363,8 @@ function BottomSheet({
6363
6363
  children: children
6364
6364
  })]
6365
6365
  })]
6366
- }, floatingKey)
6367
- })
6366
+ })
6367
+ }, floatingKey)
6368
6368
  })
6369
6369
  })
6370
6370
  })]