@transferwise/components 0.0.0-experimental-2b935a9 → 0.0.0-experimental-8eba5d3

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 (51) hide show
  1. package/build/index.js +96 -132
  2. package/build/index.js.map +1 -1
  3. package/build/index.mjs +94 -130
  4. package/build/index.mjs.map +1 -1
  5. package/build/types/checkbox/Checkbox.d.ts +16 -20
  6. package/build/types/checkbox/Checkbox.d.ts.map +1 -1
  7. package/build/types/checkbox/index.d.ts +2 -2
  8. package/build/types/checkbox/index.d.ts.map +1 -1
  9. package/build/types/decision/Decision.d.ts +1 -1
  10. package/build/types/decision/Decision.d.ts.map +1 -1
  11. package/build/types/definitionList/DefinitionList.d.ts +20 -24
  12. package/build/types/definitionList/DefinitionList.d.ts.map +1 -1
  13. package/build/types/definitionList/index.d.ts +2 -1
  14. package/build/types/definitionList/index.d.ts.map +1 -1
  15. package/build/types/index.d.ts +2 -0
  16. package/build/types/index.d.ts.map +1 -1
  17. package/build/types/logo/Logo.d.ts +16 -23
  18. package/build/types/logo/Logo.d.ts.map +1 -1
  19. package/build/types/logo/index.d.ts +1 -2
  20. package/build/types/logo/index.d.ts.map +1 -1
  21. package/build/types/tile/Tile.d.ts +37 -17
  22. package/build/types/tile/Tile.d.ts.map +1 -1
  23. package/build/types/tile/index.d.ts +1 -1
  24. package/build/types/tile/index.d.ts.map +1 -1
  25. package/package.json +3 -3
  26. package/src/checkbox/{Checkbox.spec.js → Checkbox.spec.tsx} +5 -5
  27. package/src/checkbox/{Checkbox.js → Checkbox.tsx} +19 -41
  28. package/src/checkbox/index.ts +2 -0
  29. package/src/decision/Decision.tsx +1 -1
  30. package/src/definitionList/{DefinitionList.story.js → DefinitionList.story.tsx} +22 -2
  31. package/src/definitionList/DefinitionList.tsx +95 -0
  32. package/src/definitionList/index.ts +2 -0
  33. package/src/index.ts +2 -0
  34. package/src/logo/Logo.story.tsx +3 -6
  35. package/src/logo/{Logo.js → Logo.tsx} +25 -35
  36. package/src/logo/index.ts +1 -0
  37. package/src/tile/{Tile.tsx → Tile.js} +35 -24
  38. package/src/tile/{Tile.spec.tsx → Tile.spec.js} +1 -1
  39. package/build/types/logo/logoTypes.d.ts +0 -6
  40. package/build/types/logo/logoTypes.d.ts.map +0 -1
  41. package/src/checkbox/index.js +0 -3
  42. package/src/definitionList/DefinitionList.js +0 -100
  43. package/src/definitionList/index.js +0 -1
  44. package/src/logo/index.js +0 -2
  45. package/src/logo/logoTypes.ts +0 -6
  46. /package/src/checkbox/__snapshots__/{Checkbox.spec.js.snap → Checkbox.spec.tsx.snap} +0 -0
  47. /package/src/logo/{Logo.spec.js → Logo.spec.tsx} +0 -0
  48. /package/src/logo/__snapshots__/{Logo.spec.js.snap → Logo.spec.tsx.snap} +0 -0
  49. /package/src/tile/{Tile.story.tsx → Tile.story.js} +0 -0
  50. /package/src/tile/__snapshots__/{Tile.spec.tsx.snap → Tile.spec.js.snap} +0 -0
  51. /package/src/tile/{index.ts → index.js} +0 -0
package/build/index.js CHANGED
@@ -2313,9 +2313,8 @@ const CheckboxButton = /*#__PURE__*/React.forwardRef(({
2313
2313
  })
2314
2314
  })]
