@transferwise/components 46.83.2 → 46.84.0

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 (108) hide show
  1. package/build/common/Option/Option.js +8 -2
  2. package/build/common/Option/Option.js.map +1 -1
  3. package/build/common/Option/Option.mjs +8 -2
  4. package/build/common/Option/Option.mjs.map +1 -1
  5. package/build/common/closeButton/CloseButton.js.map +1 -1
  6. package/build/common/closeButton/CloseButton.mjs.map +1 -1
  7. package/build/flowNavigation/FlowNavigation.js +8 -3
  8. package/build/flowNavigation/FlowNavigation.js.map +1 -1
  9. package/build/flowNavigation/FlowNavigation.mjs +8 -3
  10. package/build/flowNavigation/FlowNavigation.mjs.map +1 -1
  11. package/build/i18n/de.json +5 -0
  12. package/build/i18n/de.json.js +5 -0
  13. package/build/i18n/de.json.js.map +1 -1
  14. package/build/i18n/de.json.mjs +5 -0
  15. package/build/i18n/de.json.mjs.map +1 -1
  16. package/build/i18n/fr.json +6 -1
  17. package/build/i18n/fr.json.js +6 -1
  18. package/build/i18n/fr.json.js.map +1 -1
  19. package/build/i18n/fr.json.mjs +6 -1
  20. package/build/i18n/fr.json.mjs.map +1 -1
  21. package/build/i18n/it.json +5 -0
  22. package/build/i18n/it.json.js +5 -0
  23. package/build/i18n/it.json.js.map +1 -1
  24. package/build/i18n/it.json.mjs +5 -0
  25. package/build/i18n/it.json.mjs.map +1 -1
  26. package/build/i18n/pt.json +5 -0
  27. package/build/i18n/pt.json.js +5 -0
  28. package/build/i18n/pt.json.js.map +1 -1
  29. package/build/i18n/pt.json.mjs +5 -0
  30. package/build/i18n/pt.json.mjs.map +1 -1
  31. package/build/i18n/ru.json +5 -0
  32. package/build/i18n/ru.json.js +5 -0
  33. package/build/i18n/ru.json.js.map +1 -1
  34. package/build/i18n/ru.json.mjs +5 -0
  35. package/build/i18n/ru.json.mjs.map +1 -1
  36. package/build/iconButton/IconButton.js +41 -0
  37. package/build/iconButton/IconButton.js.map +1 -0
  38. package/build/iconButton/IconButton.mjs +39 -0
  39. package/build/iconButton/IconButton.mjs.map +1 -0
  40. package/build/index.js +2 -0
  41. package/build/index.js.map +1 -1
  42. package/build/index.mjs +1 -0
  43. package/build/index.mjs.map +1 -1
  44. package/build/main.css +86 -32
  45. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js +83 -0
  46. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js.map +1 -0
  47. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs +81 -0
  48. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs.map +1 -0
  49. package/build/primitives/PrimitiveButton/src/PrimitiveButton.js +90 -0
  50. package/build/primitives/PrimitiveButton/src/PrimitiveButton.js.map +1 -0
  51. package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs +88 -0
  52. package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs.map +1 -0
  53. package/build/styles/iconButton/IconButton.css +82 -0
  54. package/build/styles/main.css +86 -32
  55. package/build/styles/summary/Summary.css +4 -0
  56. package/build/summary/Summary.js +3 -3
  57. package/build/summary/Summary.js.map +1 -1
  58. package/build/summary/Summary.mjs +3 -3
  59. package/build/summary/Summary.mjs.map +1 -1
  60. package/build/types/common/Option/Option.d.ts.map +1 -1
  61. package/build/types/common/closeButton/CloseButton.d.ts +3 -0
  62. package/build/types/common/closeButton/CloseButton.d.ts.map +1 -1
  63. package/build/types/flowNavigation/FlowNavigation.d.ts.map +1 -1
  64. package/build/types/iconButton/IconButton.d.ts +15 -0
  65. package/build/types/iconButton/IconButton.d.ts.map +1 -0
  66. package/build/types/iconButton/index.d.ts +3 -0
  67. package/build/types/iconButton/index.d.ts.map +1 -0
  68. package/build/types/index.d.ts +2 -0
  69. package/build/types/index.d.ts.map +1 -1
  70. package/build/types/summary/Summary.d.ts.map +1 -1
  71. package/package.json +3 -3
  72. package/src/accordion/AccordionItem/__snapshots__/AccordionItem.spec.js.snap +8 -4
  73. package/src/card/Card.spec.tsx +3 -1
  74. package/src/common/Option/Option.tsx +11 -1
  75. package/src/common/closeButton/CloseButton.tsx +3 -0
  76. package/src/flowNavigation/FlowNavigation.spec.js +7 -8
  77. package/src/flowNavigation/FlowNavigation.tsx +11 -2
  78. package/src/flowNavigation/__snapshots__/FlowNavigation.spec.js.snap +27 -3
  79. package/src/i18n/de.json +5 -0
  80. package/src/i18n/fr.json +6 -1
  81. package/src/i18n/it.json +5 -0
  82. package/src/i18n/pt.json +5 -0
  83. package/src/i18n/ru.json +5 -0
  84. package/src/iconButton/IconButton.css +82 -0
  85. package/src/iconButton/IconButton.less +55 -0
  86. package/src/iconButton/IconButton.story.tsx +107 -0
  87. package/src/iconButton/IconButton.tsx +51 -0
  88. package/src/iconButton/index.ts +2 -0
  89. package/src/index.ts +2 -0
  90. package/src/main.css +86 -32
  91. package/src/main.less +1 -1
  92. package/src/summary/Summary.css +4 -0
  93. package/src/summary/Summary.less +3 -0
  94. package/src/summary/Summary.story.tsx +13 -3
  95. package/src/summary/Summary.tsx +13 -11
  96. package/build/flowNavigation/backButton/BackButton.js +0 -30
  97. package/build/flowNavigation/backButton/BackButton.js.map +0 -1
  98. package/build/flowNavigation/backButton/BackButton.mjs +0 -28
  99. package/build/flowNavigation/backButton/BackButton.mjs.map +0 -1
  100. package/build/styles/flowNavigation/backButton/BackButton.css +0 -32
  101. package/build/types/flowNavigation/backButton/BackButton.d.ts +0 -7
  102. package/build/types/flowNavigation/backButton/BackButton.d.ts.map +0 -1
  103. package/build/types/flowNavigation/backButton/index.d.ts +0 -3
  104. package/build/types/flowNavigation/backButton/index.d.ts.map +0 -1
  105. package/src/flowNavigation/backButton/BackButton.css +0 -32
  106. package/src/flowNavigation/backButton/BackButton.less +0 -36
  107. package/src/flowNavigation/backButton/BackButton.tsx +0 -29
  108. package/src/flowNavigation/backButton/index.ts +0 -2
