@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,240 @@
|
|
|
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 { Component, ComponentType } from 'react'
|
|
26
|
+
|
|
27
|
+
import { getCSSStyleDeclaration } from '@instructure/ui-dom-utils'
|
|
28
|
+
import { textDirectionContextConsumer } from '@instructure/ui-i18n'
|
|
29
|
+
import { logError as error } from '@instructure/console'
|
|
30
|
+
import {
|
|
31
|
+
getElementType,
|
|
32
|
+
omitProps,
|
|
33
|
+
pickProps,
|
|
34
|
+
passthroughProps
|
|
35
|
+
} from '@instructure/ui-react-utils'
|
|
36
|
+
import { withStyle } from '@instructure/emotion'
|
|
37
|
+
|
|
38
|
+
import generateStyle from './styles'
|
|
39
|
+
|
|
40
|
+
import { allowedProps } from './props'
|
|
41
|
+
import type { ViewProps } from './props'
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
---
|
|
45
|
+
category: components
|
|
46
|
+
---
|
|
47
|
+
@module View
|
|
48
|
+
**/
|
|
49
|
+
@textDirectionContextConsumer()
|
|
50
|
+
@withStyle(generateStyle)
|
|
51
|
+
class View extends Component<ViewProps> {
|
|
52
|
+
static componentId = 'View'
|
|
53
|
+
static allowedProps = allowedProps
|
|
54
|
+
static defaultProps = {
|
|
55
|
+
display: 'auto',
|
|
56
|
+
overflowX: 'visible',
|
|
57
|
+
overflowY: 'visible',
|
|
58
|
+
withVisualDebug: false,
|
|
59
|
+
borderColor: 'primary',
|
|
60
|
+
position: 'static',
|
|
61
|
+
focusPosition: 'offset',
|
|
62
|
+
focusColor: 'info',
|
|
63
|
+
shouldAnimateFocus: true,
|
|
64
|
+
overscrollBehavior: 'auto'
|
|
65
|
+
} as const
|
|
66
|
+
|
|
67
|
+
// TODO: Remove this code once all components are using passthroughProps in place
|
|
68
|
+
// of omitProps and have removed this function
|
|
69
|
+
|
|
70
|
+
// omitViewProps needs to be called on the composed View component so that the
|
|
71
|
+
// View.allowedProps in the method matches the View.allowedProps that will be called in
|
|
72
|
+
// the consumers. Otherwise the discrepancy could cause unexpected props being
|
|
73
|
+
// allowed through.
|
|
74
|
+
|
|
75
|
+
// Removes View's own props from the given object. Automatically excludes the
|
|
76
|
+
// following props: 'theme', 'children', 'className', 'style', 'styles',
|
|
77
|
+
// 'makeStyles', 'themeOverride'
|
|
78
|
+
// @param props the object to process
|
|
79
|
+
// @param Component The component whose props are processed.
|
|
80
|
+
// Only needed for debug logging in non-production builds.
|
|
81
|
+
static omitViewProps = (
|
|
82
|
+
props: Record<string, any>,
|
|
83
|
+
Component: ComponentType<any>
|
|
84
|
+
) => {
|
|
85
|
+
// We don't want the theming and styling props to pass
|
|
86
|
+
// (these are added and handled by the `@withStyle` decorator)
|
|
87
|
+
const propsToOmit = [
|
|
88
|
+
...View.allowedProps,
|
|
89
|
+
'styles',
|
|
90
|
+
'makeStyles',
|
|
91
|
+
'themeOverride'
|
|
92
|
+
]
|
|
93
|
+
|
|
94
|
+
let shouldLogError = true
|
|
95
|
+
try {
|
|
96
|
+
shouldLogError =
|
|
97
|
+
process.env.NODE_ENV !== 'production' ||
|
|
98
|
+
process.env.GITHUB_PULL_REQUEST_PREVIEW === 'true'
|
|
99
|
+
} catch (e) {
|
|
100
|
+
if (e instanceof ReferenceError) {
|
|
101
|
+
// if process is not available a ReferenceError is thrown
|
|
102
|
+
shouldLogError = false
|
|
103
|
+
} else {
|
|
104
|
+
throw e
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (shouldLogError) {
|
|
109
|
+
Object.keys(pickProps(props, propsToOmit)).forEach((prop) => {
|
|
110
|
+
error(false, `[${Component.name}] prop '${prop}' is not allowed.`)
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
return omitProps(props, propsToOmit)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
private spanMarginVerified: boolean
|
|
117
|
+
get _element() {
|
|
118
|
+
console.warn(
|
|
119
|
+
'_element property is deprecated and will be removed in v9, please use ref instead'
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
return this.ref
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
constructor(props: ViewProps) {
|
|
126
|
+
super(props)
|
|
127
|
+
this.spanMarginVerified = false
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
componentDidMount() {
|
|
131
|
+
this.props.makeStyles?.()
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
componentDidUpdate() {
|
|
135
|
+
this.props.makeStyles?.()
|
|
136
|
+
|
|
137
|
+
// Not calling getCSSStyleDeclaration can save hundreds of ms in tests and production
|
|
138
|
+
if (process.env.NODE_ENV === 'development' && !this.spanMarginVerified) {
|
|
139
|
+
// We have to verify margins in the first 'componentDidUpdate',
|
|
140
|
+
// because that is when all styles are calculated,
|
|
141
|
+
// but we only want to check once, using a flag
|
|
142
|
+
this.spanMarginVerified = true
|
|
143
|
+
|
|
144
|
+
error(
|
|
145
|
+
!(function verifySpanMargin(element, margin) {
|
|
146
|
+
if (!element) {
|
|
147
|
+
return
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const display = getCSSStyleDeclaration(element)?.display
|
|
151
|
+
|
|
152
|
+
if (display !== 'inline') {
|
|
153
|
+
return
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const marginValues = margin ? margin.split(' ') : null
|
|
157
|
+
let verticalMargin = false
|
|
158
|
+
|
|
159
|
+
// either top or bottom margin are set
|
|
160
|
+
if (margin) {
|
|
161
|
+
if (
|
|
162
|
+
marginValues &&
|
|
163
|
+
marginValues[0] &&
|
|
164
|
+
marginValues[0] !== 'none' &&
|
|
165
|
+
marginValues[0] !== '0'
|
|
166
|
+
) {
|
|
167
|
+
verticalMargin = true
|
|
168
|
+
}
|
|
169
|
+
if (
|
|
170
|
+
marginValues &&
|
|
171
|
+
marginValues[2] &&
|
|
172
|
+
marginValues[2] !== 'none' &&
|
|
173
|
+
marginValues[2] !== '0'
|
|
174
|
+
) {
|
|
175
|
+
verticalMargin = true
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return verticalMargin
|
|
180
|
+
})(this.ref, this.props.margin),
|
|
181
|
+
`[View] display style is set to 'inline' and will allow for horizontal margins only.`
|
|
182
|
+
)
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
ref: Element | null = null
|
|
187
|
+
|
|
188
|
+
handleElementRef = (el: HTMLElement | null) => {
|
|
189
|
+
if (typeof this.props.elementRef === 'function') {
|
|
190
|
+
this.props.elementRef(el)
|
|
191
|
+
}
|
|
192
|
+
this.ref = el
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
render() {
|
|
196
|
+
const {
|
|
197
|
+
children,
|
|
198
|
+
textAlign,
|
|
199
|
+
background,
|
|
200
|
+
display,
|
|
201
|
+
withVisualDebug,
|
|
202
|
+
width,
|
|
203
|
+
height,
|
|
204
|
+
minWidth,
|
|
205
|
+
minHeight,
|
|
206
|
+
maxWidth,
|
|
207
|
+
maxHeight,
|
|
208
|
+
overflowX,
|
|
209
|
+
overflowY,
|
|
210
|
+
stacking,
|
|
211
|
+
shadow,
|
|
212
|
+
position,
|
|
213
|
+
focusPosition,
|
|
214
|
+
focusColor,
|
|
215
|
+
shouldAnimateFocus,
|
|
216
|
+
borderColor,
|
|
217
|
+
className,
|
|
218
|
+
overscrollBehavior,
|
|
219
|
+
styles,
|
|
220
|
+
makeStyles,
|
|
221
|
+
...props
|
|
222
|
+
} = this.props
|
|
223
|
+
|
|
224
|
+
const ElementType = getElementType(View, this.props)
|
|
225
|
+
|
|
226
|
+
return (
|
|
227
|
+
<ElementType
|
|
228
|
+
{...passthroughProps(props)}
|
|
229
|
+
className={className}
|
|
230
|
+
css={[styles?.view, styles?.inlineStyles]}
|
|
231
|
+
ref={this.handleElementRef}
|
|
232
|
+
>
|
|
233
|
+
{children}
|
|
234
|
+
</ElementType>
|
|
235
|
+
)
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export default View
|
|
240
|
+
export { View }
|
|
@@ -0,0 +1,278 @@
|
|
|
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 type { Cursor } from '@instructure/shared-types'
|
|
27
|
+
import type {
|
|
28
|
+
AsElementType,
|
|
29
|
+
OtherHTMLAttributes,
|
|
30
|
+
ViewTheme
|
|
31
|
+
} from '@instructure/shared-types'
|
|
32
|
+
import type {
|
|
33
|
+
WithStyleProps,
|
|
34
|
+
Spacing,
|
|
35
|
+
BorderWidth,
|
|
36
|
+
BorderRadii,
|
|
37
|
+
Shadow,
|
|
38
|
+
Stacking,
|
|
39
|
+
ComponentStyle,
|
|
40
|
+
StyleObject
|
|
41
|
+
} from '@instructure/emotion'
|
|
42
|
+
|
|
43
|
+
type BorderColor =
|
|
44
|
+
| string
|
|
45
|
+
| 'transparent'
|
|
46
|
+
| 'primary'
|
|
47
|
+
| 'secondary'
|
|
48
|
+
| 'brand'
|
|
49
|
+
| 'info'
|
|
50
|
+
| 'success'
|
|
51
|
+
| 'warning'
|
|
52
|
+
| 'alert'
|
|
53
|
+
| 'danger'
|
|
54
|
+
|
|
55
|
+
type ViewOwnProps = {
|
|
56
|
+
/**
|
|
57
|
+
* The element to render as the component root, `span` by default
|
|
58
|
+
*/
|
|
59
|
+
as?: AsElementType
|
|
60
|
+
/**
|
|
61
|
+
* provides a reference to the underlying html element
|
|
62
|
+
*/
|
|
63
|
+
elementRef?: (element: HTMLElement | null) => void
|
|
64
|
+
/**
|
|
65
|
+
* By default the display prop is 'auto', meaning it takes on the
|
|
66
|
+
* display rules of the html element it's rendered as (see `as` prop).
|
|
67
|
+
*/
|
|
68
|
+
display?:
|
|
69
|
+
| 'auto'
|
|
70
|
+
| 'inline'
|
|
71
|
+
| 'block'
|
|
72
|
+
| 'inline-block'
|
|
73
|
+
| 'flex'
|
|
74
|
+
| 'inline-flex'
|
|
75
|
+
| 'contents'
|
|
76
|
+
// these are global CSS values
|
|
77
|
+
| 'inherit' // inherit the parent's display value
|
|
78
|
+
| 'initial' // reset the property back to the spec default
|
|
79
|
+
| 'revert' // reset to user agent stylesheet
|
|
80
|
+
| 'revert-layer'
|
|
81
|
+
| 'unset' // same as initial
|
|
82
|
+
overflowX?: 'auto' | 'hidden' | 'visible'
|
|
83
|
+
overflowY?: 'auto' | 'hidden' | 'visible'
|
|
84
|
+
height?: string | number
|
|
85
|
+
width?: string | number
|
|
86
|
+
maxHeight?: string | number
|
|
87
|
+
maxWidth?: string | number
|
|
88
|
+
minHeight?: string | number
|
|
89
|
+
minWidth?: string | number
|
|
90
|
+
/**
|
|
91
|
+
* The children to render inside the <View />
|
|
92
|
+
*/
|
|
93
|
+
children?: React.ReactNode
|
|
94
|
+
/**
|
|
95
|
+
* Designates the text alignment within the `<View />`
|
|
96
|
+
*/
|
|
97
|
+
textAlign?: 'start' | 'center' | 'end'
|
|
98
|
+
/**
|
|
99
|
+
* Sets the color of the View border.
|
|
100
|
+
* Accepts a color string value (e.g., "#FFFFFF", "red") or one of the predefined theme color options.
|
|
101
|
+
*/
|
|
102
|
+
borderColor?: BorderColor
|
|
103
|
+
/**
|
|
104
|
+
* Designates the background style of the `<View />`
|
|
105
|
+
*/
|
|
106
|
+
background?:
|
|
107
|
+
| 'transparent'
|
|
108
|
+
| 'primary'
|
|
109
|
+
| 'secondary'
|
|
110
|
+
| 'primary-inverse'
|
|
111
|
+
| 'brand'
|
|
112
|
+
| 'info'
|
|
113
|
+
| 'alert'
|
|
114
|
+
| 'success'
|
|
115
|
+
| 'danger'
|
|
116
|
+
| 'warning'
|
|
117
|
+
/**
|
|
118
|
+
* Specify a value for the CSS position property. Use `relative` if `focusable` will be true.
|
|
119
|
+
*/
|
|
120
|
+
position?: 'static' | 'absolute' | 'relative' | 'sticky' | 'fixed'
|
|
121
|
+
/**
|
|
122
|
+
* The `left` CSS property in left-to-right interfaces. Will not do anything if `position === "static"`.
|
|
123
|
+
*/
|
|
124
|
+
insetInlineStart?: string
|
|
125
|
+
/**
|
|
126
|
+
* The `right` CSS property in left-to-right interfaces. Will not do anything if `position === "static"`.
|
|
127
|
+
*/
|
|
128
|
+
insetInlineEnd?: string
|
|
129
|
+
/**
|
|
130
|
+
* The `top` CSS property. Will not do anything if `position === "static"`.
|
|
131
|
+
*/
|
|
132
|
+
insetBlockStart?: string
|
|
133
|
+
/**
|
|
134
|
+
* The `bottom` CSS property. Will not do anything if `position === "static"`.
|
|
135
|
+
*/
|
|
136
|
+
insetBlockEnd?: string
|
|
137
|
+
/**
|
|
138
|
+
* Manually control if the `View` should display a focus outline.
|
|
139
|
+
*
|
|
140
|
+
* When left `undefined` (which is the default) the focus outline will display
|
|
141
|
+
* automatically if the `View` is focusable and receives focus.
|
|
142
|
+
*/
|
|
143
|
+
withFocusOutline?: boolean
|
|
144
|
+
/**
|
|
145
|
+
* Determines whether the focus outline displays offset or inset from the focused View
|
|
146
|
+
*/
|
|
147
|
+
focusPosition?: 'offset' | 'inset'
|
|
148
|
+
/**
|
|
149
|
+
* Determines the color of the focus outline
|
|
150
|
+
*/
|
|
151
|
+
focusColor?: 'info' | 'inverse' | 'success' | 'danger'
|
|
152
|
+
/**
|
|
153
|
+
* Determines if the focus ring should animate when it appears
|
|
154
|
+
*/
|
|
155
|
+
shouldAnimateFocus?: boolean
|
|
156
|
+
/**
|
|
157
|
+
* Activate a dotted outline around the component to make building your
|
|
158
|
+
* layout easier
|
|
159
|
+
*/
|
|
160
|
+
withVisualDebug?: boolean
|
|
161
|
+
|
|
162
|
+
dir?: 'ltr' | 'rtl'
|
|
163
|
+
/**
|
|
164
|
+
* Valid values are `0`, `none`, `auto`, and Spacing token values,
|
|
165
|
+
* see https://instructure.design/layout-spacing. Apply these values via
|
|
166
|
+
* familiar CSS-like shorthand. For example, `margin="small auto large"`.
|
|
167
|
+
*/
|
|
168
|
+
margin?: Spacing
|
|
169
|
+
/**
|
|
170
|
+
* Valid values are `0`, `none`, `auto`, and Spacing token values,
|
|
171
|
+
* see https://instructure.design/layout-spacing. Apply these values via
|
|
172
|
+
* familiar CSS-like shorthand. For example, `padding="small auto large"`.
|
|
173
|
+
*/
|
|
174
|
+
padding?: Spacing
|
|
175
|
+
/**
|
|
176
|
+
* Accepts the familiar CSS shorthand to designate border widths corresponding
|
|
177
|
+
* to edges
|
|
178
|
+
*/
|
|
179
|
+
borderWidth?: BorderWidth
|
|
180
|
+
/**
|
|
181
|
+
* Accepts `small`, `medium`, `large`, `circle`, and `pill`. Border radius can be
|
|
182
|
+
* assigned to individual corners in CSS shorthand style (e.g., `"medium large none pill"`).
|
|
183
|
+
* Also accepts valid CSS length values like `1rem` or `12px`
|
|
184
|
+
*/
|
|
185
|
+
borderRadius?: BorderRadii
|
|
186
|
+
/**
|
|
187
|
+
* Controls the shadow depth for the `<View />`
|
|
188
|
+
*/
|
|
189
|
+
shadow?: Shadow
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Controls the z-index depth for the `<View />`
|
|
193
|
+
*/
|
|
194
|
+
stacking?: Stacking
|
|
195
|
+
/**
|
|
196
|
+
* Specify a mouse cursor to use when hovering over the `<View />`
|
|
197
|
+
*/
|
|
198
|
+
cursor?: Cursor
|
|
199
|
+
/**
|
|
200
|
+
* Sets what a browser does when reaching the boundary of a scrolling area.
|
|
201
|
+
* Valid values are `auto`, `contain`, `none`.
|
|
202
|
+
*/
|
|
203
|
+
overscrollBehavior?: 'auto' | 'contain' | 'none'
|
|
204
|
+
/**
|
|
205
|
+
* DEPRECATED, this prop does nothing. Use the focusOutlineOffset theme
|
|
206
|
+
* variable
|
|
207
|
+
*
|
|
208
|
+
* Sets the radius of the focus border ring.
|
|
209
|
+
*
|
|
210
|
+
* For offset type, the given value is increased by the difference between the focus ring' offset and the focus ring's width.
|
|
211
|
+
*
|
|
212
|
+
* For inset type, the given value is decreased by the sum of the focus ring' offset and the focus ring's width.
|
|
213
|
+
*/
|
|
214
|
+
focusRingBorderRadius?: string
|
|
215
|
+
/**
|
|
216
|
+
* Display the focus ring when any of the descendants is focused.
|
|
217
|
+
* (uses the [:focus-within](https://developer.mozilla.org/en-US/docs/Web/CSS/:focus-within)
|
|
218
|
+
* CSS selector)
|
|
219
|
+
*/
|
|
220
|
+
focusWithin?: boolean
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
type PropKeys = keyof ViewOwnProps
|
|
224
|
+
|
|
225
|
+
type ViewProps = ViewOwnProps &
|
|
226
|
+
WithStyleProps<ViewTheme, ViewStyle> &
|
|
227
|
+
OtherHTMLAttributes<ViewOwnProps>
|
|
228
|
+
|
|
229
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
230
|
+
|
|
231
|
+
type ViewStyle = ComponentStyle<'view'> & {
|
|
232
|
+
inlineStyles: StyleObject
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// This variable will be attached as static property on the `View` component
|
|
236
|
+
// so we don't rely on the `PropTypes` validators for our internal logic.
|
|
237
|
+
// This means on prod builds the consuming applications can safely delete propTypes.
|
|
238
|
+
const allowedProps: AllowedPropKeys = [
|
|
239
|
+
'as',
|
|
240
|
+
'background',
|
|
241
|
+
'borderColor',
|
|
242
|
+
'borderRadius',
|
|
243
|
+
'borderWidth',
|
|
244
|
+
'children',
|
|
245
|
+
'cursor',
|
|
246
|
+
'dir',
|
|
247
|
+
'display',
|
|
248
|
+
'elementRef',
|
|
249
|
+
'focusColor',
|
|
250
|
+
'focusPosition',
|
|
251
|
+
'height',
|
|
252
|
+
'insetBlockEnd',
|
|
253
|
+
'insetBlockStart',
|
|
254
|
+
'insetInlineEnd',
|
|
255
|
+
'insetInlineStart',
|
|
256
|
+
'margin',
|
|
257
|
+
'maxHeight',
|
|
258
|
+
'maxWidth',
|
|
259
|
+
'minHeight',
|
|
260
|
+
'minWidth',
|
|
261
|
+
'overflowX',
|
|
262
|
+
'overflowY',
|
|
263
|
+
'overscrollBehavior',
|
|
264
|
+
'padding',
|
|
265
|
+
'position',
|
|
266
|
+
'shadow',
|
|
267
|
+
'shouldAnimateFocus',
|
|
268
|
+
'stacking',
|
|
269
|
+
'textAlign',
|
|
270
|
+
'width',
|
|
271
|
+
'withFocusOutline',
|
|
272
|
+
'withVisualDebug',
|
|
273
|
+
'focusRingBorderRadius',
|
|
274
|
+
'focusWithin'
|
|
275
|
+
]
|
|
276
|
+
|
|
277
|
+
export { allowedProps }
|
|
278
|
+
export type { ViewProps, ViewOwnProps, ViewStyle, BorderColor }
|