@instructure/ui-buttons 10.16.1-snapshot-0 → 10.16.1
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.
- package/CHANGELOG.md +1 -1
- package/es/BaseButton/__new-tests__/BaseButton.test.js +123 -86
- package/es/BaseButton/index.js +33 -26
- package/es/Button/__new-tests__/Button.test.js +145 -105
- package/es/Button/index.js +6 -2
- package/es/CloseButton/__new-tests__/CloseButton.test.js +3 -3
- package/es/CloseButton/index.js +25 -20
- package/es/CondensedButton/__new-tests__/CondensedButton.test.js +60 -45
- package/es/CondensedButton/index.js +7 -4
- package/es/IconButton/__new-tests__/IconButton.test.js +25 -23
- package/es/IconButton/index.js +9 -4
- package/es/ToggleButton/__new-tests__/ToggleButton.test.js +19 -18
- package/es/ToggleButton/index.js +19 -15
- package/lib/BaseButton/__new-tests__/BaseButton.test.js +159 -122
- package/lib/BaseButton/index.js +32 -26
- package/lib/Button/__new-tests__/Button.test.js +187 -147
- package/lib/Button/index.js +6 -3
- package/lib/CloseButton/__new-tests__/CloseButton.test.js +7 -7
- package/lib/CloseButton/index.js +24 -19
- package/lib/CondensedButton/__new-tests__/CondensedButton.test.js +73 -58
- package/lib/CondensedButton/index.js +7 -5
- package/lib/IconButton/__new-tests__/IconButton.test.js +39 -37
- package/lib/IconButton/index.js +9 -5
- package/lib/ToggleButton/__new-tests__/ToggleButton.test.js +31 -30
- package/lib/ToggleButton/index.js +19 -16
- package/package.json +20 -20
- package/src/BaseButton/__new-tests__/BaseButton.test.tsx +0 -1
- package/src/BaseButton/index.tsx +2 -3
- package/src/Button/__new-tests__/Button.test.tsx +0 -1
- package/src/Button/index.tsx +1 -1
- package/src/CloseButton/__new-tests__/CloseButton.test.tsx +0 -1
- package/src/CloseButton/index.tsx +1 -2
- package/src/CondensedButton/__new-tests__/CondensedButton.test.tsx +0 -1
- package/src/CondensedButton/index.tsx +1 -1
- package/src/IconButton/__new-tests__/IconButton.test.tsx +0 -1
- package/src/IconButton/index.tsx +1 -1
- package/src/IconButton/props.ts +1 -1
- package/src/ToggleButton/__new-tests__/ToggleButton.test.tsx +0 -1
- package/src/ToggleButton/index.tsx +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/BaseButton/__new-tests__/BaseButton.test.d.ts.map +1 -1
- package/types/BaseButton/index.d.ts +4 -6
- package/types/BaseButton/index.d.ts.map +1 -1
- package/types/Button/__new-tests__/Button.test.d.ts.map +1 -1
- package/types/Button/index.d.ts +2 -2
- package/types/Button/index.d.ts.map +1 -1
- package/types/CloseButton/__new-tests__/CloseButton.test.d.ts.map +1 -1
- package/types/CloseButton/index.d.ts +1 -3
- package/types/CloseButton/index.d.ts.map +1 -1
- package/types/CondensedButton/__new-tests__/CondensedButton.test.d.ts.map +1 -1
- package/types/CondensedButton/index.d.ts +2 -2
- package/types/CondensedButton/index.d.ts.map +1 -1
- package/types/IconButton/__new-tests__/IconButton.test.d.ts.map +1 -1
- package/types/IconButton/index.d.ts +4 -4
- package/types/IconButton/index.d.ts.map +1 -1
- package/types/IconButton/props.d.ts +1 -1
- package/types/IconButton/props.d.ts.map +1 -1
- package/types/ToggleButton/__new-tests__/ToggleButton.test.d.ts.map +1 -1
- package/types/ToggleButton/index.d.ts +2 -2
- package/types/ToggleButton/index.d.ts.map +1 -1
|
@@ -23,30 +23,33 @@ var _circle, _CondensedButton, _CondensedButton2, _CondensedButton3, _CondensedB
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
import React from 'react';
|
|
27
26
|
import { render, screen, waitFor } from '@testing-library/react';
|
|
28
27
|
import { vi } from 'vitest';
|
|
29
28
|
import userEvent from '@testing-library/user-event';
|
|
30
29
|
import '@testing-library/jest-dom';
|
|
31
30
|
import { CondensedButton } from '../index';
|
|
31
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
32
32
|
describe('<CondensedButton/>', () => {
|
|
33
33
|
var _CondensedButton8;
|
|
34
|
-
const icon =
|
|
34
|
+
const icon = _jsx("svg", {
|
|
35
35
|
"data-title": "myIcon",
|
|
36
36
|
height: "1em",
|
|
37
37
|
width: "1em",
|
|
38
38
|
style: {
|
|
39
39
|
fill: 'currentcolor'
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
},
|
|
41
|
+
children: _circle || (_circle = _jsx("circle", {
|
|
42
|
+
cx: "0.5em",
|
|
43
|
+
cy: "0.5em",
|
|
44
|
+
r: "0.5em"
|
|
45
|
+
}))
|
|
46
|
+
});
|
|
46
47
|
const iconSelector = 'svg[data-title="myIcon"]';
|
|
47
48
|
it('should render children', () => {
|
|
48
49
|
const children = 'Hello world';
|
|
49
|
-
render(
|
|
50
|
+
render(_jsx(CondensedButton, {
|
|
51
|
+
children: children
|
|
52
|
+
}));
|
|
50
53
|
const button = document.querySelector('button');
|
|
51
54
|
expect(button).toBeInTheDocument();
|
|
52
55
|
expect(button).toHaveTextContent(children);
|
|
@@ -54,11 +57,12 @@ describe('<CondensedButton/>', () => {
|
|
|
54
57
|
it('should provide a focused getter', () => {
|
|
55
58
|
var _componentRef;
|
|
56
59
|
let componentRef;
|
|
57
|
-
render(
|
|
60
|
+
render(_jsx(CondensedButton, {
|
|
58
61
|
ref: component => {
|
|
59
62
|
componentRef = component;
|
|
60
|
-
}
|
|
61
|
-
|
|
63
|
+
},
|
|
64
|
+
children: "Hello"
|
|
65
|
+
}));
|
|
62
66
|
const button = screen.getByRole('button', {
|
|
63
67
|
name: 'Hello'
|
|
64
68
|
});
|
|
@@ -68,11 +72,12 @@ describe('<CondensedButton/>', () => {
|
|
|
68
72
|
it('should provide a focus function', () => {
|
|
69
73
|
var _componentRef2;
|
|
70
74
|
let componentRef;
|
|
71
|
-
render(
|
|
75
|
+
render(_jsx(CondensedButton, {
|
|
72
76
|
ref: component => {
|
|
73
77
|
componentRef = component;
|
|
74
|
-
}
|
|
75
|
-
|
|
78
|
+
},
|
|
79
|
+
children: "Hello"
|
|
80
|
+
}));
|
|
76
81
|
const button = screen.getByRole('button', {
|
|
77
82
|
name: 'Hello'
|
|
78
83
|
});
|
|
@@ -80,9 +85,10 @@ describe('<CondensedButton/>', () => {
|
|
|
80
85
|
expect(document.activeElement).toBe(button);
|
|
81
86
|
});
|
|
82
87
|
it('should pass the type attribute', () => {
|
|
83
|
-
render(_CondensedButton || (_CondensedButton =
|
|
84
|
-
type: "submit"
|
|
85
|
-
|
|
88
|
+
render(_CondensedButton || (_CondensedButton = _jsx(CondensedButton, {
|
|
89
|
+
type: "submit",
|
|
90
|
+
children: "Hello"
|
|
91
|
+
})));
|
|
86
92
|
const button = screen.getByRole('button', {
|
|
87
93
|
name: 'Hello'
|
|
88
94
|
});
|
|
@@ -91,18 +97,20 @@ describe('<CondensedButton/>', () => {
|
|
|
91
97
|
});
|
|
92
98
|
it('should pass the `elementRef` prop', async () => {
|
|
93
99
|
const elementRef = vi.fn();
|
|
94
|
-
render(
|
|
95
|
-
elementRef: elementRef
|
|
96
|
-
|
|
100
|
+
render(_jsx(CondensedButton, {
|
|
101
|
+
elementRef: elementRef,
|
|
102
|
+
children: "Hello"
|
|
103
|
+
}));
|
|
97
104
|
const button = screen.getByRole('button', {
|
|
98
105
|
name: 'Hello'
|
|
99
106
|
});
|
|
100
107
|
expect(elementRef).toHaveBeenCalledWith(button);
|
|
101
108
|
});
|
|
102
109
|
it('should pass the `as` prop', () => {
|
|
103
|
-
const _render = render(_CondensedButton2 || (_CondensedButton2 =
|
|
104
|
-
as: "li"
|
|
105
|
-
|
|
110
|
+
const _render = render(_CondensedButton2 || (_CondensedButton2 = _jsx(CondensedButton, {
|
|
111
|
+
as: "li",
|
|
112
|
+
children: "Hello"
|
|
113
|
+
}))),
|
|
106
114
|
container = _render.container;
|
|
107
115
|
const button = container.querySelector('[type="button"]');
|
|
108
116
|
expect(button).toBeInTheDocument();
|
|
@@ -110,45 +118,50 @@ describe('<CondensedButton/>', () => {
|
|
|
110
118
|
expect(button.tagName).toBe('LI');
|
|
111
119
|
});
|
|
112
120
|
it('should set the disabled attribute when `interaction` is set to disabled', () => {
|
|
113
|
-
render(_CondensedButton3 || (_CondensedButton3 =
|
|
114
|
-
interaction: "disabled"
|
|
115
|
-
|
|
121
|
+
render(_CondensedButton3 || (_CondensedButton3 = _jsx(CondensedButton, {
|
|
122
|
+
interaction: "disabled",
|
|
123
|
+
children: "Hello"
|
|
124
|
+
})));
|
|
116
125
|
const button = screen.getByRole('button', {
|
|
117
126
|
name: 'Hello'
|
|
118
127
|
});
|
|
119
128
|
expect(button).toHaveAttribute('disabled');
|
|
120
129
|
});
|
|
121
130
|
it('should set the disabled attribute when `disabled` is set', () => {
|
|
122
|
-
render(_CondensedButton4 || (_CondensedButton4 =
|
|
123
|
-
disabled: true
|
|
124
|
-
|
|
131
|
+
render(_CondensedButton4 || (_CondensedButton4 = _jsx(CondensedButton, {
|
|
132
|
+
disabled: true,
|
|
133
|
+
children: "Hello"
|
|
134
|
+
})));
|
|
125
135
|
const button = screen.getByRole('button', {
|
|
126
136
|
name: 'Hello'
|
|
127
137
|
});
|
|
128
138
|
expect(button).toHaveAttribute('disabled');
|
|
129
139
|
});
|
|
130
140
|
it('should set the disabled attribute when `interaction` is set to readonly', () => {
|
|
131
|
-
render(_CondensedButton5 || (_CondensedButton5 =
|
|
132
|
-
interaction: "readonly"
|
|
133
|
-
|
|
141
|
+
render(_CondensedButton5 || (_CondensedButton5 = _jsx(CondensedButton, {
|
|
142
|
+
interaction: "readonly",
|
|
143
|
+
children: "Hello"
|
|
144
|
+
})));
|
|
134
145
|
const button = screen.getByRole('button', {
|
|
135
146
|
name: 'Hello'
|
|
136
147
|
});
|
|
137
148
|
expect(button).toHaveAttribute('disabled');
|
|
138
149
|
});
|
|
139
150
|
it('should set the disabled attribute when `readOnly` is set', () => {
|
|
140
|
-
render(_CondensedButton6 || (_CondensedButton6 =
|
|
141
|
-
readOnly: true
|
|
142
|
-
|
|
151
|
+
render(_CondensedButton6 || (_CondensedButton6 = _jsx(CondensedButton, {
|
|
152
|
+
readOnly: true,
|
|
153
|
+
children: "Hello"
|
|
154
|
+
})));
|
|
143
155
|
const button = screen.getByRole('button', {
|
|
144
156
|
name: 'Hello'
|
|
145
157
|
});
|
|
146
158
|
expect(button).toHaveAttribute('disabled');
|
|
147
159
|
});
|
|
148
160
|
it('should pass the `href` prop', () => {
|
|
149
|
-
render(_CondensedButton7 || (_CondensedButton7 =
|
|
150
|
-
href: "#"
|
|
151
|
-
|
|
161
|
+
render(_CondensedButton7 || (_CondensedButton7 = _jsx(CondensedButton, {
|
|
162
|
+
href: "#",
|
|
163
|
+
children: "Hello"
|
|
164
|
+
})));
|
|
152
165
|
const linkButton = screen.getByRole('link', {
|
|
153
166
|
name: 'Hello'
|
|
154
167
|
});
|
|
@@ -156,9 +169,10 @@ describe('<CondensedButton/>', () => {
|
|
|
156
169
|
expect(linkButton).toHaveAttribute('href', '#');
|
|
157
170
|
});
|
|
158
171
|
it('should pass the `renderIcon` prop', async () => {
|
|
159
|
-
render(_CondensedButton8 || (_CondensedButton8 =
|
|
160
|
-
renderIcon: icon
|
|
161
|
-
|
|
172
|
+
render(_CondensedButton8 || (_CondensedButton8 = _jsx(CondensedButton, {
|
|
173
|
+
renderIcon: icon,
|
|
174
|
+
children: "Hello"
|
|
175
|
+
})));
|
|
162
176
|
const svgIcon = document.querySelector(iconSelector);
|
|
163
177
|
const button = screen.getByRole('button', {
|
|
164
178
|
name: 'Hello'
|
|
@@ -168,9 +182,10 @@ describe('<CondensedButton/>', () => {
|
|
|
168
182
|
});
|
|
169
183
|
it('should pass the `onClick` prop', async () => {
|
|
170
184
|
const onClick = vi.fn();
|
|
171
|
-
render(
|
|
172
|
-
onClick: onClick
|
|
173
|
-
|
|
185
|
+
render(_jsx(CondensedButton, {
|
|
186
|
+
onClick: onClick,
|
|
187
|
+
children: "Hello"
|
|
188
|
+
}));
|
|
174
189
|
const button = screen.getByRole('button', {
|
|
175
190
|
name: 'Hello'
|
|
176
191
|
});
|
|
@@ -25,13 +25,14 @@ var _dec, _dec2, _class, _CondensedButton;
|
|
|
25
25
|
* SOFTWARE.
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
|
-
import
|
|
28
|
+
import { Component } from 'react';
|
|
29
29
|
import { testable } from '@instructure/ui-testable';
|
|
30
30
|
import { passthroughProps } from '@instructure/ui-react-utils';
|
|
31
31
|
import { withStyle } from '@instructure/emotion';
|
|
32
32
|
import generateComponentTheme from './theme';
|
|
33
33
|
import { BaseButton } from '../BaseButton';
|
|
34
34
|
import { propTypes, allowedProps } from './props';
|
|
35
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
35
36
|
/**
|
|
36
37
|
---
|
|
37
38
|
category: components
|
|
@@ -72,7 +73,8 @@ let CondensedButton = (_dec = withStyle(null, generateComponentTheme), _dec2 = t
|
|
|
72
73
|
renderIcon = _this$props.renderIcon,
|
|
73
74
|
props = _objectWithoutProperties(_this$props, _excluded);
|
|
74
75
|
const themeOverride = this.props.themeOverride;
|
|
75
|
-
return
|
|
76
|
+
return _jsx(BaseButton, {
|
|
77
|
+
...passthroughProps(props),
|
|
76
78
|
isCondensed: true,
|
|
77
79
|
withBackground: false,
|
|
78
80
|
withBorder: false,
|
|
@@ -89,8 +91,9 @@ let CondensedButton = (_dec = withStyle(null, generateComponentTheme), _dec2 = t
|
|
|
89
91
|
themeOverride: themeOverride,
|
|
90
92
|
ref: component => {
|
|
91
93
|
this._baseButton = component;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
+
},
|
|
95
|
+
children: children
|
|
96
|
+
});
|
|
94
97
|
}
|
|
95
98
|
}, _CondensedButton.displayName = "CondensedButton", _CondensedButton.componentId = 'CondensedButton', _CondensedButton.propTypes = propTypes, _CondensedButton.allowedProps = allowedProps, _CondensedButton.defaultProps = {
|
|
96
99
|
type: 'button',
|
|
@@ -23,31 +23,33 @@ var _circle;
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
import React from 'react';
|
|
27
26
|
import { render, screen, waitFor } from '@testing-library/react';
|
|
28
27
|
import { vi } from 'vitest';
|
|
29
28
|
import userEvent from '@testing-library/user-event';
|
|
30
29
|
import '@testing-library/jest-dom';
|
|
31
30
|
import { IconButton } from '../index';
|
|
31
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
32
32
|
describe('<IconButton/>', () => {
|
|
33
33
|
var _IconButton, _IconButton2, _IconButton3, _IconButton4, _IconButton5, _IconButton6, _IconButton7, _IconButton8, _IconButton9;
|
|
34
|
-
const icon =
|
|
34
|
+
const icon = _jsx("svg", {
|
|
35
35
|
"data-title": "myIcon",
|
|
36
36
|
height: "1em",
|
|
37
37
|
width: "1em",
|
|
38
38
|
style: {
|
|
39
39
|
fill: 'currentcolor'
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
},
|
|
41
|
+
children: _circle || (_circle = _jsx("circle", {
|
|
42
|
+
cx: "0.5em",
|
|
43
|
+
cy: "0.5em",
|
|
44
|
+
r: "0.5em"
|
|
45
|
+
}))
|
|
46
|
+
});
|
|
46
47
|
const iconSelector = 'svg[data-title="myIcon"]';
|
|
47
48
|
it('should render an icon when provided as the `children` prop', () => {
|
|
48
|
-
render(_IconButton || (_IconButton =
|
|
49
|
-
screenReaderLabel: "some action"
|
|
50
|
-
|
|
49
|
+
render(_IconButton || (_IconButton = _jsx(IconButton, {
|
|
50
|
+
screenReaderLabel: "some action",
|
|
51
|
+
children: icon
|
|
52
|
+
})));
|
|
51
53
|
const svgIcon = document.querySelector(iconSelector);
|
|
52
54
|
const button = screen.getByRole('button');
|
|
53
55
|
expect(button).toBeInTheDocument();
|
|
@@ -55,7 +57,7 @@ describe('<IconButton/>', () => {
|
|
|
55
57
|
expect(button).toHaveTextContent('some action');
|
|
56
58
|
});
|
|
57
59
|
it('should render an icon when provided as the `renderIcon` prop', () => {
|
|
58
|
-
render(_IconButton2 || (_IconButton2 =
|
|
60
|
+
render(_IconButton2 || (_IconButton2 = _jsx(IconButton, {
|
|
59
61
|
screenReaderLabel: "some action",
|
|
60
62
|
renderIcon: icon
|
|
61
63
|
})));
|
|
@@ -67,7 +69,7 @@ describe('<IconButton/>', () => {
|
|
|
67
69
|
it('should provide a focused getter', () => {
|
|
68
70
|
var _componentRef;
|
|
69
71
|
let componentRef;
|
|
70
|
-
render(
|
|
72
|
+
render(_jsx(IconButton, {
|
|
71
73
|
screenReaderLabel: "some action",
|
|
72
74
|
renderIcon: icon,
|
|
73
75
|
ref: component => {
|
|
@@ -81,7 +83,7 @@ describe('<IconButton/>', () => {
|
|
|
81
83
|
it('should provide a focus function', () => {
|
|
82
84
|
var _componentRef2;
|
|
83
85
|
let componentRef;
|
|
84
|
-
render(
|
|
86
|
+
render(_jsx(IconButton, {
|
|
85
87
|
screenReaderLabel: "some action",
|
|
86
88
|
renderIcon: icon,
|
|
87
89
|
ref: component => {
|
|
@@ -93,7 +95,7 @@ describe('<IconButton/>', () => {
|
|
|
93
95
|
expect(document.activeElement).toBe(button);
|
|
94
96
|
});
|
|
95
97
|
it('should pass the `href` prop', () => {
|
|
96
|
-
render(_IconButton3 || (_IconButton3 =
|
|
98
|
+
render(_IconButton3 || (_IconButton3 = _jsx(IconButton, {
|
|
97
99
|
screenReaderLabel: "some action",
|
|
98
100
|
renderIcon: icon,
|
|
99
101
|
href: "#"
|
|
@@ -103,7 +105,7 @@ describe('<IconButton/>', () => {
|
|
|
103
105
|
expect(linkButton).toHaveAttribute('href', '#');
|
|
104
106
|
});
|
|
105
107
|
it('should pass the `type` prop', () => {
|
|
106
|
-
render(_IconButton4 || (_IconButton4 =
|
|
108
|
+
render(_IconButton4 || (_IconButton4 = _jsx(IconButton, {
|
|
107
109
|
screenReaderLabel: "some action",
|
|
108
110
|
renderIcon: icon,
|
|
109
111
|
type: "reset"
|
|
@@ -114,7 +116,7 @@ describe('<IconButton/>', () => {
|
|
|
114
116
|
});
|
|
115
117
|
it('should pass the `elementRef` prop', () => {
|
|
116
118
|
const elementRef = vi.fn();
|
|
117
|
-
render(
|
|
119
|
+
render(_jsx(IconButton, {
|
|
118
120
|
screenReaderLabel: "some action",
|
|
119
121
|
renderIcon: icon,
|
|
120
122
|
elementRef: elementRef
|
|
@@ -123,7 +125,7 @@ describe('<IconButton/>', () => {
|
|
|
123
125
|
expect(elementRef).toHaveBeenCalledWith(button);
|
|
124
126
|
});
|
|
125
127
|
it('should pass the `as` prop', () => {
|
|
126
|
-
const _render = render(_IconButton5 || (_IconButton5 =
|
|
128
|
+
const _render = render(_IconButton5 || (_IconButton5 = _jsx(IconButton, {
|
|
127
129
|
screenReaderLabel: "some action",
|
|
128
130
|
renderIcon: icon,
|
|
129
131
|
as: "li"
|
|
@@ -135,7 +137,7 @@ describe('<IconButton/>', () => {
|
|
|
135
137
|
expect(button.tagName).toBe('LI');
|
|
136
138
|
});
|
|
137
139
|
it('should set the disabled attribute when `interaction` is set to disabled', () => {
|
|
138
|
-
render(_IconButton6 || (_IconButton6 =
|
|
140
|
+
render(_IconButton6 || (_IconButton6 = _jsx(IconButton, {
|
|
139
141
|
screenReaderLabel: "some action",
|
|
140
142
|
renderIcon: icon,
|
|
141
143
|
interaction: "disabled"
|
|
@@ -144,7 +146,7 @@ describe('<IconButton/>', () => {
|
|
|
144
146
|
expect(button).toHaveAttribute('disabled');
|
|
145
147
|
});
|
|
146
148
|
it('should set the disabled attribute when `disabled` is set', () => {
|
|
147
|
-
render(_IconButton7 || (_IconButton7 =
|
|
149
|
+
render(_IconButton7 || (_IconButton7 = _jsx(IconButton, {
|
|
148
150
|
screenReaderLabel: "some action",
|
|
149
151
|
renderIcon: icon,
|
|
150
152
|
disabled: true
|
|
@@ -153,7 +155,7 @@ describe('<IconButton/>', () => {
|
|
|
153
155
|
expect(button).toHaveAttribute('disabled');
|
|
154
156
|
});
|
|
155
157
|
it('should set the disabled attribute when `interaction` is set to readonly', () => {
|
|
156
|
-
render(_IconButton8 || (_IconButton8 =
|
|
158
|
+
render(_IconButton8 || (_IconButton8 = _jsx(IconButton, {
|
|
157
159
|
screenReaderLabel: "some action",
|
|
158
160
|
renderIcon: icon,
|
|
159
161
|
interaction: "readonly"
|
|
@@ -162,7 +164,7 @@ describe('<IconButton/>', () => {
|
|
|
162
164
|
expect(button).toHaveAttribute('disabled');
|
|
163
165
|
});
|
|
164
166
|
it('should set the disabled attribute when `readOnly` is set', () => {
|
|
165
|
-
render(_IconButton9 || (_IconButton9 =
|
|
167
|
+
render(_IconButton9 || (_IconButton9 = _jsx(IconButton, {
|
|
166
168
|
screenReaderLabel: "some action",
|
|
167
169
|
renderIcon: icon,
|
|
168
170
|
readOnly: true
|
|
@@ -172,7 +174,7 @@ describe('<IconButton/>', () => {
|
|
|
172
174
|
});
|
|
173
175
|
it('should pass the `onClick` prop', async () => {
|
|
174
176
|
const onClick = vi.fn();
|
|
175
|
-
render(
|
|
177
|
+
render(_jsx(IconButton, {
|
|
176
178
|
screenReaderLabel: "some action",
|
|
177
179
|
renderIcon: icon,
|
|
178
180
|
onClick: onClick
|
package/es/IconButton/index.js
CHANGED
|
@@ -25,7 +25,7 @@ var _dec, _dec2, _class, _IconButton;
|
|
|
25
25
|
* SOFTWARE.
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
|
-
import
|
|
28
|
+
import { Component } from 'react';
|
|
29
29
|
import { testable } from '@instructure/ui-testable';
|
|
30
30
|
import { passthroughProps } from '@instructure/ui-react-utils';
|
|
31
31
|
import { ScreenReaderContent } from '@instructure/ui-a11y-content';
|
|
@@ -33,6 +33,7 @@ import { withStyle } from '@instructure/emotion';
|
|
|
33
33
|
import generateComponentTheme from './theme';
|
|
34
34
|
import { BaseButton } from '../BaseButton';
|
|
35
35
|
import { propTypes, allowedProps } from './props';
|
|
36
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
36
37
|
/**
|
|
37
38
|
---
|
|
38
39
|
category: components
|
|
@@ -78,7 +79,8 @@ let IconButton = (_dec = withStyle(null, generateComponentTheme), _dec2 = testab
|
|
|
78
79
|
href = _this$props.href,
|
|
79
80
|
props = _objectWithoutProperties(_this$props, _excluded);
|
|
80
81
|
const themeOverride = this.props.themeOverride;
|
|
81
|
-
return
|
|
82
|
+
return _jsx(BaseButton, {
|
|
83
|
+
...passthroughProps(props),
|
|
82
84
|
type: type,
|
|
83
85
|
size: size,
|
|
84
86
|
elementRef: this.handleRef,
|
|
@@ -96,8 +98,11 @@ let IconButton = (_dec = withStyle(null, generateComponentTheme), _dec2 = testab
|
|
|
96
98
|
themeOverride: themeOverride,
|
|
97
99
|
ref: component => {
|
|
98
100
|
this._baseButton = component;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
+
},
|
|
102
|
+
children: _jsx(ScreenReaderContent, {
|
|
103
|
+
children: screenReaderLabel
|
|
104
|
+
})
|
|
105
|
+
});
|
|
101
106
|
}
|
|
102
107
|
}, _IconButton.displayName = "IconButton", _IconButton.componentId = 'IconButton', _IconButton.propTypes = propTypes, _IconButton.allowedProps = allowedProps, _IconButton.defaultProps = {
|
|
103
108
|
type: 'button',
|
|
@@ -23,26 +23,27 @@ var _svg;
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
import React from 'react';
|
|
27
26
|
import { render, screen, waitFor } from '@testing-library/react';
|
|
28
27
|
import { vi } from 'vitest';
|
|
29
28
|
import userEvent from '@testing-library/user-event';
|
|
30
29
|
import '@testing-library/jest-dom';
|
|
31
30
|
import { ToggleButton } from '../index';
|
|
31
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
32
32
|
describe('<ToggleButton />', () => {
|
|
33
33
|
var _ToggleButton, _ToggleButton2, _ToggleButton3, _ToggleButton4, _ToggleButton5, _ToggleButton6, _ToggleButton7, _ToggleButton8, _ToggleButton9;
|
|
34
|
-
const icon = _svg || (_svg =
|
|
34
|
+
const icon = _svg || (_svg = _jsx("svg", {
|
|
35
35
|
"data-title": "myIcon",
|
|
36
36
|
height: "1em",
|
|
37
|
-
width: "1em"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
width: "1em",
|
|
38
|
+
children: _jsx("circle", {
|
|
39
|
+
cx: "0.5em",
|
|
40
|
+
cy: "0.5em",
|
|
41
|
+
r: "0.5em"
|
|
42
|
+
})
|
|
43
|
+
}));
|
|
43
44
|
const iconSelector = 'svg[data-title="myIcon"]';
|
|
44
45
|
it('should render', () => {
|
|
45
|
-
render(_ToggleButton || (_ToggleButton =
|
|
46
|
+
render(_ToggleButton || (_ToggleButton = _jsx(ToggleButton, {
|
|
46
47
|
screenReaderLabel: "This is a screen reader label",
|
|
47
48
|
renderIcon: icon,
|
|
48
49
|
renderTooltipContent: "This is tooltip content",
|
|
@@ -58,7 +59,7 @@ describe('<ToggleButton />', () => {
|
|
|
58
59
|
expect(tooltip).toHaveTextContent('This is tooltip content');
|
|
59
60
|
});
|
|
60
61
|
it('should set `aria-pressed` to `true` if `status` is `pressed`', () => {
|
|
61
|
-
render(_ToggleButton2 || (_ToggleButton2 =
|
|
62
|
+
render(_ToggleButton2 || (_ToggleButton2 = _jsx(ToggleButton, {
|
|
62
63
|
screenReaderLabel: "This is a screen reader label",
|
|
63
64
|
renderIcon: icon,
|
|
64
65
|
renderTooltipContent: "This is tooltip content",
|
|
@@ -68,7 +69,7 @@ describe('<ToggleButton />', () => {
|
|
|
68
69
|
expect(button).toHaveAttribute('aria-pressed', 'true');
|
|
69
70
|
});
|
|
70
71
|
it('should set `aria-pressed` to `false` if `status` is `unpressed`', () => {
|
|
71
|
-
render(_ToggleButton3 || (_ToggleButton3 =
|
|
72
|
+
render(_ToggleButton3 || (_ToggleButton3 = _jsx(ToggleButton, {
|
|
72
73
|
screenReaderLabel: "This is a screen reader label",
|
|
73
74
|
renderIcon: icon,
|
|
74
75
|
renderTooltipContent: "This is tooltip content",
|
|
@@ -78,7 +79,7 @@ describe('<ToggleButton />', () => {
|
|
|
78
79
|
expect(button).toHaveAttribute('aria-pressed', 'false');
|
|
79
80
|
});
|
|
80
81
|
it('should render an icon', () => {
|
|
81
|
-
render(_ToggleButton4 || (_ToggleButton4 =
|
|
82
|
+
render(_ToggleButton4 || (_ToggleButton4 = _jsx(ToggleButton, {
|
|
82
83
|
screenReaderLabel: "This is a screen reader label",
|
|
83
84
|
renderIcon: icon,
|
|
84
85
|
renderTooltipContent: "This is tooltip content",
|
|
@@ -90,7 +91,7 @@ describe('<ToggleButton />', () => {
|
|
|
90
91
|
expect(svgIcon).toBeInTheDocument();
|
|
91
92
|
});
|
|
92
93
|
it('should pass the `as` prop', () => {
|
|
93
|
-
const _render = render(_ToggleButton5 || (_ToggleButton5 =
|
|
94
|
+
const _render = render(_ToggleButton5 || (_ToggleButton5 = _jsx(ToggleButton, {
|
|
94
95
|
screenReaderLabel: "This is a screen reader label",
|
|
95
96
|
renderIcon: icon,
|
|
96
97
|
renderTooltipContent: "This is tooltip content",
|
|
@@ -103,7 +104,7 @@ describe('<ToggleButton />', () => {
|
|
|
103
104
|
expect(button.tagName).toBe('LI');
|
|
104
105
|
});
|
|
105
106
|
it('should set the disabled attribute when `interaction` prop is set to disabled', () => {
|
|
106
|
-
render(_ToggleButton6 || (_ToggleButton6 =
|
|
107
|
+
render(_ToggleButton6 || (_ToggleButton6 = _jsx(ToggleButton, {
|
|
107
108
|
screenReaderLabel: "This is a screen reader label",
|
|
108
109
|
renderIcon: icon,
|
|
109
110
|
renderTooltipContent: "This is tooltip content",
|
|
@@ -114,7 +115,7 @@ describe('<ToggleButton />', () => {
|
|
|
114
115
|
expect(button).toHaveAttribute('disabled');
|
|
115
116
|
});
|
|
116
117
|
it('should set the disabled attribute when `disabled` prop is set', () => {
|
|
117
|
-
render(_ToggleButton7 || (_ToggleButton7 =
|
|
118
|
+
render(_ToggleButton7 || (_ToggleButton7 = _jsx(ToggleButton, {
|
|
118
119
|
screenReaderLabel: "This is a screen reader label",
|
|
119
120
|
renderIcon: icon,
|
|
120
121
|
renderTooltipContent: "This is tooltip content",
|
|
@@ -125,7 +126,7 @@ describe('<ToggleButton />', () => {
|
|
|
125
126
|
expect(button).toHaveAttribute('disabled');
|
|
126
127
|
});
|
|
127
128
|
it('should set the disabled attribute when `interaction` prop is set to readonly', () => {
|
|
128
|
-
render(_ToggleButton8 || (_ToggleButton8 =
|
|
129
|
+
render(_ToggleButton8 || (_ToggleButton8 = _jsx(ToggleButton, {
|
|
129
130
|
screenReaderLabel: "This is a screen reader label",
|
|
130
131
|
renderIcon: icon,
|
|
131
132
|
renderTooltipContent: "This is tooltip content",
|
|
@@ -136,7 +137,7 @@ describe('<ToggleButton />', () => {
|
|
|
136
137
|
expect(button).toHaveAttribute('disabled');
|
|
137
138
|
});
|
|
138
139
|
it('should set the disabled attribute when `readOnly` prop is set', () => {
|
|
139
|
-
render(_ToggleButton9 || (_ToggleButton9 =
|
|
140
|
+
render(_ToggleButton9 || (_ToggleButton9 = _jsx(ToggleButton, {
|
|
140
141
|
screenReaderLabel: "This is a screen reader label",
|
|
141
142
|
renderIcon: icon,
|
|
142
143
|
renderTooltipContent: "This is tooltip content",
|
|
@@ -148,7 +149,7 @@ describe('<ToggleButton />', () => {
|
|
|
148
149
|
});
|
|
149
150
|
it('should pass the `onClick` prop', async () => {
|
|
150
151
|
const onClick = vi.fn();
|
|
151
|
-
render(
|
|
152
|
+
render(_jsx(ToggleButton, {
|
|
152
153
|
screenReaderLabel: "This is a screen reader label",
|
|
153
154
|
renderIcon: icon,
|
|
154
155
|
renderTooltipContent: "This is tooltip content",
|
package/es/ToggleButton/index.js
CHANGED
|
@@ -25,12 +25,13 @@ var _dec, _class, _ToggleButton;
|
|
|
25
25
|
* SOFTWARE.
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
|
-
import
|
|
28
|
+
import { Component } from 'react';
|
|
29
29
|
import { testable } from '@instructure/ui-testable';
|
|
30
30
|
import { callRenderProp, passthroughProps } from '@instructure/ui-react-utils';
|
|
31
31
|
import { Tooltip } from '@instructure/ui-tooltip';
|
|
32
32
|
import { IconButton } from '../IconButton';
|
|
33
33
|
import { propTypes, allowedProps } from './props';
|
|
34
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
34
35
|
/**
|
|
35
36
|
---
|
|
36
37
|
category: components
|
|
@@ -68,7 +69,7 @@ let ToggleButton = (_dec = testable(), _dec(_class = (_ToggleButton = class Togg
|
|
|
68
69
|
placement = _this$props.placement,
|
|
69
70
|
onClick = _this$props.onClick,
|
|
70
71
|
props = _objectWithoutProperties(_this$props, _excluded);
|
|
71
|
-
return
|
|
72
|
+
return _jsx(Tooltip, {
|
|
72
73
|
renderTip: renderTooltipContent,
|
|
73
74
|
on: ['hover', 'focus'],
|
|
74
75
|
placement: placement,
|
|
@@ -85,19 +86,22 @@ let ToggleButton = (_dec = testable(), _dec(_class = (_ToggleButton = class Togg
|
|
|
85
86
|
});
|
|
86
87
|
},
|
|
87
88
|
mountNode: mountNode,
|
|
88
|
-
elementRef: el => this.ref = el
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
89
|
+
elementRef: el => this.ref = el,
|
|
90
|
+
children: _jsx(IconButton, {
|
|
91
|
+
...passthroughProps(props),
|
|
92
|
+
screenReaderLabel: screenReaderLabel,
|
|
93
|
+
withBackground: false,
|
|
94
|
+
withBorder: false,
|
|
95
|
+
color: color,
|
|
96
|
+
size: size,
|
|
97
|
+
elementRef: this.handleRef,
|
|
98
|
+
as: as,
|
|
99
|
+
onClick: onClick,
|
|
100
|
+
interaction: interaction,
|
|
101
|
+
"aria-pressed": status === 'pressed',
|
|
102
|
+
children: callRenderProp(renderIcon)
|
|
103
|
+
})
|
|
104
|
+
});
|
|
101
105
|
}
|
|
102
106
|
}, _ToggleButton.displayName = "ToggleButton", _ToggleButton.componentId = 'ToggleButton', _ToggleButton.propTypes = propTypes, _ToggleButton.allowedProps = allowedProps, _ToggleButton.defaultProps = {
|
|
103
107
|
size: 'medium',
|