@@ -0,0 +1,39 @@
1
+ import { forwardRef } from 'react';
2
+ import PrimitiveButton from '../primitives/PrimitiveButton/src/PrimitiveButton.mjs';
3
+ import PrimitiveAnchor from '../primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs';
4
+ import Circle from '../common/circle/Circle.mjs';
5
+ import { clsx } from 'clsx';
6
+ import { jsx } from 'react/jsx-runtime';
7
+
8
+ const IconButton = /*#__PURE__*/forwardRef(function IconButton({
9
+ size = 48,
10
+ href = '#',
11
+ children,
12
+ className,
13
+ priority = 'primary',
14
+ type = 'default',
15
+ ...props
16
+ }, ref) {
17
+ const isLink = href !== '#';
18
+ return (
19
+ /*#__PURE__*/
20
+ // @ts-expect-error it's either link or `button` element so it has `onClick` / `href`
21
+ jsx(Circle, {
22
+ ref: ref,
23
+ as: isLink ? PrimitiveAnchor : PrimitiveButton,
24
+ size: size,
25
+ fixedSize: true,
26
+ className: clsx('np-icon-button', `np-icon-button-${priority}-${type}`, {
27
+ disabled: props.disabled
28
+ }, className),
29
+ ...(isLink ? {
30
+ href
31
+ } : {}),
32
+ ...props,
33
+ children: children
34
+ })
35
+ );
36
+ });
37
+
38
+ export { IconButton as default };
39
+ //# sourceMappingURL=IconButton.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IconButton.mjs","sources":["../../src/iconButton/IconButton.tsx"],"sourcesContent":["import { AnchorHTMLAttributes, ButtonHTMLAttributes, forwardRef, HTMLAttributes } from 'react';\nimport { PrimitiveAnchor, PrimitiveButton } from '../primitives';\nimport Circle from '../common/circle';\nimport { clsx } from 'clsx';\n\nexport type Props = {\n size?: 16 | 24 | 32 | 40 | 48 | 56 | 72;\n priority?: 'primary' | 'secondary' | 'tertiary' | 'minimal';\n type?: 'default' | 'negative';\n 'data-testid'?: string;\n} & Pick<AnchorHTMLAttributes<HTMLAnchorElement>, 'href' | 'target' | 'onClick'> &\n Pick<ButtonHTMLAttributes<HTMLButtonElement>, 'onClick' | 'disabled'> &\n Pick<HTMLAttributes<HTMLDivElement>, 'className' | 'role' | 'children' | 'aria-label'>;\n\nconst IconButton = forwardRef(function IconButton(\n {\n size = 48,\n href = '#',\n children,\n className,\n priority = 'primary',\n type = 'default',\n ...props\n }: Props,\n ref,\n) {\n const isLink = href !== '#';\n return (\n // @ts-expect-error it's either link or `button` element so it has `onClick` / `href`\n <Circle\n ref={ref}\n as={isLink ? PrimitiveAnchor : PrimitiveButton}\n size={size}\n fixedSize\n className={clsx(\n 'np-icon-button',\n `np-icon-button-${priority}-${type}`,\n {\n disabled: props.disabled,\n },\n className,\n )}\n {...(isLink ? { href } : {})}\n {...props}\n >\n {children}\n </Circle>\n );\n});\n\nexport default IconButton;\n"],"names":["IconButton","forwardRef","size","href","children","className","priority","type","props","ref","isLink","_jsx","Circle","as","PrimitiveAnchor","PrimitiveButton","fixedSize","clsx","disabled"],"mappings":";;;;;;;AAcA,MAAMA,UAAU,gBAAGC,UAAU,CAAC,SAASD,UAAUA,CAC/C;AACEE,EAAAA,IAAI,GAAG,EAAE;AACTC,EAAAA,IAAI,GAAG,GAAG;EACVC,QAAQ;EACRC,SAAS;AACTC,EAAAA,QAAQ,GAAG,SAAS;AACpBC,EAAAA,IAAI,GAAG,SAAS;EAChB,GAAGC,KAAAA;AAAK,CACF,EACRC,GAAG,EAAA;AAEH,EAAA,MAAMC,MAAM,GAAGP,IAAI,KAAK,GAAG,CAAA;AAC3B,EAAA;AAAA;AACE;AACAQ,IAAAA,GAAA,CAACC,MAAM,EAAA;AACLH,MAAAA,GAAG,EAAEA,GAAI;AACTI,MAAAA,EAAE,EAAEH,MAAM,GAAGI,eAAe,GAAGC,eAAgB;AAC/Cb,MAAAA,IAAI,EAAEA,IAAK;MACXc,SAAS,EAAA,IAAA;MACTX,SAAS,EAAEY,IAAI,CACb,gBAAgB,EAChB,kBAAkBX,QAAQ,CAAA,CAAA,EAAIC,IAAI,CAAA,CAAE,EACpC;QACEW,QAAQ,EAAEV,KAAK,CAACU,QAAAA;OACjB,EACDb,SAAS,CACT;AAAA,MAAA,IACGK,MAAM,GAAG;AAAEP,QAAAA,IAAAA;OAAM,GAAG,EAAE,CAAA;AAAA,MAAA,GACvBK,KAAK;AAAAJ,MAAAA,QAAA,EAERA,QAAAA;KACK,CAAA;AAAC,IAAA;AAEb,CAAC;;;;"}
package/build/index.js CHANGED
@@ -22,6 +22,7 @@ var Image = require('./image/Image.js');
22
22
  require('@transferwise/icons');
23
23
  var Body = require('./body/Body.js');
24
24
  var Button = require('./button/Button.js');
25
+ var IconButton = require('./iconButton/IconButton.js');
25
26
  var Carousel = require('./carousel/Carousel.js');
26
27
  var Card = require('./card/Card.js');
27
28
  var Checkbox = require('./checkbox/Checkbox.js');
