@zohodesk/components 1.0.0-temp-260 → 1.0.0-temp-259.3

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 (41) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/assets/Appearance/dark/mode/Component_v1_DarkMode.module.css +5 -20
  3. package/assets/Appearance/light/mode/Component_v1_LightMode.module.css +5 -20
  4. package/assets/Appearance/pureDark/mode/Component_v1_PureDarkMode.module.css +5 -20
  5. package/es/v1/Button/Button.js +160 -107
  6. package/es/v1/Button/README.md +106 -42
  7. package/es/v1/Button/__tests__/Button.spec.js +138 -47
  8. package/es/v1/Button/__tests__/__snapshots__/Button.spec.js.snap +1105 -332
  9. package/es/v1/Button/constants/index.js +26 -20
  10. package/es/v1/Button/constants/presets.js +149 -0
  11. package/es/v1/Button/css/Button_v1.module.css +33 -16
  12. package/es/v1/Button/css/cssJSLogic.js +56 -28
  13. package/es/v1/Button/props/defaultProps.js +2 -6
  14. package/es/v1/Button/props/propTypes.js +26 -8
  15. package/es/v1/helpers/colorHelpers/__tests__/colorHelper.spec.js +357 -0
  16. package/es/v1/helpers/colorHelpers/background/backgroundColor.module.css +40 -40
  17. package/es/v1/helpers/colorHelpers/border/borderColor.module.css +25 -25
  18. package/es/v1/helpers/colorHelpers/colorHelper.js +117 -139
  19. package/es/v1/helpers/colorHelpers/constants/index.js +45 -4
  20. package/es/v1/helpers/colorHelpers/index.js +0 -1
  21. package/es/v1/helpers/colorHelpers/text/textColor.module.css +35 -35
  22. package/lib/v1/Button/Button.js +179 -119
  23. package/lib/v1/Button/README.md +106 -42
  24. package/lib/v1/Button/__tests__/Button.spec.js +194 -87
  25. package/lib/v1/Button/__tests__/__snapshots__/Button.spec.js.snap +1105 -332
  26. package/lib/v1/Button/constants/index.js +31 -28
  27. package/lib/v1/Button/constants/presets.js +167 -0
  28. package/lib/v1/Button/css/Button_v1.module.css +33 -16
  29. package/lib/v1/Button/css/cssJSLogic.js +42 -19
  30. package/lib/v1/Button/props/defaultProps.js +1 -5
  31. package/lib/v1/Button/props/propTypes.js +41 -7
  32. package/lib/v1/helpers/colorHelpers/__tests__/colorHelper.spec.js +363 -0
  33. package/lib/v1/helpers/colorHelpers/background/backgroundColor.module.css +40 -40
  34. package/lib/v1/helpers/colorHelpers/border/borderColor.module.css +25 -25
  35. package/lib/v1/helpers/colorHelpers/colorHelper.js +127 -153
  36. package/lib/v1/helpers/colorHelpers/constants/index.js +45 -4
  37. package/lib/v1/helpers/colorHelpers/index.js +2 -24
  38. package/lib/v1/helpers/colorHelpers/text/textColor.module.css +35 -35
  39. package/package.json +4 -4
  40. package/es/AdvancedPopup/AdvancedPopup.js +0 -105
  41. package/lib/AdvancedPopup/AdvancedPopup.js +0 -122
@@ -18,14 +18,49 @@ import Button from '@zohodesk/components/es/v1/Button/Button';
18
18
  </Button>
19
19
  ```
20
20
 
21
- ### With Palette Variants
21
+ ### With Palette
22
22
 
23
23
  ```jsx
24
- <Button palette="primary">Save</Button>
24
+ <Button palette="brand">Save</Button>
25
25
  <Button palette="danger">Delete</Button>
26
26
  <Button palette="success">Confirm</Button>
