@transferwise/components 0.0.0-experimental-28eac06 → 0.0.0-experimental-9b6d886

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 (202) hide show
  1. package/build/alert/Alert.js +17 -17
  2. package/build/alert/Alert.js.map +1 -1
  3. package/build/alert/Alert.mjs +14 -14
  4. package/build/alert/Alert.mjs.map +1 -1
  5. package/build/avatarLayout/AvatarLayout.js +2 -9
  6. package/build/avatarLayout/AvatarLayout.js.map +1 -1
  7. package/build/avatarLayout/AvatarLayout.mjs +2 -9
  8. package/build/avatarLayout/AvatarLayout.mjs.map +1 -1
  9. package/build/button/Button.js +79 -86
  10. package/build/button/Button.js.map +1 -1
  11. package/build/button/Button.mjs +80 -87
  12. package/build/button/Button.mjs.map +1 -1
  13. package/build/circularButton/CircularButton.js.map +1 -1
  14. package/build/circularButton/CircularButton.mjs.map +1 -1
  15. package/build/common/action/Action.js +15 -26
  16. package/build/common/action/Action.js.map +1 -1
  17. package/build/common/action/Action.mjs +15 -26
  18. package/build/common/action/Action.mjs.map +1 -1
  19. package/build/common/propsValues/sentiment.js +0 -1
  20. package/build/common/propsValues/sentiment.js.map +1 -1
  21. package/build/common/propsValues/sentiment.mjs +0 -1
  22. package/build/common/propsValues/sentiment.mjs.map +1 -1
  23. package/build/criticalBanner/CriticalCommsBanner.js +73 -10
  24. package/build/criticalBanner/CriticalCommsBanner.js.map +1 -1
  25. package/build/criticalBanner/CriticalCommsBanner.mjs +74 -11
  26. package/build/criticalBanner/CriticalCommsBanner.mjs.map +1 -1
  27. package/build/header/Header.js +2 -2
  28. package/build/header/Header.js.map +1 -1
  29. package/build/header/Header.mjs +1 -1
  30. package/build/i18n/en.json +0 -1
  31. package/build/i18n/en.json.js +0 -1
  32. package/build/i18n/en.json.js.map +1 -1
  33. package/build/i18n/en.json.mjs +0 -1
  34. package/build/i18n/en.json.mjs.map +1 -1
  35. package/build/i18n/ja.json +1 -0
  36. package/build/i18n/ja.json.js +1 -0
  37. package/build/i18n/ja.json.js.map +1 -1
  38. package/build/i18n/ja.json.mjs +1 -0
  39. package/build/i18n/ja.json.mjs.map +1 -1
  40. package/build/i18n/pt.json +1 -0
  41. package/build/i18n/pt.json.js +1 -0
  42. package/build/i18n/pt.json.js.map +1 -1
  43. package/build/i18n/pt.json.mjs +1 -0
  44. package/build/i18n/pt.json.mjs.map +1 -1
  45. package/build/i18n/ru.json +1 -0
  46. package/build/i18n/ru.json.js +1 -0
  47. package/build/i18n/ru.json.js.map +1 -1
  48. package/build/i18n/ru.json.mjs +1 -0
  49. package/build/i18n/ru.json.mjs.map +1 -1
  50. package/build/i18n/zh-HK.json +1 -0
  51. package/build/i18n/zh-HK.json.js +1 -0
  52. package/build/i18n/zh-HK.json.js.map +1 -1
  53. package/build/i18n/zh-HK.json.mjs +1 -0
  54. package/build/i18n/zh-HK.json.mjs.map +1 -1
  55. package/build/index.js +2 -2
  56. package/build/index.mjs +1 -1
  57. package/build/link/Link.js +3 -8
  58. package/build/link/Link.js.map +1 -1
  59. package/build/link/Link.mjs +3 -8
  60. package/build/link/Link.mjs.map +1 -1
  61. package/build/main.css +70 -267
  62. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js +4 -2
  63. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js.map +1 -1
  64. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs +4 -2
  65. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs.map +1 -1
  66. package/build/primitives/PrimitiveButton/src/PrimitiveButton.js +5 -3
  67. package/build/primitives/PrimitiveButton/src/PrimitiveButton.js.map +1 -1
  68. package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs +5 -3
  69. package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs.map +1 -1
  70. package/build/select/Select.js +2 -2
  71. package/build/select/Select.js.map +1 -1
  72. package/build/select/Select.mjs +1 -1
  73. package/build/statusIcon/StatusIcon.js +1 -5
  74. package/build/statusIcon/StatusIcon.js.map +1 -1
  75. package/build/statusIcon/StatusIcon.messages.js +0 -3
  76. package/build/statusIcon/StatusIcon.messages.js.map +1 -1
  77. package/build/statusIcon/StatusIcon.messages.mjs +0 -3
  78. package/build/statusIcon/StatusIcon.messages.mjs.map +1 -1
  79. package/build/statusIcon/StatusIcon.mjs +1 -5
  80. package/build/statusIcon/StatusIcon.mjs.map +1 -1
  81. package/build/styles/avatarLayout/AvatarLayout.css +0 -11
  82. package/build/styles/button/Button.css +15 -230
  83. package/build/styles/criticalBanner/CriticalCommsBanner.css +73 -21
  84. package/build/styles/main.css +70 -267
  85. package/build/types/alert/Alert.d.ts +4 -3
  86. package/build/types/alert/Alert.d.ts.map +1 -1
  87. package/build/types/avatarLayout/AvatarLayout.d.ts.map +1 -1
  88. package/build/types/button/Button.d.ts +23 -2
  89. package/build/types/button/Button.d.ts.map +1 -1
  90. package/build/types/button/index.d.ts +2 -2
  91. package/build/types/button/index.d.ts.map +1 -1
  92. package/build/types/circularButton/CircularButton.d.ts.map +1 -1
  93. package/build/types/common/action/Action.d.ts +2 -5
  94. package/build/types/common/action/Action.d.ts.map +1 -1
  95. package/build/types/common/propsValues/sentiment.d.ts +0 -1
  96. package/build/types/common/propsValues/sentiment.d.ts.map +1 -1
  97. package/build/types/criticalBanner/CriticalCommsBanner.d.ts.map +1 -1
  98. package/build/types/index.d.ts +1 -0
  99. package/build/types/index.d.ts.map +1 -1
  100. package/build/types/link/Link.d.ts +2 -2
  101. package/build/types/link/Link.d.ts.map +1 -1
  102. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.d.ts.map +1 -1
  103. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts +2 -6
  104. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts.map +1 -1
  105. package/build/types/primitives/PrimitiveButton/src/PrimitiveButton.d.ts.map +1 -1
  106. package/build/types/statusIcon/StatusIcon.d.ts.map +1 -1
  107. package/build/types/statusIcon/StatusIcon.messages.d.ts +0 -5
  108. package/build/types/statusIcon/StatusIcon.messages.d.ts.map +1 -1
  109. package/build/types/test-utils/index.d.ts +0 -2
  110. package/build/types/test-utils/index.d.ts.map +1 -1
  111. package/build/types/test-utils/story-config.d.ts +1 -1
  112. package/build/types/test-utils/story-config.d.ts.map +1 -1
  113. package/build/upload/steps/completeStep/completeStep.js +2 -2
  114. package/build/upload/steps/completeStep/completeStep.js.map +1 -1
  115. package/build/upload/steps/completeStep/completeStep.mjs +1 -1
  116. package/build/upload/steps/processingStep/processingStep.js +2 -2
  117. package/build/upload/steps/processingStep/processingStep.js.map +1 -1
  118. package/build/upload/steps/processingStep/processingStep.mjs +1 -1
  119. package/build/uploadInput/UploadInput.js +3 -3
  120. package/build/uploadInput/UploadInput.js.map +1 -1
  121. package/build/uploadInput/UploadInput.mjs +1 -1
  122. package/package.json +3 -3
  123. package/src/alert/Alert.spec.tsx +30 -0
  124. package/src/alert/Alert.story.tsx +1 -34
  125. package/src/alert/Alert.tests.story.tsx +1 -1
  126. package/src/alert/Alert.tsx +15 -20
  127. package/src/avatarLayout/AvatarLayout.css +0 -11
  128. package/src/avatarLayout/AvatarLayout.less +1 -18
  129. package/src/avatarLayout/AvatarLayout.tsx +2 -10
  130. package/src/button/Button.css +15 -230
  131. package/src/button/Button.less +14 -242
  132. package/src/button/Button.spec.tsx +226 -215
  133. package/src/button/Button.story.tsx +134 -761
  134. package/src/button/Button.tsx +132 -103
  135. package/src/button/__snapshots__/Button.spec.tsx.snap +309 -0
  136. package/src/button/index.ts +3 -2
  137. package/src/circularButton/CircularButton.tsx +0 -1
  138. package/src/common/action/Action.tsx +22 -40
  139. package/src/common/propsValues/sentiment.ts +0 -1
  140. package/src/criticalBanner/CriticalCommsBanner.css +73 -21
  141. package/src/criticalBanner/CriticalCommsBanner.less +70 -24
  142. package/src/criticalBanner/CriticalCommsBanner.story.tsx +4 -26
  143. package/src/criticalBanner/CriticalCommsBanner.tsx +50 -8
  144. package/src/field/Field.story.tsx +1 -1
  145. package/src/flowNavigation/__snapshots__/FlowNavigation.spec.js.snap +2 -1
  146. package/src/i18n/en.json +0 -1
  147. package/src/i18n/ja.json +1 -0
  148. package/src/i18n/pt.json +1 -0
  149. package/src/i18n/ru.json +1 -0
  150. package/src/i18n/zh-HK.json +1 -0
  151. package/src/index.ts +1 -0
  152. package/src/inputs/SelectInput.story.tsx +1 -1
  153. package/src/label/Label.story.tsx +1 -1
  154. package/src/link/Link.tsx +6 -15
  155. package/src/main.css +70 -267
  156. package/src/main.less +0 -1
  157. package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.tsx +8 -2
  158. package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.ts +2 -7
  159. package/src/primitives/PrimitiveAnchor/test/PrimitiveAnchor.spec.tsx +3 -1
  160. package/src/primitives/PrimitiveButton/src/PrimitiveButton.tsx +12 -4
  161. package/src/primitives/PrimitiveButton/test/PrimitiveButton.spec.tsx +13 -16
  162. package/src/radio/Radio.spec.tsx +73 -0
  163. package/src/radio/Radio.story.tsx +22 -52
  164. package/src/radioGroup/RadioGroup.spec.tsx +91 -0
  165. package/src/radioGroup/RadioGroup.story.tsx +3 -5
  166. package/src/statusIcon/StatusIcon.less +0 -1
  167. package/src/statusIcon/StatusIcon.messages.ts +0 -6
  168. package/src/statusIcon/StatusIcon.tsx +1 -8
  169. package/src/test-utils/Parameters.d.ts +1 -9
  170. package/src/test-utils/story-config.ts +1 -10
  171. package/build/button/Button.resolver.js +0 -74
  172. package/build/button/Button.resolver.js.map +0 -1
  173. package/build/button/Button.resolver.mjs +0 -72
  174. package/build/button/Button.resolver.mjs.map +0 -1
  175. package/build/button/LegacyButton.js +0 -114
  176. package/build/button/LegacyButton.js.map +0 -1
  177. package/build/button/LegacyButton.mjs +0 -112
  178. package/build/button/LegacyButton.mjs.map +0 -1
  179. package/build/styles/button/Button.vars.css +0 -46
  180. package/build/styles/button/LegacyButton.css +0 -23
  181. package/build/types/button/Button.resolver.d.ts +0 -35
  182. package/build/types/button/Button.resolver.d.ts.map +0 -1
  183. package/build/types/button/Button.types.d.ts +0 -70
  184. package/build/types/button/Button.types.d.ts.map +0 -1
  185. package/build/types/button/LegacyButton.d.ts +0 -44
  186. package/build/types/button/LegacyButton.d.ts.map +0 -1
  187. package/src/button/Button.accessibility.docs.mdx +0 -103
  188. package/src/button/Button.resolver.tsx +0 -73
  189. package/src/button/Button.tests.story.tsx +0 -27
  190. package/src/button/Button.types.ts +0 -92
  191. package/src/button/Button.vars.css +0 -46
  192. package/src/button/Button.vars.less +0 -55
  193. package/src/button/LegacyButton.css +0 -23
  194. package/src/button/LegacyButton.less +0 -24
  195. package/src/button/LegacyButton.spec.tsx +0 -147
  196. package/src/button/LegacyButton.story.tsx +0 -228
  197. package/src/button/LegacyButton.tsx +0 -177
  198. package/src/radio/Radio.rtl.spec.tsx +0 -24
  199. package/src/radio/Radio.spec.js +0 -76
  200. package/src/radio/__snapshots__/Radio.rtl.spec.tsx.snap +0 -49
  201. package/src/radioGroup/RadioGroup.rtl.spec.tsx +0 -30
  202. package/src/radioGroup/RadioGroup.spec.js +0 -90
