@instructure/ui-buttons 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 (216) hide show
  1. package/CHANGELOG.md +57 -323
  2. package/es/BaseButton/{index.js → v1/index.js} +2 -2
  3. package/es/BaseButton/v2/index.js +304 -0
  4. package/es/BaseButton/v2/props.js +26 -0
  5. package/es/BaseButton/v2/styles.js +578 -0
  6. package/es/Button/{index.js → v1/index.js} +2 -2
  7. package/es/{CondensedButton → Button/v1}/theme.js +1 -1
  8. package/es/Button/v2/index.js +121 -0
  9. package/es/Button/v2/props.js +26 -0
  10. package/es/CloseButton/{index.js → v1/index.js} +2 -2
  11. package/es/CloseButton/v2/index.js +130 -0
  12. package/es/CloseButton/v2/props.js +26 -0
  13. package/es/CloseButton/v2/styles.js +68 -0
  14. package/es/CondensedButton/{index.js → v1/index.js} +2 -2
  15. package/es/{Button → CondensedButton/v1}/theme.js +1 -1
  16. package/es/CondensedButton/v2/index.js +111 -0
  17. package/es/CondensedButton/v2/props.js +26 -0
  18. package/es/IconButton/{index.js → v1/index.js} +2 -2
  19. package/es/IconButton/{theme.js → v1/theme.js} +1 -1
  20. package/es/IconButton/v2/index.js +121 -0
  21. package/es/IconButton/v2/props.js +26 -0
  22. package/es/ToggleButton/{index.js → v1/index.js} +2 -2
  23. package/es/ToggleButton/v2/index.js +121 -0
  24. package/es/ToggleButton/v2/props.js +26 -0
  25. package/es/exports/a.js +29 -0
  26. package/es/exports/b.js +29 -0
  27. package/lib/BaseButton/{index.js → v1/index.js} +3 -3
  28. package/lib/BaseButton/v2/index.js +311 -0
  29. package/lib/BaseButton/v2/props.js +31 -0
  30. package/lib/BaseButton/v2/styles.js +584 -0
  31. package/lib/Button/v1/index.js +128 -0
  32. package/lib/Button/{theme.js → v1/theme.js} +1 -1
  33. package/lib/Button/{index.js → v2/index.js} +3 -4
  34. package/lib/Button/v2/props.js +31 -0
  35. package/lib/CloseButton/{index.js → v1/index.js} +4 -4
  36. package/lib/CloseButton/v2/index.js +136 -0
  37. package/lib/CloseButton/v2/props.js +31 -0
  38. package/lib/CloseButton/v2/styles.js +74 -0
  39. package/lib/CondensedButton/{index.js → v1/index.js} +3 -3
  40. package/lib/CondensedButton/{theme.js → v1/theme.js} +1 -1
  41. package/lib/CondensedButton/v2/index.js +116 -0
  42. package/lib/CondensedButton/v2/props.js +31 -0
  43. package/lib/IconButton/{index.js → v1/index.js} +3 -3
  44. package/lib/IconButton/{theme.js → v1/theme.js} +1 -1
  45. package/lib/IconButton/v2/index.js +126 -0
  46. package/lib/IconButton/v2/props.js +31 -0
  47. package/lib/ToggleButton/{index.js → v1/index.js} +4 -4
  48. package/lib/ToggleButton/v2/index.js +127 -0
  49. package/lib/ToggleButton/v2/props.js +31 -0
  50. package/lib/{index.js → exports/a.js} +12 -12
  51. package/lib/exports/b.js +47 -0
  52. package/package.json +46 -24
  53. package/src/BaseButton/{index.tsx → v1/index.tsx} +3 -3
  54. package/src/BaseButton/{props.ts → v1/props.ts} +1 -1
  55. package/src/BaseButton/v2/README.md +15 -0
  56. package/src/BaseButton/v2/index.tsx +343 -0
  57. package/src/BaseButton/v2/props.ts +226 -0
  58. package/src/BaseButton/v2/styles.ts +640 -0
  59. package/src/Button/{index.tsx → v1/index.tsx} +2 -2
  60. package/src/Button/{props.ts → v1/props.ts} +1 -1
  61. package/src/{CondensedButton → Button/v1}/theme.ts +1 -1
  62. package/src/Button/v2/README.md +338 -0
  63. package/src/Button/v2/index.tsx +137 -0
  64. package/src/Button/v2/props.ts +159 -0
  65. package/src/CloseButton/{index.tsx → v1/index.tsx} +2 -2
  66. package/src/CloseButton/{props.ts → v1/props.ts} +1 -1
  67. package/src/CloseButton/v2/README.md +70 -0
  68. package/src/CloseButton/v2/index.tsx +142 -0
  69. package/src/CloseButton/v2/props.ts +148 -0
  70. package/src/CloseButton/v2/styles.ts +81 -0
  71. package/src/CondensedButton/{index.tsx → v1/index.tsx} +2 -2
  72. package/src/CondensedButton/{props.ts → v1/props.ts} +1 -1
  73. package/src/{Button → CondensedButton/v1}/theme.ts +1 -1
  74. package/src/CondensedButton/v2/README.md +75 -0
  75. package/src/CondensedButton/v2/index.tsx +129 -0
  76. package/src/CondensedButton/v2/props.ts +134 -0
  77. package/src/IconButton/{index.tsx → v1/index.tsx} +2 -2
  78. package/src/IconButton/{props.ts → v1/props.ts} +1 -1
  79. package/src/IconButton/{theme.ts → v1/theme.ts} +1 -1
  80. package/src/IconButton/v2/README.md +86 -0
  81. package/src/IconButton/v2/index.tsx +138 -0
  82. package/src/IconButton/v2/props.ts +166 -0
  83. package/src/ToggleButton/{index.tsx → v1/index.tsx} +2 -2
  84. package/src/ToggleButton/{props.ts → v1/props.ts} +1 -1
  85. package/src/ToggleButton/v2/README.md +85 -0
  86. package/src/ToggleButton/v2/index.tsx +133 -0
  87. package/src/ToggleButton/v2/props.ts +143 -0
  88. package/src/exports/a.ts +40 -0
  89. package/src/exports/b.ts +40 -0
  90. package/tsconfig.build.tsbuildinfo +1 -1
  91. package/types/BaseButton/{index.d.ts → v1/index.d.ts} +1 -1
  92. package/types/BaseButton/v1/index.d.ts.map +1 -0
  93. package/types/BaseButton/{props.d.ts → v1/props.d.ts} +1 -1
  94. package/types/BaseButton/v1/props.d.ts.map +1 -0
  95. package/types/BaseButton/v1/styles.d.ts.map +1 -0
  96. package/types/BaseButton/v1/theme.d.ts.map +1 -0
  97. package/types/BaseButton/v2/index.d.ts +48 -0
  98. package/types/BaseButton/v2/index.d.ts.map +1 -0
  99. package/types/BaseButton/v2/props.d.ts +118 -0
  100. package/types/BaseButton/v2/props.d.ts.map +1 -0
  101. package/types/BaseButton/v2/styles.d.ts +5 -0
  102. package/types/BaseButton/v2/styles.d.ts.map +1 -0
  103. package/types/Button/{index.d.ts → v1/index.d.ts} +2 -2
  104. package/types/Button/v1/index.d.ts.map +1 -0
  105. package/types/Button/{props.d.ts → v1/props.d.ts} +1 -1
  106. package/types/Button/v1/props.d.ts.map +1 -0
  107. package/types/Button/v1/theme.d.ts +2 -0
  108. package/types/Button/v1/theme.d.ts.map +1 -0
  109. package/types/Button/v2/index.d.ts +51 -0
  110. package/types/Button/v2/index.d.ts.map +1 -0
  111. package/types/Button/v2/props.d.ts +82 -0
  112. package/types/Button/v2/props.d.ts.map +1 -0
  113. package/types/CloseButton/{index.d.ts → v1/index.d.ts} +1 -1
  114. package/types/CloseButton/v1/index.d.ts.map +1 -0
  115. package/types/CloseButton/{props.d.ts → v1/props.d.ts} +1 -1
  116. package/types/CloseButton/v1/props.d.ts.map +1 -0
  117. package/types/CloseButton/v1/styles.d.ts.map +1 -0
  118. package/types/CloseButton/v1/theme.d.ts.map +1 -0
  119. package/types/CloseButton/v2/index.d.ts +46 -0
  120. package/types/CloseButton/v2/index.d.ts.map +1 -0
  121. package/types/CloseButton/v2/props.d.ts +77 -0
  122. package/types/CloseButton/v2/props.d.ts.map +1 -0
  123. package/types/CloseButton/v2/styles.d.ts +15 -0
  124. package/types/CloseButton/v2/styles.d.ts.map +1 -0
  125. package/types/CondensedButton/{index.d.ts → v1/index.d.ts} +2 -2
  126. package/types/CondensedButton/v1/index.d.ts.map +1 -0
  127. package/types/CondensedButton/{props.d.ts → v1/props.d.ts} +1 -1
  128. package/types/CondensedButton/v1/props.d.ts.map +1 -0
  129. package/types/CondensedButton/v1/theme.d.ts +2 -0
  130. package/types/CondensedButton/v1/theme.d.ts.map +1 -0
  131. package/types/CondensedButton/v2/index.d.ts +45 -0
  132. package/types/CondensedButton/v2/index.d.ts.map +1 -0
  133. package/types/CondensedButton/v2/props.d.ts +69 -0
  134. package/types/CondensedButton/v2/props.d.ts.map +1 -0
  135. package/types/IconButton/{index.d.ts → v1/index.d.ts} +2 -2
  136. package/types/IconButton/v1/index.d.ts.map +1 -0
  137. package/types/IconButton/{props.d.ts → v1/props.d.ts} +1 -1
  138. package/types/IconButton/v1/props.d.ts.map +1 -0
  139. package/types/IconButton/v1/theme.d.ts +2 -0
  140. package/types/IconButton/v1/theme.d.ts.map +1 -0
  141. package/types/IconButton/v2/index.d.ts +51 -0
  142. package/types/IconButton/v2/index.d.ts.map +1 -0
  143. package/types/IconButton/v2/props.d.ts +85 -0
  144. package/types/IconButton/v2/props.d.ts.map +1 -0
  145. package/types/ToggleButton/{index.d.ts → v1/index.d.ts} +1 -1
  146. package/types/ToggleButton/v1/index.d.ts.map +1 -0
  147. package/types/ToggleButton/{props.d.ts → v1/props.d.ts} +1 -1
  148. package/types/ToggleButton/v1/props.d.ts.map +1 -0
  149. package/types/ToggleButton/v2/index.d.ts +43 -0
  150. package/types/ToggleButton/v2/index.d.ts.map +1 -0
  151. package/types/ToggleButton/v2/props.d.ts +75 -0
  152. package/types/ToggleButton/v2/props.d.ts.map +1 -0
  153. package/types/exports/a.d.ts +13 -0
  154. package/types/exports/a.d.ts.map +1 -0
  155. package/types/exports/b.d.ts +13 -0
  156. package/types/exports/b.d.ts.map +1 -0
  157. package/es/index.js +0 -29
  158. package/src/index.ts +0 -37
  159. package/types/BaseButton/index.d.ts.map +0 -1
  160. package/types/BaseButton/props.d.ts.map +0 -1
  161. package/types/BaseButton/styles.d.ts.map +0 -1
  162. package/types/BaseButton/theme.d.ts.map +0 -1
  163. package/types/Button/index.d.ts.map +0 -1
  164. package/types/Button/props.d.ts.map +0 -1
  165. package/types/Button/theme.d.ts +0 -2
  166. package/types/Button/theme.d.ts.map +0 -1
  167. package/types/CloseButton/index.d.ts.map +0 -1
  168. package/types/CloseButton/props.d.ts.map +0 -1
  169. package/types/CloseButton/styles.d.ts.map +0 -1
  170. package/types/CloseButton/theme.d.ts.map +0 -1
  171. package/types/CondensedButton/index.d.ts.map +0 -1
  172. package/types/CondensedButton/props.d.ts.map +0 -1
  173. package/types/CondensedButton/theme.d.ts +0 -2
  174. package/types/CondensedButton/theme.d.ts.map +0 -1
  175. package/types/IconButton/index.d.ts.map +0 -1
  176. package/types/IconButton/props.d.ts.map +0 -1
  177. package/types/IconButton/theme.d.ts +0 -2
  178. package/types/IconButton/theme.d.ts.map +0 -1
  179. package/types/ToggleButton/index.d.ts.map +0 -1
  180. package/types/ToggleButton/props.d.ts.map +0 -1
  181. package/types/index.d.ts +0 -13
  182. package/types/index.d.ts.map +0 -1
  183. /package/es/BaseButton/{props.js → v1/props.js} +0 -0
  184. /package/es/BaseButton/{styles.js → v1/styles.js} +0 -0
  185. /package/es/BaseButton/{theme.js → v1/theme.js} +0 -0
  186. /package/es/Button/{props.js → v1/props.js} +0 -0
  187. /package/es/CloseButton/{props.js → v1/props.js} +0 -0
  188. /package/es/CloseButton/{styles.js → v1/styles.js} +0 -0
  189. /package/es/CloseButton/{theme.js → v1/theme.js} +0 -0
  190. /package/es/CondensedButton/{props.js → v1/props.js} +0 -0
  191. /package/es/IconButton/{props.js → v1/props.js} +0 -0
  192. /package/es/ToggleButton/{props.js → v1/props.js} +0 -0
  193. /package/lib/BaseButton/{props.js → v1/props.js} +0 -0
  194. /package/lib/BaseButton/{styles.js → v1/styles.js} +0 -0
  195. /package/lib/BaseButton/{theme.js → v1/theme.js} +0 -0
  196. /package/lib/Button/{props.js → v1/props.js} +0 -0
  197. /package/lib/CloseButton/{props.js → v1/props.js} +0 -0
  198. /package/lib/CloseButton/{styles.js → v1/styles.js} +0 -0
  199. /package/lib/CloseButton/{theme.js → v1/theme.js} +0 -0
  200. /package/lib/CondensedButton/{props.js → v1/props.js} +0 -0
  201. /package/lib/IconButton/{props.js → v1/props.js} +0 -0
  202. /package/lib/ToggleButton/{props.js → v1/props.js} +0 -0
  203. /package/src/BaseButton/{README.md → v1/README.md} +0 -0
  204. /package/src/BaseButton/{styles.ts → v1/styles.ts} +0 -0
  205. /package/src/BaseButton/{theme.ts → v1/theme.ts} +0 -0
  206. /package/src/Button/{README.md → v1/README.md} +0 -0
  207. /package/src/CloseButton/{README.md → v1/README.md} +0 -0
  208. /package/src/CloseButton/{styles.ts → v1/styles.ts} +0 -0
  209. /package/src/CloseButton/{theme.ts → v1/theme.ts} +0 -0
  210. /package/src/CondensedButton/{README.md → v1/README.md} +0 -0
  211. /package/src/IconButton/{README.md → v1/README.md} +0 -0
  212. /package/src/ToggleButton/{README.md → v1/README.md} +0 -0
  213. /package/types/BaseButton/{styles.d.ts → v1/styles.d.ts} +0 -0
  214. /package/types/BaseButton/{theme.d.ts → v1/theme.d.ts} +0 -0
  215. /package/types/CloseButton/{styles.d.ts → v1/styles.d.ts} +0 -0
  216. /package/types/CloseButton/{theme.d.ts → v1/theme.d.ts} +0 -0
