@transferwise/components 0.0.0-experimental-dad811d → 0.0.0-experimental-36cf7cb

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 (62) hide show
  1. package/build/index.esm.js +193 -327
  2. package/build/index.esm.js.map +1 -1
  3. package/build/index.js +164 -298
  4. package/build/index.js.map +1 -1
  5. package/build/main.css +6 -82
  6. package/build/styles/decision/Decision.css +6 -82
  7. package/build/styles/main.css +6 -82
  8. package/build/types/body/Body.d.ts +1 -1
  9. package/build/types/card/Card.d.ts +0 -1
  10. package/build/types/card/Card.d.ts.map +1 -1
  11. package/build/types/common/Option/Option.d.ts +0 -1
  12. package/build/types/common/Option/Option.d.ts.map +1 -1
  13. package/build/types/common/commonProps.d.ts +1 -1
  14. package/build/types/common/commonProps.d.ts.map +1 -1
  15. package/build/types/common/panel/Panel.d.ts +1 -1
  16. package/build/types/common/responsivePanel/ResponsivePanel.d.ts +1 -1
  17. package/build/types/dateInput/index.d.ts +2 -2
  18. package/build/types/dateInput/index.d.ts.map +1 -1
  19. package/build/types/dateLookup/DateLookup.d.ts +1 -0
  20. package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
  21. package/build/types/decision/Decision.d.ts +39 -52
  22. package/build/types/decision/Decision.d.ts.map +1 -1
  23. package/build/types/decision/index.d.ts +1 -2
  24. package/build/types/decision/index.d.ts.map +1 -1
  25. package/build/types/dimmer/Dimmer.d.ts +1 -1
  26. package/build/types/index.d.ts +2 -0
  27. package/build/types/index.d.ts.map +1 -1
  28. package/build/types/promoCard/PromoCard.d.ts +1 -2
  29. package/build/types/promoCard/PromoCard.d.ts.map +1 -1
  30. package/build/types/select/searchBox/SearchBox.d.ts +1 -1
  31. package/package.json +1 -1
  32. package/src/card/Card.js +0 -3
  33. package/src/card/Card.story.js +2 -17
  34. package/src/common/Option/Option.spec.js +0 -7
  35. package/src/common/Option/Option.tsx +2 -9
  36. package/src/common/commonProps.ts +1 -1
  37. package/src/dateInput/index.ts +2 -3
  38. package/src/dateLookup/DateLookup.js +12 -1
  39. package/src/dateLookup/DateLookup.testingLibrary.spec.js +12 -1
  40. package/src/decision/Decision.css +6 -82
  41. package/src/decision/Decision.less +3 -41
  42. package/src/decision/Decision.spec.js +56 -61
  43. package/src/decision/{Decision.story.js → Decision.story.tsx} +5 -5
  44. package/src/decision/Decision.tsx +133 -0
  45. package/src/decision/index.ts +1 -0
  46. package/src/index.ts +2 -0
  47. package/src/main.css +6 -82
  48. package/src/promoCard/PromoCard.tsx +1 -2
  49. package/src/tile/Tile.js +1 -1
  50. package/build/types/decision/decisionEnums.d.ts +0 -9
  51. package/build/types/decision/decisionEnums.d.ts.map +0 -1
  52. package/build/types/sizeSwapper/SizeSwapper.d.ts +0 -3
  53. package/build/types/sizeSwapper/SizeSwapper.d.ts.map +0 -1
  54. package/build/types/sizeSwapper/index.d.ts +0 -2
  55. package/build/types/sizeSwapper/index.d.ts.map +0 -1
  56. package/src/decision/Decision.js +0 -148
  57. package/src/decision/decisionEnums.ts +0 -11
  58. package/src/decision/index.js +0 -2
  59. package/src/sizeSwapper/SizeSwapper.js +0 -69
  60. package/src/sizeSwapper/SizeSwapper.spec.js +0 -100
  61. package/src/sizeSwapper/SizeSwapper.story.js +0 -34
  62. package/src/sizeSwapper/index.js +0 -1
@@ -1,7 +1,7 @@
1
1
  import classNames from 'classnames';
2
2
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
3
  import * as React from 'react';
4
- import React__default, { forwardRef, useMemo, cloneElement, useState, useRef, useEffect, useCallback, useLayoutEffect, createContext, useContext, Component, PureComponent, createRef, Children, Fragment as Fragment$1 } from 'react';
4
+ import React__default, { forwardRef, cloneElement, useState, useRef, useMemo, useEffect, useCallback, useLayoutEffect, createContext, useContext, Component, PureComponent, createRef, Children, Fragment as Fragment$1 } from 'react';
5
5
  import { useId } from '@radix-ui/react-id';
6
6
  import { ChevronUp, CrossCircleFill, Cross, NavigateAway, Check, Info as Info$1, Alert as Alert$2, ClockBorderless, CheckCircle, InfoCircle, Warning, CrossCircle, Clock, Briefcase, Person, ArrowLeft, QuestionMarkCircle, AlertCircle, Search, ChevronDown, CheckCircleFill, ArrowRight, Download, ClockFill, Upload as Upload$2, Document, Plus, PlusCircle, AlertCircleFill } from '@transferwise/icons';
