@transferwise/components 0.0.0-experimental-7b0ccd5 → 0.0.0-experimental-ded76ff

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.
@@ -18,6 +18,7 @@
18
18
  "neptune.Link.opensInNewTab": "(opens in new tab)",
19
19
  "neptune.MoneyInput.Select.placeholder": "Select an option...",
20
20
  "neptune.Select.searchPlaceholder": "Search...",
21
+ "neptune.SelectInput.noResultsFound": "No results found",
21
22
  "neptune.Summary.statusDone": "Item done",
22
23
  "neptune.Summary.statusNotDone": "Item to do",
23
24
  "neptune.Summary.statusPending": "Item pending",
@@ -3378,7 +3378,7 @@ const ResponsivePanel = /*#__PURE__*/forwardRef(({
3378
3378
  });
3379
3379
  var ResponsivePanel$1 = ResponsivePanel;
3380
3380
 
3381
- var messages$6 = defineMessages({
3381
+ var dateTriggerMessages = defineMessages({
3382
3382
  ariaLabel: {
3383
3383
  id: "neptune.ClearButton.ariaLabel"
3384
3384
  }
@@ -3441,7 +3441,7 @@ const DateTrigger = ({
3441
3441
  className: "input-group-addon",
3442
3442
  children: /*#__PURE__*/jsx(CloseButton, {
3443
3443
  className: `clear-btn clear-btn--${size}`,
3444
- "aria-label": formatMessage(messages$6.ariaLabel),
3444
+ "aria-label": formatMessage(dateTriggerMessages.ariaLabel),
3445
3445
  size: Size.SMALL,
3446
3446
  onClick: event => {
3447
3447
  event.stopPropagation();
@@ -3471,7 +3471,7 @@ DateTrigger.defaultProps = {
3471
3471
  };
3472
3472
  var DateTrigger$1 = DateTrigger;
3473
3473
 
3474
- var messages$5 = defineMessages({
3474
+ var messages$6 = defineMessages({
3475
3475
  next: {
3476
3476
  id: "neptune.DateLookup.next"
3477
3477
  },
@@ -3517,7 +3517,7 @@ const DateHeader = ({
3517
3517
  children: /*#__PURE__*/jsx("button", {
3518
3518
  type: "button",
3519
3519
  className: `d-inline-flex ${buttonClasses}`,
3520
- "aria-label": `${intl.formatMessage(messages$5.previous)} ${dateMode}`,
3520
+ "aria-label": `${intl.formatMessage(messages$6.previous)} ${dateMode}`,
3521
3521
  onClick: onPreviousClick,
3522
3522
  children: /*#__PURE__*/jsx(Chevron$1, {
3523
3523
  orientation: Position.LEFT,
@@ -3531,7 +3531,7 @@ const DateHeader = ({
3531
3531
  children: /*#__PURE__*/jsx("button", {
3532
3532
  type: "button",
3533
3533
  className: `tw-date-lookup-header-current ${buttonClasses}`,
3534
- "aria-label": intl.formatMessage(messages$5.goTo20YearView),
3534
+ "aria-label": intl.formatMessage(messages$6.goTo20YearView),
3535
3535
  onClick: onLabelClick,
3536
3536
  children: label
3537
3537
  })
@@ -3540,7 +3540,7 @@ const DateHeader = ({
3540
3540
  children: /*#__PURE__*/jsx("button", {
3541
3541
  type: "button",
3542
3542
  className: `d-inline-flex ${buttonClasses}`,
3543
- "aria-label": `${useIntl().formatMessage(messages$5.next)} ${dateMode}`,
3543
+ "aria-label": `${useIntl().formatMessage(messages$6.next)} ${dateMode}`,
3544
3544
  onClick: onNextClick,
3545
3545
  children: /*#__PURE__*/jsx(Chevron$1, {
3546
3546
  orientation: Position.RIGHT,
@@ -3584,7 +3584,7 @@ class TableLink extends PureComponent {
3584
3584
  };
3585
3585
  calculateAriaLabel = (longTitle, title, active, type, formatMessage) => {
3586
3586
  if (active) {
3587
- return `${longTitle || title}, ${formatMessage(messages$5.selected)} ${formatMessage(messages$5[type])}`;
3587
+ return `${longTitle || title}, ${formatMessage(messages$6.selected)} ${formatMessage(messages$6[type])}`;
3588
3588
  }
3589
3589
  return longTitle || title;
3590
3590
  };
@@ -3807,7 +3807,7 @@ class DayCalendar extends PureComponent {
3807
3807
  month: monthFormat,
3808
3808
  year: 'numeric'
3809
3809
  }),
3810
- dateMode: formatMessage(messages$5.month),
3810
+ dateMode: formatMessage(messages$6.month),
3811
3811
  onLabelClick: onLabelClick,
3812
3812
  onPreviousClick: this.selectPreviousMonth,
3813
3813
  onNextClick: this.selectNextMonth
@@ -3935,7 +3935,7 @@ class MonthCalendar extends PureComponent {
3935
3935
  } = this.props;
3936
3936
  return /*#__PURE__*/jsxs(Fragment, {
3937
3937
  children: [/*#__PURE__*/jsx(DateHeader$1, {
3938
- dateMode: formatMessage(messages$5.year),
3938
+ dateMode: formatMessage(messages$6.year),
3939
3939
  label: formatDate(new Date(viewYear, 0), locale, {
3940
3940
  year: 'numeric'
3941
3941
  }),
@@ -4060,7 +4060,7 @@ class YearCalendar extends PureComponent {
4060
4060
  } = this.props;
4061
4061
  return /*#__PURE__*/jsxs(Fragment, {
4062
4062
  children: [/*#__PURE__*/jsx(DateHeader$1, {
4063
- dateMode: formatMessage(messages$5.twentyYears),
4063
+ dateMode: formatMessage(messages$6.twentyYears),
4064
4064
  onPreviousClick: this.selectPreviousYears,
4065
4065
  onNextClick: this.selectNextYears
4066
4066
  }), /*#__PURE__*/jsx(YearCalendarTable$1, {
@@ -5697,7 +5697,7 @@ const Stepper = ({
5697
5697
  });
5698
5698
  };
5699
5699
 
5700
- var messages$4 = defineMessages({
5700
+ var messages$5 = defineMessages({
5701
5701
  back: {
5702
5702
  id: "neptune.FlowNavigation.back"
5703
5703
  }
@@ -5777,7 +5777,7 @@ const FlowNavigation = ({
5777
5777
  className: "m-x-1",
5778
5778
  labels: steps.map(step => step.label),
5779
5779
  activeLabel: activeStep - 1,
5780
- "aria-label": intl.formatMessage(messages$4.back)
5780
+ "aria-label": intl.formatMessage(messages$5.back)
5781
5781
  }),
5782
5782
  onClick: onGoBack
5783
5783
  }) : logo
@@ -6383,6 +6383,12 @@ function wrapInFragment(value) {
6383
6383
  });
6384
6384
  }
6385
6385
 
6386
+ var messages$4 = defineMessages({
6387
+ noResultsFound: {
6388
+ id: "neptune.SelectInput.noResultsFound"
6389
+ }
6390
+ });
6391
+
6386
6392
  function PreventScroll() {
6387
6393
  usePreventScroll();
6388
6394
  return null;
@@ -6428,29 +6434,29 @@ function BottomSheet({
6428
6434
  theme: theme,
6429
6435
  screenMode: screenMode,
6430
6436
  isNotRootProvider: true,
6431
- children: /*#__PURE__*/jsxs(Transition, {
6437
+ children: /*#__PURE__*/jsx(Transition, {
6432
6438
  show: open,
6433
6439
  className: "np-bottom-sheet-v2-container",
6434
6440
  beforeEnter: () => {
6435
6441
  setFloatingKey(prev => prev + 1);
6436
6442
  },
6437
- children: [/*#__PURE__*/jsx(Transition.Child, {
6438
- enter: "np-bottom-sheet-v2-backdrop-container--enter",
6439
- enterFrom: "np-bottom-sheet-v2-backdrop-container--enter-from",
6440
- leave: "np-bottom-sheet-v2-backdrop-container--leave",
6441
- leaveTo: "np-bottom-sheet-v2-backdrop-container--leave-to",
6442
- children: /*#__PURE__*/jsx("div", {
6443
- className: "np-bottom-sheet-v2-backdrop"
6444
- })
6445
- }), /*#__PURE__*/jsx("div", {
6446
- className: "np-bottom-sheet-v2",
6447
- children: /*#__PURE__*/jsx(Transition.Child, {
6448
- className: "np-bottom-sheet-v2-content",
6449
- enter: "np-bottom-sheet-v2-content--enter",
6450
- enterFrom: "np-bottom-sheet-v2-content--enter-from",
6451
- leave: "np-bottom-sheet-v2-content--leave",
6452
- leaveTo: "np-bottom-sheet-v2-content--leave-to",
6453
- children: /*#__PURE__*/jsx(FocusBoundary, {
6443
+ children: /*#__PURE__*/jsxs(FocusBoundary, {
6444
+ children: [/*#__PURE__*/jsx(Transition.Child, {
6445
+ enter: "np-bottom-sheet-v2-backdrop-container--enter",
6446
+ enterFrom: "np-bottom-sheet-v2-backdrop-container--enter-from",
6447
+ leave: "np-bottom-sheet-v2-backdrop-container--leave",
6448
+ leaveTo: "np-bottom-sheet-v2-backdrop-container--leave-to",
6449
+ children: /*#__PURE__*/jsx("div", {
6450
+ className: "np-bottom-sheet-v2-backdrop"
6451
+ })
6452
+ }), /*#__PURE__*/jsx("div", {
6453
+ className: "np-bottom-sheet-v2",
6454
+ children: /*#__PURE__*/jsx(Transition.Child, {
6455
+ className: "np-bottom-sheet-v2-content",
6456
+ enter: "np-bottom-sheet-v2-content--enter",
6457
+ enterFrom: "np-bottom-sheet-v2-content--enter-from",
6458
+ leave: "np-bottom-sheet-v2-content--leave",
6459
+ leaveTo: "np-bottom-sheet-v2-content--leave-to",
6454
6460
  children: /*#__PURE__*/jsx(FloatingFocusManager, {
6455
6461
  context: context,
6456
6462
  initialFocus: initialFocusRef,
@@ -6484,8 +6490,8 @@ function BottomSheet({
6484
6490
  }, floatingKey)
6485
6491
  })
6486
6492
  })
6487
- })
6488
- })]
6493
+ })]
6494
+ })
6489
6495
  })
6490
6496
  })
6491
6497
  })]
@@ -6636,14 +6642,14 @@ function useSelectInputItemCheckPadding() {
6636
6642
  const SelectInputTriggerButtonPropsContext = /*#__PURE__*/createContext({});
6637
6643
  const SelectInputOptionContentWithinTriggerContext = /*#__PURE__*/createContext(false);
6638
6644
  function dedupeSelectInputOptionItem(item, existingValues) {
6639
- if (existingValues.has(item.value)) {
6640
- return {
6641
- ...item,
6642
- value: undefined
6643
- };
6645
+ if (!existingValues.has(item.value)) {
6646
+ existingValues.add(item.value);
6647
+ return item;
6644
6648
  }
6645
- existingValues.add(item.value);
6646
- return item;
6649
+ return {
6650
+ ...item,
6651
+ value: undefined
6652
+ };
6647
6653
  }
6648
6654
  function dedupeSelectInputItems(items) {
6649
6655
  const existingValues = new Set();
@@ -6664,6 +6670,24 @@ function dedupeSelectInputItems(items) {
6664
6670
  return item;
6665
6671
  });
6666
6672
  }
6673
+ function filterSelectInputOptionItem(item, needle) {
6674
+ return inferSearchableStrings(item.filterMatchers ?? item.value).some(haystack => haystack.includes(needle));
6675
+ }
6676
+ function filterSelectInputItems(items, needle) {
6677
+ return items.filter(item => {
6678
+ switch (item.type) {
6679
+ case 'option':
6680
+ {
6681
+ return filterSelectInputOptionItem(item, needle);
6682
+ }
6683
+ case 'group':
6684
+ {
6685
+ return item.options.some(option => filterSelectInputOptionItem(option, needle));
6686
+ }
6687
+ }
6688
+ return false;
6689
+ });
6690
+ }
6667
6691
  const defaultRenderTrigger = ({
6668
6692
  content,
6669
6693
  placeholderShown,
@@ -6711,7 +6735,7 @@ function SelectInputClearButton({
6711
6735
  const intl = useIntl();
6712
6736
  return /*#__PURE__*/jsx("button", {
6713
6737
  type: "button",
6714
- "aria-label": intl.formatMessage(messages$6.ariaLabel),
6738
+ "aria-label": intl.formatMessage(dateTriggerMessages.ariaLabel),
6715
6739
  className: classNames(className, 'np-select-input-addon np-select-input-addon--interactive'),
6716
6740
  onClick: onClick,
6717
6741
  children: /*#__PURE__*/jsx(Cross, {
@@ -6852,9 +6876,14 @@ const SelectInputOptionsContainer = /*#__PURE__*/forwardRef(function SelectInput
6852
6876
  ref: ref,
6853
6877
  onKeyDown: event => {
6854
6878
  // Prevent absorbing dismissal requests too early
6855
- if (event.key !== 'Escape') {
6856
- onKeyDown?.(event);
6879
+ if (event.key === 'Escape') {
6880
+ return;
6881
+ }
6882
+ // Prevent confirmation close without an active item
6883
+ if (event.key === 'Enter' && ariaActiveDescendant == null) {
6884
+ return;
6857
6885
  }
6886
+ onKeyDown?.(event);
6858
6887
  },
6859
6888
  ...restProps
6860
6889
  })
@@ -6868,6 +6897,8 @@ function SelectInputOptions({
6868
6897
  searchInputRef,
6869
6898
  listboxRef
6870
6899
  }) {
6900
+ const intl = useIntl();
6901
+ const controllerRef = filterable ? searchInputRef : listboxRef;
6871
6902
  const [query, setQuery] = useState('');
6872
6903
  const needle = useMemo(() => {
6873
6904
  if (filterable) {
@@ -6875,14 +6906,16 @@ function SelectInputOptions({
6875
6906
  }
6876
6907
  return undefined;
6877
6908
  }, [filterable, query]);
6909
+ const empty = needle != null && filterSelectInputItems(items, needle).length === 0;
6878
6910
  const listboxContainerRef = useRef(null);
6879
6911
  useEffect(() => {
6880
6912
  if (listboxContainerRef.current != null) {
6881
6913
  listboxContainerRef.current.style.setProperty('--initial-height', `${listboxContainerRef.current.offsetHeight}px`);
6882
6914
  }
6883
6915
  }, []);
6916
+ const showStatus = empty;
6917
+ const statusId = useId();
6884
6918
  const listboxId = useId();
6885
- const controllerRef = filterable ? searchInputRef : listboxRef;
6886
6919
  return /*#__PURE__*/jsxs(Listbox.Options, {
6887
6920
  as: SelectInputOptionsContainer,
6888
6921
  static: true,
@@ -6904,6 +6937,7 @@ function SelectInputOptions({
6904
6937
  placeholder: filterPlaceholder,
6905
6938
  value: query,
6906
6939
  "aria-controls": listboxId,
6940
+ "aria-describedby": showStatus ? statusId : undefined,
6907
6941
  onKeyDown: event => {
6908
6942
  // Prevent interfering with the matcher of Headless UI
6909
6943
  // https://mathiasbynens.be/notes/javascript-unicode#regex
@@ -6915,24 +6949,31 @@ function SelectInputOptions({
6915
6949
  setQuery(event.currentTarget.value);
6916
6950
  }
6917
6951
  })
6918
- }) : null, /*#__PURE__*/jsx("div", {
6952
+ }) : null, /*#__PURE__*/jsxs("div", {
6919
6953
  ref: listboxContainerRef,
6920
6954
  className: classNames('np-select-input-listbox-container', items.some(item => item.type === 'group') && 'np-select-input-listbox-container--has-group'),
6921
- children: /*#__PURE__*/jsx("div", {
6955
+ children: [empty ? /*#__PURE__*/jsxs("div", {
6956
+ id: statusId,
6957
+ className: "np-select-input-options-status",
6958
+ children: [/*#__PURE__*/jsx(CrossCircle, {
6959
+ size: 16,
6960
+ className: "np-select-input-options-status-icon"
6961
+ }), intl.formatMessage(messages$4.noResultsFound)]
6962
+ }) : null, /*#__PURE__*/jsx("div", {
6922
6963
  ref: listboxRef,
6923
6964
  id: listboxId,
6924
6965
  role: "listbox",
6925
6966
  "aria-orientation": "vertical",
6926
6967
  tabIndex: 0,
6927
6968
  className: "np-select-input-listbox",
6928
- children: (needle == null ? items : dedupeSelectInputItems(items)).map((item, index) => /*#__PURE__*/jsx(SelectInputItemView
6969
+ children: (needle != null ? dedupeSelectInputItems(items) : items).map((item, index) => /*#__PURE__*/jsx(SelectInputItemView
6929
6970
  // eslint-disable-next-line react/no-array-index-key
6930
6971
  , {
6931
6972
  item: item,
6932
6973
  renderValue: renderValue,
6933
6974
  needle: needle
6934
6975
  }, index))
6935
- })
6976
+ })]
6936
6977
  })]
6937
6978
  });
6938
6979
  }
@@ -6944,7 +6985,7 @@ function SelectInputItemView({
6944
6985
  switch (item.type) {
6945
6986
  case 'option':
6946
6987
  {
6947
- if (item.value != null && (!needle || inferSearchableStrings(item.filterMatchers ?? item.value).some(haystack => haystack.includes(needle)))) {
6988
+ if (item.value != null && (needle == null || filterSelectInputOptionItem(item, needle))) {
6948
6989
  return /*#__PURE__*/jsx(SelectInputOption, {
6949
6990
  value: item.value,
6950
6991
  disabled: item.disabled,
@@ -10719,6 +10760,7 @@ var en = {
10719
10760
  "neptune.Link.opensInNewTab": "(opens in new tab)",
10720
10761
  "neptune.MoneyInput.Select.placeholder": "Select an option...",
10721
10762
  "neptune.Select.searchPlaceholder": "Search...",
10763
+ "neptune.SelectInput.noResultsFound": "No results found",
10722
10764
  "neptune.Summary.statusDone": "Item done",
10723
10765
  "neptune.Summary.statusNotDone": "Item to do",
10724
10766
  "neptune.Summary.statusPending": "Item pending",