@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
|
@@ -20,13 +20,13 @@ Object.defineProperty(exports, "ToggleFacade", {
|
|
|
20
20
|
exports.default = void 0;
|
|
21
21
|
var _react = require("react");
|
|
22
22
|
var _keycode = _interopRequireDefault(require("keycode"));
|
|
23
|
-
var
|
|
23
|
+
var _v11_ = require("@instructure/ui-form-field/v11_6");
|
|
24
24
|
var _createChainedFunction = require("@instructure/ui-utils/lib/createChainedFunction.js");
|
|
25
25
|
var _console = require("@instructure/console");
|
|
26
26
|
var _isActiveElement = require("@instructure/ui-dom-utils/lib/isActiveElement.js");
|
|
27
27
|
var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
|
|
28
28
|
var _withDeterministicId = require("@instructure/ui-react-utils/lib/DeterministicIdContext/withDeterministicId.js");
|
|
29
|
-
var
|
|
29
|
+
var _v11_2 = require("@instructure/ui-view/v11_6");
|
|
30
30
|
var _emotion = require("@instructure/emotion");
|
|
31
31
|
var _CheckboxFacade = require("./CheckboxFacade");
|
|
32
32
|
var _ToggleFacade = require("./ToggleFacade");
|
|
@@ -64,7 +64,7 @@ category: components
|
|
|
64
64
|
tags: toggle, switch
|
|
65
65
|
---
|
|
66
66
|
**/
|
|
67
|
-
let Checkbox = exports.Checkbox = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.
|
|
67
|
+
let Checkbox = exports.Checkbox = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.withStyleLegacy)(_styles.default, _theme.default), _dec(_class = _dec2(_class = (_Checkbox = class Checkbox extends _react.Component {
|
|
68
68
|
constructor(props) {
|
|
69
69
|
super(props);
|
|
70
70
|
this._defaultId = void 0;
|
|
@@ -223,11 +223,11 @@ let Checkbox = exports.Checkbox = (_dec = (0, _withDeterministicId.withDetermini
|
|
|
223
223
|
messages = _this$props5.messages,
|
|
224
224
|
styles = _this$props5.styles,
|
|
225
225
|
variant = _this$props5.variant;
|
|
226
|
-
return messages && messages.length > 0 ? (0, _jsxRuntime.jsx)(
|
|
226
|
+
return messages && messages.length > 0 ? (0, _jsxRuntime.jsx)(_v11_2.View, {
|
|
227
227
|
display: "block",
|
|
228
228
|
margin: "small 0 0",
|
|
229
229
|
css: this.isNewError && (variant === 'toggle' ? styles === null || styles === void 0 ? void 0 : styles.indentedToggleError : styles === null || styles === void 0 ? void 0 : styles.indentedError),
|
|
230
|
-
children: (0, _jsxRuntime.jsx)(
|
|
230
|
+
children: (0, _jsxRuntime.jsx)(_v11_.FormFieldMessages, {
|
|
231
231
|
messages: messages
|
|
232
232
|
})
|
|
233
233
|
}) : null;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = exports.CheckboxFacade = void 0;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _uiIcons = require("@instructure/ui-icons");
|
|
10
|
+
var _emotion = require("@instructure/emotion");
|
|
11
|
+
var _styles = _interopRequireDefault(require("./styles"));
|
|
12
|
+
var _props = require("./props");
|
|
13
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
14
|
+
var _dec, _class, _CheckboxFacade;
|
|
15
|
+
/*
|
|
16
|
+
* The MIT License (MIT)
|
|
17
|
+
*
|
|
18
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
19
|
+
*
|
|
20
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
21
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
22
|
+
* in the Software without restriction, including without limitation the rights
|
|
23
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
24
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
25
|
+
* furnished to do so, subject to the following conditions:
|
|
26
|
+
*
|
|
27
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
28
|
+
* copies or substantial portions of the Software.
|
|
29
|
+
*
|
|
30
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
31
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
32
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
33
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
34
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
35
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
36
|
+
* SOFTWARE.
|
|
37
|
+
*/
|
|
38
|
+
/**
|
|
39
|
+
---
|
|
40
|
+
parent: Checkbox
|
|
41
|
+
---
|
|
42
|
+
**/
|
|
43
|
+
let CheckboxFacade = exports.CheckboxFacade = (_dec = (0, _emotion.withStyle)(_styles.default, 'Checkbox'), _dec(_class = (_CheckboxFacade = class CheckboxFacade extends _react.Component {
|
|
44
|
+
constructor(...args) {
|
|
45
|
+
super(...args);
|
|
46
|
+
this.ref = null;
|
|
47
|
+
this.handleRef = el => {
|
|
48
|
+
this.ref = el;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
componentDidMount() {
|
|
52
|
+
var _this$props$makeStyle, _this$props;
|
|
53
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
54
|
+
}
|
|
55
|
+
componentDidUpdate() {
|
|
56
|
+
var _this$props$makeStyle2, _this$props2;
|
|
57
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
58
|
+
}
|
|
59
|
+
renderIcon() {
|
|
60
|
+
const _this$props3 = this.props,
|
|
61
|
+
disabled = _this$props3.disabled,
|
|
62
|
+
readOnly = _this$props3.readOnly,
|
|
63
|
+
indeterminate = _this$props3.indeterminate,
|
|
64
|
+
checked = _this$props3.checked;
|
|
65
|
+
const getIconColor = () => {
|
|
66
|
+
if (disabled) {
|
|
67
|
+
return 'disabledBaseColor';
|
|
68
|
+
}
|
|
69
|
+
if (readOnly) {
|
|
70
|
+
return 'baseColor';
|
|
71
|
+
}
|
|
72
|
+
return 'inverseColor';
|
|
73
|
+
};
|
|
74
|
+
const iconColor = getIconColor();
|
|
75
|
+
if (indeterminate) {
|
|
76
|
+
return (0, _uiIcons.renderIconWithProps)(_uiIcons.MinusInstUIIcon, 'sm', iconColor);
|
|
77
|
+
} else if (checked) {
|
|
78
|
+
return (0, _uiIcons.renderIconWithProps)(_uiIcons.CheckInstUIIcon, 'sm', iconColor);
|
|
79
|
+
} else {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
render() {
|
|
84
|
+
const _this$props4 = this.props,
|
|
85
|
+
children = _this$props4.children,
|
|
86
|
+
styles = _this$props4.styles;
|
|
87
|
+
return (0, _jsxRuntime.jsxs)("span", {
|
|
88
|
+
css: styles === null || styles === void 0 ? void 0 : styles.checkboxFacade,
|
|
89
|
+
ref: this.handleRef,
|
|
90
|
+
children: [(0, _jsxRuntime.jsx)("span", {
|
|
91
|
+
css: styles === null || styles === void 0 ? void 0 : styles.facade,
|
|
92
|
+
"aria-hidden": "true",
|
|
93
|
+
children: this.renderIcon()
|
|
94
|
+
}), (0, _jsxRuntime.jsx)("span", {
|
|
95
|
+
css: styles === null || styles === void 0 ? void 0 : styles.label,
|
|
96
|
+
children: children
|
|
97
|
+
})]
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}, _CheckboxFacade.displayName = "CheckboxFacade", _CheckboxFacade.componentId = 'CheckboxFacade', _CheckboxFacade.allowedProps = _props.allowedProps, _CheckboxFacade.defaultProps = {
|
|
101
|
+
checked: false,
|
|
102
|
+
disabled: false,
|
|
103
|
+
readOnly: false,
|
|
104
|
+
focused: false,
|
|
105
|
+
hovered: false,
|
|
106
|
+
size: 'medium',
|
|
107
|
+
indeterminate: false
|
|
108
|
+
}, _CheckboxFacade)) || _class);
|
|
109
|
+
var _default = exports.default = CheckboxFacade;
|
|
@@ -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 = ['children', 'checked', 'disabled', 'readOnly', 'focused', 'hovered', 'size', 'indeterminate', 'invalid'];
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _emotion = require("@instructure/emotion");
|
|
8
|
+
/*
|
|
9
|
+
* The MIT License (MIT)
|
|
10
|
+
*
|
|
11
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
12
|
+
*
|
|
13
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
* in the Software without restriction, including without limitation the rights
|
|
16
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
18
|
+
* furnished to do so, subject to the following conditions:
|
|
19
|
+
*
|
|
20
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
21
|
+
* copies or substantial portions of the Software.
|
|
22
|
+
*
|
|
23
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
+
* SOFTWARE.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* ---
|
|
34
|
+
* private: true
|
|
35
|
+
* ---
|
|
36
|
+
* Generates the style object from the theme and provided additional information
|
|
37
|
+
* @param {Object} componentTheme The theme variable object.
|
|
38
|
+
* @param {Object} props the props of the component, the style is applied to
|
|
39
|
+
* @param {Object} sharedTokens Shared theme token object
|
|
40
|
+
* @param {Object} state the state of the component, the style is applied to
|
|
41
|
+
* @return {Object} The final style object, which will be used in the component
|
|
42
|
+
*/
|
|
43
|
+
const generateStyle = (componentTheme, props, sharedTokens) => {
|
|
44
|
+
var _sizeVariants;
|
|
45
|
+
const size = props.size,
|
|
46
|
+
checked = props.checked,
|
|
47
|
+
disabled = props.disabled,
|
|
48
|
+
readOnly = props.readOnly,
|
|
49
|
+
focused = props.focused,
|
|
50
|
+
hovered = props.hovered,
|
|
51
|
+
indeterminate = props.indeterminate,
|
|
52
|
+
invalid = props.invalid;
|
|
53
|
+
const isChecked = checked || indeterminate;
|
|
54
|
+
const sizeVariants = {
|
|
55
|
+
small: {
|
|
56
|
+
label: {
|
|
57
|
+
fontSize: componentTheme.fontSizeSm
|
|
58
|
+
},
|
|
59
|
+
facade: {
|
|
60
|
+
fontSize: componentTheme.fontSizeSm,
|
|
61
|
+
width: componentTheme.controlSizeSm,
|
|
62
|
+
height: componentTheme.controlSizeSm,
|
|
63
|
+
margin: `${componentTheme.controlVerticalMargin} ${componentTheme.gap} 0 0`
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
medium: {
|
|
67
|
+
label: {
|
|
68
|
+
fontSize: componentTheme.fontSizeMd
|
|
69
|
+
},
|
|
70
|
+
facade: {
|
|
71
|
+
fontSize: componentTheme.fontSizeMd,
|
|
72
|
+
width: componentTheme.controlSizeMd,
|
|
73
|
+
height: componentTheme.controlSizeMd
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
large: {
|
|
77
|
+
label: {
|
|
78
|
+
fontSize: componentTheme.fontSizeLg
|
|
79
|
+
},
|
|
80
|
+
facade: {
|
|
81
|
+
fontSize: componentTheme.fontSizeLg,
|
|
82
|
+
width: componentTheme.controlSizeLg,
|
|
83
|
+
height: componentTheme.controlSizeLg
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const sizeVariant = (_sizeVariants = sizeVariants[size]) !== null && _sizeVariants !== void 0 ? _sizeVariants : sizeVariants.medium;
|
|
88
|
+
const getLabelColor = () => {
|
|
89
|
+
if (disabled) {
|
|
90
|
+
return componentTheme.labelDisabledColor;
|
|
91
|
+
}
|
|
92
|
+
if (readOnly) {
|
|
93
|
+
return componentTheme.labelReadonlyColor;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// DEFAULT state
|
|
97
|
+
return hovered ? componentTheme.labelHoverColor : componentTheme.labelBaseColor;
|
|
98
|
+
};
|
|
99
|
+
const getFacadeStyles = () => {
|
|
100
|
+
const baseStyles = {
|
|
101
|
+
position: 'relative',
|
|
102
|
+
display: 'flex',
|
|
103
|
+
alignItems: 'center',
|
|
104
|
+
justifyContent: 'center',
|
|
105
|
+
boxSizing: 'border-box',
|
|
106
|
+
flexShrink: 0,
|
|
107
|
+
transition: 'all 0.2s',
|
|
108
|
+
borderRadius: componentTheme.borderRadius,
|
|
109
|
+
marginInlineEnd: componentTheme.gap,
|
|
110
|
+
marginInlineStart: '0',
|
|
111
|
+
...sizeVariant.facade
|
|
112
|
+
};
|
|
113
|
+
if (disabled) {
|
|
114
|
+
return {
|
|
115
|
+
...baseStyles,
|
|
116
|
+
background: componentTheme.backgroundDisabledColor,
|
|
117
|
+
border: `${componentTheme.borderWidth} solid ${componentTheme.borderDisabledColor}`
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
if (readOnly) {
|
|
121
|
+
return {
|
|
122
|
+
...baseStyles,
|
|
123
|
+
background: componentTheme.backgroundReadonlyColor,
|
|
124
|
+
border: `${componentTheme.borderWidth} solid ${componentTheme.borderReadonlyColor}`,
|
|
125
|
+
pointerEvents: 'none'
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
if (invalid) {
|
|
129
|
+
return {
|
|
130
|
+
...baseStyles,
|
|
131
|
+
...(isChecked && {
|
|
132
|
+
background: componentTheme.backgroundCheckedColor,
|
|
133
|
+
border: `${componentTheme.borderWidth} solid ${hovered ? componentTheme.errorBorderHoverColor : componentTheme.errorBorderColor}`
|
|
134
|
+
}),
|
|
135
|
+
...(!isChecked && {
|
|
136
|
+
background: hovered ? componentTheme.backgroundHoverColor : componentTheme.backgroundColor,
|
|
137
|
+
border: `${componentTheme.borderWidth} solid ${hovered ? componentTheme.errorBorderHoverColor : componentTheme.errorBorderColor}`
|
|
138
|
+
})
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
if (isChecked) {
|
|
142
|
+
return {
|
|
143
|
+
...baseStyles,
|
|
144
|
+
background: componentTheme.backgroundCheckedColor,
|
|
145
|
+
border: `${componentTheme.borderWidth} solid ${componentTheme.borderCheckedColor}`
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// DEFAULT (unchecked) state
|
|
150
|
+
return {
|
|
151
|
+
...baseStyles,
|
|
152
|
+
background: hovered ? componentTheme.backgroundHoverColor : componentTheme.backgroundColor,
|
|
153
|
+
border: `${componentTheme.borderWidth} solid ${hovered ? componentTheme.borderHoverColor : componentTheme.borderColor}`
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
return {
|
|
157
|
+
checkboxFacade: {
|
|
158
|
+
label: 'checkboxFacade',
|
|
159
|
+
display: 'flex',
|
|
160
|
+
alignItems: 'flex-start',
|
|
161
|
+
cursor: disabled ? 'not-allowed' : readOnly ? 'default' : 'pointer'
|
|
162
|
+
},
|
|
163
|
+
facade: {
|
|
164
|
+
label: 'checkboxFacade__facade',
|
|
165
|
+
...getFacadeStyles(),
|
|
166
|
+
...(sharedTokens !== null && sharedTokens !== void 0 && sharedTokens.focusOutline ? (0, _emotion.calcFocusOutlineStyles)(sharedTokens.focusOutline, {
|
|
167
|
+
withFocusOutline: focused
|
|
168
|
+
}) : {})
|
|
169
|
+
},
|
|
170
|
+
label: {
|
|
171
|
+
label: 'checkboxFacade__label',
|
|
172
|
+
flex: '1 1 auto',
|
|
173
|
+
alignSelf: 'center',
|
|
174
|
+
minWidth: '0.0625rem',
|
|
175
|
+
color: getLabelColor(),
|
|
176
|
+
fontFamily: componentTheme.fontFamily,
|
|
177
|
+
fontWeight: componentTheme.fontWeight,
|
|
178
|
+
lineHeight: componentTheme.lineHeight,
|
|
179
|
+
...sizeVariant.label
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
var _default = exports.default = generateStyle;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = exports.ToggleFacade = void 0;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _uiIcons = require("@instructure/ui-icons");
|
|
10
|
+
var _emotion = require("@instructure/emotion");
|
|
11
|
+
var _styles = _interopRequireDefault(require("./styles"));
|
|
12
|
+
var _props = require("./props");
|
|
13
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
14
|
+
var _dec, _class, _ToggleFacade;
|
|
15
|
+
/*
|
|
16
|
+
* The MIT License (MIT)
|
|
17
|
+
*
|
|
18
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
19
|
+
*
|
|
20
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
21
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
22
|
+
* in the Software without restriction, including without limitation the rights
|
|
23
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
24
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
25
|
+
* furnished to do so, subject to the following conditions:
|
|
26
|
+
*
|
|
27
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
28
|
+
* copies or substantial portions of the Software.
|
|
29
|
+
*
|
|
30
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
31
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
32
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
33
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
34
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
35
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
36
|
+
* SOFTWARE.
|
|
37
|
+
*/
|
|
38
|
+
/**
|
|
39
|
+
---
|
|
40
|
+
parent: Checkbox
|
|
41
|
+
---
|
|
42
|
+
**/
|
|
43
|
+
let ToggleFacade = exports.ToggleFacade = (_dec = (0, _emotion.withStyle)(_styles.default, 'Toggle'), _dec(_class = (_ToggleFacade = class ToggleFacade extends _react.Component {
|
|
44
|
+
constructor(...args) {
|
|
45
|
+
super(...args);
|
|
46
|
+
this.ref = null;
|
|
47
|
+
this.handleRef = el => {
|
|
48
|
+
this.ref = el;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
componentDidMount() {
|
|
52
|
+
var _this$props$makeStyle, _this$props;
|
|
53
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
54
|
+
}
|
|
55
|
+
componentDidUpdate() {
|
|
56
|
+
var _this$props$makeStyle2, _this$props2;
|
|
57
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
58
|
+
}
|
|
59
|
+
renderIcon() {
|
|
60
|
+
const _this$props3 = this.props,
|
|
61
|
+
disabled = _this$props3.disabled,
|
|
62
|
+
readOnly = _this$props3.readOnly,
|
|
63
|
+
checked = _this$props3.checked;
|
|
64
|
+
const getIconColor = () => {
|
|
65
|
+
if (disabled) {
|
|
66
|
+
return 'disabledBaseColor';
|
|
67
|
+
}
|
|
68
|
+
if (readOnly) {
|
|
69
|
+
return 'mutedColor';
|
|
70
|
+
}
|
|
71
|
+
if (checked) {
|
|
72
|
+
return 'successColor';
|
|
73
|
+
}
|
|
74
|
+
return 'baseColor';
|
|
75
|
+
};
|
|
76
|
+
const iconColor = getIconColor();
|
|
77
|
+
if (checked) {
|
|
78
|
+
return (0, _uiIcons.renderIconWithProps)(_uiIcons.CheckInstUIIcon, 'xs', iconColor);
|
|
79
|
+
} else {
|
|
80
|
+
return (0, _uiIcons.renderIconWithProps)(_uiIcons.XInstUIIcon, 'xs', iconColor);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
renderLabel() {
|
|
84
|
+
const _this$props4 = this.props,
|
|
85
|
+
children = _this$props4.children,
|
|
86
|
+
styles = _this$props4.styles;
|
|
87
|
+
return (0, _jsxRuntime.jsx)("span", {
|
|
88
|
+
css: styles === null || styles === void 0 ? void 0 : styles.label,
|
|
89
|
+
children: children
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
render() {
|
|
93
|
+
const _this$props5 = this.props,
|
|
94
|
+
labelPlacement = _this$props5.labelPlacement,
|
|
95
|
+
styles = _this$props5.styles;
|
|
96
|
+
return (0, _jsxRuntime.jsxs)("span", {
|
|
97
|
+
css: styles === null || styles === void 0 ? void 0 : styles.toggleFacade,
|
|
98
|
+
ref: this.handleRef,
|
|
99
|
+
children: [(labelPlacement === 'top' || labelPlacement === 'start') && this.renderLabel(), (0, _jsxRuntime.jsx)("span", {
|
|
100
|
+
css: styles === null || styles === void 0 ? void 0 : styles.facade,
|
|
101
|
+
"aria-hidden": "true",
|
|
102
|
+
children: (0, _jsxRuntime.jsx)("span", {
|
|
103
|
+
css: styles === null || styles === void 0 ? void 0 : styles.icon,
|
|
104
|
+
children: (0, _jsxRuntime.jsx)("span", {
|
|
105
|
+
css: styles === null || styles === void 0 ? void 0 : styles.iconToggle,
|
|
106
|
+
children: this.renderIcon()
|
|
107
|
+
})
|
|
108
|
+
})
|
|
109
|
+
}), labelPlacement === 'end' && this.renderLabel()]
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}, _ToggleFacade.displayName = "ToggleFacade", _ToggleFacade.componentId = 'ToggleFacade', _ToggleFacade.allowedProps = _props.allowedProps, _ToggleFacade.defaultProps = {
|
|
113
|
+
checked: false,
|
|
114
|
+
focused: false,
|
|
115
|
+
hovered: false,
|
|
116
|
+
size: 'medium',
|
|
117
|
+
disabled: false,
|
|
118
|
+
readOnly: false,
|
|
119
|
+
labelPlacement: 'end'
|
|
120
|
+
}, _ToggleFacade)) || _class);
|
|
121
|
+
var _default = exports.default = ToggleFacade;
|
|
@@ -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 = ['children', 'checked', 'disabled', 'readOnly', 'focused', 'hovered', 'size', 'labelPlacement', 'invalid'];
|