@transferwise/components 0.0.0-experimental-a12c97e → 0.0.0-experimental-302d967

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 (87) hide show
  1. package/build/listItem/AvatarLayout/ListItemAvatarLayout.js +2 -0
  2. package/build/listItem/AvatarLayout/ListItemAvatarLayout.js.map +1 -1
  3. package/build/listItem/AvatarLayout/ListItemAvatarLayout.mjs +2 -0
  4. package/build/listItem/AvatarLayout/ListItemAvatarLayout.mjs.map +1 -1
  5. package/build/listItem/AvatarView/ListItemAvatarView.js +2 -0
  6. package/build/listItem/AvatarView/ListItemAvatarView.js.map +1 -1
  7. package/build/listItem/AvatarView/ListItemAvatarView.mjs +2 -0
  8. package/build/listItem/AvatarView/ListItemAvatarView.mjs.map +1 -1
  9. package/build/listItem/Image/ListItemImage.js +6 -2
  10. package/build/listItem/Image/ListItemImage.js.map +1 -1
  11. package/build/listItem/Image/ListItemImage.mjs +6 -2
  12. package/build/listItem/Image/ListItemImage.mjs.map +1 -1
  13. package/build/listItem/ListItem.js +16 -14
  14. package/build/listItem/ListItem.js.map +1 -1
  15. package/build/listItem/ListItem.mjs +16 -14
  16. package/build/listItem/ListItem.mjs.map +1 -1
  17. package/build/listItem/ListItemContext.js.map +1 -1
  18. package/build/listItem/ListItemContext.mjs.map +1 -1
  19. package/build/listItem/Navigation/ListItemNavigation.js +1 -1
  20. package/build/listItem/Navigation/ListItemNavigation.js.map +1 -1
  21. package/build/listItem/Navigation/ListItemNavigation.mjs +1 -1
  22. package/build/listItem/Navigation/ListItemNavigation.mjs.map +1 -1
  23. package/build/listItem/_stories/images/landscape.svg +1 -0
  24. package/build/listItem/_stories/images/portrait.svg +1 -0
  25. package/build/listItem/useListItemMedia.js +21 -0
  26. package/build/listItem/useListItemMedia.js.map +1 -0
  27. package/build/listItem/useListItemMedia.mjs +19 -0
  28. package/build/listItem/useListItemMedia.mjs.map +1 -0
  29. package/build/main.css +64 -101
  30. package/build/styles/avatarView/AvatarView.css +1 -3
  31. package/build/styles/listItem/ListItem.css +63 -98
  32. package/build/styles/listItem/ListItem.grid.css +17 -11
  33. package/build/styles/main.css +64 -101
  34. package/build/switch/Switch.js.map +1 -1
  35. package/build/switch/Switch.mjs.map +1 -1
  36. package/build/types/listItem/AvatarLayout/ListItemAvatarLayout.d.ts.map +1 -1
  37. package/build/types/listItem/AvatarView/ListItemAvatarView.d.ts.map +1 -1
  38. package/build/types/listItem/Image/ListItemImage.d.ts +1 -1
  39. package/build/types/listItem/Image/ListItemImage.d.ts.map +1 -1
  40. package/build/types/listItem/ListItem.d.ts +1 -1
  41. package/build/types/listItem/ListItem.d.ts.map +1 -1
  42. package/build/types/listItem/ListItemContext.d.ts +4 -0
  43. package/build/types/listItem/ListItemContext.d.ts.map +1 -1
  44. package/build/types/listItem/test-utils.d.ts +7 -0
  45. package/build/types/listItem/test-utils.d.ts.map +1 -0
  46. package/build/types/listItem/useListItemMedia.d.ts +6 -0
  47. package/build/types/listItem/useListItemMedia.d.ts.map +1 -0
  48. package/build/types/switch/Switch.d.ts +1 -1
  49. package/build/types/switch/Switch.d.ts.map +1 -1
  50. package/package.json +3 -3
  51. package/src/avatarView/AvatarView.css +1 -3
  52. package/src/avatarView/AvatarView.less +1 -2
  53. package/src/listItem/AdditionalInfo/ListItemAdditionalInfo.story.tsx +8 -58
  54. package/src/listItem/AvatarLayout/ListItemAvatarLayout.story.tsx +0 -3
  55. package/src/listItem/AvatarLayout/ListItemAvatarLayout.tsx +3 -0
  56. package/src/listItem/AvatarView/ListItemAvatarView.story.tsx +3 -21
  57. package/src/listItem/AvatarView/ListItemAvatarView.tsx +3 -0
  58. package/src/listItem/Button/ListItemButton.spec.tsx +10 -35
  59. package/src/listItem/Button/ListItemButton.story.tsx +37 -95
  60. package/src/listItem/Checkbox/ListItemCheckbox.story.tsx +0 -18
  61. package/src/listItem/IconButton/ListItemIconButton.story.tsx +2 -15
  62. package/src/listItem/Image/ListItemImage.spec.tsx +8 -5
  63. package/src/listItem/Image/ListItemImage.story.tsx +23 -6
  64. package/src/listItem/Image/ListItemImage.tsx +12 -4
  65. package/src/listItem/ListItem.css +63 -98
  66. package/src/listItem/ListItem.grid.css +17 -11
  67. package/src/listItem/ListItem.grid.less +24 -16
  68. package/src/listItem/ListItem.less +60 -113
  69. package/src/listItem/ListItem.tsx +24 -18
  70. package/src/listItem/ListItemContext.tsx +5 -0
  71. package/src/listItem/Navigation/ListItemNavigation.story.tsx +2 -5
  72. package/src/listItem/Navigation/ListItemNavigation.tsx +1 -1
  73. package/src/listItem/Radio/ListItemRadio.story.tsx +0 -10
  74. package/src/listItem/Switch/ListItemSwitch.story.tsx +0 -8
  75. package/src/listItem/_stories/ListItem.layout.test.story.tsx +142 -2
  76. package/src/listItem/_stories/ListItem.story.tsx +141 -243
  77. package/src/listItem/_stories/ListItem.variants.test.story.tsx +7 -2
  78. package/src/listItem/_stories/images/landscape.svg +1 -0
  79. package/src/listItem/_stories/images/portrait.svg +1 -0
  80. package/src/listItem/test-utils.tsx +33 -0
  81. package/src/listItem/useListItemMedia.tsx +13 -0
  82. package/src/main.css +64 -101
  83. package/src/switch/Switch.tsx +1 -1
  84. package/build/types/listItem/_stories/helpers.d.ts +0 -27
  85. package/build/types/listItem/_stories/helpers.d.ts.map +0 -1
  86. package/src/listItem/_stories/ListItem.scenarios.story.tsx +0 -209
  87. package/src/listItem/_stories/helpers.tsx +0 -53