@@ -1,11 +1,8 @@
1
- import { boolean, text } from '@storybook/addon-knobs';
2
- import { Flag } from '@wise/art';
1
+ import { boolean } from '@storybook/addon-knobs';
3
2
  import { useState } from 'react';
4
-
5
- import Avatar, { AvatarType } from '../avatar';
6
- import Checkbox from '../checkbox';
7
-
8
3
  import Radio from './Radio';
4
+ import AvatarView from '../avatarView';
5
+ import { Flag } from '@wise/art';
9
6
 
10
7
  export default {
11
8
  component: Radio,
@@ -13,69 +10,42 @@ export default {
13
10
  };
14
11
 
15
12
  export const Basic = () => {
16
- const [checked, setChecked] = useState(true);
13
+ const [selectedValue, setSelectedValue] = useState('option1');
17
14
 
18
15
  const disabled = boolean('disabled', false);
19
- const label = text('label', 'This is the label');
20
- const secondary = text('secondary', '');
21
- const showAvatar = boolean('avatar', false);
22
- const hasError = boolean('hasError', false);
23
16
 
24
17
  return (
25
18
  <>
26
- <div className={`form-group ${hasError ? 'has-error' : ''}`}>
19
+ <div className={`form-group ${selectedValue === 'option1' ? 'has-error' : ''}`}>
27
20
  <Radio
28
- label={label}
21
+ label="Without Avatar"
29
22
  name="name"
30
- id="id"
31
- checked={checked}
23
+ secondary="This is secondary text"
24
+ id="radioGroup1"
32
25
  disabled={disabled}
33
- avatar={
34
- showAvatar ? (
35
- <Avatar type={AvatarType.THUMBNAIL}>
36
- <Flag code="IMP" />
37
- </Avatar>
38
- ) : null
39
- }
40
- onChange={() => setChecked(!checked)}
26
+ value="option1"
27
+ checked={selectedValue === 'option1'}
28
+ onChange={() => setSelectedValue('option1')}
41
29
  />
42
30
  </div>
43
- <div className={`form-group ${hasError ? 'has-error' : ''}`}>
31
+ <div className="form-group">
44
32
  <Radio
45
- label={label}
33
+ label="With Avatar"
46
34
  name="name"
47
- id="id1"
48
- checked={checked}
35
+ id="radioGroup2"
49
36
  disabled={disabled}
50
- secondary={secondary}
51
37
  avatar={
52
- showAvatar ? (
53
- <Avatar type={AvatarType.THUMBNAIL}>
54
- <Flag code="KES" />
55
- </Avatar>
56
- ) : null
38
+ <AvatarView>
39
+ <Flag code="IMP" />
40
+ </AvatarView>
57
41
  }
58
- onChange={() => setChecked(!checked)}
42
+ value="option1"
43
+ checked={selectedValue === 'option2'}
44
+ onChange={() => setSelectedValue('option2')}
59
45
  />
60
46
  </div>
61
- <div className={`form-group ${hasError ? 'has-error' : ''}`}>
62
- <Checkbox
63
- label={label}
64
- id="id2"
65
- checked={checked}
66
- disabled={disabled}
67
- secondary={secondary}
68
- onChange={() => setChecked(!checked)}
69
- />
70
- </div>
71
- <div className={`form-group ${hasError ? 'has-error' : ''}`}>
72
- <Checkbox
73
- label={label}
74
- id="id3"
75
- checked={checked}
76
- disabled={disabled}
77
- onChange={() => setChecked(!checked)}
78
- />
47
+ <div className="form-group">
48
+ <Radio label="Disabled" name="name" id="radioGroup3" disabled value="option3" />
79
49
  </div>
80
50
  </>
81
51
  );
@@ -0,0 +1,91 @@
1
+ import { render, screen, mockMatchMedia } from '../test-utils';
2
+ import { userEvent } from '@testing-library/user-event';
3
+ import RadioGroup from '.';
4
+ import AvatarView from '../avatarView';
5
+ import { Field } from '../field/Field';
6
+
7
+ describe('RadioGroup', () => {
8
+ const handleChange = jest.fn();
9
+ const avatar = <AvatarView profileName="High Definition" />;
10
+ mockMatchMedia();
11
+
12
+ const RADIOS = [
13
+ {
14
+ id: 'id-test-0',
15
+ value: 'value-test0',
16
+ label: 'Radio1',
17
+ secondary: 'secondary',
18
+ disabled: true,
19
+ avatar,
20
+ },
21
+ {
22
+ id: 'id-test-1',
23
+ value: 'value-test1',
24
+ label: 'Radio2',
25
+ secondary: 'secondary',
26
+ disabled: false,
27
+ },
28
+ {
29
+ id: 'id-test-2',
30
+ value: 'value-test2',
31
+ label: 'Radio3',
32
+ secondary: 'secondary',
33
+ disabled: false,
34
+ },
35
+ ];
36
+ it('has accessible role', () => {
37
+ render(
38
+ <RadioGroup
39
+ name="currency"
40
+ radios={[{ label: 'USD' }, { label: 'EUR' }]}
41
+ onChange={() => {}}
42
+ />,
43
+ );
44
+ expect(screen.getByRole('radiogroup')).toBeInTheDocument();
45
+ });
46
+
47
+ it('supports `Field` for labeling', () => {
48
+ render(
49
+ <Field label="Currency">
50
+ <RadioGroup
51
+ name="currency"
52
+ radios={[{ label: 'USD' }, { label: 'EUR' }]}
53
+ onChange={() => {}}
54
+ />
55
+ </Field>,
56
+ );
57
+ expect(screen.getByRole('radiogroup')).toHaveAccessibleName(/^Currency/);
58
+ });
59
+
60
+ it('renders nothing if no radios are provided', () => {
61
+ render(<RadioGroup name="radio-group" radios={[]} onChange={handleChange} />);
62
+ expect(screen.queryByRole('radiogroup')).not.toBeInTheDocument();
63
+ });
64
+
65
+ it('renders radio options', () => {
66
+ render(<RadioGroup name="radio-group" radios={RADIOS} onChange={handleChange} />);
67
+ expect(screen.getAllByRole('radio')).toHaveLength(RADIOS.length);
68
+ const firstRadio = screen.getByRole('radio', { name: /Radio1/i });
69
+ expect(firstRadio).toBeDisabled();
70
+ });
71
+
72
+ it('checks the specified radio value', () => {
73
+ render(
74
+ <RadioGroup
75
+ name="radio-group"
76
+ radios={RADIOS}
77
+ selectedValue="value-test2"
78
+ onChange={handleChange}
79
+ />,
80
+ );
81
+ const checkedRadio = screen.getByRole('radio', { name: /Radio3/i });
82
+ expect(checkedRadio).toBeChecked();
83
+ });
84
+
85
+ it('calls onChange with the selected value', async () => {
86
+ render(<RadioGroup name="radio-group" radios={RADIOS} onChange={handleChange} />);
87
+ const thirdRadio = screen.getByRole('radio', { name: /Radio3/i });
88
+ await userEvent.click(thirdRadio);
89
+ expect(handleChange).toHaveBeenCalledWith('value-test2');
90
+ });
91
+ });
@@ -1,12 +1,10 @@
1
1
  import { Flag } from '@wise/art';
2
-
3
- import Avatar, { AvatarType } from '../avatar';
4
-
5
2
  import RadioGroup, { RadioGroupProps, RadioGroupRadio } from './RadioGroup';
6
3
  import { Field } from '../field/Field';
7
4
  import { Meta, StoryObj } from '@storybook/react';
8
5
  import { fn } from '@storybook/test';
9
6
  import { useState } from 'react';
7
+ import AvatarView from '../avatarView';
10
8
 
11
9
  const meta = {
12
10
  component: RadioGroup,
@@ -52,9 +50,9 @@ export const WithAvatars = {
52
50
  ({
53
51
  ...radio,
54
52
  avatar: (
55
- <Avatar type={AvatarType.THUMBNAIL}>
53
+ <AvatarView>
56
54
  <Flag code="NZD" />
57
- </Avatar>
55
+ </AvatarView>
58
56
  ),
59
57
  }) satisfies RadioGroupRadio,
60
58
  ),
@@ -24,7 +24,6 @@
24
24
  background-color: var(--color-sentiment-negative);
25
25
  }
26
26
 
27
-
28
27
  .status-circle.neutral {
29
28
  background-color: var(--color-content-secondary);
30
29
  }
@@ -19,12 +19,6 @@ export default defineMessages({
19
19
  description:
20
20
  'Visually hidden label read by screen readers, describing the Warning icon – normally a prefix to remaining visible content, e.g. validation result.',
21
21
  },
22
- criticalLabel: {
23
- id: 'neptune.StatusIcon.iconLabel.critical',
24
- defaultMessage: 'Critical:',
25
- description:
26
- 'Visually hidden label read by screen readers, describing the Critical icon – normally a prefix to remaining visible content, e.g. validation result.',
27
- },
28
22
  pendingLabel: {
29
23
  id: 'neptune.StatusIcon.iconLabel.pending',
30
24
  defaultMessage: 'Pending:',
@@ -52,10 +52,6 @@ const StatusIcon = ({ sentiment = 'neutral', size: sizeProp = 40, iconLabel }: S
52
52
  Icon: Alert,
53
53
  defaultIconLabel: intl.formatMessage(messages.warningLabel),
54
54
  },
55
- [Sentiment.CRITICAL]: {
56
- Icon: Alert,
57
- defaultIconLabel: intl.formatMessage(messages.criticalLabel),
58
- },
59
55
  [Sentiment.PENDING]: {
60
56
  Icon: ClockBorderless,
61
57
  defaultIconLabel: intl.formatMessage(messages.pendingLabel),
@@ -80,10 +76,7 @@ const StatusIcon = ({ sentiment = 'neutral', size: sizeProp = 40, iconLabel }: S
80
76
  };
81
77
  const { Icon, defaultIconLabel } = iconMetaBySentiment[sentiment];
82
78
 
83
- const iconColor =
84
- sentiment === 'warning' || sentiment === 'pending' || sentiment === 'critical'
85
- ? 'dark'
86
- : 'light';
79
+ const iconColor = sentiment === 'warning' || sentiment === 'pending' ? 'dark' : 'light';
87
80
  const isTinyViewport = useMedia(`(max-width: ${Breakpoint.ZOOM_400}px)`);
88
81
  const size = mapLegacySize[sizeProp] ?? sizeProp;
89
82
  return (
@@ -1,15 +1,7 @@
1
1
  declare module '@storybook/react' {
2
2
  interface Parameters {
3
3
  /** Prefer using `storyConfig` for configuring variants */
4
- variants?: (
5
- | 'default'
6
- | 'light'
7
- | 'dark'
8
- | 'bright-green'
9
- | 'forest-green'
10
- | 'rtl'
11
- | (string & Record<string, unknown>)
12
- )[];
4
+ variants?: ('default' | 'light' | 'dark' | 'rtl' | (string & Record<string, unknown>))[];
13
5
  /** Used by Chromatic */
14
6
  chromatic?: ChromaticParameters;
15
7
  viewport?: {
@@ -30,16 +30,7 @@ interface StoryConfig {
30
30
  *
31
31
  * @default undefined
32
32
  */
33
- variants?: (
34
- | 'default'
35
- | 'light'
36
- | 'dark'
37
- | 'bright-green'
38
- | 'forest-green'
39
- | 'rtl'
40
- | 'mobile'
41
- | '400%'
42
- )[];
33
+ variants?: ('default' | 'light' | 'dark' | 'rtl' | 'mobile' | '400%')[];
43
34
  }
44
35
 
45
36
  const getViewportWidth = (viewport: (typeof viewports)[keyof typeof viewports]) => {
@@ -1,74 +0,0 @@
1
- 'use strict';
2
-
3
- var React = require('react');
4
- var LegacyButton = require('./LegacyButton.js');
5
- var Button$1 = require('./Button.js');
6
- var jsxRuntime = require('react/jsx-runtime');
7
-
8
- const mapProps = props => {
9
- const {
10
- priority,
11
- size,
12
- type,
13
- ...newProps
14
- } = props;
15
- const priorityMapping = {
16
- accent: {
17
- primary: 'primary',
18
- secondary: 'tertiary',
19
- tertiary: 'minimal'
20
- },
21
- positive: {
22
- primary: 'primary',
23
- secondary: 'tertiary',
24
- tertiary: 'tertiary'
25
- },
26
- negative: {
27
- primary: 'primary',
28
- secondary: 'secondary',
29
- tertiary: 'secondary'
30
- }
31
- };
32
- const mappedPriority = type && priority ? priorityMapping[type]?.[priority] || priority : priority || undefined;
33
- const mappedSentiment = type === 'negative' ? 'negative' : undefined;
34
- const legacyButtonTypes = ['accent', 'negative', 'positive', 'primary', 'pay', 'secondary', 'danger', 'link'];
35
- const resolveSize = () => {
36
- if (size) {
37
- return {
38
- xs: 'sm',
39
- sm: 'sm',
40
- md: 'md',
41
- lg: 'lg'
42
- }[size] || size;
43
- }
44
- return size;
45
- };
46
- return {
47
- ...newProps,
48
- size: resolveSize(),
49
- priority: mappedPriority,
50
- sentiment: mappedSentiment || ('sentiment' in props ? props.sentiment : null),
51
- type: type && !legacyButtonTypes.includes(type) ? type : props.htmlType || null,
52
- v2: true
53
- };
54
- };
55
- const Button = /*#__PURE__*/React.forwardRef(({
56
- v2 = false,
57
- ...props
58
- }, ref) => {
59
- if (v2) {
60
- const mappedProps = mapProps(props);
61
- return /*#__PURE__*/jsxRuntime.jsx(Button$1, {
62
- ...mappedProps,
63
- ref: ref
64
- });
65
- }
66
- return /*#__PURE__*/jsxRuntime.jsx(LegacyButton, {
67
- ...props,
68
- ref: ref
69
- });
70
- });
71
- Button.displayName = 'Button';
72
-
73
- module.exports = Button;
74
- //# sourceMappingURL=Button.resolver.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Button.resolver.js","sources":["../../src/button/Button.resolver.tsx"],"sourcesContent":["import { forwardRef } from 'react';\nimport LegacyButton, { LegacyButtonProps } from './LegacyButton';\nimport { ButtonReferenceType, ButtonProps as NewButtonProps } from './Button.types';\nimport NewButton from './Button';\n\nexport type ButtonProps = LegacyButtonProps | NewButtonProps;\n\nconst mapProps = (props: LegacyButtonProps): NewButtonProps => {\n const { priority, size, type, ...newProps } = props;\n\n const priorityMapping: Record<string, Record<string, NewButtonProps['priority']>> = {\n accent: {\n primary: 'primary',\n secondary: 'tertiary',\n tertiary: 'minimal',\n },\n positive: {\n primary: 'primary',\n secondary: 'tertiary',\n tertiary: 'tertiary',\n },\n negative: {\n primary: 'primary',\n secondary: 'secondary',\n tertiary: 'secondary',\n },\n };\n\n const mappedPriority =\n type && priority ? priorityMapping[type]?.[priority] || priority : priority || undefined;\n const mappedSentiment = type === 'negative' ? 'negative' : undefined;\n\n const legacyButtonTypes: LegacyButtonProps['type'][] = [\n 'accent',\n 'negative',\n 'positive',\n 'primary',\n 'pay',\n 'secondary',\n 'danger',\n 'link',\n ];\n\n const resolveSize = () => {\n if (size) {\n return { xs: 'sm', sm: 'sm', md: 'md', lg: 'lg' }[size] || size;\n }\n\n return size;\n };\n\n return {\n ...newProps,\n size: resolveSize(),\n priority: mappedPriority,\n sentiment: mappedSentiment || ('sentiment' in props ? props.sentiment : null),\n type: type && !legacyButtonTypes.includes(type) ? type : props.htmlType || null,\n v2: true,\n } as NewButtonProps;\n};\n\nconst Button = forwardRef<ButtonReferenceType, ButtonProps>(({ v2 = false, ...props }, ref) => {\n if (v2) {\n const mappedProps = mapProps(props as LegacyButtonProps);\n return <NewButton {...mappedProps} ref={ref} />;\n }\n\n return <LegacyButton {...(props as LegacyButtonProps)} ref={ref} />;\n});\n\nButton.displayName = 'Button';\n\nexport default Button;\n"],"names":["mapProps","props","priority","size","type","newProps","priorityMapping","accent","primary","secondary","tertiary","positive","negative","mappedPriority","undefined","mappedSentiment","legacyButtonTypes","resolveSize","xs","sm","md","lg","sentiment","includes","htmlType","v2","Button","forwardRef","ref","mappedProps","_jsx","NewButton","LegacyButton","displayName"],"mappings":";;;;;;;AAOA,MAAMA,QAAQ,GAAIC,KAAwB,IAAoB;EAC5D,MAAM;IAAEC,QAAQ;IAAEC,IAAI;IAAEC,IAAI;IAAE,GAAGC,QAAAA;AAAQ,GAAE,GAAGJ,KAAK,CAAA;AAEnD,EAAA,MAAMK,eAAe,GAA+D;AAClFC,IAAAA,MAAM,EAAE;AACNC,MAAAA,OAAO,EAAE,SAAS;AAClBC,MAAAA,SAAS,EAAE,UAAU;AACrBC,MAAAA,QAAQ,EAAE,SAAA;KACX;AACDC,IAAAA,QAAQ,EAAE;AACRH,MAAAA,OAAO,EAAE,SAAS;AAClBC,MAAAA,SAAS,EAAE,UAAU;AACrBC,MAAAA,QAAQ,EAAE,UAAA;KACX;AACDE,IAAAA,QAAQ,EAAE;AACRJ,MAAAA,OAAO,EAAE,SAAS;AAClBC,MAAAA,SAAS,EAAE,WAAW;AACtBC,MAAAA,QAAQ,EAAE,WAAA;AACX,KAAA;GACF,CAAA;AAED,EAAA,MAAMG,cAAc,GAClBT,IAAI,IAAIF,QAAQ,GAAGI,eAAe,CAACF,IAAI,CAAC,GAAGF,QAAQ,CAAC,IAAIA,QAAQ,GAAGA,QAAQ,IAAIY,SAAS,CAAA;EAC1F,MAAMC,eAAe,GAAGX,IAAI,KAAK,UAAU,GAAG,UAAU,GAAGU,SAAS,CAAA;AAEpE,EAAA,MAAME,iBAAiB,GAAgC,CACrD,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AA2B;AAAE2B,IAAAA,GAAG,EAAEA,GAAAA;AAAI,IAAG,CAAA;AACrE,CAAC,EAAC;AAEFF,MAAM,CAACO,WAAW,GAAG,QAAQ;;;;"}
@@ -1,72 +0,0 @@
1
- import { forwardRef } from 'react';
2
- import LegacyButton from './LegacyButton.mjs';
3
- import Button$1 from './Button.mjs';
4
- import { jsx } from 'react/jsx-runtime';
5
-
6
- const mapProps = props => {
7
- const {
8
- priority,
9
- size,
10
- type,
11
- ...newProps
12
- } = props;
13
- const priorityMapping = {
14
- accent: {
15
- primary: 'primary',
16
- secondary: 'tertiary',
17
- tertiary: 'minimal'
18
- },
19
- positive: {
20
- primary: 'primary',
21
- secondary: 'tertiary',
22
- tertiary: 'tertiary'
23
- },
24
- negative: {
25
- primary: 'primary',
26
- secondary: 'secondary',
27
- tertiary: 'secondary'
28
- }
29
- };
30
- const mappedPriority = type && priority ? priorityMapping[type]?.[priority] || priority : priority || undefined;
31
- const mappedSentiment = type === 'negative' ? 'negative' : undefined;
32
- const legacyButtonTypes = ['accent', 'negative', 'positive', 'primary', 'pay', 'secondary', 'danger', 'link'];
33
- const resolveSize = () => {
34
- if (size) {
35
- return {
36
- xs: 'sm',
37
- sm: 'sm',
38
- md: 'md',
39
- lg: 'lg'
40
- }[size] || size;
41
- }
42
- return size;
43
- };
44
- return {
45
- ...newProps,
46
- size: resolveSize(),
47
- priority: mappedPriority,
48
- sentiment: mappedSentiment || ('sentiment' in props ? props.sentiment : null),
49
- type: type && !legacyButtonTypes.includes(type) ? type : props.htmlType || null,
50
- v2: true
51
- };
52
- };
53
- const Button = /*#__PURE__*/forwardRef(({
54
- v2 = false,
55
- ...props
56
- }, ref) => {
57
- if (v2) {
58
- const mappedProps = mapProps(props);
59
- return /*#__PURE__*/jsx(Button$1, {
60
- ...mappedProps,
61
- ref: ref
62
- });
63
- }
64
- return /*#__PURE__*/jsx(LegacyButton, {
65
- ...props,
66
- ref: ref
67
- });
68
- });
69
- Button.displayName = 'Button';
70
-
71
- export { Button as default };
72
- //# sourceMappingURL=Button.resolver.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Button.resolver.mjs","sources":["../../src/button/Button.resolver.tsx"],"sourcesContent":["import { forwardRef } from 'react';\nimport LegacyButton, { LegacyButtonProps } from './LegacyButton';\nimport { ButtonReferenceType, ButtonProps as NewButtonProps } from './Button.types';\nimport NewButton from './Button';\n\nexport type ButtonProps = LegacyButtonProps | NewButtonProps;\n\nconst mapProps = (props: LegacyButtonProps): NewButtonProps => {\n const { priority, size, type, ...newProps } = props;\n\n const priorityMapping: Record<string, Record<string, NewButtonProps['priority']>> = {\n accent: {\n primary: 'primary',\n secondary: 'tertiary',\n tertiary: 'minimal',\n },\n positive: {\n primary: 'primary',\n secondary: 'tertiary',\n tertiary: 'tertiary',\n },\n negative: {\n primary: 'primary',\n secondary: 'secondary',\n tertiary: 'secondary',\n },\n };\n\n const mappedPriority =\n type && priority ? priorityMapping[type]?.[priority] || priority : priority || undefined;\n const mappedSentiment = type === 'negative' ? 'negative' : undefined;\n\n const legacyButtonTypes: LegacyButtonProps['type'][] = [\n 'accent',\n 'negative',\n 'positive',\n 'primary',\n 'pay',\n 'secondary',\n 'danger',\n 'link',\n ];\n\n const resolveSize = () => {\n if (size) {\n return { xs: 'sm', sm: 'sm', md: 'md', lg: 'lg' }[size] || size;\n }\n\n return size;\n };\n\n return {\n ...newProps,\n size: resolveSize(),\n priority: mappedPriority,\n sentiment: mappedSentiment || ('sentiment' in props ? props.sentiment : null),\n type: type && !legacyButtonTypes.includes(type) ? type : props.htmlType || null,\n v2: true,\n } as NewButtonProps;\n};\n\nconst Button = forwardRef<ButtonReferenceType, ButtonProps>(({ v2 = false, ...props }, ref) => {\n if (v2) {\n const mappedProps = mapProps(props as LegacyButtonProps);\n return <NewButton {...mappedProps} ref={ref} />;\n }\n\n return <LegacyButton {...(props as LegacyButtonProps)} ref={ref} />;\n});\n\nButton.displayName = 'Button';\n\nexport default Button;\n"],"names":["mapProps","props","priority","size","type","newProps","priorityMapping","accent","primary","secondary","tertiary","positive","negative","mappedPriority","undefined","mappedSentiment","legacyButtonTypes","resolveSize","xs","sm","md","lg","sentiment","includes","htmlType","v2","Button","forwardRef","ref","mappedProps","_jsx","NewButton","LegacyButton","displayName"],"mappings":";;;;;AAOA,MAAMA,QAAQ,GAAIC,KAAwB,IAAoB;EAC5D,MAAM;IAAEC,QAAQ;IAAEC,IAAI;IAAEC,IAAI;IAAE,GAAGC,QAAAA;AAAQ,GAAE,GAAGJ,KAAK,CAAA;AAEnD,EAAA,MAAMK,eAAe,GAA+D;AAClFC,IAAAA,MAAM,EAAE;AACNC,MAAAA,OAAO,EAAE,SAAS;AAClBC,MAAAA,SAAS,EAAE,UAAU;AACrBC,MAAAA,QAAQ,EAAE,SAAA;KACX;AACDC,IAAAA,QAAQ,EAAE;AACRH,MAAAA,OAAO,EAAE,SAAS;AAClBC,MAAAA,SAAS,EAAE,UAAU;AACrBC,MAAAA,QAAQ,EAAE,UAAA;KACX;AACDE,IAAAA,QAAQ,EAAE;AACRJ,MAAAA,OAAO,EAAE,SAAS;AAClBC,MAAAA,SAAS,EAAE,WAAW;AACtBC,MAAAA,QAAQ,EAAE,WAAA;AACX,KAAA;GACF,CAAA;AAED,EAAA,MAAMG,cAAc,GAClBT,IAAI,IAAIF,QAAQ,GAAGI,eAAe,CAACF,IAAI,CAAC,GAAGF,QAAQ,CAAC,IAAIA,QAAQ,GAAGA,QAAQ,IAAIY,SAAS,CAAA;EAC1F,MAAMC,eAAe,GAAGX,IAAI,KAAK,UAAU,GAAG,UAAU,GAAGU,SAAS,CAAA;AAEpE,EAAA,MAAME,iBAAiB,GAAgC,CACrD,QAAQ,EACR,UAAU,EACV,UAAU,EACV,SAAS,EACT,KAAK,EACL,WAAW,EACX,QAAQ,EACR,MAAM,CACP,CAAA;EAED,MAAMC,WAAW,GAAGA,MAAK;AACvB,IAAA,IAAId,IAAI,EAAE;MACR,OAAO;AAAEe,QAAAA,EAAE,EAA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
- var reactIntl = require('react-intl');
6
- require('../common/theme.js');
7
- require('../common/direction.js');
8
- var control = require('../common/propsValues/control.js');
9
- require('../common/propsValues/breakpoint.js');
10
- var size = require('../common/propsValues/size.js');
11
- require('../common/propsValues/typography.js');
12
- require('../common/propsValues/width.js');
13
- require('../common/propsValues/type.js');
14
- require('../common/propsValues/dateMode.js');
15
- require('../common/propsValues/monthFormat.js');
16
- require('../common/propsValues/position.js');
17
- require('../common/propsValues/layouts.js');
18
- require('../common/propsValues/status.js');
19
- require('../common/propsValues/sentiment.js');
20
- require('../common/propsValues/profileType.js');
21
- require('../common/propsValues/variant.js');
22
- require('../common/propsValues/scroll.js');
23
- require('../common/propsValues/markdownNodeType.js');
24
- require('../common/fileType.js');
25
- require('@transferwise/icons');
26
- require('../common/closeButton/CloseButton.messages.js');
27
- var jsxRuntime = require('react/jsx-runtime');
28
- var ProcessIndicator = require('../processIndicator/ProcessIndicator.js');
29
- var Button_messages = require('../i18n/commonMessages/Button.messages.js');
30
- var classMap = require('./classMap.js');
31
- var legacyUtils = require('./legacyUtils/legacyUtils.js');
32
-
33
- const LegacyButton = /*#__PURE__*/React.forwardRef(({
34
- as: component = 'button',
35
- block = false,
36
- children,
37
- className,
38
- disabled,
39
- loading = false,
40
- priority = control.Priority.PRIMARY,
41
- size: size$1 = size.Size.MEDIUM,
42
- type = control.ControlType.ACCENT,
43
- onClick,
44
- ...rest
45
- }, ref) => {
46
- const intl = reactIntl.useIntl();
47
- legacyUtils.logDeprecationNotices({
48
- size: size$1,
49
- type
50
- });
51
- const newType = legacyUtils.establishNewType(type);
52
- const newPriority = legacyUtils.establishNewPriority(priority, type);
53
- const classes = clsx.clsx(`btn btn-${size$1}`, `np-btn np-btn-${size$1}`, {
54
- 'btn-loading': loading,
55
- 'btn-block np-btn-block': block,
56
- disabled
57
- },
58
- // @ts-expect-error fix when refactor `typeClassMap` to TypeScript
59
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
60
- classMap.typeClassMap[newType],
61
- // @ts-expect-error fix when refactor `typeClassMap` to TypeScript
62
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
63
- classMap.priorityClassMap[newPriority], className);
64
- function processIndicatorSize() {
65
- return ['sm', 'xs'].includes(size$1) ? 'xxs' : 'xs';
66
- }
67
- const Element = component ?? 'button';
68
- let props;
69
- if (Element === 'button') {
70
- const {
71
- htmlType = 'button',
72
- ...restProps
73
- } = rest;
74
- props = {
75
- ...restProps,
76
- disabled,
77
- 'aria-disabled': loading,
78
- type: htmlType
79
- };
80
- } else {
81
- props = {
82
- ...rest,
83
- 'aria-disabled': loading
84
- };
85
- }
86
- /**
87
- * Ensures that the button cannot be activated in loading or disabled mode,
88
- * when `aria-disabled` might be used over the `disabled` HTML attribute
89
- */
90
- const handleClick = handler => event => {
91
- if (disabled || loading) {
92
- event.preventDefault();
93
- } else if (typeof handler === 'function') {
94
- handler(event);
95
- }
96
- };
97
- return /*#__PURE__*/jsxRuntime.jsxs(Element, {
98
- ref: ref,
99
- className: classes,
100
- onClick: handleClick(onClick),
101
- ...props,
102
- "aria-live": loading ? 'polite' : 'off',
103
- "aria-busy": loading,
104
- "aria-label": loading ? intl.formatMessage(Button_messages.loadingAriaLabel) : rest['aria-label'],
105
- children: [children, loading && /*#__PURE__*/jsxRuntime.jsx(ProcessIndicator, {
106
- size: processIndicatorSize(),
107
- className: "btn-loader",
108
- "data-testid": "ButtonProgressIndicator"
109
- })]
110
- });
111
- });
112
-
113
- module.exports = LegacyButton;
114
- //# sourceMappingURL=LegacyButton.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LegacyButton.js","sources":["../../src/button/LegacyButton.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { ElementType, forwardRef, MouseEvent } from 'react';\nimport { useIntl } from 'react-intl';\n\nimport {\n Size,\n ControlType,\n Priority,\n ControlTypeAccent,\n ControlTypeNegative,\n ControlTypePositive,\n PriorityPrimary,\n PrioritySecondary,\n PriorityTertiary,\n SizeExtraSmall,\n SizeSmall,\n SizeMedium,\n SizeLarge,\n} from '../common';\nimport ProcessIndicator from '../processIndicator';\n\nimport messages from '../i18n/commonMessages/Button.messages';\nimport { typeClassMap, priorityClassMap } from './classMap';\nimport { establishNewPriority, establishNewType, logDeprecationNotices } from './legacyUtils';\nimport { ButtonReferenceType } from './Button.types';\n\n/** @deprecated */\ntype DeprecatedTypes = 'primary' | 'pay' | 'secondary' | 'danger' | 'link';\n\n/** @deprecated */\ntype DeprecatedSizes = SizeExtraSmall;\n\ntype CommonProps = {\n v2?: false;\n\n /** Makes the button take up the full width of its container */\n block?: boolean;\n\n /**\n * The `target` attribute for HTML anchor.\n * If set to `_blank`, `rel=\"noopener noreferrer\"` is automatically added to the rendered node.\n */\n target?: string;\n /**\n * Toggles the disabled state\n * @default false\n */\n\n disabled?: boolean;\n /**\n * Toggles the loading state\n * @default false\n */\n loading?: boolean;\n type?: ControlTypeAccent | ControlTypeNegative | ControlTypePositive | DeprecatedTypes | null;\n priority?: PriorityPrimary | PrioritySecondary | PriorityTertiary | null;\n size?: SizeSmall | SizeMedium | SizeLarge | DeprecatedSizes;\n htmlType?: 'submit' | 'reset' | 'button';\n};\n\ntype ButtonProps = CommonProps &\n Omit<React.ComponentPropsWithRef<'button'>, 'type'> & {\n as?: 'button';\n };\n\ntype AnchorProps = CommonProps &\n Omit<React.ComponentPropsWithRef<'a'>, 'type'> & {\n as?: 'a';\n href?: string;\n };\n\nexport type LegacyButtonProps = ButtonProps | AnchorProps;\n\n/**\n * @deprecated make sure you use new Button component via `<Button v2 .. />` and new props\n */\nconst LegacyButton = forwardRef<ButtonReferenceType, LegacyButtonProps>(\n (\n {\n as: component = 'button',\n block = false,\n children,\n className,\n disabled,\n loading = false,\n priority = Priority.PRIMARY,\n size = Size.MEDIUM,\n type = ControlType.ACCENT,\n onClick,\n ...rest\n }: LegacyButtonProps,\n ref,\n ) => {\n const intl = useIntl();\n\n logDeprecationNotices({ size, type });\n\n const newType = establishNewType(type);\n const newPriority = establishNewPriority(priority, type);\n\n const classes = clsx(\n `btn btn-${size}`,\n `np-btn np-btn-${size}`,\n {\n 'btn-loading': loading,\n 'btn-block np-btn-block': block,\n disabled,\n },\n // @ts-expect-error fix when refactor `typeClassMap` to TypeScript\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n typeClassMap[newType],\n // @ts-expect-error fix when refactor `typeClassMap` to TypeScript\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n priorityClassMap[newPriority],\n className,\n );\n\n function processIndicatorSize() {\n return ['sm', 'xs'].includes(size) ? 'xxs' : 'xs';\n }\n\n const Element = (component as ElementType) ?? 'button';\n let props;\n\n if (Element === 'button') {\n const { htmlType = 'button', ...restProps } = rest as ButtonProps;\n props = {\n ...restProps,\n disabled,\n 'aria-disabled': loading,\n type: htmlType,\n };\n } else {\n props = {\n ...rest,\n 'aria-disabled': loading,\n } as AnchorProps;\n }\n\n /**\n * Ensures that the button cannot be activated in loading or disabled mode,\n * when `aria-disabled` might be used over the `disabled` HTML attribute\n */\n const handleClick =\n (handler: LegacyButtonProps['onClick']) =>\n (event: MouseEvent<HTMLButtonElement> & MouseEvent<HTMLAnchorElement>) => {\n if (disabled || loading) {\n event.preventDefault();\n } else if (typeof handler === 'function') {\n handler(event);\n }\n };\n\n return (\n <Element\n ref={ref as React.Ref<ButtonReferenceType>}\n className={classes}\n onClick={handleClick(onClick)}\n {...props}\n aria-live={loading ? 'polite' : 'off'}\n aria-busy={loading}\n aria-label={loading ? intl.formatMessage(messages.loadingAriaLabel) : rest['aria-label']}\n >\n {children}\n {loading && (\n <ProcessIndicator\n size={processIndicatorSize()}\n className=\"btn-loader\"\n data-testid=\"ButtonProgressIndicator\"\n />\n )}\n </Element>\n );\n },\n);\n\nexport default LegacyButton;\n"],"names":["LegacyButton","forwardRef","as","component","block","children","className","disabled","loading","priority","Priority","PRIMARY","size","Size","MEDIUM","type","ControlType","ACCENT","onClick","rest","ref","intl","useIntl","logDeprecationNotices","newType","establishNewType","newPriority","establishNewPriority","classes","clsx","typeClassMap","priorityClassMap","processIndicatorSize","includes","Element","props","htmlType","restProps","handleClick","handler","event","preventDefault","_jsxs","formatMessage","messages","loadingAriaLabel","_jsx","ProcessIndicator"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4EA,MAAMA,YAAY,gBAAGC,gBAAU,CAC7B,CACE;EACEC,EAAE,EAAEC,SAAS,GAAG,QAAQ;AACxBC,EAAAA,KAAK,GAAG,KAAK;EACbC,QAAQ;EACRC,SAAS;EACTC,QAAQ;AACRC,EAAAA,OAAO,GAAG,KAAK;EACfC,QAAQ,GAAGC,gBAAQ,CAACC,OAAO;QAC3BC,MAAI,GAAGC,SAAI,CAACC,MAAM;EAClBC,IAAI,GAAGC,mBAAW,CAACC,MAAM;EACzBC,OAAO;EACP,GAAGC,IAAAA;AACe,CAAA,EACpBC,GAAG,KACD;AACF,EAAA,MAAMC,IAAI,GAAGC,iBAAO,EAAE,CAAA;AAEtBC,EAAAA,iCAAqB,CAAC;UAAEX,MAAI;AAAEG,IAAAA,IAAAA;AAAI,GAAE,CAAC,CAAA;AAErC,EAAA,MAAMS,OAAO,GAAGC,4BAAgB,CAACV,IAAI,CAAC,CAAA;AACtC,EAAA,MAAMW,WAAW,GAAGC,gCAAoB,CAAClB,QAAQ,EAAEM,IAAI,CAAC,CAAA;EAExD,MAAMa,OAAO,GAAGC,SAAI,CAClB,CAAA,QAAA,EAAWjB,MAAI,CAAA,CAAE,EACjB,CAAA,cAAA,EAAiBA,MAAI,CAAA,CAAE,EACvB;AACE,IAAA,aAAa,EAAEJ,OAAO;AACtB,IAAA,wBAAwB,EAAEJ,KAAK;AAC/BG,IAAAA,QAAAA;GACD;AACD;AACA;EACAuB,qBAAY,CAACN,OAAO,CAAC;AACrB;AACA;AACAO,EAAAA,yBAAgB,CAACL,WAAW,CAAC,EAC7BpB,SAAS,CACV,CAAA;EAED,SAAS0B,oBAAoBA,GAAA;AAC3B,IAAA,OAA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