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