@transferwise/components 0.0.0-experimental-dbd40fc → 0.0.0-experimental-b5a5d96

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 (77) hide show
  1. package/build/Markup/Markup.js +138 -0
  2. package/build/Markup/Markup.js.map +1 -0
  3. package/build/Markup/Markup.mjs +133 -0
  4. package/build/Markup/Markup.mjs.map +1 -0
  5. package/build/Markup/constants.js +21 -0
  6. package/build/Markup/constants.js.map +1 -0
  7. package/build/Markup/constants.mjs +15 -0
  8. package/build/Markup/constants.mjs.map +1 -0
  9. package/build/Markup/utils/parseMarkup.js +263 -0
  10. package/build/Markup/utils/parseMarkup.js.map +1 -0
  11. package/build/Markup/utils/parseMarkup.mjs +258 -0
  12. package/build/Markup/utils/parseMarkup.mjs.map +1 -0
  13. package/build/Markup/utils/sanitise.js +111 -0
  14. package/build/Markup/utils/sanitise.js.map +1 -0
  15. package/build/Markup/utils/sanitise.mjs +108 -0
  16. package/build/Markup/utils/sanitise.mjs.map +1 -0
  17. package/build/Nudge/Nudge.js +11 -2
  18. package/build/Nudge/Nudge.js.map +1 -1
  19. package/build/Nudge/Nudge.mjs +12 -3
  20. package/build/Nudge/Nudge.mjs.map +1 -1
  21. package/build/index.js +2 -0
  22. package/build/index.js.map +1 -1
  23. package/build/index.mjs +1 -0
  24. package/build/index.mjs.map +1 -1
  25. package/build/main.css +35 -11
  26. package/build/styles/Button/Button.css +0 -10
  27. package/build/styles/Markup/Markup.css +28 -0
  28. package/build/styles/Markup/_stories/Vulnerability/Vulnerability.css +69 -0
  29. package/build/styles/main.css +35 -11
  30. package/build/types/Body/Body.d.ts +2 -2
  31. package/build/types/IconButton/IconButton.d.ts +1 -1
  32. package/build/types/Markup/Markup.d.ts +18 -0
  33. package/build/types/Markup/Markup.d.ts.map +1 -0
  34. package/build/types/Markup/Markup.types.d.ts +77 -0
  35. package/build/types/Markup/Markup.types.d.ts.map +1 -0
  36. package/build/types/Markup/_stories/Vulnerability/Vulnerability.d.ts +12 -0
  37. package/build/types/Markup/_stories/Vulnerability/Vulnerability.d.ts.map +1 -0
  38. package/build/types/Markup/constants.d.ts +6 -0
  39. package/build/types/Markup/constants.d.ts.map +1 -0
  40. package/build/types/Markup/index.d.ts +3 -0
  41. package/build/types/Markup/index.d.ts.map +1 -0
  42. package/build/types/Markup/utils/parseMarkup.d.ts +8 -0
  43. package/build/types/Markup/utils/parseMarkup.d.ts.map +1 -0
  44. package/build/types/Markup/utils/sanitise.d.ts +4 -0
  45. package/build/types/Markup/utils/sanitise.d.ts.map +1 -0
  46. package/build/types/Nudge/Nudge.d.ts +26 -3
  47. package/build/types/Nudge/Nudge.d.ts.map +1 -1
  48. package/build/types/Title/Title.d.ts +2 -2
  49. package/build/types/Upload/Steps/UploadImageStep/UploadImageStep.d.ts +1 -1
  50. package/build/types/UploadInput/UploadItem/UploadItemLink.d.ts +1 -1
  51. package/build/types/index.d.ts +2 -0
  52. package/build/types/index.d.ts.map +1 -1
  53. package/package.json +1 -1
  54. package/src/Button/Button.css +0 -10
  55. package/src/Button/Button.less +0 -12
  56. package/src/Markup/Markup.css +28 -0
  57. package/src/Markup/Markup.injection.test.tsx +163 -0
  58. package/src/Markup/Markup.less +29 -0
  59. package/src/Markup/Markup.test.tsx +502 -0
  60. package/src/Markup/Markup.tsx +175 -0
  61. package/src/Markup/Markup.types.ts +62 -0
  62. package/src/Markup/_stories/Markup.docs.mdx +75 -0
  63. package/src/Markup/_stories/Markup.security.docs.mdx +343 -0
  64. package/src/Markup/_stories/Markup.story.tsx +266 -0
  65. package/src/Markup/_stories/Vulnerability/Vulnerability.css +69 -0
  66. package/src/Markup/_stories/Vulnerability/Vulnerability.tsx +30 -0
  67. package/src/Markup/constants.ts +23 -0
  68. package/src/Markup/index.ts +2 -0
  69. package/src/Markup/utils/parseMarkup.test.ts +706 -0
  70. package/src/Markup/utils/parseMarkup.ts +265 -0
  71. package/src/Markup/utils/sanitise.test.ts +499 -0
  72. package/src/Markup/utils/sanitise.ts +129 -0
  73. package/src/Nudge/Nudge.test.tsx +43 -0
  74. package/src/Nudge/Nudge.tsx +41 -6
  75. package/src/index.ts +2 -0
  76. package/src/main.css +35 -11
  77. package/src/main.less +1 -0
