@instructure/ui-checkbox 10.16.1-snapshot-0 → 10.16.1-snapshot-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/Checkbox/CheckboxFacade/__new-tests__/CheckboxFacade.test.js +7 -3
- package/es/Checkbox/CheckboxFacade/index.js +23 -19
- package/es/Checkbox/ToggleFacade/__new-tests__/ToggleFacade.test.js +7 -3
- package/es/Checkbox/ToggleFacade/index.js +22 -17
- package/es/Checkbox/__new-tests__/Checkbox.test.js +10 -6
- package/es/Checkbox/index.js +53 -44
- package/es/CheckboxGroup/__new-tests__/CheckboxGroup.test.js +11 -8
- package/es/CheckboxGroup/index.js +8 -4
- package/lib/Checkbox/CheckboxFacade/__new-tests__/CheckboxFacade.test.js +9 -6
- package/lib/Checkbox/CheckboxFacade/index.js +22 -18
- package/lib/Checkbox/ToggleFacade/__new-tests__/ToggleFacade.test.js +9 -6
- package/lib/Checkbox/ToggleFacade/index.js +21 -16
- package/lib/Checkbox/__new-tests__/Checkbox.test.js +10 -6
- package/lib/Checkbox/index.js +52 -44
- package/lib/CheckboxGroup/__new-tests__/CheckboxGroup.test.js +29 -26
- package/lib/CheckboxGroup/index.js +8 -5
- package/package.json +19 -19
- package/src/Checkbox/CheckboxFacade/__new-tests__/CheckboxFacade.test.tsx +0 -1
- package/src/Checkbox/CheckboxFacade/index.tsx +1 -2
- package/src/Checkbox/ToggleFacade/__new-tests__/ToggleFacade.test.tsx +0 -1
- package/src/Checkbox/ToggleFacade/index.tsx +1 -2
- package/src/Checkbox/__new-tests__/Checkbox.test.tsx +2 -2
- package/src/Checkbox/index.tsx +2 -3
- package/src/CheckboxGroup/__new-tests__/CheckboxGroup.test.tsx +0 -1
- package/src/CheckboxGroup/index.tsx +1 -1
- package/src/CheckboxGroup/props.ts +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Checkbox/CheckboxFacade/__new-tests__/CheckboxFacade.test.d.ts.map +1 -1
- package/types/Checkbox/CheckboxFacade/index.d.ts +2 -4
- package/types/Checkbox/CheckboxFacade/index.d.ts.map +1 -1
- package/types/Checkbox/ToggleFacade/__new-tests__/ToggleFacade.test.d.ts.map +1 -1
- package/types/Checkbox/ToggleFacade/index.d.ts +3 -5
- package/types/Checkbox/ToggleFacade/index.d.ts.map +1 -1
- package/types/Checkbox/index.d.ts +4 -6
- package/types/Checkbox/index.d.ts.map +1 -1
- package/types/CheckboxGroup/__new-tests__/CheckboxGroup.test.d.ts.map +1 -1
- package/types/CheckboxGroup/index.d.ts +2 -2
- package/types/CheckboxGroup/index.d.ts.map +1 -1
- package/types/CheckboxGroup/props.d.ts +1 -1
- package/types/CheckboxGroup/props.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [10.16.1-snapshot-
|
|
6
|
+
## [10.16.1-snapshot-1](https://github.com/instructure/instructure-ui/compare/v10.16.0...v10.16.1-snapshot-1) (2025-04-22)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @instructure/ui-checkbox
|
|
9
9
|
|
|
@@ -23,12 +23,12 @@ var _CheckboxFacade, _CheckboxFacade2;
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
import React from 'react';
|
|
27
26
|
import { render, screen } from '@testing-library/react';
|
|
28
27
|
import { vi } from 'vitest';
|
|
29
28
|
import '@testing-library/jest-dom';
|
|
30
29
|
import { runAxeCheck } from '@instructure/ui-axe-check';
|
|
31
30
|
import { CheckboxFacade } from '../index';
|
|
31
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
32
32
|
const TEST_TEXT = 'test-text';
|
|
33
33
|
describe('<CheckboxFacade />', () => {
|
|
34
34
|
let consoleWarningMock;
|
|
@@ -43,12 +43,16 @@ describe('<CheckboxFacade />', () => {
|
|
|
43
43
|
consoleErrorMock.mockRestore();
|
|
44
44
|
});
|
|
45
45
|
it('should render', () => {
|
|
46
|
-
render(_CheckboxFacade || (_CheckboxFacade =
|
|
46
|
+
render(_CheckboxFacade || (_CheckboxFacade = _jsx(CheckboxFacade, {
|
|
47
|
+
children: TEST_TEXT
|
|
48
|
+
})));
|
|
47
49
|
const facade = screen.getByText(TEST_TEXT);
|
|
48
50
|
expect(facade).toBeInTheDocument();
|
|
49
51
|
});
|
|
50
52
|
it('should meet a11y standards', async () => {
|
|
51
|
-
const _render = render(_CheckboxFacade2 || (_CheckboxFacade2 =
|
|
53
|
+
const _render = render(_CheckboxFacade2 || (_CheckboxFacade2 = _jsx(CheckboxFacade, {
|
|
54
|
+
children: TEST_TEXT
|
|
55
|
+
}))),
|
|
52
56
|
container = _render.container;
|
|
53
57
|
const axeCheck = await runAxeCheck(container);
|
|
54
58
|
expect(axeCheck).toBe(true);
|
|
@@ -23,14 +23,14 @@ var _dec, _class, _CheckboxFacade, _SVGIcon, _IconCheckMarkSolid;
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
/** @jsx jsx */
|
|
27
26
|
import { Component } from 'react';
|
|
28
27
|
import { SVGIcon } from '@instructure/ui-svg-images';
|
|
29
28
|
import { IconCheckMarkSolid } from '@instructure/ui-icons';
|
|
30
|
-
import { withStyle
|
|
29
|
+
import { withStyle } from '@instructure/emotion';
|
|
31
30
|
import generateStyle from './styles';
|
|
32
31
|
import generateComponentTheme from './theme';
|
|
33
32
|
import { propTypes, allowedProps } from './props';
|
|
33
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
34
34
|
/**
|
|
35
35
|
---
|
|
36
36
|
parent: Checkbox
|
|
@@ -54,17 +54,18 @@ let CheckboxFacade = (_dec = withStyle(generateStyle, generateComponentTheme), _
|
|
|
54
54
|
}
|
|
55
55
|
renderIcon() {
|
|
56
56
|
if (this.props.indeterminate) {
|
|
57
|
-
return _SVGIcon || (_SVGIcon =
|
|
57
|
+
return _SVGIcon || (_SVGIcon = _jsx(SVGIcon, {
|
|
58
58
|
viewBox: "0 0 1920 1920",
|
|
59
|
-
inline: false
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
59
|
+
inline: false,
|
|
60
|
+
children: _jsx("rect", {
|
|
61
|
+
x: "140",
|
|
62
|
+
y: "820",
|
|
63
|
+
width: "1640",
|
|
64
|
+
height: "280"
|
|
65
|
+
})
|
|
66
|
+
}));
|
|
66
67
|
} else if (this.props.checked) {
|
|
67
|
-
return _IconCheckMarkSolid || (_IconCheckMarkSolid =
|
|
68
|
+
return _IconCheckMarkSolid || (_IconCheckMarkSolid = _jsx(IconCheckMarkSolid, {
|
|
68
69
|
inline: false
|
|
69
70
|
}));
|
|
70
71
|
} else {
|
|
@@ -75,15 +76,18 @@ let CheckboxFacade = (_dec = withStyle(generateStyle, generateComponentTheme), _
|
|
|
75
76
|
const _this$props3 = this.props,
|
|
76
77
|
children = _this$props3.children,
|
|
77
78
|
styles = _this$props3.styles;
|
|
78
|
-
return
|
|
79
|
+
return _jsxs("span", {
|
|
79
80
|
css: styles === null || styles === void 0 ? void 0 : styles.checkboxFacade,
|
|
80
|
-
ref: this.handleRef
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
81
|
+
ref: this.handleRef,
|
|
82
|
+
children: [_jsx("span", {
|
|
83
|
+
css: styles === null || styles === void 0 ? void 0 : styles.facade,
|
|
84
|
+
"aria-hidden": "true",
|
|
85
|
+
children: this.renderIcon()
|
|
86
|
+
}), _jsx("span", {
|
|
87
|
+
css: styles === null || styles === void 0 ? void 0 : styles.label,
|
|
88
|
+
children: children
|
|
89
|
+
})]
|
|
90
|
+
});
|
|
87
91
|
}
|
|
88
92
|
}, _CheckboxFacade.displayName = "CheckboxFacade", _CheckboxFacade.componentId = 'CheckboxFacade', _CheckboxFacade.propTypes = propTypes, _CheckboxFacade.allowedProps = allowedProps, _CheckboxFacade.defaultProps = {
|
|
89
93
|
checked: false,
|
|
@@ -23,12 +23,12 @@ var _ToggleFacade, _ToggleFacade2;
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
import React from 'react';
|
|
27
26
|
import { render, screen } from '@testing-library/react';
|
|
28
27
|
import { vi } from 'vitest';
|
|
29
28
|
import '@testing-library/jest-dom';
|
|
30
29
|
import { runAxeCheck } from '@instructure/ui-axe-check';
|
|
31
30
|
import { ToggleFacade } from '../index';
|
|
31
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
32
32
|
const TEST_TEXT = 'test-text';
|
|
33
33
|
describe('<ToggleFacade />', () => {
|
|
34
34
|
let consoleWarningMock;
|
|
@@ -43,12 +43,16 @@ describe('<ToggleFacade />', () => {
|
|
|
43
43
|
consoleErrorMock.mockRestore();
|
|
44
44
|
});
|
|
45
45
|
it('should render', () => {
|
|
46
|
-
render(_ToggleFacade || (_ToggleFacade =
|
|
46
|
+
render(_ToggleFacade || (_ToggleFacade = _jsx(ToggleFacade, {
|
|
47
|
+
children: TEST_TEXT
|
|
48
|
+
})));
|
|
47
49
|
const facade = screen.getByText(TEST_TEXT);
|
|
48
50
|
expect(facade).toBeInTheDocument();
|
|
49
51
|
});
|
|
50
52
|
it('should meet a11y standards', async () => {
|
|
51
|
-
const _render = render(_ToggleFacade2 || (_ToggleFacade2 =
|
|
53
|
+
const _render = render(_ToggleFacade2 || (_ToggleFacade2 = _jsx(ToggleFacade, {
|
|
54
|
+
children: TEST_TEXT
|
|
55
|
+
}))),
|
|
52
56
|
container = _render.container;
|
|
53
57
|
const axeCheck = await runAxeCheck(container);
|
|
54
58
|
expect(axeCheck).toBe(true);
|
|
@@ -23,13 +23,13 @@ var _dec, _class, _ToggleFacade;
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
/** @jsx jsx */
|
|
27
26
|
import { Component } from 'react';
|
|
28
27
|
import { IconCheckSolid, IconXSolid } from '@instructure/ui-icons';
|
|
29
|
-
import { withStyle
|
|
28
|
+
import { withStyle } from '@instructure/emotion';
|
|
30
29
|
import generateStyle from './styles';
|
|
31
30
|
import generateComponentTheme from './theme';
|
|
32
31
|
import { propTypes, allowedProps } from './props';
|
|
32
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
33
33
|
/**
|
|
34
34
|
---
|
|
35
35
|
parent: Checkbox
|
|
@@ -56,11 +56,11 @@ let ToggleFacade = (_dec = withStyle(generateStyle, generateComponentTheme), _de
|
|
|
56
56
|
styles = _this$props3.styles,
|
|
57
57
|
checked = _this$props3.checked;
|
|
58
58
|
if (checked) {
|
|
59
|
-
return
|
|
59
|
+
return _jsx(IconCheckSolid, {
|
|
60
60
|
css: styles === null || styles === void 0 ? void 0 : styles.iconSVG
|
|
61
61
|
});
|
|
62
62
|
} else {
|
|
63
|
-
return
|
|
63
|
+
return _jsx(IconXSolid, {
|
|
64
64
|
css: styles === null || styles === void 0 ? void 0 : styles.iconSVG
|
|
65
65
|
});
|
|
66
66
|
}
|
|
@@ -69,25 +69,30 @@ let ToggleFacade = (_dec = withStyle(generateStyle, generateComponentTheme), _de
|
|
|
69
69
|
const _this$props4 = this.props,
|
|
70
70
|
children = _this$props4.children,
|
|
71
71
|
styles = _this$props4.styles;
|
|
72
|
-
return
|
|
73
|
-
css: styles === null || styles === void 0 ? void 0 : styles.label
|
|
74
|
-
|
|
72
|
+
return _jsx("span", {
|
|
73
|
+
css: styles === null || styles === void 0 ? void 0 : styles.label,
|
|
74
|
+
children: children
|
|
75
|
+
});
|
|
75
76
|
}
|
|
76
77
|
render() {
|
|
77
78
|
const _this$props5 = this.props,
|
|
78
79
|
labelPlacement = _this$props5.labelPlacement,
|
|
79
80
|
styles = _this$props5.styles;
|
|
80
|
-
return
|
|
81
|
+
return _jsxs("span", {
|
|
81
82
|
css: styles === null || styles === void 0 ? void 0 : styles.toggleFacade,
|
|
82
|
-
ref: this.handleRef
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
83
|
+
ref: this.handleRef,
|
|
84
|
+
children: [(labelPlacement === 'top' || labelPlacement === 'start') && this.renderLabel(), _jsx("span", {
|
|
85
|
+
css: styles === null || styles === void 0 ? void 0 : styles.facade,
|
|
86
|
+
"aria-hidden": "true",
|
|
87
|
+
children: _jsx("span", {
|
|
88
|
+
css: styles === null || styles === void 0 ? void 0 : styles.icon,
|
|
89
|
+
children: _jsx("span", {
|
|
90
|
+
css: styles === null || styles === void 0 ? void 0 : styles.iconToggle,
|
|
91
|
+
children: this.renderIcon()
|
|
92
|
+
})
|
|
93
|
+
})
|
|
94
|
+
}), labelPlacement === 'end' && this.renderLabel()]
|
|
95
|
+
});
|
|
91
96
|
}
|
|
92
97
|
}, _ToggleFacade.displayName = "ToggleFacade", _ToggleFacade.componentId = 'ToggleFacade', _ToggleFacade.propTypes = propTypes, _ToggleFacade.allowedProps = allowedProps, _ToggleFacade.defaultProps = {
|
|
93
98
|
checked: false,
|
|
@@ -22,13 +22,14 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
import
|
|
25
|
+
import { createRef } from 'react';
|
|
26
26
|
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
|
|
27
27
|
import { vi } from 'vitest';
|
|
28
28
|
import userEvent from '@testing-library/user-event';
|
|
29
29
|
import '@testing-library/jest-dom';
|
|
30
30
|
import { runAxeCheck } from '@instructure/ui-axe-check';
|
|
31
31
|
import { Checkbox } from '../index';
|
|
32
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
32
33
|
const TEST_VALUE = 'test-value';
|
|
33
34
|
const TEST_NAME = 'test-name';
|
|
34
35
|
const TEST_LABEL = 'test-label';
|
|
@@ -43,7 +44,9 @@ const renderCheckbox = props => {
|
|
|
43
44
|
...initProps,
|
|
44
45
|
...props
|
|
45
46
|
};
|
|
46
|
-
return render(
|
|
47
|
+
return render(_jsx(Checkbox, {
|
|
48
|
+
...allProps
|
|
49
|
+
}));
|
|
47
50
|
};
|
|
48
51
|
describe('<Checkbox />', () => {
|
|
49
52
|
let consoleWarningMock;
|
|
@@ -168,10 +171,11 @@ describe('<Checkbox />', () => {
|
|
|
168
171
|
});
|
|
169
172
|
it('focuses with the focus helper', () => {
|
|
170
173
|
var _checkboxRef$current;
|
|
171
|
-
const checkboxRef = /*#__PURE__*/
|
|
172
|
-
render(
|
|
173
|
-
ref: checkboxRef
|
|
174
|
-
|
|
174
|
+
const checkboxRef = /*#__PURE__*/createRef();
|
|
175
|
+
render(_jsx(Checkbox, {
|
|
176
|
+
ref: checkboxRef,
|
|
177
|
+
...initProps
|
|
178
|
+
}));
|
|
175
179
|
const checkboxElement = screen.getByRole('checkbox');
|
|
176
180
|
expect(checkboxElement).not.toHaveFocus();
|
|
177
181
|
(_checkboxRef$current = checkboxRef.current) === null || _checkboxRef$current === void 0 ? void 0 : _checkboxRef$current.focus();
|
package/es/Checkbox/index.js
CHANGED
|
@@ -23,8 +23,7 @@ var _dec, _dec2, _dec3, _class, _Checkbox;
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
import React, { Component } from 'react';
|
|
26
|
+
import { Component } from 'react';
|
|
28
27
|
import keycode from 'keycode';
|
|
29
28
|
import { FormFieldMessages } from '@instructure/ui-form-field';
|
|
30
29
|
import { createChainedFunction } from '@instructure/ui-utils';
|
|
@@ -33,12 +32,13 @@ import { isActiveElement } from '@instructure/ui-dom-utils';
|
|
|
33
32
|
import { omitProps, withDeterministicId } from '@instructure/ui-react-utils';
|
|
34
33
|
import { View } from '@instructure/ui-view';
|
|
35
34
|
import { testable } from '@instructure/ui-testable';
|
|
36
|
-
import { withStyle
|
|
35
|
+
import { withStyle } from '@instructure/emotion';
|
|
37
36
|
import { CheckboxFacade } from './CheckboxFacade';
|
|
38
37
|
import { ToggleFacade } from './ToggleFacade';
|
|
39
38
|
import generateStyle from './styles';
|
|
40
39
|
import generateComponentTheme from './theme';
|
|
41
40
|
import { propTypes, allowedProps } from './props';
|
|
41
|
+
import { jsxs as _jsxs, jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
42
42
|
/**
|
|
43
43
|
---
|
|
44
44
|
category: components
|
|
@@ -161,7 +161,7 @@ let Checkbox = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
|
|
|
161
161
|
focused = _this$state.focused;
|
|
162
162
|
error(!(variant === 'simple' && labelPlacement !== 'end'), `[Checkbox] The \`simple\` variant does not support the \`labelPlacement\` property. Use the \`toggle\` variant instead.`);
|
|
163
163
|
if (variant === 'toggle') {
|
|
164
|
-
return
|
|
164
|
+
return _jsxs(ToggleFacade, {
|
|
165
165
|
disabled: disabled,
|
|
166
166
|
size: size,
|
|
167
167
|
focused: focused,
|
|
@@ -169,24 +169,28 @@ let Checkbox = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
|
|
|
169
169
|
readOnly: readOnly,
|
|
170
170
|
labelPlacement: labelPlacement,
|
|
171
171
|
themeOverride: themeOverride,
|
|
172
|
-
invalid: this.invalid
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
172
|
+
invalid: this.invalid,
|
|
173
|
+
children: [label, isRequired && label && _jsxs("span", {
|
|
174
|
+
css: this.invalid ? styles === null || styles === void 0 ? void 0 : styles.requiredInvalid : {},
|
|
175
|
+
"aria-hidden": true,
|
|
176
|
+
children: [' ', "*"]
|
|
177
|
+
})]
|
|
178
|
+
});
|
|
177
179
|
} else {
|
|
178
|
-
return
|
|
180
|
+
return _jsxs(CheckboxFacade, {
|
|
179
181
|
size: size,
|
|
180
182
|
hovered: hovered,
|
|
181
183
|
focused: focused,
|
|
182
184
|
checked: this.checked,
|
|
183
185
|
indeterminate: indeterminate,
|
|
184
186
|
themeOverride: themeOverride,
|
|
185
|
-
invalid: this.invalid
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
187
|
+
invalid: this.invalid,
|
|
188
|
+
children: [label, isRequired && label && _jsxs("span", {
|
|
189
|
+
css: this.invalid ? styles === null || styles === void 0 ? void 0 : styles.requiredInvalid : {},
|
|
190
|
+
"aria-hidden": true,
|
|
191
|
+
children: [' ', "*"]
|
|
192
|
+
})]
|
|
193
|
+
});
|
|
190
194
|
}
|
|
191
195
|
}
|
|
192
196
|
renderMessages() {
|
|
@@ -194,13 +198,14 @@ let Checkbox = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
|
|
|
194
198
|
messages = _this$props5.messages,
|
|
195
199
|
styles = _this$props5.styles,
|
|
196
200
|
variant = _this$props5.variant;
|
|
197
|
-
return messages && messages.length > 0 ?
|
|
201
|
+
return messages && messages.length > 0 ? _jsx(View, {
|
|
198
202
|
display: "block",
|
|
199
203
|
margin: "small 0 0",
|
|
200
|
-
css: this.isNewError && (variant === 'toggle' ? styles === null || styles === void 0 ? void 0 : styles.indentedToggleError : styles === null || styles === void 0 ? void 0 : styles.indentedError)
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
+
css: this.isNewError && (variant === 'toggle' ? styles === null || styles === void 0 ? void 0 : styles.indentedToggleError : styles === null || styles === void 0 ? void 0 : styles.indentedError),
|
|
205
|
+
children: _jsx(FormFieldMessages, {
|
|
206
|
+
messages: messages
|
|
207
|
+
})
|
|
208
|
+
}) : null;
|
|
204
209
|
}
|
|
205
210
|
render() {
|
|
206
211
|
const _this$props6 = this.props,
|
|
@@ -218,35 +223,39 @@ let Checkbox = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
|
|
|
218
223
|
isRequired = _this$props6.isRequired;
|
|
219
224
|
const props = omitProps(this.props, Checkbox.allowedProps);
|
|
220
225
|
error(!(variant === 'toggle' && indeterminate), `[Checkbox] The \`toggle\` variant does not support the \`indeterminate\` property. Use the \`simple\` variant instead.`);
|
|
221
|
-
return
|
|
226
|
+
return _jsx("div", {
|
|
222
227
|
css: styles === null || styles === void 0 ? void 0 : styles.checkbox
|
|
223
228
|
/* eslint-disable-next-line jsx-a11y/mouse-events-have-key-events */,
|
|
224
229
|
onMouseOver: createChainedFunction(onMouseOver, this.handleMouseOver)
|
|
225
230
|
/* eslint-disable-next-line jsx-a11y/mouse-events-have-key-events */,
|
|
226
231
|
onMouseOut: createChainedFunction(onMouseOut, this.handleMouseOut),
|
|
227
|
-
ref: this.handleRef
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
232
|
+
ref: this.handleRef,
|
|
233
|
+
children: _jsxs("div", {
|
|
234
|
+
css: styles === null || styles === void 0 ? void 0 : styles.container,
|
|
235
|
+
children: [_jsx("input", {
|
|
236
|
+
...props,
|
|
237
|
+
id: this.id,
|
|
238
|
+
value: value,
|
|
239
|
+
type: "checkbox",
|
|
240
|
+
ref: c => {
|
|
241
|
+
this._input = c;
|
|
242
|
+
},
|
|
243
|
+
required: isRequired,
|
|
244
|
+
disabled: disabled || readOnly,
|
|
245
|
+
"aria-checked": indeterminate ? 'mixed' : void 0,
|
|
246
|
+
css: styles === null || styles === void 0 ? void 0 : styles.input,
|
|
247
|
+
onChange: this.handleChange,
|
|
248
|
+
onKeyDown: createChainedFunction(onKeyDown, this.handleKeyDown),
|
|
249
|
+
onFocus: createChainedFunction(onFocus, this.handleFocus),
|
|
250
|
+
onBlur: createChainedFunction(onBlur, this.handleBlur),
|
|
251
|
+
checked: this.checked
|
|
252
|
+
}), _jsxs("label", {
|
|
253
|
+
htmlFor: this.id,
|
|
254
|
+
css: styles === null || styles === void 0 ? void 0 : styles.control,
|
|
255
|
+
children: [this.renderFacade(), this.renderMessages()]
|
|
256
|
+
})]
|
|
257
|
+
})
|
|
258
|
+
});
|
|
250
259
|
}
|
|
251
260
|
}, _Checkbox.displayName = "Checkbox", _Checkbox.componentId = 'Checkbox', _Checkbox.propTypes = propTypes, _Checkbox.allowedProps = allowedProps, _Checkbox.defaultProps = {
|
|
252
261
|
size: 'medium',
|
|
@@ -23,7 +23,6 @@ var _Checkbox, _Checkbox2;
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
import React from 'react';
|
|
27
26
|
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
|
|
28
27
|
import { vi } from 'vitest';
|
|
29
28
|
import userEvent from '@testing-library/user-event';
|
|
@@ -31,6 +30,7 @@ import '@testing-library/jest-dom';
|
|
|
31
30
|
import { runAxeCheck } from '@instructure/ui-axe-check';
|
|
32
31
|
import { CheckboxGroup } from '../index';
|
|
33
32
|
import { Checkbox } from '../../Checkbox';
|
|
33
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
34
34
|
const TEST_NAME = 'test-name';
|
|
35
35
|
const TEST_DESCRIPTION = 'test-description';
|
|
36
36
|
const TEST_ERROR_MESSAGE = 'test-error-message';
|
|
@@ -44,13 +44,16 @@ const renderCheckboxGroup = props => {
|
|
|
44
44
|
description: TEST_DESCRIPTION,
|
|
45
45
|
...props
|
|
46
46
|
};
|
|
47
|
-
return render(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
return render(_jsxs(CheckboxGroup, {
|
|
48
|
+
...allProps,
|
|
49
|
+
children: [_Checkbox || (_Checkbox = _jsx(Checkbox, {
|
|
50
|
+
label: TEST_LABEL_1,
|
|
51
|
+
value: TEST_VALUE_1
|
|
52
|
+
})), _Checkbox2 || (_Checkbox2 = _jsx(Checkbox, {
|
|
53
|
+
label: TEST_LABEL_2,
|
|
54
|
+
value: TEST_VALUE_2
|
|
55
|
+
}))]
|
|
56
|
+
}));
|
|
54
57
|
};
|
|
55
58
|
describe('<CheckboxGroup />', () => {
|
|
56
59
|
let consoleWarningMock;
|
|
@@ -23,12 +23,13 @@ var _dec, _dec2, _class, _CheckboxGroup;
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
import
|
|
26
|
+
import { Children, Component } from 'react';
|
|
27
27
|
import { FormFieldGroup } from '@instructure/ui-form-field';
|
|
28
28
|
import { matchComponentTypes, safeCloneElement, pickProps, omitProps, withDeterministicId } from '@instructure/ui-react-utils';
|
|
29
29
|
import { testable } from '@instructure/ui-testable';
|
|
30
30
|
import { Checkbox } from '../Checkbox';
|
|
31
31
|
import { propTypes, allowedProps } from './props';
|
|
32
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
32
33
|
/**
|
|
33
34
|
---
|
|
34
35
|
category: components
|
|
@@ -102,13 +103,16 @@ let CheckboxGroup = (_dec = withDeterministicId(), _dec2 = testable(), _dec(_cla
|
|
|
102
103
|
});
|
|
103
104
|
}
|
|
104
105
|
render() {
|
|
105
|
-
return
|
|
106
|
+
return _jsx(FormFieldGroup, {
|
|
107
|
+
...omitProps(this.props, CheckboxGroup.allowedProps),
|
|
108
|
+
...pickProps(this.props, FormFieldGroup.allowedProps),
|
|
106
109
|
description: this.props.description,
|
|
107
110
|
rowSpacing: "small",
|
|
108
111
|
vAlign: "top",
|
|
109
112
|
messagesId: this._messagesId,
|
|
110
|
-
elementRef: this.handleRef
|
|
111
|
-
|
|
113
|
+
elementRef: this.handleRef,
|
|
114
|
+
children: this.renderChildren()
|
|
115
|
+
});
|
|
112
116
|
}
|
|
113
117
|
}, _CheckboxGroup.displayName = "CheckboxGroup", _CheckboxGroup.componentId = 'CheckboxGroup', _CheckboxGroup.propTypes = propTypes, _CheckboxGroup.allowedProps = allowedProps, _CheckboxGroup.defaultProps = {
|
|
114
118
|
disabled: false,
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var _react = _interopRequireDefault(require("react"));
|
|
5
|
-
var _react2 = require("@testing-library/react");
|
|
3
|
+
var _react = require("@testing-library/react");
|
|
6
4
|
var _vitest = require("vitest");
|
|
7
5
|
require("@testing-library/jest-dom");
|
|
8
6
|
var _runAxeCheck = require("@instructure/ui-axe-check/lib/runAxeCheck.js");
|
|
9
7
|
var _index = require("../index");
|
|
8
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
10
9
|
var _CheckboxFacade, _CheckboxFacade2;
|
|
11
10
|
/*
|
|
12
11
|
* The MIT License (MIT)
|
|
@@ -45,12 +44,16 @@ describe('<CheckboxFacade />', () => {
|
|
|
45
44
|
consoleErrorMock.mockRestore();
|
|
46
45
|
});
|
|
47
46
|
it('should render', () => {
|
|
48
|
-
(0,
|
|
49
|
-
|
|
47
|
+
(0, _react.render)(_CheckboxFacade || (_CheckboxFacade = (0, _jsxRuntime.jsx)(_index.CheckboxFacade, {
|
|
48
|
+
children: TEST_TEXT
|
|
49
|
+
})));
|
|
50
|
+
const facade = _react.screen.getByText(TEST_TEXT);
|
|
50
51
|
expect(facade).toBeInTheDocument();
|
|
51
52
|
});
|
|
52
53
|
it('should meet a11y standards', async () => {
|
|
53
|
-
const _render = (0,
|
|
54
|
+
const _render = (0, _react.render)(_CheckboxFacade2 || (_CheckboxFacade2 = (0, _jsxRuntime.jsx)(_index.CheckboxFacade, {
|
|
55
|
+
children: TEST_TEXT
|
|
56
|
+
}))),
|
|
54
57
|
container = _render.container;
|
|
55
58
|
const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container);
|
|
56
59
|
expect(axeCheck).toBe(true);
|
|
@@ -12,6 +12,7 @@ var _emotion = require("@instructure/emotion");
|
|
|
12
12
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
13
13
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
14
14
|
var _props = require("./props");
|
|
15
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
15
16
|
var _dec, _class, _CheckboxFacade, _SVGIcon, _IconCheckMarkSolid;
|
|
16
17
|
/*
|
|
17
18
|
* The MIT License (MIT)
|
|
@@ -36,7 +37,6 @@ var _dec, _class, _CheckboxFacade, _SVGIcon, _IconCheckMarkSolid;
|
|
|
36
37
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
37
38
|
* SOFTWARE.
|
|
38
39
|
*/
|
|
39
|
-
/** @jsx jsx */
|
|
40
40
|
/**
|
|
41
41
|
---
|
|
42
42
|
parent: Checkbox
|
|
@@ -60,17 +60,18 @@ let CheckboxFacade = exports.CheckboxFacade = (_dec = (0, _emotion.withStyle)(_s
|
|
|
60
60
|
}
|
|
61
61
|
renderIcon() {
|
|
62
62
|
if (this.props.indeterminate) {
|
|
63
|
-
return _SVGIcon || (_SVGIcon = (0,
|
|
63
|
+
return _SVGIcon || (_SVGIcon = (0, _jsxRuntime.jsx)(_SVGIcon2.SVGIcon, {
|
|
64
64
|
viewBox: "0 0 1920 1920",
|
|
65
|
-
inline: false
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
65
|
+
inline: false,
|
|
66
|
+
children: (0, _jsxRuntime.jsx)("rect", {
|
|
67
|
+
x: "140",
|
|
68
|
+
y: "820",
|
|
69
|
+
width: "1640",
|
|
70
|
+
height: "280"
|
|
71
|
+
})
|
|
72
|
+
}));
|
|
72
73
|
} else if (this.props.checked) {
|
|
73
|
-
return _IconCheckMarkSolid || (_IconCheckMarkSolid = (0,
|
|
74
|
+
return _IconCheckMarkSolid || (_IconCheckMarkSolid = (0, _jsxRuntime.jsx)(_IconCheckMarkSolid2.IconCheckMarkSolid, {
|
|
74
75
|
inline: false
|
|
75
76
|
}));
|
|
76
77
|
} else {
|
|
@@ -81,15 +82,18 @@ let CheckboxFacade = exports.CheckboxFacade = (_dec = (0, _emotion.withStyle)(_s
|
|
|
81
82
|
const _this$props3 = this.props,
|
|
82
83
|
children = _this$props3.children,
|
|
83
84
|
styles = _this$props3.styles;
|
|
84
|
-
return (0,
|
|
85
|
+
return (0, _jsxRuntime.jsxs)("span", {
|
|
85
86
|
css: styles === null || styles === void 0 ? void 0 : styles.checkboxFacade,
|
|
86
|
-
ref: this.handleRef
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
87
|
+
ref: this.handleRef,
|
|
88
|
+
children: [(0, _jsxRuntime.jsx)("span", {
|
|
89
|
+
css: styles === null || styles === void 0 ? void 0 : styles.facade,
|
|
90
|
+
"aria-hidden": "true",
|
|
91
|
+
children: this.renderIcon()
|
|
92
|
+
}), (0, _jsxRuntime.jsx)("span", {
|
|
93
|
+
css: styles === null || styles === void 0 ? void 0 : styles.label,
|
|
94
|
+
children: children
|
|
95
|
+
})]
|
|
96
|
+
});
|
|
93
97
|
}
|
|
94
98
|
}, _CheckboxFacade.displayName = "CheckboxFacade", _CheckboxFacade.componentId = 'CheckboxFacade', _CheckboxFacade.propTypes = _props.propTypes, _CheckboxFacade.allowedProps = _props.allowedProps, _CheckboxFacade.defaultProps = {
|
|
95
99
|
checked: false,
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var _react = _interopRequireDefault(require("react"));
|
|
5
|
-
var _react2 = require("@testing-library/react");
|
|
3
|
+
var _react = require("@testing-library/react");
|
|
6
4
|
var _vitest = require("vitest");
|
|
7
5
|
require("@testing-library/jest-dom");
|
|
8
6
|
var _runAxeCheck = require("@instructure/ui-axe-check/lib/runAxeCheck.js");
|
|
9
7
|
var _index = require("../index");
|
|
8
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
10
9
|
var _ToggleFacade, _ToggleFacade2;
|
|
11
10
|
/*
|
|
12
11
|
* The MIT License (MIT)
|
|
@@ -45,12 +44,16 @@ describe('<ToggleFacade />', () => {
|
|
|
45
44
|
consoleErrorMock.mockRestore();
|
|
46
45
|
});
|
|
47
46
|
it('should render', () => {
|
|
48
|
-
(0,
|
|
49
|
-
|
|
47
|
+
(0, _react.render)(_ToggleFacade || (_ToggleFacade = (0, _jsxRuntime.jsx)(_index.ToggleFacade, {
|
|
48
|
+
children: TEST_TEXT
|
|
49
|
+
})));
|
|
50
|
+
const facade = _react.screen.getByText(TEST_TEXT);
|
|
50
51
|
expect(facade).toBeInTheDocument();
|
|
51
52
|
});
|
|
52
53
|
it('should meet a11y standards', async () => {
|
|
53
|
-
const _render = (0,
|
|
54
|
+
const _render = (0, _react.render)(_ToggleFacade2 || (_ToggleFacade2 = (0, _jsxRuntime.jsx)(_index.ToggleFacade, {
|
|
55
|
+
children: TEST_TEXT
|
|
56
|
+
}))),
|
|
54
57
|
container = _render.container;
|
|
55
58
|
const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container);
|
|
56
59
|
expect(axeCheck).toBe(true);
|