@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.
Files changed (158) hide show
  1. package/CHANGELOG.md +44 -297
  2. package/es/Checkbox/{CheckboxFacade → v1/CheckboxFacade}/index.js +1 -1
  3. package/es/Checkbox/{ToggleFacade → v1/ToggleFacade}/index.js +1 -1
  4. package/es/Checkbox/{index.js → v1/index.js} +3 -3
  5. package/es/Checkbox/v2/CheckboxFacade/index.js +104 -0
  6. package/es/Checkbox/v2/CheckboxFacade/props.js +26 -0
  7. package/es/Checkbox/v2/CheckboxFacade/styles.js +177 -0
  8. package/es/Checkbox/v2/ToggleFacade/index.js +116 -0
  9. package/es/Checkbox/v2/ToggleFacade/props.js +26 -0
  10. package/es/Checkbox/v2/ToggleFacade/styles.js +232 -0
  11. package/es/Checkbox/v2/index.js +289 -0
  12. package/es/Checkbox/v2/props.js +26 -0
  13. package/es/Checkbox/v2/styles.js +102 -0
  14. package/es/CheckboxGroup/{index.js → v1/index.js} +2 -2
  15. package/es/CheckboxGroup/v2/index.js +125 -0
  16. package/es/CheckboxGroup/v2/props.js +26 -0
  17. package/es/{index.js → exports/a.js} +2 -2
  18. package/es/exports/b.js +25 -0
  19. package/lib/Checkbox/{CheckboxFacade → v1/CheckboxFacade}/index.js +2 -2
  20. package/lib/Checkbox/{ToggleFacade → v1/ToggleFacade}/index.js +3 -3
  21. package/lib/Checkbox/{index.js → v1/index.js} +5 -5
  22. package/lib/Checkbox/v2/CheckboxFacade/index.js +109 -0
  23. package/lib/Checkbox/v2/CheckboxFacade/props.js +31 -0
  24. package/lib/Checkbox/v2/CheckboxFacade/styles.js +183 -0
  25. package/lib/Checkbox/v2/ToggleFacade/index.js +121 -0
  26. package/lib/Checkbox/v2/ToggleFacade/props.js +31 -0
  27. package/lib/Checkbox/v2/ToggleFacade/styles.js +238 -0
  28. package/lib/Checkbox/v2/index.js +308 -0
  29. package/lib/Checkbox/v2/props.js +31 -0
  30. package/lib/Checkbox/v2/styles.js +108 -0
  31. package/lib/CheckboxGroup/{index.js → v1/index.js} +5 -5
  32. package/lib/CheckboxGroup/v2/index.js +133 -0
  33. package/lib/CheckboxGroup/v2/props.js +31 -0
  34. package/lib/{index.js → exports/a.js} +6 -6
  35. package/lib/exports/b.js +31 -0
  36. package/package.json +45 -23
  37. package/src/Checkbox/{CheckboxFacade → v1/CheckboxFacade}/index.tsx +1 -1
  38. package/src/Checkbox/{CheckboxFacade → v1/CheckboxFacade}/styles.ts +3 -1
  39. package/src/Checkbox/{ToggleFacade → v1/ToggleFacade}/index.tsx +1 -1
  40. package/src/Checkbox/{index.tsx → v1/index.tsx} +3 -3
  41. package/src/Checkbox/{props.ts → v1/props.ts} +1 -1
  42. package/src/Checkbox/{styles.ts → v1/styles.ts} +1 -1
  43. package/src/Checkbox/{theme.ts → v1/theme.ts} +1 -1
  44. package/src/Checkbox/v2/CheckboxFacade/index.tsx +113 -0
  45. package/src/Checkbox/v2/CheckboxFacade/props.ts +67 -0
  46. package/src/Checkbox/v2/CheckboxFacade/styles.ts +209 -0
  47. package/src/Checkbox/v2/README.md +193 -0
  48. package/src/Checkbox/v2/ToggleFacade/index.tsx +124 -0
  49. package/src/Checkbox/v2/ToggleFacade/props.ts +67 -0
  50. package/src/Checkbox/v2/ToggleFacade/styles.ts +301 -0
  51. package/src/Checkbox/v2/index.tsx +376 -0
  52. package/src/Checkbox/v2/props.ts +132 -0
  53. package/src/Checkbox/v2/styles.ts +118 -0
  54. package/src/CheckboxGroup/{index.tsx → v1/index.tsx} +2 -2
  55. package/src/CheckboxGroup/{props.ts → v1/props.ts} +3 -3
  56. package/src/CheckboxGroup/v2/README.md +111 -0
  57. package/src/CheckboxGroup/v2/index.tsx +157 -0
  58. package/src/CheckboxGroup/v2/props.ts +77 -0
  59. package/src/{index.ts → exports/a.ts} +6 -6
  60. package/src/exports/b.ts +30 -0
  61. package/tsconfig.build.tsbuildinfo +1 -1
  62. package/types/Checkbox/v1/CheckboxFacade/index.d.ts.map +1 -0
  63. package/types/Checkbox/v1/CheckboxFacade/props.d.ts.map +1 -0
  64. package/types/Checkbox/v1/CheckboxFacade/styles.d.ts.map +1 -0
  65. package/types/Checkbox/v1/CheckboxFacade/theme.d.ts.map +1 -0
  66. package/types/Checkbox/v1/ToggleFacade/index.d.ts.map +1 -0
  67. package/types/Checkbox/v1/ToggleFacade/props.d.ts.map +1 -0
  68. package/types/Checkbox/v1/ToggleFacade/styles.d.ts.map +1 -0
  69. package/types/Checkbox/v1/ToggleFacade/theme.d.ts.map +1 -0
  70. package/types/Checkbox/{index.d.ts → v1/index.d.ts} +1 -1
  71. package/types/Checkbox/v1/index.d.ts.map +1 -0
  72. package/types/Checkbox/{props.d.ts → v1/props.d.ts} +1 -1
  73. package/types/Checkbox/v1/props.d.ts.map +1 -0
  74. package/types/Checkbox/v1/styles.d.ts.map +1 -0
  75. package/types/Checkbox/v1/theme.d.ts.map +1 -0
  76. package/types/Checkbox/v2/CheckboxFacade/index.d.ts +39 -0
  77. package/types/Checkbox/v2/CheckboxFacade/index.d.ts.map +1 -0
  78. package/types/Checkbox/v2/CheckboxFacade/props.d.ts +27 -0
  79. package/types/Checkbox/v2/CheckboxFacade/props.d.ts.map +1 -0
  80. package/types/Checkbox/v2/CheckboxFacade/styles.d.ts +16 -0
  81. package/types/Checkbox/v2/CheckboxFacade/styles.d.ts.map +1 -0
  82. package/types/Checkbox/v2/ToggleFacade/index.d.ts +40 -0
  83. package/types/Checkbox/v2/ToggleFacade/index.d.ts.map +1 -0
  84. package/types/Checkbox/v2/ToggleFacade/props.d.ts +25 -0
  85. package/types/Checkbox/v2/ToggleFacade/props.d.ts.map +1 -0
  86. package/types/Checkbox/v2/ToggleFacade/styles.d.ts +16 -0
  87. package/types/Checkbox/v2/ToggleFacade/styles.d.ts.map +1 -0
  88. package/types/Checkbox/v2/index.d.ts +71 -0
  89. package/types/Checkbox/v2/index.d.ts.map +1 -0
  90. package/types/Checkbox/v2/props.d.ts +64 -0
  91. package/types/Checkbox/v2/props.d.ts.map +1 -0
  92. package/types/Checkbox/v2/styles.d.ts +16 -0
  93. package/types/Checkbox/v2/styles.d.ts.map +1 -0
  94. package/types/CheckboxGroup/{index.d.ts → v1/index.d.ts} +1 -1
  95. package/types/CheckboxGroup/v1/index.d.ts.map +1 -0
  96. package/types/CheckboxGroup/{props.d.ts → v1/props.d.ts} +3 -3
  97. package/types/CheckboxGroup/v1/props.d.ts.map +1 -0
  98. package/types/CheckboxGroup/v2/index.d.ts +42 -0
  99. package/types/CheckboxGroup/v2/index.d.ts.map +1 -0
  100. package/types/CheckboxGroup/v2/props.d.ts +30 -0
  101. package/types/CheckboxGroup/v2/props.d.ts.map +1 -0
  102. package/types/exports/a.d.ts +7 -0
  103. package/types/exports/a.d.ts.map +1 -0
  104. package/types/exports/b.d.ts +7 -0
  105. package/types/exports/b.d.ts.map +1 -0
  106. package/types/Checkbox/CheckboxFacade/index.d.ts.map +0 -1
  107. package/types/Checkbox/CheckboxFacade/props.d.ts.map +0 -1
  108. package/types/Checkbox/CheckboxFacade/styles.d.ts.map +0 -1
  109. package/types/Checkbox/CheckboxFacade/theme.d.ts.map +0 -1
  110. package/types/Checkbox/ToggleFacade/index.d.ts.map +0 -1
  111. package/types/Checkbox/ToggleFacade/props.d.ts.map +0 -1
  112. package/types/Checkbox/ToggleFacade/styles.d.ts.map +0 -1
  113. package/types/Checkbox/ToggleFacade/theme.d.ts.map +0 -1
  114. package/types/Checkbox/index.d.ts.map +0 -1
  115. package/types/Checkbox/props.d.ts.map +0 -1
  116. package/types/Checkbox/styles.d.ts.map +0 -1
  117. package/types/Checkbox/theme.d.ts.map +0 -1
  118. package/types/CheckboxGroup/index.d.ts.map +0 -1
  119. package/types/CheckboxGroup/props.d.ts.map +0 -1
  120. package/types/index.d.ts +0 -7
  121. package/types/index.d.ts.map +0 -1
  122. /package/es/Checkbox/{CheckboxFacade → v1/CheckboxFacade}/props.js +0 -0
  123. /package/es/Checkbox/{CheckboxFacade → v1/CheckboxFacade}/styles.js +0 -0
  124. /package/es/Checkbox/{CheckboxFacade → v1/CheckboxFacade}/theme.js +0 -0
  125. /package/es/Checkbox/{ToggleFacade → v1/ToggleFacade}/props.js +0 -0
  126. /package/es/Checkbox/{ToggleFacade → v1/ToggleFacade}/styles.js +0 -0
  127. /package/es/Checkbox/{ToggleFacade → v1/ToggleFacade}/theme.js +0 -0
  128. /package/es/Checkbox/{props.js → v1/props.js} +0 -0
  129. /package/es/Checkbox/{styles.js → v1/styles.js} +0 -0
  130. /package/es/Checkbox/{theme.js → v1/theme.js} +0 -0
  131. /package/es/CheckboxGroup/{props.js → v1/props.js} +0 -0
  132. /package/lib/Checkbox/{CheckboxFacade → v1/CheckboxFacade}/props.js +0 -0
  133. /package/lib/Checkbox/{CheckboxFacade → v1/CheckboxFacade}/styles.js +0 -0
  134. /package/lib/Checkbox/{CheckboxFacade → v1/CheckboxFacade}/theme.js +0 -0
  135. /package/lib/Checkbox/{ToggleFacade → v1/ToggleFacade}/props.js +0 -0
  136. /package/lib/Checkbox/{ToggleFacade → v1/ToggleFacade}/styles.js +0 -0
  137. /package/lib/Checkbox/{ToggleFacade → v1/ToggleFacade}/theme.js +0 -0
  138. /package/lib/Checkbox/{props.js → v1/props.js} +0 -0
  139. /package/lib/Checkbox/{styles.js → v1/styles.js} +0 -0
  140. /package/lib/Checkbox/{theme.js → v1/theme.js} +0 -0
  141. /package/lib/CheckboxGroup/{props.js → v1/props.js} +0 -0
  142. /package/src/Checkbox/{CheckboxFacade → v1/CheckboxFacade}/props.ts +0 -0
  143. /package/src/Checkbox/{CheckboxFacade → v1/CheckboxFacade}/theme.ts +0 -0
  144. /package/src/Checkbox/{README.md → v1/README.md} +0 -0
  145. /package/src/Checkbox/{ToggleFacade → v1/ToggleFacade}/props.ts +0 -0
  146. /package/src/Checkbox/{ToggleFacade → v1/ToggleFacade}/styles.ts +0 -0
  147. /package/src/Checkbox/{ToggleFacade → v1/ToggleFacade}/theme.ts +0 -0
  148. /package/src/CheckboxGroup/{README.md → v1/README.md} +0 -0
  149. /package/types/Checkbox/{CheckboxFacade → v1/CheckboxFacade}/index.d.ts +0 -0
  150. /package/types/Checkbox/{CheckboxFacade → v1/CheckboxFacade}/props.d.ts +0 -0
  151. /package/types/Checkbox/{CheckboxFacade → v1/CheckboxFacade}/styles.d.ts +0 -0
  152. /package/types/Checkbox/{CheckboxFacade → v1/CheckboxFacade}/theme.d.ts +0 -0
  153. /package/types/Checkbox/{ToggleFacade → v1/ToggleFacade}/index.d.ts +0 -0
  154. /package/types/Checkbox/{ToggleFacade → v1/ToggleFacade}/props.d.ts +0 -0
  155. /package/types/Checkbox/{ToggleFacade → v1/ToggleFacade}/styles.d.ts +0 -0
  156. /package/types/Checkbox/{ToggleFacade → v1/ToggleFacade}/theme.d.ts +0 -0
  157. /package/types/Checkbox/{styles.d.ts → v1/styles.d.ts} +0 -0
  158. /package/types/Checkbox/{theme.d.ts → v1/theme.d.ts} +0 -0
