@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.
package/build/index.js CHANGED
@@ -11,8 +11,7 @@ var componentsTheming = require('@wise/components-theming');
11
11
  var formatting = require('@transferwise/formatting');
12
12
  var react$1 = require('@headlessui/react');
13
13
  var mergeProps = require('merge-props');
14
- var mergeRefs = require('react-merge-refs');
15
- var shim = require('use-sync-external-store/shim');
14
+ var index_js = require('use-sync-external-store/shim/index.js');
16
15
  var react = require('@floating-ui/react');
17
16
  var focus = require('@react-aria/focus');
18
17
  var overlays = require('@react-aria/overlays');
@@ -53,7 +52,6 @@ var classNames__default = /*#__PURE__*/_interopDefault(classNames);
53
52
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
54
53
  var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
55
54
  var mergeProps__default = /*#__PURE__*/_interopDefault(mergeProps);
56
- var mergeRefs__default = /*#__PURE__*/_interopDefault(mergeRefs);
57
55
  var throttle__default = /*#__PURE__*/_interopDefault(throttle);
58
56
  var commonmark__default = /*#__PURE__*/_interopDefault(commonmark);
59
57
  var clamp__default = /*#__PURE__*/_interopDefault(clamp$2);
@@ -1751,8 +1749,9 @@ const useHasIntersected = ({
1751
1749
  return [hasIntersected];
1752
1750
  };
1753
1751
 
1752
+ // eslint-disable-next-line import/extensions
1754
1753
  function useMedia(query) {
1755
- return shim.useSyncExternalStore(onStoreChange => {
1754
+ return index_js.useSyncExternalStore(onStoreChange => {
1756
1755
  const mediaQueryList = window.matchMedia(query);
1757
1756
  mediaQueryList.addEventListener('change', onStoreChange);
1758
1757
  return () => {
@@ -1784,6 +1783,18 @@ const useLayout = () => {
1784
1783
  };
1785
1784
  };
1786
1785
 
1786
+ function mergeRefs(refs) {
1787
+ return function (value) {
1788
+ refs.forEach(function (ref) {
1789
+ if (typeof ref === "function") {
1790
+ ref(value);
1791
+ } else if (ref != null) {
1792
+ ref.current = value;
1793
+ }
1794
+ });
1795
+ };
1796
+ }
1797
+
1787
1798
  const EXIT_ANIMATION = 350;
1788
1799
  const SlidingPanel = /*#__PURE__*/React.forwardRef(({
1789
1800
  position = 'left',
@@ -1810,7 +1821,7 @@ const SlidingPanel = /*#__PURE__*/React.forwardRef(({
1810
1821
  appear: true,
1811
1822
  unmountOnExit: true
1812
1823
  }, /*#__PURE__*/jsxRuntime.jsx("div", {
1813
- ref: mergeRefs__default.default([reference, localReference]),
1824
+ ref: mergeRefs([reference, localReference]),
1814
1825
  className: classNames__default.default('sliding-panel', `sliding-panel--open-${position}`, showSlidingPanelBorder && `sliding-panel--border-${position}`, slidingPanelPositionFixed && 'sliding-panel--fixed', className),
1815
1826
  children: children
1816
1827
  }));
@@ -2753,6 +2764,7 @@ const convertToLocalMidnight = date => {
2753
2764
  return new Date(utcDate.getUTCFullYear(), utcDate.getUTCMonth(), utcDate.getUTCDate());
2754
2765
  };
2755
2766
 
2767
+ const MonthBeforeDay = new Set(['en-US', 'ja-JP']);
2756
2768
  const DateInput = ({
2757
2769
  'aria-labelledby': ariaLabelledBy,
2758
2770
  'aria-label': ariaLabel,
@@ -2942,86 +2954,7 @@ const DateInput = ({
2942
2954
  'col-sm-8': monthYearOnly,
2943
2955
  'col-sm-5': !monthYearOnly
2944
2956
  });
2945
- const getMonth = () => {
2946
- return /*#__PURE__*/jsxRuntime.jsx("div", {
2947
- className: monthWidth,
2948
- children: getSelectElement()
2949
- });
2950
- };
2951
- const getDay = () => {
2952
- return /*#__PURE__*/jsxRuntime.jsx("div", {
2953
- className: "col-sm-3",
2954
- children: /*#__PURE__*/jsxRuntime.jsxs("label", {
2955
- children: [/*#__PURE__*/jsxRuntime.jsx("span", {
2956
- className: "sr-only",
2957
- children: dayLabel
2958
- }), /*#__PURE__*/jsxRuntime.jsx("div", {
2959
- className: `input-group input-group-${size}`,
2960
- children: /*#__PURE__*/jsxRuntime.jsx(Input, {
2961
- type: "text",
2962
- inputMode: "numeric",
2963
- pattern: "[0-9]*",
2964
- name: "day",
2965
- autoComplete: dayAutoComplete,
2966
- value: day || '',
2967
- placeholder: placeholders?.day,
2968
- disabled: disabled,
2969
- min: 1,
2970
- onChange: event => handleDayChange(event)
2971
- })
2972
- })]
2973
- })
2974
- });
2975
- };
2976
- const getYear = () => {
2977
- return /*#__PURE__*/jsxRuntime.jsx("div", {
2978
- className: "col-sm-4",
2979
- children: /*#__PURE__*/jsxRuntime.jsxs("label", {
2980
- children: [/*#__PURE__*/jsxRuntime.jsx("span", {
2981
- className: "sr-only",
2982
- children: yearLabel
2983
- }), /*#__PURE__*/jsxRuntime.jsx("div", {
2984
- className: `input-group input-group-${size}`,
2985
- children: /*#__PURE__*/jsxRuntime.jsx(Input, {
2986
- type: "text",
2987
- inputMode: "numeric",
2988
- pattern: "[0-9]*",
2989
- name: "year",
2990
- autoComplete: yearAutoComplete,
2991
- placeholder: placeholders?.year,
2992
- value: year || '',
2993
- disabled: disabled,
2994
- min: 1,
2995
- onChange: event => handleYearChange(event)
2996
- })
2997
- })]
2998
- })
2999
- });
3000
- };
3001
- const MDY = new Set(['en-US']);
3002
- const YMD = new Set(['hu', 'hu-HU', 'zh-HK', 'zh-CN', 'ja', 'ja-JP']);
3003
- const monthBeforeDay = MDY.has(locale);
3004
- const yearFirst = YMD.has(locale);
3005
- const returnOrderedInputs = () => {
3006
- if (monthYearOnly) {
3007
- return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
3008
- children: ["!yearFirst && ", getMonth(), getYear(), "yearFirst && ", getMonth()]
3009
- });
3010
- }
3011
- if (monthBeforeDay) {
3012
- return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
3013
- children: [getMonth(), getDay(), getYear()]
3014
- });
3015
- } else if (yearFirst) {
3016
- return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
3017
- children: [getYear(), getMonth(), getDay()]
3018
- });
3019
- } else {
3020
- return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
3021
- children: [getDay(), getMonth(), getYear()]
3022
- });
3023
- }
3024
- };
2957
+ const monthBeforeDay = MonthBeforeDay.has(locale);
3025
2958
  return /*#__PURE__*/jsxRuntime.jsx("div", {
3026
2959
  className: "tw-date",
3027
2960
  id: id,
@@ -3031,9 +2964,59 @@ const DateInput = ({
3031
2964
  ,
3032
2965
  onFocus: event => shouldPropagateOnFocus(event) ? onFocus && onFocus(event) : event.stopPropagation(),
3033
2966
  onBlur: event => shouldPropagateOnBlur(event) ? onBlur && onBlur(event) : event.stopPropagation(),
3034
- children: /*#__PURE__*/jsxRuntime.jsx("div", {
2967
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
3035
2968
  className: "row",
3036
- children: returnOrderedInputs()
2969
+ children: [monthBeforeDay && /*#__PURE__*/jsxRuntime.jsx("div", {
2970
+ className: monthWidth,
2971
+ children: getSelectElement()
2972
+ }), !monthYearOnly && /*#__PURE__*/jsxRuntime.jsx("div", {
2973
+ className: "col-sm-3",
2974
+ children: /*#__PURE__*/jsxRuntime.jsxs("label", {
2975
+ children: [/*#__PURE__*/jsxRuntime.jsx("span", {
2976
+ className: "sr-only",
2977
+ children: dayLabel
2978
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
2979
+ className: `input-group input-group-${size}`,
2980
+ children: /*#__PURE__*/jsxRuntime.jsx(Input, {
2981
+ type: "text",
2982
+ inputMode: "numeric",
2983
+ pattern: "[0-9]*",
2984
+ name: "day",
2985
+ autoComplete: dayAutoComplete,
2986
+ value: day || '',
2987
+ placeholder: placeholders.day,
2988
+ disabled: disabled,
2989
+ min: 1,
2990
+ onChange: event => handleDayChange(event)
2991
+ })
2992
+ })]
2993
+ })
2994
+ }), !monthBeforeDay && /*#__PURE__*/jsxRuntime.jsx("div", {
2995
+ className: monthWidth,
2996
+ children: getSelectElement()
2997
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
2998
+ className: "col-sm-4",
2999
+ children: /*#__PURE__*/jsxRuntime.jsxs("label", {
3000
+ children: [/*#__PURE__*/jsxRuntime.jsx("span", {
3001
+ className: "sr-only",
3002
+ children: yearLabel
3003
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
3004
+ className: `input-group input-group-${size}`,
3005
+ children: /*#__PURE__*/jsxRuntime.jsx(Input, {
3006
+ type: "text",
3007
+ inputMode: "numeric",
3008
+ pattern: "[0-9]*",
3009
+ name: "year",
3010
+ autoComplete: yearAutoComplete,
3011
+ placeholder: placeholders.year,
3012
+ value: year || '',
3013
+ disabled: disabled,
3014
+ min: 1,
3015
+ onChange: event => handleYearChange(event)
3016
+ })
3017
+ })]
3018
+ })
3019
+ })]
3037
3020
  })
3038
3021
  });
3039
3022
  };
@@ -6602,7 +6585,7 @@ function SelectInput({
6602
6585
  }) => /*#__PURE__*/jsxRuntime.jsx(SelectInputTriggerButtonPropsContext.Provider, {
6603
6586
  // eslint-disable-next-line react/jsx-no-constructed-context-values
6604
6587
  value: {
6605
- ref: mergeRefs__default.default([ref, triggerRef]),
6588
+ ref: mergeRefs([ref, triggerRef]),
6606
6589
  id,
6607
6590
  ...mergeProps__default.default({
6608
6591
  onClick: () => {
@@ -15103,13 +15086,12 @@ const translations = {
15103
15086
  cs,
15104
15087
  de,
15105
15088
  en,
15106
- 'en-US': en,
15107
15089
  es,
15108
15090
  fr,
15109
15091
  hu,
15110
15092
  id,
15111
15093
  it,
15112
- 'ja-JP': ja,
15094
+ ja,
15113
15095
  pl,
15114
15096
  pt,
15115
15097
  ro,