@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,420 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { DIRECTION } from '@instructure/ui-i18n';
|
|
26
|
+
import { calcSpacingFromShorthand, mirrorShorthandEdges, mirrorShorthandCorners, calcFocusOutlineStyles } from '@instructure/emotion';
|
|
27
|
+
import { pickProps } from '@instructure/ui-react-utils';
|
|
28
|
+
import { boxShadowObjectsToCSSString } from '@instructure/ui-themes';
|
|
29
|
+
const processBorderRadiusValue = (value, sharedTokens) => {
|
|
30
|
+
if (!value) return '';
|
|
31
|
+
|
|
32
|
+
// Split by spaces to handle CSS shorthand (1-4 values)
|
|
33
|
+
const values = value.split(' ');
|
|
34
|
+
const processedValues = values.map(v => {
|
|
35
|
+
// Handle special cases
|
|
36
|
+
if (v === 'auto' || v === '0') return v;
|
|
37
|
+
if (v === 'none') return '0';
|
|
38
|
+
if (v === 'circle') return '100%';
|
|
39
|
+
if (v === 'pill') return '999em';
|
|
40
|
+
|
|
41
|
+
// Handle SharedTokens values
|
|
42
|
+
if (v === 'small') return sharedTokens.legacy.radiusSmall; // 2px in Canvas
|
|
43
|
+
if (v === 'medium') return sharedTokens.legacy.radiusMedium; // 4px in Canvas
|
|
44
|
+
if (v === 'large') return sharedTokens.legacy.radiusLarge; // 8px in Canvas
|
|
45
|
+
|
|
46
|
+
// Pass through CSS values (1rem, 12px, etc.)
|
|
47
|
+
return v;
|
|
48
|
+
});
|
|
49
|
+
return processedValues.join(' ');
|
|
50
|
+
};
|
|
51
|
+
const processBorderWidthValue = (value, sharedTokens) => {
|
|
52
|
+
if (!value) return '';
|
|
53
|
+
|
|
54
|
+
// Split by spaces to handle CSS shorthand (1-4 values)
|
|
55
|
+
const values = value.split(' ');
|
|
56
|
+
const processedValues = values.map(v => {
|
|
57
|
+
// Handle special cases
|
|
58
|
+
if (v === 'auto' || v === '0') return v;
|
|
59
|
+
if (v === 'none') return '0';
|
|
60
|
+
|
|
61
|
+
// Handle SharedTokens values
|
|
62
|
+
if (v === 'small') return sharedTokens.strokeWidth.sm;
|
|
63
|
+
if (v === 'medium') return sharedTokens.strokeWidth.md;
|
|
64
|
+
if (v === 'large') return sharedTokens.strokeWidth.lg;
|
|
65
|
+
|
|
66
|
+
// Pass through CSS values (1rem, 2px, etc.)
|
|
67
|
+
return v;
|
|
68
|
+
});
|
|
69
|
+
return processedValues.join(' ');
|
|
70
|
+
};
|
|
71
|
+
const getBorderStyle = ({
|
|
72
|
+
borderRadius,
|
|
73
|
+
borderWidth,
|
|
74
|
+
dir,
|
|
75
|
+
sharedTokens
|
|
76
|
+
}) => {
|
|
77
|
+
const isRtlDirection = dir === DIRECTION.rtl;
|
|
78
|
+
return {
|
|
79
|
+
borderRadius: processBorderRadiusValue(isRtlDirection ? mirrorShorthandCorners(borderRadius) : borderRadius, sharedTokens),
|
|
80
|
+
borderWidth: processBorderWidthValue(isRtlDirection ? mirrorShorthandEdges(borderWidth) : borderWidth, sharedTokens)
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
const getSpacingStyle = ({
|
|
84
|
+
margin,
|
|
85
|
+
padding,
|
|
86
|
+
dir,
|
|
87
|
+
sharedTokens
|
|
88
|
+
}) => {
|
|
89
|
+
const isRtlDirection = dir === DIRECTION.rtl;
|
|
90
|
+
return {
|
|
91
|
+
// TODO handle the merging on tokens inside the util
|
|
92
|
+
margin: calcSpacingFromShorthand(isRtlDirection ? mirrorShorthandEdges(margin) : margin, {
|
|
93
|
+
...sharedTokens.spacing,
|
|
94
|
+
...sharedTokens.legacy.spacing
|
|
95
|
+
}),
|
|
96
|
+
padding: calcSpacingFromShorthand(isRtlDirection ? mirrorShorthandEdges(padding) : padding, {
|
|
97
|
+
...sharedTokens.spacing,
|
|
98
|
+
...sharedTokens.legacy.spacing
|
|
99
|
+
})
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
const getOffsetStyle = ({
|
|
103
|
+
insetBlockStart,
|
|
104
|
+
insetBlockEnd,
|
|
105
|
+
insetInlineStart,
|
|
106
|
+
insetInlineEnd,
|
|
107
|
+
dir
|
|
108
|
+
}) => {
|
|
109
|
+
const isRtlDirection = dir === DIRECTION.rtl;
|
|
110
|
+
const blockStart = {
|
|
111
|
+
top: insetBlockStart,
|
|
112
|
+
insetBlockStart
|
|
113
|
+
};
|
|
114
|
+
const blockEnd = {
|
|
115
|
+
bottom: insetBlockEnd,
|
|
116
|
+
insetBlockEnd
|
|
117
|
+
};
|
|
118
|
+
const horizontalOffsets = {
|
|
119
|
+
left: isRtlDirection ? insetInlineEnd : insetInlineStart,
|
|
120
|
+
right: isRtlDirection ? insetInlineStart : insetInlineEnd
|
|
121
|
+
};
|
|
122
|
+
return {
|
|
123
|
+
...blockStart,
|
|
124
|
+
...blockEnd,
|
|
125
|
+
...horizontalOffsets
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
const getStyleProps = ({
|
|
129
|
+
cursor,
|
|
130
|
+
style
|
|
131
|
+
}) => {
|
|
132
|
+
const whitelisted = pickProps(style || {}, {}, [
|
|
133
|
+
// Position/calculateElementPosition:
|
|
134
|
+
'top', 'left', 'position', 'display', 'transform', 'overflow', 'minWidth', 'minHeight',
|
|
135
|
+
// Img:
|
|
136
|
+
'filter',
|
|
137
|
+
// Flex.Item:
|
|
138
|
+
'flexBasis',
|
|
139
|
+
// Avatar:
|
|
140
|
+
'backgroundImage',
|
|
141
|
+
// Popover:
|
|
142
|
+
'pointerEvents']);
|
|
143
|
+
if (cursor) {
|
|
144
|
+
whitelisted.cursor = cursor;
|
|
145
|
+
}
|
|
146
|
+
return whitelisted;
|
|
147
|
+
};
|
|
148
|
+
const withBorder = props => {
|
|
149
|
+
const borderWidth = props.borderWidth;
|
|
150
|
+
return borderWidth && borderWidth !== '0' && borderWidth !== 'none';
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Generates the style object from the theme and provided additional information
|
|
155
|
+
* @param {Object} componentTheme The theme variable object.
|
|
156
|
+
* @param {Object} props the props of the component, the style is applied to
|
|
157
|
+
* @return {Object} The final style object, which will be used in the component
|
|
158
|
+
*/
|
|
159
|
+
const generateStyle = (componentTheme, props, sharedTokens) => {
|
|
160
|
+
const borderRadius = props.borderRadius,
|
|
161
|
+
borderWidth = props.borderWidth,
|
|
162
|
+
margin = props.margin,
|
|
163
|
+
padding = props.padding,
|
|
164
|
+
position = props.position,
|
|
165
|
+
display = props.display,
|
|
166
|
+
textAlign = props.textAlign,
|
|
167
|
+
borderColor = props.borderColor,
|
|
168
|
+
background = props.background,
|
|
169
|
+
stacking = props.stacking,
|
|
170
|
+
shadow = props.shadow,
|
|
171
|
+
overflowY = props.overflowY,
|
|
172
|
+
overflowX = props.overflowX,
|
|
173
|
+
overscrollBehavior = props.overscrollBehavior,
|
|
174
|
+
insetBlockEnd = props.insetBlockEnd,
|
|
175
|
+
insetBlockStart = props.insetBlockStart,
|
|
176
|
+
insetInlineEnd = props.insetInlineEnd,
|
|
177
|
+
insetInlineStart = props.insetInlineStart,
|
|
178
|
+
width = props.width,
|
|
179
|
+
height = props.height,
|
|
180
|
+
minWidth = props.minWidth,
|
|
181
|
+
minHeight = props.minHeight,
|
|
182
|
+
maxWidth = props.maxWidth,
|
|
183
|
+
maxHeight = props.maxHeight,
|
|
184
|
+
withVisualDebug = props.withVisualDebug,
|
|
185
|
+
dir = props.dir;
|
|
186
|
+
const borderStyle = getBorderStyle({
|
|
187
|
+
sharedTokens,
|
|
188
|
+
borderRadius,
|
|
189
|
+
borderWidth,
|
|
190
|
+
dir
|
|
191
|
+
});
|
|
192
|
+
const spacingStyle = getSpacingStyle({
|
|
193
|
+
margin,
|
|
194
|
+
padding,
|
|
195
|
+
sharedTokens,
|
|
196
|
+
dir
|
|
197
|
+
});
|
|
198
|
+
const offsetStyle = getOffsetStyle({
|
|
199
|
+
dir,
|
|
200
|
+
insetBlockEnd,
|
|
201
|
+
insetBlockStart,
|
|
202
|
+
insetInlineEnd,
|
|
203
|
+
insetInlineStart
|
|
204
|
+
});
|
|
205
|
+
const displayVariants = {
|
|
206
|
+
inline: {
|
|
207
|
+
label: 'view--inline',
|
|
208
|
+
display: 'inline'
|
|
209
|
+
},
|
|
210
|
+
block: {
|
|
211
|
+
label: 'view--block',
|
|
212
|
+
display: 'block'
|
|
213
|
+
},
|
|
214
|
+
'inline-block': {
|
|
215
|
+
label: 'view--inlineBlock',
|
|
216
|
+
display: 'inline-block',
|
|
217
|
+
verticalAlign: 'middle'
|
|
218
|
+
},
|
|
219
|
+
flex: {
|
|
220
|
+
label: 'view--flex',
|
|
221
|
+
display: 'flex'
|
|
222
|
+
},
|
|
223
|
+
'inline-flex': {
|
|
224
|
+
label: 'view--inlineFlex',
|
|
225
|
+
display: 'inline-flex',
|
|
226
|
+
verticalAlign: 'middle'
|
|
227
|
+
},
|
|
228
|
+
contents: {
|
|
229
|
+
label: 'view--contents',
|
|
230
|
+
display: 'contents'
|
|
231
|
+
},
|
|
232
|
+
inherit: {
|
|
233
|
+
label: 'view--inherit',
|
|
234
|
+
display: 'inherit'
|
|
235
|
+
},
|
|
236
|
+
initial: {
|
|
237
|
+
label: 'view--initial',
|
|
238
|
+
display: 'initial'
|
|
239
|
+
},
|
|
240
|
+
revert: {
|
|
241
|
+
label: 'view--revert',
|
|
242
|
+
display: 'revert'
|
|
243
|
+
},
|
|
244
|
+
'revert-layer': {
|
|
245
|
+
label: 'view--revertLayer',
|
|
246
|
+
display: 'revert-layer'
|
|
247
|
+
},
|
|
248
|
+
unset: {
|
|
249
|
+
label: 'view--unset',
|
|
250
|
+
display: 'unset'
|
|
251
|
+
},
|
|
252
|
+
auto: {}
|
|
253
|
+
};
|
|
254
|
+
const textAlignVariants = {
|
|
255
|
+
start: {
|
|
256
|
+
textAlign: 'start'
|
|
257
|
+
},
|
|
258
|
+
center: {
|
|
259
|
+
textAlign: 'center'
|
|
260
|
+
},
|
|
261
|
+
end: {
|
|
262
|
+
textAlign: 'end'
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
const borderColorVariants = {
|
|
266
|
+
transparent: {
|
|
267
|
+
borderColor: componentTheme.borderColorTransparent
|
|
268
|
+
},
|
|
269
|
+
primary: {
|
|
270
|
+
borderColor: componentTheme.borderColorPrimary
|
|
271
|
+
},
|
|
272
|
+
secondary: {
|
|
273
|
+
borderColor: componentTheme.borderColorSecondary
|
|
274
|
+
},
|
|
275
|
+
brand: {
|
|
276
|
+
borderColor: componentTheme.borderColorBrand
|
|
277
|
+
},
|
|
278
|
+
info: {
|
|
279
|
+
borderColor: componentTheme.borderColorInfo
|
|
280
|
+
},
|
|
281
|
+
success: {
|
|
282
|
+
borderColor: componentTheme.borderColorSuccess
|
|
283
|
+
},
|
|
284
|
+
warning: {
|
|
285
|
+
borderColor: componentTheme.borderColorWarning
|
|
286
|
+
},
|
|
287
|
+
alert: {
|
|
288
|
+
borderColor: componentTheme.borderColorAlert
|
|
289
|
+
},
|
|
290
|
+
danger: {
|
|
291
|
+
borderColor: componentTheme.borderColorDanger
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
const backgroundColorVariants = {
|
|
295
|
+
transparent: {
|
|
296
|
+
color: componentTheme.color,
|
|
297
|
+
background: 'none'
|
|
298
|
+
},
|
|
299
|
+
primary: {
|
|
300
|
+
color: componentTheme.color,
|
|
301
|
+
background: componentTheme.backgroundPrimary
|
|
302
|
+
},
|
|
303
|
+
secondary: {
|
|
304
|
+
color: componentTheme.color,
|
|
305
|
+
background: componentTheme.backgroundSecondary
|
|
306
|
+
},
|
|
307
|
+
['primary-inverse']: {
|
|
308
|
+
color: componentTheme.colorPrimaryInverse,
|
|
309
|
+
background: componentTheme.backgroundPrimaryInverse
|
|
310
|
+
},
|
|
311
|
+
brand: {
|
|
312
|
+
color: componentTheme.colorPrimaryInverse,
|
|
313
|
+
background: componentTheme.backgroundBrand
|
|
314
|
+
},
|
|
315
|
+
info: {
|
|
316
|
+
color: componentTheme.colorPrimaryInverse,
|
|
317
|
+
background: componentTheme.backgroundInfo
|
|
318
|
+
},
|
|
319
|
+
alert: {
|
|
320
|
+
color: componentTheme.colorPrimaryInverse,
|
|
321
|
+
background: componentTheme.backgroundAlert
|
|
322
|
+
},
|
|
323
|
+
success: {
|
|
324
|
+
color: componentTheme.colorPrimaryInverse,
|
|
325
|
+
background: componentTheme.backgroundSuccess
|
|
326
|
+
},
|
|
327
|
+
danger: {
|
|
328
|
+
color: componentTheme.colorPrimaryInverse,
|
|
329
|
+
background: componentTheme.backgroundDanger
|
|
330
|
+
},
|
|
331
|
+
warning: {
|
|
332
|
+
color: componentTheme.colorPrimaryInverse,
|
|
333
|
+
background: componentTheme.backgroundWarning
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
const stackingVariants = {
|
|
337
|
+
topmost: {
|
|
338
|
+
zIndex: componentTheme.stackingTopmost
|
|
339
|
+
},
|
|
340
|
+
above: {
|
|
341
|
+
zIndex: componentTheme.stackingAbove
|
|
342
|
+
},
|
|
343
|
+
resting: {},
|
|
344
|
+
below: {
|
|
345
|
+
zIndex: componentTheme.stackingBelow
|
|
346
|
+
},
|
|
347
|
+
deepest: {
|
|
348
|
+
zIndex: componentTheme.stackingDeepest
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
const shadowVariants = {
|
|
352
|
+
topmost: {
|
|
353
|
+
boxShadow: boxShadowObjectsToCSSString(sharedTokens.boxShadow.elevation4)
|
|
354
|
+
},
|
|
355
|
+
resting: {
|
|
356
|
+
boxShadow: boxShadowObjectsToCSSString(sharedTokens.boxShadow.elevation1)
|
|
357
|
+
},
|
|
358
|
+
above: {
|
|
359
|
+
boxShadow: boxShadowObjectsToCSSString(sharedTokens.boxShadow.elevation2)
|
|
360
|
+
},
|
|
361
|
+
none: {}
|
|
362
|
+
};
|
|
363
|
+
const focusColor = props.focusColor,
|
|
364
|
+
focusPosition = props.focusPosition,
|
|
365
|
+
shouldAnimateFocus = props.shouldAnimateFocus,
|
|
366
|
+
withFocusOutline = props.withFocusOutline,
|
|
367
|
+
focusWithin = props.focusWithin;
|
|
368
|
+
const focusOutline = calcFocusOutlineStyles(sharedTokens.focusOutline, {
|
|
369
|
+
focusColor,
|
|
370
|
+
focusPosition,
|
|
371
|
+
shouldAnimateFocus,
|
|
372
|
+
focusWithin,
|
|
373
|
+
withFocusOutline
|
|
374
|
+
});
|
|
375
|
+
return {
|
|
376
|
+
view: {
|
|
377
|
+
label: 'view',
|
|
378
|
+
boxSizing: 'border-box',
|
|
379
|
+
fontFamily: componentTheme.fontFamily,
|
|
380
|
+
maxWidth: '100%',
|
|
381
|
+
overflow: 'visible',
|
|
382
|
+
...displayVariants[display],
|
|
383
|
+
...(background && backgroundColorVariants[background]),
|
|
384
|
+
...(stacking && stackingVariants[stacking]),
|
|
385
|
+
...(shadow && shadowVariants[shadow]),
|
|
386
|
+
...(textAlign && textAlignVariants[textAlign]),
|
|
387
|
+
overflowX: overflowX && overflowX !== 'visible' ? overflowX : '',
|
|
388
|
+
overflowY: overflowY && overflowY !== 'visible' ? overflowY : '',
|
|
389
|
+
position: position !== 'static' ? position : '',
|
|
390
|
+
overscrollBehavior: overscrollBehavior ? overscrollBehavior : 'auto',
|
|
391
|
+
...(withVisualDebug ? {
|
|
392
|
+
boxShadow: `0 0 0 1px ${componentTheme.debugOutlineColor}`
|
|
393
|
+
} : {}),
|
|
394
|
+
...(withBorder(props) ? {
|
|
395
|
+
borderStyle: componentTheme.borderStyle,
|
|
396
|
+
...(borderColorVariants[borderColor] || {
|
|
397
|
+
borderColor: borderColor
|
|
398
|
+
})
|
|
399
|
+
} : {}),
|
|
400
|
+
...borderStyle
|
|
401
|
+
},
|
|
402
|
+
inlineStyles: {
|
|
403
|
+
//every '&' symbol will add another class to the rule, so it will be stronger
|
|
404
|
+
//making an accidental override less likely
|
|
405
|
+
'&&&&&&&&&&': {
|
|
406
|
+
...offsetStyle,
|
|
407
|
+
...focusOutline,
|
|
408
|
+
width,
|
|
409
|
+
height,
|
|
410
|
+
minWidth,
|
|
411
|
+
minHeight,
|
|
412
|
+
maxWidth,
|
|
413
|
+
maxHeight,
|
|
414
|
+
...getStyleProps(props),
|
|
415
|
+
...spacingStyle
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
};
|
|
419
|
+
};
|
|
420
|
+
export default generateStyle;
|
|
@@ -21,5 +21,5 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
-
export { ContextView } from "
|
|
25
|
-
export { View } from "
|
|
24
|
+
export { ContextView } from "../ContextView/v1/index.js";
|
|
25
|
+
export { View } from "../View/v1/index.js";
|
|
@@ -21,9 +21,5 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
-
|
|
25
|
-
export {
|
|
26
|
-
export { View } from './View'
|
|
27
|
-
|
|
28
|
-
export type { ContextViewProps } from './ContextView/props'
|
|
29
|
-
export type { ViewProps, ViewOwnProps } from './View/props'
|
|
24
|
+
export { ContextView } from "../ContextView/v2/index.js";
|
|
25
|
+
export { View } from "../View/v2/index.js";
|
|
@@ -8,7 +8,7 @@ exports.default = exports.ContextView = void 0;
|
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
var _emotion = require("@instructure/emotion");
|
|
10
10
|
var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
|
|
11
|
-
var
|
|
11
|
+
var _v = require("../../View/v1");
|
|
12
12
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
13
13
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
14
14
|
var _props = require("./props");
|
|
@@ -42,7 +42,7 @@ var _dec, _class, _ContextView;
|
|
|
42
42
|
category: components
|
|
43
43
|
---
|
|
44
44
|
**/
|
|
45
|
-
let ContextView = exports.ContextView = (_dec = (0, _emotion.
|
|
45
|
+
let ContextView = exports.ContextView = (_dec = (0, _emotion.withStyleLegacy)(_styles.default, _theme.default), _dec(_class = (_ContextView = class ContextView extends _react.Component {
|
|
46
46
|
constructor(...args) {
|
|
47
47
|
super(...args);
|
|
48
48
|
this.ref = null;
|
|
@@ -82,7 +82,7 @@ let ContextView = exports.ContextView = (_dec = (0, _emotion.withStyle)(_styles.
|
|
|
82
82
|
textAlign = _this$props3.textAlign,
|
|
83
83
|
styles = _this$props3.styles,
|
|
84
84
|
borderColor = _this$props3.borderColor;
|
|
85
|
-
return (0, _jsxRuntime.jsx)(
|
|
85
|
+
return (0, _jsxRuntime.jsx)(_v.View, {
|
|
86
86
|
...(0, _omitProps.omitProps)(this.props, ContextView.allowedProps),
|
|
87
87
|
css: styles === null || styles === void 0 ? void 0 : styles.contextView,
|
|
88
88
|
style: style,
|
|
@@ -93,7 +93,7 @@ let ContextView = exports.ContextView = (_dec = (0, _emotion.withStyle)(_styles.
|
|
|
93
93
|
elementRef: this.handleRef,
|
|
94
94
|
margin: margin,
|
|
95
95
|
stacking: stacking,
|
|
96
|
-
children: (0, _jsxRuntime.jsxs)(
|
|
96
|
+
children: (0, _jsxRuntime.jsxs)(_v.View, {
|
|
97
97
|
css: styles === null || styles === void 0 ? void 0 : styles.contextView__content,
|
|
98
98
|
display: "block",
|
|
99
99
|
borderRadius: "medium",
|
|
@@ -0,0 +1,130 @@
|
|
|
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, _ContextView;
|
|
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.withStyle)(_styles.default), _dec(_class = (_ContextView = class ContextView extends _react.Component {
|
|
45
|
+
constructor(...args) {
|
|
46
|
+
super(...args);
|
|
47
|
+
this.ref = null;
|
|
48
|
+
this.handleRef = el => {
|
|
49
|
+
const elementRef = this.props.elementRef;
|
|
50
|
+
this.ref = el;
|
|
51
|
+
if (typeof elementRef === 'function') {
|
|
52
|
+
elementRef(el);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
componentDidMount() {
|
|
57
|
+
var _this$props$makeStyle, _this$props;
|
|
58
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
59
|
+
}
|
|
60
|
+
componentDidUpdate() {
|
|
61
|
+
var _this$props$makeStyle2, _this$props2;
|
|
62
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
63
|
+
}
|
|
64
|
+
render() {
|
|
65
|
+
const _this$props3 = this.props,
|
|
66
|
+
as = _this$props3.as,
|
|
67
|
+
background = _this$props3.background,
|
|
68
|
+
children = _this$props3.children,
|
|
69
|
+
debug = _this$props3.debug,
|
|
70
|
+
height = _this$props3.height,
|
|
71
|
+
width = _this$props3.width,
|
|
72
|
+
maxHeight = _this$props3.maxHeight,
|
|
73
|
+
maxWidth = _this$props3.maxWidth,
|
|
74
|
+
minHeight = _this$props3.minHeight,
|
|
75
|
+
minWidth = _this$props3.minWidth,
|
|
76
|
+
margin = _this$props3.margin,
|
|
77
|
+
padding = _this$props3.padding,
|
|
78
|
+
shadow = _this$props3.shadow,
|
|
79
|
+
stacking = _this$props3.stacking,
|
|
80
|
+
style = _this$props3.style,
|
|
81
|
+
textAlign = _this$props3.textAlign,
|
|
82
|
+
styles = _this$props3.styles,
|
|
83
|
+
borderColor = _this$props3.borderColor;
|
|
84
|
+
return (0, _jsxRuntime.jsx)(_v.View, {
|
|
85
|
+
...(0, _omitProps.omitProps)(this.props, ContextView.allowedProps),
|
|
86
|
+
css: styles === null || styles === void 0 ? void 0 : styles.contextView,
|
|
87
|
+
style: style,
|
|
88
|
+
borderWidth: "none",
|
|
89
|
+
display: "inline-block",
|
|
90
|
+
as: as,
|
|
91
|
+
withVisualDebug: debug,
|
|
92
|
+
elementRef: this.handleRef,
|
|
93
|
+
margin: margin,
|
|
94
|
+
stacking: stacking,
|
|
95
|
+
children: (0, _jsxRuntime.jsxs)(_v.View, {
|
|
96
|
+
css: styles === null || styles === void 0 ? void 0 : styles.contextView__content,
|
|
97
|
+
display: "block",
|
|
98
|
+
borderRadius: styles === null || styles === void 0 ? void 0 : styles.borderRadius,
|
|
99
|
+
borderWidth: "small",
|
|
100
|
+
borderColor: borderColor || (background === 'default' ? 'primary' : 'transparent'),
|
|
101
|
+
background: background === 'default' ? 'primary' : 'primary-inverse',
|
|
102
|
+
withVisualDebug: debug,
|
|
103
|
+
height: height,
|
|
104
|
+
width: width,
|
|
105
|
+
maxHeight: maxHeight,
|
|
106
|
+
maxWidth: maxWidth,
|
|
107
|
+
minHeight: minHeight,
|
|
108
|
+
minWidth: minWidth,
|
|
109
|
+
padding: padding,
|
|
110
|
+
shadow: shadow,
|
|
111
|
+
textAlign: textAlign,
|
|
112
|
+
children: [(0, _jsxRuntime.jsx)("span", {
|
|
113
|
+
css: styles === null || styles === void 0 ? void 0 : styles.contextView__arrow
|
|
114
|
+
}), children]
|
|
115
|
+
})
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}, _ContextView.displayName = "ContextView", _ContextView.componentId = 'ContextView', _ContextView.allowedProps = _props.allowedProps, _ContextView.defaultProps = {
|
|
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);
|
|
130
|
+
var _default = exports.default = ContextView;
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
const allowedProps = exports.allowedProps = ['as', 'elementRef', 'margin', 'padding', 'height', 'width', 'maxHeight', 'maxWidth', 'minHeight', 'minWidth', 'children', 'textAlign', 'shadow', 'stacking', 'background', 'placement', 'debug', 'borderColor'];
|