@instructure/ui-view 11.7.3 → 11.7.4-pr-snapshot-1781695314229
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 +44 -0
- package/LICENSE.md +1 -0
- package/{lib/ContextView/v2/props.js → babel.config.cjs} +12 -7
- package/es/ContextView/v1/index.js +5 -5
- package/es/ContextView/v1/styles.js +0 -1
- package/es/ContextView/v2/index.js +4 -4
- package/es/ContextView/v2/styles.js +0 -1
- package/es/View/v1/index.js +4 -4
- package/es/View/v2/index.js +3 -6
- package/es/View/v2/props.js +1 -1
- package/es/exports/a.js +3 -2
- package/es/exports/b.js +3 -2
- package/package.json +14 -19
- package/src/ContextView/v1/index.tsx +5 -4
- package/src/ContextView/v2/index.tsx +4 -3
- package/src/View/v1/index.tsx +4 -3
- package/src/View/v2/index.tsx +3 -9
- package/src/View/v2/props.ts +0 -12
- package/src/exports/a.ts +2 -2
- package/src/exports/b.ts +2 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/ContextView/v1/index.d.ts +1 -0
- package/types/ContextView/v1/index.d.ts.map +1 -1
- package/types/ContextView/v2/index.d.ts +1 -0
- package/types/ContextView/v2/index.d.ts.map +1 -1
- package/types/View/v1/index.d.ts +2 -1
- package/types/View/v1/index.d.ts.map +1 -1
- package/types/View/v2/index.d.ts +2 -2
- package/types/View/v2/index.d.ts.map +1 -1
- package/types/View/v2/props.d.ts +0 -11
- package/types/View/v2/props.d.ts.map +1 -1
- package/types/exports/a.d.ts +2 -2
- package/types/exports/a.d.ts.map +1 -1
- package/types/exports/b.d.ts +2 -2
- package/types/exports/b.d.ts.map +1 -1
- package/lib/ContextView/v1/index.js +0 -133
- package/lib/ContextView/v1/props.js +0 -31
- package/lib/ContextView/v1/styles.js +0 -267
- package/lib/ContextView/v1/theme.js +0 -49
- package/lib/ContextView/v2/index.js +0 -132
- package/lib/ContextView/v2/styles.js +0 -267
- package/lib/View/v1/index.js +0 -182
- package/lib/View/v1/props.js +0 -34
- package/lib/View/v1/styles.js +0 -423
- package/lib/View/v1/theme.js +0 -109
- package/lib/View/v2/index.js +0 -181
- package/lib/View/v2/props.js +0 -34
- package/lib/View/v2/styles.js +0 -432
- package/lib/exports/a.js +0 -19
- package/lib/exports/b.js +0 -19
- package/lib/package.json +0 -1
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = exports.ContextView = void 0;
|
|
8
|
-
var _react = require("react");
|
|
9
|
-
var _emotion = require("@instructure/emotion");
|
|
10
|
-
var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
|
|
11
|
-
var _v = require("../../View/v2");
|
|
12
|
-
var _styles = _interopRequireDefault(require("./styles"));
|
|
13
|
-
var _props = require("./props");
|
|
14
|
-
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
15
|
-
var _dec, _class;
|
|
16
|
-
/*
|
|
17
|
-
* The MIT License (MIT)
|
|
18
|
-
*
|
|
19
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
20
|
-
*
|
|
21
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
22
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
23
|
-
* in the Software without restriction, including without limitation the rights
|
|
24
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
25
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
26
|
-
* furnished to do so, subject to the following conditions:
|
|
27
|
-
*
|
|
28
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
29
|
-
* copies or substantial portions of the Software.
|
|
30
|
-
*
|
|
31
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
32
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
33
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
34
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
35
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
36
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
37
|
-
* SOFTWARE.
|
|
38
|
-
*/
|
|
39
|
-
/**
|
|
40
|
-
---
|
|
41
|
-
category: components
|
|
42
|
-
---
|
|
43
|
-
**/
|
|
44
|
-
let ContextView = exports.ContextView = (_dec = (0, _emotion.withStyleNew)(_styles.default), _dec(_class = class ContextView extends _react.Component {
|
|
45
|
-
static displayName = "ContextView";
|
|
46
|
-
static componentId = 'ContextView';
|
|
47
|
-
static allowedProps = _props.allowedProps;
|
|
48
|
-
static defaultProps = {
|
|
49
|
-
as: 'span',
|
|
50
|
-
elementRef: () => {},
|
|
51
|
-
debug: false,
|
|
52
|
-
width: 'auto',
|
|
53
|
-
height: 'auto',
|
|
54
|
-
children: null,
|
|
55
|
-
textAlign: 'start',
|
|
56
|
-
background: 'default',
|
|
57
|
-
shadow: 'above',
|
|
58
|
-
placement: 'center end'
|
|
59
|
-
};
|
|
60
|
-
componentDidMount() {
|
|
61
|
-
this.props.makeStyles?.();
|
|
62
|
-
}
|
|
63
|
-
componentDidUpdate() {
|
|
64
|
-
this.props.makeStyles?.();
|
|
65
|
-
}
|
|
66
|
-
ref = null;
|
|
67
|
-
handleRef = el => {
|
|
68
|
-
const {
|
|
69
|
-
elementRef
|
|
70
|
-
} = this.props;
|
|
71
|
-
this.ref = el;
|
|
72
|
-
if (typeof elementRef === 'function') {
|
|
73
|
-
elementRef(el);
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
render() {
|
|
77
|
-
const {
|
|
78
|
-
as,
|
|
79
|
-
background,
|
|
80
|
-
children,
|
|
81
|
-
debug,
|
|
82
|
-
height,
|
|
83
|
-
width,
|
|
84
|
-
maxHeight,
|
|
85
|
-
maxWidth,
|
|
86
|
-
minHeight,
|
|
87
|
-
minWidth,
|
|
88
|
-
margin,
|
|
89
|
-
padding,
|
|
90
|
-
shadow,
|
|
91
|
-
stacking,
|
|
92
|
-
style,
|
|
93
|
-
textAlign,
|
|
94
|
-
styles,
|
|
95
|
-
borderColor
|
|
96
|
-
} = this.props;
|
|
97
|
-
return (0, _jsxRuntime.jsx)(_v.View, {
|
|
98
|
-
...(0, _omitProps.omitProps)(this.props, ContextView.allowedProps),
|
|
99
|
-
css: styles?.contextView,
|
|
100
|
-
style: style,
|
|
101
|
-
borderWidth: "none",
|
|
102
|
-
display: "inline-block",
|
|
103
|
-
as: as,
|
|
104
|
-
withVisualDebug: debug,
|
|
105
|
-
elementRef: this.handleRef,
|
|
106
|
-
margin: margin,
|
|
107
|
-
stacking: stacking,
|
|
108
|
-
children: (0, _jsxRuntime.jsxs)(_v.View, {
|
|
109
|
-
css: styles?.contextView__content,
|
|
110
|
-
display: "block",
|
|
111
|
-
borderRadius: styles?.borderRadius,
|
|
112
|
-
borderWidth: "small",
|
|
113
|
-
borderColor: borderColor || (background === 'default' ? 'primary' : 'transparent'),
|
|
114
|
-
background: background === 'default' ? 'primary' : 'primary-inverse',
|
|
115
|
-
withVisualDebug: debug,
|
|
116
|
-
height: height,
|
|
117
|
-
width: width,
|
|
118
|
-
maxHeight: maxHeight,
|
|
119
|
-
maxWidth: maxWidth,
|
|
120
|
-
minHeight: minHeight,
|
|
121
|
-
minWidth: minWidth,
|
|
122
|
-
padding: padding,
|
|
123
|
-
shadow: shadow,
|
|
124
|
-
textAlign: textAlign,
|
|
125
|
-
children: [(0, _jsxRuntime.jsx)("span", {
|
|
126
|
-
css: styles?.contextView__arrow
|
|
127
|
-
}), children]
|
|
128
|
-
})
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
}) || _class);
|
|
132
|
-
var _default = exports.default = ContextView;
|
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
require("core-js/modules/es.array.includes.js");
|
|
8
|
-
var _mirrorPlacement = require("@instructure/ui-position/lib/mirrorPlacement.js");
|
|
9
|
-
/*
|
|
10
|
-
* The MIT License (MIT)
|
|
11
|
-
*
|
|
12
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
13
|
-
*
|
|
14
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
16
|
-
* in the Software without restriction, including without limitation the rights
|
|
17
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
19
|
-
* furnished to do so, subject to the following conditions:
|
|
20
|
-
*
|
|
21
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
22
|
-
* copies or substantial portions of the Software.
|
|
23
|
-
*
|
|
24
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
30
|
-
* SOFTWARE.
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
const endPlacements = ['end center', 'end top', 'end bottom', 'end stretch', 'center end', 'end'];
|
|
34
|
-
const startPlacements = ['start center', 'start top', 'start bottom', 'start stretch', 'center start', 'start'];
|
|
35
|
-
const bottomPlacements = ['bottom', 'bottom end', 'bottom start', 'bottom stretch', 'bottom center'];
|
|
36
|
-
const topPlacements = ['top', 'top start', 'top end', 'top stretch', 'top center'];
|
|
37
|
-
const getPlacementStyle = (placement, theme) => {
|
|
38
|
-
if (endPlacements.includes(placement)) {
|
|
39
|
-
return {
|
|
40
|
-
paddingInlineStart: theme?.arrowSize,
|
|
41
|
-
paddingInlineEnd: '0'
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
if (startPlacements.includes(placement)) {
|
|
45
|
-
return {
|
|
46
|
-
paddingInlineEnd: theme?.arrowSize,
|
|
47
|
-
paddingInlineStart: '0'
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
if (bottomPlacements.includes(placement)) {
|
|
51
|
-
return {
|
|
52
|
-
paddingTop: theme?.arrowSize
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
if (topPlacements.includes(placement)) {
|
|
56
|
-
return {
|
|
57
|
-
paddingBottom: theme?.arrowSize
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
return {
|
|
61
|
-
position: 'absolute',
|
|
62
|
-
left: '-999em'
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
const getArrowCorrections = (placement, theme) => {
|
|
66
|
-
const center = ['top', 'bottom', 'top center', 'bottom center', 'top stretch', 'bottom stretch'];
|
|
67
|
-
const start = ['top start', 'bottom start'];
|
|
68
|
-
const end = ['top end', 'bottom end'];
|
|
69
|
-
const top = ['start top', 'end top'];
|
|
70
|
-
const bottom = ['start bottom', 'end bottom'];
|
|
71
|
-
if (center.includes(placement)) {
|
|
72
|
-
return {
|
|
73
|
-
insetInlineStart: '50%'
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
if (start.includes(placement)) {
|
|
77
|
-
return {
|
|
78
|
-
insetInlineStart: `calc((${theme?.arrowSize} + ${theme?.arrowBorderWidth}) * 2)`,
|
|
79
|
-
insetInlineEnd: 'auto'
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
if (end.includes(placement)) {
|
|
83
|
-
return {
|
|
84
|
-
insetInlineStart: `calc(100% - (${theme?.arrowSize} + ${theme?.arrowBorderWidth}) * 2)`,
|
|
85
|
-
insetInlineEnd: 'auto'
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
if (top.includes(placement)) {
|
|
89
|
-
return {
|
|
90
|
-
top: `calc((${theme?.arrowSize} + ${theme?.arrowBorderWidth}) * 2)`
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
if (bottom.includes(placement)) {
|
|
94
|
-
return {
|
|
95
|
-
top: `calc(100% - (${theme?.arrowSize} + ${theme?.arrowBorderWidth}) * 2)`
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
return {};
|
|
99
|
-
};
|
|
100
|
-
const getArrowPlacementVariant = (placement, background, theme, props) => {
|
|
101
|
-
const transformedPlacement = (0, _mirrorPlacement.mirrorPlacement)(placement, ' ');
|
|
102
|
-
const isInversed = background === 'inverse';
|
|
103
|
-
const {
|
|
104
|
-
borderColor
|
|
105
|
-
} = props;
|
|
106
|
-
if (endPlacements.includes(transformedPlacement)) {
|
|
107
|
-
return {
|
|
108
|
-
main: {
|
|
109
|
-
top: '50%',
|
|
110
|
-
insetInlineStart: '100%',
|
|
111
|
-
insetInlineEnd: 'auto',
|
|
112
|
-
marginTop: `calc(-1 * (${theme?.arrowSize} + ${theme?.arrowBorderWidth}))`,
|
|
113
|
-
borderInlineEndWidth: '0',
|
|
114
|
-
borderInlineEndColor: 'transparent',
|
|
115
|
-
borderInlineStartColor: borderColor || (isInversed ? theme?.arrowBorderColorInverse : theme?.arrowBorderColor),
|
|
116
|
-
borderTopColor: 'transparent',
|
|
117
|
-
borderBottomColor: 'transparent',
|
|
118
|
-
borderInlineStartWidth: theme?.arrowSize
|
|
119
|
-
},
|
|
120
|
-
__after: {
|
|
121
|
-
insetInlineEnd: theme?.arrowBorderWidth,
|
|
122
|
-
insetInlineStart: 'auto',
|
|
123
|
-
marginTop: `calc(-1 * ${theme?.arrowSize})`,
|
|
124
|
-
borderInlineEndWidth: '0',
|
|
125
|
-
borderInlineEndColor: 'transparent',
|
|
126
|
-
borderTopColor: 'transparent',
|
|
127
|
-
borderBottomColor: 'transparent',
|
|
128
|
-
borderInlineStartWidth: theme?.arrowSize,
|
|
129
|
-
borderInlineStartColor: isInversed ? theme?.arrowBackgroundColorInverse : theme?.arrowBackgroundColor
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
if (startPlacements.includes(transformedPlacement)) {
|
|
134
|
-
return {
|
|
135
|
-
main: {
|
|
136
|
-
top: '50%',
|
|
137
|
-
insetInlineEnd: '100%',
|
|
138
|
-
insetInlineStart: 'auto',
|
|
139
|
-
marginTop: `calc(-1 * (${theme?.arrowSize} + ${theme?.arrowBorderWidth}))`,
|
|
140
|
-
borderInlineStartWidth: '0',
|
|
141
|
-
borderInlineStartColor: 'transparent',
|
|
142
|
-
borderInlineEndColor: borderColor || (isInversed ? theme?.arrowBorderColorInverse : theme?.arrowBorderColor),
|
|
143
|
-
borderTopColor: 'transparent',
|
|
144
|
-
borderBottomColor: 'transparent',
|
|
145
|
-
borderInlineEndWidth: theme?.arrowSize
|
|
146
|
-
},
|
|
147
|
-
__after: {
|
|
148
|
-
insetInlineStart: theme?.arrowBorderWidth,
|
|
149
|
-
insetInlineEnd: 'auto',
|
|
150
|
-
marginTop: `calc(-1 * ${theme?.arrowSize})`,
|
|
151
|
-
borderInlineStartWidth: '0',
|
|
152
|
-
borderInlineStartColor: 'transparent',
|
|
153
|
-
borderTopColor: 'transparent',
|
|
154
|
-
borderBottomColor: 'transparent',
|
|
155
|
-
borderInlineEndWidth: theme?.arrowSize,
|
|
156
|
-
borderInlineEndColor: isInversed ? theme?.arrowBackgroundColorInverse : theme?.arrowBackgroundColor
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
if (bottomPlacements.includes(transformedPlacement)) {
|
|
161
|
-
return {
|
|
162
|
-
main: {
|
|
163
|
-
top: '100%',
|
|
164
|
-
marginInlineStart: `calc(-1 * (${theme?.arrowSize} + ${theme?.arrowBorderWidth}))`,
|
|
165
|
-
marginInlineEnd: '0',
|
|
166
|
-
borderBottomWidth: '0',
|
|
167
|
-
borderBottomColor: 'transparent',
|
|
168
|
-
borderInlineStartColor: 'transparent',
|
|
169
|
-
borderInlineEndColor: 'transparent'
|
|
170
|
-
},
|
|
171
|
-
__after: {
|
|
172
|
-
bottom: theme?.arrowBorderWidth,
|
|
173
|
-
marginInlineStart: `calc(-1 * ${theme?.arrowSize})`,
|
|
174
|
-
marginInlineEnd: '0',
|
|
175
|
-
borderBottomWidth: '0',
|
|
176
|
-
borderBottomColor: 'transparent',
|
|
177
|
-
borderInlineStartColor: 'transparent',
|
|
178
|
-
borderInlineEndColor: 'transparent',
|
|
179
|
-
borderTopColor: isInversed ? theme?.arrowBackgroundColorInverse : theme?.arrowBackgroundColor
|
|
180
|
-
}
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
return {
|
|
184
|
-
main: {
|
|
185
|
-
bottom: '100%',
|
|
186
|
-
marginInlineStart: `calc(-1 * (${theme?.arrowSize} + ${theme?.arrowBorderWidth}))`,
|
|
187
|
-
marginInlineEnd: '0',
|
|
188
|
-
borderTopWidth: '0',
|
|
189
|
-
borderTopColor: 'transparent',
|
|
190
|
-
borderInlineStartColor: 'transparent',
|
|
191
|
-
borderInlineEndColor: 'transparent'
|
|
192
|
-
},
|
|
193
|
-
__after: {
|
|
194
|
-
top: theme?.arrowBorderWidth,
|
|
195
|
-
marginInlineStart: `calc(-1 * ${theme?.arrowSize})`,
|
|
196
|
-
marginInlineEnd: '0',
|
|
197
|
-
borderTopWidth: '0',
|
|
198
|
-
borderTopColor: 'transparent',
|
|
199
|
-
borderInlineStartColor: 'transparent',
|
|
200
|
-
borderInlineEndColor: 'transparent',
|
|
201
|
-
borderBottomColor: isInversed ? theme?.arrowBackgroundColorInverse : theme?.arrowBackgroundColor
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* ---
|
|
208
|
-
* private: true
|
|
209
|
-
* ---
|
|
210
|
-
* Generates the style object from the theme and provided additional information
|
|
211
|
-
* @param {Object} componentTheme The theme variable object.
|
|
212
|
-
* @param {Object} props the props of the component, the style is applied to
|
|
213
|
-
* @return {Object} The final style object, which will be used in the component
|
|
214
|
-
*/
|
|
215
|
-
const generateStyle = (componentTheme, props) => {
|
|
216
|
-
const {
|
|
217
|
-
placement,
|
|
218
|
-
background,
|
|
219
|
-
borderColor
|
|
220
|
-
} = props;
|
|
221
|
-
const arrowBaseStyles = {
|
|
222
|
-
content: '""',
|
|
223
|
-
height: '0',
|
|
224
|
-
width: '0',
|
|
225
|
-
position: 'absolute',
|
|
226
|
-
display: 'block',
|
|
227
|
-
boxSizing: 'border-box',
|
|
228
|
-
pointerEvents: 'none',
|
|
229
|
-
borderStyle: 'solid'
|
|
230
|
-
};
|
|
231
|
-
const arrowBackGroundVariants = {
|
|
232
|
-
default: componentTheme?.arrowBorderColor,
|
|
233
|
-
inverse: componentTheme?.arrowBorderColorInverse
|
|
234
|
-
};
|
|
235
|
-
const arrowPlacementVariant = getArrowPlacementVariant(placement, background, componentTheme, props);
|
|
236
|
-
return {
|
|
237
|
-
borderRadius: componentTheme?.borderRadius,
|
|
238
|
-
contextView: {
|
|
239
|
-
label: 'contextView',
|
|
240
|
-
boxSizing: 'border-box',
|
|
241
|
-
minHeight: `calc(${componentTheme?.arrowSize} * 2)`,
|
|
242
|
-
...getPlacementStyle(placement, componentTheme)
|
|
243
|
-
},
|
|
244
|
-
contextView__content: {
|
|
245
|
-
label: 'contextView__content',
|
|
246
|
-
position: 'relative'
|
|
247
|
-
},
|
|
248
|
-
contextView__arrow: {
|
|
249
|
-
label: 'contextView__arrow',
|
|
250
|
-
...arrowBaseStyles,
|
|
251
|
-
display: 'block',
|
|
252
|
-
borderWidth: `calc(${componentTheme?.arrowSize} + ${componentTheme?.arrowBorderWidth})`,
|
|
253
|
-
borderColor: borderColor || arrowBackGroundVariants[background],
|
|
254
|
-
...arrowPlacementVariant.main,
|
|
255
|
-
...getArrowCorrections(placement, componentTheme),
|
|
256
|
-
'&::after': {
|
|
257
|
-
borderWidth: componentTheme?.arrowSize,
|
|
258
|
-
borderColor: arrowBackGroundVariants[background],
|
|
259
|
-
...arrowPlacementVariant.__after,
|
|
260
|
-
...arrowBaseStyles
|
|
261
|
-
}
|
|
262
|
-
},
|
|
263
|
-
arrowSize: componentTheme.arrowSize,
|
|
264
|
-
arrowBorderWidth: componentTheme.arrowBorderWidth
|
|
265
|
-
};
|
|
266
|
-
};
|
|
267
|
-
var _default = exports.default = generateStyle;
|
package/lib/View/v1/index.js
DELETED
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = exports.View = void 0;
|
|
8
|
-
var _react = require("react");
|
|
9
|
-
var _getCSSStyleDeclaration = require("@instructure/ui-dom-utils/lib/getCSSStyleDeclaration.js");
|
|
10
|
-
var _textDirectionContextConsumer = require("@instructure/ui-i18n/lib/textDirectionContextConsumer.js");
|
|
11
|
-
var _console = require("@instructure/console");
|
|
12
|
-
var _getElementType = require("@instructure/ui-react-utils/lib/getElementType.js");
|
|
13
|
-
var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
|
|
14
|
-
var _pickProps = require("@instructure/ui-react-utils/lib/pickProps.js");
|
|
15
|
-
var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProps.js");
|
|
16
|
-
var _emotion = require("@instructure/emotion");
|
|
17
|
-
var _styles = _interopRequireDefault(require("./styles"));
|
|
18
|
-
var _theme = _interopRequireDefault(require("./theme"));
|
|
19
|
-
var _props = require("./props");
|
|
20
|
-
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
21
|
-
var _dec, _dec2, _class;
|
|
22
|
-
/*
|
|
23
|
-
* The MIT License (MIT)
|
|
24
|
-
*
|
|
25
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
26
|
-
*
|
|
27
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
28
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
29
|
-
* in the Software without restriction, including without limitation the rights
|
|
30
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
31
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
32
|
-
* furnished to do so, subject to the following conditions:
|
|
33
|
-
*
|
|
34
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
35
|
-
* copies or substantial portions of the Software.
|
|
36
|
-
*
|
|
37
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
38
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
39
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
40
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
41
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
42
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
43
|
-
* SOFTWARE.
|
|
44
|
-
*/
|
|
45
|
-
/**
|
|
46
|
-
---
|
|
47
|
-
category: components
|
|
48
|
-
---
|
|
49
|
-
@module View
|
|
50
|
-
**/
|
|
51
|
-
let View = exports.View = (_dec = (0, _textDirectionContextConsumer.textDirectionContextConsumer)(), _dec2 = (0, _emotion.withStyle)(_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 `@withStyleNew` 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;
|
|
94
|
-
get _element() {
|
|
95
|
-
return this.ref;
|
|
96
|
-
}
|
|
97
|
-
constructor(props) {
|
|
98
|
-
super(props);
|
|
99
|
-
this.spanMarginVerified = false;
|
|
100
|
-
}
|
|
101
|
-
componentDidMount() {
|
|
102
|
-
this.props.makeStyles?.();
|
|
103
|
-
}
|
|
104
|
-
componentDidUpdate() {
|
|
105
|
-
this.props.makeStyles?.();
|
|
106
|
-
|
|
107
|
-
// Not calling getCSSStyleDeclaration can save hundreds of ms in tests and production
|
|
108
|
-
if (typeof process !== 'undefined' && process?.env?.NODE_ENV === 'development' && !this.spanMarginVerified) {
|
|
109
|
-
// We have to verify margins in the first 'componentDidUpdate',
|
|
110
|
-
// because that is when all styles are calculated,
|
|
111
|
-
// but we only want to check once, using a flag
|
|
112
|
-
this.spanMarginVerified = true;
|
|
113
|
-
(0, _console.logError)(!function verifySpanMargin(element, margin) {
|
|
114
|
-
if (!element) {
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
const display = (0, _getCSSStyleDeclaration.getCSSStyleDeclaration)(element)?.display;
|
|
118
|
-
if (display !== 'inline') {
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
const marginValues = margin ? margin.split(' ') : null;
|
|
122
|
-
let verticalMargin = false;
|
|
123
|
-
|
|
124
|
-
// either top or bottom margin are set
|
|
125
|
-
if (margin) {
|
|
126
|
-
if (marginValues && marginValues[0] && marginValues[0] !== 'none' && marginValues[0] !== '0') {
|
|
127
|
-
verticalMargin = true;
|
|
128
|
-
}
|
|
129
|
-
if (marginValues && marginValues[2] && marginValues[2] !== 'none' && marginValues[2] !== '0') {
|
|
130
|
-
verticalMargin = true;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
return verticalMargin;
|
|
134
|
-
}(this.ref, this.props.margin), `[View] display style is set to 'inline' and will allow for horizontal margins only.`);
|
|
135
|
-
}
|
|
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
|
-
};
|
|
144
|
-
render() {
|
|
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;
|
|
172
|
-
const ElementType = (0, _getElementType.getElementType)(View, this.props);
|
|
173
|
-
return (0, _jsxRuntime.jsx)(ElementType, {
|
|
174
|
-
...(0, _passthroughProps.passthroughProps)(props),
|
|
175
|
-
className: className,
|
|
176
|
-
css: [styles?.view, styles?.inlineStyles],
|
|
177
|
-
ref: this.handleElementRef,
|
|
178
|
-
children: children
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
}) || _class) || _class);
|
|
182
|
-
var _default = exports.default = View;
|
package/lib/View/v1/props.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.allowedProps = void 0;
|
|
7
|
-
/*
|
|
8
|
-
* The MIT License (MIT)
|
|
9
|
-
*
|
|
10
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
11
|
-
*
|
|
12
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
14
|
-
* in the Software without restriction, including without limitation the rights
|
|
15
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
17
|
-
* furnished to do so, subject to the following conditions:
|
|
18
|
-
*
|
|
19
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
20
|
-
* copies or substantial portions of the Software.
|
|
21
|
-
*
|
|
22
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
-
* SOFTWARE.
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
// This variable will be attached as static property on the `View` component
|
|
32
|
-
// so we don't rely on the `PropTypes` validators for our internal logic.
|
|
33
|
-
// This means on prod builds the consuming applications can safely delete propTypes.
|
|
34
|
-
const allowedProps = exports.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', 'overscrollBehavior', 'padding', 'position', 'shadow', 'shouldAnimateFocus', 'stacking', 'textAlign', 'width', 'withFocusOutline', 'withVisualDebug', 'focusRingBorderRadius', 'focusWithin'];
|