27
27
  ```
28
28
 
29
+ ### With Appearance
30
+
31
+ `appearance`, `hoverAppearance`, and `selectedAppearance` are objects with optional `bg`, `border`, and `text` keys. Each key accepts `true` (use palette color), `false` (suppress), or a palette name string.
32
+
33
+ ```jsx
34
+ <Button palette="brand" appearance={{ bg: false, border: true }}>
35
+ Ghost
36
+ </Button>
37
+
38
+ <Button
39
+ palette="brand"
40
+ appearance={{ bg: false, border: true }}
41
+ hoverAppearance={{ bg: false, border: true }}
42
+ selectedAppearance={{ bg: false, border: true }}
43
+ >
44
+ Ghost with states
45
+ </Button>
46
+ ```
47
+
48
+ ### Using Presets
49
+
50
+ ```jsx
51
+ import {
52
+ BRAND_GHOST,
53
+ BRAND_TEXT_ONLY,
54
+ SECONDARY_GHOST_BRAND_TINTED_ONSELECT,
55
+ BRAND_TINTED_OUTLINE,
56
+ BRAND_TEXT_TINTED_HOVER
57
+ } from '@zohodesk/components/es/v1/Button/constants/presets';
58
+
59
+ <Button {...BRAND_GHOST}>Brand Ghost</Button>
60
+ <Button {...BRAND_TEXT_ONLY}>Brand Text Only</Button>
61
+ <Button {...SECONDARY_GHOST_BRAND_TINTED_ONSELECT}>Secondary Ghost</Button>
62
+ ```
63
+
29
64
  ### With Icon
30
65
 
31
66
  ```jsx
@@ -36,75 +71,104 @@ import Button from '@zohodesk/components/es/v1/Button/Button';
36
71
  </Button>
37
72
  ```
38
73
 
39
- ### Loading State
74
+ ### Loading / Success State
40
75
 
41
76
  ```jsx
42
- <Button status="loading" loaderPlacement="overlay">
43
- Saving...
44
- </Button>
45
-
46
- <Button status="loading" loaderPlacement="start">
47
- Loading
48
- </Button>
77
+ <Button status="loading" loaderPlacement="overlay">Saving...</Button>
78
+ <Button status="loading" loaderPlacement="start">Loading</Button>
79
+ <Button status="success">Done</Button>
49
80
  ```
50
81
 
51
- ### Disabled / Read Only
82
+ ### Disabled
52
83
 
53
84
  ```jsx
54
85
  <Button isDisabled>Disabled</Button>