package/src/main.css CHANGED
@@ -454,8 +454,7 @@
454
454
  right: 0;
455
455
  }
456
456
  .np-avatar-view .np-avatar-view-content {
457
- color: #37517e;
458
- color: var(--color-content-primary);
457
+ color: var(--color-interactive-primary);
459
458
  }
460
459
  .np-avatar-view-interactive {
461
460
  cursor: pointer;
@@ -463,7 +462,6 @@
463
462
  .np-avatar-view-interactive .np-circle {
464
463
  background-color: rgba(134,167,189,0.10196);
465
464
  background-color: var(--color-background-neutral);
466
- color: var(--color-interactive-primary);
467
465
  }
468
466
  .np-avatar-view-non-interactive .np-circle {
469
467
  background-color: transparent;
@@ -2642,21 +2640,21 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
2642
2640
  gap: 4px 16px;
2643
2641
  gap: var(--size-4) var(--size-16);
2644
2642
  }
2645
- @container (min-width: 380px) {
2643
+ @container (min-width: 375px) {
2646
2644
  .wds-list-item-gridWrapper.wds-list-item-hasMedia-hasControl.wds-list-item-hasInfo-hasPrompt {
2647
2645
  grid-template-columns: auto 1fr auto;
2648
2646
  grid-template-rows: auto auto auto;
2649
- grid-template-areas: "media body control" "media info control" "media prompt prompt";
2647
+ grid-template-areas: "media body control" ". info ." ". prompt prompt";
2650
2648
  }
2651
2649
  .wds-list-item-gridWrapper.wds-list-item-hasMedia-hasControl.wds-list-item-hasInfo-noPrompt {
2652
2650
  grid-template-columns: auto 1fr auto;
2653
2651
  grid-template-rows: auto auto;
2654
- grid-template-areas: "media body control" "media info control";
2652
+ grid-template-areas: "media body control" ". info .";
2655
2653
  }
2656
2654
  .wds-list-item-gridWrapper.wds-list-item-hasMedia-hasControl.wds-list-item-noInfo-hasPrompt {
2657
2655
  grid-template-columns: auto 1fr auto;
2658
2656
  grid-template-rows: auto auto;
2659
- grid-template-areas: "media body control" "media prompt prompt";
2657
+ grid-template-areas: "media body control" ". prompt prompt";
2660
2658
  }
2661
2659
  .wds-list-item-gridWrapper.wds-list-item-hasMedia-hasControl.wds-list-item-noInfo-noPrompt {
2662
2660
  grid-template-columns: auto 1fr auto;
@@ -2666,17 +2664,17 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
2666
2664
  .wds-list-item-gridWrapper.wds-list-item-hasMedia-noControl.wds-list-item-hasInfo-hasPrompt {
2667
2665
  grid-template-columns: auto 1fr;
2668
2666
  grid-template-rows: auto auto;
2669
- grid-template-areas: "media body" "media info" "media prompt";
2667
+ grid-template-areas: "media body" ". info" ". prompt";
2670
2668
  }
2671
2669
  .wds-list-item-gridWrapper.wds-list-item-hasMedia-noControl.wds-list-item-hasInfo-noPrompt {
2672
2670
  grid-template-columns: auto 1fr;
2673
2671
  grid-template-rows: auto auto auto;
2674
- grid-template-areas: "media body" "media info";
2672
+ grid-template-areas: "media body" ". info";
2675
2673
  }
2676
2674
  .wds-list-item-gridWrapper.wds-list-item-hasMedia-noControl.wds-list-item-noInfo-hasPrompt {
2677
2675
  grid-template-columns: auto 1fr;
2678
2676
  grid-template-rows: auto auto;
2679
- grid-template-areas: "media body" "media prompt";
2677
+ grid-template-areas: "media body" ". prompt";
2680
2678
  }
2681
2679
  .wds-list-item-gridWrapper.wds-list-item-hasMedia-noControl.wds-list-item-noInfo-noPrompt {
2682
2680
  grid-template-columns: auto 1fr;
@@ -2689,12 +2687,12 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
2689
2687
  .wds-list-item-gridWrapper.wds-list-item-noMedia-hasControl.wds-list-item-hasInfo-hasPrompt {
2690
2688
  grid-template-columns: 1fr auto;
2691
2689
  grid-template-rows: auto auto auto;
2692
- grid-template-areas: "body control" "info control" "prompt prompt";
2690
+ grid-template-areas: "body control" "info ." "prompt prompt";
2693
2691
  }
2694
2692
  .wds-list-item-gridWrapper.wds-list-item-noMedia-hasControl.wds-list-item-hasInfo-noPrompt {
2695
2693
  grid-template-columns: 1fr auto;
2696
2694
  grid-template-rows: auto auto;
2697
- grid-template-areas: "body control" "info control";
2695
+ grid-template-areas: "body control" "info .";
2698
2696
  }
2699
2697
  .wds-list-item-gridWrapper.wds-list-item-noMedia-hasControl.wds-list-item-noInfo-hasPrompt {
2700
2698
  grid-template-columns: 1fr auto;
@@ -2730,11 +2728,14 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
2730
2728
  grid-template-areas: "body";
2731
2729
  }
2732
2730
  }
2733
- @container (min-width: 290px) and (max-width: 380px) {
2731
+ @container (min-width: 297px) and (max-width: 375px) {
2734
2732
  .wds-list-item-gridWrapper.wds-list-item-hasMedia-hasControl .wds-list-item-media {
2735
2733
  margin-bottom: 12px;
2736
2734
  margin-bottom: var(--size-12);
2737
2735
  }
2736
+ .wds-list-item-gridWrapper.wds-list-item-hasMedia-hasControl .wds-list-item-media .wds-list-item-media-image {
2737
+ height: auto;
2738
+ }
2738
2739
  .wds-list-item-gridWrapper.wds-list-item-hasMedia-hasControl.wds-list-item-hasInfo-hasPrompt {
2739
2740
  grid-template-columns: 1fr auto;
2740
2741
  grid-template-rows: auto auto auto auto;
@@ -2775,6 +2776,9 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
2775
2776
  margin-bottom: 16px;
2776
2777
  margin-bottom: var(--size-16);
2777
2778
  }
2779
+ .wds-list-item-gridWrapper.wds-list-item-hasMedia-noControl .wds-list-item-media .wds-list-item-media-image {
2780
+ height: auto;
2781
+ }
2778
2782
  .wds-list-item-gridWrapper.wds-list-item-hasMedia-noControl.wds-list-item-hasInfo-hasPrompt {
2779
2783
  grid-template-columns: auto auto;
2780
2784
  grid-template-rows: auto auto auto auto;
@@ -2858,7 +2862,7 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
2858
2862
  grid-template-areas: "body";
2859
2863
  }
2860
2864
  }
2861
- @container (max-width: 290px) {
2865
+ @container (max-width: 297px) {
2862
2866
  .wds-list-item-gridWrapper.wds-list-item-hasMedia-hasControl.wds-list-item-hasInfo-hasPrompt {
2863
2867
  grid-template-columns: auto 1fr;
2864
2868
  grid-template-rows: auto auto auto;
@@ -3005,8 +3009,8 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
3005
3009
  background-color: #ffffff;
3006
3010
  background-color: var(--color-background-screen);
3007
3011
  position: relative;
3008
- padding: 12px 0;
3009
- padding: var(--size-12) 0;
3012
+ padding: 12px;
3013
+ padding: var(--size-12);
3010
3014
  container-type: inline-size;
3011
3015
  }
3012
3016
  .wds-list-item + .wds-list-item-spotlight,
@@ -3040,6 +3044,12 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
3040
3044
  .wds-list-item-interactive .np-checkbox-button:has(input[type="checkbox"]:focus-visible) .tw-checkbox-button {
3041
3045
  outline: none;
3042
3046
  }
3047
+ .wds-list-item-interactive:has(.wds-list-item-control:focus-visible),
3048
+ .wds-list-item-interactive:has(input[type="checkbox"]:focus-visible) {
3049
+ outline: var(--ring-outline-color) solid var(--ring-outline-width);
3050
+ outline-offset: var(--ring-outline-offset);
3051
+ outline-offset: -1px;
3052
+ }
3043
3053
  .wds-list-item-interactive .wds-list-item-additional-info {
3044
3054
  --ring-outline-offset: 0;
3045
3055
  }
@@ -3058,68 +3068,45 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
3058
3068
  position: absolute;
3059
3069
  inset: 0;
3060
3070
  }
3061
- .wds-list-item-interactive.wds-list-item-spotlight:has(.wds-list-item-control:focus-visible),
3062
- .wds-list-item-interactive.wds-list-item-spotlight:has(input[type="checkbox"]:focus-visible) {
3063
- outline: var(--ring-outline-color) solid var(--ring-outline-width);
3064
- outline-offset: var(--ring-outline-offset);
3065
- outline-offset: -1px;
3066
- }
3067
- .wds-list-item-interactive.wds-list-item-spotlight:not(.disabled):not(:disabled):hover {
3071
+ .wds-list-item-interactive:not(.disabled):not(:disabled):hover {
3068
3072
  background-color: var(--color-background-screen-hover);
3069
3073
  }
3070
- .wds-list-item-interactive.wds-list-item-spotlight:not(.disabled):not(:disabled):active {
3071
- background-color: var(--color-background-screen-active);
3072
- }
3073
- .wds-list-item-interactive.wds-list-item-spotlight:has(.wds-list-item-prompt:hover a, .wds-list-item-prompt:hover button):hover {
3074
- background-color: transparent;
3075
- background-color: initial;
3076
- }
3077
- .wds-list-item-interactive:not(.wds-list-item-spotlight):has(.wds-list-item-control:focus-visible):before,
3078
- .wds-list-item-interactive:not(.wds-list-item-spotlight):has(input[type="checkbox"]:focus-visible):before {
3079
- outline: var(--ring-outline-color) solid var(--ring-outline-width);
3080
- outline-offset: var(--ring-outline-offset);
3081
- content: '';
3082
- position: absolute;
3083
- inset: 0 -8px;
3084
- border-radius: 16px;
3085
- border-radius: var(--radius-medium);
3086
- outline-offset: -1px;
3087
- }
3088
- .wds-list-item-interactive:not(.wds-list-item-spotlight):not(.disabled):not(:disabled):hover:before,
3089
- .wds-list-item-interactive:not(.wds-list-item-spotlight):not(.disabled):not(:disabled):active:before {
3090
- content: '';
3091
- position: absolute;
3092
- inset: 0 -8px;
3093
- border-radius: 16px;
3094
- border-radius: var(--radius-medium);
3095
- }
3096
- .wds-list-item-interactive:not(.wds-list-item-spotlight):not(.disabled):not(:disabled):hover:before {
3097
- background-color: var(--color-background-screen-hover);
3098
- }
3099
- .wds-list-item-interactive:not(.wds-list-item-spotlight):not(.disabled):not(:disabled):active:before {
3100
- background-color: var(--color-background-screen-active);
3101
- }
3102
- .wds-list-item-interactive:not(.wds-list-item-spotlight):has(.wds-list-item-prompt:hover a, .wds-list-item-prompt:hover button):hover:before {
3103
- background-color: transparent;
3104
- background-color: initial;
3105
- }
3106
3074
  .wds-list-item-interactive:not(.disabled):not(:disabled):hover .wds-list-item-control-wrapper .wds-Button {
3107
3075
  background-color: var(--Button-background-hover);
3108
3076
  color: var(--Button-color-hover);
3109
3077
  transition: none;
3110
3078
  }
3079
+ .wds-list-item-interactive:not(.disabled):not(:disabled):active {
3080
+ background-color: var(--color-background-screen-active);
3081
+ }
3111
3082
  .wds-list-item-interactive .wds-list-item-button-control .wds-Button {
3112
3083
  transition: none;
3113
3084
  }
3085
+ .wds-list-item-interactive:has(.wds-list-item-prompt:hover a, .wds-list-item-prompt:hover button):hover {
3086
+ background-color: transparent;
3087
+ background-color: initial;
3088
+ }
3114
3089
  .wds-list-item-media {
3115
3090
  grid-area: media;
3091
+ display: flex;
3092
+ align-items: center;
3093
+ }
3094
+ .wds-list-item-media-image-wrapper {
3095
+ width: var(--wds-list-item-media-size);
3096
+ height: var(--wds-list-item-media-size);
3097
+ display: flex;
3098
+ align-items: center;
3099
+ justify-content: center;
3116
3100
  }
3117
3101
  .wds-list-item-media-image {
3118
- width: var(--item-media-image-size);
3119
- height: var(--item-media-image-size);
3102
+ width: 100%;
3103
+ height: 100%;
3104
+ -o-object-fit: contain;
3105
+ object-fit: contain;
3120
3106
  }
3121
3107
  .wds-list-item-body {
3122
3108
  grid-area: body;
3109
+ align-items: center;
3123
3110
  width: 100%;
3124
3111
  display: grid;
3125
3112
  grid-template-columns: 1fr max-content;
@@ -3130,11 +3117,18 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
3130
3117
  gap: var(--size-16);
3131
3118
  word-break: break-word;
3132
3119
  }
3133
- .wds-list-item-title,
3134
- .wds-list-item-title-value {
3120
+ .wds-list-item-title {
3135
3121
  color: #37517e;
3136
3122
  color: var(--color-content-primary);
3137
3123
  }
3124
+ .wds-list-item-value {
3125
+ text-align: right;
3126
+ }
3127
+ .wds-list-item-body-center {
3128
+ display: flex;
3129
+ flex-direction: row;
3130
+ align-items: center;
3131
+ }
3138
3132
  .wds-list-item-additional-info {
3139
3133
  grid-area: info;
3140
3134
  color: #768e9c;
@@ -3142,12 +3136,13 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
3142
3136
  margin-top: calc(4px * -1);
3143
3137
  margin-top: calc(var(--size-4) * -1);
3144
3138
  }
3145
- .wds-list-item-value {
3146
- align-items: end;
3147
- text-align: right;
3148
- }
3149
3139
  .wds-list-item-control-wrapper {
3150
3140
  grid-area: control;
3141
+ align-content: center;
3142
+ }
3143
+ .wds-list-item-navigation .tw-icon-chevron-right {
3144
+ color: #c9cbce;
3145
+ color: var(--color-interactive-secondary);
3151
3146
  }
3152
3147
  .wds-list-item-control {
3153
3148
  flex: 0 0 auto;
@@ -3163,12 +3158,6 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
3163
3158
  color: #768e9c;
3164
3159
  color: var(--color-content-tertiary);
3165
3160
  }
3166
- .wds-list-item-spotlight {
3167
- padding-left: 12px;
3168
- padding-left: var(--size-12);
3169
- padding-right: 12px;
3170
- padding-right: var(--size-12);
3171
- }
3172
3161
  .wds-list-item-spotlight-active {
3173
3162
  background-color: rgba(134,167,189,0.10196);
3174
3163
  background-color: var(--color-background-neutral);
@@ -3181,6 +3170,8 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
3181
3170
  }
3182
3171
  .wds-list-item-spotlight-inactive {
3183
3172
  background-color: rgba(134, 167, 189, 0.025);
3173
+ border: 1px dashed rgba(0,0,0,0.10196);
3174
+ border: 1px dashed var(--color-border-neutral);
3184
3175
  }
3185
3176
  @supports (color: color-mix(in lch, red, blue)) {
3186
3177
  .wds-list-item-spotlight-inactive {
@@ -3193,34 +3184,6 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
3193
3184
  .wds-list-item-spotlight-inactive:not(.disabled):not(:disabled):active {
3194
3185
  background-color: color-mix(in srgb, var(--color-background-neutral-active) 25%, transparent);
3195
3186
  }
3196
- .wds-list-item .wds-list-item-spotlight__border {
3197
- position: absolute;
3198
- inset: 0;
3199
- width: 100%;
3200
- height: 100%;
3201
- }
3202
- .wds-list-item .wds-list-item-spotlight__border rect {
3203
- --wds-list-item-spotlight-borderWidth: 1px;
3204
- --wds-list-item-spotlight-borderWidthOffset: 0.5px;
3205
- --wds-list-item-spotlight-strokeDashSize: calc(var(--size-12) * 0.5);
3206
- fill: none;
3207
- stroke: rgba(0,0,0,0.10196);
3208
- stroke: var(--color-border-neutral);
3209
- width: calc(100% - 1px);
3210
- width: calc(100% - var(--wds-list-item-spotlight-borderWidth));
3211
- height: calc(100% - 1px);
3212
- height: calc(100% - var(--wds-list-item-spotlight-borderWidth));
3213
- x: 0.5px;
3214
- x: var(--wds-list-item-spotlight-borderWidthOffset);
3215
- y: 0.5px;
3216
- y: var(--wds-list-item-spotlight-borderWidthOffset);
3217
- rx: calc(16px - 0.5px);
3218
- rx: calc(var(--radius-medium) - var(--wds-list-item-spotlight-borderWidthOffset));
3219
- ry: calc(16px - 0.5px);
3220
- ry: calc(var(--radius-medium) - var(--wds-list-item-spotlight-borderWidthOffset));
3221
- stroke-dasharray: calc(12px * 0.5) calc(12px * 0.5);
3222
- stroke-dasharray: var(--wds-list-item-spotlight-strokeDashSize) var(--wds-list-item-spotlight-strokeDashSize);
3223
- }
3224
3187
  .wds-list-item-prompt {
3225
3188
  grid-area: prompt;
3226
3189
  display: inline-flex;
@@ -20,7 +20,7 @@ export type SwitchProps = CommonProps & {
20
20
  /** ID to apply to the switch container */
21
21
  id?: string;
22
22
  /** Function called when the switch is toggled */
23
- onClick: (event?: MouseEvent<HTMLButtonElement>) => void;
23
+ onClick: (event?: MouseEvent<HTMLSpanElement>) => void;
24
24
  };
25
25
 
26
26
  const Switch = (props: SwitchProps) => {
@@ -1,27 +0,0 @@
1
- import { StoryObj, type Decorator } from '@storybook/react-webpack5';
2
- import type { Props as ItemProps } from '../ListItem';
3
- type Story = StoryObj<ItemProps>;
4
- /**
5
- * Recent storybook versions render the full source including all story parameters which
6
- * creates noise, this simple workaround only shows the render function.
7
- * This is a workaround for the issue.
8
- * @see https://github.com/storybookjs/storybook/issues/22281
9
- */
10
- export declare const storySourceWithoutNoise: (config: Story) => Story;
11
- /**
12
- * In order to make preview controls work correctly, we have to refresh the render
13
- * by swapping the `key`. This is a workaround for the Storybook's limitation.
14
- */
15
- export declare const withoutKey: Decorator;
16
- /**
17
- * Not all stories need access to all controls as it causes unnecessary UI noise.
18
- */
19
- export declare const disableControls: (hiddenByDefault?: string[]) => (hiddenForStory?: string[]) => {
20
- [k: string]: {
21
- table: {
22
- disable: boolean;
23
- };
24
- };
25
- };
26
- export {};
27
- //# sourceMappingURL=helpers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/listItem/_stories/helpers.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AAEtD,KAAK,KAAK,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;AAEjC;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,GAAI,QAAQ,KAAK,KAAG,KAuBvD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,UAAU,EAAE,SAExB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,GACzB,kBAAiB,MAAM,EAAO,MAC9B,iBAAgB,MAAM,EAAO;;;;;;CAG7B,CAAC"}
@@ -1,209 +0,0 @@
1
- import { useState } from 'react';
2
- import { Title, Subtitle, Description, Stories } from '@storybook/addon-docs/blocks';
3
- import { Meta, StoryObj } from '@storybook/react-webpack5';
4
- import { action } from 'storybook/actions';
5
- import { InfoCircle, Documents } from '@transferwise/icons';
6
- import { lorem10, lorem100, lorem20, lorem5 } from '../../test-utils';
7
- import Modal from '../../modal';
8
- import Link from '../../link';
9
- import Popover from '../../popover';
10
- import { SnackbarConsumer, type SnackbarContextType } from '../../snackbar/SnackbarContext';
11
- import SnackbarProvider from '../../snackbar/SnackbarProvider';
12
- import Tooltip from '../../tooltip';
13
- import { Position } from '../../common';
14
- import { ListItem, type Props as ItemProps } from '../ListItem';
15
- import { storySourceWithoutNoise } from './helpers';
16
- import {
17
- SB_LIST_ITEM_ADDITIONAL_INFO as INFO,
18
- SB_LIST_ITEM_CONTROLS as CONTROLS,
19
- SB_LIST_ITEM_MEDIA as MEDIA,
20
- SB_LIST_ITEM_PROMPTS as PROMPTS,
21
- } from './subcomponents';
22
-
23
- export default {
24
- component: ListItem,
25
- title: 'Content/ListItem/common scenarios',
26
- tags: ['autodocs'],
27
- args: {
28
- title: lorem5,
29
- subtitle: lorem10,
30
- media: MEDIA.image,
31
- additionalInfo: INFO.nonInteractive,
32
- prompt: PROMPTS.interactive,
33
- control: CONTROLS.button,
34
- },
35
- parameters: {
36
- docs: {
37
- toc: true,
38
- page: () => (
39
- <>
40
- <Title>Common scenarios</Title>
41
- <Subtitle />
42
- <Description />
43
- <Stories />
44
- </>
45
- ),
46
- },
47
- },
48
- } satisfies Meta<ItemProps>;
49
- type Story = StoryObj<ItemProps>;
50
-
51
- /**
52
- * Aside from using the main control for triggering a [Modal](?path=/docs/dialogs-modal--docs),
53
- * it's also possible to toggle it via inline-button as part of the `<ListItem.AdditionalInfo>`
54
- * or `<ListItem.Prompt>`.
55
- */
56
- export const WithModals: Story = storySourceWithoutNoise({
57
- parameters: {
58
- controls: { disable: true },
59
- },
60
- render: function WithModals(listItemProps) {
61
- const [isModalOpen, setIsModalOpen] = useState(false);
62
-
63
- const handleOpening = () => {
64
- setIsModalOpen(true);
65
- action('Modal opening')();
66
- };
67
- const handleClosing = () => {
68
- setIsModalOpen(false);
69
- action('Modal closing')();
70
- };
71
-
72
- return (
73
- <>
74
- <ListItem
75
- {...listItemProps}
76
- control={
77
- <ListItem.Button partiallyInteractive onClick={handleOpening}>
78
- Open modal
79
- </ListItem.Button>
80
- }
81
- additionalInfo={
82
- <ListItem.AdditionalInfo
83
- action={{ label: 'button opening a modal', onClick: handleOpening }}
84
- >
85
- This is additional information that contains a
86
- </ListItem.AdditionalInfo>
87
- }
88
- prompt={
89
- <ListItem.Prompt sentiment="positive">
90
- {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events */}
91
- This prompt also has a <Link onClick={handleOpening}>
92
- button that opens a modal
93
- </Link>{' '}
94
- for your convenience.
95
- </ListItem.Prompt>
96
- }
97
- />
98
- <Modal body={lorem100} open={isModalOpen} onClose={handleClosing} />
99
- </>
100
- );
101
- },
102
- });
103
-
104
- /**
105
- * The control or inline buttons can trigger a [Popover](?path=/docs/dialogs-popover--docs).
106
- */
107
- export const WithPopover: Story = {
108
- parameters: {
109
- controls: { disable: true },
110
- },
111
- render: (listItemProps) => {
112
- return (
113
- <ListItem
114
- {...listItemProps}
115
- control={
116
- <Popover preferredPlacement={Position.BOTTOM} title={lorem5} content={lorem20}>
117
- <ListItem.IconButton partiallyInteractive>
118
- <InfoCircle />
119
- </ListItem.IconButton>
120
- </Popover>
121
- }
122
- prompt={PROMPTS.nonInteractive}
123
- />
124
- );
125
- },
126
- };
127
-
128
- /**
129
- * The control or inline buttons can trigger a [Tooltip](?path=/docs/dialogs-tooltip--docs).
130
- */
131
- export const WithTooltip: Story = {
132
- parameters: {
133
- controls: { disable: true },
134
- },
135
- render: (listItemProps) => {
136
- return (
137
- <ListItem
138
- {...listItemProps}
139
- control={
140
- <Tooltip position={Position.BOTTOM} label={lorem10}>
141
- <ListItem.IconButton partiallyInteractive>
142
- <InfoCircle />
143
- </ListItem.IconButton>
144
- </Tooltip>
145
- }
146
- prompt={PROMPTS.nonInteractive}
147
- />
148
- );
149
- },
150
- };
151
-
152
- /**
153
- * ListItem is often used as a simple copy and paste button augmented with a [Snackbar](?path=/docs/dialogs-snackbar--docs). <br />
154
- *
155
- * **NB** The snippet below uses a simplified example implementation of a clipboard handler,
156
- * which may not be suitable or sufficient for your needs.
157
- */
158
- export const CopyAndPasteWithSnackbar: Story = storySourceWithoutNoise({
159
- parameters: {
160
- controls: { disable: true },
161
- },
162
- render: function CopyAndPaste() {
163
- const title = 'Artie Choke';
164
- const subtitle = 'Account holder';
165
-
166
- const handleCopy = async (createSnackbar: SnackbarContextType['createSnackbar']) =>
167
- navigator.clipboard
168
- .writeText(`${subtitle}: ${title}`)
169
- .catch((err) => {
170
- console.error('Failed to copy text: ', err);
171
- })
172
- .then(() => {
173
- createSnackbar({
174
- text: `${subtitle} copied to clipboard.`,
175
- });
176
- });
177
-
178
- return (
179
- <ListItem
180
- title={title}
181
- subtitle={subtitle}
182
- inverted
183
- control={
184
- <SnackbarProvider>
185
- <SnackbarConsumer>
186
- {({ createSnackbar }) => {
187
- return (
188
- <ListItem.IconButton
189
- partiallyInteractive
190
- onClick={async () => handleCopy(createSnackbar)}
191
- >
192
- <Documents />
193
- </ListItem.IconButton>
194
- );
195
- }}
196
- </SnackbarConsumer>
197
- </SnackbarProvider>
198
- }
199
- media={
200
- <ListItem.AvatarView
201
- imgSrc="../avatar-square-dude.webp"
202
- profileName="John Smith"
203
- size={48}
204
- />
205
- }
206
- />
207
- );
208
- },
209
- });
@@ -1,53 +0,0 @@
1
- import { StoryObj, type Decorator } from '@storybook/react-webpack5';
2
- import type { Props as ItemProps } from '../ListItem';
3
-
4
- type Story = StoryObj<ItemProps>;
5
-
6
- /**
7
- * Recent storybook versions render the full source including all story parameters which
8
- * creates noise, this simple workaround only shows the render function.
9
- * This is a workaround for the issue.
10
- * @see https://github.com/storybookjs/storybook/issues/22281
11
- */
12
- export const storySourceWithoutNoise = (config: Story): Story => {
13
- const newConfig: Story = {
14
- ...config,
15
- parameters: {
16
- ...config.parameters,
17
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
18
- docs: {
19
- ...config.parameters?.docs,
20
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
21
- source: {
22
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
23
- ...config.parameters?.docs?.source,
24
- type: 'code',
25
- transform: (code: string) =>
26
- code
27
- // eslint-disable-next-line regexp/no-super-linear-backtracking
28
- .replace(/storySourceWithoutNoise\(\{.+render\s?:\s+(.*)\}\)$/gms, '$1'),
29
- },
30
- },
31
- },
32
- };
33
-
34
- return newConfig;
35
- };
36
-
37
- /**
38
- * In order to make preview controls work correctly, we have to refresh the render
39
- * by swapping the `key`. This is a workaround for the Storybook's limitation.
40
- */
41
- export const withoutKey: Decorator = (Story, { args }) => (
42
- <Story key={args?.disabled ? 'disabled' : 'enabled'} />
43
- );
44
-
45
- /**
46
- * Not all stories need access to all controls as it causes unnecessary UI noise.
47
- */
48
- export const disableControls =
49
- (hiddenByDefault: string[] = []) =>
50
- (hiddenForStory: string[] = []) => {
51
- const hiddenControls = hiddenByDefault.concat(hiddenForStory);
52
- return Object.fromEntries(hiddenControls.map((item) => [item, { table: { disable: true } }]));
53
- };