7
7
  import { defineMessages, useIntl, injectIntl, IntlProvider } from 'react-intl';
@@ -207,7 +207,7 @@ var Width;
207
207
  /**
208
208
  * @deprecated use `ControlType` and `Priority` enums instead
209
209
  */
210
- var Type$1;
210
+ var Type;
211
211
  (function (Type) {
212
212
  Type["PRIMARY"] = "primary";
213
213
  /**
@@ -217,7 +217,7 @@ var Type$1;
217
217
  Type["SECONDARY"] = "secondary";
218
218
  Type["DANGER"] = "danger";
219
219
  Type["LINK"] = "link";
220
- })(Type$1 || (Type$1 = {}));
220
+ })(Type || (Type = {}));
221
221
 
222
222
  var DateMode;
223
223
  (function (DateMode) {
@@ -244,7 +244,7 @@ var Position;
244
244
  Position["TOP"] = "top";
245
245
  })(Position || (Position = {}));
246
246
 
247
- var Layout$1;
247
+ var Layout;
248
248
  (function (Layout) {
249
249
  Layout["VERTICAL"] = "VERTICAL";
250
250
  Layout["VERTICAL_TWO_COLUMN"] = "VERTICAL_TWO_COLUMN";
@@ -253,7 +253,7 @@ var Layout$1;
253
253
  Layout["HORIZONTAL_JUSTIFIED"] = "HORIZONTAL_JUSTIFIED";
254
254
  Layout["HORIZONTAL_LEFT_ALIGNED"] = "HORIZONTAL_LEFT_ALIGNED";
255
255
  Layout["HORIZONTAL_RIGHT_ALIGNED"] = "HORIZONTAL_RIGHT_ALIGNED";
256
- })(Layout$1 || (Layout$1 = {}));
256
+ })(Layout || (Layout = {}));
257
257
 
258
258
  var Status;
259
259
  (function (Status) {
@@ -515,108 +515,8 @@ const Chevron = ({
515
515
  });
516
516
  };
517
517
 
518
- // TODO: consider to move this enum into component file once we migrate it on TypeScript or replace with some common enum
519
- var AvatarType;
520
- (function (AvatarType) {
521
- AvatarType["THUMBNAIL"] = "thumbnail";
522
- AvatarType["ICON"] = "icon";
523
- AvatarType["EMOJI"] = "emoji";
524
- AvatarType["INITIALS"] = "initials";
525
- })(AvatarType || (AvatarType = {}));
526
-
527
- /*
528
- * The colors we support generating an Avatar background color from a "seed" for.
529
- * Changing this array will change the assignment between seeds.
530
- * Do not change this array.
531
- */
532
- const avatarColors = ['--color-bright-blue', '--color-bright-yellow', '--color-bright-pink', '--color-bright-orange'];
533
- /*
534
- * Takes in a "seed" string and spits out an index for the color we should use.
535
- * This implementation has been synced across all three clients so that we consistently
536
- * generate branded avatar colors when rendering a list of Avatars.
537
- * Do not change this implementation.
538
- */
539
- const hashSeed = seed => {
540
- const base = 31;
541
- const modulo = avatarColors.length;
542
- let hashValue = 0;
543
- let basePow = 1;
544
- for (let i = 0; i < seed.length; i++) {
545
- hashValue = (hashValue + seed.charCodeAt(i) * basePow) % modulo;
546
- basePow = basePow * base % modulo;
547
- }
548
- return hashValue;
549
- };
550
- const getAvatarColorFromSeed = seed => {
551
- return avatarColors[hashSeed(seed)];
552
- };
553
-
554
- const backwardsCompatibleSize = size => {
555
- switch (size) {
556
- case 'sm':
557
- return 24;
558
- case 'md':
559
- return 48;
560
- case 'lg':
561
- return 72;
562
- default:
563
- return size;
564
- }
565
- };
566
- const Avatar = ({
567
- backgroundColor = null,
568
- backgroundColorSeed = null,
569
- children = null,
570
- className,
571
- outlined = false,
572
- size: sizeFromProps = 48,
573
- theme = Theme.LIGHT,
574
- type = 'thumbnail'
575
- }) => {
576
- const backgroundColorFromSeed = useMemo(() => !backgroundColor && backgroundColorSeed ? `var(${getAvatarColorFromSeed(backgroundColorSeed)})` : undefined, [backgroundColor, backgroundColorSeed]);
577
- const size = backwardsCompatibleSize(sizeFromProps);
578
- return /*#__PURE__*/jsx("div", {
579
- className: classNames('tw-avatar', className, `tw-avatar--${size}`, `tw-avatar--${type}`, {
580
- 'tw-avatar--outlined': outlined,
581
- 'tw-avatar--branded': Boolean(backgroundColorFromSeed),
582
- 'np-text-title-body': type === 'initials'
583
- }),
584
- children: /*#__PURE__*/jsx("div", {
585
- className: "tw-avatar__content",
586
- style: {
587
- backgroundColor: backgroundColor || backgroundColorFromSeed
588
- },
589
- children: children
590
- })
591
- });
592
- };
593
-
594
- const Badge = ({
595
- badge,
596
- className = undefined,
597
- size = Size.SMALL,
598
- border = Theme.LIGHT,
599
- children
600
- }) => {
601
- const classes = classNames('tw-badge', {
602
- [`tw-badge-border-${border}`]: border,
603
- [`tw-badge-${size}`]: size
604
- }, className);
605
- return /*#__PURE__*/jsxs("div", {
606
- className: classes,
607
- children: [/*#__PURE__*/jsx("div", {
608
- className: "tw-badge__children",
609
- children: children
610
- }), /*#__PURE__*/jsx("div", {
611
- className: "tw-badge__content",
612
- children: badge
613
- })]
614
- });
615
- };
616
-
617
518
  const Option$2 = /*#__PURE__*/forwardRef(({
618
519
  media = '',
619
- badgeContentIcon = '',
620
520
  title,
621
521
  content,
622
522
  as: component,
@@ -647,13 +547,7 @@ const Option$2 = /*#__PURE__*/forwardRef(({
647
547
  className: "media",
648
548
  children: [media && /*#__PURE__*/jsx("div", {
649
549
  className: "media-left",
650
- children: badgeContentIcon ? /*#__PURE__*/jsx(Badge, {
651
- badge: badgeContentIcon,
652
- children: /*#__PURE__*/jsx(Avatar, {
653
- type: "icon",
654
- children: media
655
- })
656
- }) : showMediaCircle ? /*#__PURE__*/jsx("div", {
550
+ children: showMediaCircle ? /*#__PURE__*/jsx("div", {
657
551
  className: classNames('circle circle-sm text-primary', {
658
552
  'circle-inverse': inverseMediaCircle
659
553
  }),
@@ -1321,6 +1215,105 @@ Alert.defaultProps = {
1321
1215
  };
1322
1216
  var Alert$1 = Alert;
1323
1217
 
1218
+ // TODO: consider to move this enum into component file once we migrate it on TypeScript or replace with some common enum
1219
+ var AvatarType;
1220
+ (function (AvatarType) {
1221
+ AvatarType["THUMBNAIL"] = "thumbnail";
1222
+ AvatarType["ICON"] = "icon";
1223
+ AvatarType["EMOJI"] = "emoji";
1224
+ AvatarType["INITIALS"] = "initials";
1225
+ })(AvatarType || (AvatarType = {}));
1226
+
1227
+ /*
1228
+ * The colors we support generating an Avatar background color from a "seed" for.
1229
+ * Changing this array will change the assignment between seeds.
1230
+ * Do not change this array.
1231
+ */
1232
+ const avatarColors = ['--color-bright-blue', '--color-bright-yellow', '--color-bright-pink', '--color-bright-orange'];
1233
+ /*
1234
+ * Takes in a "seed" string and spits out an index for the color we should use.
1235
+ * This implementation has been synced across all three clients so that we consistently
1236
+ * generate branded avatar colors when rendering a list of Avatars.
1237
+ * Do not change this implementation.
1238
+ */
1239
+ const hashSeed = seed => {
1240
+ const base = 31;
1241
+ const modulo = avatarColors.length;
1242
+ let hashValue = 0;
1243
+ let basePow = 1;
1244
+ for (let i = 0; i < seed.length; i++) {
1245
+ hashValue = (hashValue + seed.charCodeAt(i) * basePow) % modulo;
1246
+ basePow = basePow * base % modulo;
1247
+ }
1248
+ return hashValue;
1249
+ };
1250
+ const getAvatarColorFromSeed = seed => {
1251
+ return avatarColors[hashSeed(seed)];
1252
+ };
1253
+
1254
+ const backwardsCompatibleSize = size => {
1255
+ switch (size) {
1256
+ case 'sm':
1257
+ return 24;
1258
+ case 'md':
1259
+ return 48;
1260
+ case 'lg':
1261
+ return 72;
1262
+ default:
1263
+ return size;
1264
+ }
1265
+ };
1266
+ const Avatar = ({
1267
+ backgroundColor = null,
1268
+ backgroundColorSeed = null,
1269
+ children = null,
1270
+ className,
1271
+ outlined = false,
1272
+ size: sizeFromProps = 48,
1273
+ theme = Theme.LIGHT,
1274
+ type = 'thumbnail'
1275
+ }) => {
1276
+ const backgroundColorFromSeed = useMemo(() => !backgroundColor && backgroundColorSeed ? `var(${getAvatarColorFromSeed(backgroundColorSeed)})` : undefined, [backgroundColor, backgroundColorSeed]);
1277
+ const size = backwardsCompatibleSize(sizeFromProps);
1278
+ return /*#__PURE__*/jsx("div", {
1279
+ className: classNames('tw-avatar', className, `tw-avatar--${size}`, `tw-avatar--${type}`, {
1280
+ 'tw-avatar--outlined': outlined,
1281
+ 'tw-avatar--branded': Boolean(backgroundColorFromSeed),
1282
+ 'np-text-title-body': type === 'initials'
1283
+ }),
1284
+ children: /*#__PURE__*/jsx("div", {
1285
+ className: "tw-avatar__content",
1286
+ style: {
1287
+ backgroundColor: backgroundColor || backgroundColorFromSeed
1288
+ },
1289
+ children: children
1290
+ })
1291
+ });
1292
+ };
1293
+
1294
+ const Badge = ({
1295
+ badge,
1296
+ className = undefined,
1297
+ size = Size.SMALL,
1298
+ border = Theme.LIGHT,
1299
+ children
1300
+ }) => {
1301
+ const classes = classNames('tw-badge', {
1302
+ [`tw-badge-border-${border}`]: border,
1303
+ [`tw-badge-${size}`]: size
1304
+ }, className);
1305
+ return /*#__PURE__*/jsxs("div", {
1306
+ className: classes,
1307
+ children: [/*#__PURE__*/jsx("div", {
1308
+ className: "tw-badge__children",
1309
+ children: children
1310
+ }), /*#__PURE__*/jsx("div", {
1311
+ className: "tw-badge__content",
1312
+ children: badge
1313
+ })]
1314
+ });
1315
+ };
1316
+
1324
1317
  const OptionalBadge = ({
1325
1318
  url,
1326
1319
  altText,
@@ -2246,23 +2239,23 @@ const priorityClassMap = {
2246
2239
  };
2247
2240
 
2248
2241
  const deprecatedTypeMap = {
2249
- [Type$1.PRIMARY]: ControlType.ACCENT,
2250
- [Type$1.SECONDARY]: ControlType.ACCENT,
2251
- [Type$1.LINK]: ControlType.ACCENT,
2252
- [Type$1.PAY]: ControlType.POSITIVE,
2253
- [Type$1.DANGER]: ControlType.NEGATIVE
2242
+ [Type.PRIMARY]: ControlType.ACCENT,
2243
+ [Type.SECONDARY]: ControlType.ACCENT,
2244
+ [Type.LINK]: ControlType.ACCENT,
2245
+ [Type.PAY]: ControlType.POSITIVE,
2246
+ [Type.DANGER]: ControlType.NEGATIVE
2254
2247
  };
2255
2248
  const oldTypePriorityMap = {
2256
- [Type$1.DANGER]: Priority.SECONDARY,
2257
- [Type$1.LINK]: Priority.TERTIARY,
2258
- [Type$1.SECONDARY]: Priority.SECONDARY
2249
+ [Type.DANGER]: Priority.SECONDARY,
2250
+ [Type.LINK]: Priority.TERTIARY,
2251
+ [Type.SECONDARY]: Priority.SECONDARY
2259
2252
  };
2260
2253
  const deprecatedTypeMapMessage = {
2261
- [Type$1.DANGER]: 'Type.NEGATIVE',
2262
- [Type$1.LINK]: 'ControlType.ACCENT with priority Priority.TERTIARY',
2263
- [Type$1.PAY]: 'ControlType.POSITIVE',
2264
- [Type$1.PRIMARY]: 'ControlType.ACCENT',
2265
- [Type$1.SECONDARY]: 'ControlType.ACCENT with priority Priority.SECONDARY'
2254
+ [Type.DANGER]: 'Type.NEGATIVE',
2255
+ [Type.LINK]: 'ControlType.ACCENT with priority Priority.TERTIARY',
2256
+ [Type.PAY]: 'ControlType.POSITIVE',
2257
+ [Type.PRIMARY]: 'ControlType.ACCENT',
2258
+ [Type.SECONDARY]: 'ControlType.ACCENT with priority Priority.SECONDARY'
2266
2259
  };
2267
2260
  const deprecatedTypes = Object.keys(deprecatedTypeMap);
2268
2261
  const establishNewType = originalType => deprecatedTypeMap[originalType] || originalType;
@@ -2365,7 +2358,6 @@ const Card$1 = /*#__PURE__*/forwardRef((props, reference) => {
2365
2358
  children,
2366
2359
  onClick,
2367
2360
  icon,
2368
- badgeContentIcon,
2369
2361
  id,
2370
2362
  className,
2371
2363
  ...rest
@@ -2385,7 +2377,6 @@ const Card$1 = /*#__PURE__*/forwardRef((props, reference) => {
2385
2377
  as: children ? 'button' : 'div',
2386
2378
  className: classNames('np-card__button'),
2387
2379
  media: icon,
2388
- badgeContentIcon: badgeContentIcon,
2389
2380
  title: title,
2390
2381
  content: details,
2391
2382
  showMediaAtAllSizes: true,
@@ -2416,7 +2407,6 @@ Card$1.propTypes = {
2416
2407
  details: PropTypes.node.isRequired,
2417
2408
  onClick: requiredIf(PropTypes.func, hasChildren),
2418
2409
  icon: PropTypes.node,
2419
- badgeContentIcon: PropTypes.node,
2420
2410
  children: PropTypes.node,
2421
2411
  id: PropTypes.string,
2422
2412
  className: PropTypes.string,
@@ -4276,6 +4266,7 @@ class DateLookup extends PureComponent {
4276
4266
  size,
4277
4267
  placeholder,
4278
4268
  label,
4269
+ 'aria-labelledby': ariaLabelledBy,
4279
4270
  monthFormat,
4280
4271
  disabled,
4281
4272
  clearable,
@@ -4284,6 +4275,7 @@ class DateLookup extends PureComponent {
4284
4275
  return /*#__PURE__*/jsxs("div", {
4285
4276
  // eslint-disable-line jsx-a11y/no-static-element-interactions
4286
4277
  ref: this.element,
4278
+ "aria-labelledby": ariaLabelledBy,
4287
4279
  className: "input-group",
4288
4280
  onKeyDown: this.handleKeyDown,
4289
4281
  children: [/*#__PURE__*/jsx(DateTrigger$1, {
@@ -4313,6 +4305,7 @@ DateLookup.propTypes = {
4313
4305
  size: PropTypes.oneOf(['sm', 'md', 'lg']),
4314
4306
  placeholder: PropTypes.string,
4315
4307
  label: PropTypes.string,
4308
+ 'aria-labelledby': PropTypes.string,
4316
4309
  monthFormat: PropTypes.oneOf(['long', 'short']),
4317
4310
  disabled: PropTypes.bool,
4318
4311
  onChange: PropTypes.func.isRequired,
@@ -4335,19 +4328,6 @@ DateLookup.defaultProps = {
4335
4328
  };
4336
4329
  var DateLookup$1 = DateLookup;
4337
4330
 
4338
- // TODO: consider to move this enum into component file once we migrate it on TypeScript or replace with some common enum
4339
- var Presentation;
4340
- (function (Presentation) {
4341
- Presentation["LIST"] = "LIST";
4342
- Presentation["LIST_BLOCK"] = "LIST_BLOCK";
4343
- Presentation["LIST_BLOCK_GRID"] = "LIST_BLOCK_GRID";
4344
- })(Presentation || (Presentation = {}));
4345
- // TODO: consider to move this enum into component file once we migrate it on TypeScript or replace with some common enum
4346
- var Type;
4347
- (function (Type) {
4348
- Type["NAVIGATION"] = "NAVIGATION";
4349
- })(Type || (Type = {}));
4350
-
4351
4331
  const NavigationOption = /*#__PURE__*/forwardRef(({
4352
4332
  as: component = 'button',
4353
4333
  disabled = false,
@@ -4381,70 +4361,6 @@ const NavigationOption = /*#__PURE__*/forwardRef(({
4381
4361
  });
4382
4362
  });
4383
4363
 
4384
- const Layout = {
4385
- COLUMN: 'COLUMN'
4386
- };
4387
- const SizeSwapper = /*#__PURE__*/forwardRef(({
4388
- items,
4389
- inline
4390
- }, reference) => {
4391
- const parentReference = useRef(null);
4392
- const [clientWidth] = useClientWidth({
4393
- ref: reference || parentReference
4394
- });
4395
- if (!items || items.length === 0) {
4396
- return null;
4397
- }
4398
- // If all breakpoints are specified and clientWidth never > breakpoint itemsToRender can be undefined.
4399
- // Do not use deconstruct here to get items and layout.
4400
- let itemsToRender = [];
4401
- if (clientWidth) {
4402
- itemsToRender = items.filter(({
4403
- breakpoint = 0
4404
- }) => clientWidth >= breakpoint).pop();
4405
- } else {
4406
- // On SSR environments useClientWidth returns null because ref is undefined so we render
4407
- // all elements by default.
4408
- // If there's no SSR and on first Hydration only the right elements are going to be rendered.
4409
- // If clientWidth is null or zero all elements render like a responsive technique would do.
4410
- itemsToRender.items = items.map(({
4411
- items
4412
- }) => Object.values(items));
4413
- }
4414
-
4415
- // Always return parent container even if there are no items to display to
4416
- // keep the ref on DOM and let clientWidth be calculated properly.
4417
- return /*#__PURE__*/jsx("div", {
4418
- ref: parentReference,
4419
- className: classNames('np-size-swapper', {
4420
- 'd-flex': !inline,
4421
- 'd-inline-flex': inline,
4422
- 'flex-column': itemsToRender && itemsToRender.layout === Layout.COLUMN,
4423
- 'flex-wrap': itemsToRender && itemsToRender.wrap
4424
- }),
4425
- style: {
4426
- visibility: clientWidth ? 'visible' : 'hidden'
4427
- },
4428
- children: itemsToRender && itemsToRender.items
4429
- });
4430
- });
4431
- SizeSwapper.Breakpoint = Breakpoint;
4432
- SizeSwapper.Layout = Layout;
4433
- SizeSwapper.propTypes = {
4434
- inline: PropTypes.bool,
4435
- /** List of items that will appear at the specified breakpoint and presented in row or columns depending on layout */
4436
- items: PropTypes.arrayOf(PropTypes.shape({
4437
- items: PropTypes.arrayOf(PropTypes.element),
4438
- breakpoint: PropTypes.number,
4439
- layout: PropTypes.oneOf([SizeSwapper.Layout.COLUMN]),
4440
- wrap: PropTypes.bool
4441
- })).isRequired
4442
- };
4443
- SizeSwapper.defaultProps = {
4444
- inline: false
4445
- };
4446
- var SizeSwapper$1 = SizeSwapper;
4447
-
4448
4364
  const Tile = ({
4449
4365
  className,
4450
4366
  description,
@@ -4493,7 +4409,7 @@ Tile.propTypes = {
4493
4409
  className: PropTypes.string,
4494
4410
  description: PropTypes.node,
4495
4411
  disabled: PropTypes.bool,
4496
- href: PropTypes.string.isRequired,
4412
+ href: PropTypes.string,
4497
4413
  target: PropTypes.oneOf(['_self', '_blank', '_parent', '_top']),
4498
4414
  /** Accepts only Avatar and images */
4499
4415
  media: PropTypes.node.isRequired,
@@ -4512,85 +4428,28 @@ Tile.defaultProps = {
4512
4428
  };
4513
4429
  var Tile$1 = Tile;
4514
4430
 
4431
+ var DecisionPresentation;
4432
+ (function (DecisionPresentation) {
4433
+ DecisionPresentation["LIST"] = "LIST";
4434
+ DecisionPresentation["LIST_BLOCK"] = "LIST_BLOCK";
4435
+ DecisionPresentation["LIST_BLOCK_GRID"] = "LIST_BLOCK_GRID";
4436
+ })(DecisionPresentation || (DecisionPresentation = {}));
4437
+ var DecisionType;
4438
+ (function (DecisionType) {
4439
+ DecisionType["NAVIGATION"] = "NAVIGATION";
4440
+ })(DecisionType || (DecisionType = {}));
4515
4441
  const Decision = ({
4516
4442
  options,
4517
- presentation,
4518
- type,
4519
- showMediaCircleInList,
4520
- isContainerAligned,
4521
- size
4443
+ presentation = DecisionPresentation.LIST,
4444
+ size = Size.MEDIUM,
4445
+ type = DecisionType.NAVIGATION,
4446
+ showMediaCircleInList = true,
4447
+ isContainerAligned = false
4522
4448
  }) => {
4523
- if (type === Type.NAVIGATION) {
4524
- const {
4525
- LIST_BLOCK,
4526
- LIST_BLOCK_GRID
4527
- } = Presentation;
4528
- if (presentation === LIST_BLOCK || presentation === LIST_BLOCK_GRID) {
4529
- const isSmall = size === Size.SMALL;
4530
- const isGrid = presentation === LIST_BLOCK_GRID;
4531
- const items = [{
4532
- items: [],
4533
- layout: SizeSwapper$1.Layout.COLUMN
4534
- }, {
4535
- items: [],
4536
- breakpoint: isSmall ? Breakpoint.EXTRA_SMALL : Breakpoint.SMALL,
4537
- wrap: isGrid
4538
- }];
4539
- options.forEach(({
4540
- description,
4541
- disabled,
4542
- href,
4543
- target,
4544
- media: {
4545
- block,
4546
- list
4547
- },
4548
- onClick,
4549
- title
4550
- }, key) => {
4551
- items[0].items.push( /*#__PURE__*/jsx(NavigationOption
4552
- // eslint-disable-next-line react/no-array-index-key
4553
- , {
4554
- complex: false,
4555
- content: description,
4556
- disabled: disabled,
4557
- href: href,
4558
- target: target,
4559
- media: list,
4560
- showMediaAtAllSizes: true,
4561
- showMediaCircle: showMediaCircleInList,
4562
- isContainerAligned: isContainerAligned,
4563
- title: title,
4564
- onClick: onClick
4565
- }, `nav-${key}`));
4566
- items[1].items.push( /*#__PURE__*/jsx(Tile$1
4567
- // eslint-disable-next-line react/no-array-index-key
4568
- , {
4569
- className: classNames(`np-decision__tile${isSmall ? '--small' : ''}`, {
4570
- 'np-decision__tile--fixed-width': isGrid
4571
- }),
4572
- description: description,
4573
- disabled: disabled,
4574
- href: href,
4575
- target: target,
4576
- media: block,
4577
- size: isSmall ? Size.SMALL : Size.MEDIUM,
4578
- title: title,
4579
- onClick: onClick
4580
- }, `tile-${key}`));
4581
- });
4582
- return /*#__PURE__*/jsx("div", {
4583
- className: classNames('np-decision', {
4584
- 'np-decision--small': isSmall,
4585
- 'np-decision--grid': isGrid
4586
- }),
4587
- children: /*#__PURE__*/jsx(SizeSwapper$1, {
4588
- items: items
4589
- })
4590
- });
4591
- }
4592
- // LIST
4593
- return options.map(({
4449
+ const screenXs = useScreenSize(Breakpoint.EXTRA_SMALL);
4450
+ const screenSm = useScreenSize(Breakpoint.SMALL);
4451
+ if (type === DecisionType.NAVIGATION) {
4452
+ const renderedOptions = options.map(({
4594
4453
  title,
4595
4454
  description,
4596
4455
  disabled,
@@ -4615,44 +4474,51 @@ const Decision = ({
4615
4474
  title: title,
4616
4475
  onClick: onClick
4617
4476
  }, `nav-${key}`));
4477
+ if (presentation === DecisionPresentation.LIST_BLOCK || presentation === DecisionPresentation.LIST_BLOCK_GRID) {
4478
+ const isSmall = size === Size.SMALL;
4479
+ const breakpoint = isSmall ? screenXs : screenSm;
4480
+ const isGrid = presentation === DecisionPresentation.LIST_BLOCK_GRID;
4481
+ return /*#__PURE__*/jsx("div", {
4482
+ className: classNames('np-decision d-flex', {
4483
+ 'np-decision--small': isSmall,
4484
+ 'np-decision--grid': isGrid
4485
+ }, breakpoint ? isGrid && 'flex-wrap' : 'flex-column'),
4486
+ children: breakpoint ? options.map(({
4487
+ description,
4488
+ disabled,
4489
+ href,
4490
+ target,
4491
+ media: {
4492
+ block
4493
+ },
4494
+ onClick,
4495
+ title
4496
+ }, key) => /*#__PURE__*/jsx(Tile$1
4497
+ // eslint-disable-next-line react/no-array-index-key
4498
+ , {
4499
+ className: classNames(`np-decision__tile${isSmall ? '--small' : ''}`, {
4500
+ 'np-decision__tile--fixed-width': isGrid
4501
+ }),
4502
+ description: description,
4503
+ disabled: disabled,
4504
+ href: href,
4505
+ target: target,
4506
+ media: block,
4507
+ size: isSmall ? Size.SMALL : Size.MEDIUM,
4508
+ title: title,
4509
+ onClick: onClick
4510
+ }, `tile-${key}`)) : renderedOptions
4511
+ });
4512
+ }
4513
+ // LIST
4514
+ return /*#__PURE__*/jsx(Fragment, {
4515
+ children: renderedOptions
4516
+ });
4618
4517
  }
4619
- return /*#__PURE__*/jsx(Fragment, {});
4620
- };
4621
- Decision.propTypes = {
4622
- /** A list of elements to be rendered */
4623
- options: PropTypes.arrayOf(PropTypes.shape({
4624
- description: PropTypes.node,
4625
- disabled: PropTypes.bool,
4626
- href: PropTypes.string,
4627
- target: PropTypes.oneOf(['_self', '_blank', '_parent', '_top']),
4628
- media: PropTypes.shape({
4629
- block: PropTypes.node.isRequired,
4630
- list: PropTypes.node.isRequired
4631
- }),
4632
- onClick: PropTypes.func,
4633
- title: PropTypes.node.isRequired
4634
- })).isRequired,
4635
- /** Handles the display mode of the component */
4636
- presentation: PropTypes.oneOf(['LIST', 'LIST_BLOCK', 'LIST_BLOCK_GRID']),
4637
- /** Size currently affects only Tile dimension */
4638
- size: PropTypes.oneOf(['sm', 'md']),
4639
- /** Decide which kind of element type needs to be rendered ex: Navigation Options or in the future Radio or Checkbox Options */
4640
- type: PropTypes.oneOf(['NAVIGATION']),
4641
- /** Display media in a circle in list presentation */
4642
- showMediaCircleInList: PropTypes.bool,
4643
- /** Sets navigation options to be aligned with the parent container */
4644
- isContainerAligned: PropTypes.bool
4645
- };
4646
- Decision.defaultProps = {
4647
- presentation: Presentation.LIST,
4648
- size: Size.MEDIUM,
4649
- type: Type.NAVIGATION,
4650
- showMediaCircleInList: true,
4651
- isContainerAligned: false
4518
+ return null;
4652
4519
  };
4653
- var Decision$1 = Decision;
4654
4520
 
4655
- const isLayoutHorizontal = layout => [Layout$1.HORIZONTAL_LEFT_ALIGNED, Layout$1.HORIZONTAL_RIGHT_ALIGNED, Layout$1.HORIZONTAL_JUSTIFIED].includes(layout);
4521
+ const isLayoutHorizontal = layout => [Layout.HORIZONTAL_LEFT_ALIGNED, Layout.HORIZONTAL_RIGHT_ALIGNED, Layout.HORIZONTAL_JUSTIFIED].includes(layout);
4656
4522
  const getAlignmentClasses = (layout, action) => {
4657
4523
  let classes = ['d-flex'];
4658
4524
  if (action) {
@@ -4662,12 +4528,12 @@ const getAlignmentClasses = (layout, action) => {
4662
4528
  classes.push('align-items-start');
4663
4529
  }
4664
4530
  }
4665
- if (layout === Layout$1.HORIZONTAL_RIGHT_ALIGNED) {
4531
+ if (layout === Layout.HORIZONTAL_RIGHT_ALIGNED) {
4666
4532
  classes.push('text-sm-right tw-definition-list--right-aligned-desktop');
4667
4533
  } else {
4668
4534
  classes.push('justify-content-between');
4669
4535
  }
4670
- if (layout === Layout$1.HORIZONTAL_JUSTIFIED) {
4536
+ if (layout === Layout.HORIZONTAL_JUSTIFIED) {
4671
4537
  classes.push('text-sm-justify');
4672
4538
  }
4673
4539
  return classes;
@@ -4679,8 +4545,8 @@ const DefinitionList = ({
4679
4545
  }) => /*#__PURE__*/jsx("dl", {
4680
4546
  className: classNames('tw-definition-list d-flex ', {
4681
4547
  'text-muted': muted,
4682
- 'flex-column': layout === Layout$1.VERTICAL_ONE_COLUMN,
4683
- 'tw-definition-list--columns flex-column flex-row--sm': layout === Layout$1.VERTICAL_TWO_COLUMN,
4548
+ 'flex-column': layout === Layout.VERTICAL_ONE_COLUMN,
4549
+ 'tw-definition-list--columns flex-column flex-row--sm': layout === Layout.VERTICAL_TWO_COLUMN,
4684
4550
  'tw-definition-list--horizontal flex-column': isLayoutHorizontal(layout)
4685
4551
  }),
4686
4552
  children: definitions.filter(definition => definition).map(({
@@ -4722,7 +4588,7 @@ DefinitionList.propTypes = {
4722
4588
  };
4723
4589
  DefinitionList.defaultProps = {
4724
4590
  definitions: [],
4725
- layout: Layout$1.VERTICAL_TWO_COLUMN,
4591
+ layout: Layout.VERTICAL_TWO_COLUMN,
4726
4592
  muted: false
4727
4593
  };
4728
4594
  var DefinitionList$1 = DefinitionList;
@@ -5275,7 +5141,7 @@ DynamicFieldDefinitionList.propTypes = {
5275
5141
  };
5276
5142
  DynamicFieldDefinitionList.defaultProps = {
5277
5143
  title: null,
5278
- layout: Layout$1.VERTICAL_TWO_COLUMN
5144
+ layout: Layout.VERTICAL_TWO_COLUMN
5279
5145
  };
5280
5146
  var DynamicFieldDefinitionList$1 = DynamicFieldDefinitionList;
5281
5147
 
@@ -5334,11 +5200,11 @@ const Emphasis = ({
5334
5200
  const FlowHeader = /*#__PURE__*/React.forwardRef(({
5335
5201
  bottomContent,
5336
5202
  className,
5337
- layout = Layout$1.HORIZONTAL,
5203
+ layout = Layout.HORIZONTAL,
5338
5204
  leftContent,
5339
5205
  rightContent
5340
5206
  }, reference) => {
5341
- const isVertical = layout === Layout$1.VERTICAL;
5207
+ const isVertical = layout === Layout.VERTICAL;
5342
5208
  return /*#__PURE__*/jsxs("div", {
5343
5209
  ref: reference,
5344
5210
  className: classNames('np-flow-header', 'd-flex', 'flex-wrap', 'align-items-center', 'justify-content-between', 'flex__item--12', className),
@@ -5749,7 +5615,7 @@ const FlowNavigation = ({
5749
5615
  steps: steps,
5750
5616
  className: classNames('np-flow-navigation__stepper')
5751
5617
  }),
5752
- layout: clientWidth != null && clientWidth < Breakpoint.LARGE ? Layout$1.VERTICAL : Layout$1.HORIZONTAL
5618
+ layout: clientWidth != null && clientWidth < Breakpoint.LARGE ? Layout.VERTICAL : Layout.HORIZONTAL
5753
5619
  })
5754
5620
  });
5755
5621
  };
@@ -15390,5 +15256,5 @@ const translations = {
15390
15256
  'zh-HK': zhHK
15391
15257
  };
15392
15258
 
15393
- 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$1 as CircularButton, ControlType, CriticalCommsBanner, DEFAULT_LANG, DEFAULT_LOCALE, DateInput, DateLookup$1 as DateLookup, DateMode, Decision$1 as Decision, Presentation as DecisionPresentation, Type as 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$1 as InstructionsList, LanguageProvider, Layout$1 as Layout, Link, ListItem$1 as ListItem, Loader$1 as Loader, Logo$1 as Logo, LogoType, Markdown$1 as 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$2 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$1 as Radio, RadioGroup$1 as RadioGroup, RadioOption$1 as RadioOption, SUPPORTED_LANGUAGES, Scroll, SearchInput, Section, SegmentedControl, Select, SelectInput, SelectInputOptionContent, SelectInputTriggerButton, Sentiment, Size, SlidingPanel$1 as SlidingPanel, SnackbarConsumer, SnackbarContext, SnackbarPortal, SnackbarProvider, Status, StatusIcon, Stepper, Sticky$1 as Sticky, Summary, Switch, SwitchOption, Tabs$1 as Tabs, TextArea, TextareaWithDisplayFormat, Theme, Title, Tooltip$1 as Tooltip, Type$1 as Type, Typeahead, Typography, Upload$1 as Upload, UploadInput, UploadStep, Variant, Width, adjustLocale, getCountryFromLocale, getDirectionFromLocale, getLangFromLocale, isBrowser, isServerSide, translations, useDirection, useLayout, useScreenSize, useSnackbar };
15259
+ 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$1 as 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$1 as InstructionsList, LanguageProvider, Layout, Link, ListItem$1 as ListItem, Loader$1 as Loader, Logo$1 as Logo, LogoType, Markdown$1 as 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$2 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$1 as Radio, RadioGroup$1 as RadioGroup, RadioOption$1 as RadioOption, SUPPORTED_LANGUAGES, Scroll, SearchInput, Section, SegmentedControl, Select, SelectInput, SelectInputOptionContent, SelectInputTriggerButton, Sentiment, Size, SlidingPanel$1 as SlidingPanel, SnackbarConsumer, SnackbarContext, SnackbarPortal, SnackbarProvider, Status, StatusIcon, Stepper, Sticky$1 as Sticky, Summary, Switch, SwitchOption, Tabs$1 as Tabs, TextArea, TextareaWithDisplayFormat, Theme, Title, Tooltip$1 as Tooltip, Type, Typeahead, Typography, Upload$1 as Upload, UploadInput, UploadStep, Variant, Width, adjustLocale, getCountryFromLocale, getDirectionFromLocale, getLangFromLocale, isBrowser, isServerSide, translations, useDirection, useLayout, useScreenSize, useSnackbar };
15394
15260
  //# sourceMappingURL=index.esm.js.map