55
- <Button isReadOnly>Read Only</Button>
86
+ <Button isDisabled disabledAppearance="strike">Disabled Strike</Button>
87
+ ```
88
+
89
+ ### Shape
90
+
91
+ ```jsx
92
+ <Button shape="pill">Pill</Button>
93
+ <Button shape="rectangle">Rectangle</Button>
94
+ <Button shape="roundedRectangle">Rounded</Button>
56
95
  ```
57
96
 
58
97
  ## Props
59
98
 
60
99
  | Prop | Type | Default | Description |
61
100
  |---|---|---|---|
62
- | `customId` | `string` | — | `data-id` attribute for automation |
63
- | `testId` | `string` | — | `data-test-id` attribute for testing |
64
- | `palette` | `oneOf: default, primary, secondary, danger, success` | `default` | Color palette |
65
- | `bgAppearance` | `oneOf: filled, onHover, none` | `filled` | Background behavior |
66
- | `borderAppearance` | `oneOf: default, onHover, none` | `default` | Border behavior |
101
+ | `palette` | `oneOf: brand, brandLighter, info, infoLighter, secondary, secondaryLighter, danger, dangerLighter, success, successLighter, warning, warningLighter` | `''` | Color palette |
102
+ | `appearance` | `{ bg?, border?, text? }` | `{ bg: true, text: true }` | Color treatments at rest. Values: `true`, `false`, or a palette name |
103
+ | `hoverAppearance` | `{ bg?, border?, text? }` | `{ bg: true, text: true }` | Color treatments on hover/focus/active |
104
+ | `selectedAppearance` | `{ bg?, border?, text? }` | `{ bg: true, text: true }` | Color treatments when `isSelected` is true |
67
105
  | `variant` | `oneOf: text, icon, iconWithText` | `text` | Display variant |
68
106
  | `size` | `oneOf: small, medium, large, full` | `medium` | Size variant |
69
107
  | `status` | `oneOf: default, loading, success` | `default` | Status state |
70
- | `loaderPlacement` | `oneOf: start, end, overlay` | `overlay` | Where loader appears |
108
+ | `loaderPlacement` | `oneOf: start, end, overlay` | `overlay` | Where the loader appears |
109
+ | `shape` | `oneOf: pill, rectangle, roundedRectangle` | `roundedRectangle` | Border shape |
71
110
  | `iconName` | `string` | — | Icon name from `@zohodesk/icons` |
72
111
  | `iconSize` | `number` | `16` | Icon size in pixels |
73
112
  | `iconPlacement` | `oneOf: left, right` | `left` | Icon position relative to text |
74
- | `paletteShade` | `oneOf: default, lighter` | `default` | Shade variant |
75
- | `disabledAppearance` | `oneOf: none, dull, strike` | `dull` | Disabled visual style |
113
+ | `disabledAppearance` | `oneOf: none, dull, strike` | `dull` | Visual style when disabled |
114
+ | `isDisabled` | `bool` | `false` | Disables the button |
115
+ | `isSelected` | `bool` | `false` | Selected/pressed state (`aria-pressed`) |
116
+ | `type` | `oneOf: button, submit, reset` | `button` | HTML button type |
117
+ | `onClick` | `func` | — | Click handler (suppressed when disabled or loading) |
118
+ | `title` | `string` | — | Tooltip / `data-title` attribute |
119
+ | `children` | `node` | — | Button label content |
76
120
  | `renderIcon` | `node \| func` | — | Custom icon render slot |
77
121
  | `renderBefore` | `node \| func` | — | Slot before main content |
78
122
  | `renderAfter` | `node \| func` | — | Slot after main content |
79
123
  | `renderLoader` | `node \| func` | — | Custom loader render slot |
80
124
  | `renderSuccess` | `node \| func` | — | Custom success render slot |
81
- | `children` | `node` | — | Button text content |
82
- | `type` | `oneOf: button, submit, reset` | `button` | HTML button type |
83
- | `onClick` | `func` | — | Click event handler |
84
- | `isDisabled` | `bool` | `false` | Disables the button |
85
- | `isReadOnly` | `bool` | `false` | Read-only state |
86
- | `isSelected` | `bool` | `false` | Selected/pressed state |
87
- | `isRounded` | `bool` | `false` | Rounded border radius |
88
- | `title` | `string` | — | Title/tooltip text |
125
+ | `customId` | `string` | — | `data-id` attribute |
126
+ | `testId` | `string` | — | `data-test-id` attribute |
127
+ | `dataSelectorId` | `string` | — | `data-selector-id` attribute |
128
+ | `a11yAttributes` | `object` | `{}` | Extra ARIA/accessibility attributes spread onto `<button>` |
129
+ | `customClass` | `{ wrapper?, text?, icon?, loader?, success? }` | `{}` | CSS class overrides per part |
130
+ | `customProps` | `{ text?, icon? }` | `{}` | Extra props forwarded to text/icon sub-elements |
131
+ | `customAttributes` | `{ button?, contentWrapper?, loader?, success?, icon?, text? }` | `{}` | Extra HTML attributes per internal element |
132
+
133
+ ## Presets
134
+
135
+ Ready-made palette + appearance combinations exported from `constants/presets`:
136
+
137
+ | Name | Palette | Appearance | Description |
138
+ |---|---|---|---|
139
+ | `BRAND_GHOST` | `brand` | `{ bg: false, border: true }` | Transparent bg, brand border |
140
+ | `BRAND_TEXT_ONLY` | `brand` | `{ bg: false }` | Text only, no border |
141
+ | `BRAND_TINTED_OUTLINE` | `brandLighter` | `{ border: true }` | Tinted fill, brand border |
142
+ | `SUCCESS_GHOST` | `success` | `{ bg: false, border: true }` | Transparent bg, success border |
143
+ | `SUCCESS_TEXT_ONLY` | `success` | `{ bg: false }` | Text only, no border |
144
+ | `SUCCESS_TINTED_OUTLINE` | `successLighter` | `{ border: true }` | Tinted fill, success border |
145
+ | `SECONDARY_GHOST_BRAND_TINTED_ONSELECT` | `secondary` | `{ bg: false, border: true }` | Secondary ghost; selected state switches to brand tint |
146
+ | `BLACK_TEXT_BRAND_ONHOVER` | `brand` | `{ bg: false, text: 'black' }` | Black text, brand color on hover |
147
+ | `BRAND_BG_ONSELECT` | `brand` | `{ bg: false, border: true }` | Ghost without a defined selected state |
148
+ | `BRAND_TEXT_TINTED_HOVER` | `brandLighter` | `{ bg: false }` | Ghost that becomes tinted on hover |
149
+ | `BRAND_TEXT_TINTED_DANGER_HOVER` | `brandLighter` | `{ bg: false }` | Ghost that becomes danger-tinted on hover |
89
150
 
90
151
  ## Customization
91
152
 
92
153
  ### Parts
93
154
 
94
- | Part | Element | Description |
155
+ | Part key | Element | Description |
95
156
  |---|---|---|
96
- | `wrapper` | `<button>` root | The outermost button element |
97
- | `text` | Typography | The text label |
98
-
99
- ### CSS Custom Properties
157
+ | `button` | `<button>` | Outermost button element |
158
+ | `contentWrapper` | Inner `<Flex>` | Wraps icon + text content |
159
+ | `text` | `<Typography>` | Text label |
160
+ | `icon` | `<Icon>` | Icon element |
161
+ | `loader` | `<Flex>` | Loader wrapper |
162
+ | `success` | `<Flex>` | Success tick wrapper |
100
163
 
101
- The `.varClass` block in `Button.module.css` defines local custom properties that size variants override:
164
+ Pass class overrides via `customClass`, extra props via `customProps`, or arbitrary HTML attributes via `customAttributes`.
102
165
 
103
- | Property | Default | Description |
104
- |---|---|---|
105
- | `--local-Button-radius` | `4px` | Border radius |
106
- | `--local-Button-gap` | `8px` | Content gap |
107
- | `--local-Button-padding-block` | `6px` | Block padding |
108
- | `--local-Button-padding-inline` | `15px` | Inline padding |
109
- | `--local-Button-min-width` | `90px` | Minimum width |
110
- | `--local-Button-spinner-size` | `16px` | Spinner/tick size |
166
+ ```jsx
167
+ <Button
168
+ customClass={{ wrapper: 'myBtn', text: 'myBtnText' }}
169
+ customAttributes={{ button: { 'data-analytics': 'save' } }}
170
+ a11yAttributes={{ 'aria-label': 'Save document' }}
171
+ >
172
+ Save
173
+ </Button>
174
+ ```
@@ -1,12 +1,16 @@
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
1
3
  import React from 'react';
2
- import { cleanup, render, screen } from '@testing-library/react';
4
+ import { cleanup, render } from '@testing-library/react';
3
5
  import userEvent from '@testing-library/user-event';
4
- import Button from "../Button";
6
+ import Button from "../index";
5
7
  import '@testing-library/jest-dom';
8
+ import { PALETTE, VARIANT, SIZE, STATUS, LOADER_PLACEMENT, SHAPE, DISABLED_APPEARANCE, BUTTON_TYPE } from "../constants";
9
+ import { BRAND_GHOST, BRAND_TEXT_ONLY, BRAND_TINTED_OUTLINE, SUCCESS_GHOST, SUCCESS_TEXT_ONLY, SUCCESS_TINTED_OUTLINE, SECONDARY_GHOST_BRAND_TINTED_ONSELECT, BLACK_TEXT_BRAND_ONHOVER, BRAND_BG_ONSELECT, BRAND_TEXT_TINTED_HOVER, BRAND_TEXT_TINTED_DANGER_HOVER } from "../constants/presets";
6
10
  afterEach(() => {
7
11
  cleanup();
8
12
  });
9
- describe('Button - Component', () => {
13
+ describe('Button', () => {
10
14
  test('Should render with the basic set of default props', () => {
11
15
  const {
12
16
  asFragment
@@ -19,8 +23,7 @@ describe('Button - Component', () => {
19
23
  } = render( /*#__PURE__*/React.createElement(Button, null, "Click Me"));
20
24
  expect(asFragment()).toMatchSnapshot();
21
25
  });
22
- const palette = ['default', 'primary', 'secondary', 'danger', 'success'];
23
- test.each(palette)('Should render palette of buttons - %s', palette => {
26
+ test.each(Object.values(PALETTE))('Should render palette of buttons - %s', palette => {
24
27
  const {
25
28
  asFragment
26
29
  } = render( /*#__PURE__*/React.createElement(Button, {
@@ -28,26 +31,46 @@ describe('Button - Component', () => {
28
31
  }));
29
32
  expect(asFragment()).toMatchSnapshot();
30
33
  });
31
- const bgAppearance = ['default', 'onHover', 'none'];
32
- test.each(bgAppearance)('Should render bgAppearance of buttons - %s', bg => {
34
+ const appearanceCombos = [{
35
+ bg: true,
36
+ text: 'black'
37
+ }, {
38
+ border: true
39
+ }, {
40
+ text: true
41
+ }, {
42
+ bg: false,
43
+ border: true
44
+ }, {}];
45
+ test.each(appearanceCombos.map(combo => [combo]))('Should render appearance of buttons - %o', appearance => {
33
46
  const {
34
47
  asFragment
35
48
  } = render( /*#__PURE__*/React.createElement(Button, {
36
- bgAppearance: bg
49
+ palette: PALETTE.BRAND,
50
+ appearance: appearance
37
51
  }));
38
52
  expect(asFragment()).toMatchSnapshot();
39
53
  });
40
- const borderAppearance = ['default', 'onHover', 'none'];
41
- test.each(borderAppearance)('Should render borderAppearance of buttons - %s', border => {
54
+ test.each(appearanceCombos.map(combo => [combo]))('Should render hoverAppearance of buttons - %o', appearance => {
42
55
  const {
43
56
  asFragment
44
57
  } = render( /*#__PURE__*/React.createElement(Button, {
45
- borderAppearance: border
58
+ palette: PALETTE.BRAND,
59
+ hoverAppearance: appearance
46
60
  }));
47
61
  expect(asFragment()).toMatchSnapshot();
48
62
  });
49
- const variant = ['text', 'icon', 'iconWithText'];
50
- test.each(variant)('Should render variant of buttons - %s', variant => {
63
+ test.each(appearanceCombos.map(combo => [combo]))('Should render selectedAppearance of buttons - %o', appearance => {
64
+ const {
65
+ asFragment
66
+ } = render( /*#__PURE__*/React.createElement(Button, {
67
+ palette: PALETTE.BRAND,
68
+ isSelected: true,
69
+ selectedAppearance: appearance
70
+ }));
71
+ expect(asFragment()).toMatchSnapshot();
72
+ });
73
+ test.each(Object.values(VARIANT))('Should render variant of buttons - %s', variant => {
51
74
  const {
52
75
  asFragment
53
76
  } = render( /*#__PURE__*/React.createElement(Button, {
@@ -55,8 +78,7 @@ describe('Button - Component', () => {
55
78
  }));
56
79
  expect(asFragment()).toMatchSnapshot();
57
80
  });
58
- const size = ['small', 'medium', 'large', 'full'];
59
- test.each(size)('Should render Sizes of buttons - %s', size => {
81
+ test.each(Object.values(SIZE))('Should render Sizes of buttons - %s', size => {
60
82
  const {
61
83
  asFragment
62
84
  } = render( /*#__PURE__*/React.createElement(Button, {
@@ -64,8 +86,7 @@ describe('Button - Component', () => {
64
86
  }));
65
87
  expect(asFragment()).toMatchSnapshot();
66
88
  });
67
- const status = ['default', 'loading', 'success'];
68
- test.each(status)('Should render Status of buttons - %s', status => {
89
+ test.each(Object.values(STATUS))('Should render Status of buttons - %s', status => {
69
90
  const {
70
91
  asFragment
71
92
  } = render( /*#__PURE__*/React.createElement(Button, {
@@ -73,8 +94,7 @@ describe('Button - Component', () => {
73
94
  }));
74
95
  expect(asFragment()).toMatchSnapshot();
75
96
  });
76
- const loaderPlacement = ['start', 'end', 'overlay'];
77
- test.each(loaderPlacement)('Should render loaderPlacement of buttons - %s', loaderPlacement => {
97
+ test.each(Object.values(LOADER_PLACEMENT))('Should render loaderPlacement of buttons - %s', loaderPlacement => {
78
98
  const {
79
99
  asFragment
80
100
  } = render( /*#__PURE__*/React.createElement(Button, {
@@ -83,7 +103,7 @@ describe('Button - Component', () => {
83
103
  }));
84
104
  expect(asFragment()).toMatchSnapshot();
85
105
  });
86
- test('Should render with iconName and iconSize ', () => {
106
+ test('Should render with iconName and iconSize', () => {
87
107
  const {
88
108
  asFragment
89
109
  } = render( /*#__PURE__*/React.createElement(Button, {
@@ -93,7 +113,7 @@ describe('Button - Component', () => {
93
113
  }));
94
114
  expect(asFragment()).toMatchSnapshot();
95
115
  });
96
- test('Should render with iconPlacement ', () => {
116
+ test('Should render with iconPlacement', () => {
97
117
  const {
98
118
  asFragment
99
119
  } = render( /*#__PURE__*/React.createElement(Button, {
@@ -139,8 +159,7 @@ describe('Button - Component', () => {
139
159
  }));
140
160
  expect(asFragment()).toMatchSnapshot();
141
161
  });
142
- const type = ['button', 'submit', 'reset'];
143
- test.each(type)('Should render type of buttons - %s', type => {
162
+ test.each(Object.values(BUTTON_TYPE))('Should render type of buttons - %s', type => {
144
163
  const {
145
164
  asFragment
146
165
  } = render( /*#__PURE__*/React.createElement(Button, {
@@ -166,14 +185,6 @@ describe('Button - Component', () => {
166
185
  }));
167
186
  expect(asFragment()).toMatchSnapshot();
168
187
  });
169
- test('Should render with readOnly style when isReadOnly prop is true', () => {
170
- const {
171
- asFragment
172
- } = render( /*#__PURE__*/React.createElement(Button, {
173
- isReadOnly: true
174
- }));
175
- expect(asFragment()).toMatchSnapshot();
176
- });
177
188
  test('Should render with selected style when isSelected prop is true', () => {
178
189
  const {
179
190
  asFragment
@@ -182,8 +193,7 @@ describe('Button - Component', () => {
182
193
  }));
183
194
  expect(asFragment()).toMatchSnapshot();
184
195
  });
185
- const shape = ['pill', 'rectangle', 'roundedRectangle'];
186
- test.each(shape)('Should render shape of buttons - %s', shape => {
196
+ test.each(Object.values(SHAPE))('Should render shape of buttons - %s', shape => {
187
197
  const {
188
198
  asFragment
189
199
  } = render( /*#__PURE__*/React.createElement(Button, {
@@ -191,17 +201,7 @@ describe('Button - Component', () => {
191
201
  }));
192
202
  expect(asFragment()).toMatchSnapshot();
193
203
  });
194
- const paletteShade = ['default', 'lighter'];
195
- test.each(paletteShade)('Should render paletteShade of buttons - %s', shade => {
196
- const {
197
- asFragment
198
- } = render( /*#__PURE__*/React.createElement(Button, {
199
- paletteShade: shade
200
- }));
201
- expect(asFragment()).toMatchSnapshot();
202
- });
203
- const disabledAppearance = ['none', 'dull', 'strike'];
204
- test.each(disabledAppearance)('Should render disabledAppearance of buttons - %s', style => {
204
+ test.each(Object.values(DISABLED_APPEARANCE))('Should render disabledAppearance of buttons - %s', style => {
205
205
  const {
206
206
  asFragment
207
207
  } = render( /*#__PURE__*/React.createElement(Button, {
@@ -239,9 +239,6 @@ describe('Button - Component', () => {
239
239
  variant: "iconWithText",
240
240
  iconName: "check",
241
241
  customProps: {
242
- wrapper: {
243
- 'data-wrapper': 'wrapperProps'
244
- },
245
242
  text: {
246
243
  'data-text': 'textProps'
247
244
  },
@@ -252,6 +249,21 @@ describe('Button - Component', () => {
252
249
  }, "Button"));
253
250
  expect(asFragment()).toMatchSnapshot();
254
251
  });
252
+ test('Should apply customAttributes to button elements', () => {
253
+ const {
254
+ asFragment
255
+ } = render( /*#__PURE__*/React.createElement(Button, {
256
+ customAttributes: {
257
+ button: {
258
+ 'data-wrapper': 'wrapperAttr'
259
+ },
260
+ text: {
261
+ 'data-text': 'textAttr'
262
+ }
263
+ }
264
+ }, "Button"));
265
+ expect(asFragment()).toMatchSnapshot();
266
+ });
255
267
  test('Should render with customId and testId', () => {
256
268
  const {
257
269
  asFragment
@@ -272,4 +284,83 @@ describe('Button - Component', () => {
272
284
  }, "Button"));
273
285
  expect(asFragment()).toMatchSnapshot();
274
286
  });
287
+ test('Should render renderBefore slot content in DOM', () => {
288
+ const {
289
+ getByText
290
+ } = render( /*#__PURE__*/React.createElement(Button, {
291
+ renderBefore: () => /*#__PURE__*/React.createElement("span", null, "BeforeSlot")
292
+ }, "Button"));
293
+ expect(getByText('BeforeSlot')).toBeInTheDocument();
294
+ });
295
+ test('Should render renderAfter slot content in DOM', () => {
296
+ const {
297
+ getByText
298
+ } = render( /*#__PURE__*/React.createElement(Button, {
299
+ renderAfter: () => /*#__PURE__*/React.createElement("span", null, "AfterSlot")
300
+ }, "Button"));
301
+ expect(getByText('AfterSlot')).toBeInTheDocument();
302
+ });
303
+ test('Should render renderIcon slot content in DOM', () => {
304
+ const {
305
+ getByText
306
+ } = render( /*#__PURE__*/React.createElement(Button, {
307
+ variant: "icon",
308
+ renderIcon: () => /*#__PURE__*/React.createElement("span", null, "IconSlot")
309
+ }));
310
+ expect(getByText('IconSlot')).toBeInTheDocument();
311
+ });
312
+ test('Should not call onClick when button is disabled', () => {
313
+ const onClick = jest.fn();
314
+ const {
315
+ getByRole
316
+ } = render( /*#__PURE__*/React.createElement(Button, {
317
+ isDisabled: true,
318
+ onClick: onClick
319
+ }));
320
+ userEvent.click(getByRole('button'));
321
+ expect(onClick).not.toHaveBeenCalled();
322
+ });
323
+ test('Should render loader overlay when status is loading and loaderPlacement is overlay', () => {
324
+ const {
325
+ asFragment
326
+ } = render( /*#__PURE__*/React.createElement(Button, {
327
+ status: "loading",
328
+ loaderPlacement: "overlay"
329
+ }));
330
+ expect(asFragment()).toMatchSnapshot();
331
+ });
332
+ test('Should render success overlay when status is success and loaderPlacement is overlay', () => {
333
+ const {
334
+ asFragment
335
+ } = render( /*#__PURE__*/React.createElement(Button, {
336
+ status: "success",
337
+ loaderPlacement: "overlay"
338
+ }));
339
+ expect(asFragment()).toMatchSnapshot();
340
+ });
341
+ test('Should render with dataSelectorId', () => {
342
+ const {
343
+ asFragment
344
+ } = render( /*#__PURE__*/React.createElement(Button, {
345
+ dataSelectorId: "selectorId"
346
+ }));
347
+ expect(asFragment()).toMatchSnapshot();
348
+ });
349
+ describe('Presets', () => {
350
+ const presets = [['BRAND_GHOST', BRAND_GHOST], ['BRAND_TEXT_ONLY', BRAND_TEXT_ONLY], ['BRAND_TINTED_OUTLINE', BRAND_TINTED_OUTLINE], ['SUCCESS_GHOST', SUCCESS_GHOST], ['SUCCESS_TEXT_ONLY', SUCCESS_TEXT_ONLY], ['SUCCESS_TINTED_OUTLINE', SUCCESS_TINTED_OUTLINE], ['SECONDARY_GHOST_BRAND_TINTED_ONSELECT', SECONDARY_GHOST_BRAND_TINTED_ONSELECT], ['BLACK_TEXT_BRAND_ONHOVER', BLACK_TEXT_BRAND_ONHOVER], ['BRAND_BG_ONSELECT', BRAND_BG_ONSELECT], ['BRAND_TEXT_TINTED_HOVER', BRAND_TEXT_TINTED_HOVER], ['BRAND_TEXT_TINTED_DANGER_HOVER', BRAND_TEXT_TINTED_DANGER_HOVER]];
351
+ test.each(presets)('Should render preset %s', (_name, preset) => {
352
+ const {
353
+ asFragment
354
+ } = render( /*#__PURE__*/React.createElement(Button, preset, "Button"));
355
+ expect(asFragment()).toMatchSnapshot();
356
+ });
357
+ test.each(presets)('Should render preset %s in selected state', (_name, preset) => {
358
+ const {
359
+ asFragment
360
+ } = render( /*#__PURE__*/React.createElement(Button, _extends({}, preset, {
361
+ isSelected: true
362
+ }), "Button"));
363
+ expect(asFragment()).toMatchSnapshot();
364
+ });
365
+ });
275
366
  });