@@ -164,6 +165,7 @@ Object.defineProperty(exports, "Breakpoint", {
164
165
  exports.Image = Image.default;
165
166
  exports.Body = Body;
166
167
  exports.Button = Button;
168
+ exports.IconButton = IconButton;
167
169
  exports.Carousel = Carousel;
168
170
  exports.Card = Card;
169
171
  exports.Checkbox = Checkbox;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/build/index.mjs CHANGED
@@ -20,6 +20,7 @@ export { default as Image } from './image/Image.mjs';
20
20
  import '@transferwise/icons';
21
21
  export { default as Body } from './body/Body.mjs';
22
22
  export { default as Button } from './button/Button.mjs';
23
+ export { default as IconButton } from './iconButton/IconButton.mjs';
23
24
  export { default as Carousel } from './carousel/Carousel.mjs';
24
25
  export { default as Card } from './card/Card.mjs';
25
26
  export { default as Checkbox } from './checkbox/Checkbox.mjs';
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/build/main.css CHANGED
@@ -535,6 +535,88 @@ div.critical-comms .critical-comms-body {
535
535
  .np-avatar-layout-horizontal-child {
536
536
  margin-left: calc(var(--np-avatar-offset) * -1);
537
537
  }
538
+ .np-icon-button {
539
+ border: none;
540
+ }
541
+ .np-icon-button-tertiary-default {
542
+ color: var(--color-interactive-primary);
543
+ background-color: rgba(134,167,189,0.10196);
544
+ background-color: var(--color-background-neutral);
545
+ }
546
+ .np-icon-button-tertiary-default:not(.disabled):not(:disabled):hover {
547
+ background-color: var(--color-background-neutral-hover);
548
+ }
549
+ .np-icon-button-tertiary-default:not(.disabled):not(:disabled):active {
550
+ background-color: var(--color-background-neutral-active);
551
+ }
552
+ .np-icon-button-primary-default {
553
+ color: var(--color-interactive-control);
554
+ background-color: #00a2dd;
555
+ background-color: var(--color-interactive-accent);
556
+ }
557
+ .np-icon-button-primary-default:not(.disabled):not(:disabled):hover {
558
+ background-color: #008fc9;
559
+ background-color: var(--color-interactive-accent-hover);
560
+ }
561
+ .np-icon-button-primary-default:not(.disabled):not(:disabled):active {
562
+ background-color: #0081ba;
563
+ background-color: var(--color-interactive-accent-active);
564
+ }
565
+ .np-icon-button-primary-negative {
566
+ color: var(--color-contrast-overlay);
567
+ background-color: var(--color-sentiment-negative-primary);
568
+ }
569
+ .np-icon-button-primary-negative:not(.disabled):not(:disabled):hover {
570
+ background-color: var(--color-sentiment-negative-primary-hover);
571
+ }
572
+ .np-icon-button-primary-negative:not(.disabled):not(:disabled):active {
573
+ background-color: var(--color-sentiment-negative-primary-active);
574
+ }
575
+ .np-theme-personal--bright-green .np-icon-button-primary-negative {
576
+ color: var(--color-white);
577
+ }
578
+ .np-icon-button-minimal-default {
579
+ color: var(--color-interactive-primary);
580
+ background-color: #ffffff;
581
+ background-color: var(--color-background-screen);
582
+ background-color: transparent;
583
+ }
584
+ .np-icon-button-minimal-default:not(.disabled):not(:disabled):hover {
585
+ background-color: var(--color-background-screen-hover);
586
+ }
587
+ .np-icon-button-minimal-default:not(.disabled):not(:disabled):active {
588
+ background-color: var(--color-background-screen-active);
589
+ }
590
+ .np-icon-button-secondary-default {
591
+ color: var(--color-interactive-primary);
592
+ background-color: var(--color-interactive-neutral);
593
+ }
594
+ .np-icon-button-secondary-default:not(.disabled):not(:disabled):hover {
595
+ background-color: var(--color-interactive-neutral-hover);
596
+ }
597
+ .np-icon-button-secondary-default:not(.disabled):not(:disabled):active {
598
+ background-color: var(--color-interactive-neutral-active);
599
+ }
600
+ .np-theme-personal--bright-green .np-icon-button-secondary-default,
601
+ .np-theme-personal--forest-green .np-icon-button-secondary-default {
602
+ color: var(--color-interactive-control);
603
+ }
604
+ .np-icon-button-secondary-negative {
605
+ color: var(--color-sentiment-negative-primary);
606
+ background-color: var(--color-sentiment-negative-secondary);
607
+ }
608
+ .np-icon-button-secondary-negative:not(.disabled):not(:disabled):hover {
609
+ background-color: var(--color-sentiment-negative-secondary-hover);
610
+ }
611
+ .np-icon-button-secondary-negative:not(.disabled):not(:disabled):active {
612
+ background-color: var(--color-sentiment-negative-secondary-active);
613
+ }
614
+ .np-theme-personal--bright-green .np-icon-button-secondary-negative {
615
+ color: var(--color-white);
616
+ }
617
+ .np-theme-personal--forest-green .np-icon-button-secondary-negative {
618
+ color: var(--color-contrast-overlay);
619
+ }
538
620
  .tw-badge {
539
621
  position: relative;
540
622
  display: inline-block;
@@ -2201,38 +2283,6 @@ button.np-option {
2201
2283
  outline: var(--ring-outline-color) solid var(--ring-outline-width);
2202
2284
  outline-offset: var(--ring-outline-offset);
2203
2285
  }
2204
- .np-back-button {
2205
- color: #00a2dd;
2206
- color: var(--color-interactive-accent);
2207
- display: flex !important;
2208
- }
2209
- .np-back-button:hover {
2210
- color: #008fc9;
2211
- color: var(--color-interactive-accent-hover);
2212
- }
2213
- .np-back-button:active {
2214
- color: #0081ba;
2215
- color: var(--color-interactive-accent-active);
2216
- }
2217
- .np-theme-personal .np-back-button {
2218
- color: #37517e;
2219
- color: var(--color-content-primary);
2220
- }
2221
- .np-theme-personal .np-back-button:hover {
2222
- color: var(--color-content-primary-hover);
2223
- }
2224
- .np-theme-personal .np-back-button:active {
2225
- color: var(--color-content-primary-active);
2226
- }
2227
- .np-theme-personal .np-back-button .tw-icon {
2228
- color: var(--color-interactive-primary);
2229
- }
2230
- .np-theme-personal .np-back-button .tw-icon:hover {
2231
- color: var(--color-interactive-primary-hover);
2232
- }
2233
- .np-theme-personal .np-back-button .tw-icon:active {
2234
- color: var(--color-interactive-primary-active);
2235
- }
2236
2286
  .np-flow-navigation {
2237
2287
  width: 100%;
2238
2288
  min-height: 97px;
@@ -4950,6 +5000,10 @@ html:not([dir="rtl"]) .np-navigation-option {
4950
5000
  padding-left: calc(var(--size-24) + var(--size-8));
4951
5001
  padding-right: 0;
4952
5002
  }
5003
+ .np-summary__description-icon {
5004
+ margin-top: 4px;
5005
+ margin-top: var(--size-4);
5006
+ }
4953
5007
  .np-summary__action {
4954
5008
  margin-top: 4px;
4955
5009
  margin-top: var(--size-4);
@@ -0,0 +1,83 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var clsx = require('clsx');
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+
7
+ const PrimitiveAnchor = /*#__PURE__*/React.forwardRef(({
8
+ children,
9
+ className,
10
+ href,
11
+ id,
12
+ disabled = false,
13
+ testId,
14
+ onClick,
15
+ onFocus,
16
+ onBlur,
17
+ onMouseEnter,
18
+ onMouseLeave,
19
+ onKeyDown,
20
+ ...props
21
+ }, ref) => {
22
+ const anchorClasses = clsx.clsx('wds-Anchor', {
23
+ 'wds-Anchor--disabled': disabled
24
+ }, className);
25
+ const handleClick = React.useCallback(event => {
26
+ if (disabled) {
27
+ event.preventDefault();
28
+ } else {
29
+ onClick?.(event);
30
+ }
31
+ }, [disabled, onClick]);
32
+ const handleFocus = React.useCallback(event => {
33
+ onFocus?.(event);
34
+ }, [onFocus]);
35
+ const handleBlur = React.useCallback(event => {
36
+ onBlur?.(event);
37
+ }, [onBlur]);
38
+ const handleMouseEnter = React.useCallback(event => {
39
+ onMouseEnter?.(event);
40
+ }, [onMouseEnter]);
41
+ const handleMouseLeave = React.useCallback(event => {
42
+ onMouseLeave?.(event);
43
+ }, [onMouseLeave]);
44
+ const handleKeyDown = React.useCallback(event => {
45
+ onKeyDown?.(event);
46
+ }, [onKeyDown]);
47
+ /**
48
+ * The following props are set to handle the `disabled` state for the link:
49
+ *
50
+ * - `aria-disabled`: Exposes the link as disabled to assistive technologies.
51
+ * - `href`: Removed when `disabled` is true to prevent navigation.
52
+ * - `role`: Set to 'link' when `disabled` is true to ensure the element
53
+ * is still exposed as a link.
54
+ *
55
+ * For more details, refer to Scott O'Hara's article on disabling links:
56
+ * https://www.scottohara.me/blog/2021/05/28/disabled-links.html
57
+ */
58
+ const anchorProps = {
59
+ 'aria-disabled': disabled,
60
+ className: anchorClasses,
61
+ 'data-testid': testId,
62
+ href: disabled ? undefined : href,
63
+ id,
64
+ ref,
65
+ role: disabled ? 'link' : undefined,
66
+ rel: props.target === '_blank' ? 'noopener noreferrer' : undefined,
67
+ onClick: handleClick,
68
+ onFocus: handleFocus,
69
+ onBlur: handleBlur,
70
+ onMouseEnter: handleMouseEnter,
71
+ onMouseLeave: handleMouseLeave,
72
+ onKeyDown: handleKeyDown,
73
+ ...props
74
+ };
75
+ return /*#__PURE__*/jsxRuntime.jsx("a", {
76
+ ...anchorProps,
77
+ children: children
78
+ });
79
+ });
80
+ PrimitiveAnchor.displayName = 'PrimitiveAnchor';
81
+
82
+ module.exports = PrimitiveAnchor;
83
+ //# sourceMappingURL=PrimitiveAnchor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrimitiveAnchor.js","sources":["../../../../src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.tsx"],"sourcesContent":["import React, { forwardRef, useCallback } from 'react';\nimport { clsx } from 'clsx';\nimport type { PrimitiveAnchorProps } from '..';\n\n/**\n * The Primitive `PrimitiveAnchor` component is customisable link element that can be\n * used in various parts of the Wise Design System internally. It supports\n * different states such as disabled and provides event handlers for common\n * interactions like click, focus, blur, mouse enter, mouse leave, and key down.\n *\n * @see {@link PrimitiveAnchor} for further information.\n * @see {@link https://storybook.wise.design/?path=/docs/primitive-anchor--docs|Storybook Wise Design}\n */\nconst PrimitiveAnchor = forwardRef<HTMLAnchorElement, PrimitiveAnchorProps>(\n (\n {\n children,\n className,\n href,\n id,\n disabled = false,\n testId,\n onClick,\n onFocus,\n onBlur,\n onMouseEnter,\n onMouseLeave,\n onKeyDown,\n ...props\n },\n ref,\n ) => {\n const anchorClasses = clsx(\n 'wds-Anchor',\n {\n 'wds-Anchor--disabled': disabled,\n },\n className,\n );\n\n const handleClick = useCallback(\n (event: React.MouseEvent<HTMLAnchorElement>) => {\n if (disabled) {\n event.preventDefault();\n } else {\n onClick?.(event);\n }\n },\n [disabled, onClick],\n );\n\n const handleFocus = useCallback(\n (event: React.FocusEvent<HTMLAnchorElement>) => {\n onFocus?.(event);\n },\n [onFocus],\n );\n\n const handleBlur = useCallback(\n (event: React.FocusEvent<HTMLAnchorElement>) => {\n onBlur?.(event);\n },\n [onBlur],\n );\n\n const handleMouseEnter = useCallback(\n (event: React.MouseEvent<HTMLAnchorElement>) => {\n onMouseEnter?.(event);\n },\n [onMouseEnter],\n );\n\n const handleMouseLeave = useCallback(\n (event: React.MouseEvent<HTMLAnchorElement>) => {\n onMouseLeave?.(event);\n },\n [onMouseLeave],\n );\n\n const handleKeyDown = useCallback(\n (event: React.KeyboardEvent<HTMLAnchorElement>) => {\n onKeyDown?.(event);\n },\n [onKeyDown],\n );\n\n /**\n * The following props are set to handle the `disabled` state for the link:\n *\n * - `aria-disabled`: Exposes the link as disabled to assistive technologies.\n * - `href`: Removed when `disabled` is true to prevent navigation.\n * - `role`: Set to 'link' when `disabled` is true to ensure the element\n * is still exposed as a link.\n *\n * For more details, refer to Scott O'Hara's article on disabling links:\n * https://www.scottohara.me/blog/2021/05/28/disabled-links.html\n */\n const anchorProps = {\n 'aria-disabled': disabled,\n className: anchorClasses,\n 'data-testid': testId,\n href: disabled ? undefined : href,\n id,\n ref,\n role: disabled ? 'link' : undefined,\n rel: props.target === '_blank' ? 'noopener noreferrer' : undefined,\n onClick: handleClick,\n onFocus: handleFocus,\n onBlur: handleBlur,\n onMouseEnter: handleMouseEnter,\n onMouseLeave: handleMouseLeave,\n onKeyDown: handleKeyDown,\n ...props,\n };\n\n return <a {...anchorProps}>{children}</a>;\n },\n);\n\nPrimitiveAnchor.displayName = 'PrimitiveAnchor';\n\nexport default PrimitiveAnchor;\n"],"names":["PrimitiveAnchor","forwardRef","children","className","href","id","disabled","testId","onClick","onFocus","onBlur","onMouseEnter","onMouseLeave","onKeyDown","props","ref","anchorClasses","clsx","handleClick","useCallback","event","preventDefault","handleFocus","handleBlur","handleMouseEnter","handleMouseLeave","handleKeyDown","anchorProps","undefined","role","rel","target","_jsx","displayName"],"mappings":";;;;;;AAaA,MAAMA,eAAe,gBAAGC,gBAAU,CAChC,CACE;EACEC,QAAQ;EACRC,SAAS;EACTC,IAAI;EACJC,EAAE;AACFC,EAAAA,QAAQ,GAAG,KAAK;EAChBC,MAAM;EACNC,OAAO;EACPC,OAAO;EACPC,MAAM;EACNC,YAAY;EACZC,YAAY;EACZC,SAAS;EACT,GAAGC,KAAAA;CACJ,EACDC,GAAG,KACD;AACF,EAAA,MAAMC,aAAa,GAAGC,SAAI,CACxB,YAAY,EACZ;AACE,IAAA,sBAAsB,EAAEX,QAAAA;GACzB,EACDH,SAAS,CACV,CAAA;AAED,EAAA,MAAMe,WAAW,GAAGC,iBAAW,CAC5BC,KAA0C,IAAI;AAC7C,IAAA,IAAId,QAAQ,EAAE;MACZc,KAAK,CAACC,cAAc,EAAE,CAAA;AACxB,KAAC,MAAM;MACLb,OAAO,GAAGY,KAAK,CAAC,CAAA;AAClB,KAAA;AACF,GAAC,EACD,CAACd,QAAQ,EAAEE,OAAO,CAAC,CACpB,CAAA;AAED,EAAA,MAAMc,WAAW,GAAGH,iBAAW,CAC5BC,KAA0C,IAAI;IAC7CX,OAAO,GAAGW,KAAK,CAAC,CAAA;AAClB,GAAC,EACD,CAACX,OAAO,CAAC,CACV,CAAA;AAED,EAAA,MAAMc,UAAU,GAAGJ,iBAAW,CAC3BC,KAA0C,IAAI;IAC7CV,MAAM,GAAGU,KAA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AA;AAAQ,GAAI,CAAC,CAAA;AAC3C,CAAC,EACF;AAEDF,eAAe,CAACiC,WAAW,GAAG,iBAAiB;;;;"}
@@ -0,0 +1,81 @@
1
+ import { forwardRef, useCallback } from 'react';
2
+ import { clsx } from 'clsx';
3
+ import { jsx } from 'react/jsx-runtime';
4
+
5
+ const PrimitiveAnchor = /*#__PURE__*/forwardRef(({
6
+ children,
7
+ className,
8
+ href,
9
+ id,
10
+ disabled = false,
11
+ testId,
12
+ onClick,
13
+ onFocus,
14
+ onBlur,
15
+ onMouseEnter,
16
+ onMouseLeave,
17
+ onKeyDown,
18
+ ...props
19
+ }, ref) => {
20
+ const anchorClasses = clsx('wds-Anchor', {
21
+ 'wds-Anchor--disabled': disabled
22
+ }, className);
23
+ const handleClick = useCallback(event => {
24
+ if (disabled) {
25
+ event.preventDefault();
26
+ } else {
27
+ onClick?.(event);
28
+ }
29
+ }, [disabled, onClick]);
30
+ const handleFocus = useCallback(event => {
31
+ onFocus?.(event);
32
+ }, [onFocus]);
33
+ const handleBlur = useCallback(event => {
34
+ onBlur?.(event);
35
+ }, [onBlur]);
36
+ const handleMouseEnter = useCallback(event => {
37
+ onMouseEnter?.(event);
38
+ }, [onMouseEnter]);
39
+ const handleMouseLeave = useCallback(event => {
40
+ onMouseLeave?.(event);
41
+ }, [onMouseLeave]);
42
+ const handleKeyDown = useCallback(event => {
43
+ onKeyDown?.(event);
44
+ }, [onKeyDown]);
45
+ /**
46
+ * The following props are set to handle the `disabled` state for the link:
47
+ *
48
+ * - `aria-disabled`: Exposes the link as disabled to assistive technologies.
49
+ * - `href`: Removed when `disabled` is true to prevent navigation.
50
+ * - `role`: Set to 'link' when `disabled` is true to ensure the element
51
+ * is still exposed as a link.
52
+ *
53
+ * For more details, refer to Scott O'Hara's article on disabling links:
54
+ * https://www.scottohara.me/blog/2021/05/28/disabled-links.html
55
+ */
56
+ const anchorProps = {
57
+ 'aria-disabled': disabled,
58
+ className: anchorClasses,
59
+ 'data-testid': testId,
60
+ href: disabled ? undefined : href,
61
+ id,
62
+ ref,
63
+ role: disabled ? 'link' : undefined,
64
+ rel: props.target === '_blank' ? 'noopener noreferrer' : undefined,
65
+ onClick: handleClick,
66
+ onFocus: handleFocus,
67
+ onBlur: handleBlur,
68
+ onMouseEnter: handleMouseEnter,
69
+ onMouseLeave: handleMouseLeave,
70
+ onKeyDown: handleKeyDown,
71
+ ...props
72
+ };
73
+ return /*#__PURE__*/jsx("a", {
74
+ ...anchorProps,
75
+ children: children
76
+ });
77
+ });
78
+ PrimitiveAnchor.displayName = 'PrimitiveAnchor';
79
+
80
+ export { PrimitiveAnchor as default };
81
+ //# sourceMappingURL=PrimitiveAnchor.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrimitiveAnchor.mjs","sources":["../../../../src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.tsx"],"sourcesContent":["import React, { forwardRef, useCallback } from 'react';\nimport { clsx } from 'clsx';\nimport type { PrimitiveAnchorProps } from '..';\n\n/**\n * The Primitive `PrimitiveAnchor` component is customisable link element that can be\n * used in various parts of the Wise Design System internally. It supports\n * different states such as disabled and provides event handlers for common\n * interactions like click, focus, blur, mouse enter, mouse leave, and key down.\n *\n * @see {@link PrimitiveAnchor} for further information.\n * @see {@link https://storybook.wise.design/?path=/docs/primitive-anchor--docs|Storybook Wise Design}\n */\nconst PrimitiveAnchor = forwardRef<HTMLAnchorElement, PrimitiveAnchorProps>(\n (\n {\n children,\n className,\n href,\n id,\n disabled = false,\n testId,\n onClick,\n onFocus,\n onBlur,\n onMouseEnter,\n onMouseLeave,\n onKeyDown,\n ...props\n },\n ref,\n ) => {\n const anchorClasses = clsx(\n 'wds-Anchor',\n {\n 'wds-Anchor--disabled': disabled,\n },\n className,\n );\n\n const handleClick = useCallback(\n (event: React.MouseEvent<HTMLAnchorElement>) => {\n if (disabled) {\n event.preventDefault();\n } else {\n onClick?.(event);\n }\n },\n [disabled, onClick],\n );\n\n const handleFocus = useCallback(\n (event: React.FocusEvent<HTMLAnchorElement>) => {\n onFocus?.(event);\n },\n [onFocus],\n );\n\n const handleBlur = useCallback(\n (event: React.FocusEvent<HTMLAnchorElement>) => {\n onBlur?.(event);\n },\n [onBlur],\n );\n\n const handleMouseEnter = useCallback(\n (event: React.MouseEvent<HTMLAnchorElement>) => {\n onMouseEnter?.(event);\n },\n [onMouseEnter],\n );\n\n const handleMouseLeave = useCallback(\n (event: React.MouseEvent<HTMLAnchorElement>) => {\n onMouseLeave?.(event);\n },\n [onMouseLeave],\n );\n\n const handleKeyDown = useCallback(\n (event: React.KeyboardEvent<HTMLAnchorElement>) => {\n onKeyDown?.(event);\n },\n [onKeyDown],\n );\n\n /**\n * The following props are set to handle the `disabled` state for the link:\n *\n * - `aria-disabled`: Exposes the link as disabled to assistive technologies.\n * - `href`: Removed when `disabled` is true to prevent navigation.\n * - `role`: Set to 'link' when `disabled` is true to ensure the element\n * is still exposed as a link.\n *\n * For more details, refer to Scott O'Hara's article on disabling links:\n * https://www.scottohara.me/blog/2021/05/28/disabled-links.html\n */\n const anchorProps = {\n 'aria-disabled': disabled,\n className: anchorClasses,\n 'data-testid': testId,\n href: disabled ? undefined : href,\n id,\n ref,\n role: disabled ? 'link' : undefined,\n rel: props.target === '_blank' ? 'noopener noreferrer' : undefined,\n onClick: handleClick,\n onFocus: handleFocus,\n onBlur: handleBlur,\n onMouseEnter: handleMouseEnter,\n onMouseLeave: handleMouseLeave,\n onKeyDown: handleKeyDown,\n ...props,\n };\n\n return <a {...anchorProps}>{children}</a>;\n },\n);\n\nPrimitiveAnchor.displayName = 'PrimitiveAnchor';\n\nexport default PrimitiveAnchor;\n"],"names":["PrimitiveAnchor","forwardRef","children","className","href","id","disabled","testId","onClick","onFocus","onBlur","onMouseEnter","onMouseLeave","onKeyDown","props","ref","anchorClasses","clsx","handleClick","useCallback","event","preventDefault","handleFocus","handleBlur","handleMouseEnter","handleMouseLeave","handleKeyDown","anchorProps","undefined","role","rel","target","_jsx","displayName"],"mappings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,aAAa,GAAGP,WAAW,CAC9BC,KAA6C,IAAI;IAChDP,SAAS,GAAGO,KAAK,CAAC,CAAA;AACpB,GAAC,EACD,CAACP,SAAS,CAAC,CACZ,CAAA;AAED;;;;;;;;;;AAUG;AACH,EAAA,MAAMc,WAAW,GAAG;AAClB,IAAA,eAAe,EAAErB,QAAQ;AACzBH,IAAAA,SAAS,EAAEa,aAAa;AACxB,IAAA,aAAa,EAAET,MAAM;AACrBH,IAAAA,IAAI,EAAEE,QAAQ,GAAGsB,SAAS,GAAGxB,IAAI;IACjCC,EAAE;IACFU,GAAG;AACHc,IAAAA,IAAI,EAAEvB,QAAQ,GAAG,MAAM,GAAGsB,SAAS;IACnCE,GAAG,EAAEhB,KAAK,CAACiB,MAAM,KAAK,QAAQ,GAAG,qBAAqB,GAAGH,SAAS;AAClEpB,IAAAA,OAAO,EAAEU,WAAW;AACpBT,IAAAA,OAAO,EAAEa,WAAW;AACpBZ,IAAAA,MAAM,EAAEa,UAAU;AAClBZ,IAAAA,YAAY,EAAEa,gBAAgB;AAC9BZ,IAAAA,YAAY,EAAEa,gBAAgB;AAC9BZ,IAAAA,SAAS,EAAEa,aAAa;IACxB,GAAGZ,KAAAA;GACJ,CAAA;AAED,EAAA,oBAAOkB,GAAA,CAAA,GAAA,EAAA;AAAA,IAAA,GAAOL,WAAW;AAAAzB,IAAAA,QAAA,EAAGA,QAAAA;AAAQ,GAAI,CAAC,CAAA;AAC3C,CAAC,EACF;AAEDF,eAAe,CAACiC,WAAW,GAAG,iBAAiB;;;;"}
@@ -0,0 +1,90 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var clsx = require('clsx');
5
+ var reactIntl = require('react-intl');
6
+ var Button_messages = require('../../../i18n/commonMessages/Button.messages.js');
7
+ var jsxRuntime = require('react/jsx-runtime');
8
+
9
+ /* eslint-disable react/button-has-type */
10
+ const PrimitiveButton = /*#__PURE__*/React.forwardRef(({
11
+ children,
12
+ className,
13
+ id,
14
+ disabled = false,
15
+ loading = false,
16
+ testId,
17
+ type = 'button',
18
+ onClick,
19
+ onFocus,
20
+ onBlur,
21
+ onMouseEnter,
22
+ onMouseLeave,
23
+ onKeyDown,
24
+ ...props
25
+ }, ref) => {
26
+ const intl = reactIntl.useIntl();
27
+ const classNames = clsx.clsx('wds-Button', {
28
+ 'wds-Button--disabled': disabled,
29
+ 'wds-Button--loading': loading
30
+ }, className);
31
+ const handleClick = React.useCallback(event => {
32
+ if (disabled || loading) {
33
+ event.preventDefault();
34
+ } else {
35
+ onClick?.(event);
36
+ }
37
+ }, [disabled, loading, onClick]);
38
+ const handleFocus = React.useCallback(event => {
39
+ onFocus?.(event);
40
+ }, [onFocus]);
41
+ const handleBlur = React.useCallback(event => {
42
+ onBlur?.(event);
43
+ }, [onBlur]);
44
+ const handleMouseEnter = React.useCallback(event => {
45
+ onMouseEnter?.(event);
46
+ }, [onMouseEnter]);
47
+ const handleMouseLeave = React.useCallback(event => {
48
+ onMouseLeave?.(event);
49
+ }, [onMouseLeave]);
50
+ const handleKeyDown = React.useCallback(event => {
51
+ onKeyDown?.(event);
52
+ }, [onKeyDown]);
53
+ /**
54
+ * The following props are used to manage the `disabled` and `loading`
55
+ * states for the button:
56
+ *
57
+ * - `aria-disabled`: Communicates to assistive technologies that the button
58
+ * is disabled when it is either disabled or loading.
59
+ * - `aria-label`: Provides an accessible label for the button, using a
60
+ * localized loading message when the button is in a loading state.
61
+ * - `aria-live`: Ensures that updates to the button's content are announced
62
+ * by assistive technologies, set to 'polite' during loading.
63
+ */
64
+ const buttonProps = {
65
+ 'aria-disabled': disabled || loading,
66
+ 'aria-label': loading ? intl.formatMessage(Button_messages.loadingAriaLabel) : props['aria-label'],
67
+ 'aria-live': loading ? 'polite' : 'off',
68
+ className: classNames,
69
+ 'data-testid': testId,
70
+ disabled,
71
+ id,
72
+ ref,
73
+ type,
74
+ onBlur: handleBlur,
75
+ onClick: handleClick,
76
+ onFocus: handleFocus,
77
+ onMouseEnter: handleMouseEnter,
78
+ onMouseLeave: handleMouseLeave,
79
+ onKeyDown: handleKeyDown,
80
+ ...props
81
+ };
82
+ return /*#__PURE__*/jsxRuntime.jsx("button", {
83
+ ...buttonProps,
84
+ children: children
85
+ });
86
+ });
87
+ PrimitiveButton.displayName = 'PrimitiveButton';
88
+
89
+ module.exports = PrimitiveButton;
90
+ //# sourceMappingURL=PrimitiveButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrimitiveButton.js","sources":["../../../../src/primitives/PrimitiveButton/src/PrimitiveButton.tsx"],"sourcesContent":["/* eslint-disable react/button-has-type */\nimport React, { forwardRef, useCallback } from 'react';\nimport { clsx } from 'clsx';\nimport { useIntl, MessageDescriptor } from 'react-intl';\nimport messages from '../../../i18n/commonMessages/Button.messages';\nimport type { PrimitiveButtonProps } from '..';\n\n/**\n * The Primitive `PrimitiveButton` component can be used in various parts the Wise Design\n * System internally. It supports different states such as disabled and loading,\n * and provides event handlers for common interactions like click, focus, blur,\n * mouse enter, mouse leave, and keydown.\n *\n * @see {@link PrimitiveButton} for further information.\n * @see {@link https://storybook.wise.design/?path=/docs/primitive-button--docs|Storybook Wise Design}\n */\nconst PrimitiveButton = forwardRef<HTMLButtonElement, PrimitiveButtonProps>(\n (\n {\n children,\n className,\n id,\n disabled = false,\n loading = false,\n testId,\n type = 'button',\n onClick,\n onFocus,\n onBlur,\n onMouseEnter,\n onMouseLeave,\n onKeyDown,\n ...props\n },\n ref,\n ) => {\n const intl = useIntl();\n const classNames = clsx(\n 'wds-Button',\n {\n 'wds-Button--disabled': disabled,\n 'wds-Button--loading': loading,\n },\n className,\n );\n\n const handleClick = useCallback(\n (event: React.MouseEvent<HTMLButtonElement>) => {\n if (disabled || loading) {\n event.preventDefault();\n } else {\n onClick?.(event);\n }\n },\n [disabled, loading, onClick],\n );\n\n const handleFocus = useCallback(\n (event: React.FocusEvent<HTMLButtonElement>) => {\n onFocus?.(event);\n },\n [onFocus],\n );\n\n const handleBlur = useCallback(\n (event: React.FocusEvent<HTMLButtonElement>) => {\n onBlur?.(event);\n },\n [onBlur],\n );\n\n const handleMouseEnter = useCallback(\n (event: React.MouseEvent<HTMLButtonElement>) => {\n onMouseEnter?.(event);\n },\n [onMouseEnter],\n );\n\n const handleMouseLeave = useCallback(\n (event: React.MouseEvent<HTMLButtonElement>) => {\n onMouseLeave?.(event);\n },\n [onMouseLeave],\n );\n\n const handleKeyDown = useCallback(\n (event: React.KeyboardEvent<HTMLButtonElement>) => {\n onKeyDown?.(event);\n },\n [onKeyDown],\n );\n\n /**\n * The following props are used to manage the `disabled` and `loading`\n * states for the button:\n *\n * - `aria-disabled`: Communicates to assistive technologies that the button\n * is disabled when it is either disabled or loading.\n * - `aria-label`: Provides an accessible label for the button, using a\n * localized loading message when the button is in a loading state.\n * - `aria-live`: Ensures that updates to the button's content are announced\n * by assistive technologies, set to 'polite' during loading.\n */\n const buttonProps = {\n 'aria-disabled': disabled || loading,\n 'aria-label': loading\n ? intl.formatMessage(messages.loadingAriaLabel as MessageDescriptor)\n : props['aria-label'],\n 'aria-live': (loading ? 'polite' : 'off') as 'polite' | 'off' | 'assertive' | undefined,\n className: classNames,\n 'data-testid': testId,\n disabled,\n id,\n ref,\n type,\n onBlur: handleBlur,\n onClick: handleClick,\n onFocus: handleFocus,\n onMouseEnter: handleMouseEnter,\n onMouseLeave: handleMouseLeave,\n onKeyDown: handleKeyDown,\n ...props,\n };\n\n return <button {...buttonProps}>{children}</button>;\n },\n);\n\nPrimitiveButton.displayName = 'PrimitiveButton';\n\nexport default PrimitiveButton;\n"],"names":["PrimitiveButton","forwardRef","children","className","id","disabled","loading","testId","type","onClick","onFocus","onBlur","onMouseEnter","onMouseLeave","onKeyDown","props","ref","intl","useIntl","classNames","clsx","handleClick","useCallback","event","preventDefault","handleFocus","handleBlur","handleMouseEnter","handleMouseLeave","handleKeyDown","buttonProps","formatMessage","messages","loadingAriaLabel","_jsx","displayName"],"mappings":";;;;;;;;AAAA;AAgBA,MAAMA,eAAe,gBAAGC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AAgB,GAAGN,iBAAW,CACjCC,KAA0C,IAAI;IAC7CV,YAAY,GAAGU,KAAK,CAAC,CAAA;AACvB,GAAC,EACD,CAACV,YAAY,CAAC,CACf,CAAA;AAED,EAAA,MAAMgB,aAAa,GAAGP,iBAAW,CAC9BC,KAA6C,IAAI;IAChDT,SAAS,GAAGS,KAAK,CAAC,CAAA;AACpB,GAAC,EACD,CAACT,SAAS,CAAC,CACZ,CAAA;AAED;;;;;;;;;;AAUG;AACH,EAAA,MAAMgB,WAAW,GAAG;IAClB,eAAe,EAAEzB,QAAQ,IAAIC,OAAO;AACpC,IAAA,YAAY,EAAEA,OAAO,GACjBW,IAAI,CAACc,aAAa,CAACC,eAAQ,CAACC,gBAAqC,CAAC,GAClElB,KAAK,CAAC,YAAY,CAAC;AACvB,IAAA,WAAW,EAAGT,OAAO,GAAG,QAAQ,GAAG,KAAoD;AACvFH,IAAAA,SAAS,EAAEgB,UAAU;AACrB,IAAA,aAAa,EAAEZ,MAAM;IACrBF,QAAQ;IACRD,EAAE;IACFY,GAAG;IACHR,IAAI;AACJG,IAAAA,MAAM,EAAEe,UAAU;AAClBjB,IAAAA,OAAO,EAAEY,WAAW;AACpBX,IAAAA,OAAO,EAAEe,WAAW;AACpBb,IAAAA,YAAY,EAAEe,gBAAgB;AAC9Bd,IAAAA,YAAY,EAAEe,gBAAgB;AAC9Bd,IAAAA,SAAS,EAAEe,aAAa;IACxB,GAAGd,KAAAA;GACJ,CAAA;AAED,EAAA,oBAAOmB,cAAA,CAAA,QAAA,EAAA;AAAA,IAAA,GAAYJ,WAAW;AAAA5B,IAAAA,QAAA,EAAGA,QAAAA;AAAQ,GAAS,CAAC,CAAA;AACrD,CAAC,EACF;AAEDF,eAAe,CAACmC,WAAW,GAAG,iBAAiB;;;;"}
@@ -0,0 +1,88 @@
1
+ import { forwardRef, useCallback } from 'react';
2
+ import { clsx } from 'clsx';
3
+ import { useIntl } from 'react-intl';
4
+ import messages from '../../../i18n/commonMessages/Button.messages.mjs';
5
+ import { jsx } from 'react/jsx-runtime';
6
+
7
+ /* eslint-disable react/button-has-type */
8
+ const PrimitiveButton = /*#__PURE__*/forwardRef(({
9
+ children,
10
+ className,
11
+ id,
12
+ disabled = false,
13
+ loading = false,
14
+ testId,
15
+ type = 'button',
16
+ onClick,
17
+ onFocus,
18
+ onBlur,
19
+ onMouseEnter,
20
+ onMouseLeave,
21
+ onKeyDown,
22
+ ...props
23
+ }, ref) => {
24
+ const intl = useIntl();
25
+ const classNames = clsx('wds-Button', {
26
+ 'wds-Button--disabled': disabled,
27
+ 'wds-Button--loading': loading
28
+ }, className);
29
+ const handleClick = useCallback(event => {
30
+ if (disabled || loading) {
31
+ event.preventDefault();
32
+ } else {
33
+ onClick?.(event);
34
+ }
35
+ }, [disabled, loading, onClick]);
36
+ const handleFocus = useCallback(event => {
37
+ onFocus?.(event);
38
+ }, [onFocus]);
39
+ const handleBlur = useCallback(event => {
40
+ onBlur?.(event);
41
+ }, [onBlur]);
42
+ const handleMouseEnter = useCallback(event => {
43
+ onMouseEnter?.(event);
44
+ }, [onMouseEnter]);
45
+ const handleMouseLeave = useCallback(event => {
46
+ onMouseLeave?.(event);
47
+ }, [onMouseLeave]);
48
+ const handleKeyDown = useCallback(event => {
49
+ onKeyDown?.(event);
50
+ }, [onKeyDown]);
51
+ /**
52
+ * The following props are used to manage the `disabled` and `loading`
53
+ * states for the button:
54
+ *
55
+ * - `aria-disabled`: Communicates to assistive technologies that the button
56
+ * is disabled when it is either disabled or loading.
57
+ * - `aria-label`: Provides an accessible label for the button, using a
58
+ * localized loading message when the button is in a loading state.
59
+ * - `aria-live`: Ensures that updates to the button's content are announced
60
+ * by assistive technologies, set to 'polite' during loading.
61
+ */
62
+ const buttonProps = {
63
+ 'aria-disabled': disabled || loading,
64
+ 'aria-label': loading ? intl.formatMessage(messages.loadingAriaLabel) : props['aria-label'],
65
+ 'aria-live': loading ? 'polite' : 'off',
66
+ className: classNames,
67
+ 'data-testid': testId,
68
+ disabled,
69
+ id,
70
+ ref,
71
+ type,
72
+ onBlur: handleBlur,
73
+ onClick: handleClick,
74
+ onFocus: handleFocus,
75
+ onMouseEnter: handleMouseEnter,
76
+ onMouseLeave: handleMouseLeave,
77
+ onKeyDown: handleKeyDown,
78
+ ...props
79
+ };
80
+ return /*#__PURE__*/jsx("button", {
81
+ ...buttonProps,
82
+ children: children
83
+ });
84
+ });
85
+ PrimitiveButton.displayName = 'PrimitiveButton';
86
+
87
+ export { PrimitiveButton as default };
88
+ //# sourceMappingURL=PrimitiveButton.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrimitiveButton.mjs","sources":["../../../../src/primitives/PrimitiveButton/src/PrimitiveButton.tsx"],"sourcesContent":["/* eslint-disable react/button-has-type */\nimport React, { forwardRef, useCallback } from 'react';\nimport { clsx } from 'clsx';\nimport { useIntl, MessageDescriptor } from 'react-intl';\nimport messages from '../../../i18n/commonMessages/Button.messages';\nimport type { PrimitiveButtonProps } from '..';\n\n/**\n * The Primitive `PrimitiveButton` component can be used in various parts the Wise Design\n * System internally. It supports different states such as disabled and loading,\n * and provides event handlers for common interactions like click, focus, blur,\n * mouse enter, mouse leave, and keydown.\n *\n * @see {@link PrimitiveButton} for further information.\n * @see {@link https://storybook.wise.design/?path=/docs/primitive-button--docs|Storybook Wise Design}\n */\nconst PrimitiveButton = forwardRef<HTMLButtonElement, PrimitiveButtonProps>(\n (\n {\n children,\n className,\n id,\n disabled = false,\n loading = false,\n testId,\n type = 'button',\n onClick,\n onFocus,\n onBlur,\n onMouseEnter,\n onMouseLeave,\n onKeyDown,\n ...props\n },\n ref,\n ) => {\n const intl = useIntl();\n const classNames = clsx(\n 'wds-Button',\n {\n 'wds-Button--disabled': disabled,\n 'wds-Button--loading': loading,\n },\n className,\n );\n\n const handleClick = useCallback(\n (event: React.MouseEvent<HTMLButtonElement>) => {\n if (disabled || loading) {\n event.preventDefault();\n } else {\n onClick?.(event);\n }\n },\n [disabled, loading, onClick],\n );\n\n const handleFocus = useCallback(\n (event: React.FocusEvent<HTMLButtonElement>) => {\n onFocus?.(event);\n },\n [onFocus],\n );\n\n const handleBlur = useCallback(\n (event: React.FocusEvent<HTMLButtonElement>) => {\n onBlur?.(event);\n },\n [onBlur],\n );\n\n const handleMouseEnter = useCallback(\n (event: React.MouseEvent<HTMLButtonElement>) => {\n onMouseEnter?.(event);\n },\n [onMouseEnter],\n );\n\n const handleMouseLeave = useCallback(\n (event: React.MouseEvent<HTMLButtonElement>) => {\n onMouseLeave?.(event);\n },\n [onMouseLeave],\n );\n\n const handleKeyDown = useCallback(\n (event: React.KeyboardEvent<HTMLButtonElement>) => {\n onKeyDown?.(event);\n },\n [onKeyDown],\n );\n\n /**\n * The following props are used to manage the `disabled` and `loading`\n * states for the button:\n *\n * - `aria-disabled`: Communicates to assistive technologies that the button\n * is disabled when it is either disabled or loading.\n * - `aria-label`: Provides an accessible label for the button, using a\n * localized loading message when the button is in a loading state.\n * - `aria-live`: Ensures that updates to the button's content are announced\n * by assistive technologies, set to 'polite' during loading.\n */\n const buttonProps = {\n 'aria-disabled': disabled || loading,\n 'aria-label': loading\n ? intl.formatMessage(messages.loadingAriaLabel as MessageDescriptor)\n : props['aria-label'],\n 'aria-live': (loading ? 'polite' : 'off') as 'polite' | 'off' | 'assertive' | undefined,\n className: classNames,\n 'data-testid': testId,\n disabled,\n id,\n ref,\n type,\n onBlur: handleBlur,\n onClick: handleClick,\n onFocus: handleFocus,\n onMouseEnter: handleMouseEnter,\n onMouseLeave: handleMouseLeave,\n onKeyDown: handleKeyDown,\n ...props,\n };\n\n return <button {...buttonProps}>{children}</button>;\n },\n);\n\nPrimitiveButton.displayName = 'PrimitiveButton';\n\nexport default PrimitiveButton;\n"],"names":["PrimitiveButton","forwardRef","children","className","id","disabled","loading","testId","type","onClick","onFocus","onBlur","onMouseEnter","onMouseLeave","onKeyDown","props","ref","intl","useIntl","classNames","clsx","handleClick","useCallback","event","preventDefault","handleFocus","handleBlur","handleMouseEnter","handleMouseLeave","handleKeyDown","buttonProps","formatMessage","messages","loadingAriaLabel","_jsx","displayName"],"mappings":";;;;;;AAAA;AAgBA,MAAMA,eAAe,gBAAGC,UAAU,CAChC,CACE;EACEC,QAAQ;EACRC,SAAS;EACTC,EAAE;AACFC,EAAAA,QAAQ,GAAG,KAAK;AAChBC,EAAAA,OAAO,GAAG,KAAK;EACfC,MAAM;AACNC,EAAAA,IAAI,GAAG,QAAQ;EACfC,OAAO;EACPC,OAAO;EACPC,MAAM;EACNC,YAAY;EACZC,YAAY;EACZC,SAAS;EACT,GAAGC,KAAAA;CACJ,EACDC,GAAG,KACD;AACF,EAAA,MAAMC,IAAI,GAAGC,OAAO,EAAE,CAAA;AACtB,EAAA,MAAMC,UAAU,GAAGC,IAAI,CACrB,YAAY,EACZ;AACE,IAAA,sBAAsB,EAAEf,QAAQ;AAChC,IAAA,qBAAqB,EAAEC,OAAAA;GACxB,EACDH,SAAS,CACV,CAAA;AAED,EAAA,MAAMkB,WAAW,GAAGC,WAAW,CAC5BC,KAA0C,IAAI;IAC7C,IAAIlB,QAAQ,IAAIC,OAAO,EAAE;MACvBiB,KAAK,CAACC,cAAc,EAAE,CAAA;AACxB,KAAC,MAAM;MACLf,OAAO,GAAGc,KAAK,CAAC,CAAA;AAClB,KAAA;GACD,EACD,CAAClB,QAAQ,EAAEC,OAAO,EAAEG,OAAO,CAAC,CAC7B,CAAA;AAED,EAAA,MAAMgB,WAAW,GAAGH,WAAW,CAC5BC,KAA0C,IAAI;IAC7Cb,OAAO,GAAGa,KAAK,CAAC,CAAA;AAClB,GAAC,EACD,CAACb,OAAO,CAAC,CACV,CAAA;AAED,EAAA,MAAMgB,UAAU,GAAGJ,WAAW,CAC3BC,KAA0C,IAAI;IAC7CZ,MAAM,GAAGY,KAAK,CAAC,CAAA;AACjB,GAAC,EACD,CAACZ,MAAM,CAAC,CACT,CAAA;AAED,EAAA,MAAMgB,gBAAgB,GAAGL,WAAW,CACjCC,KAA0C,IAAI;IAC7CX,Y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