@instructure/ui-checkbox 11.6.0 → 11.6.1-snapshot-129
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 +44 -297
- package/es/Checkbox/{CheckboxFacade → v1/CheckboxFacade}/index.js +1 -1
- package/es/Checkbox/{ToggleFacade → v1/ToggleFacade}/index.js +1 -1
- package/es/Checkbox/{index.js → v1/index.js} +3 -3
- package/es/Checkbox/v2/CheckboxFacade/index.js +104 -0
- package/es/Checkbox/v2/CheckboxFacade/props.js +26 -0
- package/es/Checkbox/v2/CheckboxFacade/styles.js +177 -0
- package/es/Checkbox/v2/ToggleFacade/index.js +116 -0
- package/es/Checkbox/v2/ToggleFacade/props.js +26 -0
- package/es/Checkbox/v2/ToggleFacade/styles.js +232 -0
- package/es/Checkbox/v2/index.js +289 -0
- package/es/Checkbox/v2/props.js +26 -0
- package/es/Checkbox/v2/styles.js +102 -0
- package/es/CheckboxGroup/{index.js → v1/index.js} +2 -2
- package/es/CheckboxGroup/v2/index.js +125 -0
- package/es/CheckboxGroup/v2/props.js +26 -0
- package/es/{index.js → exports/a.js} +2 -2
- package/es/exports/b.js +25 -0
- package/lib/Checkbox/{CheckboxFacade → v1/CheckboxFacade}/index.js +2 -2
- package/lib/Checkbox/{ToggleFacade → v1/ToggleFacade}/index.js +3 -3
- package/lib/Checkbox/{index.js → v1/index.js} +5 -5
- package/lib/Checkbox/v2/CheckboxFacade/index.js +109 -0
- package/lib/Checkbox/v2/CheckboxFacade/props.js +31 -0
- package/lib/Checkbox/v2/CheckboxFacade/styles.js +183 -0
- package/lib/Checkbox/v2/ToggleFacade/index.js +121 -0
- package/lib/Checkbox/v2/ToggleFacade/props.js +31 -0
- package/lib/Checkbox/v2/ToggleFacade/styles.js +238 -0
- package/lib/Checkbox/v2/index.js +308 -0
- package/lib/Checkbox/v2/props.js +31 -0
- package/lib/Checkbox/v2/styles.js +108 -0
- package/lib/CheckboxGroup/{index.js → v1/index.js} +5 -5
- package/lib/CheckboxGroup/v2/index.js +133 -0
- package/lib/CheckboxGroup/v2/props.js +31 -0
- package/lib/{index.js → exports/a.js} +6 -6
- package/lib/exports/b.js +31 -0
- package/package.json +45 -23
- package/src/Checkbox/{CheckboxFacade → v1/CheckboxFacade}/index.tsx +1 -1
- package/src/Checkbox/{CheckboxFacade → v1/CheckboxFacade}/styles.ts +3 -1
- package/src/Checkbox/{ToggleFacade → v1/ToggleFacade}/index.tsx +1 -1
- package/src/Checkbox/{index.tsx → v1/index.tsx} +3 -3
- package/src/Checkbox/{props.ts → v1/props.ts} +1 -1
- package/src/Checkbox/{styles.ts → v1/styles.ts} +1 -1
- package/src/Checkbox/{theme.ts → v1/theme.ts} +1 -1
- package/src/Checkbox/v2/CheckboxFacade/index.tsx +113 -0
- package/src/Checkbox/v2/CheckboxFacade/props.ts +67 -0
- package/src/Checkbox/v2/CheckboxFacade/styles.ts +209 -0
- package/src/Checkbox/v2/README.md +193 -0
- package/src/Checkbox/v2/ToggleFacade/index.tsx +124 -0
- package/src/Checkbox/v2/ToggleFacade/props.ts +67 -0
- package/src/Checkbox/v2/ToggleFacade/styles.ts +301 -0
- package/src/Checkbox/v2/index.tsx +376 -0
- package/src/Checkbox/v2/props.ts +132 -0
- package/src/Checkbox/v2/styles.ts +118 -0
- package/src/CheckboxGroup/{index.tsx → v1/index.tsx} +2 -2
- package/src/CheckboxGroup/{props.ts → v1/props.ts} +3 -3
- package/src/CheckboxGroup/v2/README.md +111 -0
- package/src/CheckboxGroup/v2/index.tsx +157 -0
- package/src/CheckboxGroup/v2/props.ts +77 -0
- package/src/{index.ts → exports/a.ts} +6 -6
- package/src/exports/b.ts +30 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Checkbox/v1/CheckboxFacade/index.d.ts.map +1 -0
- package/types/Checkbox/v1/CheckboxFacade/props.d.ts.map +1 -0
- package/types/Checkbox/v1/CheckboxFacade/styles.d.ts.map +1 -0
- package/types/Checkbox/v1/CheckboxFacade/theme.d.ts.map +1 -0
- package/types/Checkbox/v1/ToggleFacade/index.d.ts.map +1 -0
- package/types/Checkbox/v1/ToggleFacade/props.d.ts.map +1 -0
- package/types/Checkbox/v1/ToggleFacade/styles.d.ts.map +1 -0
- package/types/Checkbox/v1/ToggleFacade/theme.d.ts.map +1 -0
- package/types/Checkbox/{index.d.ts → v1/index.d.ts} +1 -1
- package/types/Checkbox/v1/index.d.ts.map +1 -0
- package/types/Checkbox/{props.d.ts → v1/props.d.ts} +1 -1
- package/types/Checkbox/v1/props.d.ts.map +1 -0
- package/types/Checkbox/v1/styles.d.ts.map +1 -0
- package/types/Checkbox/v1/theme.d.ts.map +1 -0
- package/types/Checkbox/v2/CheckboxFacade/index.d.ts +39 -0
- package/types/Checkbox/v2/CheckboxFacade/index.d.ts.map +1 -0
- package/types/Checkbox/v2/CheckboxFacade/props.d.ts +27 -0
- package/types/Checkbox/v2/CheckboxFacade/props.d.ts.map +1 -0
- package/types/Checkbox/v2/CheckboxFacade/styles.d.ts +16 -0
- package/types/Checkbox/v2/CheckboxFacade/styles.d.ts.map +1 -0
- package/types/Checkbox/v2/ToggleFacade/index.d.ts +40 -0
- package/types/Checkbox/v2/ToggleFacade/index.d.ts.map +1 -0
- package/types/Checkbox/v2/ToggleFacade/props.d.ts +25 -0
- package/types/Checkbox/v2/ToggleFacade/props.d.ts.map +1 -0
- package/types/Checkbox/v2/ToggleFacade/styles.d.ts +16 -0
- package/types/Checkbox/v2/ToggleFacade/styles.d.ts.map +1 -0
- package/types/Checkbox/v2/index.d.ts +71 -0
- package/types/Checkbox/v2/index.d.ts.map +1 -0
- package/types/Checkbox/v2/props.d.ts +64 -0
- package/types/Checkbox/v2/props.d.ts.map +1 -0
- package/types/Checkbox/v2/styles.d.ts +16 -0
- package/types/Checkbox/v2/styles.d.ts.map +1 -0
- package/types/CheckboxGroup/{index.d.ts → v1/index.d.ts} +1 -1
- package/types/CheckboxGroup/v1/index.d.ts.map +1 -0
- package/types/CheckboxGroup/{props.d.ts → v1/props.d.ts} +3 -3
- package/types/CheckboxGroup/v1/props.d.ts.map +1 -0
- package/types/CheckboxGroup/v2/index.d.ts +42 -0
- package/types/CheckboxGroup/v2/index.d.ts.map +1 -0
- package/types/CheckboxGroup/v2/props.d.ts +30 -0
- package/types/CheckboxGroup/v2/props.d.ts.map +1 -0
- package/types/exports/a.d.ts +7 -0
- package/types/exports/a.d.ts.map +1 -0
- package/types/exports/b.d.ts +7 -0
- package/types/exports/b.d.ts.map +1 -0
- package/types/Checkbox/CheckboxFacade/index.d.ts.map +0 -1
- package/types/Checkbox/CheckboxFacade/props.d.ts.map +0 -1
- package/types/Checkbox/CheckboxFacade/styles.d.ts.map +0 -1
- package/types/Checkbox/CheckboxFacade/theme.d.ts.map +0 -1
- package/types/Checkbox/ToggleFacade/index.d.ts.map +0 -1
- package/types/Checkbox/ToggleFacade/props.d.ts.map +0 -1
- package/types/Checkbox/ToggleFacade/styles.d.ts.map +0 -1
- package/types/Checkbox/ToggleFacade/theme.d.ts.map +0 -1
- package/types/Checkbox/index.d.ts.map +0 -1
- package/types/Checkbox/props.d.ts.map +0 -1
- package/types/Checkbox/styles.d.ts.map +0 -1
- package/types/Checkbox/theme.d.ts.map +0 -1
- package/types/CheckboxGroup/index.d.ts.map +0 -1
- package/types/CheckboxGroup/props.d.ts.map +0 -1
- package/types/index.d.ts +0 -7
- package/types/index.d.ts.map +0 -1
- /package/es/Checkbox/{CheckboxFacade → v1/CheckboxFacade}/props.js +0 -0
- /package/es/Checkbox/{CheckboxFacade → v1/CheckboxFacade}/styles.js +0 -0
- /package/es/Checkbox/{CheckboxFacade → v1/CheckboxFacade}/theme.js +0 -0
- /package/es/Checkbox/{ToggleFacade → v1/ToggleFacade}/props.js +0 -0
- /package/es/Checkbox/{ToggleFacade → v1/ToggleFacade}/styles.js +0 -0
- /package/es/Checkbox/{ToggleFacade → v1/ToggleFacade}/theme.js +0 -0
- /package/es/Checkbox/{props.js → v1/props.js} +0 -0
- /package/es/Checkbox/{styles.js → v1/styles.js} +0 -0
- /package/es/Checkbox/{theme.js → v1/theme.js} +0 -0
- /package/es/CheckboxGroup/{props.js → v1/props.js} +0 -0
- /package/lib/Checkbox/{CheckboxFacade → v1/CheckboxFacade}/props.js +0 -0
- /package/lib/Checkbox/{CheckboxFacade → v1/CheckboxFacade}/styles.js +0 -0
- /package/lib/Checkbox/{CheckboxFacade → v1/CheckboxFacade}/theme.js +0 -0
- /package/lib/Checkbox/{ToggleFacade → v1/ToggleFacade}/props.js +0 -0
- /package/lib/Checkbox/{ToggleFacade → v1/ToggleFacade}/styles.js +0 -0
- /package/lib/Checkbox/{ToggleFacade → v1/ToggleFacade}/theme.js +0 -0
- /package/lib/Checkbox/{props.js → v1/props.js} +0 -0
- /package/lib/Checkbox/{styles.js → v1/styles.js} +0 -0
- /package/lib/Checkbox/{theme.js → v1/theme.js} +0 -0
- /package/lib/CheckboxGroup/{props.js → v1/props.js} +0 -0
- /package/src/Checkbox/{CheckboxFacade → v1/CheckboxFacade}/props.ts +0 -0
- /package/src/Checkbox/{CheckboxFacade → v1/CheckboxFacade}/theme.ts +0 -0
- /package/src/Checkbox/{README.md → v1/README.md} +0 -0
- /package/src/Checkbox/{ToggleFacade → v1/ToggleFacade}/props.ts +0 -0
- /package/src/Checkbox/{ToggleFacade → v1/ToggleFacade}/styles.ts +0 -0
- /package/src/Checkbox/{ToggleFacade → v1/ToggleFacade}/theme.ts +0 -0
- /package/src/CheckboxGroup/{README.md → v1/README.md} +0 -0
- /package/types/Checkbox/{CheckboxFacade → v1/CheckboxFacade}/index.d.ts +0 -0
- /package/types/Checkbox/{CheckboxFacade → v1/CheckboxFacade}/props.d.ts +0 -0
- /package/types/Checkbox/{CheckboxFacade → v1/CheckboxFacade}/styles.d.ts +0 -0
- /package/types/Checkbox/{CheckboxFacade → v1/CheckboxFacade}/theme.d.ts +0 -0
- /package/types/Checkbox/{ToggleFacade → v1/ToggleFacade}/index.d.ts +0 -0
- /package/types/Checkbox/{ToggleFacade → v1/ToggleFacade}/props.d.ts +0 -0
- /package/types/Checkbox/{ToggleFacade → v1/ToggleFacade}/styles.d.ts +0 -0
- /package/types/Checkbox/{ToggleFacade → v1/ToggleFacade}/theme.d.ts +0 -0
- /package/types/Checkbox/{styles.d.ts → v1/styles.d.ts} +0 -0
- /package/types/Checkbox/{theme.d.ts → v1/theme.d.ts} +0 -0
|
@@ -5,13 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.CheckboxGroup = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
|
-
var
|
|
8
|
+
var _v11_ = require("@instructure/ui-form-field/v11_6");
|
|
9
9
|
var _matchComponentTypes = require("@instructure/ui-react-utils/lib/matchComponentTypes.js");
|
|
10
10
|
var _safeCloneElement = require("@instructure/ui-react-utils/lib/safeCloneElement.js");
|
|
11
11
|
var _pickProps = require("@instructure/ui-react-utils/lib/pickProps.js");
|
|
12
12
|
var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
|
|
13
13
|
var _withDeterministicId = require("@instructure/ui-react-utils/lib/DeterministicIdContext/withDeterministicId.js");
|
|
14
|
-
var
|
|
14
|
+
var _v = require("../../Checkbox/v1");
|
|
15
15
|
var _props = require("./props");
|
|
16
16
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
17
17
|
var _dec, _class, _CheckboxGroup;
|
|
@@ -92,7 +92,7 @@ let CheckboxGroup = exports.CheckboxGroup = (_dec = (0, _withDeterministicId.wit
|
|
|
92
92
|
disabled = _this$props.disabled,
|
|
93
93
|
readOnly = _this$props.readOnly;
|
|
94
94
|
return _react.Children.map(children, child => {
|
|
95
|
-
if ((0, _matchComponentTypes.matchComponentTypes)(child, [
|
|
95
|
+
if ((0, _matchComponentTypes.matchComponentTypes)(child, [_v.Checkbox])) {
|
|
96
96
|
return (0, _safeCloneElement.safeCloneElement)(child, {
|
|
97
97
|
key: `${child.props.name}`,
|
|
98
98
|
name,
|
|
@@ -111,9 +111,9 @@ let CheckboxGroup = exports.CheckboxGroup = (_dec = (0, _withDeterministicId.wit
|
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
113
|
render() {
|
|
114
|
-
return (0, _jsxRuntime.jsx)(
|
|
114
|
+
return (0, _jsxRuntime.jsx)(_v11_.FormFieldGroup, {
|
|
115
115
|
...(0, _omitProps.omitProps)(this.props, CheckboxGroup.allowedProps),
|
|
116
|
-
...(0, _pickProps.pickProps)(this.props,
|
|
116
|
+
...(0, _pickProps.pickProps)(this.props, _v11_.FormFieldGroup.allowedProps),
|
|
117
117
|
description: this.props.description,
|
|
118
118
|
rowSpacing: "small",
|
|
119
119
|
vAlign: "top",
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.CheckboxGroup = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _latest = require("@instructure/ui-form-field/latest");
|
|
9
|
+
var _matchComponentTypes = require("@instructure/ui-react-utils/lib/matchComponentTypes.js");
|
|
10
|
+
var _safeCloneElement = require("@instructure/ui-react-utils/lib/safeCloneElement.js");
|
|
11
|
+
var _pickProps = require("@instructure/ui-react-utils/lib/pickProps.js");
|
|
12
|
+
var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
|
|
13
|
+
var _withDeterministicId = require("@instructure/ui-react-utils/lib/DeterministicIdContext/withDeterministicId.js");
|
|
14
|
+
var _v = require("../../Checkbox/v2");
|
|
15
|
+
var _props = require("./props");
|
|
16
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
17
|
+
var _dec, _class, _CheckboxGroup;
|
|
18
|
+
/*
|
|
19
|
+
* The MIT License (MIT)
|
|
20
|
+
*
|
|
21
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
22
|
+
*
|
|
23
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
24
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
25
|
+
* in the Software without restriction, including without limitation the rights
|
|
26
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
27
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
28
|
+
* furnished to do so, subject to the following conditions:
|
|
29
|
+
*
|
|
30
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
31
|
+
* copies or substantial portions of the Software.
|
|
32
|
+
*
|
|
33
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
34
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
35
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
36
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
37
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
38
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
39
|
+
* SOFTWARE.
|
|
40
|
+
*/
|
|
41
|
+
/**
|
|
42
|
+
---
|
|
43
|
+
category: components
|
|
44
|
+
---
|
|
45
|
+
**/
|
|
46
|
+
let CheckboxGroup = exports.CheckboxGroup = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec(_class = (_CheckboxGroup = class CheckboxGroup extends _react.Component {
|
|
47
|
+
constructor(props) {
|
|
48
|
+
super(props);
|
|
49
|
+
this._messagesId = void 0;
|
|
50
|
+
this.ref = null;
|
|
51
|
+
this.handleRef = el => {
|
|
52
|
+
this.ref = el;
|
|
53
|
+
};
|
|
54
|
+
this.handleChange = e => {
|
|
55
|
+
const newValue = this.value;
|
|
56
|
+
if (this.props.disabled || this.props.readOnly) {
|
|
57
|
+
e.preventDefault();
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (e.target.checked) {
|
|
61
|
+
newValue.push(e.target.value);
|
|
62
|
+
} else {
|
|
63
|
+
newValue.splice(newValue.indexOf(e.target.value), 1);
|
|
64
|
+
}
|
|
65
|
+
if (typeof this.props.value === 'undefined') {
|
|
66
|
+
this.setState({
|
|
67
|
+
value: newValue
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
if (typeof this.props.onChange === 'function') {
|
|
71
|
+
this.props.onChange(newValue);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
if (typeof props.value === 'undefined') {
|
|
75
|
+
this.state = {
|
|
76
|
+
value: props.defaultValue || []
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
this._messagesId = props.deterministicId();
|
|
80
|
+
}
|
|
81
|
+
get hasMessages() {
|
|
82
|
+
return this.props.messages && this.props.messages.length > 0;
|
|
83
|
+
}
|
|
84
|
+
get value() {
|
|
85
|
+
return typeof this.props.value === 'undefined' ? [...this.state.value] : [...this.props.value];
|
|
86
|
+
}
|
|
87
|
+
renderChildren() {
|
|
88
|
+
const _this$props = this.props,
|
|
89
|
+
children = _this$props.children,
|
|
90
|
+
name = _this$props.name,
|
|
91
|
+
size = _this$props.size,
|
|
92
|
+
disabled = _this$props.disabled,
|
|
93
|
+
readOnly = _this$props.readOnly;
|
|
94
|
+
return _react.Children.map(children, child => {
|
|
95
|
+
if ((0, _matchComponentTypes.matchComponentTypes)(child, [_v.Checkbox])) {
|
|
96
|
+
return (0, _safeCloneElement.safeCloneElement)(child, {
|
|
97
|
+
key: `${child.props.name}`,
|
|
98
|
+
name,
|
|
99
|
+
label: child.props.label,
|
|
100
|
+
disabled: disabled || child.props.disabled,
|
|
101
|
+
readOnly: readOnly || child.props.readOnly,
|
|
102
|
+
size,
|
|
103
|
+
checked: this.value.indexOf(child.props.value) > -1,
|
|
104
|
+
onChange: this.handleChange,
|
|
105
|
+
width: child.props.width || 'auto',
|
|
106
|
+
'aria-describedby': this.hasMessages ? this._messagesId : void 0
|
|
107
|
+
});
|
|
108
|
+
} else {
|
|
109
|
+
return child;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
render() {
|
|
114
|
+
return (0, _jsxRuntime.jsx)(_latest.FormFieldGroup, {
|
|
115
|
+
...(0, _omitProps.omitProps)(this.props, CheckboxGroup.allowedProps),
|
|
116
|
+
...(0, _pickProps.pickProps)(this.props, _latest.FormFieldGroup.allowedProps),
|
|
117
|
+
description: this.props.description,
|
|
118
|
+
rowSpacing: "small",
|
|
119
|
+
vAlign: "top",
|
|
120
|
+
messagesId: this._messagesId,
|
|
121
|
+
elementRef: this.handleRef,
|
|
122
|
+
"data-cid": "CheckboxGroup",
|
|
123
|
+
children: this.renderChildren()
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}, _CheckboxGroup.displayName = "CheckboxGroup", _CheckboxGroup.componentId = 'CheckboxGroup', _CheckboxGroup.allowedProps = _props.allowedProps, _CheckboxGroup.defaultProps = {
|
|
127
|
+
disabled: false,
|
|
128
|
+
readOnly: false,
|
|
129
|
+
size: 'medium',
|
|
130
|
+
layout: 'stacked',
|
|
131
|
+
children: null
|
|
132
|
+
}, _CheckboxGroup)) || _class);
|
|
133
|
+
var _default = exports.default = CheckboxGroup;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.allowedProps = void 0;
|
|
7
|
+
/*
|
|
8
|
+
* The MIT License (MIT)
|
|
9
|
+
*
|
|
10
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
11
|
+
*
|
|
12
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
* in the Software without restriction, including without limitation the rights
|
|
15
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
* furnished to do so, subject to the following conditions:
|
|
18
|
+
*
|
|
19
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
* copies or substantial portions of the Software.
|
|
21
|
+
*
|
|
22
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
* SOFTWARE.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
const allowedProps = exports.allowedProps = ['name', 'description', 'defaultValue', 'value', 'onChange', 'disabled', 'readOnly', 'messages', 'children', 'size', 'layout'];
|
|
@@ -6,26 +6,26 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
Object.defineProperty(exports, "Checkbox", {
|
|
7
7
|
enumerable: true,
|
|
8
8
|
get: function () {
|
|
9
|
-
return
|
|
9
|
+
return _v.Checkbox;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "CheckboxFacade", {
|
|
13
13
|
enumerable: true,
|
|
14
14
|
get: function () {
|
|
15
|
-
return
|
|
15
|
+
return _v.CheckboxFacade;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
18
|
Object.defineProperty(exports, "CheckboxGroup", {
|
|
19
19
|
enumerable: true,
|
|
20
20
|
get: function () {
|
|
21
|
-
return
|
|
21
|
+
return _v2.CheckboxGroup;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
Object.defineProperty(exports, "ToggleFacade", {
|
|
25
25
|
enumerable: true,
|
|
26
26
|
get: function () {
|
|
27
|
-
return
|
|
27
|
+
return _v.ToggleFacade;
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
|
-
var
|
|
31
|
-
var
|
|
30
|
+
var _v = require("../Checkbox/v1");
|
|
31
|
+
var _v2 = require("../CheckboxGroup/v1");
|
package/lib/exports/b.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "Checkbox", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _v.Checkbox;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "CheckboxFacade", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _v.CheckboxFacade;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "CheckboxGroup", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _v2.CheckboxGroup;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "ToggleFacade", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _v.ToggleFacade;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
var _v = require("../Checkbox/v2");
|
|
31
|
+
var _v2 = require("../CheckboxGroup/v2");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-checkbox",
|
|
3
|
-
"version": "11.6.
|
|
3
|
+
"version": "11.6.1-snapshot-129",
|
|
4
4
|
"description": " styled HTML input type='checkbox' component.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -16,27 +16,27 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@babel/runtime": "^7.27.6",
|
|
18
18
|
"keycode": "^2",
|
|
19
|
-
"@instructure/console": "11.6.
|
|
20
|
-
"@instructure/
|
|
21
|
-
"@instructure/
|
|
22
|
-
"@instructure/ui-dom-utils": "11.6.
|
|
23
|
-
"@instructure/ui-form-field": "11.6.
|
|
24
|
-
"@instructure/ui-
|
|
25
|
-
"@instructure/ui-
|
|
26
|
-
"@instructure/ui-
|
|
27
|
-
"@instructure/ui-view": "11.6.
|
|
28
|
-
"@instructure/uid": "11.6.
|
|
29
|
-
"@instructure/ui-
|
|
19
|
+
"@instructure/console": "11.6.1-snapshot-129",
|
|
20
|
+
"@instructure/shared-types": "11.6.1-snapshot-129",
|
|
21
|
+
"@instructure/emotion": "11.6.1-snapshot-129",
|
|
22
|
+
"@instructure/ui-dom-utils": "11.6.1-snapshot-129",
|
|
23
|
+
"@instructure/ui-form-field": "11.6.1-snapshot-129",
|
|
24
|
+
"@instructure/ui-icons": "11.6.1-snapshot-129",
|
|
25
|
+
"@instructure/ui-react-utils": "11.6.1-snapshot-129",
|
|
26
|
+
"@instructure/ui-svg-images": "11.6.1-snapshot-129",
|
|
27
|
+
"@instructure/ui-view": "11.6.1-snapshot-129",
|
|
28
|
+
"@instructure/uid": "11.6.1-snapshot-129",
|
|
29
|
+
"@instructure/ui-utils": "11.6.1-snapshot-129"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@testing-library/jest-dom": "^6.6.3",
|
|
33
33
|
"@testing-library/react": "15.0.7",
|
|
34
34
|
"@testing-library/user-event": "^14.6.1",
|
|
35
35
|
"vitest": "^3.2.2",
|
|
36
|
-
"@instructure/ui-babel-preset": "11.6.
|
|
37
|
-
"@instructure/ui-
|
|
38
|
-
"@instructure/ui-
|
|
39
|
-
"@instructure/ui-themes": "11.6.
|
|
36
|
+
"@instructure/ui-babel-preset": "11.6.1-snapshot-129",
|
|
37
|
+
"@instructure/ui-axe-check": "11.6.1-snapshot-129",
|
|
38
|
+
"@instructure/ui-color-utils": "11.6.1-snapshot-129",
|
|
39
|
+
"@instructure/ui-themes": "11.6.1-snapshot-129"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"react": ">=18 <=19"
|
|
@@ -46,17 +46,39 @@
|
|
|
46
46
|
},
|
|
47
47
|
"sideEffects": false,
|
|
48
48
|
"exports": {
|
|
49
|
-
".": {
|
|
50
|
-
"types": "./types/index.d.ts",
|
|
51
|
-
"import": "./es/index.js",
|
|
52
|
-
"require": "./lib/index.js",
|
|
53
|
-
"default": "./es/index.js"
|
|
54
|
-
},
|
|
55
49
|
"./lib/*": "./lib/*",
|
|
56
50
|
"./es/*": "./es/*",
|
|
57
51
|
"./types/*": "./types/*",
|
|
58
52
|
"./package.json": "./package.json",
|
|
59
|
-
"./src/*": "./src/*"
|
|
53
|
+
"./src/*": "./src/*",
|
|
54
|
+
".": {
|
|
55
|
+
"src": "./src/exports/a.ts",
|
|
56
|
+
"types": "./types/exports/a.d.ts",
|
|
57
|
+
"import": "./es/exports/a.js",
|
|
58
|
+
"require": "./lib/exports/a.js",
|
|
59
|
+
"default": "./es/exports/a.js"
|
|
60
|
+
},
|
|
61
|
+
"./v11_6": {
|
|
62
|
+
"src": "./src/exports/a.ts",
|
|
63
|
+
"types": "./types/exports/a.d.ts",
|
|
64
|
+
"import": "./es/exports/a.js",
|
|
65
|
+
"require": "./lib/exports/a.js",
|
|
66
|
+
"default": "./es/exports/a.js"
|
|
67
|
+
},
|
|
68
|
+
"./v11_7": {
|
|
69
|
+
"src": "./src/exports/b.ts",
|
|
70
|
+
"types": "./types/exports/b.d.ts",
|
|
71
|
+
"import": "./es/exports/b.js",
|
|
72
|
+
"require": "./lib/exports/b.js",
|
|
73
|
+
"default": "./es/exports/b.js"
|
|
74
|
+
},
|
|
75
|
+
"./latest": {
|
|
76
|
+
"src": "./src/exports/b.ts",
|
|
77
|
+
"types": "./types/exports/b.d.ts",
|
|
78
|
+
"import": "./es/exports/b.js",
|
|
79
|
+
"require": "./lib/exports/b.js",
|
|
80
|
+
"default": "./es/exports/b.js"
|
|
81
|
+
}
|
|
60
82
|
},
|
|
61
83
|
"scripts": {
|
|
62
84
|
"lint": "ui-scripts lint",
|
|
@@ -27,7 +27,7 @@ import { Component } from 'react'
|
|
|
27
27
|
import { SVGIcon } from '@instructure/ui-svg-images'
|
|
28
28
|
import { IconCheckMarkSolid } from '@instructure/ui-icons'
|
|
29
29
|
|
|
30
|
-
import { withStyle } from '@instructure/emotion'
|
|
30
|
+
import { withStyleLegacy as withStyle } from '@instructure/emotion'
|
|
31
31
|
|
|
32
32
|
import generateStyle from './styles'
|
|
33
33
|
import generateComponentTheme from './theme'
|
|
@@ -87,7 +87,9 @@ const generateStyle = (
|
|
|
87
87
|
boxSizing: 'border-box',
|
|
88
88
|
flexShrink: 0,
|
|
89
89
|
transition: 'all 0.2s',
|
|
90
|
-
border: `${componentTheme.borderWidth} solid ${
|
|
90
|
+
border: `${componentTheme.borderWidth} solid ${
|
|
91
|
+
invalid ? componentTheme.errorBorderColor : componentTheme.borderColor
|
|
92
|
+
}`,
|
|
91
93
|
borderRadius: componentTheme.borderRadius,
|
|
92
94
|
marginInlineEnd: componentTheme.marginRight,
|
|
93
95
|
marginInlineStart: '0',
|
|
@@ -26,7 +26,7 @@ import { Component } from 'react'
|
|
|
26
26
|
|
|
27
27
|
import { IconCheckSolid, IconXSolid } from '@instructure/ui-icons'
|
|
28
28
|
|
|
29
|
-
import { withStyle } from '@instructure/emotion'
|
|
29
|
+
import { withStyleLegacy as withStyle } from '@instructure/emotion'
|
|
30
30
|
|
|
31
31
|
import generateStyle from './styles'
|
|
32
32
|
import generateComponentTheme from './theme'
|
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
import { Component } from 'react'
|
|
26
26
|
import keycode from 'keycode'
|
|
27
27
|
|
|
28
|
-
import { FormFieldMessages } from '@instructure/ui-form-field'
|
|
28
|
+
import { FormFieldMessages } from '@instructure/ui-form-field/v11_6'
|
|
29
29
|
import { createChainedFunction } from '@instructure/ui-utils'
|
|
30
30
|
import { logError as error } from '@instructure/console'
|
|
31
31
|
import { isActiveElement } from '@instructure/ui-dom-utils'
|
|
32
32
|
import { omitProps, withDeterministicId } from '@instructure/ui-react-utils'
|
|
33
|
-
import { View } from '@instructure/ui-view'
|
|
33
|
+
import { View } from '@instructure/ui-view/v11_6'
|
|
34
34
|
|
|
35
|
-
import { withStyle } from '@instructure/emotion'
|
|
35
|
+
import { withStyleLegacy as withStyle } from '@instructure/emotion'
|
|
36
36
|
|
|
37
37
|
import { CheckboxFacade } from './CheckboxFacade'
|
|
38
38
|
import { ToggleFacade } from './ToggleFacade'
|
|
@@ -35,7 +35,7 @@ const generateComponentTheme = (theme: Theme): any => {
|
|
|
35
35
|
const componentVariables: any = {
|
|
36
36
|
requiredInvalidColor: colors?.contrasts?.red5782,
|
|
37
37
|
toggleErrorInsetWidth: `calc(${forms?.inputHeightSmall}*1.5 + ${spacing?.small})`,
|
|
38
|
-
checkErrorInsetWidth: `calc(1.25em + ${spacing?.xSmall})
|
|
38
|
+
checkErrorInsetWidth: `calc(1.25em + ${spacing?.xSmall})`
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
return {
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { Component } from 'react'
|
|
26
|
+
|
|
27
|
+
import {
|
|
28
|
+
CheckInstUIIcon,
|
|
29
|
+
MinusInstUIIcon,
|
|
30
|
+
renderIconWithProps
|
|
31
|
+
} from '@instructure/ui-icons'
|
|
32
|
+
|
|
33
|
+
import { withStyle } from '@instructure/emotion'
|
|
34
|
+
|
|
35
|
+
import generateStyle from './styles'
|
|
36
|
+
|
|
37
|
+
import { allowedProps } from './props'
|
|
38
|
+
import type { CheckboxFacadeProps } from './props'
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
---
|
|
42
|
+
parent: Checkbox
|
|
43
|
+
---
|
|
44
|
+
**/
|
|
45
|
+
@withStyle(generateStyle, 'Checkbox')
|
|
46
|
+
class CheckboxFacade extends Component<CheckboxFacadeProps> {
|
|
47
|
+
static readonly componentId = 'CheckboxFacade'
|
|
48
|
+
|
|
49
|
+
static allowedProps = allowedProps
|
|
50
|
+
static defaultProps = {
|
|
51
|
+
checked: false,
|
|
52
|
+
disabled: false,
|
|
53
|
+
readOnly: false,
|
|
54
|
+
focused: false,
|
|
55
|
+
hovered: false,
|
|
56
|
+
size: 'medium',
|
|
57
|
+
indeterminate: false
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
ref: Element | null = null
|
|
61
|
+
|
|
62
|
+
handleRef = (el: Element | null) => {
|
|
63
|
+
this.ref = el
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
componentDidMount() {
|
|
67
|
+
this.props.makeStyles?.()
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
componentDidUpdate() {
|
|
71
|
+
this.props.makeStyles?.()
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
renderIcon() {
|
|
75
|
+
const { disabled, readOnly, indeterminate, checked } = this.props
|
|
76
|
+
|
|
77
|
+
const getIconColor = () => {
|
|
78
|
+
if (disabled) {
|
|
79
|
+
return 'disabledBaseColor'
|
|
80
|
+
}
|
|
81
|
+
if (readOnly) {
|
|
82
|
+
return 'baseColor'
|
|
83
|
+
}
|
|
84
|
+
return 'inverseColor'
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const iconColor = getIconColor()
|
|
88
|
+
|
|
89
|
+
if (indeterminate) {
|
|
90
|
+
return renderIconWithProps(MinusInstUIIcon, 'sm', iconColor)
|
|
91
|
+
} else if (checked) {
|
|
92
|
+
return renderIconWithProps(CheckInstUIIcon, 'sm', iconColor)
|
|
93
|
+
} else {
|
|
94
|
+
return null
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
render() {
|
|
99
|
+
const { children, styles } = this.props
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<span css={styles?.checkboxFacade} ref={this.handleRef}>
|
|
103
|
+
<span css={styles?.facade} aria-hidden="true">
|
|
104
|
+
{this.renderIcon()}
|
|
105
|
+
</span>
|
|
106
|
+
<span css={styles?.label}>{children}</span>
|
|
107
|
+
</span>
|
|
108
|
+
)
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export default CheckboxFacade
|
|
113
|
+
export { CheckboxFacade }
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import type { CheckboxFacadeTheme } from '@instructure/shared-types'
|
|
26
|
+
import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
|
|
27
|
+
|
|
28
|
+
type CheckboxFacadeOwnProps = {
|
|
29
|
+
children: React.ReactNode
|
|
30
|
+
checked?: boolean
|
|
31
|
+
disabled?: boolean
|
|
32
|
+
readOnly?: boolean
|
|
33
|
+
focused?: boolean
|
|
34
|
+
hovered?: boolean
|
|
35
|
+
size?: 'small' | 'medium' | 'large'
|
|
36
|
+
/**
|
|
37
|
+
* Visual state showing that child checkboxes are a combination of checked and unchecked
|
|
38
|
+
*/
|
|
39
|
+
indeterminate?: boolean
|
|
40
|
+
/**
|
|
41
|
+
* Indicate if the parent component (`Checkbox`) is invalid to set the style accordingly.
|
|
42
|
+
*/
|
|
43
|
+
invalid?: boolean
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
type PropKeys = keyof CheckboxFacadeOwnProps
|
|
47
|
+
|
|
48
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
49
|
+
|
|
50
|
+
type CheckboxFacadeProps = CheckboxFacadeOwnProps &
|
|
51
|
+
WithStyleProps<CheckboxFacadeTheme, CheckboxFacadeStyle>
|
|
52
|
+
|
|
53
|
+
type CheckboxFacadeStyle = ComponentStyle<'checkboxFacade' | 'facade' | 'label'>
|
|
54
|
+
const allowedProps: AllowedPropKeys = [
|
|
55
|
+
'children',
|
|
56
|
+
'checked',
|
|
57
|
+
'disabled',
|
|
58
|
+
'readOnly',
|
|
59
|
+
'focused',
|
|
60
|
+
'hovered',
|
|
61
|
+
'size',
|
|
62
|
+
'indeterminate',
|
|
63
|
+
'invalid'
|
|
64
|
+
]
|
|
65
|
+
|
|
66
|
+
export type { CheckboxFacadeProps, CheckboxFacadeStyle }
|
|
67
|
+
export { allowedProps }
|