@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/es/View/v2/index.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
const _excluded = ["children", "textAlign", "background", "display", "withVisualDebug", "width", "height", "minWidth", "minHeight", "maxWidth", "maxHeight", "overflowX", "overflowY", "stacking", "shadow", "position", "focusPosition", "focusColor", "shouldAnimateFocus", "borderColor", "className", "overscrollBehavior", "styles", "makeStyles"];
|
|
3
|
-
var _dec, _dec2, _class, _View;
|
|
1
|
+
var _dec, _dec2, _class;
|
|
4
2
|
/*
|
|
5
3
|
* The MIT License (MIT)
|
|
6
4
|
*
|
|
@@ -40,42 +38,73 @@ category: components
|
|
|
40
38
|
---
|
|
41
39
|
@module View
|
|
42
40
|
**/
|
|
43
|
-
let View = (_dec = textDirectionContextConsumer(), _dec2 = withStyle(generateStyle), _dec(_class = _dec2(_class =
|
|
41
|
+
let View = (_dec = textDirectionContextConsumer(), _dec2 = withStyle(generateStyle), _dec(_class = _dec2(_class = class View extends Component {
|
|
42
|
+
static displayName = "View";
|
|
43
|
+
static componentId = 'View';
|
|
44
|
+
static allowedProps = allowedProps;
|
|
45
|
+
static defaultProps = {
|
|
46
|
+
display: 'auto',
|
|
47
|
+
overflowX: 'visible',
|
|
48
|
+
overflowY: 'visible',
|
|
49
|
+
withVisualDebug: false,
|
|
50
|
+
borderColor: 'primary',
|
|
51
|
+
position: 'static',
|
|
52
|
+
focusPosition: 'offset',
|
|
53
|
+
focusColor: 'info',
|
|
54
|
+
shouldAnimateFocus: true,
|
|
55
|
+
overscrollBehavior: 'auto'
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// TODO: Remove this code once all components are using passthroughProps in place
|
|
59
|
+
// of omitProps and have removed this function
|
|
60
|
+
|
|
61
|
+
// omitViewProps needs to be called on the composed View component so that the
|
|
62
|
+
// View.allowedProps in the method matches the View.allowedProps that will be called in
|
|
63
|
+
// the consumers. Otherwise the discrepancy could cause unexpected props being
|
|
64
|
+
// allowed through.
|
|
65
|
+
|
|
66
|
+
// Removes View's own props from the given object. Automatically excludes the
|
|
67
|
+
// following props: 'theme', 'children', 'className', 'style', 'styles',
|
|
68
|
+
// 'makeStyles', 'themeOverride'
|
|
69
|
+
// @param props the object to process
|
|
70
|
+
// @param Component The component whose props are processed.
|
|
71
|
+
// Only needed for debug logging in non-production builds.
|
|
72
|
+
static omitViewProps = (props, Component) => {
|
|
73
|
+
// We don't want the theming and styling props to pass
|
|
74
|
+
// (these are added and handled by the `@withStyle` decorator)
|
|
75
|
+
const propsToOmit = [...View.allowedProps, 'styles', 'makeStyles', 'themeOverride'];
|
|
76
|
+
if (typeof process !== 'undefined' && (process?.env?.GITHUB_PULL_REQUEST_PREVIEW === 'true' || process?.env?.NODE_ENV !== 'production')) {
|
|
77
|
+
Object.keys(pickProps(props, propsToOmit)).forEach(prop => {
|
|
78
|
+
error(false, `[${Component.name}] prop '${prop}' is not allowed.`);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return omitProps(props, propsToOmit);
|
|
82
|
+
};
|
|
83
|
+
spanMarginVerified;
|
|
44
84
|
get _element() {
|
|
45
85
|
return this.ref;
|
|
46
86
|
}
|
|
47
87
|
constructor(props) {
|
|
48
88
|
super(props);
|
|
49
|
-
this.spanMarginVerified = void 0;
|
|
50
|
-
this.ref = null;
|
|
51
|
-
this.handleElementRef = el => {
|
|
52
|
-
if (typeof this.props.elementRef === 'function') {
|
|
53
|
-
this.props.elementRef(el);
|
|
54
|
-
}
|
|
55
|
-
this.ref = el;
|
|
56
|
-
};
|
|
57
89
|
this.spanMarginVerified = false;
|
|
58
90
|
}
|
|
59
91
|
componentDidMount() {
|
|
60
|
-
|
|
61
|
-
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
92
|
+
this.props.makeStyles?.();
|
|
62
93
|
}
|
|
63
94
|
componentDidUpdate() {
|
|
64
|
-
|
|
65
|
-
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
95
|
+
this.props.makeStyles?.();
|
|
66
96
|
|
|
67
97
|
// Not calling getCSSStyleDeclaration can save hundreds of ms in tests and production
|
|
68
|
-
if (typeof process !== 'undefined' &&
|
|
98
|
+
if (typeof process !== 'undefined' && process?.env?.NODE_ENV === 'development' && !this.spanMarginVerified) {
|
|
69
99
|
// We have to verify margins in the first 'componentDidUpdate',
|
|
70
100
|
// because that is when all styles are calculated,
|
|
71
101
|
// but we only want to check once, using a flag
|
|
72
102
|
this.spanMarginVerified = true;
|
|
73
103
|
error(!function verifySpanMargin(element, margin) {
|
|
74
|
-
var _getCSSStyleDeclarati;
|
|
75
104
|
if (!element) {
|
|
76
105
|
return;
|
|
77
106
|
}
|
|
78
|
-
const display =
|
|
107
|
+
const display = getCSSStyleDeclaration(element)?.display;
|
|
79
108
|
if (display !== 'inline') {
|
|
80
109
|
return;
|
|
81
110
|
}
|
|
@@ -95,64 +124,50 @@ let View = (_dec = textDirectionContextConsumer(), _dec2 = withStyle(generateSty
|
|
|
95
124
|
}(this.ref, this.props.margin), `[View] display style is set to 'inline' and will allow for horizontal margins only.`);
|
|
96
125
|
}
|
|
97
126
|
}
|
|
127
|
+
ref = null;
|
|
128
|
+
handleElementRef = el => {
|
|
129
|
+
if (typeof this.props.elementRef === 'function') {
|
|
130
|
+
this.props.elementRef(el);
|
|
131
|
+
}
|
|
132
|
+
this.ref = el;
|
|
133
|
+
};
|
|
98
134
|
render() {
|
|
99
|
-
const
|
|
100
|
-
children
|
|
101
|
-
textAlign
|
|
102
|
-
background
|
|
103
|
-
display
|
|
104
|
-
withVisualDebug
|
|
105
|
-
width
|
|
106
|
-
height
|
|
107
|
-
minWidth
|
|
108
|
-
minHeight
|
|
109
|
-
maxWidth
|
|
110
|
-
maxHeight
|
|
111
|
-
overflowX
|
|
112
|
-
overflowY
|
|
113
|
-
stacking
|
|
114
|
-
shadow
|
|
115
|
-
position
|
|
116
|
-
focusPosition
|
|
117
|
-
focusColor
|
|
118
|
-
shouldAnimateFocus
|
|
119
|
-
borderColor
|
|
120
|
-
className
|
|
121
|
-
overscrollBehavior
|
|
122
|
-
styles
|
|
123
|
-
makeStyles
|
|
124
|
-
props
|
|
135
|
+
const {
|
|
136
|
+
children,
|
|
137
|
+
textAlign,
|
|
138
|
+
background,
|
|
139
|
+
display,
|
|
140
|
+
withVisualDebug,
|
|
141
|
+
width,
|
|
142
|
+
height,
|
|
143
|
+
minWidth,
|
|
144
|
+
minHeight,
|
|
145
|
+
maxWidth,
|
|
146
|
+
maxHeight,
|
|
147
|
+
overflowX,
|
|
148
|
+
overflowY,
|
|
149
|
+
stacking,
|
|
150
|
+
shadow,
|
|
151
|
+
position,
|
|
152
|
+
focusPosition,
|
|
153
|
+
focusColor,
|
|
154
|
+
shouldAnimateFocus,
|
|
155
|
+
borderColor,
|
|
156
|
+
className,
|
|
157
|
+
overscrollBehavior,
|
|
158
|
+
styles,
|
|
159
|
+
makeStyles,
|
|
160
|
+
...props
|
|
161
|
+
} = this.props;
|
|
125
162
|
const ElementType = getElementType(View, this.props);
|
|
126
163
|
return _jsx(ElementType, {
|
|
127
164
|
...passthroughProps(props),
|
|
128
165
|
className: className,
|
|
129
|
-
css: [styles
|
|
166
|
+
css: [styles?.view, styles?.inlineStyles],
|
|
130
167
|
ref: this.handleElementRef,
|
|
131
168
|
children: children
|
|
132
169
|
});
|
|
133
170
|
}
|
|
134
|
-
}
|
|
135
|
-
display: 'auto',
|
|
136
|
-
overflowX: 'visible',
|
|
137
|
-
overflowY: 'visible',
|
|
138
|
-
withVisualDebug: false,
|
|
139
|
-
borderColor: 'primary',
|
|
140
|
-
position: 'static',
|
|
141
|
-
focusPosition: 'offset',
|
|
142
|
-
focusColor: 'info',
|
|
143
|
-
shouldAnimateFocus: true,
|
|
144
|
-
overscrollBehavior: 'auto'
|
|
145
|
-
}, _View.omitViewProps = (props, Component) => {
|
|
146
|
-
var _process2, _process2$env, _process3, _process3$env;
|
|
147
|
-
// We don't want the theming and styling props to pass
|
|
148
|
-
// (these are added and handled by the `@withStyle` decorator)
|
|
149
|
-
const propsToOmit = [..._View.allowedProps, 'styles', 'makeStyles', 'themeOverride'];
|
|
150
|
-
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')) {
|
|
151
|
-
Object.keys(pickProps(props, propsToOmit)).forEach(prop => {
|
|
152
|
-
error(false, `[${Component.name}] prop '${prop}' is not allowed.`);
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
return omitProps(props, propsToOmit);
|
|
156
|
-
}, _View)) || _class) || _class);
|
|
171
|
+
}) || _class) || _class);
|
|
157
172
|
export default View;
|
|
158
173
|
export { View };
|
package/es/View/v2/styles.js
CHANGED
|
@@ -146,7 +146,9 @@ const getStyleProps = ({
|
|
|
146
146
|
return whitelisted;
|
|
147
147
|
};
|
|
148
148
|
const withBorder = props => {
|
|
149
|
-
const
|
|
149
|
+
const {
|
|
150
|
+
borderWidth
|
|
151
|
+
} = props;
|
|
150
152
|
return borderWidth && borderWidth !== '0' && borderWidth !== 'none';
|
|
151
153
|
};
|
|
152
154
|
|
|
@@ -157,32 +159,34 @@ const withBorder = props => {
|
|
|
157
159
|
* @return {Object} The final style object, which will be used in the component
|
|
158
160
|
*/
|
|
159
161
|
const generateStyle = (componentTheme, props, sharedTokens) => {
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
162
|
+
const {
|
|
163
|
+
borderRadius,
|
|
164
|
+
borderWidth,
|
|
165
|
+
margin,
|
|
166
|
+
padding,
|
|
167
|
+
position,
|
|
168
|
+
display,
|
|
169
|
+
textAlign,
|
|
170
|
+
borderColor,
|
|
171
|
+
background,
|
|
172
|
+
stacking,
|
|
173
|
+
shadow,
|
|
174
|
+
overflowY,
|
|
175
|
+
overflowX,
|
|
176
|
+
overscrollBehavior,
|
|
177
|
+
insetBlockEnd,
|
|
178
|
+
insetBlockStart,
|
|
179
|
+
insetInlineEnd,
|
|
180
|
+
insetInlineStart,
|
|
181
|
+
width,
|
|
182
|
+
height,
|
|
183
|
+
minWidth,
|
|
184
|
+
minHeight,
|
|
185
|
+
maxWidth,
|
|
186
|
+
maxHeight,
|
|
187
|
+
withVisualDebug,
|
|
188
|
+
dir
|
|
189
|
+
} = props;
|
|
186
190
|
const borderStyle = getBorderStyle({
|
|
187
191
|
sharedTokens,
|
|
188
192
|
borderRadius,
|
|
@@ -360,11 +364,13 @@ const generateStyle = (componentTheme, props, sharedTokens) => {
|
|
|
360
364
|
},
|
|
361
365
|
none: {}
|
|
362
366
|
};
|
|
363
|
-
const
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
367
|
+
const {
|
|
368
|
+
focusColor,
|
|
369
|
+
focusPosition,
|
|
370
|
+
shouldAnimateFocus,
|
|
371
|
+
withFocusOutline,
|
|
372
|
+
focusWithin
|
|
373
|
+
} = props;
|
|
368
374
|
const focusOutline = calcFocusOutlineStyles(sharedTokens.focusOutline, {
|
|
369
375
|
focusColor,
|
|
370
376
|
focusPosition,
|
|
@@ -13,7 +13,7 @@ var _styles = _interopRequireDefault(require("./styles"));
|
|
|
13
13
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
14
14
|
var _props = require("./props");
|
|
15
15
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
16
|
-
var _dec, _class
|
|
16
|
+
var _dec, _class;
|
|
17
17
|
/*
|
|
18
18
|
* The MIT License (MIT)
|
|
19
19
|
*
|
|
@@ -42,49 +42,62 @@ var _dec, _class, _ContextView;
|
|
|
42
42
|
category: components
|
|
43
43
|
---
|
|
44
44
|
**/
|
|
45
|
-
let ContextView = exports.ContextView = (_dec = (0, _emotion.withStyleLegacy)(_styles.default, _theme.default), _dec(_class =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
45
|
+
let ContextView = exports.ContextView = (_dec = (0, _emotion.withStyleLegacy)(_styles.default, _theme.default), _dec(_class = class ContextView extends _react.Component {
|
|
46
|
+
static displayName = "ContextView";
|
|
47
|
+
static componentId = 'ContextView';
|
|
48
|
+
static allowedProps = _props.allowedProps;
|
|
49
|
+
static defaultProps = {
|
|
50
|
+
as: 'span',
|
|
51
|
+
elementRef: () => {},
|
|
52
|
+
debug: false,
|
|
53
|
+
width: 'auto',
|
|
54
|
+
height: 'auto',
|
|
55
|
+
children: null,
|
|
56
|
+
textAlign: 'start',
|
|
57
|
+
background: 'default',
|
|
58
|
+
shadow: 'resting',
|
|
59
|
+
placement: 'center end'
|
|
60
|
+
};
|
|
57
61
|
componentDidMount() {
|
|
58
|
-
|
|
59
|
-
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
62
|
+
this.props.makeStyles?.();
|
|
60
63
|
}
|
|
61
64
|
componentDidUpdate() {
|
|
62
|
-
|
|
63
|
-
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
65
|
+
this.props.makeStyles?.();
|
|
64
66
|
}
|
|
67
|
+
ref = null;
|
|
68
|
+
handleRef = el => {
|
|
69
|
+
const {
|
|
70
|
+
elementRef
|
|
71
|
+
} = this.props;
|
|
72
|
+
this.ref = el;
|
|
73
|
+
if (typeof elementRef === 'function') {
|
|
74
|
+
elementRef(el);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
65
77
|
render() {
|
|
66
|
-
const
|
|
67
|
-
as
|
|
68
|
-
background
|
|
69
|
-
children
|
|
70
|
-
debug
|
|
71
|
-
height
|
|
72
|
-
width
|
|
73
|
-
maxHeight
|
|
74
|
-
maxWidth
|
|
75
|
-
minHeight
|
|
76
|
-
minWidth
|
|
77
|
-
margin
|
|
78
|
-
padding
|
|
79
|
-
shadow
|
|
80
|
-
stacking
|
|
81
|
-
style
|
|
82
|
-
textAlign
|
|
83
|
-
styles
|
|
84
|
-
borderColor
|
|
78
|
+
const {
|
|
79
|
+
as,
|
|
80
|
+
background,
|
|
81
|
+
children,
|
|
82
|
+
debug,
|
|
83
|
+
height,
|
|
84
|
+
width,
|
|
85
|
+
maxHeight,
|
|
86
|
+
maxWidth,
|
|
87
|
+
minHeight,
|
|
88
|
+
minWidth,
|
|
89
|
+
margin,
|
|
90
|
+
padding,
|
|
91
|
+
shadow,
|
|
92
|
+
stacking,
|
|
93
|
+
style,
|
|
94
|
+
textAlign,
|
|
95
|
+
styles,
|
|
96
|
+
borderColor
|
|
97
|
+
} = this.props;
|
|
85
98
|
return (0, _jsxRuntime.jsx)(_v.View, {
|
|
86
99
|
...(0, _omitProps.omitProps)(this.props, ContextView.allowedProps),
|
|
87
|
-
css: styles
|
|
100
|
+
css: styles?.contextView,
|
|
88
101
|
style: style,
|
|
89
102
|
borderWidth: "none",
|
|
90
103
|
display: "inline-block",
|
|
@@ -94,7 +107,7 @@ let ContextView = exports.ContextView = (_dec = (0, _emotion.withStyleLegacy)(_s
|
|
|
94
107
|
margin: margin,
|
|
95
108
|
stacking: stacking,
|
|
96
109
|
children: (0, _jsxRuntime.jsxs)(_v.View, {
|
|
97
|
-
css: styles
|
|
110
|
+
css: styles?.contextView__content,
|
|
98
111
|
display: "block",
|
|
99
112
|
borderRadius: "medium",
|
|
100
113
|
borderWidth: "small",
|
|
@@ -111,21 +124,10 @@ let ContextView = exports.ContextView = (_dec = (0, _emotion.withStyleLegacy)(_s
|
|
|
111
124
|
shadow: shadow,
|
|
112
125
|
textAlign: textAlign,
|
|
113
126
|
children: [(0, _jsxRuntime.jsx)("span", {
|
|
114
|
-
css: styles
|
|
127
|
+
css: styles?.contextView__arrow
|
|
115
128
|
}), children]
|
|
116
129
|
})
|
|
117
130
|
});
|
|
118
131
|
}
|
|
119
|
-
}
|
|
120
|
-
as: 'span',
|
|
121
|
-
elementRef: () => {},
|
|
122
|
-
debug: false,
|
|
123
|
-
width: 'auto',
|
|
124
|
-
height: 'auto',
|
|
125
|
-
children: null,
|
|
126
|
-
textAlign: 'start',
|
|
127
|
-
background: 'default',
|
|
128
|
-
shadow: 'resting',
|
|
129
|
-
placement: 'center end'
|
|
130
|
-
}, _ContextView)) || _class);
|
|
132
|
+
}) || _class);
|
|
131
133
|
var _default = exports.default = ContextView;
|