@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
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
require("core-js/modules/es.array.includes.js");
|
|
7
8
|
var _mirrorPlacement = require("@instructure/ui-position/lib/mirrorPlacement.js");
|
|
8
9
|
/*
|
|
9
10
|
* The MIT License (MIT)
|
|
@@ -36,24 +37,24 @@ const topPlacements = ['top', 'top start', 'top end', 'top stretch', 'top center
|
|
|
36
37
|
const getPlacementStyle = (placement, theme) => {
|
|
37
38
|
if (endPlacements.includes(placement)) {
|
|
38
39
|
return {
|
|
39
|
-
paddingInlineStart: theme
|
|
40
|
+
paddingInlineStart: theme?.arrowSize,
|
|
40
41
|
paddingInlineEnd: '0'
|
|
41
42
|
};
|
|
42
43
|
}
|
|
43
44
|
if (startPlacements.includes(placement)) {
|
|
44
45
|
return {
|
|
45
|
-
paddingInlineEnd: theme
|
|
46
|
+
paddingInlineEnd: theme?.arrowSize,
|
|
46
47
|
paddingInlineStart: '0'
|
|
47
48
|
};
|
|
48
49
|
}
|
|
49
50
|
if (bottomPlacements.includes(placement)) {
|
|
50
51
|
return {
|
|
51
|
-
paddingTop: theme
|
|
52
|
+
paddingTop: theme?.arrowSize
|
|
52
53
|
};
|
|
53
54
|
}
|
|
54
55
|
if (topPlacements.includes(placement)) {
|
|
55
56
|
return {
|
|
56
|
-
paddingBottom: theme
|
|
57
|
+
paddingBottom: theme?.arrowSize
|
|
57
58
|
};
|
|
58
59
|
}
|
|
59
60
|
return {
|
|
@@ -74,24 +75,24 @@ const getArrowCorrections = (placement, theme) => {
|
|
|
74
75
|
}
|
|
75
76
|
if (start.includes(placement)) {
|
|
76
77
|
return {
|
|
77
|
-
insetInlineStart: `calc((${theme
|
|
78
|
+
insetInlineStart: `calc((${theme?.arrowSize} + ${theme?.arrowBorderWidth}) * 2)`,
|
|
78
79
|
insetInlineEnd: 'auto'
|
|
79
80
|
};
|
|
80
81
|
}
|
|
81
82
|
if (end.includes(placement)) {
|
|
82
83
|
return {
|
|
83
|
-
insetInlineStart: `calc(100% - (${theme
|
|
84
|
+
insetInlineStart: `calc(100% - (${theme?.arrowSize} + ${theme?.arrowBorderWidth}) * 2)`,
|
|
84
85
|
insetInlineEnd: 'auto'
|
|
85
86
|
};
|
|
86
87
|
}
|
|
87
88
|
if (top.includes(placement)) {
|
|
88
89
|
return {
|
|
89
|
-
top: `calc((${theme
|
|
90
|
+
top: `calc((${theme?.arrowSize} + ${theme?.arrowBorderWidth}) * 2)`
|
|
90
91
|
};
|
|
91
92
|
}
|
|
92
93
|
if (bottom.includes(placement)) {
|
|
93
94
|
return {
|
|
94
|
-
top: `calc(100% - (${theme
|
|
95
|
+
top: `calc(100% - (${theme?.arrowSize} + ${theme?.arrowBorderWidth}) * 2)`
|
|
95
96
|
};
|
|
96
97
|
}
|
|
97
98
|
return {};
|
|
@@ -99,31 +100,33 @@ const getArrowCorrections = (placement, theme) => {
|
|
|
99
100
|
const getArrowPlacementVariant = (placement, background, theme, props) => {
|
|
100
101
|
const transformedPlacement = (0, _mirrorPlacement.mirrorPlacement)(placement, ' ');
|
|
101
102
|
const isInversed = background === 'inverse';
|
|
102
|
-
const
|
|
103
|
+
const {
|
|
104
|
+
borderColor
|
|
105
|
+
} = props;
|
|
103
106
|
if (endPlacements.includes(transformedPlacement)) {
|
|
104
107
|
return {
|
|
105
108
|
main: {
|
|
106
109
|
top: '50%',
|
|
107
110
|
insetInlineStart: '100%',
|
|
108
111
|
insetInlineEnd: 'auto',
|
|
109
|
-
marginTop: `calc(-1 * (${theme
|
|
112
|
+
marginTop: `calc(-1 * (${theme?.arrowSize} + ${theme?.arrowBorderWidth}))`,
|
|
110
113
|
borderInlineEndWidth: '0',
|
|
111
114
|
borderInlineEndColor: 'transparent',
|
|
112
|
-
borderInlineStartColor: borderColor || (isInversed ? theme
|
|
115
|
+
borderInlineStartColor: borderColor || (isInversed ? theme?.arrowBorderColorInverse : theme?.arrowBorderColor),
|
|
113
116
|
borderTopColor: 'transparent',
|
|
114
117
|
borderBottomColor: 'transparent',
|
|
115
|
-
borderInlineStartWidth: theme
|
|
118
|
+
borderInlineStartWidth: theme?.arrowSize
|
|
116
119
|
},
|
|
117
120
|
__after: {
|
|
118
|
-
insetInlineEnd: theme
|
|
121
|
+
insetInlineEnd: theme?.arrowBorderWidth,
|
|
119
122
|
insetInlineStart: 'auto',
|
|
120
|
-
marginTop: `calc(-1 * ${theme
|
|
123
|
+
marginTop: `calc(-1 * ${theme?.arrowSize})`,
|
|
121
124
|
borderInlineEndWidth: '0',
|
|
122
125
|
borderInlineEndColor: 'transparent',
|
|
123
126
|
borderTopColor: 'transparent',
|
|
124
127
|
borderBottomColor: 'transparent',
|
|
125
|
-
borderInlineStartWidth: theme
|
|
126
|
-
borderInlineStartColor: isInversed ? theme
|
|
128
|
+
borderInlineStartWidth: theme?.arrowSize,
|
|
129
|
+
borderInlineStartColor: isInversed ? theme?.arrowBackgroundColorInverse : theme?.arrowBackgroundColor
|
|
127
130
|
}
|
|
128
131
|
};
|
|
129
132
|
}
|
|
@@ -133,24 +136,24 @@ const getArrowPlacementVariant = (placement, background, theme, props) => {
|
|
|
133
136
|
top: '50%',
|
|
134
137
|
insetInlineEnd: '100%',
|
|
135
138
|
insetInlineStart: 'auto',
|
|
136
|
-
marginTop: `calc(-1 * (${theme
|
|
139
|
+
marginTop: `calc(-1 * (${theme?.arrowSize} + ${theme?.arrowBorderWidth}))`,
|
|
137
140
|
borderInlineStartWidth: '0',
|
|
138
141
|
borderInlineStartColor: 'transparent',
|
|
139
|
-
borderInlineEndColor: borderColor || (isInversed ? theme
|
|
142
|
+
borderInlineEndColor: borderColor || (isInversed ? theme?.arrowBorderColorInverse : theme?.arrowBorderColor),
|
|
140
143
|
borderTopColor: 'transparent',
|
|
141
144
|
borderBottomColor: 'transparent',
|
|
142
|
-
borderInlineEndWidth: theme
|
|
145
|
+
borderInlineEndWidth: theme?.arrowSize
|
|
143
146
|
},
|
|
144
147
|
__after: {
|
|
145
|
-
insetInlineStart: theme
|
|
148
|
+
insetInlineStart: theme?.arrowBorderWidth,
|
|
146
149
|
insetInlineEnd: 'auto',
|
|
147
|
-
marginTop: `calc(-1 * ${theme
|
|
150
|
+
marginTop: `calc(-1 * ${theme?.arrowSize})`,
|
|
148
151
|
borderInlineStartWidth: '0',
|
|
149
152
|
borderInlineStartColor: 'transparent',
|
|
150
153
|
borderTopColor: 'transparent',
|
|
151
154
|
borderBottomColor: 'transparent',
|
|
152
|
-
borderInlineEndWidth: theme
|
|
153
|
-
borderInlineEndColor: isInversed ? theme
|
|
155
|
+
borderInlineEndWidth: theme?.arrowSize,
|
|
156
|
+
borderInlineEndColor: isInversed ? theme?.arrowBackgroundColorInverse : theme?.arrowBackgroundColor
|
|
154
157
|
}
|
|
155
158
|
};
|
|
156
159
|
}
|
|
@@ -158,7 +161,7 @@ const getArrowPlacementVariant = (placement, background, theme, props) => {
|
|
|
158
161
|
return {
|
|
159
162
|
main: {
|
|
160
163
|
top: '100%',
|
|
161
|
-
marginInlineStart: `calc(-1 * (${theme
|
|
164
|
+
marginInlineStart: `calc(-1 * (${theme?.arrowSize} + ${theme?.arrowBorderWidth}))`,
|
|
162
165
|
marginInlineEnd: '0',
|
|
163
166
|
borderBottomWidth: '0',
|
|
164
167
|
borderBottomColor: 'transparent',
|
|
@@ -166,21 +169,21 @@ const getArrowPlacementVariant = (placement, background, theme, props) => {
|
|
|
166
169
|
borderInlineEndColor: 'transparent'
|
|
167
170
|
},
|
|
168
171
|
__after: {
|
|
169
|
-
bottom: theme
|
|
170
|
-
marginInlineStart: `calc(-1 * ${theme
|
|
172
|
+
bottom: theme?.arrowBorderWidth,
|
|
173
|
+
marginInlineStart: `calc(-1 * ${theme?.arrowSize})`,
|
|
171
174
|
marginInlineEnd: '0',
|
|
172
175
|
borderBottomWidth: '0',
|
|
173
176
|
borderBottomColor: 'transparent',
|
|
174
177
|
borderInlineStartColor: 'transparent',
|
|
175
178
|
borderInlineEndColor: 'transparent',
|
|
176
|
-
borderTopColor: isInversed ? theme
|
|
179
|
+
borderTopColor: isInversed ? theme?.arrowBackgroundColorInverse : theme?.arrowBackgroundColor
|
|
177
180
|
}
|
|
178
181
|
};
|
|
179
182
|
}
|
|
180
183
|
return {
|
|
181
184
|
main: {
|
|
182
185
|
bottom: '100%',
|
|
183
|
-
marginInlineStart: `calc(-1 * (${theme
|
|
186
|
+
marginInlineStart: `calc(-1 * (${theme?.arrowSize} + ${theme?.arrowBorderWidth}))`,
|
|
184
187
|
marginInlineEnd: '0',
|
|
185
188
|
borderTopWidth: '0',
|
|
186
189
|
borderTopColor: 'transparent',
|
|
@@ -188,14 +191,14 @@ const getArrowPlacementVariant = (placement, background, theme, props) => {
|
|
|
188
191
|
borderInlineEndColor: 'transparent'
|
|
189
192
|
},
|
|
190
193
|
__after: {
|
|
191
|
-
top: theme
|
|
192
|
-
marginInlineStart: `calc(-1 * ${theme
|
|
194
|
+
top: theme?.arrowBorderWidth,
|
|
195
|
+
marginInlineStart: `calc(-1 * ${theme?.arrowSize})`,
|
|
193
196
|
marginInlineEnd: '0',
|
|
194
197
|
borderTopWidth: '0',
|
|
195
198
|
borderTopColor: 'transparent',
|
|
196
199
|
borderInlineStartColor: 'transparent',
|
|
197
200
|
borderInlineEndColor: 'transparent',
|
|
198
|
-
borderBottomColor: isInversed ? theme
|
|
201
|
+
borderBottomColor: isInversed ? theme?.arrowBackgroundColorInverse : theme?.arrowBackgroundColor
|
|
199
202
|
}
|
|
200
203
|
};
|
|
201
204
|
};
|
|
@@ -211,9 +214,11 @@ const getArrowPlacementVariant = (placement, background, theme, props) => {
|
|
|
211
214
|
* @return {Object} The final style object, which will be used in the component
|
|
212
215
|
*/
|
|
213
216
|
const generateStyle = (componentTheme, props) => {
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
|
|
217
|
+
const {
|
|
218
|
+
placement,
|
|
219
|
+
background,
|
|
220
|
+
borderColor
|
|
221
|
+
} = props;
|
|
217
222
|
const arrowBaseStyles = {
|
|
218
223
|
content: '""',
|
|
219
224
|
height: '0',
|
|
@@ -225,15 +230,15 @@ const generateStyle = (componentTheme, props) => {
|
|
|
225
230
|
borderStyle: 'solid'
|
|
226
231
|
};
|
|
227
232
|
const arrowBackGroundVariants = {
|
|
228
|
-
default: componentTheme
|
|
229
|
-
inverse: componentTheme
|
|
233
|
+
default: componentTheme?.arrowBorderColor,
|
|
234
|
+
inverse: componentTheme?.arrowBorderColorInverse
|
|
230
235
|
};
|
|
231
236
|
const arrowPlacementVariant = getArrowPlacementVariant(placement, background, componentTheme, props);
|
|
232
237
|
return {
|
|
233
238
|
contextView: {
|
|
234
239
|
label: 'contextView',
|
|
235
240
|
boxSizing: 'border-box',
|
|
236
|
-
minHeight: `calc(${componentTheme
|
|
241
|
+
minHeight: `calc(${componentTheme?.arrowSize} * 2)`,
|
|
237
242
|
...getPlacementStyle(placement, componentTheme)
|
|
238
243
|
},
|
|
239
244
|
contextView__content: {
|
|
@@ -244,12 +249,12 @@ const generateStyle = (componentTheme, props) => {
|
|
|
244
249
|
label: 'contextView__arrow',
|
|
245
250
|
...arrowBaseStyles,
|
|
246
251
|
display: 'block',
|
|
247
|
-
borderWidth: `calc(${componentTheme
|
|
252
|
+
borderWidth: `calc(${componentTheme?.arrowSize} + ${componentTheme?.arrowBorderWidth})`,
|
|
248
253
|
borderColor: borderColor || arrowBackGroundVariants[background],
|
|
249
254
|
...arrowPlacementVariant.main,
|
|
250
255
|
...getArrowCorrections(placement, componentTheme),
|
|
251
256
|
'&::after': {
|
|
252
|
-
borderWidth: componentTheme
|
|
257
|
+
borderWidth: componentTheme?.arrowSize,
|
|
253
258
|
borderColor: arrowBackGroundVariants[background],
|
|
254
259
|
...arrowPlacementVariant.__after,
|
|
255
260
|
...arrowBaseStyles
|
|
@@ -34,13 +34,12 @@ exports.default = void 0;
|
|
|
34
34
|
* @return {Object} The final theme object with the overrides and component variables
|
|
35
35
|
*/
|
|
36
36
|
const generateComponentTheme = theme => {
|
|
37
|
-
var _theme$borders, _theme$colors, _theme$colors$contras, _theme$colors2, _theme$colors2$contra, _theme$colors3, _theme$colors3$contra;
|
|
38
37
|
const componentVariables = {
|
|
39
38
|
arrowSize: '0.5rem',
|
|
40
|
-
arrowBorderWidth: theme
|
|
41
|
-
arrowBackgroundColor: theme
|
|
42
|
-
arrowBorderColor: theme
|
|
43
|
-
arrowBackgroundColorInverse: theme
|
|
39
|
+
arrowBorderWidth: theme?.borders?.widthSmall,
|
|
40
|
+
arrowBackgroundColor: theme?.colors?.contrasts?.white1010,
|
|
41
|
+
arrowBorderColor: theme?.colors?.contrasts?.grey1424,
|
|
42
|
+
arrowBackgroundColorInverse: theme?.colors?.contrasts?.grey125125,
|
|
44
43
|
arrowBorderColorInverse: 'transparent'
|
|
45
44
|
};
|
|
46
45
|
return {
|
|
@@ -12,7 +12,7 @@ var _v = require("../../View/v2");
|
|
|
12
12
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
13
13
|
var _props = require("./props");
|
|
14
14
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
15
|
-
var _dec, _class
|
|
15
|
+
var _dec, _class;
|
|
16
16
|
/*
|
|
17
17
|
* The MIT License (MIT)
|
|
18
18
|
*
|
|
@@ -41,49 +41,62 @@ var _dec, _class, _ContextView;
|
|
|
41
41
|
category: components
|
|
42
42
|
---
|
|
43
43
|
**/
|
|
44
|
-
let ContextView = exports.ContextView = (_dec = (0, _emotion.withStyle)(_styles.default), _dec(_class =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
44
|
+
let ContextView = exports.ContextView = (_dec = (0, _emotion.withStyle)(_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
|
+
};
|
|
56
60
|
componentDidMount() {
|
|
57
|
-
|
|
58
|
-
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
61
|
+
this.props.makeStyles?.();
|
|
59
62
|
}
|
|
60
63
|
componentDidUpdate() {
|
|
61
|
-
|
|
62
|
-
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
64
|
+
this.props.makeStyles?.();
|
|
63
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
|
+
};
|
|
64
76
|
render() {
|
|
65
|
-
const
|
|
66
|
-
as
|
|
67
|
-
background
|
|
68
|
-
children
|
|
69
|
-
debug
|
|
70
|
-
height
|
|
71
|
-
width
|
|
72
|
-
maxHeight
|
|
73
|
-
maxWidth
|
|
74
|
-
minHeight
|
|
75
|
-
minWidth
|
|
76
|
-
margin
|
|
77
|
-
padding
|
|
78
|
-
shadow
|
|
79
|
-
stacking
|
|
80
|
-
style
|
|
81
|
-
textAlign
|
|
82
|
-
styles
|
|
83
|
-
borderColor
|
|
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;
|
|
84
97
|
return (0, _jsxRuntime.jsx)(_v.View, {
|
|
85
98
|
...(0, _omitProps.omitProps)(this.props, ContextView.allowedProps),
|
|
86
|
-
css: styles
|
|
99
|
+
css: styles?.contextView,
|
|
87
100
|
style: style,
|
|
88
101
|
borderWidth: "none",
|
|
89
102
|
display: "inline-block",
|
|
@@ -93,9 +106,9 @@ let ContextView = exports.ContextView = (_dec = (0, _emotion.withStyle)(_styles.
|
|
|
93
106
|
margin: margin,
|
|
94
107
|
stacking: stacking,
|
|
95
108
|
children: (0, _jsxRuntime.jsxs)(_v.View, {
|
|
96
|
-
css: styles
|
|
109
|
+
css: styles?.contextView__content,
|
|
97
110
|
display: "block",
|
|
98
|
-
borderRadius: styles
|
|
111
|
+
borderRadius: styles?.borderRadius,
|
|
99
112
|
borderWidth: "small",
|
|
100
113
|
borderColor: borderColor || (background === 'default' ? 'primary' : 'transparent'),
|
|
101
114
|
background: background === 'default' ? 'primary' : 'primary-inverse',
|
|
@@ -110,21 +123,10 @@ let ContextView = exports.ContextView = (_dec = (0, _emotion.withStyle)(_styles.
|
|
|
110
123
|
shadow: shadow,
|
|
111
124
|
textAlign: textAlign,
|
|
112
125
|
children: [(0, _jsxRuntime.jsx)("span", {
|
|
113
|
-
css: styles
|
|
126
|
+
css: styles?.contextView__arrow
|
|
114
127
|
}), children]
|
|
115
128
|
})
|
|
116
129
|
});
|
|
117
130
|
}
|
|
118
|
-
}
|
|
119
|
-
as: 'span',
|
|
120
|
-
elementRef: () => {},
|
|
121
|
-
debug: false,
|
|
122
|
-
width: 'auto',
|
|
123
|
-
height: 'auto',
|
|
124
|
-
children: null,
|
|
125
|
-
textAlign: 'start',
|
|
126
|
-
background: 'default',
|
|
127
|
-
shadow: 'above',
|
|
128
|
-
placement: 'center end'
|
|
129
|
-
}, _ContextView)) || _class);
|
|
131
|
+
}) || _class);
|
|
130
132
|
var _default = exports.default = ContextView;
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
require("core-js/modules/es.array.includes.js");
|
|
7
8
|
var _mirrorPlacement = require("@instructure/ui-position/lib/mirrorPlacement.js");
|
|
8
9
|
/*
|
|
9
10
|
* The MIT License (MIT)
|
|
@@ -36,24 +37,24 @@ const topPlacements = ['top', 'top start', 'top end', 'top stretch', 'top center
|
|
|
36
37
|
const getPlacementStyle = (placement, theme) => {
|
|
37
38
|
if (endPlacements.includes(placement)) {
|
|
38
39
|
return {
|
|
39
|
-
paddingInlineStart: theme
|
|
40
|
+
paddingInlineStart: theme?.arrowSize,
|
|
40
41
|
paddingInlineEnd: '0'
|
|
41
42
|
};
|
|
42
43
|
}
|
|
43
44
|
if (startPlacements.includes(placement)) {
|
|
44
45
|
return {
|
|
45
|
-
paddingInlineEnd: theme
|
|
46
|
+
paddingInlineEnd: theme?.arrowSize,
|
|
46
47
|
paddingInlineStart: '0'
|
|
47
48
|
};
|
|
48
49
|
}
|
|
49
50
|
if (bottomPlacements.includes(placement)) {
|
|
50
51
|
return {
|
|
51
|
-
paddingTop: theme
|
|
52
|
+
paddingTop: theme?.arrowSize
|
|
52
53
|
};
|
|
53
54
|
}
|
|
54
55
|
if (topPlacements.includes(placement)) {
|
|
55
56
|
return {
|
|
56
|
-
paddingBottom: theme
|
|
57
|
+
paddingBottom: theme?.arrowSize
|
|
57
58
|
};
|
|
58
59
|
}
|
|
59
60
|
return {
|
|
@@ -74,24 +75,24 @@ const getArrowCorrections = (placement, theme) => {
|
|
|
74
75
|
}
|
|
75
76
|
if (start.includes(placement)) {
|
|
76
77
|
return {
|
|
77
|
-
insetInlineStart: `calc((${theme
|
|
78
|
+
insetInlineStart: `calc((${theme?.arrowSize} + ${theme?.arrowBorderWidth}) * 2)`,
|
|
78
79
|
insetInlineEnd: 'auto'
|
|
79
80
|
};
|
|
80
81
|
}
|
|
81
82
|
if (end.includes(placement)) {
|
|
82
83
|
return {
|
|
83
|
-
insetInlineStart: `calc(100% - (${theme
|
|
84
|
+
insetInlineStart: `calc(100% - (${theme?.arrowSize} + ${theme?.arrowBorderWidth}) * 2)`,
|
|
84
85
|
insetInlineEnd: 'auto'
|
|
85
86
|
};
|
|
86
87
|
}
|
|
87
88
|
if (top.includes(placement)) {
|
|
88
89
|
return {
|
|
89
|
-
top: `calc((${theme
|
|
90
|
+
top: `calc((${theme?.arrowSize} + ${theme?.arrowBorderWidth}) * 2)`
|
|
90
91
|
};
|
|
91
92
|
}
|
|
92
93
|
if (bottom.includes(placement)) {
|
|
93
94
|
return {
|
|
94
|
-
top: `calc(100% - (${theme
|
|
95
|
+
top: `calc(100% - (${theme?.arrowSize} + ${theme?.arrowBorderWidth}) * 2)`
|
|
95
96
|
};
|
|
96
97
|
}
|
|
97
98
|
return {};
|
|
@@ -99,31 +100,33 @@ const getArrowCorrections = (placement, theme) => {
|
|
|
99
100
|
const getArrowPlacementVariant = (placement, background, theme, props) => {
|
|
100
101
|
const transformedPlacement = (0, _mirrorPlacement.mirrorPlacement)(placement, ' ');
|
|
101
102
|
const isInversed = background === 'inverse';
|
|
102
|
-
const
|
|
103
|
+
const {
|
|
104
|
+
borderColor
|
|
105
|
+
} = props;
|
|
103
106
|
if (endPlacements.includes(transformedPlacement)) {
|
|
104
107
|
return {
|
|
105
108
|
main: {
|
|
106
109
|
top: '50%',
|
|
107
110
|
insetInlineStart: '100%',
|
|
108
111
|
insetInlineEnd: 'auto',
|
|
109
|
-
marginTop: `calc(-1 * (${theme
|
|
112
|
+
marginTop: `calc(-1 * (${theme?.arrowSize} + ${theme?.arrowBorderWidth}))`,
|
|
110
113
|
borderInlineEndWidth: '0',
|
|
111
114
|
borderInlineEndColor: 'transparent',
|
|
112
|
-
borderInlineStartColor: borderColor || (isInversed ? theme
|
|
115
|
+
borderInlineStartColor: borderColor || (isInversed ? theme?.arrowBorderColorInverse : theme?.arrowBorderColor),
|
|
113
116
|
borderTopColor: 'transparent',
|
|
114
117
|
borderBottomColor: 'transparent',
|
|
115
|
-
borderInlineStartWidth: theme
|
|
118
|
+
borderInlineStartWidth: theme?.arrowSize
|
|
116
119
|
},
|
|
117
120
|
__after: {
|
|
118
|
-
insetInlineEnd: theme
|
|
121
|
+
insetInlineEnd: theme?.arrowBorderWidth,
|
|
119
122
|
insetInlineStart: 'auto',
|
|
120
|
-
marginTop: `calc(-1 * ${theme
|
|
123
|
+
marginTop: `calc(-1 * ${theme?.arrowSize})`,
|
|
121
124
|
borderInlineEndWidth: '0',
|
|
122
125
|
borderInlineEndColor: 'transparent',
|
|
123
126
|
borderTopColor: 'transparent',
|
|
124
127
|
borderBottomColor: 'transparent',
|
|
125
|
-
borderInlineStartWidth: theme
|
|
126
|
-
borderInlineStartColor: isInversed ? theme
|
|
128
|
+
borderInlineStartWidth: theme?.arrowSize,
|
|
129
|
+
borderInlineStartColor: isInversed ? theme?.arrowBackgroundColorInverse : theme?.arrowBackgroundColor
|
|
127
130
|
}
|
|
128
131
|
};
|
|
129
132
|
}
|
|
@@ -133,24 +136,24 @@ const getArrowPlacementVariant = (placement, background, theme, props) => {
|
|
|
133
136
|
top: '50%',
|
|
134
137
|
insetInlineEnd: '100%',
|
|
135
138
|
insetInlineStart: 'auto',
|
|
136
|
-
marginTop: `calc(-1 * (${theme
|
|
139
|
+
marginTop: `calc(-1 * (${theme?.arrowSize} + ${theme?.arrowBorderWidth}))`,
|
|
137
140
|
borderInlineStartWidth: '0',
|
|
138
141
|
borderInlineStartColor: 'transparent',
|
|
139
|
-
borderInlineEndColor: borderColor || (isInversed ? theme
|
|
142
|
+
borderInlineEndColor: borderColor || (isInversed ? theme?.arrowBorderColorInverse : theme?.arrowBorderColor),
|
|
140
143
|
borderTopColor: 'transparent',
|
|
141
144
|
borderBottomColor: 'transparent',
|
|
142
|
-
borderInlineEndWidth: theme
|
|
145
|
+
borderInlineEndWidth: theme?.arrowSize
|
|
143
146
|
},
|
|
144
147
|
__after: {
|
|
145
|
-
insetInlineStart: theme
|
|
148
|
+
insetInlineStart: theme?.arrowBorderWidth,
|
|
146
149
|
insetInlineEnd: 'auto',
|
|
147
|
-
marginTop: `calc(-1 * ${theme
|
|
150
|
+
marginTop: `calc(-1 * ${theme?.arrowSize})`,
|
|
148
151
|
borderInlineStartWidth: '0',
|
|
149
152
|
borderInlineStartColor: 'transparent',
|
|
150
153
|
borderTopColor: 'transparent',
|
|
151
154
|
borderBottomColor: 'transparent',
|
|
152
|
-
borderInlineEndWidth: theme
|
|
153
|
-
borderInlineEndColor: isInversed ? theme
|
|
155
|
+
borderInlineEndWidth: theme?.arrowSize,
|
|
156
|
+
borderInlineEndColor: isInversed ? theme?.arrowBackgroundColorInverse : theme?.arrowBackgroundColor
|
|
154
157
|
}
|
|
155
158
|
};
|
|
156
159
|
}
|
|
@@ -158,7 +161,7 @@ const getArrowPlacementVariant = (placement, background, theme, props) => {
|
|
|
158
161
|
return {
|
|
159
162
|
main: {
|
|
160
163
|
top: '100%',
|
|
161
|
-
marginInlineStart: `calc(-1 * (${theme
|
|
164
|
+
marginInlineStart: `calc(-1 * (${theme?.arrowSize} + ${theme?.arrowBorderWidth}))`,
|
|
162
165
|
marginInlineEnd: '0',
|
|
163
166
|
borderBottomWidth: '0',
|
|
164
167
|
borderBottomColor: 'transparent',
|
|
@@ -166,21 +169,21 @@ const getArrowPlacementVariant = (placement, background, theme, props) => {
|
|
|
166
169
|
borderInlineEndColor: 'transparent'
|
|
167
170
|
},
|
|
168
171
|
__after: {
|
|
169
|
-
bottom: theme
|
|
170
|
-
marginInlineStart: `calc(-1 * ${theme
|
|
172
|
+
bottom: theme?.arrowBorderWidth,
|
|
173
|
+
marginInlineStart: `calc(-1 * ${theme?.arrowSize})`,
|
|
171
174
|
marginInlineEnd: '0',
|
|
172
175
|
borderBottomWidth: '0',
|
|
173
176
|
borderBottomColor: 'transparent',
|
|
174
177
|
borderInlineStartColor: 'transparent',
|
|
175
178
|
borderInlineEndColor: 'transparent',
|
|
176
|
-
borderTopColor: isInversed ? theme
|
|
179
|
+
borderTopColor: isInversed ? theme?.arrowBackgroundColorInverse : theme?.arrowBackgroundColor
|
|
177
180
|
}
|
|
178
181
|
};
|
|
179
182
|
}
|
|
180
183
|
return {
|
|
181
184
|
main: {
|
|
182
185
|
bottom: '100%',
|
|
183
|
-
marginInlineStart: `calc(-1 * (${theme
|
|
186
|
+
marginInlineStart: `calc(-1 * (${theme?.arrowSize} + ${theme?.arrowBorderWidth}))`,
|
|
184
187
|
marginInlineEnd: '0',
|
|
185
188
|
borderTopWidth: '0',
|
|
186
189
|
borderTopColor: 'transparent',
|
|
@@ -188,14 +191,14 @@ const getArrowPlacementVariant = (placement, background, theme, props) => {
|
|
|
188
191
|
borderInlineEndColor: 'transparent'
|
|
189
192
|
},
|
|
190
193
|
__after: {
|
|
191
|
-
top: theme
|
|
192
|
-
marginInlineStart: `calc(-1 * ${theme
|
|
194
|
+
top: theme?.arrowBorderWidth,
|
|
195
|
+
marginInlineStart: `calc(-1 * ${theme?.arrowSize})`,
|
|
193
196
|
marginInlineEnd: '0',
|
|
194
197
|
borderTopWidth: '0',
|
|
195
198
|
borderTopColor: 'transparent',
|
|
196
199
|
borderInlineStartColor: 'transparent',
|
|
197
200
|
borderInlineEndColor: 'transparent',
|
|
198
|
-
borderBottomColor: isInversed ? theme
|
|
201
|
+
borderBottomColor: isInversed ? theme?.arrowBackgroundColorInverse : theme?.arrowBackgroundColor
|
|
199
202
|
}
|
|
200
203
|
};
|
|
201
204
|
};
|
|
@@ -210,9 +213,11 @@ const getArrowPlacementVariant = (placement, background, theme, props) => {
|
|
|
210
213
|
* @return {Object} The final style object, which will be used in the component
|
|
211
214
|
*/
|
|
212
215
|
const generateStyle = (componentTheme, props) => {
|
|
213
|
-
const
|
|
214
|
-
|
|
215
|
-
|
|
216
|
+
const {
|
|
217
|
+
placement,
|
|
218
|
+
background,
|
|
219
|
+
borderColor
|
|
220
|
+
} = props;
|
|
216
221
|
const arrowBaseStyles = {
|
|
217
222
|
content: '""',
|
|
218
223
|
height: '0',
|
|
@@ -224,16 +229,16 @@ const generateStyle = (componentTheme, props) => {
|
|
|
224
229
|
borderStyle: 'solid'
|
|
225
230
|
};
|
|
226
231
|
const arrowBackGroundVariants = {
|
|
227
|
-
default: componentTheme
|
|
228
|
-
inverse: componentTheme
|
|
232
|
+
default: componentTheme?.arrowBorderColor,
|
|
233
|
+
inverse: componentTheme?.arrowBorderColorInverse
|
|
229
234
|
};
|
|
230
235
|
const arrowPlacementVariant = getArrowPlacementVariant(placement, background, componentTheme, props);
|
|
231
236
|
return {
|
|
232
|
-
borderRadius: componentTheme
|
|
237
|
+
borderRadius: componentTheme?.borderRadius,
|
|
233
238
|
contextView: {
|
|
234
239
|
label: 'contextView',
|
|
235
240
|
boxSizing: 'border-box',
|
|
236
|
-
minHeight: `calc(${componentTheme
|
|
241
|
+
minHeight: `calc(${componentTheme?.arrowSize} * 2)`,
|
|
237
242
|
...getPlacementStyle(placement, componentTheme)
|
|
238
243
|
},
|
|
239
244
|
contextView__content: {
|
|
@@ -244,12 +249,12 @@ const generateStyle = (componentTheme, props) => {
|
|
|
244
249
|
label: 'contextView__arrow',
|
|
245
250
|
...arrowBaseStyles,
|
|
246
251
|
display: 'block',
|
|
247
|
-
borderWidth: `calc(${componentTheme
|
|
252
|
+
borderWidth: `calc(${componentTheme?.arrowSize} + ${componentTheme?.arrowBorderWidth})`,
|
|
248
253
|
borderColor: borderColor || arrowBackGroundVariants[background],
|
|
249
254
|
...arrowPlacementVariant.main,
|
|
250
255
|
...getArrowCorrections(placement, componentTheme),
|
|
251
256
|
'&::after': {
|
|
252
|
-
borderWidth: componentTheme
|
|
257
|
+
borderWidth: componentTheme?.arrowSize,
|
|
253
258
|
borderColor: arrowBackGroundVariants[background],
|
|
254
259
|
...arrowPlacementVariant.__after,
|
|
255
260
|
...arrowBaseStyles
|