@@ -25,7 +25,7 @@ const getLocalStorage = (): string[] => {
25
25
  return storage.map((item) => String(item));
26
26
  }
27
27
  }
28
- } catch (error) {}
28
+ } catch {}
29
29
 
30
30
  return [];
31
31
  };
@@ -47,18 +47,41 @@ type MediaNameType =
47
47
  | `${Assets.DOCUMENTS}`;
48
48
 
49
49
  type BaseProps = {
50
- /** @deprecated Use `mediaName` property instead. */
50
+ /**
51
+ * @deprecated Use `mediaName` instead.
52
+ * Legacy custom media content is no longer used by `Nudge`.
53
+ */
51
54
  media?: ReactNode;
52
- /** Media name */
55
+ /**
56
+ * Illustration asset name shown at the start of the nudge.
57
+ */
53
58
  mediaName?: MediaNameType;
59
+ /** Main nudge message content. */
54
60
  title: ReactNode;
61
+ /**
62
+ * Legacy CTA label content.
63
+ * Rendered only when `action` is not provided.
64
+ */
55
65
  link?: ReactNode;
66
+ /**
67
+ * Legacy CTA destination for `link`.
68
+ * Ignored when `action` is provided.
69
+ */
56
70
  href?: string;
71
+ /**
72
+ * Legacy click handler for `link`.
73
+ * Ignored when `action` is provided.
74
+ */
57
75
  onClick?: (event?: MouseEvent<HTMLSpanElement>) => void;
58
76
  /** Fired when the user clicks on close button */
59
77
  onDismiss?: () => void;
60
- /** An optional call to action to sit under the main body of the nudge. If your label is short, use aria-label to provide more context */
78
+ /**
79
+ * Preferred CTA configuration rendered under the nudge body.
80
+ * Single CTA rule: when `action` is provided, legacy `link`/`href` is not rendered.
81
+ * If your label is short, use `aria-label` to provide more context.
82
+ */
61
83
  action?: AlertAction;
84
+ /** Optional class name applied to the root nudge container. */
62
85
  className?: string;
63
86
  };
64
87
 
