@instructure/ui-view 11.7.3-snapshot-7 → 11.7.3-snapshot-26
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 +5 -2
- package/es/ContextView/v1/index.js +53 -51
- package/es/ContextView/v1/styles.js +44 -39
- package/es/ContextView/v1/theme.js +4 -5
- package/es/ContextView/v2/index.js +54 -52
- package/es/ContextView/v2/styles.js +45 -40
- package/es/View/v1/index.js +84 -69
- package/es/View/v1/styles.js +38 -32
- package/es/View/v1/theme.js +41 -40
- package/es/View/v2/index.js +84 -69
- package/es/View/v2/styles.js +38 -32
- package/lib/ContextView/v1/index.js +53 -51
- package/lib/ContextView/v1/styles.js +44 -39
- package/lib/ContextView/v1/theme.js +4 -5
- package/lib/ContextView/v2/index.js +54 -52
- package/lib/ContextView/v2/styles.js +45 -40
- package/lib/View/v1/index.js +84 -69
- package/lib/View/v1/styles.js +38 -32
- package/lib/View/v1/theme.js +41 -40
- package/lib/View/v2/index.js +84 -69
- package/lib/View/v2/styles.js +38 -32
- package/package.json +13 -13
- package/tsconfig.build.tsbuildinfo +1 -1
package/lib/View/v1/index.js
CHANGED
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = exports.View = void 0;
|
|
8
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
9
8
|
var _react = require("react");
|
|
10
9
|
var _getCSSStyleDeclaration = require("@instructure/ui-dom-utils/lib/getCSSStyleDeclaration.js");
|
|
11
10
|
var _textDirectionContextConsumer = require("@instructure/ui-i18n/lib/textDirectionContextConsumer.js");
|
|
@@ -19,8 +18,7 @@ var _styles = _interopRequireDefault(require("./styles"));
|
|
|
19
18
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
20
19
|
var _props = require("./props");
|
|
21
20
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
22
|
-
|
|
23
|
-
var _dec, _dec2, _class, _View;
|
|
21
|
+
var _dec, _dec2, _class;
|
|
24
22
|
/*
|
|
25
23
|
* The MIT License (MIT)
|
|
26
24
|
*
|
|
@@ -50,42 +48,73 @@ category: components
|
|
|
50
48
|
---
|
|
51
49
|
@module View
|
|
52
50
|
**/
|
|
53
|
-
let View = exports.View = (_dec = (0, _textDirectionContextConsumer.textDirectionContextConsumer)(), _dec2 = (0, _emotion.withStyleLegacy)(_styles.default, _theme.default), _dec(_class = _dec2(_class =
|
|
51
|
+
let View = exports.View = (_dec = (0, _textDirectionContextConsumer.textDirectionContextConsumer)(), _dec2 = (0, _emotion.withStyleLegacy)(_styles.default, _theme.default), _dec(_class = _dec2(_class = class View extends _react.Component {
|
|
52
|
+
static displayName = "View";
|
|
53
|
+
static componentId = 'View';
|
|
54
|
+
static allowedProps = _props.allowedProps;
|
|
55
|
+
static defaultProps = {
|
|
56
|
+
display: 'auto',
|
|
57
|
+
overflowX: 'visible',
|
|
58
|
+
overflowY: 'visible',
|
|
59
|
+
withVisualDebug: false,
|
|
60
|
+
borderColor: 'primary',
|
|
61
|
+
position: 'static',
|
|
62
|
+
focusPosition: 'offset',
|
|
63
|
+
focusColor: 'info',
|
|
64
|
+
shouldAnimateFocus: true,
|
|
65
|
+
overscrollBehavior: 'auto'
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// TODO: Remove this code once all components are using passthroughProps in place
|
|
69
|
+
// of omitProps and have removed this function
|
|
70
|
+
|
|
71
|
+
// omitViewProps needs to be called on the composed View component so that the
|
|
72
|
+
// View.allowedProps in the method matches the View.allowedProps that will be called in
|
|
73
|
+
// the consumers. Otherwise the discrepancy could cause unexpected props being
|
|
74
|
+
// allowed through.
|
|
75
|
+
|
|
76
|
+
// Removes View's own props from the given object. Automatically excludes the
|
|
77
|
+
// following props: 'theme', 'children', 'className', 'style', 'styles',
|
|
78
|
+
// 'makeStyles', 'themeOverride'
|
|
79
|
+
// @param props the object to process
|
|
80
|
+
// @param Component The component whose props are processed.
|
|
81
|
+
// Only needed for debug logging in non-production builds.
|
|
82
|
+
static omitViewProps = (props, Component) => {
|
|
83
|
+
// We don't want the theming and styling props to pass
|
|
84
|
+
// (these are added and handled by the `@withStyle` decorator)
|
|
85
|
+
const propsToOmit = [...View.allowedProps, 'styles', 'makeStyles', 'themeOverride'];
|
|
86
|
+
if (typeof process !== 'undefined' && process?.env?.NODE_ENV !== 'production') {
|
|
87
|
+
Object.keys((0, _pickProps.pickProps)(props, propsToOmit)).forEach(prop => {
|
|
88
|
+
(0, _console.logError)(false, `[${Component.name}] prop '${prop}' is not allowed.`);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return (0, _omitProps.omitProps)(props, propsToOmit);
|
|
92
|
+
};
|
|
93
|
+
spanMarginVerified;
|
|
54
94
|
get _element() {
|
|
55
95
|
return this.ref;
|
|
56
96
|
}
|
|
57
97
|
constructor(props) {
|
|
58
98
|
super(props);
|
|
59
|
-
this.spanMarginVerified = void 0;
|
|
60
|
-
this.ref = null;
|
|
61
|
-
this.handleElementRef = el => {
|
|
62
|
-
if (typeof this.props.elementRef === 'function') {
|
|
63
|
-
this.props.elementRef(el);
|
|
64
|
-
}
|
|
65
|
-
this.ref = el;
|
|
66
|
-
};
|
|
67
99
|
this.spanMarginVerified = false;
|
|
68
100
|
}
|
|
69
101
|
componentDidMount() {
|
|
70
|
-
|
|
71
|
-
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
102
|
+
this.props.makeStyles?.();
|
|
72
103
|
}
|
|
73
104
|
componentDidUpdate() {
|
|
74
|
-
|
|
75
|
-
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
105
|
+
this.props.makeStyles?.();
|
|
76
106
|
|
|
77
107
|
// Not calling getCSSStyleDeclaration can save hundreds of ms in tests and production
|
|
78
|
-
if (typeof process !== 'undefined' &&
|
|
108
|
+
if (typeof process !== 'undefined' && process?.env?.NODE_ENV === 'development' && !this.spanMarginVerified) {
|
|
79
109
|
// We have to verify margins in the first 'componentDidUpdate',
|
|
80
110
|
// because that is when all styles are calculated,
|
|
81
111
|
// but we only want to check once, using a flag
|
|
82
112
|
this.spanMarginVerified = true;
|
|
83
113
|
(0, _console.logError)(!function verifySpanMargin(element, margin) {
|
|
84
|
-
var _getCSSStyleDeclarati;
|
|
85
114
|
if (!element) {
|
|
86
115
|
return;
|
|
87
116
|
}
|
|
88
|
-
const display = (
|
|
117
|
+
const display = (0, _getCSSStyleDeclaration.getCSSStyleDeclaration)(element)?.display;
|
|
89
118
|
if (display !== 'inline') {
|
|
90
119
|
return;
|
|
91
120
|
}
|
|
@@ -105,63 +134,49 @@ let View = exports.View = (_dec = (0, _textDirectionContextConsumer.textDirectio
|
|
|
105
134
|
}(this.ref, this.props.margin), `[View] display style is set to 'inline' and will allow for horizontal margins only.`);
|
|
106
135
|
}
|
|
107
136
|
}
|
|
137
|
+
ref = null;
|
|
138
|
+
handleElementRef = el => {
|
|
139
|
+
if (typeof this.props.elementRef === 'function') {
|
|
140
|
+
this.props.elementRef(el);
|
|
141
|
+
}
|
|
142
|
+
this.ref = el;
|
|
143
|
+
};
|
|
108
144
|
render() {
|
|
109
|
-
const
|
|
110
|
-
children
|
|
111
|
-
textAlign
|
|
112
|
-
background
|
|
113
|
-
display
|
|
114
|
-
withVisualDebug
|
|
115
|
-
width
|
|
116
|
-
height
|
|
117
|
-
minWidth
|
|
118
|
-
minHeight
|
|
119
|
-
maxWidth
|
|
120
|
-
maxHeight
|
|
121
|
-
overflowX
|
|
122
|
-
overflowY
|
|
123
|
-
stacking
|
|
124
|
-
shadow
|
|
125
|
-
position
|
|
126
|
-
focusPosition
|
|
127
|
-
focusColor
|
|
128
|
-
shouldAnimateFocus
|
|
129
|
-
borderColor
|
|
130
|
-
className
|
|
131
|
-
overscrollBehavior
|
|
132
|
-
styles
|
|
133
|
-
makeStyles
|
|
134
|
-
props
|
|
145
|
+
const {
|
|
146
|
+
children,
|
|
147
|
+
textAlign,
|
|
148
|
+
background,
|
|
149
|
+
display,
|
|
150
|
+
withVisualDebug,
|
|
151
|
+
width,
|
|
152
|
+
height,
|
|
153
|
+
minWidth,
|
|
154
|
+
minHeight,
|
|
155
|
+
maxWidth,
|
|
156
|
+
maxHeight,
|
|
157
|
+
overflowX,
|
|
158
|
+
overflowY,
|
|
159
|
+
stacking,
|
|
160
|
+
shadow,
|
|
161
|
+
position,
|
|
162
|
+
focusPosition,
|
|
163
|
+
focusColor,
|
|
164
|
+
shouldAnimateFocus,
|
|
165
|
+
borderColor,
|
|
166
|
+
className,
|
|
167
|
+
overscrollBehavior,
|
|
168
|
+
styles,
|
|
169
|
+
makeStyles,
|
|
170
|
+
...props
|
|
171
|
+
} = this.props;
|
|
135
172
|
const ElementType = (0, _getElementType.getElementType)(View, this.props);
|
|
136
173
|
return (0, _jsxRuntime.jsx)(ElementType, {
|
|
137
174
|
...(0, _passthroughProps.passthroughProps)(props),
|
|
138
175
|
className: className,
|
|
139
|
-
css: [styles
|
|
176
|
+
css: [styles?.view, styles?.inlineStyles],
|
|
140
177
|
ref: this.handleElementRef,
|
|
141
178
|
children: children
|
|
142
179
|
});
|
|
143
180
|
}
|
|
144
|
-
}
|
|
145
|
-
display: 'auto',
|
|
146
|
-
overflowX: 'visible',
|
|
147
|
-
overflowY: 'visible',
|
|
148
|
-
withVisualDebug: false,
|
|
149
|
-
borderColor: 'primary',
|
|
150
|
-
position: 'static',
|
|
151
|
-
focusPosition: 'offset',
|
|
152
|
-
focusColor: 'info',
|
|
153
|
-
shouldAnimateFocus: true,
|
|
154
|
-
overscrollBehavior: 'auto'
|
|
155
|
-
}, _View.omitViewProps = (props, Component) => {
|
|
156
|
-
var _process2, _process2$env;
|
|
157
|
-
// We don't want the theming and styling props to pass
|
|
158
|
-
// (these are added and handled by the `@withStyle` decorator)
|
|
159
|
-
const propsToOmit = [..._View.allowedProps, 'styles', 'makeStyles', 'themeOverride'];
|
|
160
|
-
if (typeof process !== 'undefined' && ((_process2 = process) === null || _process2 === void 0 ? void 0 : (_process2$env = _process2.env) === null || _process2$env === void 0 ? void 0 : _process2$env.NODE_ENV) !== 'production') {
|
|
161
|
-
Object.keys((0, _pickProps.pickProps)(props, propsToOmit)).forEach(prop => {
|
|
162
|
-
(0, _console.logError)(false, `[${Component.name}] prop '${prop}' is not allowed.`);
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
return (0, _omitProps.omitProps)(props, propsToOmit);
|
|
166
|
-
}, _View)) || _class) || _class);
|
|
181
|
+
}) || _class) || _class);
|
|
167
182
|
var _default = exports.default = View;
|
package/lib/View/v1/styles.js
CHANGED
|
@@ -103,15 +103,19 @@ const getStyleProps = ({
|
|
|
103
103
|
return whitelisted;
|
|
104
104
|
};
|
|
105
105
|
const withBorder = props => {
|
|
106
|
-
const
|
|
106
|
+
const {
|
|
107
|
+
borderWidth
|
|
108
|
+
} = props;
|
|
107
109
|
return borderWidth && borderWidth !== '0' && borderWidth !== 'none';
|
|
108
110
|
};
|
|
109
111
|
const getFocusStyles = (props, componentTheme) => {
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
112
|
+
const {
|
|
113
|
+
focusColor,
|
|
114
|
+
focusPosition,
|
|
115
|
+
shouldAnimateFocus,
|
|
116
|
+
withFocusOutline,
|
|
117
|
+
focusWithin
|
|
118
|
+
} = props;
|
|
115
119
|
const focusPos = focusPosition == 'offset' || focusPosition == 'inset' ? focusPosition : 'offset';
|
|
116
120
|
const focusPositionVariants = {
|
|
117
121
|
offset: {
|
|
@@ -165,32 +169,34 @@ const getFocusStyles = (props, componentTheme) => {
|
|
|
165
169
|
* @return {Object} The final style object, which will be used in the component
|
|
166
170
|
*/
|
|
167
171
|
const generateStyle = (componentTheme, props) => {
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
172
|
+
const {
|
|
173
|
+
borderRadius,
|
|
174
|
+
borderWidth,
|
|
175
|
+
margin,
|
|
176
|
+
padding,
|
|
177
|
+
position,
|
|
178
|
+
display,
|
|
179
|
+
textAlign,
|
|
180
|
+
borderColor,
|
|
181
|
+
background,
|
|
182
|
+
stacking,
|
|
183
|
+
shadow,
|
|
184
|
+
overflowY,
|
|
185
|
+
overflowX,
|
|
186
|
+
overscrollBehavior,
|
|
187
|
+
insetBlockEnd,
|
|
188
|
+
insetBlockStart,
|
|
189
|
+
insetInlineEnd,
|
|
190
|
+
insetInlineStart,
|
|
191
|
+
width,
|
|
192
|
+
height,
|
|
193
|
+
minWidth,
|
|
194
|
+
minHeight,
|
|
195
|
+
maxWidth,
|
|
196
|
+
maxHeight,
|
|
197
|
+
withVisualDebug,
|
|
198
|
+
dir
|
|
199
|
+
} = props;
|
|
194
200
|
const borderStyle = getBorderStyle({
|
|
195
201
|
theme: componentTheme,
|
|
196
202
|
borderRadius,
|
package/lib/View/v1/theme.js
CHANGED
|
@@ -37,15 +37,16 @@ var _emotion = require("@instructure/emotion");
|
|
|
37
37
|
* @return {Object} The final theme object with the overrides and component variables
|
|
38
38
|
*/
|
|
39
39
|
const generateComponentTheme = theme => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
typography
|
|
43
|
-
borders
|
|
44
|
-
breakpoints
|
|
45
|
-
spacing
|
|
46
|
-
shadows
|
|
47
|
-
stacking
|
|
48
|
-
themeName
|
|
40
|
+
const {
|
|
41
|
+
colors,
|
|
42
|
+
typography,
|
|
43
|
+
borders,
|
|
44
|
+
breakpoints,
|
|
45
|
+
spacing,
|
|
46
|
+
shadows,
|
|
47
|
+
stacking,
|
|
48
|
+
key: themeName
|
|
49
|
+
} = theme;
|
|
49
50
|
const themeSpecificStyle = {
|
|
50
51
|
canvas: {
|
|
51
52
|
color: theme['ic-brand-font-color-dark'],
|
|
@@ -57,43 +58,43 @@ const generateComponentTheme = theme => {
|
|
|
57
58
|
}
|
|
58
59
|
};
|
|
59
60
|
const componentVariables = {
|
|
60
|
-
fontFamily: typography
|
|
61
|
-
color: colors
|
|
62
|
-
colorPrimaryInverse: colors
|
|
63
|
-
borderColorPrimary: colors
|
|
64
|
-
borderColorSecondary: colors
|
|
65
|
-
borderColorSuccess: colors
|
|
66
|
-
borderColorBrand: colors
|
|
67
|
-
borderColorInfo: colors
|
|
68
|
-
borderColorAlert: colors
|
|
69
|
-
borderColorWarning: colors
|
|
70
|
-
borderColorDanger: colors
|
|
61
|
+
fontFamily: typography?.fontFamily,
|
|
62
|
+
color: colors?.contrasts?.grey125125,
|
|
63
|
+
colorPrimaryInverse: colors?.contrasts?.white1010,
|
|
64
|
+
borderColorPrimary: colors?.contrasts?.grey1424,
|
|
65
|
+
borderColorSecondary: colors?.contrasts?.grey3045,
|
|
66
|
+
borderColorSuccess: colors?.contrasts?.green4570,
|
|
67
|
+
borderColorBrand: colors?.contrasts?.blue4570,
|
|
68
|
+
borderColorInfo: colors?.contrasts?.blue4570,
|
|
69
|
+
borderColorAlert: colors?.contrasts?.blue4570,
|
|
70
|
+
borderColorWarning: colors?.contrasts?.orange4570,
|
|
71
|
+
borderColorDanger: colors?.contrasts?.red4570,
|
|
71
72
|
borderColorTransparent: 'transparent',
|
|
72
|
-
debugOutlineColor: colors
|
|
73
|
-
backgroundPrimary: colors
|
|
74
|
-
backgroundSecondary: colors
|
|
75
|
-
backgroundPrimaryInverse: colors
|
|
76
|
-
backgroundBrand: colors
|
|
77
|
-
backgroundInfo: colors
|
|
78
|
-
backgroundAlert: colors
|
|
79
|
-
backgroundSuccess: colors
|
|
80
|
-
backgroundDanger: colors
|
|
81
|
-
backgroundWarning: colors
|
|
73
|
+
debugOutlineColor: colors?.contrasts?.red4570,
|
|
74
|
+
backgroundPrimary: colors?.contrasts?.white1010,
|
|
75
|
+
backgroundSecondary: colors?.contrasts?.grey1111,
|
|
76
|
+
backgroundPrimaryInverse: colors?.contrasts?.grey125125,
|
|
77
|
+
backgroundBrand: colors?.contrasts?.blue4570,
|
|
78
|
+
backgroundInfo: colors?.contrasts?.blue4570,
|
|
79
|
+
backgroundAlert: colors?.contrasts?.blue4570,
|
|
80
|
+
backgroundSuccess: colors?.contrasts?.green4570,
|
|
81
|
+
backgroundDanger: colors?.contrasts?.red4570,
|
|
82
|
+
backgroundWarning: colors?.contrasts?.orange4570,
|
|
82
83
|
arrowSize: '0.5rem',
|
|
83
|
-
focusOutlineStyle: borders
|
|
84
|
-
focusOutlineWidth: borders
|
|
84
|
+
focusOutlineStyle: borders?.style,
|
|
85
|
+
focusOutlineWidth: borders?.widthMedium,
|
|
85
86
|
focusOutlineOffset: '0.3125rem',
|
|
86
87
|
focusOutlineInset: '0rem',
|
|
87
88
|
// do not use unitless zero (for CSS calc())
|
|
88
89
|
|
|
89
|
-
focusColorInfo: colors
|
|
90
|
-
focusColorDanger: colors
|
|
91
|
-
focusColorSuccess: colors
|
|
92
|
-
focusColorInverse: colors
|
|
93
|
-
xSmallMaxWidth: breakpoints
|
|
94
|
-
smallMaxWidth: breakpoints
|
|
95
|
-
mediumMaxWidth: breakpoints
|
|
96
|
-
largeMaxWidth: breakpoints
|
|
90
|
+
focusColorInfo: colors?.contrasts?.blue4570,
|
|
91
|
+
focusColorDanger: colors?.contrasts?.red4570,
|
|
92
|
+
focusColorSuccess: colors?.contrasts?.green4570,
|
|
93
|
+
focusColorInverse: colors?.contrasts?.white1010,
|
|
94
|
+
xSmallMaxWidth: breakpoints?.xSmall,
|
|
95
|
+
smallMaxWidth: breakpoints?.small,
|
|
96
|
+
mediumMaxWidth: breakpoints?.medium,
|
|
97
|
+
largeMaxWidth: breakpoints?.large,
|
|
97
98
|
...(0, _emotion.makeThemeVars)('margin', spacing),
|
|
98
99
|
...(0, _emotion.makeThemeVars)('padding', spacing),
|
|
99
100
|
...(0, _emotion.makeThemeVars)('shadow', shadows),
|
package/lib/View/v2/index.js
CHANGED
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = exports.View = void 0;
|
|
8
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
9
8
|
var _react = require("react");
|
|
10
9
|
var _getCSSStyleDeclaration = require("@instructure/ui-dom-utils/lib/getCSSStyleDeclaration.js");
|
|
11
10
|
var _textDirectionContextConsumer = require("@instructure/ui-i18n/lib/textDirectionContextConsumer.js");
|
|
@@ -18,8 +17,7 @@ var _emotion = require("@instructure/emotion");
|
|
|
18
17
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
19
18
|
var _props = require("./props");
|
|
20
19
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
21
|
-
|
|
22
|
-
var _dec, _dec2, _class, _View;
|
|
20
|
+
var _dec, _dec2, _class;
|
|
23
21
|
/*
|
|
24
22
|
* The MIT License (MIT)
|
|
25
23
|
*
|
|
@@ -49,42 +47,73 @@ category: components
|
|
|
49
47
|
---
|
|
50
48
|
@module View
|
|
51
49
|
**/
|
|
52
|
-
let View = exports.View = (_dec = (0, _textDirectionContextConsumer.textDirectionContextConsumer)(), _dec2 = (0, _emotion.withStyle)(_styles.default), _dec(_class = _dec2(_class =
|
|
50
|
+
let View = exports.View = (_dec = (0, _textDirectionContextConsumer.textDirectionContextConsumer)(), _dec2 = (0, _emotion.withStyle)(_styles.default), _dec(_class = _dec2(_class = class View extends _react.Component {
|
|
51
|
+
static displayName = "View";
|
|
52
|
+
static componentId = 'View';
|
|
53
|
+
static allowedProps = _props.allowedProps;
|
|
54
|
+
static defaultProps = {
|
|
55
|
+
display: 'auto',
|
|
56
|
+
overflowX: 'visible',
|
|
57
|
+
overflowY: 'visible',
|
|
58
|
+
withVisualDebug: false,
|
|
59
|
+
borderColor: 'primary',
|
|
60
|
+
position: 'static',
|
|
61
|
+
focusPosition: 'offset',
|
|
62
|
+
focusColor: 'info',
|
|
63
|
+
shouldAnimateFocus: true,
|
|
64
|
+
overscrollBehavior: 'auto'
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// TODO: Remove this code once all components are using passthroughProps in place
|
|
68
|
+
// of omitProps and have removed this function
|
|
69
|
+
|
|
70
|
+
// omitViewProps needs to be called on the composed View component so that the
|
|
71
|
+
// View.allowedProps in the method matches the View.allowedProps that will be called in
|
|
72
|
+
// the consumers. Otherwise the discrepancy could cause unexpected props being
|
|
73
|
+
// allowed through.
|
|
74
|
+
|
|
75
|
+
// Removes View's own props from the given object. Automatically excludes the
|
|
76
|
+
// following props: 'theme', 'children', 'className', 'style', 'styles',
|
|
77
|
+
// 'makeStyles', 'themeOverride'
|
|
78
|
+
// @param props the object to process
|
|
79
|
+
// @param Component The component whose props are processed.
|
|
80
|
+
// Only needed for debug logging in non-production builds.
|
|
81
|
+
static omitViewProps = (props, Component) => {
|
|
82
|
+
// We don't want the theming and styling props to pass
|
|
83
|
+
// (these are added and handled by the `@withStyle` decorator)
|
|
84
|
+
const propsToOmit = [...View.allowedProps, 'styles', 'makeStyles', 'themeOverride'];
|
|
85
|
+
if (typeof process !== 'undefined' && (process?.env?.GITHUB_PULL_REQUEST_PREVIEW === 'true' || process?.env?.NODE_ENV !== 'production')) {
|
|
86
|
+
Object.keys((0, _pickProps.pickProps)(props, propsToOmit)).forEach(prop => {
|
|
87
|
+
(0, _console.logError)(false, `[${Component.name}] prop '${prop}' is not allowed.`);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
return (0, _omitProps.omitProps)(props, propsToOmit);
|
|
91
|
+
};
|
|
92
|
+
spanMarginVerified;
|
|
53
93
|
get _element() {
|
|
54
94
|
return this.ref;
|
|
55
95
|
}
|
|
56
96
|
constructor(props) {
|
|
57
97
|
super(props);
|
|
58
|
-
this.spanMarginVerified = void 0;
|
|
59
|
-
this.ref = null;
|
|
60
|
-
this.handleElementRef = el => {
|
|
61
|
-
if (typeof this.props.elementRef === 'function') {
|
|
62
|
-
this.props.elementRef(el);
|
|
63
|
-
}
|
|
64
|
-
this.ref = el;
|
|
65
|
-
};
|
|
66
98
|
this.spanMarginVerified = false;
|
|
67
99
|
}
|
|
68
100
|
componentDidMount() {
|
|
69
|
-
|
|
70
|
-
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
101
|
+
this.props.makeStyles?.();
|
|
71
102
|
}
|
|
72
103
|
componentDidUpdate() {
|
|
73
|
-
|
|
74
|
-
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
104
|
+
this.props.makeStyles?.();
|
|
75
105
|
|
|
76
106
|
// Not calling getCSSStyleDeclaration can save hundreds of ms in tests and production
|
|
77
|
-
if (typeof process !== 'undefined' &&
|
|
107
|
+
if (typeof process !== 'undefined' && process?.env?.NODE_ENV === 'development' && !this.spanMarginVerified) {
|
|
78
108
|
// We have to verify margins in the first 'componentDidUpdate',
|
|
79
109
|
// because that is when all styles are calculated,
|
|
80
110
|
// but we only want to check once, using a flag
|
|
81
111
|
this.spanMarginVerified = true;
|
|
82
112
|
(0, _console.logError)(!function verifySpanMargin(element, margin) {
|
|
83
|
-
var _getCSSStyleDeclarati;
|
|
84
113
|
if (!element) {
|
|
85
114
|
return;
|
|
86
115
|
}
|
|
87
|
-
const display = (
|
|
116
|
+
const display = (0, _getCSSStyleDeclaration.getCSSStyleDeclaration)(element)?.display;
|
|
88
117
|
if (display !== 'inline') {
|
|
89
118
|
return;
|
|
90
119
|
}
|
|
@@ -104,63 +133,49 @@ let View = exports.View = (_dec = (0, _textDirectionContextConsumer.textDirectio
|
|
|
104
133
|
}(this.ref, this.props.margin), `[View] display style is set to 'inline' and will allow for horizontal margins only.`);
|
|
105
134
|
}
|
|
106
135
|
}
|
|
136
|
+
ref = null;
|
|
137
|
+
handleElementRef = el => {
|
|
138
|
+
if (typeof this.props.elementRef === 'function') {
|
|
139
|
+
this.props.elementRef(el);
|
|
140
|
+
}
|
|
141
|
+
this.ref = el;
|
|
142
|
+
};
|
|
107
143
|
render() {
|
|
108
|
-
const
|
|
109
|
-
children
|
|
110
|
-
textAlign
|
|
111
|
-
background
|
|
112
|
-
display
|
|
113
|
-
withVisualDebug
|
|
114
|
-
width
|
|
115
|
-
height
|
|
116
|
-
minWidth
|
|
117
|
-
minHeight
|
|
118
|
-
maxWidth
|
|
119
|
-
maxHeight
|
|
120
|
-
overflowX
|
|
121
|
-
overflowY
|
|
122
|
-
stacking
|
|
123
|
-
shadow
|
|
124
|
-
position
|
|
125
|
-
focusPosition
|
|
126
|
-
focusColor
|
|
127
|
-
shouldAnimateFocus
|
|
128
|
-
borderColor
|
|
129
|
-
className
|
|
130
|
-
overscrollBehavior
|
|
131
|
-
styles
|
|
132
|
-
makeStyles
|
|
133
|
-
props
|
|
144
|
+
const {
|
|
145
|
+
children,
|
|
146
|
+
textAlign,
|
|
147
|
+
background,
|
|
148
|
+
display,
|
|
149
|
+
withVisualDebug,
|
|
150
|
+
width,
|
|
151
|
+
height,
|
|
152
|
+
minWidth,
|
|
153
|
+
minHeight,
|
|
154
|
+
maxWidth,
|
|
155
|
+
maxHeight,
|
|
156
|
+
overflowX,
|
|
157
|
+
overflowY,
|
|
158
|
+
stacking,
|
|
159
|
+
shadow,
|
|
160
|
+
position,
|
|
161
|
+
focusPosition,
|
|
162
|
+
focusColor,
|
|
163
|
+
shouldAnimateFocus,
|
|
164
|
+
borderColor,
|
|
165
|
+
className,
|
|
166
|
+
overscrollBehavior,
|
|
167
|
+
styles,
|
|
168
|
+
makeStyles,
|
|
169
|
+
...props
|
|
170
|
+
} = this.props;
|
|
134
171
|
const ElementType = (0, _getElementType.getElementType)(View, this.props);
|
|
135
172
|
return (0, _jsxRuntime.jsx)(ElementType, {
|
|
136
173
|
...(0, _passthroughProps.passthroughProps)(props),
|
|
137
174
|
className: className,
|
|
138
|
-
css: [styles
|
|
175
|
+
css: [styles?.view, styles?.inlineStyles],
|
|
139
176
|
ref: this.handleElementRef,
|
|
140
177
|
children: children
|
|
141
178
|
});
|
|
142
179
|
}
|
|
143
|
-
}
|
|
144
|
-
display: 'auto',
|
|
145
|
-
overflowX: 'visible',
|
|
146
|
-
overflowY: 'visible',
|
|
147
|
-
withVisualDebug: false,
|
|
148
|
-
borderColor: 'primary',
|
|
149
|
-
position: 'static',
|
|
150
|
-
focusPosition: 'offset',
|
|
151
|
-
focusColor: 'info',
|
|
152
|
-
shouldAnimateFocus: true,
|
|
153
|
-
overscrollBehavior: 'auto'
|
|
154
|
-
}, _View.omitViewProps = (props, Component) => {
|
|
155
|
-
var _process2, _process2$env, _process3, _process3$env;
|
|
156
|
-
// We don't want the theming and styling props to pass
|
|
157
|
-
// (these are added and handled by the `@withStyle` decorator)
|
|
158
|
-
const propsToOmit = [..._View.allowedProps, 'styles', 'makeStyles', 'themeOverride'];
|
|
159
|
-
if (typeof process !== 'undefined' && (((_process2 = process) === null || _process2 === void 0 ? void 0 : (_process2$env = _process2.env) === null || _process2$env === void 0 ? void 0 : _process2$env.GITHUB_PULL_REQUEST_PREVIEW) === 'true' || ((_process3 = process) === null || _process3 === void 0 ? void 0 : (_process3$env = _process3.env) === null || _process3$env === void 0 ? void 0 : _process3$env.NODE_ENV) !== 'production')) {
|
|
160
|
-
Object.keys((0, _pickProps.pickProps)(props, propsToOmit)).forEach(prop => {
|
|
161
|
-
(0, _console.logError)(false, `[${Component.name}] prop '${prop}' is not allowed.`);
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
return (0, _omitProps.omitProps)(props, propsToOmit);
|
|
165
|
-
}, _View)) || _class) || _class);
|
|
180
|
+
}) || _class) || _class);
|
|
166
181
|
var _default = exports.default = View;
|