@instructure/ui-view 8.8.1-snapshot.3 → 8.9.0
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 +6 -0
- package/es/ContextView/index.js +4 -83
- package/es/ContextView/props.js +96 -0
- package/es/View/index.js +8 -4
- package/es/View/{types.js → props.js} +6 -7
- package/lib/ContextView/index.js +4 -84
- package/lib/ContextView/props.js +109 -0
- package/lib/View/index.js +8 -4
- package/lib/View/{types.js → props.js} +4 -6
- package/package.json +14 -15
- package/src/ContextView/index.tsx +6 -87
- package/src/ContextView/props.ts +156 -0
- package/src/ContextView/styles.ts +4 -4
- package/src/View/__examples__/View.examples.ts +1 -1
- package/src/View/index.tsx +18 -5
- package/src/View/{types.ts → props.ts} +23 -15
- package/src/View/styles.ts +1 -1
- package/src/index.ts +2 -2
- package/types/ContextView/index.d.ts +39 -69
- package/types/ContextView/index.d.ts.map +1 -1
- package/types/ContextView/props.d.ts +31 -0
- package/types/ContextView/props.d.ts.map +1 -0
- package/types/ContextView/styles.d.ts +1 -1
- package/types/View/__examples__/View.examples.d.ts +1 -1
- package/types/View/index.d.ts +80 -48
- package/types/View/index.d.ts.map +1 -1
- package/types/View/{types.d.ts → props.d.ts} +15 -44
- package/types/View/props.d.ts.map +1 -0
- package/types/View/styles.d.ts +1 -1
- package/types/index.d.ts +2 -2
- package/LICENSE.md +0 -27
- package/es/ContextView/types.js +0 -1
- package/lib/ContextView/types.js +0 -1
- package/src/ContextView/types.ts +0 -48
- package/types/ContextView/types.d.ts +0 -24
- package/types/ContextView/types.d.ts.map +0 -1
- package/types/View/types.d.ts.map +0 -1
package/lib/View/index.js
CHANGED
|
@@ -31,7 +31,7 @@ var _styles = _interopRequireDefault(require("./styles"));
|
|
|
31
31
|
|
|
32
32
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
33
33
|
|
|
34
|
-
var
|
|
34
|
+
var _props = require("./props");
|
|
35
35
|
|
|
36
36
|
const _excluded = ["children", "textAlign", "background", "display", "withVisualDebug", "width", "height", "minWidth", "minHeight", "maxWidth", "maxHeight", "overflowX", "overflowY", "stacking", "shadow", "position", "focusPosition", "focusColor", "shouldAnimateFocus", "borderColor", "className", "styles", "makeStyles"];
|
|
37
37
|
|
|
@@ -159,7 +159,7 @@ let View = (_dec = (0, _bidirectional.bidirectional)(), _dec2 = (0, _emotion.wit
|
|
|
159
159
|
}), children);
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
-
}, _class2.displayName = "View", _class2.componentId = 'View', _class2.allowedProps =
|
|
162
|
+
}, _class2.displayName = "View", _class2.componentId = 'View', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
|
|
163
163
|
display: 'auto',
|
|
164
164
|
overflowX: 'visible',
|
|
165
165
|
overflowY: 'visible',
|
|
@@ -170,13 +170,17 @@ let View = (_dec = (0, _bidirectional.bidirectional)(), _dec2 = (0, _emotion.wit
|
|
|
170
170
|
focusColor: 'info',
|
|
171
171
|
shouldAnimateFocus: true
|
|
172
172
|
}, _class2.omitViewProps = (props, Component) => {
|
|
173
|
+
// We don't want the theming and styling props to pass
|
|
174
|
+
// (these are added and handled by the `@withStyle` decorator)
|
|
175
|
+
const propsToOmit = [..._class2.allowedProps, 'styles', 'makeStyles', 'themeOverride'];
|
|
176
|
+
|
|
173
177
|
if (process.env.NODE_ENV !== 'production') {
|
|
174
|
-
Object.keys((0, _pickProps.pickProps)(props,
|
|
178
|
+
Object.keys((0, _pickProps.pickProps)(props, propsToOmit)).forEach(prop => {
|
|
175
179
|
(0, _console.logError)(false, `[${Component.name}] prop '${prop}' is not allowed.`);
|
|
176
180
|
});
|
|
177
181
|
}
|
|
178
182
|
|
|
179
|
-
return (0, _omitProps.omitProps)(props,
|
|
183
|
+
return (0, _omitProps.omitProps)(props, propsToOmit);
|
|
180
184
|
}, _temp)) || _class) || _class);
|
|
181
185
|
exports.View = View;
|
|
182
186
|
var _default = View;
|
|
@@ -71,13 +71,11 @@ const propTypes = {
|
|
|
71
71
|
focusColor: _propTypes.default.oneOf(['info', 'inverse', 'success', 'danger']),
|
|
72
72
|
shouldAnimateFocus: _propTypes.default.bool,
|
|
73
73
|
withVisualDebug: _propTypes.default.bool,
|
|
74
|
-
makeStyles: _propTypes.default.func,
|
|
75
|
-
styles: _propTypes.default.object,
|
|
76
74
|
dir: _propTypes.default.oneOf(Object.values(_bidirectional.bidirectional.DIRECTION))
|
|
77
|
-
}; //This variable will be attached as static property on the `View` component
|
|
78
|
-
//so we don't rely on the `PropTypes` validators for our internal logic.
|
|
79
|
-
//This means on prod builds the consuming applications can safely delete propTypes.
|
|
75
|
+
}; // This variable will be attached as static property on the `View` component
|
|
76
|
+
// so we don't rely on the `PropTypes` validators for our internal logic.
|
|
77
|
+
// This means on prod builds the consuming applications can safely delete propTypes.
|
|
80
78
|
|
|
81
79
|
exports.propTypes = propTypes;
|
|
82
|
-
const allowedProps = ['as', 'background', 'borderColor', 'borderRadius', 'borderWidth', 'cursor', 'dir', 'display', 'elementRef', 'focusColor', 'focusPosition', 'height', 'insetBlockEnd', 'insetBlockStart', 'insetInlineEnd', 'insetInlineStart', '
|
|
80
|
+
const 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', 'padding', 'position', 'shadow', 'shouldAnimateFocus', 'stacking', 'textAlign', 'width', 'withFocusOutline', 'withVisualDebug'];
|
|
83
81
|
exports.allowedProps = allowedProps;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-view",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.9.0",
|
|
4
4
|
"description": "A component for basic styles including spacing, sizing, borders, display, positioning, and focus states.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -25,21 +25,21 @@
|
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@babel/runtime": "^7.13.10",
|
|
28
|
-
"@instructure/console": "8.
|
|
29
|
-
"@instructure/emotion": "8.
|
|
30
|
-
"@instructure/
|
|
31
|
-
"@instructure/ui-
|
|
32
|
-
"@instructure/ui-
|
|
33
|
-
"@instructure/ui-
|
|
34
|
-
"@instructure/ui-
|
|
35
|
-
"@instructure/ui-
|
|
28
|
+
"@instructure/console": "8.9.0",
|
|
29
|
+
"@instructure/emotion": "8.9.0",
|
|
30
|
+
"@instructure/shared-types": "8.9.0",
|
|
31
|
+
"@instructure/ui-color-utils": "8.9.0",
|
|
32
|
+
"@instructure/ui-dom-utils": "8.9.0",
|
|
33
|
+
"@instructure/ui-i18n": "8.9.0",
|
|
34
|
+
"@instructure/ui-position": "8.9.0",
|
|
35
|
+
"@instructure/ui-prop-types": "8.9.0",
|
|
36
|
+
"@instructure/ui-react-utils": "8.9.0",
|
|
36
37
|
"prop-types": "^15"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
|
-
"@instructure/
|
|
40
|
-
"@instructure/ui-
|
|
41
|
-
"@instructure/ui-
|
|
42
|
-
"@instructure/ui-themes": "8.8.1-snapshot.3+d5d6d4cd8"
|
|
40
|
+
"@instructure/ui-babel-preset": "8.9.0",
|
|
41
|
+
"@instructure/ui-test-utils": "8.9.0",
|
|
42
|
+
"@instructure/ui-themes": "8.9.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"react": ">=16.8 <=17"
|
|
@@ -47,6 +47,5 @@
|
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|
|
49
49
|
},
|
|
50
|
-
"sideEffects": false
|
|
51
|
-
"gitHead": "d5d6d4cd8f300e8635c69248f5d794c002269e08"
|
|
50
|
+
"sideEffects": false
|
|
52
51
|
}
|
|
@@ -24,10 +24,8 @@
|
|
|
24
24
|
/** @jsx jsx */
|
|
25
25
|
|
|
26
26
|
import { Component } from 'react'
|
|
27
|
-
import PropTypes from 'prop-types'
|
|
28
27
|
|
|
29
|
-
import { jsx, withStyle
|
|
30
|
-
import { PositionPropTypes } from '@instructure/ui-position'
|
|
28
|
+
import { jsx, withStyle } from '@instructure/emotion'
|
|
31
29
|
import { omitProps } from '@instructure/ui-react-utils'
|
|
32
30
|
import { OtherHTMLAttributes } from '@instructure/shared-types'
|
|
33
31
|
|
|
@@ -35,7 +33,8 @@ import { View } from '../View'
|
|
|
35
33
|
|
|
36
34
|
import generateStyle from './styles'
|
|
37
35
|
import generateComponentTheme from './theme'
|
|
38
|
-
import {
|
|
36
|
+
import { propTypes, allowedProps } from './props'
|
|
37
|
+
import type { ContextViewProps } from './props'
|
|
39
38
|
|
|
40
39
|
/**
|
|
41
40
|
---
|
|
@@ -48,81 +47,8 @@ class ContextView extends Component<
|
|
|
48
47
|
ContextViewProps & OtherHTMLAttributes<ContextViewProps>
|
|
49
48
|
> {
|
|
50
49
|
static readonly componentId = 'ContextView'
|
|
51
|
-
|
|
52
|
-
static propTypes =
|
|
53
|
-
/**
|
|
54
|
-
* The element to render as the component root
|
|
55
|
-
*/
|
|
56
|
-
as: PropTypes.elementType,
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* provides a reference to the underlying html root element
|
|
60
|
-
*/
|
|
61
|
-
elementRef: PropTypes.func,
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
65
|
-
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
66
|
-
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
67
|
-
*/
|
|
68
|
-
margin: ThemeablePropTypes.spacing,
|
|
69
|
-
/**
|
|
70
|
-
* Valid values are `0`, `none`, `xxx-small`, `xx-small`, `x-small`,
|
|
71
|
-
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
72
|
-
* familiar CSS-like shorthand. For example: `padding="small x-large large"`.
|
|
73
|
-
*/
|
|
74
|
-
padding: ThemeablePropTypes.spacing,
|
|
75
|
-
|
|
76
|
-
height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
77
|
-
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
78
|
-
maxHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
79
|
-
maxWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
80
|
-
minHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
81
|
-
minWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* The children to render inside the `<ContextView />`
|
|
85
|
-
*/
|
|
86
|
-
children: PropTypes.node,
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Designates the text alignment within the `<ContextView />`
|
|
90
|
-
*/
|
|
91
|
-
textAlign: PropTypes.oneOf(['start', 'center', 'end']),
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Controls the shadow depth for the `<ContextView />`
|
|
95
|
-
*/
|
|
96
|
-
shadow: ThemeablePropTypes.shadow,
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Controls the z-index depth for the `<ContextView />`
|
|
100
|
-
*/
|
|
101
|
-
stacking: ThemeablePropTypes.stacking,
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Designates the background style of the `<ContextView />`
|
|
105
|
-
*/
|
|
106
|
-
background: PropTypes.oneOf(['default', 'inverse']),
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Specifies how the arrow for `<ContextView />` will be rendered.
|
|
110
|
-
* Ex. `placement="top"` will render with an arrow pointing down.
|
|
111
|
-
*/
|
|
112
|
-
placement: PositionPropTypes.placement,
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Activate an outline around the component to make building your
|
|
116
|
-
* layout easier
|
|
117
|
-
*/
|
|
118
|
-
debug: PropTypes.bool,
|
|
119
|
-
|
|
120
|
-
// eslint-disable-next-line react/require-default-props
|
|
121
|
-
makeStyles: PropTypes.func,
|
|
122
|
-
// eslint-disable-next-line react/require-default-props
|
|
123
|
-
styles: PropTypes.object
|
|
124
|
-
}
|
|
125
|
-
|
|
50
|
+
static allowedProps = allowedProps
|
|
51
|
+
static propTypes = propTypes
|
|
126
52
|
static defaultProps = {
|
|
127
53
|
as: 'span',
|
|
128
54
|
elementRef: () => {},
|
|
@@ -133,14 +59,7 @@ class ContextView extends Component<
|
|
|
133
59
|
textAlign: 'start',
|
|
134
60
|
background: 'default',
|
|
135
61
|
shadow: 'resting',
|
|
136
|
-
placement: 'center end'
|
|
137
|
-
margin: undefined,
|
|
138
|
-
padding: undefined,
|
|
139
|
-
stacking: undefined,
|
|
140
|
-
maxWidth: undefined,
|
|
141
|
-
minWidth: undefined,
|
|
142
|
-
maxHeight: undefined,
|
|
143
|
-
minHeight: undefined
|
|
62
|
+
placement: 'center end'
|
|
144
63
|
}
|
|
145
64
|
|
|
146
65
|
componentDidMount() {
|
|
@@ -0,0 +1,156 @@
|
|
|
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 React from 'react'
|
|
26
|
+
import PropTypes from 'prop-types'
|
|
27
|
+
|
|
28
|
+
import { ThemeablePropTypes } from '@instructure/emotion'
|
|
29
|
+
import { PositionPropTypes } from '@instructure/ui-position'
|
|
30
|
+
|
|
31
|
+
import type { AsElementType, PropValidators } from '@instructure/shared-types'
|
|
32
|
+
import type { PlacementPropValues } from '@instructure/ui-position'
|
|
33
|
+
import type {
|
|
34
|
+
Shadow,
|
|
35
|
+
Spacing,
|
|
36
|
+
Stacking,
|
|
37
|
+
WithStyleProps
|
|
38
|
+
} from '@instructure/emotion'
|
|
39
|
+
|
|
40
|
+
type ContextViewOwnProps = {
|
|
41
|
+
as?: AsElementType
|
|
42
|
+
elementRef?: (...args: any[]) => any
|
|
43
|
+
height?: string | number
|
|
44
|
+
width?: string | number
|
|
45
|
+
maxHeight?: string | number
|
|
46
|
+
maxWidth?: string | number
|
|
47
|
+
minHeight?: string | number
|
|
48
|
+
minWidth?: string | number
|
|
49
|
+
children?: React.ReactNode
|
|
50
|
+
textAlign?: 'start' | 'center' | 'end'
|
|
51
|
+
background?: 'default' | 'inverse'
|
|
52
|
+
debug?: boolean
|
|
53
|
+
margin?: Spacing
|
|
54
|
+
padding?: Spacing
|
|
55
|
+
shadow?: Shadow
|
|
56
|
+
stacking?: Stacking
|
|
57
|
+
placement?: PlacementPropValues
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
type PropKeys = keyof ContextViewOwnProps
|
|
61
|
+
|
|
62
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
63
|
+
|
|
64
|
+
type ContextViewProps = ContextViewOwnProps & WithStyleProps
|
|
65
|
+
|
|
66
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
67
|
+
/**
|
|
68
|
+
* The element to render as the component root
|
|
69
|
+
*/
|
|
70
|
+
as: PropTypes.elementType,
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* provides a reference to the underlying html root element
|
|
74
|
+
*/
|
|
75
|
+
elementRef: PropTypes.func,
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
79
|
+
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
80
|
+
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
81
|
+
*/
|
|
82
|
+
margin: ThemeablePropTypes.spacing,
|
|
83
|
+
/**
|
|
84
|
+
* Valid values are `0`, `none`, `xxx-small`, `xx-small`, `x-small`,
|
|
85
|
+
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
86
|
+
* familiar CSS-like shorthand. For example: `padding="small x-large large"`.
|
|
87
|
+
*/
|
|
88
|
+
padding: ThemeablePropTypes.spacing,
|
|
89
|
+
|
|
90
|
+
height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
91
|
+
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
92
|
+
maxHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
93
|
+
maxWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
94
|
+
minHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
95
|
+
minWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* The children to render inside the `<ContextView />`
|
|
99
|
+
*/
|
|
100
|
+
children: PropTypes.node,
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Designates the text alignment within the `<ContextView />`
|
|
104
|
+
*/
|
|
105
|
+
textAlign: PropTypes.oneOf(['start', 'center', 'end']),
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Controls the shadow depth for the `<ContextView />`
|
|
109
|
+
*/
|
|
110
|
+
shadow: ThemeablePropTypes.shadow,
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Controls the z-index depth for the `<ContextView />`
|
|
114
|
+
*/
|
|
115
|
+
stacking: ThemeablePropTypes.stacking,
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Designates the background style of the `<ContextView />`
|
|
119
|
+
*/
|
|
120
|
+
background: PropTypes.oneOf(['default', 'inverse']),
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Specifies how the arrow for `<ContextView />` will be rendered.
|
|
124
|
+
* Ex. `placement="top"` will render with an arrow pointing down.
|
|
125
|
+
*/
|
|
126
|
+
placement: PositionPropTypes.placement,
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Activate an outline around the component to make building your
|
|
130
|
+
* layout easier
|
|
131
|
+
*/
|
|
132
|
+
debug: PropTypes.bool
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const allowedProps: AllowedPropKeys = [
|
|
136
|
+
'as',
|
|
137
|
+
'elementRef',
|
|
138
|
+
'margin',
|
|
139
|
+
'padding',
|
|
140
|
+
'height',
|
|
141
|
+
'width',
|
|
142
|
+
'maxHeight',
|
|
143
|
+
'maxWidth',
|
|
144
|
+
'minHeight',
|
|
145
|
+
'minWidth',
|
|
146
|
+
'children',
|
|
147
|
+
'textAlign',
|
|
148
|
+
'shadow',
|
|
149
|
+
'stacking',
|
|
150
|
+
'background',
|
|
151
|
+
'placement',
|
|
152
|
+
'debug'
|
|
153
|
+
]
|
|
154
|
+
|
|
155
|
+
export type { ContextViewProps }
|
|
156
|
+
export { propTypes, allowedProps }
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
import { mirrorPlacement } from '@instructure/ui-position'
|
|
26
26
|
import type { PlacementPropValues } from '@instructure/ui-position'
|
|
27
27
|
import { ContextViewTheme } from '@instructure/shared-types'
|
|
28
|
-
import { ContextViewProps } from './
|
|
28
|
+
import { ContextViewProps } from './props'
|
|
29
29
|
|
|
30
30
|
type PlacementArray = PlacementPropValues[]
|
|
31
31
|
|
|
@@ -279,7 +279,7 @@ const generateStyle = (
|
|
|
279
279
|
}
|
|
280
280
|
|
|
281
281
|
const arrowPlacementVariant = getArrowPlacementVariant(
|
|
282
|
-
placement
|
|
282
|
+
placement!,
|
|
283
283
|
background,
|
|
284
284
|
componentTheme
|
|
285
285
|
)
|
|
@@ -289,7 +289,7 @@ const generateStyle = (
|
|
|
289
289
|
label: 'contextView',
|
|
290
290
|
boxSizing: 'border-box',
|
|
291
291
|
minHeight: `calc(${componentTheme?.arrowSize} * 2)`,
|
|
292
|
-
...getPlacementStyle(placement
|
|
292
|
+
...getPlacementStyle(placement!, componentTheme)
|
|
293
293
|
},
|
|
294
294
|
contextView__content: {
|
|
295
295
|
label: 'contextView__content',
|
|
@@ -302,7 +302,7 @@ const generateStyle = (
|
|
|
302
302
|
borderWidth: `calc(${componentTheme?.arrowSize} + ${componentTheme?.arrowBorderWidth})`,
|
|
303
303
|
borderColor: arrowBackGroundVariants[background!],
|
|
304
304
|
...arrowPlacementVariant.main,
|
|
305
|
-
...getArrowCorrections(placement
|
|
305
|
+
...getArrowCorrections(placement!, componentTheme),
|
|
306
306
|
'&::after': {
|
|
307
307
|
borderWidth: componentTheme?.arrowSize,
|
|
308
308
|
borderColor: arrowBackGroundVariants[background!],
|
package/src/View/index.tsx
CHANGED
|
@@ -35,11 +35,13 @@ import {
|
|
|
35
35
|
passthroughProps
|
|
36
36
|
} from '@instructure/ui-react-utils'
|
|
37
37
|
import { jsx, withStyle } from '@instructure/emotion'
|
|
38
|
-
import { OtherHTMLAttributes } from '@instructure/shared-types'
|
|
38
|
+
import type { OtherHTMLAttributes } from '@instructure/shared-types'
|
|
39
39
|
|
|
40
40
|
import generateStyle from './styles'
|
|
41
41
|
import generateComponentTheme from './theme'
|
|
42
|
-
|
|
42
|
+
|
|
43
|
+
import { propTypes, allowedProps } from './props'
|
|
44
|
+
import type { ViewProps } from './props'
|
|
43
45
|
|
|
44
46
|
/**
|
|
45
47
|
---
|
|
@@ -67,7 +69,7 @@ class View extends Component<ViewProps & OtherHTMLAttributes<ViewProps>> {
|
|
|
67
69
|
focusPosition: 'offset',
|
|
68
70
|
focusColor: 'info',
|
|
69
71
|
shouldAnimateFocus: true
|
|
70
|
-
}
|
|
72
|
+
} as const
|
|
71
73
|
|
|
72
74
|
// TODO: Remove this code once all components are using passthroughProps in place
|
|
73
75
|
// of omitProps and have removed this function
|
|
@@ -89,12 +91,21 @@ class View extends Component<ViewProps & OtherHTMLAttributes<ViewProps>> {
|
|
|
89
91
|
props: Record<string, any>,
|
|
90
92
|
Component: ComponentType<any>
|
|
91
93
|
) => {
|
|
94
|
+
// We don't want the theming and styling props to pass
|
|
95
|
+
// (these are added and handled by the `@withStyle` decorator)
|
|
96
|
+
const propsToOmit = [
|
|
97
|
+
...View.allowedProps,
|
|
98
|
+
'styles',
|
|
99
|
+
'makeStyles',
|
|
100
|
+
'themeOverride'
|
|
101
|
+
]
|
|
102
|
+
|
|
92
103
|
if (process.env.NODE_ENV !== 'production') {
|
|
93
|
-
Object.keys(pickProps(props,
|
|
104
|
+
Object.keys(pickProps(props, propsToOmit)).forEach((prop) => {
|
|
94
105
|
error(false, `[${Component.name}] prop '${prop}' is not allowed.`)
|
|
95
106
|
})
|
|
96
107
|
}
|
|
97
|
-
return omitProps(props,
|
|
108
|
+
return omitProps(props, propsToOmit)
|
|
98
109
|
}
|
|
99
110
|
|
|
100
111
|
private spanMarginVerified: boolean
|
|
@@ -199,9 +210,11 @@ class View extends Component<ViewProps & OtherHTMLAttributes<ViewProps>> {
|
|
|
199
210
|
|
|
200
211
|
return (
|
|
201
212
|
<ElementType
|
|
213
|
+
//@ts-expect-error TODO: `ref` prop causes: "Expression produces a union type that is too complex to represent.ts(2590)"
|
|
202
214
|
{...passthroughProps(props)}
|
|
203
215
|
className={className}
|
|
204
216
|
css={styles?.view}
|
|
217
|
+
//@ts-expect-error TODO: null not assignable
|
|
205
218
|
style={styles?.inlineStyles}
|
|
206
219
|
ref={this.handleElementRef}
|
|
207
220
|
>
|