@instructure/ui-tabs 8.33.1 → 8.33.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/es/Tabs/Panel/index.js +14 -25
- package/es/Tabs/Panel/props.js +1 -0
- package/es/Tabs/Panel/styles.js +1 -2
- package/es/Tabs/Panel/theme.js +5 -5
- package/es/Tabs/Tab/index.js +17 -32
- package/es/Tabs/Tab/props.js +1 -0
- package/es/Tabs/Tab/styles.js +10 -7
- package/es/Tabs/Tab/theme.js +5 -5
- package/es/Tabs/TabsLocator.js +2 -1
- package/es/Tabs/index.js +27 -75
- package/es/Tabs/props.js +1 -0
- package/es/Tabs/styles.js +3 -3
- package/es/Tabs/theme.js +5 -5
- package/es/index.js +1 -0
- package/lib/Tabs/Panel/index.js +13 -34
- package/lib/Tabs/Panel/props.js +1 -4
- package/lib/Tabs/Panel/styles.js +1 -3
- package/lib/Tabs/Panel/theme.js +5 -6
- package/lib/Tabs/Tab/index.js +16 -42
- package/lib/Tabs/Tab/props.js +1 -3
- package/lib/Tabs/Tab/styles.js +10 -9
- package/lib/Tabs/Tab/theme.js +5 -6
- package/lib/Tabs/TabsLocator.js +3 -4
- package/lib/Tabs/index.js +27 -100
- package/lib/Tabs/locator.js +0 -2
- package/lib/Tabs/props.js +1 -6
- package/lib/Tabs/styles.js +3 -4
- package/lib/Tabs/theme.js +5 -6
- package/lib/index.js +0 -1
- package/package.json +20 -20
- package/tsconfig.build.tsbuildinfo +1 -1
package/es/Tabs/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
2
|
const _excluded = ["children", "elementRef", "maxWidth", "variant", "margin", "screenReaderLabel", "onRequestTabChange", "tabOverflow", "styles"];
|
|
3
|
-
|
|
4
3
|
var _dec, _dec2, _class, _class2;
|
|
5
|
-
|
|
6
4
|
/*
|
|
7
5
|
* The MIT License (MIT)
|
|
8
6
|
*
|
|
@@ -45,7 +43,6 @@ import generateComponentTheme from './theme';
|
|
|
45
43
|
import { Tab } from './Tab';
|
|
46
44
|
import { Panel } from './Panel';
|
|
47
45
|
import { allowedProps, propTypes } from './props';
|
|
48
|
-
|
|
49
46
|
/**
|
|
50
47
|
---
|
|
51
48
|
category: components
|
|
@@ -61,26 +58,21 @@ let Tabs = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
|
|
|
61
58
|
this._debounced = void 0;
|
|
62
59
|
this._resizeListener = void 0;
|
|
63
60
|
this.ref = null;
|
|
64
|
-
|
|
65
61
|
this.handleRef = el => {
|
|
66
62
|
const elementRef = this.props.elementRef;
|
|
67
63
|
this.ref = el;
|
|
68
|
-
|
|
69
64
|
if (typeof elementRef === 'function') {
|
|
70
65
|
elementRef(el);
|
|
71
66
|
}
|
|
72
67
|
};
|
|
73
|
-
|
|
74
68
|
this.handleTabClick = (event, _ref) => {
|
|
75
69
|
let index = _ref.index;
|
|
76
70
|
const nextTab = this.getNextTab(index, 0);
|
|
77
71
|
this.fireOnChange(event, nextTab);
|
|
78
72
|
};
|
|
79
|
-
|
|
80
73
|
this.handleTabKeyDown = (event, _ref2) => {
|
|
81
74
|
let index = _ref2.index;
|
|
82
75
|
let nextTab;
|
|
83
|
-
|
|
84
76
|
if (event.keyCode === keycode.codes.up || event.keyCode === keycode.codes.left) {
|
|
85
77
|
// Select next tab to the left
|
|
86
78
|
nextTab = this.getNextTab(index, -1);
|
|
@@ -88,34 +80,28 @@ let Tabs = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
|
|
|
88
80
|
// Select next tab to the right
|
|
89
81
|
nextTab = this.getNextTab(index, 1);
|
|
90
82
|
}
|
|
91
|
-
|
|
92
83
|
if (nextTab) {
|
|
93
84
|
event.preventDefault();
|
|
94
85
|
this.fireOnChange(event, nextTab);
|
|
95
86
|
}
|
|
96
87
|
};
|
|
97
|
-
|
|
98
88
|
this.handleResize = () => {
|
|
99
89
|
this.setState({
|
|
100
90
|
withTabListOverflow: this._tabList.scrollWidth > this._tabList.offsetWidth
|
|
101
91
|
});
|
|
102
92
|
this._tabListPosition = getBoundingClientRect(this._tabList);
|
|
103
93
|
};
|
|
104
|
-
|
|
105
94
|
this.handleFocusableRef = el => {
|
|
106
95
|
this._focusable = el;
|
|
107
96
|
};
|
|
108
|
-
|
|
109
97
|
this.handleTabListRef = el => {
|
|
110
98
|
this._tabList = el;
|
|
111
99
|
};
|
|
112
|
-
|
|
113
100
|
this.handleScroll = event => {
|
|
114
101
|
if (this.props.tabOverflow !== 'scroll' || !this.state.withTabListOverflow) {
|
|
115
102
|
event.preventDefault();
|
|
116
103
|
return;
|
|
117
104
|
}
|
|
118
|
-
|
|
119
105
|
const tabList = event.currentTarget;
|
|
120
106
|
const scrollLeftMax = Math.round(tabList.scrollWidth - getBoundingClientRect(tabList).width);
|
|
121
107
|
const scrollLeft = Math.floor(Math.abs(tabList.scrollLeft));
|
|
@@ -124,65 +110,54 @@ let Tabs = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
|
|
|
124
110
|
showEndOverLay: scrollLeft < scrollLeftMax
|
|
125
111
|
});
|
|
126
112
|
};
|
|
127
|
-
|
|
128
113
|
this.state = {
|
|
129
114
|
withTabListOverflow: false,
|
|
130
115
|
showStartOverLay: false,
|
|
131
116
|
showEndOverLay: false
|
|
132
117
|
};
|
|
133
118
|
}
|
|
134
|
-
|
|
135
119
|
componentDidMount() {
|
|
136
120
|
var _this$props$makeStyle, _this$props;
|
|
137
|
-
|
|
138
121
|
if (this.props.tabOverflow === 'scroll' && this._tabList) {
|
|
139
122
|
this.startScrollOverflow();
|
|
140
123
|
}
|
|
141
|
-
|
|
142
124
|
if (this.props.shouldFocusOnRender) {
|
|
143
125
|
this.focus();
|
|
144
126
|
}
|
|
145
|
-
|
|
146
127
|
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
147
128
|
}
|
|
148
|
-
|
|
149
129
|
componentDidUpdate(prevProps, prevState) {
|
|
150
130
|
var _this$props$makeStyle2, _this$props2;
|
|
151
|
-
|
|
152
131
|
if (this.props.shouldFocusOnRender && !prevProps.shouldFocusOnRender) {
|
|
153
132
|
this.focus();
|
|
154
|
-
}
|
|
155
|
-
|
|
133
|
+
}
|
|
156
134
|
|
|
135
|
+
// start event listeners for scroll overflow
|
|
157
136
|
if (prevProps.tabOverflow === 'stack' && this.props.tabOverflow === 'scroll') {
|
|
158
137
|
this.startScrollOverflow();
|
|
159
|
-
}
|
|
160
|
-
|
|
138
|
+
}
|
|
161
139
|
|
|
140
|
+
// cancel event listeners for scroll overflow
|
|
162
141
|
if (prevProps.tabOverflow === 'scroll' && this.props.tabOverflow === 'stack') {
|
|
163
142
|
this.cancelScrollOverflow();
|
|
164
|
-
}
|
|
165
|
-
|
|
143
|
+
}
|
|
166
144
|
|
|
145
|
+
// we need to recalculate the scroll overflow if the style changes
|
|
167
146
|
if (this.props.tabOverflow === 'scroll' && prevProps.styles !== this.props.styles) {
|
|
168
147
|
this.handleResize();
|
|
169
|
-
}
|
|
170
|
-
// make sure active tab is always visible
|
|
171
|
-
|
|
148
|
+
}
|
|
172
149
|
|
|
150
|
+
// when tabList is set as overflown,
|
|
151
|
+
// make sure active tab is always visible
|
|
173
152
|
if (this.props.tabOverflow === 'scroll' && this._tabList && !prevState.withTabListOverflow && this.state.withTabListOverflow) {
|
|
174
153
|
const activeTabEl = this._tabList.querySelector('[aria-selected="true"]');
|
|
175
|
-
|
|
176
154
|
this.showActiveTabIfOverlayed(activeTabEl);
|
|
177
155
|
}
|
|
178
|
-
|
|
179
156
|
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
180
157
|
}
|
|
181
|
-
|
|
182
158
|
componentWillUnmount() {
|
|
183
159
|
this.cancelScrollOverflow();
|
|
184
160
|
}
|
|
185
|
-
|
|
186
161
|
startScrollOverflow() {
|
|
187
162
|
this.handleResize();
|
|
188
163
|
this._debounced = debounce(this.handleResize, 300, {
|
|
@@ -193,34 +168,27 @@ let Tabs = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
|
|
|
193
168
|
this._resizeListener = new ResizeObserver(entries => {
|
|
194
169
|
for (const entry of entries) {
|
|
195
170
|
const newWidth = entry.contentRect.width;
|
|
196
|
-
|
|
197
171
|
if (this._tabListPosition.width !== newWidth) {
|
|
198
172
|
var _this$_debounced;
|
|
199
|
-
|
|
200
173
|
(_this$_debounced = this._debounced) === null || _this$_debounced === void 0 ? void 0 : _this$_debounced.call(this);
|
|
201
174
|
}
|
|
202
175
|
}
|
|
203
176
|
});
|
|
204
|
-
|
|
205
177
|
this._resizeListener.observe(this._tabList);
|
|
206
178
|
}
|
|
207
|
-
|
|
208
179
|
cancelScrollOverflow() {
|
|
209
180
|
if (this._resizeListener) {
|
|
210
181
|
this._resizeListener.disconnect();
|
|
211
182
|
}
|
|
212
|
-
|
|
213
183
|
if (this._debounced) {
|
|
214
184
|
this._debounced.cancel();
|
|
215
185
|
}
|
|
216
186
|
}
|
|
217
|
-
|
|
218
187
|
getOverlayWidth() {
|
|
219
188
|
const _this$props3 = this.props,
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
189
|
+
variant = _this$props3.variant,
|
|
190
|
+
tabOverflow = _this$props3.tabOverflow,
|
|
191
|
+
styles = _this$props3.styles;
|
|
224
192
|
if (styles && tabOverflow === 'scroll') {
|
|
225
193
|
if (variant === 'default') {
|
|
226
194
|
return px(styles === null || styles === void 0 ? void 0 : styles.scrollOverlayWidthDefault);
|
|
@@ -228,10 +196,8 @@ let Tabs = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
|
|
|
228
196
|
return px(styles === null || styles === void 0 ? void 0 : styles.scrollOverlayWidthSecondary);
|
|
229
197
|
}
|
|
230
198
|
}
|
|
231
|
-
|
|
232
199
|
return 0;
|
|
233
200
|
}
|
|
234
|
-
|
|
235
201
|
showActiveTabIfOverlayed(activeTabEl) {
|
|
236
202
|
if (this._tabList && this._tabListPosition && typeof this._tabList.scrollTo === 'function' // test for scrollTo support
|
|
237
203
|
) {
|
|
@@ -241,10 +207,8 @@ let Tabs = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
|
|
|
241
207
|
const tabListBoundEnd = tabListPosition.right + this.getOverlayWidth();
|
|
242
208
|
const tabPositionStart = tabPosition.left;
|
|
243
209
|
const tabPositionEnd = tabPosition.right;
|
|
244
|
-
|
|
245
210
|
if (tabListBoundEnd > tabPositionEnd) {
|
|
246
211
|
const offset = Math.round(tabListBoundEnd - tabPositionEnd);
|
|
247
|
-
|
|
248
212
|
this._tabList.scrollTo({
|
|
249
213
|
top: 0,
|
|
250
214
|
left: this._tabList.scrollLeft + offset,
|
|
@@ -252,7 +216,6 @@ let Tabs = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
|
|
|
252
216
|
});
|
|
253
217
|
} else if (tabListBoundStart > tabPositionStart) {
|
|
254
218
|
const offset = Math.round(tabListBoundStart - tabPositionStart);
|
|
255
|
-
|
|
256
219
|
this._tabList.scrollTo({
|
|
257
220
|
top: 0,
|
|
258
221
|
left: this._tabList.scrollLeft - offset,
|
|
@@ -261,7 +224,6 @@ let Tabs = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
|
|
|
261
224
|
}
|
|
262
225
|
}
|
|
263
226
|
}
|
|
264
|
-
|
|
265
227
|
getNextTab(startIndex, step) {
|
|
266
228
|
const tabs = React.Children.toArray(this.props.children).map(child => matchComponentTypes(child, [Panel]) && child);
|
|
267
229
|
const count = tabs.length;
|
|
@@ -269,33 +231,27 @@ let Tabs = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
|
|
|
269
231
|
error(startIndex >= 0 && startIndex < count, `[Tabs] Invalid tab index: '${startIndex}'.`);
|
|
270
232
|
let nextIndex = startIndex;
|
|
271
233
|
let nextTab;
|
|
272
|
-
|
|
273
234
|
do {
|
|
274
235
|
nextIndex = (nextIndex + change) % count;
|
|
275
236
|
nextTab = tabs[nextIndex];
|
|
276
237
|
} while (nextTab && nextTab.props && nextTab.props.isDisabled);
|
|
277
|
-
|
|
278
238
|
error(nextIndex >= 0 && nextIndex < count, `[Tabs] Invalid tab index: '${nextIndex}'.`);
|
|
279
239
|
return {
|
|
280
240
|
index: nextIndex,
|
|
281
241
|
id: nextTab.props.id
|
|
282
242
|
};
|
|
283
243
|
}
|
|
284
|
-
|
|
285
244
|
fireOnChange(event, _ref3) {
|
|
286
245
|
let index = _ref3.index,
|
|
287
|
-
|
|
288
|
-
|
|
246
|
+
id = _ref3.id;
|
|
289
247
|
if (typeof this.props.onRequestTabChange === 'function') {
|
|
290
248
|
this.props.onRequestTabChange(event, {
|
|
291
249
|
index,
|
|
292
250
|
id
|
|
293
251
|
});
|
|
294
252
|
}
|
|
295
|
-
|
|
296
253
|
this.state.withTabListOverflow && this.showActiveTabIfOverlayed(this._tabList.querySelector(`#tab-${id}`));
|
|
297
254
|
}
|
|
298
|
-
|
|
299
255
|
createTab(index, generatedId, selected, panel) {
|
|
300
256
|
const id = panel.props.id || generatedId;
|
|
301
257
|
return /*#__PURE__*/createElement(Tab, {
|
|
@@ -311,10 +267,10 @@ let Tabs = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
|
|
|
311
267
|
onKeyDown: this.handleTabKeyDown
|
|
312
268
|
});
|
|
313
269
|
}
|
|
314
|
-
|
|
315
270
|
clonePanel(_index, generatedId, selected, panel) {
|
|
316
|
-
const id = panel.props.id || generatedId;
|
|
271
|
+
const id = panel.props.id || generatedId;
|
|
317
272
|
|
|
273
|
+
// fixHeight can be 0, so simply `fixheight` could return falsy value
|
|
318
274
|
const hasFixedHeight = typeof this.props.fixHeight !== 'undefined';
|
|
319
275
|
return safeCloneElement(panel, {
|
|
320
276
|
id: panel.props.id || `panel-${id}`,
|
|
@@ -328,27 +284,23 @@ let Tabs = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
|
|
|
328
284
|
minHeight: !hasFixedHeight ? this.props.minHeight : '100%'
|
|
329
285
|
});
|
|
330
286
|
}
|
|
331
|
-
|
|
332
287
|
focus() {
|
|
333
288
|
this._focusable && typeof this._focusable.focus === 'function' && this._focusable.focus();
|
|
334
289
|
}
|
|
335
|
-
|
|
336
290
|
render() {
|
|
337
291
|
const panels = [];
|
|
338
292
|
const tabs = [];
|
|
339
|
-
|
|
340
293
|
const _this$props4 = this.props,
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
294
|
+
children = _this$props4.children,
|
|
295
|
+
elementRef = _this$props4.elementRef,
|
|
296
|
+
maxWidth = _this$props4.maxWidth,
|
|
297
|
+
variant = _this$props4.variant,
|
|
298
|
+
margin = _this$props4.margin,
|
|
299
|
+
screenReaderLabel = _this$props4.screenReaderLabel,
|
|
300
|
+
onRequestTabChange = _this$props4.onRequestTabChange,
|
|
301
|
+
tabOverflow = _this$props4.tabOverflow,
|
|
302
|
+
styles = _this$props4.styles,
|
|
303
|
+
props = _objectWithoutProperties(_this$props4, _excluded);
|
|
352
304
|
const selectedChildIndex = React.Children.toArray(children).filter(child => matchComponentTypes(child, [Panel])).findIndex(child => child.props.isSelected && !child.props.isDisabled);
|
|
353
305
|
let index = 0;
|
|
354
306
|
const selectedIndex = selectedChildIndex >= 0 ? selectedChildIndex : 0;
|
|
@@ -363,8 +315,9 @@ let Tabs = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
|
|
|
363
315
|
panels.push(child);
|
|
364
316
|
}
|
|
365
317
|
});
|
|
366
|
-
const withScrollFade = tabOverflow === 'scroll' && this.state.withTabListOverflow;
|
|
318
|
+
const withScrollFade = tabOverflow === 'scroll' && this.state.withTabListOverflow;
|
|
367
319
|
|
|
320
|
+
// suppress overlay whenever final Tab is active, or Firefox will cover it
|
|
368
321
|
const startScrollOverlay = this.state.showStartOverLay ? jsx("span", {
|
|
369
322
|
key: "start-overlay",
|
|
370
323
|
css: styles === null || styles === void 0 ? void 0 : styles.startScrollOverlay
|
|
@@ -398,7 +351,6 @@ let Tabs = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
|
|
|
398
351
|
css: styles === null || styles === void 0 ? void 0 : styles.panelsContainer
|
|
399
352
|
}, panels));
|
|
400
353
|
}
|
|
401
|
-
|
|
402
354
|
}, _class2.displayName = "Tabs", _class2.componentId = 'Tabs', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
|
|
403
355
|
variant: 'default',
|
|
404
356
|
shouldFocusOnRender: false,
|
package/es/Tabs/props.js
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
+
|
|
24
25
|
import PropTypes from 'prop-types';
|
|
25
26
|
import { Children } from '@instructure/ui-prop-types';
|
|
26
27
|
import { ThemeablePropTypes } from '@instructure/emotion';
|
package/es/Tabs/styles.js
CHANGED
|
@@ -34,9 +34,10 @@
|
|
|
34
34
|
*/
|
|
35
35
|
const generateStyle = (componentTheme, props) => {
|
|
36
36
|
const variant = props.variant,
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
tabOverflow = props.tabOverflow,
|
|
38
|
+
fixHeight = props.fixHeight;
|
|
39
39
|
|
|
40
|
+
// fixHeight can be 0, so simply `fixheight` could return falsy value
|
|
40
41
|
const hasFixedHeight = typeof fixHeight !== 'undefined';
|
|
41
42
|
const variants = {
|
|
42
43
|
default: {
|
|
@@ -138,5 +139,4 @@ const generateStyle = (componentTheme, props) => {
|
|
|
138
139
|
scrollOverlayWidthSecondary: componentTheme.scrollOverlayWidthSecondary
|
|
139
140
|
};
|
|
140
141
|
};
|
|
141
|
-
|
|
142
142
|
export default generateStyle;
|
package/es/Tabs/theme.js
CHANGED
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
*/
|
|
30
30
|
const generateComponentTheme = theme => {
|
|
31
31
|
const borders = theme.borders,
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
colors = theme.colors,
|
|
33
|
+
stacking = theme.stacking;
|
|
34
34
|
const componentVariables = {
|
|
35
35
|
defaultBackground: colors === null || colors === void 0 ? void 0 : colors.backgroundLightest,
|
|
36
36
|
scrollFadeColor: colors === null || colors === void 0 ? void 0 : colors.backgroundLightest,
|
|
@@ -40,10 +40,10 @@ const generateComponentTheme = theme => {
|
|
|
40
40
|
scrollOverlayWidthDefault: '5rem',
|
|
41
41
|
// has to be 4 times the horizontal padding of the default style tab
|
|
42
42
|
scrollOverlayWidthSecondary: '3rem' // has to be 3 times the horizontal padding of the secondary style tab
|
|
43
|
-
|
|
44
43
|
};
|
|
45
|
-
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
...componentVariables
|
|
46
47
|
};
|
|
47
48
|
};
|
|
48
|
-
|
|
49
49
|
export default generateComponentTheme;
|
package/es/index.js
CHANGED
package/lib/Tabs/Panel/index.js
CHANGED
|
@@ -1,34 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = exports.Panel = void 0;
|
|
9
|
-
|
|
10
8
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
11
|
-
|
|
12
9
|
var _react = require("react");
|
|
13
|
-
|
|
14
10
|
var _View = require("@instructure/ui-view/lib/View");
|
|
15
|
-
|
|
16
11
|
var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProps.js");
|
|
17
|
-
|
|
18
12
|
var _Transition = require("@instructure/ui-motion/lib/Transition");
|
|
19
|
-
|
|
20
13
|
var _emotion = require("@instructure/emotion");
|
|
21
|
-
|
|
22
14
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
23
|
-
|
|
24
15
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
25
|
-
|
|
26
16
|
var _props = require("./props");
|
|
27
|
-
|
|
28
17
|
const _excluded = ["labelledBy", "variant", "id", "maxHeight", "minHeight", "padding", "textAlign", "children", "elementRef", "isDisabled", "isSelected", "styles"];
|
|
29
|
-
|
|
30
18
|
var _dec, _class, _class2;
|
|
31
|
-
|
|
32
19
|
/**
|
|
33
20
|
---
|
|
34
21
|
parent: Tabs
|
|
@@ -40,44 +27,37 @@ let Panel = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _d
|
|
|
40
27
|
constructor() {
|
|
41
28
|
super(...arguments);
|
|
42
29
|
this.ref = null;
|
|
43
|
-
|
|
44
30
|
this.handleRef = el => {
|
|
45
31
|
const elementRef = this.props.elementRef;
|
|
46
32
|
this.ref = el;
|
|
47
|
-
|
|
48
33
|
if (typeof elementRef === 'function') {
|
|
49
34
|
elementRef(el);
|
|
50
35
|
}
|
|
51
36
|
};
|
|
52
37
|
}
|
|
53
|
-
|
|
54
38
|
componentDidMount() {
|
|
55
39
|
var _this$props$makeStyle, _this$props;
|
|
56
|
-
|
|
57
40
|
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
58
41
|
}
|
|
59
|
-
|
|
60
42
|
componentDidUpdate() {
|
|
61
43
|
var _this$props$makeStyle2, _this$props2;
|
|
62
|
-
|
|
63
44
|
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
64
45
|
}
|
|
65
|
-
|
|
66
46
|
render() {
|
|
67
47
|
const _this$props3 = this.props,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
48
|
+
labelledBy = _this$props3.labelledBy,
|
|
49
|
+
variant = _this$props3.variant,
|
|
50
|
+
id = _this$props3.id,
|
|
51
|
+
maxHeight = _this$props3.maxHeight,
|
|
52
|
+
minHeight = _this$props3.minHeight,
|
|
53
|
+
padding = _this$props3.padding,
|
|
54
|
+
textAlign = _this$props3.textAlign,
|
|
55
|
+
children = _this$props3.children,
|
|
56
|
+
elementRef = _this$props3.elementRef,
|
|
57
|
+
isDisabled = _this$props3.isDisabled,
|
|
58
|
+
isSelected = _this$props3.isSelected,
|
|
59
|
+
styles = _this$props3.styles,
|
|
60
|
+
props = (0, _objectWithoutProperties2.default)(_this$props3, _excluded);
|
|
81
61
|
const isHidden = !isSelected || !!isDisabled;
|
|
82
62
|
return (0, _emotion.jsx)("div", Object.assign({}, (0, _passthroughProps.passthroughProps)(props), {
|
|
83
63
|
css: styles === null || styles === void 0 ? void 0 : styles.panel,
|
|
@@ -100,7 +80,6 @@ let Panel = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _d
|
|
|
100
80
|
textAlign: textAlign
|
|
101
81
|
}, children)));
|
|
102
82
|
}
|
|
103
|
-
|
|
104
83
|
}, _class2.displayName = "Panel", _class2.componentId = 'Tabs.Panel', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
|
|
105
84
|
isDisabled: false,
|
|
106
85
|
textAlign: 'start',
|
package/lib/Tabs/Panel/props.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.propTypes = exports.allowedProps = void 0;
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
var _emotion = require("@instructure/emotion");
|
|
13
|
-
|
|
14
10
|
/*
|
|
15
11
|
* The MIT License (MIT)
|
|
16
12
|
*
|
|
@@ -34,6 +30,7 @@ var _emotion = require("@instructure/emotion");
|
|
|
34
30
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
35
31
|
* SOFTWARE.
|
|
36
32
|
*/
|
|
33
|
+
|
|
37
34
|
const propTypes = {
|
|
38
35
|
renderTitle: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]).isRequired,
|
|
39
36
|
children: _propTypes.default.node,
|
package/lib/Tabs/Panel/styles.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/*
|
|
9
8
|
* The MIT License (MIT)
|
|
10
9
|
*
|
|
@@ -41,7 +40,7 @@ exports.default = void 0;
|
|
|
41
40
|
*/
|
|
42
41
|
const generateStyle = (componentTheme, props) => {
|
|
43
42
|
const maxHeight = props.maxHeight,
|
|
44
|
-
|
|
43
|
+
isSelected = props.isSelected;
|
|
45
44
|
return {
|
|
46
45
|
panel: {
|
|
47
46
|
label: 'panel',
|
|
@@ -79,6 +78,5 @@ const generateStyle = (componentTheme, props) => {
|
|
|
79
78
|
}
|
|
80
79
|
};
|
|
81
80
|
};
|
|
82
|
-
|
|
83
81
|
var _default = generateStyle;
|
|
84
82
|
exports.default = _default;
|
package/lib/Tabs/Panel/theme.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/*
|
|
9
8
|
* The MIT License (MIT)
|
|
10
9
|
*
|
|
@@ -36,9 +35,9 @@ exports.default = void 0;
|
|
|
36
35
|
*/
|
|
37
36
|
const generateComponentTheme = theme => {
|
|
38
37
|
const typography = theme.typography,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
colors = theme.colors,
|
|
39
|
+
borders = theme.borders,
|
|
40
|
+
themeName = theme.key;
|
|
42
41
|
const themeSpecificStyle = {
|
|
43
42
|
canvas: {
|
|
44
43
|
color: theme['ic-brand-font-color-dark']
|
|
@@ -56,10 +55,10 @@ const generateComponentTheme = theme => {
|
|
|
56
55
|
borderStyle: borders === null || borders === void 0 ? void 0 : borders.style,
|
|
57
56
|
defaultOverflowY: 'auto'
|
|
58
57
|
};
|
|
59
|
-
return {
|
|
58
|
+
return {
|
|
59
|
+
...componentVariables,
|
|
60
60
|
...themeSpecificStyle[themeName]
|
|
61
61
|
};
|
|
62
62
|
};
|
|
63
|
-
|
|
64
63
|
var _default = generateComponentTheme;
|
|
65
64
|
exports.default = _default;
|