@instructure/ui-view 8.33.1 → 8.33.2-snapshot-5
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 +8 -0
- package/es/ContextView/__examples__/ContextView.examples.js +1 -1
- package/es/ContextView/index.js +18 -28
- package/es/ContextView/props.js +1 -10
- package/es/ContextView/styles.js +3 -21
- package/es/ContextView/theme.js +2 -3
- package/es/View/__examples__/View.examples.js +11 -6
- package/es/View/index.js +31 -47
- package/es/View/props.js +4 -2
- package/es/View/styles.js +63 -75
- package/es/View/theme.js +11 -10
- package/es/index.js +1 -0
- package/lib/ContextView/__examples__/ContextView.examples.js +0 -4
- package/lib/ContextView/index.js +17 -35
- package/lib/ContextView/props.js +1 -15
- package/lib/ContextView/styles.js +3 -23
- package/lib/ContextView/theme.js +2 -4
- package/lib/View/__examples__/View.examples.js +11 -8
- package/lib/View/index.js +31 -60
- package/lib/View/props.js +4 -8
- package/lib/View/styles.js +63 -79
- package/lib/View/theme.js +10 -11
- package/lib/index.js +0 -2
- package/package.json +13 -13
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/ContextView/index.d.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [8.33.2-snapshot-5](https://github.com/instructure/instructure-ui/compare/v8.33.1...v8.33.2-snapshot-5) (2023-01-23)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @instructure/ui-view
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## [8.33.1](https://github.com/instructure/instructure-ui/compare/v8.33.0...v8.33.1) (2023-01-06)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @instructure/ui-view
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
var _span;
|
|
2
|
-
|
|
3
2
|
/*
|
|
4
3
|
* The MIT License (MIT)
|
|
5
4
|
*
|
|
@@ -23,6 +22,7 @@ var _span;
|
|
|
23
22
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
23
|
* SOFTWARE.
|
|
25
24
|
*/
|
|
25
|
+
|
|
26
26
|
import React from 'react';
|
|
27
27
|
export default {
|
|
28
28
|
sectionProp: 'background',
|
package/es/ContextView/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
var _dec, _class, _class2;
|
|
2
|
-
|
|
3
2
|
/*
|
|
4
3
|
* The MIT License (MIT)
|
|
5
4
|
*
|
|
@@ -23,8 +22,8 @@ var _dec, _class, _class2;
|
|
|
23
22
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
23
|
* SOFTWARE.
|
|
25
24
|
*/
|
|
26
|
-
|
|
27
25
|
/** @jsx jsx */
|
|
26
|
+
|
|
28
27
|
import { Component } from 'react';
|
|
29
28
|
import { jsx, withStyle } from '@instructure/emotion';
|
|
30
29
|
import { omitProps } from '@instructure/ui-react-utils';
|
|
@@ -32,7 +31,6 @@ import { View } from '../View';
|
|
|
32
31
|
import generateStyle from './styles';
|
|
33
32
|
import generateComponentTheme from './theme';
|
|
34
33
|
import { propTypes, allowedProps } from './props';
|
|
35
|
-
|
|
36
34
|
/**
|
|
37
35
|
---
|
|
38
36
|
category: components
|
|
@@ -43,48 +41,41 @@ let ContextView = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
|
|
|
43
41
|
constructor() {
|
|
44
42
|
super(...arguments);
|
|
45
43
|
this.ref = null;
|
|
46
|
-
|
|
47
44
|
this.handleRef = el => {
|
|
48
45
|
const elementRef = this.props.elementRef;
|
|
49
46
|
this.ref = el;
|
|
50
|
-
|
|
51
47
|
if (typeof elementRef === 'function') {
|
|
52
48
|
elementRef(el);
|
|
53
49
|
}
|
|
54
50
|
};
|
|
55
51
|
}
|
|
56
|
-
|
|
57
52
|
componentDidMount() {
|
|
58
53
|
var _this$props$makeStyle, _this$props;
|
|
59
|
-
|
|
60
54
|
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
61
55
|
}
|
|
62
|
-
|
|
63
56
|
componentDidUpdate() {
|
|
64
57
|
var _this$props$makeStyle2, _this$props2;
|
|
65
|
-
|
|
66
58
|
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
67
59
|
}
|
|
68
|
-
|
|
69
60
|
render() {
|
|
70
61
|
const _this$props3 = this.props,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
62
|
+
as = _this$props3.as,
|
|
63
|
+
background = _this$props3.background,
|
|
64
|
+
children = _this$props3.children,
|
|
65
|
+
debug = _this$props3.debug,
|
|
66
|
+
height = _this$props3.height,
|
|
67
|
+
width = _this$props3.width,
|
|
68
|
+
maxHeight = _this$props3.maxHeight,
|
|
69
|
+
maxWidth = _this$props3.maxWidth,
|
|
70
|
+
minHeight = _this$props3.minHeight,
|
|
71
|
+
minWidth = _this$props3.minWidth,
|
|
72
|
+
margin = _this$props3.margin,
|
|
73
|
+
padding = _this$props3.padding,
|
|
74
|
+
shadow = _this$props3.shadow,
|
|
75
|
+
stacking = _this$props3.stacking,
|
|
76
|
+
style = _this$props3.style,
|
|
77
|
+
textAlign = _this$props3.textAlign,
|
|
78
|
+
styles = _this$props3.styles;
|
|
88
79
|
return jsx(View, Object.assign({}, omitProps(this.props, ContextView.allowedProps), {
|
|
89
80
|
css: styles === null || styles === void 0 ? void 0 : styles.contextView,
|
|
90
81
|
style: style,
|
|
@@ -116,7 +107,6 @@ let ContextView = (_dec = withStyle(generateStyle, generateComponentTheme), _dec
|
|
|
116
107
|
css: styles === null || styles === void 0 ? void 0 : styles.contextView__arrow
|
|
117
108
|
}), children));
|
|
118
109
|
}
|
|
119
|
-
|
|
120
110
|
}, _class2.displayName = "ContextView", _class2.componentId = 'ContextView', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
|
|
121
111
|
as: 'span',
|
|
122
112
|
elementRef: () => {},
|
package/es/ContextView/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 { ThemeablePropTypes } from '@instructure/emotion';
|
|
26
27
|
import { PositionPropTypes } from '@instructure/ui-position';
|
|
@@ -29,19 +30,16 @@ const propTypes = {
|
|
|
29
30
|
* The element to render as the component root
|
|
30
31
|
*/
|
|
31
32
|
as: PropTypes.elementType,
|
|
32
|
-
|
|
33
33
|
/**
|
|
34
34
|
* provides a reference to the underlying html root element
|
|
35
35
|
*/
|
|
36
36
|
elementRef: PropTypes.func,
|
|
37
|
-
|
|
38
37
|
/**
|
|
39
38
|
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
40
39
|
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
41
40
|
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
42
41
|
*/
|
|
43
42
|
margin: ThemeablePropTypes.spacing,
|
|
44
|
-
|
|
45
43
|
/**
|
|
46
44
|
* Valid values are `0`, `none`, `xxx-small`, `xx-small`, `x-small`,
|
|
47
45
|
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
@@ -54,38 +52,31 @@ const propTypes = {
|
|
|
54
52
|
maxWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
55
53
|
minHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
56
54
|
minWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
57
|
-
|
|
58
55
|
/**
|
|
59
56
|
* The children to render inside the `<ContextView />`
|
|
60
57
|
*/
|
|
61
58
|
children: PropTypes.node,
|
|
62
|
-
|
|
63
59
|
/**
|
|
64
60
|
* Designates the text alignment within the `<ContextView />`
|
|
65
61
|
*/
|
|
66
62
|
textAlign: PropTypes.oneOf(['start', 'center', 'end']),
|
|
67
|
-
|
|
68
63
|
/**
|
|
69
64
|
* Controls the shadow depth for the `<ContextView />`
|
|
70
65
|
*/
|
|
71
66
|
shadow: ThemeablePropTypes.shadow,
|
|
72
|
-
|
|
73
67
|
/**
|
|
74
68
|
* Controls the z-index depth for the `<ContextView />`
|
|
75
69
|
*/
|
|
76
70
|
stacking: ThemeablePropTypes.stacking,
|
|
77
|
-
|
|
78
71
|
/**
|
|
79
72
|
* Designates the background style of the `<ContextView />`
|
|
80
73
|
*/
|
|
81
74
|
background: PropTypes.oneOf(['default', 'inverse']),
|
|
82
|
-
|
|
83
75
|
/**
|
|
84
76
|
* Specifies how the arrow for `<ContextView />` will be rendered.
|
|
85
77
|
* Ex. `placement="top"` will render with an arrow pointing down.
|
|
86
78
|
*/
|
|
87
79
|
placement: PositionPropTypes.placement,
|
|
88
|
-
|
|
89
80
|
/**
|
|
90
81
|
* Activate an outline around the component to make building your
|
|
91
82
|
* layout easier
|
package/es/ContextView/styles.js
CHANGED
|
@@ -21,12 +21,12 @@
|
|
|
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 { mirrorPlacement } from '@instructure/ui-position';
|
|
25
26
|
const endPlacements = ['end center', 'end top', 'end bottom', 'center end', 'end'];
|
|
26
27
|
const startPlacements = ['start center', 'start top', 'start bottom', 'center start', 'start'];
|
|
27
28
|
const bottomPlacements = ['bottom', 'bottom end', 'bottom start', 'bottom center'];
|
|
28
29
|
const topPlacements = ['top', 'top start', 'top end', 'top center'];
|
|
29
|
-
|
|
30
30
|
const getPlacementStyle = (placement, theme) => {
|
|
31
31
|
if (endPlacements.includes(placement)) {
|
|
32
32
|
return {
|
|
@@ -34,78 +34,65 @@ const getPlacementStyle = (placement, theme) => {
|
|
|
34
34
|
paddingInlineEnd: '0'
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
-
|
|
38
37
|
if (startPlacements.includes(placement)) {
|
|
39
38
|
return {
|
|
40
39
|
paddingInlineEnd: theme === null || theme === void 0 ? void 0 : theme.arrowSize,
|
|
41
40
|
paddingInlineStart: '0'
|
|
42
41
|
};
|
|
43
42
|
}
|
|
44
|
-
|
|
45
43
|
if (bottomPlacements.includes(placement)) {
|
|
46
44
|
return {
|
|
47
45
|
paddingTop: theme === null || theme === void 0 ? void 0 : theme.arrowSize
|
|
48
46
|
};
|
|
49
47
|
}
|
|
50
|
-
|
|
51
48
|
if (topPlacements.includes(placement)) {
|
|
52
49
|
return {
|
|
53
50
|
paddingBottom: theme === null || theme === void 0 ? void 0 : theme.arrowSize
|
|
54
51
|
};
|
|
55
52
|
}
|
|
56
|
-
|
|
57
53
|
return {
|
|
58
54
|
position: 'absolute',
|
|
59
55
|
left: '-999em'
|
|
60
56
|
};
|
|
61
57
|
};
|
|
62
|
-
|
|
63
58
|
const getArrowCorrections = (placement, theme) => {
|
|
64
59
|
const center = ['top', 'bottom', 'top center', 'bottom center'];
|
|
65
60
|
const start = ['top start', 'bottom start'];
|
|
66
61
|
const end = ['top end', 'bottom end'];
|
|
67
62
|
const top = ['start top', 'end top'];
|
|
68
63
|
const bottom = ['start bottom', 'end bottom'];
|
|
69
|
-
|
|
70
64
|
if (center.includes(placement)) {
|
|
71
65
|
return {
|
|
72
66
|
insetInlineStart: '50%'
|
|
73
67
|
};
|
|
74
68
|
}
|
|
75
|
-
|
|
76
69
|
if (start.includes(placement)) {
|
|
77
70
|
return {
|
|
78
71
|
insetInlineStart: `calc((${theme === null || theme === void 0 ? void 0 : theme.arrowSize} + ${theme === null || theme === void 0 ? void 0 : theme.arrowBorderWidth}) * 2)`,
|
|
79
72
|
insetInlineEnd: 'auto'
|
|
80
73
|
};
|
|
81
74
|
}
|
|
82
|
-
|
|
83
75
|
if (end.includes(placement)) {
|
|
84
76
|
return {
|
|
85
77
|
insetInlineStart: `calc(100% - (${theme === null || theme === void 0 ? void 0 : theme.arrowSize} + ${theme === null || theme === void 0 ? void 0 : theme.arrowBorderWidth}) * 2)`,
|
|
86
78
|
insetInlineEnd: 'auto'
|
|
87
79
|
};
|
|
88
80
|
}
|
|
89
|
-
|
|
90
81
|
if (top.includes(placement)) {
|
|
91
82
|
return {
|
|
92
83
|
top: `calc((${theme === null || theme === void 0 ? void 0 : theme.arrowSize} + ${theme === null || theme === void 0 ? void 0 : theme.arrowBorderWidth}) * 2)`
|
|
93
84
|
};
|
|
94
85
|
}
|
|
95
|
-
|
|
96
86
|
if (bottom.includes(placement)) {
|
|
97
87
|
return {
|
|
98
88
|
top: `calc(100% - (${theme === null || theme === void 0 ? void 0 : theme.arrowSize} + ${theme === null || theme === void 0 ? void 0 : theme.arrowBorderWidth}) * 2)`
|
|
99
89
|
};
|
|
100
90
|
}
|
|
101
|
-
|
|
102
91
|
return {};
|
|
103
92
|
};
|
|
104
|
-
|
|
105
93
|
const getArrowPlacementVariant = (placement, background, theme) => {
|
|
106
94
|
const transformedPlacement = mirrorPlacement(placement, ' ');
|
|
107
95
|
const isInversed = background === 'inverse';
|
|
108
|
-
|
|
109
96
|
if (endPlacements.includes(transformedPlacement)) {
|
|
110
97
|
return {
|
|
111
98
|
main: {
|
|
@@ -133,7 +120,6 @@ const getArrowPlacementVariant = (placement, background, theme) => {
|
|
|
133
120
|
}
|
|
134
121
|
};
|
|
135
122
|
}
|
|
136
|
-
|
|
137
123
|
if (startPlacements.includes(transformedPlacement)) {
|
|
138
124
|
return {
|
|
139
125
|
main: {
|
|
@@ -161,7 +147,6 @@ const getArrowPlacementVariant = (placement, background, theme) => {
|
|
|
161
147
|
}
|
|
162
148
|
};
|
|
163
149
|
}
|
|
164
|
-
|
|
165
150
|
if (bottomPlacements.includes(transformedPlacement)) {
|
|
166
151
|
return {
|
|
167
152
|
main: {
|
|
@@ -185,7 +170,6 @@ const getArrowPlacementVariant = (placement, background, theme) => {
|
|
|
185
170
|
}
|
|
186
171
|
};
|
|
187
172
|
}
|
|
188
|
-
|
|
189
173
|
return {
|
|
190
174
|
main: {
|
|
191
175
|
bottom: '100%',
|
|
@@ -208,6 +192,7 @@ const getArrowPlacementVariant = (placement, background, theme) => {
|
|
|
208
192
|
}
|
|
209
193
|
};
|
|
210
194
|
};
|
|
195
|
+
|
|
211
196
|
/**
|
|
212
197
|
* ---
|
|
213
198
|
* private: true
|
|
@@ -218,11 +203,9 @@ const getArrowPlacementVariant = (placement, background, theme) => {
|
|
|
218
203
|
* @param {Object} state the state of the component, the style is applied to
|
|
219
204
|
* @return {Object} The final style object, which will be used in the component
|
|
220
205
|
*/
|
|
221
|
-
|
|
222
|
-
|
|
223
206
|
const generateStyle = (componentTheme, props) => {
|
|
224
207
|
const placement = props.placement,
|
|
225
|
-
|
|
208
|
+
background = props.background;
|
|
226
209
|
const arrowBaseStyles = {
|
|
227
210
|
content: '""',
|
|
228
211
|
height: '0',
|
|
@@ -268,5 +251,4 @@ const generateStyle = (componentTheme, props) => {
|
|
|
268
251
|
arrowBorderWidth: componentTheme.arrowBorderWidth
|
|
269
252
|
};
|
|
270
253
|
};
|
|
271
|
-
|
|
272
254
|
export default generateStyle;
|
package/es/ContextView/theme.js
CHANGED
|
@@ -29,7 +29,6 @@
|
|
|
29
29
|
*/
|
|
30
30
|
const generateComponentTheme = theme => {
|
|
31
31
|
var _theme$borders, _theme$colors, _theme$colors2, _theme$colors3;
|
|
32
|
-
|
|
33
32
|
const componentVariables = {
|
|
34
33
|
arrowSize: '0.5rem',
|
|
35
34
|
arrowBorderWidth: theme === null || theme === void 0 ? void 0 : (_theme$borders = theme.borders) === null || _theme$borders === void 0 ? void 0 : _theme$borders.widthSmall,
|
|
@@ -38,8 +37,8 @@ const generateComponentTheme = theme => {
|
|
|
38
37
|
arrowBackgroundColorInverse: theme === null || theme === void 0 ? void 0 : (_theme$colors3 = theme.colors) === null || _theme$colors3 === void 0 ? void 0 : _theme$colors3.licorice,
|
|
39
38
|
arrowBorderColorInverse: 'transparent'
|
|
40
39
|
};
|
|
41
|
-
return {
|
|
40
|
+
return {
|
|
41
|
+
...componentVariables
|
|
42
42
|
};
|
|
43
43
|
};
|
|
44
|
-
|
|
45
44
|
export default generateComponentTheme;
|
|
@@ -21,10 +21,11 @@
|
|
|
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 { ThemeablePropValues } from '@instructure/emotion';
|
|
25
26
|
const SHADOW_TYPES = ThemeablePropValues.SHADOW_TYPES,
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
BORDER_WIDTHS = ThemeablePropValues.BORDER_WIDTHS,
|
|
28
|
+
BORDER_RADII = ThemeablePropValues.BORDER_RADII;
|
|
28
29
|
export default {
|
|
29
30
|
maxExamplesPerPage: 50,
|
|
30
31
|
maxExamples: 500,
|
|
@@ -51,11 +52,15 @@ export default {
|
|
|
51
52
|
},
|
|
52
53
|
excludeProps: ['padding', 'shouldAnimateFocus', 'display', 'focusColor', 'focusPosition', 'borderColor', 'overflowX', 'overflowY'],
|
|
53
54
|
filter: props => {
|
|
54
|
-
return (
|
|
55
|
+
return (
|
|
56
|
+
// Border radius and border width list 0 in addition to none in their object values
|
|
55
57
|
// so we filter those here as they are redundant
|
|
56
|
-
props.withFocusOutline && props.position !== 'relative' ||
|
|
57
|
-
|
|
58
|
-
props.background !== 'transparent'
|
|
58
|
+
props.withFocusOutline && props.position !== 'relative' ||
|
|
59
|
+
// Only generate a 1 variation for withVisualDebug
|
|
60
|
+
props.withVisualDebug && (props.background !== 'transparent' || props.borderRadius !== '0' || props.position !== 'static' || props.shadow !== 'none' || props.textAlign !== 'center') ||
|
|
61
|
+
// Only generate a 1 variation for non-'transparent' background
|
|
62
|
+
props.background !== 'transparent' && (props.borderRadius !== '0' || props.position !== 'static' || props.shadow !== 'none' || props.textAlign !== 'center') ||
|
|
63
|
+
// Only generate a 1 variation for non-'0' borderWidth
|
|
59
64
|
props.borderWidth !== '0' && (props.background !== 'transparent' || props.borderRadius !== '0' || props.position !== 'static' || props.shadow !== 'none' || props.textAlign !== 'center')
|
|
60
65
|
);
|
|
61
66
|
}
|
package/es/View/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
2
|
const _excluded = ["children", "textAlign", "background", "display", "withVisualDebug", "width", "height", "minWidth", "minHeight", "maxWidth", "maxHeight", "overflowX", "overflowY", "stacking", "shadow", "position", "focusPosition", "focusColor", "shouldAnimateFocus", "borderColor", "className", "styles", "makeStyles"];
|
|
3
|
-
|
|
4
3
|
var _dec, _dec2, _class, _class2;
|
|
5
|
-
|
|
6
4
|
/*
|
|
7
5
|
* The MIT License (MIT)
|
|
8
6
|
*
|
|
@@ -37,7 +35,6 @@ import { jsx, withStyle } from '@instructure/emotion';
|
|
|
37
35
|
import generateStyle from './styles';
|
|
38
36
|
import generateComponentTheme from './theme';
|
|
39
37
|
import { propTypes, allowedProps } from './props';
|
|
40
|
-
|
|
41
38
|
/**
|
|
42
39
|
---
|
|
43
40
|
category: components
|
|
@@ -48,47 +45,43 @@ category: components
|
|
|
48
45
|
let View = (_dec = textDirectionContextConsumer(), _dec2 = withStyle(generateStyle, generateComponentTheme), _dec(_class = _dec2(_class = (_class2 = class View extends Component {
|
|
49
46
|
// TODO: Remove this code once all components are using passthroughProps in place
|
|
50
47
|
// of omitProps and have removed this function
|
|
48
|
+
|
|
51
49
|
// omitViewProps needs to be called on the composed View component so that the
|
|
52
50
|
// View.allowedProps in the method matches the View.allowedProps that will be called in
|
|
53
51
|
// the consumers. Otherwise the discrepancy could cause unexpected props being
|
|
54
52
|
// allowed through.
|
|
53
|
+
|
|
55
54
|
// Removes View's own props from the given object. Automatically excludes the
|
|
56
55
|
// following props: 'theme', 'children', 'className', 'style', 'styles',
|
|
57
56
|
// 'makeStyles', 'themeOverride'
|
|
58
57
|
// @param props the object to process
|
|
59
58
|
// @param Component The component whose props are processed.
|
|
60
59
|
// Only needed for debug logging in non-production builds.
|
|
60
|
+
|
|
61
61
|
get _element() {
|
|
62
62
|
return this.ref;
|
|
63
63
|
}
|
|
64
|
-
|
|
65
64
|
constructor(props) {
|
|
66
65
|
super(props);
|
|
67
66
|
this.spanMarginVerified = void 0;
|
|
68
67
|
this.ref = null;
|
|
69
|
-
|
|
70
68
|
this.handleElementRef = el => {
|
|
71
69
|
if (typeof this.props.elementRef === 'function') {
|
|
72
70
|
this.props.elementRef(el);
|
|
73
71
|
}
|
|
74
|
-
|
|
75
72
|
this.ref = el;
|
|
76
73
|
};
|
|
77
|
-
|
|
78
74
|
this.spanMarginVerified = false;
|
|
79
75
|
}
|
|
80
|
-
|
|
81
76
|
componentDidMount() {
|
|
82
77
|
var _this$props$makeStyle, _this$props;
|
|
83
|
-
|
|
84
78
|
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
85
79
|
}
|
|
86
|
-
|
|
87
80
|
componentDidUpdate() {
|
|
88
81
|
var _this$props$makeStyle2, _this$props2;
|
|
82
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
89
83
|
|
|
90
|
-
|
|
91
|
-
|
|
84
|
+
// Not calling getComputedStyle can save hundreds of ms in tests and production
|
|
92
85
|
if (process.env.NODE_ENV === 'development' && !this.spanMarginVerified) {
|
|
93
86
|
// We have to verify margins in the first 'componentDidUpdate',
|
|
94
87
|
// because that is when all styles are calculated,
|
|
@@ -98,58 +91,52 @@ let View = (_dec = textDirectionContextConsumer(), _dec2 = withStyle(generateSty
|
|
|
98
91
|
if (!element) {
|
|
99
92
|
return;
|
|
100
93
|
}
|
|
101
|
-
|
|
102
94
|
const display = getComputedStyle(element).display;
|
|
103
|
-
|
|
104
95
|
if (display !== 'inline') {
|
|
105
96
|
return;
|
|
106
97
|
}
|
|
107
|
-
|
|
108
98
|
const marginValues = margin ? margin.split(' ') : null;
|
|
109
|
-
let verticalMargin = false;
|
|
99
|
+
let verticalMargin = false;
|
|
110
100
|
|
|
101
|
+
// either top or bottom margin are set
|
|
111
102
|
if (margin) {
|
|
112
103
|
if (marginValues && marginValues[0] && marginValues[0] !== 'none' && marginValues[0] !== '0') {
|
|
113
104
|
verticalMargin = true;
|
|
114
105
|
}
|
|
115
|
-
|
|
116
106
|
if (marginValues && marginValues[2] && marginValues[2] !== 'none' && marginValues[2] !== '0') {
|
|
117
107
|
verticalMargin = true;
|
|
118
108
|
}
|
|
119
109
|
}
|
|
120
|
-
|
|
121
110
|
return verticalMargin;
|
|
122
111
|
}(this.ref, this.props.margin), `[View] display style is set to 'inline' and will allow for horizontal margins only.`);
|
|
123
112
|
}
|
|
124
113
|
}
|
|
125
|
-
|
|
126
114
|
render() {
|
|
127
115
|
const _this$props3 = this.props,
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
116
|
+
children = _this$props3.children,
|
|
117
|
+
textAlign = _this$props3.textAlign,
|
|
118
|
+
background = _this$props3.background,
|
|
119
|
+
display = _this$props3.display,
|
|
120
|
+
withVisualDebug = _this$props3.withVisualDebug,
|
|
121
|
+
width = _this$props3.width,
|
|
122
|
+
height = _this$props3.height,
|
|
123
|
+
minWidth = _this$props3.minWidth,
|
|
124
|
+
minHeight = _this$props3.minHeight,
|
|
125
|
+
maxWidth = _this$props3.maxWidth,
|
|
126
|
+
maxHeight = _this$props3.maxHeight,
|
|
127
|
+
overflowX = _this$props3.overflowX,
|
|
128
|
+
overflowY = _this$props3.overflowY,
|
|
129
|
+
stacking = _this$props3.stacking,
|
|
130
|
+
shadow = _this$props3.shadow,
|
|
131
|
+
position = _this$props3.position,
|
|
132
|
+
focusPosition = _this$props3.focusPosition,
|
|
133
|
+
focusColor = _this$props3.focusColor,
|
|
134
|
+
shouldAnimateFocus = _this$props3.shouldAnimateFocus,
|
|
135
|
+
borderColor = _this$props3.borderColor,
|
|
136
|
+
className = _this$props3.className,
|
|
137
|
+
styles = _this$props3.styles,
|
|
138
|
+
makeStyles = _this$props3.makeStyles,
|
|
139
|
+
props = _objectWithoutProperties(_this$props3, _excluded);
|
|
153
140
|
const ElementType = getElementType(View, this.props);
|
|
154
141
|
return jsx(ElementType, Object.assign({}, passthroughProps(props), {
|
|
155
142
|
className: className,
|
|
@@ -157,7 +144,6 @@ let View = (_dec = textDirectionContextConsumer(), _dec2 = withStyle(generateSty
|
|
|
157
144
|
ref: this.handleElementRef
|
|
158
145
|
}), children);
|
|
159
146
|
}
|
|
160
|
-
|
|
161
147
|
}, _class2.displayName = "View", _class2.componentId = 'View', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
|
|
162
148
|
display: 'auto',
|
|
163
149
|
overflowX: 'visible',
|
|
@@ -172,13 +158,11 @@ let View = (_dec = textDirectionContextConsumer(), _dec2 = withStyle(generateSty
|
|
|
172
158
|
// We don't want the theming and styling props to pass
|
|
173
159
|
// (these are added and handled by the `@withStyle` decorator)
|
|
174
160
|
const propsToOmit = [..._class2.allowedProps, 'styles', 'makeStyles', 'themeOverride'];
|
|
175
|
-
|
|
176
161
|
if (process.env.NODE_ENV !== 'production') {
|
|
177
162
|
Object.keys(pickProps(props, propsToOmit)).forEach(prop => {
|
|
178
163
|
error(false, `[${Component.name}] prop '${prop}' is not allowed.`);
|
|
179
164
|
});
|
|
180
165
|
}
|
|
181
|
-
|
|
182
166
|
return omitProps(props, propsToOmit);
|
|
183
167
|
}, _class2)) || _class) || _class);
|
|
184
168
|
export default View;
|
package/es/View/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 { cursor as cursorPropTypes } from '@instructure/ui-prop-types';
|
|
26
27
|
import { textDirectionContextConsumer } from '@instructure/ui-i18n';
|
|
@@ -59,9 +60,10 @@ const propTypes = {
|
|
|
59
60
|
shouldAnimateFocus: PropTypes.bool,
|
|
60
61
|
withVisualDebug: PropTypes.bool,
|
|
61
62
|
dir: PropTypes.oneOf(Object.values(textDirectionContextConsumer.DIRECTION))
|
|
62
|
-
};
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// This variable will be attached as static property on the `View` component
|
|
63
66
|
// so we don't rely on the `PropTypes` validators for our internal logic.
|
|
64
67
|
// This means on prod builds the consuming applications can safely delete propTypes.
|
|
65
|
-
|
|
66
68
|
const allowedProps = ['as', 'background', 'borderColor', 'borderRadius', 'borderWidth', 'children', 'cursor', 'dir', 'display', 'elementRef', 'focusColor', 'focusPosition', 'height', 'insetBlockEnd', 'insetBlockStart', 'insetInlineEnd', 'insetInlineStart', 'margin', 'maxHeight', 'maxWidth', 'minHeight', 'minWidth', 'overflowX', 'overflowY', 'padding', 'position', 'shadow', 'shouldAnimateFocus', 'stacking', 'textAlign', 'width', 'withFocusOutline', 'withVisualDebug'];
|
|
67
69
|
export { propTypes, allowedProps };
|