@@ -0,0 +1,104 @@
1
+ var _dec, _class, _CheckboxFacade;
2
+ /*
3
+ * The MIT License (MIT)
4
+ *
5
+ * Copyright (c) 2015 - present Instructure, Inc.
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+
26
+ import { Component } from 'react';
27
+ import { CheckInstUIIcon, MinusInstUIIcon, renderIconWithProps } from '@instructure/ui-icons';
28
+ import { withStyle } from '@instructure/emotion';
29
+ import generateStyle from "./styles.js";
30
+ import { allowedProps } from "./props.js";
31
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
32
+ /**
33
+ ---
34
+ parent: Checkbox
35
+ ---
36
+ **/
37
+ let CheckboxFacade = (_dec = withStyle(generateStyle, 'Checkbox'), _dec(_class = (_CheckboxFacade = class CheckboxFacade extends Component {
38
+ constructor(...args) {
39
+ super(...args);
40
+ this.ref = null;
41
+ this.handleRef = el => {
42
+ this.ref = el;
43
+ };
44
+ }
45
+ componentDidMount() {
46
+ var _this$props$makeStyle, _this$props;
47
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
48
+ }
49
+ componentDidUpdate() {
50
+ var _this$props$makeStyle2, _this$props2;
51
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
52
+ }
53
+ renderIcon() {
54
+ const _this$props3 = this.props,
55
+ disabled = _this$props3.disabled,
56
+ readOnly = _this$props3.readOnly,
57
+ indeterminate = _this$props3.indeterminate,
58
+ checked = _this$props3.checked;
59
+ const getIconColor = () => {
60
+ if (disabled) {
61
+ return 'disabledBaseColor';
62
+ }
63
+ if (readOnly) {
64
+ return 'baseColor';
65
+ }
66
+ return 'inverseColor';
67
+ };
68
+ const iconColor = getIconColor();
69
+ if (indeterminate) {
70
+ return renderIconWithProps(MinusInstUIIcon, 'sm', iconColor);
71
+ } else if (checked) {
72
+ return renderIconWithProps(CheckInstUIIcon, 'sm', iconColor);
73
+ } else {
74
+ return null;
75
+ }
76
+ }
77
+ render() {
78
+ const _this$props4 = this.props,
79
+ children = _this$props4.children,
80
+ styles = _this$props4.styles;
81
+ return _jsxs("span", {
82
+ css: styles === null || styles === void 0 ? void 0 : styles.checkboxFacade,
83
+ ref: this.handleRef,
84
+ children: [_jsx("span", {
85
+ css: styles === null || styles === void 0 ? void 0 : styles.facade,
86
+ "aria-hidden": "true",
87
+ children: this.renderIcon()
88
+ }), _jsx("span", {
89
+ css: styles === null || styles === void 0 ? void 0 : styles.label,
90
+ children: children
91
+ })]
92
+ });
93
+ }
94
+ }, _CheckboxFacade.displayName = "CheckboxFacade", _CheckboxFacade.componentId = 'CheckboxFacade', _CheckboxFacade.allowedProps = allowedProps, _CheckboxFacade.defaultProps = {
95
+ checked: false,
96
+ disabled: false,
97
+ readOnly: false,
98
+ focused: false,
99
+ hovered: false,
100
+ size: 'medium',
101
+ indeterminate: false
102
+ }, _CheckboxFacade)) || _class);
103
+ export default CheckboxFacade;
104
+ export { CheckboxFacade };
@@ -0,0 +1,26 @@
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
+ const allowedProps = ['children', 'checked', 'disabled', 'readOnly', 'focused', 'hovered', 'size', 'indeterminate', 'invalid'];
26
+ export { allowedProps };
@@ -0,0 +1,177 @@
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 { calcFocusOutlineStyles } from '@instructure/emotion';
26
+ /**
27
+ * ---
28
+ * private: true
29
+ * ---
30
+ * Generates the style object from the theme and provided additional information
31
+ * @param {Object} componentTheme The theme variable object.
32
+ * @param {Object} props the props of the component, the style is applied to
33
+ * @param {Object} sharedTokens Shared theme token object
34
+ * @param {Object} state the state of the component, the style is applied to
35
+ * @return {Object} The final style object, which will be used in the component
36
+ */
37
+ const generateStyle = (componentTheme, props, sharedTokens) => {
38
+ var _sizeVariants;
39
+ const size = props.size,
40
+ checked = props.checked,
41
+ disabled = props.disabled,
42
+ readOnly = props.readOnly,
43
+ focused = props.focused,
44
+ hovered = props.hovered,
45
+ indeterminate = props.indeterminate,
46
+ invalid = props.invalid;
47
+ const isChecked = checked || indeterminate;
48
+ const sizeVariants = {
49
+ small: {
50
+ label: {
51
+ fontSize: componentTheme.fontSizeSm
52
+ },
53
+ facade: {
54
+ fontSize: componentTheme.fontSizeSm,
55
+ width: componentTheme.controlSizeSm,
56
+ height: componentTheme.controlSizeSm,
57
+ margin: `${componentTheme.controlVerticalMargin} ${componentTheme.gap} 0 0`
58
+ }
59
+ },
60
+ medium: {
61
+ label: {
62
+ fontSize: componentTheme.fontSizeMd
63
+ },
64
+ facade: {
65
+ fontSize: componentTheme.fontSizeMd,
66
+ width: componentTheme.controlSizeMd,
67
+ height: componentTheme.controlSizeMd
68
+ }
69
+ },
70
+ large: {
71
+ label: {
72
+ fontSize: componentTheme.fontSizeLg
73
+ },
74
+ facade: {
75
+ fontSize: componentTheme.fontSizeLg,
76
+ width: componentTheme.controlSizeLg,
77
+ height: componentTheme.controlSizeLg
78
+ }
79
+ }
80
+ };
81
+ const sizeVariant = (_sizeVariants = sizeVariants[size]) !== null && _sizeVariants !== void 0 ? _sizeVariants : sizeVariants.medium;
82
+ const getLabelColor = () => {
83
+ if (disabled) {
84
+ return componentTheme.labelDisabledColor;
85
+ }
86
+ if (readOnly) {
87
+ return componentTheme.labelReadonlyColor;
88
+ }
89
+
90
+ // DEFAULT state
91
+ return hovered ? componentTheme.labelHoverColor : componentTheme.labelBaseColor;
92
+ };
93
+ const getFacadeStyles = () => {
94
+ const baseStyles = {
95
+ position: 'relative',
96
+ display: 'flex',
97
+ alignItems: 'center',
98
+ justifyContent: 'center',
99
+ boxSizing: 'border-box',
100
+ flexShrink: 0,
101
+ transition: 'all 0.2s',
102
+ borderRadius: componentTheme.borderRadius,
103
+ marginInlineEnd: componentTheme.gap,
104
+ marginInlineStart: '0',
105
+ ...sizeVariant.facade
106
+ };
107
+ if (disabled) {
108
+ return {
109
+ ...baseStyles,
110
+ background: componentTheme.backgroundDisabledColor,
111
+ border: `${componentTheme.borderWidth} solid ${componentTheme.borderDisabledColor}`
112
+ };
113
+ }
114
+ if (readOnly) {
115
+ return {
116
+ ...baseStyles,
117
+ background: componentTheme.backgroundReadonlyColor,
118
+ border: `${componentTheme.borderWidth} solid ${componentTheme.borderReadonlyColor}`,
119
+ pointerEvents: 'none'
120
+ };
121
+ }
122
+ if (invalid) {
123
+ return {
124
+ ...baseStyles,
125
+ ...(isChecked && {
126
+ background: componentTheme.backgroundCheckedColor,
127
+ border: `${componentTheme.borderWidth} solid ${hovered ? componentTheme.errorBorderHoverColor : componentTheme.errorBorderColor}`
128
+ }),
129
+ ...(!isChecked && {
130
+ background: hovered ? componentTheme.backgroundHoverColor : componentTheme.backgroundColor,
131
+ border: `${componentTheme.borderWidth} solid ${hovered ? componentTheme.errorBorderHoverColor : componentTheme.errorBorderColor}`
132
+ })
133
+ };
134
+ }
135
+ if (isChecked) {
136
+ return {
137
+ ...baseStyles,
138
+ background: componentTheme.backgroundCheckedColor,
139
+ border: `${componentTheme.borderWidth} solid ${componentTheme.borderCheckedColor}`
140
+ };
141
+ }
142
+
143
+ // DEFAULT (unchecked) state
144
+ return {
145
+ ...baseStyles,
146
+ background: hovered ? componentTheme.backgroundHoverColor : componentTheme.backgroundColor,
147
+ border: `${componentTheme.borderWidth} solid ${hovered ? componentTheme.borderHoverColor : componentTheme.borderColor}`
148
+ };
149
+ };
150
+ return {
151
+ checkboxFacade: {
152
+ label: 'checkboxFacade',
153
+ display: 'flex',
154
+ alignItems: 'flex-start',
155
+ cursor: disabled ? 'not-allowed' : readOnly ? 'default' : 'pointer'
156
+ },
157
+ facade: {
158
+ label: 'checkboxFacade__facade',
159
+ ...getFacadeStyles(),
160
+ ...(sharedTokens !== null && sharedTokens !== void 0 && sharedTokens.focusOutline ? calcFocusOutlineStyles(sharedTokens.focusOutline, {
161
+ withFocusOutline: focused
162
+ }) : {})
163
+ },
164
+ label: {
165
+ label: 'checkboxFacade__label',
166
+ flex: '1 1 auto',
167
+ alignSelf: 'center',
168
+ minWidth: '0.0625rem',
169
+ color: getLabelColor(),
170
+ fontFamily: componentTheme.fontFamily,
171
+ fontWeight: componentTheme.fontWeight,
172
+ lineHeight: componentTheme.lineHeight,
173
+ ...sizeVariant.label
174
+ }
175
+ };
176
+ };
177
+ export default generateStyle;
@@ -0,0 +1,116 @@
1
+ var _dec, _class, _ToggleFacade;
2
+ /*
3
+ * The MIT License (MIT)
4
+ *
5
+ * Copyright (c) 2015 - present Instructure, Inc.
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+
26
+ import { Component } from 'react';
27
+ import { CheckInstUIIcon, XInstUIIcon, renderIconWithProps } from '@instructure/ui-icons';
28
+ import { withStyle } from '@instructure/emotion';
29
+ import generateStyle from "./styles.js";
30
+ import { allowedProps } from "./props.js";
31
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
32
+ /**
33
+ ---
34
+ parent: Checkbox
35
+ ---
36
+ **/
37
+ let ToggleFacade = (_dec = withStyle(generateStyle, 'Toggle'), _dec(_class = (_ToggleFacade = class ToggleFacade extends Component {
38
+ constructor(...args) {
39
+ super(...args);
40
+ this.ref = null;
41
+ this.handleRef = el => {
42
+ this.ref = el;
43
+ };
44
+ }
45
+ componentDidMount() {
46
+ var _this$props$makeStyle, _this$props;
47
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
48
+ }
49
+ componentDidUpdate() {
50
+ var _this$props$makeStyle2, _this$props2;
51
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
52
+ }
53
+ renderIcon() {
54
+ const _this$props3 = this.props,
55
+ disabled = _this$props3.disabled,
56
+ readOnly = _this$props3.readOnly,
57
+ checked = _this$props3.checked;
58
+ const getIconColor = () => {
59
+ if (disabled) {
60
+ return 'disabledBaseColor';
61
+ }
62
+ if (readOnly) {
63
+ return 'mutedColor';
64
+ }
65
+ if (checked) {
66
+ return 'successColor';
67
+ }
68
+ return 'baseColor';
69
+ };
70
+ const iconColor = getIconColor();
71
+ if (checked) {
72
+ return renderIconWithProps(CheckInstUIIcon, 'xs', iconColor);
73
+ } else {
74
+ return renderIconWithProps(XInstUIIcon, 'xs', iconColor);
75
+ }
76
+ }
77
+ renderLabel() {
78
+ const _this$props4 = this.props,
79
+ children = _this$props4.children,
80
+ styles = _this$props4.styles;
81
+ return _jsx("span", {
82
+ css: styles === null || styles === void 0 ? void 0 : styles.label,
83
+ children: children
84
+ });
85
+ }
86
+ render() {
87
+ const _this$props5 = this.props,
88
+ labelPlacement = _this$props5.labelPlacement,
89
+ styles = _this$props5.styles;
90
+ return _jsxs("span", {
91
+ css: styles === null || styles === void 0 ? void 0 : styles.toggleFacade,
92
+ ref: this.handleRef,
93
+ children: [(labelPlacement === 'top' || labelPlacement === 'start') && this.renderLabel(), _jsx("span", {
94
+ css: styles === null || styles === void 0 ? void 0 : styles.facade,
95
+ "aria-hidden": "true",
96
+ children: _jsx("span", {
97
+ css: styles === null || styles === void 0 ? void 0 : styles.icon,
98
+ children: _jsx("span", {
99
+ css: styles === null || styles === void 0 ? void 0 : styles.iconToggle,
100
+ children: this.renderIcon()
101
+ })
102
+ })
103
+ }), labelPlacement === 'end' && this.renderLabel()]
104
+ });
105
+ }
106
+ }, _ToggleFacade.displayName = "ToggleFacade", _ToggleFacade.componentId = 'ToggleFacade', _ToggleFacade.allowedProps = allowedProps, _ToggleFacade.defaultProps = {
107
+ checked: false,
108
+ focused: false,
109
+ hovered: false,
110
+ size: 'medium',
111
+ disabled: false,
112
+ readOnly: false,
113
+ labelPlacement: 'end'
114
+ }, _ToggleFacade)) || _class);
115
+ export default ToggleFacade;
116
+ export { ToggleFacade };
@@ -0,0 +1,26 @@
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
+ const allowedProps = ['children', 'checked', 'disabled', 'readOnly', 'focused', 'hovered', 'size', 'labelPlacement', 'invalid'];
26
+ export { allowedProps };
@@ -0,0 +1,232 @@
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 { boxShadowObjectsToCSSString } from '@instructure/ui-themes';
26
+ import { calcFocusOutlineStyles } from '@instructure/emotion';
27
+ /**
28
+ * ---
29
+ * private: true
30
+ * ---
31
+ * Generates the style object from the theme and provided additional information
32
+ * @param {Object} componentTheme The theme variable object.
33
+ * @param {Object} props the props of the component, the style is applied to
34
+ * @param {Object} sharedTokens Shared theme token object
35
+ * @param {Object} state the state of the component, the style is applied to
36
+ * @return {Object} The final style object, which will be used in the component
37
+ */
38
+ const generateStyle = (componentTheme, props, sharedTokens) => {
39
+ var _labelPlacementVarian, _labelSizeVariants;
40
+ const disabled = props.disabled,
41
+ size = props.size,
42
+ checked = props.checked,
43
+ readOnly = props.readOnly,
44
+ focused = props.focused,
45
+ hovered = props.hovered,
46
+ labelPlacement = props.labelPlacement,
47
+ invalid = props.invalid;
48
+ const labelPlacementVariants = {
49
+ start: {
50
+ facade: {
51
+ marginInlineEnd: componentTheme.marginEnd,
52
+ marginInlineStart: componentTheme.marginStart
53
+ },
54
+ label: {
55
+ textAlign: 'end'
56
+ }
57
+ },
58
+ end: {
59
+ facade: {
60
+ marginInlineEnd: componentTheme.marginEnd
61
+ },
62
+ label: {}
63
+ },
64
+ top: {
65
+ facade: {
66
+ marginTop: componentTheme.marginVertical
67
+ },
68
+ label: {
69
+ display: 'block'
70
+ }
71
+ }
72
+ };
73
+ const labelPlacementVariant = (_labelPlacementVarian = labelPlacementVariants[labelPlacement]) !== null && _labelPlacementVarian !== void 0 ? _labelPlacementVarian : labelPlacementVariants.end;
74
+ const labelSizeVariants = {
75
+ small: {
76
+ fontSize: componentTheme.labelFontSizeSm,
77
+ lineHeight: componentTheme.labelLineHeightSm
78
+ },
79
+ medium: {
80
+ fontSize: componentTheme.labelFontSizeMd,
81
+ lineHeight: componentTheme.labelLineHeightMd
82
+ },
83
+ large: {
84
+ fontSize: componentTheme.labelFontSizeLg,
85
+ lineHeight: componentTheme.labelLineHeightLg
86
+ }
87
+ };
88
+ const sizeVariant = (_labelSizeVariants = labelSizeVariants[size]) !== null && _labelSizeVariants !== void 0 ? _labelSizeVariants : labelSizeVariants.medium;
89
+ const getIconBorderColor = () => {
90
+ if (disabled) {
91
+ return checked ? componentTheme.checkedIconBorderDisabledColor : componentTheme.uncheckedIconBorderDisabledColor;
92
+ }
93
+ if (readOnly) {
94
+ return checked ? componentTheme.checkedIconBorderReadonlyColor : componentTheme.uncheckedIconBorderReadonlyColor;
95
+ }
96
+ if (invalid && !checked) {
97
+ return hovered ? componentTheme.uncheckedIconBorderHoverColor : componentTheme.uncheckedIconErrorBorderColor;
98
+ }
99
+ if (checked) {
100
+ return hovered ? componentTheme.checkedIconBorderHoverColor : componentTheme.checkedIconBorderColor;
101
+ }
102
+
103
+ // DEFAULT (unchecked) state
104
+ return hovered ? componentTheme.uncheckedIconBorderHoverColor : componentTheme.uncheckedIconBorderColor;
105
+ };
106
+ const getFacadeStyles = () => {
107
+ const baseStyles = {
108
+ display: 'inline-block',
109
+ userSelect: 'none',
110
+ position: 'relative',
111
+ borderRadius: componentTheme.borderRadius,
112
+ verticalAlign: 'middle',
113
+ height: componentTheme.toggleSize,
114
+ width: componentTheme.toggleWidth,
115
+ ...labelPlacementVariant.facade
116
+ };
117
+ if (disabled) {
118
+ return {
119
+ ...baseStyles,
120
+ background: checked ? componentTheme.checkedBackgroundDisabledColor : componentTheme.backgroundDisabledColor,
121
+ boxShadow: `inset 0 0 0 ${componentTheme.borderWidth} ${checked ? componentTheme.checkedBorderDisabledColor : componentTheme.borderDisabledColor}`,
122
+ opacity: componentTheme.disabledOpacity
123
+ };
124
+ }
125
+ if (readOnly) {
126
+ return {
127
+ ...baseStyles,
128
+ background: checked ? componentTheme.checkedBackgroundReadonlyColor : componentTheme.backgroundReadonlyColor,
129
+ boxShadow: `inset 0 0 0 ${componentTheme.borderWidth} ${checked ? componentTheme.checkedBorderReadonlyColor : componentTheme.borderReadonlyColor}`,
130
+ pointerEvents: 'none'
131
+ };
132
+ }
133
+ if (invalid) {
134
+ return {
135
+ ...baseStyles,
136
+ ...(checked && {
137
+ background: hovered ? componentTheme.checkedBackgroundHoverColor : componentTheme.checkedBackgroundColor,
138
+ boxShadow: `inset 0 0 0 ${componentTheme.borderWidth} ${componentTheme.errorBorderColor}`
139
+ }),
140
+ ...(!checked && {
141
+ background: hovered ? componentTheme.errorBackgroundHoverColor : componentTheme.errorBackgroundColor,
142
+ boxShadow: `inset 0 0 0 ${componentTheme.borderWidth} ${componentTheme.errorBorderColor}`
143
+ })
144
+ };
145
+ }
146
+ if (checked) {
147
+ return {
148
+ ...baseStyles,
149
+ background: hovered ? componentTheme.checkedBackgroundHoverColor : componentTheme.checkedBackgroundColor,
150
+ boxShadow: `inset 0 0 0 ${componentTheme.borderWidth} ${hovered ? componentTheme.checkedBorderHoverColor : componentTheme.checkedBorderColor}`
151
+ };
152
+ }
153
+
154
+ // DEFAULT (unchecked) state
155
+ return {
156
+ ...baseStyles,
157
+ background: hovered ? componentTheme.backgroundHoverColor : componentTheme.backgroundColor,
158
+ boxShadow: `inset 0 0 0 ${componentTheme.borderWidth} ${hovered ? componentTheme.borderHoverColor : componentTheme.borderColor}`
159
+ };
160
+ };
161
+ return {
162
+ toggleFacade: {
163
+ label: 'toggleFacade',
164
+ display: 'flex',
165
+ alignItems: 'center',
166
+ cursor: disabled ? 'not-allowed' : readOnly ? 'default' : 'pointer',
167
+ ...(labelPlacement === 'top' && {
168
+ display: 'block'
169
+ })
170
+ },
171
+ facade: {
172
+ label: 'toggleFacade__facade',
173
+ ...getFacadeStyles(),
174
+ ...(sharedTokens !== null && sharedTokens !== void 0 && sharedTokens.focusOutline ? calcFocusOutlineStyles(sharedTokens.focusOutline, {
175
+ withFocusOutline: focused
176
+ }) : {})
177
+ },
178
+ icon: {
179
+ label: 'toggleFacade__icon',
180
+ display: 'block',
181
+ textAlign: 'center',
182
+ position: 'absolute',
183
+ top: '0',
184
+ insetInlineStart: '0',
185
+ insetInlineEnd: 'auto',
186
+ transition: 'all 0.2s',
187
+ transform: 'translate3d(0, 0, 0)',
188
+ height: componentTheme.toggleSize,
189
+ width: componentTheme.toggleSize,
190
+ ...(checked && {
191
+ transform: `translateX(calc(${componentTheme.toggleWidth} - ${componentTheme.toggleSize}))`,
192
+ '[dir="rtl"] &': {
193
+ transform: `translateX(calc(-1 * (${componentTheme.toggleWidth} - ${componentTheme.toggleSize})))`
194
+ }
195
+ })
196
+ },
197
+ iconToggle: {
198
+ label: 'toggleFacade__iconToggle',
199
+ position: 'relative',
200
+ height: '100%',
201
+ width: '100%',
202
+ display: 'flex',
203
+ alignItems: 'center',
204
+ justifyContent: 'center',
205
+ '&::before': {
206
+ content: '""',
207
+ position: 'absolute',
208
+ height: `calc(100% - (${componentTheme.borderWidth} * 6))`,
209
+ width: `calc(100% - (${componentTheme.borderWidth} * 6))`,
210
+ background: componentTheme.toggleBackground,
211
+ boxShadow: boxShadowObjectsToCSSString(componentTheme.toggleShadow),
212
+ borderRadius: '100%',
213
+ border: `${componentTheme.borderWidth} solid ${getIconBorderColor()}`
214
+ },
215
+ '& [class*="lucideIcon"] svg': {
216
+ position: 'relative',
217
+ zIndex: 1
218
+ }
219
+ },
220
+ label: {
221
+ label: 'toggleFacade__label',
222
+ flex: 1,
223
+ minWidth: '0.0625rem',
224
+ color: disabled ? componentTheme.labelDisabledColor : componentTheme.labelColor,
225
+ fontFamily: componentTheme.labelFontFamily,
226
+ fontWeight: componentTheme.labelFontWeight,
227
+ ...sizeVariant,
228
+ ...labelPlacementVariant.label
229
+ }
230
+ };
231
+ };
232
+ export default generateStyle;