2315
2315
  }));
2316
- var CheckboxButton$1 = CheckboxButton;
2317
2316
 
2318
- const Checkbox = ({
2317
+ function Checkbox({
2319
2318
  id,
2320
2319
  checked,
2321
2320
  required,
@@ -2327,14 +2326,11 @@ const Checkbox = ({
2327
2326
  onChange,
2328
2327
  onFocus,
2329
2328
  onBlur
2330
- }) => {
2331
- const {
2332
- isModern
2333
- } = componentsTheming.useTheme();
2329
+ }) {
2334
2330
  const classList = classNames__default.default('np-checkbox', {
2335
2331
  checkbox: true,
2336
2332
  'checkbox-lg': secondary,
2337
- disabled: isModern && disabled
2333
+ disabled
2338
2334
  }, className);
2339
2335
  const innerDisabled = disabled || readOnly;
2340
2336
  return /*#__PURE__*/jsxRuntime.jsx("div", {
@@ -2344,7 +2340,7 @@ const Checkbox = ({
2344
2340
  className: classNames__default.default({
2345
2341
  disabled
2346
2342
  }),
2347
- children: [/*#__PURE__*/jsxRuntime.jsx(CheckboxButton$1, {
2343
+ children: [/*#__PURE__*/jsxRuntime.jsx(CheckboxButton, {
2348
2344
  className: "p-r-2",
2349
2345
  checked: checked,
2350
2346
  disabled: innerDisabled,
@@ -2361,39 +2357,12 @@ const Checkbox = ({
2361
2357
  children: label
2362
2358
  }), secondary && /*#__PURE__*/jsxRuntime.jsx(Body, {
2363
2359
  as: "span",
2364
- className: classNames__default.default({
2365
- secondary: !isModern
2366
- }),
2367
2360
  children: secondary
2368
2361
  })]
2369
2362
  })]
2370
2363
  })
2371
2364
  });
2372
- };
2373
- Checkbox.propTypes = {
2374
- id: PropTypes__default.default.string,
2375
- checked: PropTypes__default.default.bool,
2376
- required: PropTypes__default.default.bool,
2377
- disabled: PropTypes__default.default.bool,
2378
- readOnly: PropTypes__default.default.bool,
2379
- label: PropTypes__default.default.node.isRequired,
2380
- secondary: PropTypes__default.default.string,
2381
- onFocus: PropTypes__default.default.func,
2382
- onChange: PropTypes__default.default.func.isRequired,
2383
- onBlur: PropTypes__default.default.func,
2384
- className: PropTypes__default.default.string
2385
- };
2386
- Checkbox.defaultProps = {
2387
- id: null,
2388
- checked: false,
2389
- required: false,
2390
- disabled: false,
2391
- readOnly: false,
2392
- secondary: null,
2393
- onFocus: null,
2394
- onBlur: null,
2395
- className: undefined
2396
- };
2365
+ }
2397
2366
 
2398
2367
  const CheckboxOption = /*#__PURE__*/React.forwardRef(({
2399
2368
  checked,
@@ -2405,7 +2374,7 @@ const CheckboxOption = /*#__PURE__*/React.forwardRef(({
2405
2374
  ...rest,
2406
2375
  ref: reference,
2407
2376
  disabled: disabled,
2408
- button: /*#__PURE__*/jsxRuntime.jsx(CheckboxButton$1, {
2377
+ button: /*#__PURE__*/jsxRuntime.jsx(CheckboxButton, {
2409
2378
  checked: checked,
2410
2379
  disabled: disabled,
2411
2380
  onChange: () => onChange?.(!checked)
@@ -4682,7 +4651,7 @@ const NavigationOption = /*#__PURE__*/React.forwardRef(({
4682
4651
  });
4683
4652
  });
4684
4653
 
4685
- function Tile({
4654
+ const Tile = ({
4686
4655
  className,
4687
4656
  description,
4688
4657
  disabled,
@@ -4690,10 +4659,10 @@ function Tile({
4690
4659
  target,
4691
4660
  media,
4692
4661
  onClick,
4693
- size = 'md',
4662
+ size,
4694
4663
  title
4695
- }) {
4696
- const isSmall = size === 'sm';
4664
+ }) => {
4665
+ const isSmall = size === exports.Size.SMALL;
4697
4666
  const Element = href ? 'a' : 'button';
4698
4667
  return /*#__PURE__*/jsxRuntime.jsxs(Element, {
4699
4668
  className: classNames__default.default('decision', 'flex-column', 'np-tile', 'text-no-decoration', 'text-xs-center', className, {
@@ -4702,12 +4671,12 @@ function Tile({
4702
4671
  }, disabled && 'disabled'),
4703
4672
  href: href,
4704
4673
  target: target,
4705
- onClick: disabled ? undefined : onClick,
4706
- onKeyDown: disabled ? undefined : ({
4674
+ onClick: disabled ? null : onClick,
4675
+ onKeyDown: disabled ? null : ({
4707
4676
  key
4708
4677
  }) => {
4709
4678
  if (key === 'Enter' || key === ' ') {
4710
- onClick?.();
4679
+ onClick();
4711
4680
  }
4712
4681
  },
4713
4682
  children: [/*#__PURE__*/jsxRuntime.jsx("div", {
@@ -4724,7 +4693,29 @@ function Tile({
4724
4693
  children: description
4725
4694
  }) : null]
4726
4695
  });
4727
- }
4696
+ };
4697
+ Tile.propTypes = {
4698
+ /** Classes to apply to the Tile container */
4699
+ className: PropTypes__default.default.string,
4700
+ description: PropTypes__default.default.node,
4701
+ disabled: PropTypes__default.default.bool,
4702
+ href: PropTypes__default.default.string,
4703
+ target: PropTypes__default.default.oneOf(['_self', '_blank', '_parent', '_top']),
4704
+ /** Accepts only Avatar and images */
4705
+ media: PropTypes__default.default.node.isRequired,
4706
+ /** Function called onClick or onKeyDown */
4707
+ onClick: PropTypes__default.default.func,
4708
+ /** The size applied to Tile */
4709
+ size: PropTypes__default.default.oneOf(['sm', 'md']),
4710
+ title: PropTypes__default.default.node.isRequired
4711
+ };
4712
+ Tile.defaultProps = {
4713
+ className: '',
4714
+ description: null,
4715
+ disabled: false,
4716
+ size: exports.Size.MEDIUM,
4717
+ target: undefined
4718
+ };
4728
4719
 
4729
4720
  exports.DecisionPresentation = void 0;
4730
4721
  (function (DecisionPresentation) {
@@ -4816,9 +4807,9 @@ const Decision = ({
4816
4807
  return null;
4817
4808
  };
4818
4809
 
4819
- const isLayoutHorizontal = layout => [exports.Layout.HORIZONTAL_LEFT_ALIGNED, exports.Layout.HORIZONTAL_RIGHT_ALIGNED, exports.Layout.HORIZONTAL_JUSTIFIED].includes(layout);
4810
+ const isLayoutHorizontal = layout => layout === exports.Layout.HORIZONTAL_LEFT_ALIGNED || layout === exports.Layout.HORIZONTAL_RIGHT_ALIGNED || layout === exports.Layout.HORIZONTAL_JUSTIFIED;
4820
4811
  const getAlignmentClasses = (layout, action) => {
4821
- let classes = ['d-flex'];
4812
+ const classes = ['d-flex'];
4822
4813
  if (action) {
4823
4814
  if (isLayoutHorizontal(layout)) {
4824
4815
  classes.push('align-items-center');
@@ -4836,60 +4827,44 @@ const getAlignmentClasses = (layout, action) => {
4836
4827
  }
4837
4828
  return classes;
4838
4829
  };
4839
- const DefinitionList = ({
4840
- definitions,
4841
- layout,
4830
+ const defaultDefinitions = [];
4831
+ function DefinitionList({
4832
+ definitions = defaultDefinitions,
4833
+ layout = 'VERTICAL_TWO_COLUMN',
4842
4834
  muted
4843
- }) => /*#__PURE__*/jsxRuntime.jsx("dl", {
4844
- className: classNames__default.default('tw-definition-list d-flex ', {
4845
- 'text-muted': muted,
4846
- 'flex-column': layout === exports.Layout.VERTICAL_ONE_COLUMN,
4847
- 'tw-definition-list--columns flex-column flex-row--sm': layout === exports.Layout.VERTICAL_TWO_COLUMN,
4848
- 'tw-definition-list--horizontal flex-column': isLayoutHorizontal(layout)
4849
- }),
4850
- children: definitions.filter(definition => definition).map(({
4851
- action,
4852
- title,
4853
- value,
4854
- key
4855
- }) => /*#__PURE__*/jsxRuntime.jsxs("div", {
4856
- className: "tw-definition-list__item",
4857
- children: [/*#__PURE__*/jsxRuntime.jsx("dt", {
4858
- children: title
4859
- }), /*#__PURE__*/jsxRuntime.jsxs("dd", {
4860
- className: classNames__default.default(...getAlignmentClasses(layout, action)),
4861
- children: [/*#__PURE__*/jsxRuntime.jsx("div", {
4862
- children: value
4863
- }), action ? /*#__PURE__*/jsxRuntime.jsx("div", {
4864
- className: classNames__default.default(isLayoutHorizontal(layout) ? 'p-l-2' : 'p-x-2', 'tw-definition-list__action'),
4865
- children: /*#__PURE__*/jsxRuntime.jsx(ActionButton, {
4866
- className: "tw-definition-list__button",
4867
- onClick: action.onClick,
4868
- children: action.label
4869
- })
4870
- }) : null]
4871
- })]
4872
- }, key))
4873
- });
4874
- DefinitionList.propTypes = {
4875
- definitions: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
4876
- action: PropTypes__default.default.shape({
4877
- label: PropTypes__default.default.string.isRequired,
4878
- onClick: PropTypes__default.default.func
4835
+ }) {
4836
+ return /*#__PURE__*/jsxRuntime.jsx("dl", {
4837
+ className: classNames__default.default('tw-definition-list d-flex ', {
4838
+ 'text-muted': muted,
4839
+ 'flex-column': layout === exports.Layout.VERTICAL_ONE_COLUMN,
4840
+ 'tw-definition-list--columns flex-column flex-row--sm': layout === exports.Layout.VERTICAL_TWO_COLUMN,
4841
+ 'tw-definition-list--horizontal flex-column': isLayoutHorizontal(layout)
4879
4842
  }),
4880
- title: PropTypes__default.default.node.isRequired,
4881
- value: PropTypes__default.default.node.isRequired,
4882
- key: PropTypes__default.default.string.isRequired
4883
- })),
4884
- layout: PropTypes__default.default.oneOf(['VERTICAL_TWO_COLUMN', 'VERTICAL_ONE_COLUMN', 'HORIZONTAL_JUSTIFIED', 'HORIZONTAL_LEFT_ALIGNED', 'HORIZONTAL_RIGHT_ALIGNED']),
4885
- muted: PropTypes__default.default.bool
4886
- };
4887
- DefinitionList.defaultProps = {
4888
- definitions: [],
4889
- layout: exports.Layout.VERTICAL_TWO_COLUMN,
4890
- muted: false
4891
- };
4892
- var DefinitionList$1 = DefinitionList;
4843
+ children: definitions.filter(definition => definition).map(({
4844
+ action,
4845
+ title,
4846
+ value,
4847
+ key
4848
+ }) => /*#__PURE__*/jsxRuntime.jsxs("div", {
4849
+ className: "tw-definition-list__item",
4850
+ children: [/*#__PURE__*/jsxRuntime.jsx("dt", {
4851
+ children: title
4852
+ }), /*#__PURE__*/jsxRuntime.jsxs("dd", {
4853
+ className: classNames__default.default(...getAlignmentClasses(layout, action)),
4854
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
4855
+ children: value
4856
+ }), action ? /*#__PURE__*/jsxRuntime.jsx("div", {
4857
+ className: classNames__default.default(isLayoutHorizontal(layout) ? 'p-l-2' : 'p-x-2', 'tw-definition-list__action'),
4858
+ children: /*#__PURE__*/jsxRuntime.jsx(ActionButton, {
4859
+ className: "tw-definition-list__button",
4860
+ onClick: action.onClick,
4861
+ children: action.label
4862
+ })
4863
+ }) : null]
4864
+ })]
4865
+ }, key))
4866
+ });
4867
+ }
4893
4868
 
4894
4869
  const DropFade = ({
4895
4870
  children,
@@ -5078,14 +5053,6 @@ const FlowHeader = /*#__PURE__*/React__namespace.forwardRef(({
5078
5053
  });
5079
5054
  });
5080
5055
 
5081
- // TODO: consider to move this enum into component file once we migrate it on TypeScript or replace with some common enum
5082
- exports.LogoType = void 0;
5083
- (function (LogoType) {
5084
- LogoType["WISE"] = "WISE";
5085
- LogoType["WISE_BUSINESS"] = "WISE_BUSINESS";
5086
- LogoType["WISE_PLATFORM"] = "WISE_PLATFORM";
5087
- })(exports.LogoType || (exports.LogoType = {}));
5088
-
5089
5056
  var LogoFlagInverse = function LogoFlagInverse(props) {
5090
5057
  return /*#__PURE__*/jsxRuntime.jsx("svg", {
5091
5058
  ...props,
@@ -5218,15 +5185,26 @@ const svgPaths = {
5218
5185
  WISE_FLAG_PLATFORM: LogoFlagPlatform,
5219
5186
  WISE_FLAG_PLATFORM_INVERSE: LogoFlagPlatformInverse
5220
5187
  };
5221
- const Logo = ({
5188
+ exports.LogoType = void 0;
5189
+ (function (LogoType) {
5190
+ LogoType["WISE"] = "WISE";
5191
+ LogoType["WISE_BUSINESS"] = "WISE_BUSINESS";
5192
+ LogoType["WISE_PLATFORM"] = "WISE_PLATFORM";
5193
+ })(exports.LogoType || (exports.LogoType = {}));
5194
+ const labelByType = {
5195
+ WISE: 'Wise',
5196
+ WISE_BUSINESS: 'Wise Business',
5197
+ WISE_PLATFORM: 'Wise Platform'
5198
+ };
5199
+ function Logo({
5222
5200
  className,
5223
5201
  inverse,
5224
- type
5225
- }) => {
5226
- const LogoSm = svgPaths[`WISE_FLAG${type === exports.LogoType.WISE_PLATFORM ? '_PLATFORM' : ''}${inverse ? '_INVERSE' : ''}`];
5202
+ type = 'WISE'
5203
+ }) {
5204
+ const LogoSm = svgPaths[`WISE_FLAG${type === 'WISE_PLATFORM' ? '_PLATFORM' : ''}${inverse ? '_INVERSE' : ''}`];
5227
5205
  const LogoMd = svgPaths[`${type}${inverse ? '_INVERSE' : ''}`];
5228
5206
  return /*#__PURE__*/jsxRuntime.jsxs("span", {
5229
- "aria-label": type === exports.LogoType.WISE ? 'Wise' : 'Wise Business' | type === exports.LogoType.WISE_PLATFORM ? 'Wise Platform' : 'Wise Business',
5207
+ "aria-label": labelByType[type],
5230
5208
  role: "img",
5231
5209
  className: classNames__default.default(className, 'np-logo'),
5232
5210
  children: [/*#__PURE__*/jsxRuntime.jsx(LogoSm, {
@@ -5235,21 +5213,7 @@ const Logo = ({
5235
5213
  className: "np-logo-svg np-logo-svg--size-md"
5236
5214
  })]
5237
5215
  });
5238
- };
5239
- Logo.propTypes = {
5240
- /** Extra classes applied to Logo */
5241
- className: PropTypes__default.default.string,
5242
- /** If true, will use dark colours for dark on light theme */
5243
- inverse: PropTypes__default.default.bool,
5244
- /** What type of logo to display */
5245
- type: PropTypes__default.default.oneOf(['WISE', 'WISE_BUSINESS', 'WISE_PLATFORM'])
5246
- };
5247
- Logo.defaultProps = {
5248
- className: undefined,
5249
- inverse: false,
5250
- type: exports.LogoType.WISE
5251
- };
5252
- var Logo$1 = Logo;
5216
+ }
5253
5217
 
5254
5218
  /* eslint-disable @typescript-eslint/ban-ts-comment */
5255
5219
  const Tooltip = ({
@@ -5479,7 +5443,7 @@ BackButton.defaultProps = {
5479
5443
  const FlowNavigation = ({
5480
5444
  activeStep = 0,
5481
5445
  avatar,
5482
- logo = /*#__PURE__*/jsxRuntime.jsx(Logo$1, {}),
5446
+ logo = /*#__PURE__*/jsxRuntime.jsx(Logo, {}),
5483
5447
  done = false,
5484
5448
  onClose,
5485
5449
  onGoBack,
@@ -7906,7 +7870,7 @@ const OverlayHeader = ({
7906
7870
  };
7907
7871
  OverlayHeader.defaultProps = {
7908
7872
  avatar: null,
7909
- logo: /*#__PURE__*/jsxRuntime.jsx(Logo$1, {}),
7873
+ logo: /*#__PURE__*/jsxRuntime.jsx(Logo, {}),
7910
7874
  onClose: null
7911
7875
  };
7912
7876
  OverlayHeader.propTypes = {
@@ -14767,7 +14731,7 @@ exports.Button = Button;
14767
14731
  exports.Card = Card$1;
14768
14732
  exports.Carousel = Carousel;
14769
14733
  exports.Checkbox = Checkbox;
14770
- exports.CheckboxButton = CheckboxButton$1;
14734
+ exports.CheckboxButton = CheckboxButton;
14771
14735
  exports.CheckboxOption = CheckboxOption;
14772
14736
  exports.Chevron = Chevron;
14773
14737
  exports.Chip = Chip;
@@ -14779,7 +14743,7 @@ exports.DEFAULT_LOCALE = DEFAULT_LOCALE;
14779
14743
  exports.DateInput = DateInput;
14780
14744
  exports.DateLookup = DateLookup$1;
14781
14745
  exports.Decision = Decision;
14782
- exports.DefinitionList = DefinitionList$1;
14746
+ exports.DefinitionList = DefinitionList;
14783
14747
  exports.Dimmer = Dimmer$1;
14784
14748
  exports.DirectionProvider = DirectionProvider;
14785
14749
  exports.Display = Display;
@@ -14801,7 +14765,7 @@ exports.LanguageProvider = LanguageProvider;
14801
14765
  exports.Link = Link;
14802
14766
  exports.ListItem = ListItem$1;
14803
14767
  exports.Loader = Loader;
14804
- exports.Logo = Logo$1;
14768
+ exports.Logo = Logo;
14805
14769
  exports.Markdown = Markdown;
14806
14770
  exports.Modal = Modal;
14807
14771
  exports.Money = Money;