@transferwise/components 0.0.0-experimental-756c861 → 0.0.0-experimental-a4db2ca

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.
Files changed (52) hide show
  1. package/README.md +1 -1
  2. package/build/index.js +31 -84
  3. package/build/index.js.map +1 -1
  4. package/build/index.mjs +28 -80
  5. package/build/index.mjs.map +1 -1
  6. package/build/types/card/Card.d.ts +17 -20
  7. package/build/types/card/Card.d.ts.map +1 -1
  8. package/build/types/card/index.d.ts +2 -1
  9. package/build/types/card/index.d.ts.map +1 -1
  10. package/build/types/drawer/Drawer.d.ts +19 -36
  11. package/build/types/drawer/Drawer.d.ts.map +1 -1
  12. package/build/types/drawer/index.d.ts +2 -1
  13. package/build/types/drawer/index.d.ts.map +1 -1
  14. package/build/types/index.d.ts +2 -0
  15. package/build/types/index.d.ts.map +1 -1
  16. package/package.json +4 -5
  17. package/src/accordion/Accordion.spec.js +5 -5
  18. package/src/accordion/AccordionItem/AccordionItem.spec.js +2 -2
  19. package/src/actionButton/ActionButton.spec.tsx +4 -4
  20. package/src/alert/Alert.spec.tsx +4 -4
  21. package/src/button/Button.spec.js +4 -4
  22. package/src/card/{Card.spec.js → Card.spec.tsx} +4 -4
  23. package/src/card/{Card.story.js → Card.story.tsx} +6 -15
  24. package/src/card/{Card.js → Card.tsx} +23 -34
  25. package/src/card/index.ts +2 -0
  26. package/src/carousel/Carousel.spec.tsx +17 -17
  27. package/src/circularButton/CircularButton.spec.tsx +4 -4
  28. package/src/common/RadioButton/RadioButton.spec.tsx +2 -2
  29. package/src/dateLookup/DateLookup.rtl.spec.tsx +16 -18
  30. package/src/dateLookup/DateLookup.testingLibrary.spec.js +43 -47
  31. package/src/dimmer/Dimmer.rtl.spec.js +10 -10
  32. package/src/drawer/{Drawer.rtl.spec.js → Drawer.rtl.spec.tsx} +6 -4
  33. package/src/drawer/{Drawer.story.js → Drawer.story.tsx} +20 -28
  34. package/src/drawer/{Drawer.js → Drawer.tsx} +26 -31
  35. package/src/drawer/index.ts +2 -0
  36. package/src/field/Field.spec.tsx +2 -2
  37. package/src/header/Header.spec.tsx +6 -6
  38. package/src/index.ts +2 -0
  39. package/src/inputs/SelectInput.spec.tsx +47 -26
  40. package/src/moneyInput/MoneyInput.rtl.spec.tsx +2 -2
  41. package/src/popover/Popover.spec.tsx +10 -10
  42. package/src/section/Section.story.tsx +0 -2
  43. package/src/segmentedControl/SegmentedControl.spec.tsx +10 -10
  44. package/src/select/Select.spec.js +71 -71
  45. package/src/test-utils/index.js +1 -1
  46. package/src/tooltip/Tooltip.spec.tsx +16 -15
  47. package/src/uploadInput/UploadInput.spec.tsx +10 -9
  48. package/src/uploadInput/uploadButton/UploadButton.spec.tsx +4 -4
  49. package/src/uploadInput/uploadItem/UploadItem.spec.tsx +4 -4
  50. package/src/card/index.js +0 -1
  51. package/src/drawer/index.js +0 -1
  52. /package/src/drawer/__snapshots__/{Drawer.rtl.spec.js.snap → Drawer.rtl.spec.tsx.snap} +0 -0
