@transferwise/components 0.0.0-experimental-7fb3545 → 0.0.0-experimental-930909f

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.
@@ -10,8 +10,7 @@ import { useTheme, ThemeProvider } from '@wise/components-theming';
10
10
  import { formatDate, formatNumber, formatMoney, formatAmount } from '@transferwise/formatting';
11
11
  import { Transition, Listbox } from '@headlessui/react';
12
12
  import mergeProps from 'merge-props';
13
- import mergeRefs from 'react-merge-refs';
14
- import { useSyncExternalStore } from 'use-sync-external-store/shim';
13
+ import { useSyncExternalStore } from 'use-sync-external-store/shim/index.js';
15
14
  import { useFloating, useDismiss, useRole, useInteractions, FloatingPortal, FloatingFocusManager, offset, flip, shift, size, autoUpdate } from '@floating-ui/react';
16
15
  import { FocusScope } from '@react-aria/focus';
17
16
  import { usePreventScroll } from '@react-aria/overlays';
@@ -1718,6 +1717,7 @@ const useHasIntersected = ({
1718
1717
  return [hasIntersected];
1719
1718
  };
1720
1719
 
1720
+ // eslint-disable-next-line import/extensions
1721
1721
  function useMedia(query) {
1722
1722
  return useSyncExternalStore(onStoreChange => {
1723
1723
  const mediaQueryList = window.matchMedia(query);
@@ -1751,6 +1751,18 @@ const useLayout = () => {
1751
1751
  };
1752
1752
  };
1753
1753
 
1754
+ function mergeRefs(refs) {
1755
+ return function (value) {
1756
+ refs.forEach(function (ref) {
1757
+ if (typeof ref === "function") {
1758
+ ref(value);
1759
+ } else if (ref != null) {
1760
+ ref.current = value;
1761
+ }
1762
+ });
1763
+ };
1764
+ }
1765
+
1754
1766
  const EXIT_ANIMATION = 350;
1755
1767
  const SlidingPanel = /*#__PURE__*/forwardRef(({
1756
1768
  position = 'left',
@@ -2720,6 +2732,7 @@ const convertToLocalMidnight = date => {
2720
2732
  return new Date(utcDate.getUTCFullYear(), utcDate.getUTCMonth(), utcDate.getUTCDate());
2721
2733
  };
2722
2734
 
2735
+ const MonthBeforeDay = new Set(['en-US', 'ja-JP']);
2723
2736
  const DateInput = ({
2724
2737
  'aria-labelledby': ariaLabelledBy,
2725
2738
  'aria-label': ariaLabel,
@@ -2909,86 +2922,7 @@ const DateInput = ({
2909
2922
  'col-sm-8': monthYearOnly,
2910
2923
  'col-sm-5': !monthYearOnly
2911
2924
  });
2912
- const getMonth = () => {
2913
- return /*#__PURE__*/jsx("div", {
2914
- className: monthWidth,
2915
- children: getSelectElement()
2916
- });
2917
- };
2918
- const getDay = () => {
2919
- return /*#__PURE__*/jsx("div", {
2920
- className: "col-sm-3",
2921
- children: /*#__PURE__*/jsxs("label", {
2922
- children: [/*#__PURE__*/jsx("span", {
2923
- className: "sr-only",
2924
- children: dayLabel
2925
- }), /*#__PURE__*/jsx("div", {
2926
- className: `input-group input-group-${size}`,
2927
- children: /*#__PURE__*/jsx(Input, {
2928
- type: "text",
2929
- inputMode: "numeric",
2930
- pattern: "[0-9]*",
2931
- name: "day",
2932
- autoComplete: dayAutoComplete,
2933
- value: day || '',
2934
- placeholder: placeholders?.day,
2935
- disabled: disabled,
2936
- min: 1,
2937
- onChange: event => handleDayChange(event)
2938
- })
2939
- })]
2940
- })
2941
- });
2942
- };
2943
- const getYear = () => {
2944
- return /*#__PURE__*/jsx("div", {
2945
- className: "col-sm-4",
2946
- children: /*#__PURE__*/jsxs("label", {
2947
- children: [/*#__PURE__*/jsx("span", {
2948
- className: "sr-only",
2949
- children: yearLabel
2950
- }), /*#__PURE__*/jsx("div", {
2951
- className: `input-group input-group-${size}`,
2952
- children: /*#__PURE__*/jsx(Input, {
2953
- type: "text",
2954
- inputMode: "numeric",
2955
- pattern: "[0-9]*",
2956
- name: "year",
2957
- autoComplete: yearAutoComplete,
2958
- placeholder: placeholders?.year,
2959
- value: year || '',
2960
- disabled: disabled,
2961
- min: 1,
2962
- onChange: event => handleYearChange(event)
2963
- })
2964
- })]
2965
- })
2966
- });
2967
- };
2968
- const MDY = new Set(['en-US']);
2969
- const YMD = new Set(['hu', 'hu-HU', 'zh-HK', 'zh-CN', 'ja', 'ja-JP']);
2970
- const monthBeforeDay = MDY.has(locale);
2971
- const yearFirst = YMD.has(locale);
2972
- const returnOrderedInputs = () => {
2973
- if (monthYearOnly) {
2974
- return /*#__PURE__*/jsxs(Fragment, {
2975
- children: ["!yearFirst && ", getMonth(), getYear(), "yearFirst && ", getMonth()]
2976
- });
2977
- }
2978
- if (monthBeforeDay) {
2979
- return /*#__PURE__*/jsxs(Fragment, {
2980
- children: [getMonth(), getDay(), getYear()]
2981
- });
2982
- } else if (yearFirst) {
2983
- return /*#__PURE__*/jsxs(Fragment, {
2984
- children: [getYear(), getMonth(), getDay()]
2985
- });
2986
- } else {
2987
- return /*#__PURE__*/jsxs(Fragment, {
2988
- children: [getDay(), getMonth(), getYear()]
2989
- });
2990
- }
2991
- };
2925
+ const monthBeforeDay = MonthBeforeDay.has(locale);
2992
2926
  return /*#__PURE__*/jsx("div", {
2993
2927
  className: "tw-date",
2994
2928
  id: id,
@@ -2998,9 +2932,59 @@ const DateInput = ({
2998
2932
  ,
2999
2933
  onFocus: event => shouldPropagateOnFocus(event) ? onFocus && onFocus(event) : event.stopPropagation(),
3000
2934
  onBlur: event => shouldPropagateOnBlur(event) ? onBlur && onBlur(event) : event.stopPropagation(),
3001
- children: /*#__PURE__*/jsx("div", {
2935
+ children: /*#__PURE__*/jsxs("div", {
3002
2936
  className: "row",
3003
- children: returnOrderedInputs()
2937
+ children: [monthBeforeDay && /*#__PURE__*/jsx("div", {
2938
+ className: monthWidth,
2939
+ children: getSelectElement()
2940
+ }), !monthYearOnly && /*#__PURE__*/jsx("div", {
2941
+ className: "col-sm-3",
2942
+ children: /*#__PURE__*/jsxs("label", {
2943
+ children: [/*#__PURE__*/jsx("span", {
2944
+ className: "sr-only",
2945
+ children: dayLabel
2946
+ }), /*#__PURE__*/jsx("div", {
2947
+ className: `input-group input-group-${size}`,
2948
+ children: /*#__PURE__*/jsx(Input, {
2949
+ type: "text",
2950
+ inputMode: "numeric",
2951
+ pattern: "[0-9]*",
2952
+ name: "day",
2953
+ autoComplete: dayAutoComplete,
2954
+ value: day || '',
2955
+ placeholder: placeholders.day,
2956
+ disabled: disabled,
2957
+ min: 1,
2958
+ onChange: event => handleDayChange(event)
2959
+ })
2960
+ })]
2961
+ })
2962
+ }), !monthBeforeDay && /*#__PURE__*/jsx("div", {
2963
+ className: monthWidth,
2964
+ children: getSelectElement()
2965
+ }), /*#__PURE__*/jsx("div", {
2966
+ className: "col-sm-4",
2967
+ children: /*#__PURE__*/jsxs("label", {
2968
+ children: [/*#__PURE__*/jsx("span", {
2969
+ className: "sr-only",
2970
+ children: yearLabel
2971
+ }), /*#__PURE__*/jsx("div", {
2972
+ className: `input-group input-group-${size}`,
2973
+ children: /*#__PURE__*/jsx(Input, {
2974
+ type: "text",
2975
+ inputMode: "numeric",
2976
+ pattern: "[0-9]*",
2977
+ name: "year",
2978
+ autoComplete: yearAutoComplete,
2979
+ placeholder: placeholders.year,
2980
+ value: year || '',
2981
+ disabled: disabled,
2982
+ min: 1,
2983
+ onChange: event => handleYearChange(event)
2984
+ })
2985
+ })]
2986
+ })
2987
+ })]
3004
2988
  })
3005
2989
  });
3006
2990
  };
@@ -15070,13 +15054,12 @@ const translations = {
15070
15054
  cs,
15071
15055
  de,
15072
15056
  en,
15073
- 'en-US': en,
15074
15057
  es,
15075
15058
  fr,
15076
15059
  hu,
15077
15060
  id,
15078
15061
  it,
15079
- 'ja-JP': ja,
15062
+ ja,
15080
15063
  pl,
15081
15064
  pt,
15082
15065
  ro,
@@ -15089,4 +15072,4 @@ const translations = {
15089
15072
  };
15090
15073
 
15091
15074
  export { Accordion, ActionButton, ActionOption, Alert$1 as Alert, ArrowPosition as AlertArrowPosition, Avatar, AvatarType, AvatarWrapper, Badge, Card as BaseCard, Body, BottomSheet$2 as BottomSheet, Breakpoint, Button, Card$2 as Card, Checkbox$1 as 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, DynamicFieldDefinitionList$1 as DynamicFieldDefinitionList, Emphasis, FileType, FlowNavigation, Header, Image, Info, InfoPresentation, InlineAlert, Input, InputGroup, InputWithDisplayFormat, InstructionsList, LanguageProvider, Layout, Link, ListItem$1 as ListItem, Loader$1 as Loader, Logo$1 as Logo, LogoType, Markdown, MarkdownNodeType, Modal, Money$1 as Money, MoneyInput$1 as MoneyInput, MonthFormat, NavigationOption, NavigationOptionList$1 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, PromoCard$1 as PromoCardGroup, Provider$1 as 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 };
15092
- //# sourceMappingURL=index.esm.js.map
15075
+ //# sourceMappingURL=index.mjs.map