@@ -97,6 +120,19 @@ const Nudge = ({
97
120
  action,
98
121
  }: NudgeProps) => {
99
122
  const intl = useIntl();
123
+ const hasLegacyLink = Boolean(link);
124
+ const hasAction = action != null;
125
+ const shouldRenderLegacyLink = hasLegacyLink && !hasAction;
126
+
127
+ useEffect(() => {
128
+ if (process.env.NODE_ENV !== 'production' && hasAction && (hasLegacyLink || href != null)) {
129
+ // eslint-disable-next-line no-console -- Intentional developer warning for conflicting API usage.
130
+ console.warn(
131
+ 'Nudge received both action and link/href props. Rendering action only. Remove link/href to silence this warning.',
132
+ );
133
+ }
134
+ }, [hasAction, hasLegacyLink, href]);
135
+
100
136
  const getIsDismissed = useCallback(
101
137
  () => (persistDismissal && id ? !!getLocalStorage()?.find((item) => item === id) : false),
102
138
  [persistDismissal, id],
@@ -166,8 +202,7 @@ const Nudge = ({
166
202
  <Body type={Typography.BODY_LARGE} className={clsx('wds-nudge-body')}>
167
203
  {title}
168
204
  </Body>
169
- {/* Merge these two Link instances into one */}
170
- {link && (
205
+ {shouldRenderLegacyLink && (
171
206
  <Link
172
207
  href={href}
173
208
  type={Typography.LINK_LARGE}
package/src/index.ts CHANGED
@@ -94,6 +94,7 @@ export type { LegacyListItemProps } from './_deprecated/LegacyListItem';
94
94
  export type { LinkProps } from './Link';
95
95
  export type { LoaderProps } from './Loader';
96
96
  export type { MarkdownProps } from './Markdown';
97
+ export type { MarkupActionHandler, MarkupActions, MarkupNode, MarkupProps } from './Markup';
97
98
  export type { ModalProps } from './Modal';
98
99
  export type { MoneyProps } from './Money';
99
100
  export type {
@@ -253,6 +254,7 @@ export { default as LegacyListItem } from './_deprecated/LegacyListItem';
253
254
  export { default as Loader } from './Loader';
254
255
  export { default as Logo } from './Logo';
255
256
  export { default as Markdown } from './Markdown';
257
+ export { default as Markup } from './Markup';
256
258
  export { default as Modal } from './Modal';
257
259
  export { default as Money } from './Money';
258
260
  export { default as MoneyInput } from './MoneyInput';
package/src/main.css CHANGED
@@ -27121,7 +27121,6 @@ a[data-toggle="tooltip"] {
27121
27121
 
27122
27122
  .wds-Button--medium {
27123
27123
  padding: var(--Button-medium-padding);
27124
- --Button-iconSpacerSize: 18px;
27125
27124
  }
27126
27125
 
27127
27126
  .wds-Button--medium:has(.wds-Button-avatars) {
@@ -27140,7 +27139,6 @@ a[data-toggle="tooltip"] {
27140
27139
 
27141
27140
  .wds-Button--small {
27142
27141
  padding: var(--Button-small-padding);
27143
- --Button-iconSpacerSize: 16px;
27144
27142
  }
27145
27143
 
27146
27144
  .wds-Button--small:has(.wds-Button-icon--start) {
@@ -27159,7 +27157,6 @@ a[data-toggle="tooltip"] {
27159
27157
 
27160
27158
  .wds-Button-avatars {
27161
27159
  display: inline-flex;
27162
- flex-shrink: 0;
27163
27160
  }
27164
27161
 
27165
27162
  .wds-Button-avatars .np-avatar-view .np-avatar-view-content {
@@ -27168,7 +27165,6 @@ a[data-toggle="tooltip"] {
27168
27165
 
27169
27166
  .wds-Button-icon {
27170
27167
  display: inline-block;
27171
- flex-shrink: 0;
27172
27168
  }
27173
27169
 
27174
27170
  .wds-Button-icon--md {
@@ -27203,13 +27199,6 @@ a[data-toggle="tooltip"] {
27203
27199
  position: relative;
27204
27200
  }
27205
27201
 
27206
- .wds-Button:has(.wds-Button-icon--start):not(:has(.wds-Button-icon--end)) .wds-Button-label::after,
27207
- .wds-Button:has(.wds-Button-icon--end):not(:has(.wds-Button-icon--start)) .wds-Button-label::before {
27208
- content: '';
27209
- width: var(--Button-iconSpacerSize);
27210
- flex-shrink: 0;
27211
- }
27212
-
27213
27202
  .wds-Button-loader {
27214
27203
  position: absolute;
27215
27204
  width: 100%;
@@ -30928,6 +30917,41 @@ button.np-link {
30928
30917
  height: var(--wds-logo-height);
30929
30918
  }
30930
30919
 
30920
+ .wds-markup-emphasis {
30921
+ font-weight: 600;
30922
+ font-weight: var(--font-weight-semi-bold);
30923
+ font-style: normal;
30924
+ }
30925
+
30926
+ .wds-markup-emphasis--important {
30927
+ color: #37517e;
30928
+ color: var(--color-content-primary);
30929
+ }
30930
+
30931
+ .wds-markup-emphasis--positive {
30932
+ color: #008026;
30933
+ color: var(--color-content-positive);
30934
+ }
30935
+
30936
+ .wds-markup-emphasis--negative {
30937
+ color: #cf2929;
30938
+ color: var(--color-content-negative);
30939
+ }
30940
+
30941
+ .wds-markup-strong {
30942
+ font-weight: 600;
30943
+ font-weight: var(--font-weight-semi-bold);
30944
+ }
30945
+
30946
+ .wds-markup-strikethrough {
30947
+ -webkit-text-decoration: line-through;
30948
+ text-decoration: line-through;
30949
+ }
30950
+
30951
+ .wds-markup-paragraph {
30952
+ margin: 0;
30953
+ }
30954
+
30931
30955
  .tw-modal--scrollable {
30932
30956
  max-height: 100%;
30933
30957
  /* mobile viewport bug fix */
package/src/main.less CHANGED
@@ -56,6 +56,7 @@
56
56
  @import "./Link/Link.less";
57
57
  @import "./Loader/Loader.less";
58
58
  @import "./Logo/Logo.less";
59
+ @import "./Markup/Markup.less";
59
60
  @import "./Modal/Modal.less";
60
61
  @import "./MoneyInput/MoneyInput.less";
61
62
  @import "./ExpressiveMoneyInput/ExpressiveMoneyInput.less";