package/README.md CHANGED
@@ -44,7 +44,7 @@ export default function Hello() {
44
44
 
45
45
  This package exposes [type declarations](https://www.typescriptlang.org/docs/handbook/2/type-declarations.html) for all components.
46
46
 
47
- Note: types for some of components are not 100% accurate (some of them will be just [`any`](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#any)), this is due to fact that many of components written on JavaScript and types generated by [react-to-typescript-definitions](https://www.npmjs.com/package/react-to-typescript-definitions) based of components `PropTypes` and unfortunatly the library doesn't resolve all `PropTypes` features and use cases (e.g custom validators, `PropTypes.objectOf`, [requireIf](https://www.npmjs.com/package/react-required-if), etc). But bear with us as eventually it would be fully on TypeScript.
47
+ Note: types for some of components are not 100% accurate (some of them will be just [`any`](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#any)), this is due to fact that many of components written on JavaScript and types generated by [react-to-typescript-definitions](https://www.npmjs.com/package/react-to-typescript-definitions) based of components `PropTypes` and unfortunatly the library doesn't resolve all `PropTypes` features and use cases (e.g custom validators, `PropTypes.objectOf`, etc). But bear with us as eventually it would be fully on TypeScript.
48
48
 
49
49
  Please follow [rules for JS components](https://github.com/transferwise/neptune-web/blob/main/packages/components/CONTRIBUTING.md#js-component-rules) in order to generate accurate types for them.
50
50
 
package/build/index.js CHANGED
@@ -11,17 +11,16 @@ var reactTransitionGroup = require('react-transition-group');
11
11
  var focus = require('@react-aria/focus');
12
12
  var reactDom = require('react-dom');
13
13
  var neptuneValidation = require('@transferwise/neptune-validation');
14
- var PropTypes = require('prop-types');
15
14
  var formatting = require('@transferwise/formatting');
16
15
  var react$1 = require('@headlessui/react');
17
16
  var mergeProps = require('merge-props');
18
17
  var react = require('@floating-ui/react');
19
18
  var overlays = require('@react-aria/overlays');
20
19
  var reactPopper = require('react-popper');
20
+ var PropTypes = require('prop-types');
21
21
  var art = require('@wise/art');
22
22
  var clamp$2 = require('lodash.clamp');
23
23
  var debounce = require('lodash.debounce');
24
- var requiredIf = require('react-required-if');
25
24
  var web = require('@react-spring/web');
26
25
 
27
26
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
@@ -47,11 +46,10 @@ function _interopNamespace(e) {
47
46
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
48
47
  var classNames__default = /*#__PURE__*/_interopDefault(classNames);
49
48
  var commonmark__default = /*#__PURE__*/_interopDefault(commonmark);
50
- var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
51
49
  var mergeProps__default = /*#__PURE__*/_interopDefault(mergeProps);
50
+ var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
52
51
  var clamp__default = /*#__PURE__*/_interopDefault(clamp$2);
53
52
  var debounce__default = /*#__PURE__*/_interopDefault(debounce);
54
- var requiredIf__default = /*#__PURE__*/_interopDefault(requiredIf);
55
53
 
56
54
  exports.Typography = void 0;
57
55
  (function (Typography) {
@@ -1501,7 +1499,7 @@ const Button = /*#__PURE__*/React.forwardRef(({
1501
1499
  });
1502
1500
  });
1503
1501
 
1504
- const Card$2 = /*#__PURE__*/React.forwardRef(({
1502
+ const Card$1 = /*#__PURE__*/React.forwardRef(({
1505
1503
  className,
1506
1504
  children = null,
1507
1505
  id,
@@ -1534,7 +1532,7 @@ const Card$2 = /*#__PURE__*/React.forwardRef(({
1534
1532
  }), children]
1535
1533
  });
1536
1534
  });
1537
- Card$2.displayName = 'Card';
1535
+ Card$1.displayName = 'Card';
1538
1536
 
1539
1537
  function Display({
1540
1538
  as: Heading = 'h1',
@@ -1913,7 +1911,7 @@ const PromoCard = /*#__PURE__*/React.forwardRef(({
1913
1911
  React.useEffect(() => {
1914
1912
  setChecked(defaultChecked ?? isChecked ?? false);
1915
1913
  }, [defaultChecked, isChecked]);
1916
- return /*#__PURE__*/jsxRuntime.jsxs(Card$2, {
1914
+ return /*#__PURE__*/jsxRuntime.jsxs(Card$1, {
1917
1915
  ...commonProps,
1918
1916
  ...checkedProps,
1919
1917
  ...props,
@@ -2210,20 +2208,19 @@ const isVisible = (container, el) => {
2210
2208
  return elemLeft >= cScrollOffset && elemRight <= cScrollOffset + cWidth;
2211
2209
  };
2212
2210
 
2213
- const Card = /*#__PURE__*/React.forwardRef((props, reference) => {
2214
- const {
2215
- 'aria-label': ariaLabel,
2216
- as: Element,
2217
- isExpanded,
2218
- title,
2219
- details,
2220
- children,
2221
- onClick,
2222
- icon,
2223
- id,
2224
- className,
2225
- ...rest
2226
- } = props;
2211
+ const Card = /*#__PURE__*/React.forwardRef(function Card({
2212
+ 'aria-label': ariaLabel,
2213
+ as: Element = 'div',
2214
+ isExpanded,
2215
+ title,
2216
+ details,
2217
+ children,
2218
+ onClick,
2219
+ icon,
2220
+ id,
2221
+ className,
2222
+ 'data-testid': dataTestId
2223
+ }, reference) {
2227
2224
  const isOpen = !!(isExpanded && children);
2228
2225
  return /*#__PURE__*/jsxRuntime.jsxs(Element, {
2229
2226
  ref: reference,
@@ -2233,7 +2230,7 @@ const Card = /*#__PURE__*/React.forwardRef((props, reference) => {
2233
2230
  'np-card--has-icon': !!icon
2234
2231
  }),
2235
2232
  id: id,
2236
- "data-testid": rest['data-testid'],
2233
+ "data-testid": dataTestId,
2237
2234
  children: [/*#__PURE__*/jsxRuntime.jsx(Option$2, {
2238
2235
  "aria-label": ariaLabel,
2239
2236
  as: children ? 'button' : 'div',
@@ -2245,7 +2242,7 @@ const Card = /*#__PURE__*/React.forwardRef((props, reference) => {
2245
2242
  button: children && /*#__PURE__*/jsxRuntime.jsx(Chevron, {
2246
2243
  orientation: isOpen ? exports.Position.TOP : exports.Position.BOTTOM
2247
2244
  }),
2248
- onClick: () => children && onClick(!isExpanded)
2245
+ onClick: children ? () => onClick?.(!isExpanded) : undefined
2249
2246
  }), /*#__PURE__*/jsxRuntime.jsx("div", {
2250
2247
  className: classNames__default.default('np-card__divider', {
2251
2248
  'np-card__divider--expanded': isOpen
@@ -2258,31 +2255,6 @@ const Card = /*#__PURE__*/React.forwardRef((props, reference) => {
2258
2255
  })]
2259
2256
  });
2260
2257
  });
2261
- const hasChildren = ({
2262
- children
2263
- }) => children;
2264
- Card.propTypes = {
2265
- 'aria-label': PropTypes__default.default.string,
2266
- as: PropTypes__default.default.string,
2267
- isExpanded: requiredIf__default.default(PropTypes__default.default.bool, hasChildren),
2268
- title: PropTypes__default.default.node.isRequired,
2269
- details: PropTypes__default.default.node.isRequired,
2270
- onClick: requiredIf__default.default(PropTypes__default.default.func, hasChildren),
2271
- icon: PropTypes__default.default.node,
2272
- children: PropTypes__default.default.node,
2273
- id: PropTypes__default.default.string,
2274
- className: PropTypes__default.default.string,
2275
- 'data-testid': PropTypes__default.default.string
2276
- };
2277
- Card.defaultProps = {
2278
- 'aria-label': undefined,
2279
- as: 'div',
2280
- children: null,
2281
- id: null,
2282
- className: null,
2283
- 'data-testid': null
2284
- };
2285
- var Card$1 = Card;
2286
2258
 
2287
2259
  const CheckboxButton = /*#__PURE__*/React.forwardRef(({
2288
2260
  checked,
@@ -2772,15 +2744,15 @@ const SlidingPanel = /*#__PURE__*/React.forwardRef(({
2772
2744
  }));
2773
2745
  });
2774
2746
 
2775
- const Drawer = ({
2747
+ function Drawer({
2776
2748
  children,
2777
2749
  className,
2778
2750
  footerContent,
2779
2751
  headerTitle,
2780
2752
  onClose,
2781
- open,
2782
- position
2783
- }) => {
2753
+ open = false,
2754
+ position = 'right'
2755
+ }) {
2784
2756
  logActionRequiredIf('Drawer now expects `onClose`, and will soon make this prop required. Please update your usage to provide it.', !onClose);
2785
2757
  const {
2786
2758
  isMobile
@@ -2818,32 +2790,7 @@ const Drawer = ({
2818
2790
  })
2819
2791
  })
2820
2792
  });
2821
- };
2822
- Drawer.propTypes = {
2823
- /** The content to appear in the drawer body. */
2824
- children: PropTypes__default.default.node,
2825
- className: PropTypes__default.default.string,
2826
- /** The content to appear in the drawer footer. */
2827
- footerContent: PropTypes__default.default.node,
2828
- /** The content to appear in the drawer header. */
2829
- headerTitle: PropTypes__default.default.node,
2830
- /** The status of Drawer either open or not. */
2831
- open: PropTypes__default.default.bool,
2832
- /** The placement of Drawer on the screen either left or right. On mobile it will default to bottom. */
2833
- position: PropTypes__default.default.oneOf(['left', 'right', 'bottom']),
2834
- /** The action to perform on close click. */
2835
- onClose: PropTypes__default.default.func
2836
- };
2837
- Drawer.defaultProps = {
2838
- children: null,
2839
- className: undefined,
2840
- footerContent: null,
2841
- headerTitle: null,
2842
- onClose: null,
2843
- open: false,
2844
- position: exports.Position.RIGHT
2845
- };
2846
- var Drawer$1 = Drawer;
2793
+ }
2847
2794
 
2848
2795
  const INITIAL_Y_POSITION = 0;
2849
2796
  const CONTENT_SCROLL_THRESHOLD = 1;
@@ -2973,7 +2920,7 @@ const BottomSheet$1 = props => {
2973
2920
  };
2974
2921
  }
2975
2922
  const is400Zoom = useMedia(`(max-width: ${exports.Breakpoint.ZOOM_400}px)`);
2976
- return is400Zoom ? /*#__PURE__*/jsxRuntime.jsx(Drawer$1, {
2923
+ return is400Zoom ? /*#__PURE__*/jsxRuntime.jsx(Drawer, {
2977
2924
  open: props.open,
2978
2925
  className: props.className,
2979
2926
  onClose: close,
@@ -5566,7 +5513,7 @@ const Modal = ({
5566
5513
  const noDivider = checkSpecialClasses('no-divider');
5567
5514
  const contentReference = React.useRef(null);
5568
5515
  const titleId = React.useId();
5569
- return !isMedium ? /*#__PURE__*/jsxRuntime.jsx(Drawer$1, {
5516
+ return !isMedium ? /*#__PURE__*/jsxRuntime.jsx(Drawer, {
5570
5517
  open: open,
5571
5518
  headerTitle: title,
5572
5519
  footerContent: footer,
@@ -10394,7 +10341,7 @@ function Select({
10394
10341
  , {
10395
10342
  className: classNames__default.default(s('tw-icon'), s('tw-chevron-up-icon'), s('tw-chevron'), s('bottom'), s('np-select-chevron'))
10396
10343
  })]
10397
- }), isMobile ? isSearchEnabled ? /*#__PURE__*/jsxRuntime.jsx(Drawer$1, {
10344
+ }), isMobile ? isSearchEnabled ? /*#__PURE__*/jsxRuntime.jsx(Drawer, {
10398
10345
  open: open,
10399
10346
  headerTitle: searchPlaceholder || formatMessage(messages$2.searchPlaceholder),
10400
10347
  onClose: handleCloseOptions,
@@ -14695,11 +14642,11 @@ exports.Alert = Alert;
14695
14642
  exports.Avatar = Avatar;
14696
14643
  exports.AvatarWrapper = AvatarWrapper;
14697
14644
  exports.Badge = Badge;
14698
- exports.BaseCard = Card$2;
14645
+ exports.BaseCard = Card$1;
14699
14646
  exports.Body = Body;
14700
14647
  exports.BottomSheet = BottomSheet$1;
14701
14648
  exports.Button = Button;
14702
- exports.Card = Card$1;
14649
+ exports.Card = Card;
14703
14650
  exports.Carousel = Carousel;
14704
14651
  exports.Checkbox = Checkbox;
14705
14652
  exports.CheckboxButton = CheckboxButton;
@@ -14718,7 +14665,7 @@ exports.DefinitionList = DefinitionList;
14718
14665
  exports.Dimmer = Dimmer$1;
14719
14666
  exports.DirectionProvider = DirectionProvider;
14720
14667
  exports.Display = Display;
14721
- exports.Drawer = Drawer$1;
14668
+ exports.Drawer = Drawer;
14722
14669
  exports.DropFade = DropFade;
14723
14670
  exports.Emphasis = Emphasis;
14724
14671
  exports.Field = Field;