@instructure/ui-view 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/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/lib/ContextView/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,7 +35,6 @@ exports.default = void 0;
|
|
|
36
35
|
*/
|
|
37
36
|
const generateComponentTheme = theme => {
|
|
38
37
|
var _theme$borders, _theme$colors, _theme$colors2, _theme$colors3;
|
|
39
|
-
|
|
40
38
|
const componentVariables = {
|
|
41
39
|
arrowSize: '0.5rem',
|
|
42
40
|
arrowBorderWidth: theme === null || theme === void 0 ? void 0 : (_theme$borders = theme.borders) === null || _theme$borders === void 0 ? void 0 : _theme$borders.widthSmall,
|
|
@@ -45,9 +43,9 @@ const generateComponentTheme = theme => {
|
|
|
45
43
|
arrowBackgroundColorInverse: theme === null || theme === void 0 ? void 0 : (_theme$colors3 = theme.colors) === null || _theme$colors3 === void 0 ? void 0 : _theme$colors3.licorice,
|
|
46
44
|
arrowBorderColorInverse: 'transparent'
|
|
47
45
|
};
|
|
48
|
-
return {
|
|
46
|
+
return {
|
|
47
|
+
...componentVariables
|
|
49
48
|
};
|
|
50
49
|
};
|
|
51
|
-
|
|
52
50
|
var _default = generateComponentTheme;
|
|
53
51
|
exports.default = _default;
|
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _emotion = require("@instructure/emotion");
|
|
9
|
-
|
|
10
8
|
/*
|
|
11
9
|
* The MIT License (MIT)
|
|
12
10
|
*
|
|
@@ -30,9 +28,10 @@ var _emotion = require("@instructure/emotion");
|
|
|
30
28
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
31
29
|
* SOFTWARE.
|
|
32
30
|
*/
|
|
31
|
+
|
|
33
32
|
const SHADOW_TYPES = _emotion.ThemeablePropValues.SHADOW_TYPES,
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
BORDER_WIDTHS = _emotion.ThemeablePropValues.BORDER_WIDTHS,
|
|
34
|
+
BORDER_RADII = _emotion.ThemeablePropValues.BORDER_RADII;
|
|
36
35
|
var _default = {
|
|
37
36
|
maxExamplesPerPage: 50,
|
|
38
37
|
maxExamples: 500,
|
|
@@ -59,11 +58,15 @@ var _default = {
|
|
|
59
58
|
},
|
|
60
59
|
excludeProps: ['padding', 'shouldAnimateFocus', 'display', 'focusColor', 'focusPosition', 'borderColor', 'overflowX', 'overflowY'],
|
|
61
60
|
filter: props => {
|
|
62
|
-
return (
|
|
61
|
+
return (
|
|
62
|
+
// Border radius and border width list 0 in addition to none in their object values
|
|
63
63
|
// so we filter those here as they are redundant
|
|
64
|
-
props.withFocusOutline && props.position !== 'relative' ||
|
|
65
|
-
|
|
66
|
-
props.background !== 'transparent'
|
|
64
|
+
props.withFocusOutline && props.position !== 'relative' ||
|
|
65
|
+
// Only generate a 1 variation for withVisualDebug
|
|
66
|
+
props.withVisualDebug && (props.background !== 'transparent' || props.borderRadius !== '0' || props.position !== 'static' || props.shadow !== 'none' || props.textAlign !== 'center') ||
|
|
67
|
+
// Only generate a 1 variation for non-'transparent' background
|
|
68
|
+
props.background !== 'transparent' && (props.borderRadius !== '0' || props.position !== 'static' || props.shadow !== 'none' || props.textAlign !== 'center') ||
|
|
69
|
+
// Only generate a 1 variation for non-'0' borderWidth
|
|
67
70
|
props.borderWidth !== '0' && (props.background !== 'transparent' || props.borderRadius !== '0' || props.position !== 'static' || props.shadow !== 'none' || props.textAlign !== 'center')
|
|
68
71
|
);
|
|
69
72
|
}
|
package/lib/View/index.js
CHANGED
|
@@ -1,42 +1,25 @@
|
|
|
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.View = void 0;
|
|
9
|
-
|
|
10
8
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
11
|
-
|
|
12
9
|
var _react = require("react");
|
|
13
|
-
|
|
14
10
|
var _getComputedStyle = require("@instructure/ui-dom-utils/lib/getComputedStyle.js");
|
|
15
|
-
|
|
16
11
|
var _textDirectionContextConsumer = require("@instructure/ui-i18n/lib/textDirectionContextConsumer.js");
|
|
17
|
-
|
|
18
12
|
var _console = require("@instructure/console");
|
|
19
|
-
|
|
20
13
|
var _getElementType = require("@instructure/ui-react-utils/lib/getElementType.js");
|
|
21
|
-
|
|
22
14
|
var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
|
|
23
|
-
|
|
24
15
|
var _pickProps = require("@instructure/ui-react-utils/lib/pickProps.js");
|
|
25
|
-
|
|
26
16
|
var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProps.js");
|
|
27
|
-
|
|
28
17
|
var _emotion = require("@instructure/emotion");
|
|
29
|
-
|
|
30
18
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
31
|
-
|
|
32
19
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
33
|
-
|
|
34
20
|
var _props = require("./props");
|
|
35
|
-
|
|
36
21
|
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"];
|
|
37
|
-
|
|
38
22
|
var _dec, _dec2, _class, _class2;
|
|
39
|
-
|
|
40
23
|
/**
|
|
41
24
|
---
|
|
42
25
|
category: components
|
|
@@ -47,47 +30,43 @@ category: components
|
|
|
47
30
|
let View = (_dec = (0, _textDirectionContextConsumer.textDirectionContextConsumer)(), _dec2 = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec(_class = _dec2(_class = (_class2 = class View extends _react.Component {
|
|
48
31
|
// TODO: Remove this code once all components are using passthroughProps in place
|
|
49
32
|
// of omitProps and have removed this function
|
|
33
|
+
|
|
50
34
|
// omitViewProps needs to be called on the composed View component so that the
|
|
51
35
|
// View.allowedProps in the method matches the View.allowedProps that will be called in
|
|
52
36
|
// the consumers. Otherwise the discrepancy could cause unexpected props being
|
|
53
37
|
// allowed through.
|
|
38
|
+
|
|
54
39
|
// Removes View's own props from the given object. Automatically excludes the
|
|
55
40
|
// following props: 'theme', 'children', 'className', 'style', 'styles',
|
|
56
41
|
// 'makeStyles', 'themeOverride'
|
|
57
42
|
// @param props the object to process
|
|
58
43
|
// @param Component The component whose props are processed.
|
|
59
44
|
// Only needed for debug logging in non-production builds.
|
|
45
|
+
|
|
60
46
|
get _element() {
|
|
61
47
|
return this.ref;
|
|
62
48
|
}
|
|
63
|
-
|
|
64
49
|
constructor(props) {
|
|
65
50
|
super(props);
|
|
66
51
|
this.spanMarginVerified = void 0;
|
|
67
52
|
this.ref = null;
|
|
68
|
-
|
|
69
53
|
this.handleElementRef = el => {
|
|
70
54
|
if (typeof this.props.elementRef === 'function') {
|
|
71
55
|
this.props.elementRef(el);
|
|
72
56
|
}
|
|
73
|
-
|
|
74
57
|
this.ref = el;
|
|
75
58
|
};
|
|
76
|
-
|
|
77
59
|
this.spanMarginVerified = false;
|
|
78
60
|
}
|
|
79
|
-
|
|
80
61
|
componentDidMount() {
|
|
81
62
|
var _this$props$makeStyle, _this$props;
|
|
82
|
-
|
|
83
63
|
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
84
64
|
}
|
|
85
|
-
|
|
86
65
|
componentDidUpdate() {
|
|
87
66
|
var _this$props$makeStyle2, _this$props2;
|
|
67
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
88
68
|
|
|
89
|
-
|
|
90
|
-
|
|
69
|
+
// Not calling getComputedStyle can save hundreds of ms in tests and production
|
|
91
70
|
if (process.env.NODE_ENV === 'development' && !this.spanMarginVerified) {
|
|
92
71
|
// We have to verify margins in the first 'componentDidUpdate',
|
|
93
72
|
// because that is when all styles are calculated,
|
|
@@ -97,57 +76,52 @@ let View = (_dec = (0, _textDirectionContextConsumer.textDirectionContextConsume
|
|
|
97
76
|
if (!element) {
|
|
98
77
|
return;
|
|
99
78
|
}
|
|
100
|
-
|
|
101
79
|
const display = (0, _getComputedStyle.getComputedStyle)(element).display;
|
|
102
|
-
|
|
103
80
|
if (display !== 'inline') {
|
|
104
81
|
return;
|
|
105
82
|
}
|
|
106
|
-
|
|
107
83
|
const marginValues = margin ? margin.split(' ') : null;
|
|
108
|
-
let verticalMargin = false;
|
|
84
|
+
let verticalMargin = false;
|
|
109
85
|
|
|
86
|
+
// either top or bottom margin are set
|
|
110
87
|
if (margin) {
|
|
111
88
|
if (marginValues && marginValues[0] && marginValues[0] !== 'none' && marginValues[0] !== '0') {
|
|
112
89
|
verticalMargin = true;
|
|
113
90
|
}
|
|
114
|
-
|
|
115
91
|
if (marginValues && marginValues[2] && marginValues[2] !== 'none' && marginValues[2] !== '0') {
|
|
116
92
|
verticalMargin = true;
|
|
117
93
|
}
|
|
118
94
|
}
|
|
119
|
-
|
|
120
95
|
return verticalMargin;
|
|
121
96
|
}(this.ref, this.props.margin), `[View] display style is set to 'inline' and will allow for horizontal margins only.`);
|
|
122
97
|
}
|
|
123
98
|
}
|
|
124
|
-
|
|
125
99
|
render() {
|
|
126
100
|
const _this$props3 = this.props,
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
101
|
+
children = _this$props3.children,
|
|
102
|
+
textAlign = _this$props3.textAlign,
|
|
103
|
+
background = _this$props3.background,
|
|
104
|
+
display = _this$props3.display,
|
|
105
|
+
withVisualDebug = _this$props3.withVisualDebug,
|
|
106
|
+
width = _this$props3.width,
|
|
107
|
+
height = _this$props3.height,
|
|
108
|
+
minWidth = _this$props3.minWidth,
|
|
109
|
+
minHeight = _this$props3.minHeight,
|
|
110
|
+
maxWidth = _this$props3.maxWidth,
|
|
111
|
+
maxHeight = _this$props3.maxHeight,
|
|
112
|
+
overflowX = _this$props3.overflowX,
|
|
113
|
+
overflowY = _this$props3.overflowY,
|
|
114
|
+
stacking = _this$props3.stacking,
|
|
115
|
+
shadow = _this$props3.shadow,
|
|
116
|
+
position = _this$props3.position,
|
|
117
|
+
focusPosition = _this$props3.focusPosition,
|
|
118
|
+
focusColor = _this$props3.focusColor,
|
|
119
|
+
shouldAnimateFocus = _this$props3.shouldAnimateFocus,
|
|
120
|
+
borderColor = _this$props3.borderColor,
|
|
121
|
+
className = _this$props3.className,
|
|
122
|
+
styles = _this$props3.styles,
|
|
123
|
+
makeStyles = _this$props3.makeStyles,
|
|
124
|
+
props = (0, _objectWithoutProperties2.default)(_this$props3, _excluded);
|
|
151
125
|
const ElementType = (0, _getElementType.getElementType)(View, this.props);
|
|
152
126
|
return (0, _emotion.jsx)(ElementType, Object.assign({}, (0, _passthroughProps.passthroughProps)(props), {
|
|
153
127
|
className: className,
|
|
@@ -155,7 +129,6 @@ let View = (_dec = (0, _textDirectionContextConsumer.textDirectionContextConsume
|
|
|
155
129
|
ref: this.handleElementRef
|
|
156
130
|
}), children);
|
|
157
131
|
}
|
|
158
|
-
|
|
159
132
|
}, _class2.displayName = "View", _class2.componentId = 'View', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
|
|
160
133
|
display: 'auto',
|
|
161
134
|
overflowX: 'visible',
|
|
@@ -170,13 +143,11 @@ let View = (_dec = (0, _textDirectionContextConsumer.textDirectionContextConsume
|
|
|
170
143
|
// We don't want the theming and styling props to pass
|
|
171
144
|
// (these are added and handled by the `@withStyle` decorator)
|
|
172
145
|
const propsToOmit = [..._class2.allowedProps, 'styles', 'makeStyles', 'themeOverride'];
|
|
173
|
-
|
|
174
146
|
if (process.env.NODE_ENV !== 'production') {
|
|
175
147
|
Object.keys((0, _pickProps.pickProps)(props, propsToOmit)).forEach(prop => {
|
|
176
148
|
(0, _console.logError)(false, `[${Component.name}] prop '${prop}' is not allowed.`);
|
|
177
149
|
});
|
|
178
150
|
}
|
|
179
|
-
|
|
180
151
|
return (0, _omitProps.omitProps)(props, propsToOmit);
|
|
181
152
|
}, _class2)) || _class) || _class);
|
|
182
153
|
exports.View = View;
|
package/lib/View/props.js
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
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 _cursor = require("@instructure/ui-prop-types/lib/cursor.js");
|
|
13
|
-
|
|
14
10
|
var _textDirectionContextConsumer = require("@instructure/ui-i18n/lib/textDirectionContextConsumer.js");
|
|
15
|
-
|
|
16
11
|
var _emotion = require("@instructure/emotion");
|
|
17
|
-
|
|
18
12
|
/*
|
|
19
13
|
* The MIT License (MIT)
|
|
20
14
|
*
|
|
@@ -38,6 +32,7 @@ var _emotion = require("@instructure/emotion");
|
|
|
38
32
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
39
33
|
* SOFTWARE.
|
|
40
34
|
*/
|
|
35
|
+
|
|
41
36
|
const propTypes = {
|
|
42
37
|
as: _propTypes.default.elementType,
|
|
43
38
|
elementRef: _propTypes.default.func,
|
|
@@ -72,10 +67,11 @@ const propTypes = {
|
|
|
72
67
|
shouldAnimateFocus: _propTypes.default.bool,
|
|
73
68
|
withVisualDebug: _propTypes.default.bool,
|
|
74
69
|
dir: _propTypes.default.oneOf(Object.values(_textDirectionContextConsumer.textDirectionContextConsumer.DIRECTION))
|
|
75
|
-
};
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// This variable will be attached as static property on the `View` component
|
|
76
73
|
// so we don't rely on the `PropTypes` validators for our internal logic.
|
|
77
74
|
// This means on prod builds the consuming applications can safely delete propTypes.
|
|
78
|
-
|
|
79
75
|
exports.propTypes = propTypes;
|
|
80
76
|
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'];
|
|
81
77
|
exports.allowedProps = allowedProps;
|
package/lib/View/styles.js
CHANGED
|
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _uiI18n = require("@instructure/ui-i18n");
|
|
9
|
-
|
|
10
8
|
var _emotion = require("@instructure/emotion");
|
|
11
|
-
|
|
12
9
|
var _pickProps = require("@instructure/ui-react-utils/lib/pickProps.js");
|
|
13
|
-
|
|
14
10
|
var _console = require("@instructure/console");
|
|
15
|
-
|
|
16
11
|
/*
|
|
17
12
|
* The MIT License (MIT)
|
|
18
13
|
*
|
|
@@ -36,36 +31,35 @@ var _console = require("@instructure/console");
|
|
|
36
31
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
37
32
|
* SOFTWARE.
|
|
38
33
|
*/
|
|
34
|
+
|
|
39
35
|
const getBorderStyle = _ref => {
|
|
40
36
|
let borderRadius = _ref.borderRadius,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
borderWidth = _ref.borderWidth,
|
|
38
|
+
dir = _ref.dir,
|
|
39
|
+
theme = _ref.theme;
|
|
44
40
|
const isRtlDirection = dir === _uiI18n.DIRECTION.rtl;
|
|
45
41
|
return {
|
|
46
42
|
borderRadius: (0, _emotion.getShorthandPropValue)('View', theme, isRtlDirection ? (0, _emotion.mirrorShorthandCorners)(borderRadius) : borderRadius, 'borderRadius'),
|
|
47
43
|
borderWidth: (0, _emotion.getShorthandPropValue)('View', theme, isRtlDirection ? (0, _emotion.mirrorShorthandEdges)(borderWidth) : borderWidth, 'borderWidth')
|
|
48
44
|
};
|
|
49
45
|
};
|
|
50
|
-
|
|
51
46
|
const getSpacingStyle = _ref2 => {
|
|
52
47
|
let margin = _ref2.margin,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
48
|
+
padding = _ref2.padding,
|
|
49
|
+
dir = _ref2.dir,
|
|
50
|
+
theme = _ref2.theme;
|
|
56
51
|
const isRtlDirection = dir === _uiI18n.DIRECTION.rtl;
|
|
57
52
|
return {
|
|
58
53
|
margin: (0, _emotion.getShorthandPropValue)('View', theme, isRtlDirection ? (0, _emotion.mirrorShorthandEdges)(margin) : margin, 'margin'),
|
|
59
54
|
padding: (0, _emotion.getShorthandPropValue)('View', theme, isRtlDirection ? (0, _emotion.mirrorShorthandEdges)(padding) : padding, 'padding')
|
|
60
55
|
};
|
|
61
56
|
};
|
|
62
|
-
|
|
63
57
|
const getOffsetStyle = _ref3 => {
|
|
64
58
|
let insetBlockStart = _ref3.insetBlockStart,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
59
|
+
insetBlockEnd = _ref3.insetBlockEnd,
|
|
60
|
+
insetInlineStart = _ref3.insetInlineStart,
|
|
61
|
+
insetInlineEnd = _ref3.insetInlineEnd,
|
|
62
|
+
dir = _ref3.dir;
|
|
69
63
|
const isRtlDirection = dir === _uiI18n.DIRECTION.rtl;
|
|
70
64
|
const blockStart = {
|
|
71
65
|
top: insetBlockStart,
|
|
@@ -79,80 +73,71 @@ const getOffsetStyle = _ref3 => {
|
|
|
79
73
|
left: isRtlDirection ? insetInlineEnd : insetInlineStart,
|
|
80
74
|
right: isRtlDirection ? insetInlineStart : insetInlineEnd
|
|
81
75
|
};
|
|
82
|
-
return {
|
|
76
|
+
return {
|
|
77
|
+
...blockStart,
|
|
83
78
|
...blockEnd,
|
|
84
79
|
...horizontalOffsets
|
|
85
80
|
};
|
|
86
81
|
};
|
|
87
|
-
|
|
88
82
|
const getStyleProps = _ref4 => {
|
|
89
83
|
let cursor = _ref4.cursor,
|
|
90
|
-
|
|
91
|
-
const whitelisted = (0, _pickProps.pickProps)(style || {}, {}, [
|
|
92
|
-
|
|
93
|
-
'
|
|
94
|
-
|
|
95
|
-
'
|
|
84
|
+
style = _ref4.style;
|
|
85
|
+
const whitelisted = (0, _pickProps.pickProps)(style || {}, {}, [
|
|
86
|
+
// Position/calculateElementPosition:
|
|
87
|
+
'top', 'left', 'position', 'display', 'transform', 'overflow', 'minWidth', 'minHeight',
|
|
88
|
+
// Img:
|
|
89
|
+
'filter',
|
|
90
|
+
// Flex.Item:
|
|
91
|
+
'flexBasis',
|
|
92
|
+
// Avatar:
|
|
93
|
+
'backgroundImage',
|
|
94
|
+
// Popover:
|
|
96
95
|
'pointerEvents']);
|
|
97
|
-
|
|
98
96
|
if (cursor) {
|
|
99
97
|
whitelisted.cursor = cursor;
|
|
100
98
|
}
|
|
101
|
-
|
|
102
99
|
return whitelisted;
|
|
103
100
|
};
|
|
104
|
-
|
|
105
101
|
const verifyUniformValues = (initialValue, input) => {
|
|
106
102
|
if (typeof input !== 'string') {
|
|
107
103
|
return false;
|
|
108
104
|
}
|
|
109
|
-
|
|
110
105
|
return input.trim().split(' ').every(value => initialValue === value);
|
|
111
106
|
};
|
|
112
|
-
|
|
113
107
|
const getFocusRingRadius = borderRadius => {
|
|
114
108
|
const baseRadiusStyle = 'focusRing--radius';
|
|
115
109
|
const initialValue = (borderRadius || '').trim().split(' ')[0];
|
|
116
|
-
|
|
117
110
|
if (verifyUniformValues(initialValue, borderRadius)) {
|
|
118
111
|
const capitalize = str => `${str.charAt(0).toUpperCase()}${str.slice(1)}`;
|
|
119
|
-
|
|
120
112
|
if (['small', 'medium', 'large'].includes(initialValue)) return `${baseRadiusStyle}${capitalize(initialValue)}`;
|
|
121
113
|
if (['circle', 'pill'].includes(initialValue)) return `${baseRadiusStyle}Inherit`;
|
|
122
114
|
}
|
|
123
|
-
|
|
124
115
|
return `${baseRadiusStyle}None`;
|
|
125
116
|
};
|
|
126
|
-
|
|
127
117
|
const getFocusOutline = props => {
|
|
128
118
|
const position = props.position,
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
119
|
+
display = props.display,
|
|
120
|
+
focusPosition = props.focusPosition,
|
|
121
|
+
shouldDisplayFocusOutline = props.withFocusOutline;
|
|
133
122
|
if (typeof shouldDisplayFocusOutline === 'undefined') {
|
|
134
123
|
return shouldDisplayFocusOutline;
|
|
135
124
|
}
|
|
136
|
-
|
|
137
125
|
if (shouldDisplayFocusOutline) {
|
|
138
126
|
(0, _console.logError)(display === 'inline' || position === 'relative', '[View] the focus outline will only show if the `position` prop is `relative`.');
|
|
139
127
|
(0, _console.logError)(display !== 'inline' || focusPosition === 'inset', '[View] when display is set to `inline` the focus outline will only show if `focusPosition` is set to `inset`.');
|
|
140
128
|
}
|
|
141
|
-
|
|
142
129
|
return shouldDisplayFocusOutline;
|
|
143
130
|
};
|
|
144
|
-
|
|
145
131
|
const withBorder = props => {
|
|
146
132
|
const borderWidth = props.borderWidth;
|
|
147
133
|
return borderWidth && borderWidth !== '0' && borderWidth !== 'none';
|
|
148
134
|
};
|
|
149
|
-
|
|
150
135
|
const getFocusStyles = (props, componentTheme) => {
|
|
151
136
|
const focusColor = props.focusColor,
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
137
|
+
focusPosition = props.focusPosition,
|
|
138
|
+
position = props.position,
|
|
139
|
+
shouldAnimateFocus = props.shouldAnimateFocus,
|
|
140
|
+
borderRadius = props.borderRadius;
|
|
156
141
|
const focusOutline = getFocusOutline(props);
|
|
157
142
|
const shouldUseBrowserFocus = typeof focusOutline === 'undefined';
|
|
158
143
|
const focusPositionVariants = {
|
|
@@ -175,7 +160,6 @@ const getFocusStyles = (props, componentTheme) => {
|
|
|
175
160
|
success: componentTheme.focusColorSuccess,
|
|
176
161
|
danger: componentTheme.focusColorDanger
|
|
177
162
|
};
|
|
178
|
-
|
|
179
163
|
if (position === 'relative') {
|
|
180
164
|
const focusRingRadius = getFocusRingRadius(borderRadius);
|
|
181
165
|
const focusRingVariants = {
|
|
@@ -229,7 +213,8 @@ const getFocusStyles = (props, componentTheme) => {
|
|
|
229
213
|
},
|
|
230
214
|
'&:focus': {
|
|
231
215
|
outline: 'none',
|
|
232
|
-
'&::before': {
|
|
216
|
+
'&::before': {
|
|
217
|
+
...(shouldUseBrowserFocus ? {
|
|
233
218
|
opacity: 1,
|
|
234
219
|
transform: 'scale(1)'
|
|
235
220
|
} : {})
|
|
@@ -237,7 +222,6 @@ const getFocusStyles = (props, componentTheme) => {
|
|
|
237
222
|
}
|
|
238
223
|
};
|
|
239
224
|
}
|
|
240
|
-
|
|
241
225
|
return {
|
|
242
226
|
'&::before': {
|
|
243
227
|
borderStyle: 'none'
|
|
@@ -248,13 +232,15 @@ const getFocusStyles = (props, componentTheme) => {
|
|
|
248
232
|
outlineWidth: componentTheme.focusOutlineWidth,
|
|
249
233
|
outlineStyle: componentTheme.focusOutlineStyle
|
|
250
234
|
} : {}),
|
|
251
|
-
'&:focus': {
|
|
235
|
+
'&:focus': {
|
|
236
|
+
...(shouldUseBrowserFocus ? {
|
|
252
237
|
outlineWidth: componentTheme.focusOutlineWidth,
|
|
253
238
|
outlineStyle: componentTheme.focusOutlineStyle
|
|
254
239
|
} : {})
|
|
255
240
|
}
|
|
256
241
|
};
|
|
257
242
|
};
|
|
243
|
+
|
|
258
244
|
/**
|
|
259
245
|
* ---
|
|
260
246
|
* private: true
|
|
@@ -265,35 +251,33 @@ const getFocusStyles = (props, componentTheme) => {
|
|
|
265
251
|
* @param {Object} extraArgs
|
|
266
252
|
* @return {Object} The final style object, which will be used in the component
|
|
267
253
|
*/
|
|
268
|
-
|
|
269
|
-
|
|
270
254
|
const generateStyle = (componentTheme, props) => {
|
|
271
255
|
const borderRadius = props.borderRadius,
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
256
|
+
borderWidth = props.borderWidth,
|
|
257
|
+
margin = props.margin,
|
|
258
|
+
padding = props.padding,
|
|
259
|
+
position = props.position,
|
|
260
|
+
display = props.display,
|
|
261
|
+
focusPosition = props.focusPosition,
|
|
262
|
+
textAlign = props.textAlign,
|
|
263
|
+
borderColor = props.borderColor,
|
|
264
|
+
background = props.background,
|
|
265
|
+
stacking = props.stacking,
|
|
266
|
+
shadow = props.shadow,
|
|
267
|
+
overflowY = props.overflowY,
|
|
268
|
+
overflowX = props.overflowX,
|
|
269
|
+
insetBlockEnd = props.insetBlockEnd,
|
|
270
|
+
insetBlockStart = props.insetBlockStart,
|
|
271
|
+
insetInlineEnd = props.insetInlineEnd,
|
|
272
|
+
insetInlineStart = props.insetInlineStart,
|
|
273
|
+
width = props.width,
|
|
274
|
+
height = props.height,
|
|
275
|
+
minWidth = props.minWidth,
|
|
276
|
+
minHeight = props.minHeight,
|
|
277
|
+
maxWidth = props.maxWidth,
|
|
278
|
+
maxHeight = props.maxHeight,
|
|
279
|
+
withVisualDebug = props.withVisualDebug,
|
|
280
|
+
dir = props.dir;
|
|
297
281
|
const borderStyle = getBorderStyle({
|
|
298
282
|
theme: componentTheme,
|
|
299
283
|
borderRadius,
|
|
@@ -476,7 +460,8 @@ const generateStyle = (componentTheme, props) => {
|
|
|
476
460
|
inlineStyles: {
|
|
477
461
|
//every '&' symbol will add another class to the rule, so it will be stronger
|
|
478
462
|
//making an accidental override less likely
|
|
479
|
-
'&&&&&&&&&&': {
|
|
463
|
+
'&&&&&&&&&&': {
|
|
464
|
+
...spacingStyle,
|
|
480
465
|
...borderStyle,
|
|
481
466
|
...offsetStyle,
|
|
482
467
|
width,
|
|
@@ -490,6 +475,5 @@ const generateStyle = (componentTheme, props) => {
|
|
|
490
475
|
}
|
|
491
476
|
};
|
|
492
477
|
};
|
|
493
|
-
|
|
494
478
|
var _default = generateStyle;
|
|
495
479
|
exports.default = _default;
|
package/lib/View/theme.js
CHANGED
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _emotion = require("@instructure/emotion");
|
|
9
|
-
|
|
10
8
|
/*
|
|
11
9
|
* The MIT License (MIT)
|
|
12
10
|
*
|
|
@@ -40,13 +38,13 @@ var _emotion = require("@instructure/emotion");
|
|
|
40
38
|
*/
|
|
41
39
|
const generateComponentTheme = theme => {
|
|
42
40
|
const colors = theme.colors,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
41
|
+
typography = theme.typography,
|
|
42
|
+
borders = theme.borders,
|
|
43
|
+
breakpoints = theme.breakpoints,
|
|
44
|
+
spacing = theme.spacing,
|
|
45
|
+
shadows = theme.shadows,
|
|
46
|
+
stacking = theme.stacking,
|
|
47
|
+
themeName = theme.key;
|
|
50
48
|
const themeSpecificStyle = {
|
|
51
49
|
canvas: {
|
|
52
50
|
color: theme['ic-brand-font-color-dark'],
|
|
@@ -86,6 +84,7 @@ const generateComponentTheme = theme => {
|
|
|
86
84
|
focusOutlineOffset: '0.3125rem',
|
|
87
85
|
focusOutlineInset: '0rem',
|
|
88
86
|
// do not use unitless zero (for CSS calc())
|
|
87
|
+
|
|
89
88
|
focusColorInfo: colors === null || colors === void 0 ? void 0 : colors.borderInfo,
|
|
90
89
|
focusColorDanger: colors === null || colors === void 0 ? void 0 : colors.borderDanger,
|
|
91
90
|
focusColorSuccess: colors === null || colors === void 0 ? void 0 : colors.borderSuccess,
|
|
@@ -100,10 +99,10 @@ const generateComponentTheme = theme => {
|
|
|
100
99
|
...(0, _emotion.makeThemeVars)('stacking', stacking),
|
|
101
100
|
...(0, _emotion.makeThemeVars)('border', borders)
|
|
102
101
|
};
|
|
103
|
-
return {
|
|
102
|
+
return {
|
|
103
|
+
...componentVariables,
|
|
104
104
|
...themeSpecificStyle[themeName]
|
|
105
105
|
};
|
|
106
106
|
};
|
|
107
|
-
|
|
108
107
|
var _default = generateComponentTheme;
|
|
109
108
|
exports.default = _default;
|