@@ -30,12 +30,12 @@ import keycode from 'keycode';
30
30
  import { getElementType, getInteraction, passthroughProps, callRenderProp } from '@instructure/ui-react-utils';
31
31
  import { isActiveElement } from '@instructure/ui-dom-utils';
32
32
  import { hasVisibleChildren } from '@instructure/ui-a11y-utils';
33
- import { View } from '@instructure/ui-view';
33
+ import { View } from '@instructure/ui-view/v11_6';
34
34
  // TODO these have to be imported in separate lines because otherwise `isSafari` will be missing from the babel build
35
35
  // this bug is very likely caused by `babel-plugin-transform-imports` and can be reverted once it is removed from the codebase
36
36
  import { isSafari } from '@instructure/ui-utils';
37
37
  import { combineDataCid } from '@instructure/ui-utils';
38
- import { withStyle } from '@instructure/emotion';
38
+ import { withStyleLegacy as withStyle } from '@instructure/emotion';
39
39
  import generateStyles from "./styles.js";
40
40
  import generateComponentTheme from "./theme.js";
41
41
  import { allowedProps } from "./props.js";
@@ -0,0 +1,304 @@
1
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
+ const _excluded = ["type", "size", "elementRef", "as", "href", "color", "focusColor", "textAlign", "shape", "display", "withBackground", "withBorder", "isCondensed", "margin", "cursor", "onClick", "renderIcon", "tabIndex", "styles", "makeStyles", "withFocusOutline"];
3
+ var _dec, _class, _BaseButton;
4
+ /*
5
+ * The MIT License (MIT)
6
+ *
7
+ * Copyright (c) 2015 - present Instructure, Inc.
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ * of this software and associated documentation files (the "Software"), to deal
11
+ * in the Software without restriction, including without limitation the rights
12
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ * copies of the Software, and to permit persons to whom the Software is
14
+ * furnished to do so, subject to the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be included in all
17
+ * copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ * SOFTWARE.
26
+ */
27
+
28
+ import { Component } from 'react';
29
+ import keycode from 'keycode';
30
+ import { getElementType, getInteraction, passthroughProps } from '@instructure/ui-react-utils';
31
+ import { isActiveElement } from '@instructure/ui-dom-utils';
32
+ import { hasVisibleChildren } from '@instructure/ui-a11y-utils';
33
+ import { renderIconWithProps } from '@instructure/ui-icons';
34
+ import { View } from '@instructure/ui-view/latest';
35
+ // TODO these have to be imported in separate lines because otherwise `isSafari` will be missing from the babel build
36
+ // this bug is very likely caused by `babel-plugin-transform-imports` and can be reverted once it is removed from the codebase
37
+ import { isSafari } from '@instructure/ui-utils';
38
+ import { combineDataCid } from '@instructure/ui-utils';
39
+ import { withStyle } from '@instructure/emotion';
40
+ import generateStyles from "./styles.js";
41
+ import { allowedProps } from "./props.js";
42
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
43
+ const buttonSizeToIconSize = {
44
+ small: 'sm',
45
+ medium: 'md',
46
+ large: 'lg',
47
+ condensedSmall: 'xs',
48
+ condensedMedium: 'xs'
49
+ };
50
+ const buttonColorToIconColor = {
51
+ 'primary': 'inherit',
52
+ 'primary-inverse': 'inherit',
53
+ 'secondary': 'inherit',
54
+ 'success': 'inherit',
55
+ 'danger': 'inherit',
56
+ 'ai-primary': 'inherit',
57
+ 'ai-secondary': 'ai'
58
+ };
59
+
60
+ /**
61
+ ---
62
+ category: components/utilities
63
+ ---
64
+ **/
65
+ let BaseButton = (_dec = withStyle(generateStyles), _dec(_class = (_BaseButton = class BaseButton extends Component {
66
+ constructor(...args) {
67
+ super(...args);
68
+ this.ref = null;
69
+ this.handleElementRef = el => {
70
+ const elementRef = this.props.elementRef;
71
+ this.ref = el;
72
+ if (typeof elementRef === 'function') {
73
+ elementRef(el);
74
+ }
75
+ };
76
+ this.handleClick = event => {
77
+ const onClick = this.props.onClick;
78
+ const interaction = this.interaction;
79
+ if (interaction !== 'enabled') {
80
+ event.preventDefault();
81
+ event.stopPropagation();
82
+ return;
83
+ }
84
+ if (typeof onClick === 'function') {
85
+ onClick(event);
86
+ }
87
+ };
88
+ this.handleKeyDown = event => {
89
+ const _this$props = this.props,
90
+ onClick = _this$props.onClick,
91
+ onKeyDown = _this$props.onKeyDown,
92
+ href = _this$props.href;
93
+ const interaction = this.interaction;
94
+ if (typeof onKeyDown === 'function') {
95
+ onKeyDown(event);
96
+ }
97
+
98
+ // behave like a button when space key is pressed
99
+ const _keycode$codes = keycode.codes,
100
+ space = _keycode$codes.space,
101
+ enter = _keycode$codes.enter;
102
+ if (this.elementType !== 'button' && [space, enter].includes(event.keyCode)) {
103
+ event.preventDefault();
104
+ event.stopPropagation();
105
+ if (typeof onClick === 'function' && interaction === 'enabled') {
106
+ onClick(event);
107
+ }
108
+ if (href) {
109
+ this.ref && this.ref.click();
110
+ }
111
+ }
112
+ };
113
+ }
114
+ componentDidMount() {
115
+ var _this$props$makeStyle, _this$props2;
116
+ (_this$props$makeStyle = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props2, this.makeStylesVariables);
117
+ }
118
+ componentDidUpdate() {
119
+ var _this$props$makeStyle2, _this$props3;
120
+ (_this$props$makeStyle2 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props3, this.makeStylesVariables);
121
+ }
122
+ get makeStylesVariables() {
123
+ return {
124
+ isDisabled: this.isDisabled,
125
+ hasOnlyIconVisible: this.hasOnlyIconVisible,
126
+ isEnabled: this.isEnabled
127
+ };
128
+ }
129
+ get hasOnlyIconVisible() {
130
+ const _this$props4 = this.props,
131
+ children = _this$props4.children,
132
+ renderIcon = _this$props4.renderIcon;
133
+ return !!(renderIcon && !hasVisibleChildren(children));
134
+ }
135
+ get elementType() {
136
+ return getElementType(BaseButton, this.props);
137
+ }
138
+ get interaction() {
139
+ return getInteraction({
140
+ props: this.props
141
+ });
142
+ }
143
+ get isDisabled() {
144
+ return this.interaction === 'disabled';
145
+ }
146
+ get isReadOnly() {
147
+ return this.interaction === 'readonly';
148
+ }
149
+ get isEnabled() {
150
+ return this.interaction === 'enabled';
151
+ }
152
+ get focusColor() {
153
+ const _this$props5 = this.props,
154
+ color = _this$props5.color,
155
+ focusColor = _this$props5.focusColor,
156
+ withBackground = _this$props5.withBackground;
157
+
158
+ // Give user specified focusColor preference
159
+ if (focusColor) {
160
+ return focusColor;
161
+ }
162
+
163
+ // The `primary-inverse` background has an info focus outline
164
+ // by default since it is replacing the `light` button variant.
165
+ // Override the focus color with info even though it is
166
+ // an inverse color
167
+ if (color === 'primary-inverse' && withBackground) {
168
+ return 'info';
169
+ }
170
+ return color.includes('inverse') ? 'inverse' : 'info';
171
+ }
172
+ get focused() {
173
+ return isActiveElement(this.ref);
174
+ }
175
+ focus() {
176
+ this.ref && this.ref.focus();
177
+ }
178
+ renderChildren() {
179
+ const _this$props6 = this.props,
180
+ renderIcon = _this$props6.renderIcon,
181
+ children = _this$props6.children,
182
+ styles = _this$props6.styles,
183
+ size = _this$props6.size,
184
+ color = _this$props6.color;
185
+ const wrappedChildren = _jsx("span", {
186
+ css: styles === null || styles === void 0 ? void 0 : styles.children,
187
+ children: children
188
+ });
189
+ if (!renderIcon) {
190
+ return wrappedChildren;
191
+ }
192
+ const hasOnlyIconVisible = this.hasOnlyIconVisible;
193
+ const iconSize = buttonSizeToIconSize[size];
194
+ const iconColor = buttonColorToIconColor[color];
195
+ const wrappedIcon = _jsx("span", {
196
+ css: styles === null || styles === void 0 ? void 0 : styles.iconSVG,
197
+ children: renderIconWithProps(renderIcon, iconSize, iconColor)
198
+ });
199
+ const flexChildren = hasOnlyIconVisible ? _jsxs("span", {
200
+ css: styles === null || styles === void 0 ? void 0 : styles.iconOnly,
201
+ children: [wrappedIcon, children]
202
+ }) : [_jsx("span", {
203
+ css: styles === null || styles === void 0 ? void 0 : styles.iconWrapper,
204
+ children: wrappedIcon
205
+ }, "icon"), _jsx("span", {
206
+ css: styles === null || styles === void 0 ? void 0 : styles.childrenWrapper,
207
+ children: wrappedChildren
208
+ }, "children")];
209
+ return _jsx("span", {
210
+ css: styles === null || styles === void 0 ? void 0 : styles.childrenLayout,
211
+ children: flexChildren
212
+ });
213
+ }
214
+ render() {
215
+ const _this$props7 = this.props,
216
+ type = _this$props7.type,
217
+ size = _this$props7.size,
218
+ elementRef = _this$props7.elementRef,
219
+ as = _this$props7.as,
220
+ href = _this$props7.href,
221
+ color = _this$props7.color,
222
+ focusColor = _this$props7.focusColor,
223
+ textAlign = _this$props7.textAlign,
224
+ shape = _this$props7.shape,
225
+ display = _this$props7.display,
226
+ withBackground = _this$props7.withBackground,
227
+ withBorder = _this$props7.withBorder,
228
+ isCondensed = _this$props7.isCondensed,
229
+ margin = _this$props7.margin,
230
+ cursor = _this$props7.cursor,
231
+ onClick = _this$props7.onClick,
232
+ renderIcon = _this$props7.renderIcon,
233
+ tabIndex = _this$props7.tabIndex,
234
+ styles = _this$props7.styles,
235
+ makeStyles = _this$props7.makeStyles,
236
+ withFocusOutline = _this$props7.withFocusOutline,
237
+ props = _objectWithoutProperties(_this$props7, _excluded);
238
+ const isDisabled = this.isDisabled,
239
+ isReadOnly = this.isReadOnly,
240
+ elementType = this.elementType;
241
+ // only add 0 tabIndex value if it doesn't have it by default, see
242
+ // https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex
243
+ let needsZeroTabIndex = true;
244
+ if (typeof elementType == 'string') {
245
+ if (['button', 'frame', 'iframe', 'input', 'object', 'select', 'textarea', 'summary'].includes(elementType)) {
246
+ needsZeroTabIndex = false;
247
+ }
248
+ if (href && (elementType === 'a' || elementType === 'area')) {
249
+ needsZeroTabIndex = false;
250
+ }
251
+ }
252
+ let tabIndexValue = tabIndex;
253
+ // In Safari, a button cannot get focus unless it has an explicit 0 tabindex
254
+ if (onClick && as && needsZeroTabIndex || isSafari() && as) {
255
+ tabIndexValue = tabIndex || 0;
256
+ }
257
+ return _jsx(View, {
258
+ ...passthroughProps(props),
259
+ as: elementType,
260
+ focusColor: this.focusColor,
261
+ position: "relative",
262
+ display: display,
263
+ width: display === 'block' ? '100%' : 'auto',
264
+ borderRadius: shape === 'circle' ? 'circle' : 'medium',
265
+ background: "transparent",
266
+ padding: "none",
267
+ borderWidth: "none",
268
+ margin: margin,
269
+ cursor: isDisabled ? 'not-allowed' : cursor,
270
+ href: href,
271
+ type: href ? void 0 : type,
272
+ elementRef: this.handleElementRef,
273
+ onClick: this.handleClick,
274
+ onKeyDown: this.handleKeyDown,
275
+ role: onClick && as !== 'button' ? 'button' : void 0,
276
+ tabIndex: tabIndexValue,
277
+ disabled: isDisabled || isReadOnly,
278
+ css: styles === null || styles === void 0 ? void 0 : styles.baseButton,
279
+ withFocusOutline: withFocusOutline,
280
+ "data-cid": combineDataCid('BaseButton', this.props),
281
+ children: _jsx("span", {
282
+ css: styles === null || styles === void 0 ? void 0 : styles.content,
283
+ children: this.renderChildren()
284
+ })
285
+ });
286
+ }
287
+ }, _BaseButton.displayName = "BaseButton", _BaseButton.componentId = 'BaseButton', _BaseButton.allowedProps = allowedProps, _BaseButton.defaultProps = {
288
+ type: 'button',
289
+ size: 'medium',
290
+ as: 'button',
291
+ // Leave interaction default undefined so that `disabled` and `readOnly` can also be supplied
292
+ interaction: void 0,
293
+ color: 'secondary',
294
+ shape: 'rectangle',
295
+ display: 'inline-block',
296
+ textAlign: 'start',
297
+ withBackground: true,
298
+ withBorder: true,
299
+ isCondensed: false,
300
+ margin: '0',
301
+ cursor: 'pointer'
302
+ }, _BaseButton)) || _class);
303
+ export { BaseButton };
304
+ export default BaseButton;
@@ -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 = ['as', 'children', 'color', 'cursor', 'display', 'elementRef', 'focusColor', 'href', 'interaction', 'isCondensed', 'margin', 'onClick', 'onKeyDown', 'renderIcon', 'shape', 'size', 'tabIndex', 'textAlign', 'type', 'withBackground', 'withBorder'];
26
+ export { allowedProps };