@instructure/ui-checkbox 10.19.2-snapshot-0 → 10.19.2-snapshot-2
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 +5 -2
- package/es/Checkbox/__new-tests__/Checkbox.test.js +8 -0
- package/es/Checkbox/index.js +7 -3
- package/es/Checkbox/props.js +3 -2
- package/lib/Checkbox/__new-tests__/Checkbox.test.js +8 -0
- package/lib/Checkbox/index.js +7 -3
- package/lib/Checkbox/props.js +3 -2
- package/package.json +19 -19
- package/src/Checkbox/__new-tests__/Checkbox.test.tsx +8 -0
- package/src/Checkbox/index.tsx +8 -3
- package/src/Checkbox/props.ts +8 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Checkbox/index.d.ts +3 -0
- package/types/Checkbox/index.d.ts.map +1 -1
- package/types/Checkbox/props.d.ts +4 -0
- package/types/Checkbox/props.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,9 +3,12 @@
|
|
|
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.19.2-snapshot-
|
|
6
|
+
## [10.19.2-snapshot-2](https://github.com/instructure/instructure-ui/compare/v10.19.1...v10.19.2-snapshot-2) (2025-06-11)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **many:** add missing inputRef prop to input components ([e1158fb](https://github.com/instructure/instructure-ui/commit/e1158fb7af5426e6ce13efe197c2148e1c5f15f0))
|
|
9
12
|
|
|
10
13
|
|
|
11
14
|
|
|
@@ -91,6 +91,14 @@ describe('<Checkbox />', () => {
|
|
|
91
91
|
expect(inputElem).toBeInTheDocument();
|
|
92
92
|
expect(inputElem).toHaveAttribute('aria-checked', 'mixed');
|
|
93
93
|
});
|
|
94
|
+
it('should provide an inputRef prop', async () => {
|
|
95
|
+
const inputRef = vi.fn();
|
|
96
|
+
renderCheckbox({
|
|
97
|
+
inputRef
|
|
98
|
+
});
|
|
99
|
+
const input = screen.getByRole('checkbox');
|
|
100
|
+
expect(inputRef).toHaveBeenCalledWith(input);
|
|
101
|
+
});
|
|
94
102
|
describe('events', () => {
|
|
95
103
|
it('when clicked, fires onClick and onChange events', async () => {
|
|
96
104
|
const onClick = vi.fn();
|
package/es/Checkbox/index.js
CHANGED
|
@@ -54,6 +54,12 @@ let Checkbox = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
|
|
|
54
54
|
this.handleRef = el => {
|
|
55
55
|
this.ref = el;
|
|
56
56
|
};
|
|
57
|
+
this.handleInputRef = el => {
|
|
58
|
+
this._input = el;
|
|
59
|
+
if (typeof this.props.inputRef === 'function') {
|
|
60
|
+
this.props.inputRef(el);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
57
63
|
this.handleChange = e => {
|
|
58
64
|
const _this$props = this.props,
|
|
59
65
|
onChange = _this$props.onChange,
|
|
@@ -237,9 +243,7 @@ let Checkbox = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle, g
|
|
|
237
243
|
id: this.id,
|
|
238
244
|
value: value,
|
|
239
245
|
type: "checkbox",
|
|
240
|
-
ref:
|
|
241
|
-
this._input = c;
|
|
242
|
-
},
|
|
246
|
+
ref: this.handleInputRef,
|
|
243
247
|
required: isRequired,
|
|
244
248
|
disabled: disabled || readOnly,
|
|
245
249
|
"aria-checked": indeterminate ? 'mixed' : void 0,
|
package/es/Checkbox/props.js
CHANGED
|
@@ -45,7 +45,8 @@ const propTypes = {
|
|
|
45
45
|
variant: PropTypes.oneOf(['simple', 'toggle']),
|
|
46
46
|
inline: PropTypes.bool,
|
|
47
47
|
labelPlacement: PropTypes.oneOf(['top', 'start', 'end']),
|
|
48
|
-
isRequired: PropTypes.bool
|
|
48
|
+
isRequired: PropTypes.bool,
|
|
49
|
+
inputRef: PropTypes.func
|
|
49
50
|
};
|
|
50
|
-
const allowedProps = ['label', 'id', 'value', 'messages', 'defaultChecked', 'checked', 'onChange', 'onKeyDown', 'onFocus', 'onBlur', 'onMouseOver', 'onMouseOut', 'disabled', 'readOnly', 'indeterminate', 'size', 'variant', 'inline', 'labelPlacement', 'isRequired'];
|
|
51
|
+
const allowedProps = ['label', 'id', 'value', 'messages', 'defaultChecked', 'checked', 'onChange', 'onKeyDown', 'onFocus', 'onBlur', 'onMouseOver', 'onMouseOut', 'disabled', 'readOnly', 'indeterminate', 'size', 'variant', 'inline', 'labelPlacement', 'isRequired', 'inputRef'];
|
|
51
52
|
export { propTypes, allowedProps };
|
|
@@ -94,6 +94,14 @@ describe('<Checkbox />', () => {
|
|
|
94
94
|
expect(inputElem).toBeInTheDocument();
|
|
95
95
|
expect(inputElem).toHaveAttribute('aria-checked', 'mixed');
|
|
96
96
|
});
|
|
97
|
+
it('should provide an inputRef prop', async () => {
|
|
98
|
+
const inputRef = _vitest.vi.fn();
|
|
99
|
+
renderCheckbox({
|
|
100
|
+
inputRef
|
|
101
|
+
});
|
|
102
|
+
const input = _react2.screen.getByRole('checkbox');
|
|
103
|
+
expect(inputRef).toHaveBeenCalledWith(input);
|
|
104
|
+
});
|
|
97
105
|
describe('events', () => {
|
|
98
106
|
it('when clicked, fires onClick and onChange events', async () => {
|
|
99
107
|
const onClick = _vitest.vi.fn();
|
package/lib/Checkbox/index.js
CHANGED
|
@@ -74,6 +74,12 @@ let Checkbox = exports.Checkbox = (_dec = (0, _withDeterministicId.withDetermini
|
|
|
74
74
|
this.handleRef = el => {
|
|
75
75
|
this.ref = el;
|
|
76
76
|
};
|
|
77
|
+
this.handleInputRef = el => {
|
|
78
|
+
this._input = el;
|
|
79
|
+
if (typeof this.props.inputRef === 'function') {
|
|
80
|
+
this.props.inputRef(el);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
77
83
|
this.handleChange = e => {
|
|
78
84
|
const _this$props = this.props,
|
|
79
85
|
onChange = _this$props.onChange,
|
|
@@ -257,9 +263,7 @@ let Checkbox = exports.Checkbox = (_dec = (0, _withDeterministicId.withDetermini
|
|
|
257
263
|
id: this.id,
|
|
258
264
|
value: value,
|
|
259
265
|
type: "checkbox",
|
|
260
|
-
ref:
|
|
261
|
-
this._input = c;
|
|
262
|
-
},
|
|
266
|
+
ref: this.handleInputRef,
|
|
263
267
|
required: isRequired,
|
|
264
268
|
disabled: disabled || readOnly,
|
|
265
269
|
"aria-checked": indeterminate ? 'mixed' : void 0,
|
package/lib/Checkbox/props.js
CHANGED
|
@@ -52,6 +52,7 @@ const propTypes = exports.propTypes = {
|
|
|
52
52
|
variant: _propTypes.default.oneOf(['simple', 'toggle']),
|
|
53
53
|
inline: _propTypes.default.bool,
|
|
54
54
|
labelPlacement: _propTypes.default.oneOf(['top', 'start', 'end']),
|
|
55
|
-
isRequired: _propTypes.default.bool
|
|
55
|
+
isRequired: _propTypes.default.bool,
|
|
56
|
+
inputRef: _propTypes.default.func
|
|
56
57
|
};
|
|
57
|
-
const allowedProps = exports.allowedProps = ['label', 'id', 'value', 'messages', 'defaultChecked', 'checked', 'onChange', 'onKeyDown', 'onFocus', 'onBlur', 'onMouseOver', 'onMouseOut', 'disabled', 'readOnly', 'indeterminate', 'size', 'variant', 'inline', 'labelPlacement', 'isRequired'];
|
|
58
|
+
const allowedProps = exports.allowedProps = ['label', 'id', 'value', 'messages', 'defaultChecked', 'checked', 'onChange', 'onKeyDown', 'onFocus', 'onBlur', 'onMouseOver', 'onMouseOut', 'disabled', 'readOnly', 'indeterminate', 'size', 'variant', 'inline', 'labelPlacement', 'isRequired', 'inputRef'];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-checkbox",
|
|
3
|
-
"version": "10.19.2-snapshot-
|
|
3
|
+
"version": "10.19.2-snapshot-2",
|
|
4
4
|
"description": " styled HTML input type='checkbox' component.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -24,28 +24,28 @@
|
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@babel/runtime": "^7.26.0",
|
|
27
|
-
"@instructure/console": "10.19.2-snapshot-
|
|
28
|
-
"@instructure/emotion": "10.19.2-snapshot-
|
|
29
|
-
"@instructure/shared-types": "10.19.2-snapshot-
|
|
30
|
-
"@instructure/ui-dom-utils": "10.19.2-snapshot-
|
|
31
|
-
"@instructure/ui-form-field": "10.19.2-snapshot-
|
|
32
|
-
"@instructure/ui-icons": "10.19.2-snapshot-
|
|
33
|
-
"@instructure/ui-prop-types": "10.19.2-snapshot-
|
|
34
|
-
"@instructure/ui-react-utils": "10.19.2-snapshot-
|
|
35
|
-
"@instructure/ui-svg-images": "10.19.2-snapshot-
|
|
36
|
-
"@instructure/ui-testable": "10.19.2-snapshot-
|
|
37
|
-
"@instructure/ui-utils": "10.19.2-snapshot-
|
|
38
|
-
"@instructure/ui-view": "10.19.2-snapshot-
|
|
39
|
-
"@instructure/uid": "10.19.2-snapshot-
|
|
27
|
+
"@instructure/console": "10.19.2-snapshot-2",
|
|
28
|
+
"@instructure/emotion": "10.19.2-snapshot-2",
|
|
29
|
+
"@instructure/shared-types": "10.19.2-snapshot-2",
|
|
30
|
+
"@instructure/ui-dom-utils": "10.19.2-snapshot-2",
|
|
31
|
+
"@instructure/ui-form-field": "10.19.2-snapshot-2",
|
|
32
|
+
"@instructure/ui-icons": "10.19.2-snapshot-2",
|
|
33
|
+
"@instructure/ui-prop-types": "10.19.2-snapshot-2",
|
|
34
|
+
"@instructure/ui-react-utils": "10.19.2-snapshot-2",
|
|
35
|
+
"@instructure/ui-svg-images": "10.19.2-snapshot-2",
|
|
36
|
+
"@instructure/ui-testable": "10.19.2-snapshot-2",
|
|
37
|
+
"@instructure/ui-utils": "10.19.2-snapshot-2",
|
|
38
|
+
"@instructure/ui-view": "10.19.2-snapshot-2",
|
|
39
|
+
"@instructure/uid": "10.19.2-snapshot-2",
|
|
40
40
|
"keycode": "^2",
|
|
41
41
|
"prop-types": "^15.8.1"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@instructure/ui-axe-check": "10.19.2-snapshot-
|
|
45
|
-
"@instructure/ui-babel-preset": "10.19.2-snapshot-
|
|
46
|
-
"@instructure/ui-color-utils": "10.19.2-snapshot-
|
|
47
|
-
"@instructure/ui-test-utils": "10.19.2-snapshot-
|
|
48
|
-
"@instructure/ui-themes": "10.19.2-snapshot-
|
|
44
|
+
"@instructure/ui-axe-check": "10.19.2-snapshot-2",
|
|
45
|
+
"@instructure/ui-babel-preset": "10.19.2-snapshot-2",
|
|
46
|
+
"@instructure/ui-color-utils": "10.19.2-snapshot-2",
|
|
47
|
+
"@instructure/ui-test-utils": "10.19.2-snapshot-2",
|
|
48
|
+
"@instructure/ui-themes": "10.19.2-snapshot-2",
|
|
49
49
|
"@testing-library/jest-dom": "^6.6.3",
|
|
50
50
|
"@testing-library/react": "^16.0.1",
|
|
51
51
|
"@testing-library/user-event": "^14.5.2",
|
|
@@ -105,6 +105,14 @@ describe('<Checkbox />', () => {
|
|
|
105
105
|
expect(inputElem).toHaveAttribute('aria-checked', 'mixed')
|
|
106
106
|
})
|
|
107
107
|
|
|
108
|
+
it('should provide an inputRef prop', async () => {
|
|
109
|
+
const inputRef = vi.fn()
|
|
110
|
+
renderCheckbox({ inputRef })
|
|
111
|
+
const input = screen.getByRole('checkbox')
|
|
112
|
+
|
|
113
|
+
expect(inputRef).toHaveBeenCalledWith(input)
|
|
114
|
+
})
|
|
115
|
+
|
|
108
116
|
describe('events', () => {
|
|
109
117
|
it('when clicked, fires onClick and onChange events', async () => {
|
|
110
118
|
const onClick = vi.fn()
|
package/src/Checkbox/index.tsx
CHANGED
|
@@ -102,6 +102,13 @@ class Checkbox extends Component<CheckboxProps, CheckboxState> {
|
|
|
102
102
|
this.ref = el
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
+
handleInputRef = (el: HTMLInputElement | null) => {
|
|
106
|
+
this._input = el
|
|
107
|
+
if (typeof this.props.inputRef === 'function') {
|
|
108
|
+
this.props.inputRef(el)
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
105
112
|
componentDidMount() {
|
|
106
113
|
if (this._input) {
|
|
107
114
|
this._input.indeterminate = this.props.indeterminate!
|
|
@@ -323,9 +330,7 @@ class Checkbox extends Component<CheckboxProps, CheckboxState> {
|
|
|
323
330
|
id={this.id}
|
|
324
331
|
value={value}
|
|
325
332
|
type="checkbox"
|
|
326
|
-
ref={
|
|
327
|
-
this._input = c
|
|
328
|
-
}}
|
|
333
|
+
ref={this.handleInputRef}
|
|
329
334
|
required={isRequired}
|
|
330
335
|
disabled={disabled || readOnly}
|
|
331
336
|
aria-checked={indeterminate ? 'mixed' : undefined}
|
package/src/Checkbox/props.ts
CHANGED
|
@@ -80,6 +80,10 @@ type CheckboxOwnProps = {
|
|
|
80
80
|
inline?: boolean
|
|
81
81
|
labelPlacement?: 'top' | 'start' | 'end'
|
|
82
82
|
isRequired?: boolean
|
|
83
|
+
/**
|
|
84
|
+
* A function that provides a reference to the actual underlying input element
|
|
85
|
+
*/
|
|
86
|
+
inputRef?: (inputElement: HTMLInputElement | null) => void
|
|
83
87
|
}
|
|
84
88
|
|
|
85
89
|
type PropKeys = keyof CheckboxOwnProps
|
|
@@ -121,7 +125,8 @@ const propTypes: PropValidators<PropKeys> = {
|
|
|
121
125
|
variant: PropTypes.oneOf(['simple', 'toggle']),
|
|
122
126
|
inline: PropTypes.bool,
|
|
123
127
|
labelPlacement: PropTypes.oneOf(['top', 'start', 'end']),
|
|
124
|
-
isRequired: PropTypes.bool
|
|
128
|
+
isRequired: PropTypes.bool,
|
|
129
|
+
inputRef: PropTypes.func
|
|
125
130
|
}
|
|
126
131
|
|
|
127
132
|
const allowedProps: AllowedPropKeys = [
|
|
@@ -144,7 +149,8 @@ const allowedProps: AllowedPropKeys = [
|
|
|
144
149
|
'variant',
|
|
145
150
|
'inline',
|
|
146
151
|
'labelPlacement',
|
|
147
|
-
'isRequired'
|
|
152
|
+
'isRequired',
|
|
153
|
+
'inputRef'
|
|
148
154
|
]
|
|
149
155
|
|
|
150
156
|
type CheckboxState = {
|