@instructure/ui-modal 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/Modal/ModalBody/index.js +7 -18
- package/{src/Modal/ModalBody/types.ts → es/Modal/ModalBody/props.js} +12 -13
- package/es/Modal/ModalFooter/index.js +5 -10
- package/{src/Modal/ModalFooter/types.ts → es/Modal/ModalFooter/props.js} +7 -6
- package/es/Modal/ModalHeader/index.js +5 -10
- package/{src/Modal/ModalHeader/types.ts → es/Modal/ModalHeader/props.js} +7 -10
- package/es/Modal/index.js +6 -134
- package/es/Modal/props.js +157 -0
- package/lib/Modal/ModalBody/index.js +7 -18
- package/lib/Modal/ModalBody/props.js +47 -0
- package/lib/Modal/ModalFooter/index.js +6 -11
- package/lib/Modal/ModalFooter/props.js +41 -0
- package/lib/Modal/ModalHeader/index.js +6 -11
- package/lib/Modal/ModalHeader/props.js +41 -0
- package/lib/Modal/index.js +7 -138
- package/lib/Modal/props.js +175 -0
- package/package.json +21 -22
- package/src/Modal/ModalBody/index.tsx +8 -21
- package/src/Modal/{types.ts → ModalBody/props.ts} +38 -31
- package/src/Modal/ModalBody/styles.ts +1 -1
- package/src/Modal/ModalFooter/index.tsx +6 -13
- package/src/Modal/ModalFooter/props.ts +50 -0
- package/src/Modal/ModalFooter/styles.ts +1 -1
- package/src/Modal/ModalHeader/index.tsx +6 -13
- package/src/Modal/ModalHeader/props.ts +54 -0
- package/src/Modal/ModalHeader/styles.ts +1 -1
- package/src/Modal/index.tsx +7 -145
- package/src/Modal/props.ts +238 -0
- package/src/Modal/styles.ts +1 -1
- package/src/index.ts +4 -4
- package/types/Modal/ModalBody/index.d.ts +27 -14
- package/types/Modal/ModalBody/index.d.ts.map +1 -1
- package/types/Modal/ModalBody/props.d.ts +19 -0
- package/types/Modal/ModalBody/props.d.ts.map +1 -0
- package/types/Modal/ModalBody/styles.d.ts +1 -1
- package/types/Modal/ModalFooter/index.d.ts +9 -8
- package/types/Modal/ModalFooter/index.d.ts.map +1 -1
- package/types/Modal/ModalFooter/props.d.ts +15 -0
- package/types/Modal/ModalFooter/props.d.ts.map +1 -0
- package/types/Modal/ModalFooter/styles.d.ts +1 -1
- package/types/Modal/ModalHeader/index.d.ts +10 -9
- package/types/Modal/ModalHeader/index.d.ts.map +1 -1
- package/types/Modal/ModalHeader/props.d.ts +18 -0
- package/types/Modal/ModalHeader/props.d.ts.map +1 -0
- package/types/Modal/ModalHeader/styles.d.ts +1 -1
- package/types/Modal/index.d.ts +55 -110
- package/types/Modal/index.d.ts.map +1 -1
- package/types/Modal/{types.d.ts → props.d.ts} +13 -6
- package/types/Modal/{types.d.ts.map → props.d.ts.map} +1 -1
- package/types/Modal/styles.d.ts +1 -1
- package/types/index.d.ts +4 -4
- package/LICENSE.md +0 -27
- package/es/Modal/ModalBody/types.js +0 -1
- package/es/Modal/ModalFooter/types.js +0 -1
- package/es/Modal/ModalHeader/types.js +0 -1
- package/es/Modal/types.js +0 -1
- package/lib/Modal/ModalBody/types.js +0 -1
- package/lib/Modal/ModalFooter/types.js +0 -1
- package/lib/Modal/ModalHeader/types.js +0 -1
- package/lib/Modal/types.js +0 -1
- package/types/Modal/ModalBody/types.d.ts +0 -12
- package/types/Modal/ModalBody/types.d.ts.map +0 -1
- package/types/Modal/ModalFooter/types.d.ts +0 -6
- package/types/Modal/ModalFooter/types.d.ts.map +0 -1
- package/types/Modal/ModalHeader/types.d.ts +0 -9
- package/types/Modal/ModalHeader/types.d.ts.map +0 -1
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
|
|
25
25
|
/** @jsx jsx */
|
|
26
26
|
import React, { Component } from 'react'
|
|
27
|
-
import PropTypes from 'prop-types'
|
|
28
27
|
|
|
29
28
|
import {
|
|
30
29
|
matchComponentTypes,
|
|
@@ -36,7 +35,9 @@ import { withStyle, jsx } from '@instructure/emotion'
|
|
|
36
35
|
|
|
37
36
|
import generateStyle from './styles'
|
|
38
37
|
import generateComponentTheme from './theme'
|
|
39
|
-
|
|
38
|
+
|
|
39
|
+
import { propTypes, allowedProps } from './props'
|
|
40
|
+
import type { ModalHeaderProps, ModalHeaderStyleProps } from './props'
|
|
40
41
|
|
|
41
42
|
/**
|
|
42
43
|
---
|
|
@@ -49,16 +50,8 @@ id: Modal.Header
|
|
|
49
50
|
class ModalHeader extends Component<ModalHeaderProps> {
|
|
50
51
|
static readonly componentId = 'Modal.Header'
|
|
51
52
|
|
|
52
|
-
static propTypes =
|
|
53
|
-
|
|
54
|
-
variant: PropTypes.oneOf(['default', 'inverse']),
|
|
55
|
-
|
|
56
|
-
// eslint-disable-next-line react/require-default-props
|
|
57
|
-
makeStyles: PropTypes.func,
|
|
58
|
-
// eslint-disable-next-line react/require-default-props
|
|
59
|
-
styles: PropTypes.object
|
|
60
|
-
}
|
|
61
|
-
|
|
53
|
+
static propTypes = propTypes
|
|
54
|
+
static allowedProps = allowedProps
|
|
62
55
|
static defaultProps = {
|
|
63
56
|
children: null,
|
|
64
57
|
variant: 'default'
|
|
@@ -95,7 +88,7 @@ class ModalHeader extends Component<ModalHeaderProps> {
|
|
|
95
88
|
const { children, ...rest } = this.props
|
|
96
89
|
|
|
97
90
|
return (
|
|
98
|
-
<div css={this.props.styles
|
|
91
|
+
<div css={this.props.styles?.modalHeader} {...passthroughProps(rest)}>
|
|
99
92
|
{children}
|
|
100
93
|
</div>
|
|
101
94
|
)
|
|
@@ -0,0 +1,54 @@
|
|
|
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 type { PropValidators } from '@instructure/shared-types'
|
|
29
|
+
import type { WithStyleProps } from '@instructure/emotion'
|
|
30
|
+
|
|
31
|
+
type ModalHeaderOwnProps = {
|
|
32
|
+
children?: React.ReactNode
|
|
33
|
+
variant?: 'default' | 'inverse'
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
type ModalHeaderStyleProps = {
|
|
37
|
+
withCloseButton: boolean
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
type PropKeys = keyof ModalHeaderOwnProps
|
|
41
|
+
|
|
42
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
43
|
+
|
|
44
|
+
type ModalHeaderProps = ModalHeaderOwnProps & WithStyleProps
|
|
45
|
+
|
|
46
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
47
|
+
children: PropTypes.node,
|
|
48
|
+
variant: PropTypes.oneOf(['default', 'inverse'])
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const allowedProps: AllowedPropKeys = ['children', 'variant']
|
|
52
|
+
|
|
53
|
+
export type { ModalHeaderProps, ModalHeaderStyleProps }
|
|
54
|
+
export { propTypes, allowedProps }
|
package/src/Modal/index.tsx
CHANGED
|
@@ -24,13 +24,8 @@
|
|
|
24
24
|
|
|
25
25
|
/** @jsx jsx */
|
|
26
26
|
import { Children, Component, ReactElement } from 'react'
|
|
27
|
-
import PropTypes from 'prop-types'
|
|
28
27
|
|
|
29
28
|
import { Dialog } from '@instructure/ui-dialog'
|
|
30
|
-
import {
|
|
31
|
-
element,
|
|
32
|
-
Children as ChildrenPropTypes
|
|
33
|
-
} from '@instructure/ui-prop-types'
|
|
34
29
|
import {
|
|
35
30
|
passthroughProps,
|
|
36
31
|
safeCloneElement,
|
|
@@ -49,7 +44,9 @@ import { ModalFooter } from './ModalFooter'
|
|
|
49
44
|
|
|
50
45
|
import generateStyle from './styles'
|
|
51
46
|
import generateComponentTheme from './theme'
|
|
52
|
-
|
|
47
|
+
|
|
48
|
+
import { propTypes, allowedProps } from './props'
|
|
49
|
+
import type { ModalProps } from './props'
|
|
53
50
|
|
|
54
51
|
/**
|
|
55
52
|
---
|
|
@@ -62,143 +59,8 @@ tags: overlay, portal, dialog
|
|
|
62
59
|
class Modal extends Component<ModalProps> {
|
|
63
60
|
static readonly componentId = 'Modal'
|
|
64
61
|
|
|
65
|
-
static propTypes =
|
|
66
|
-
|
|
67
|
-
* An accessible label for the `<Modal />` content
|
|
68
|
-
*/
|
|
69
|
-
label: PropTypes.string.isRequired,
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* The children to be rendered within the `<Modal />`
|
|
73
|
-
*/
|
|
74
|
-
children: ChildrenPropTypes.enforceOrder(
|
|
75
|
-
[ModalHeader, ModalBody, ModalFooter],
|
|
76
|
-
[ModalHeader, ModalBody],
|
|
77
|
-
[ModalBody, ModalFooter],
|
|
78
|
-
[ModalBody]
|
|
79
|
-
),
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* The element to render the dialog as, `span` by default
|
|
83
|
-
*/
|
|
84
|
-
as: PropTypes.elementType,
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* The size of the `<Modal />` content
|
|
88
|
-
*/
|
|
89
|
-
size: PropTypes.oneOf(['auto', 'small', 'medium', 'large', 'fullscreen']),
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Designates the background style of the `<Modal />`
|
|
93
|
-
*/
|
|
94
|
-
variant: PropTypes.oneOf(['default', 'inverse']),
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Whether or not the `<Modal />` is open
|
|
98
|
-
*/
|
|
99
|
-
open: PropTypes.bool,
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* An element or a function returning an element to focus by default
|
|
103
|
-
*/
|
|
104
|
-
defaultFocusElement: PropTypes.oneOfType([
|
|
105
|
-
PropTypes.element,
|
|
106
|
-
PropTypes.func
|
|
107
|
-
]),
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Whether focus should be returned to the trigger when the `<Modal/>` is closed
|
|
111
|
-
*/
|
|
112
|
-
shouldReturnFocus: PropTypes.bool,
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Whether the `<Modal/>` should request close when the document is clicked
|
|
116
|
-
*/
|
|
117
|
-
shouldCloseOnDocumentClick: PropTypes.bool,
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Callback fired when `<Modal />` content has been mounted in the DOM
|
|
121
|
-
*/
|
|
122
|
-
onOpen: PropTypes.func,
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Callback fired when `<Modal />` has been unmounted from the DOM
|
|
126
|
-
*/
|
|
127
|
-
onClose: PropTypes.func,
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Callback fired when the `<Modal />` is requesting to be closed
|
|
131
|
-
*/
|
|
132
|
-
onDismiss: PropTypes.func,
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
*
|
|
136
|
-
* A function that returns a reference to the content element
|
|
137
|
-
*/
|
|
138
|
-
contentRef: PropTypes.func,
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* An element or a function returning an element to use as the mount node
|
|
142
|
-
* for the `<Modal />` (defaults to `document.body`)
|
|
143
|
-
*/
|
|
144
|
-
mountNode: PropTypes.oneOfType([element, PropTypes.func]),
|
|
145
|
-
/**
|
|
146
|
-
* Insert the element at the 'top' of the mountNode or at the 'bottom'
|
|
147
|
-
*/
|
|
148
|
-
insertAt: PropTypes.oneOf(['bottom', 'top']),
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* An element, function returning an element, or array of elements that will not be hidden from
|
|
152
|
-
* the screen reader when the `<Modal />` is open
|
|
153
|
-
*/
|
|
154
|
-
liveRegion: PropTypes.oneOfType([
|
|
155
|
-
PropTypes.arrayOf(PropTypes.element),
|
|
156
|
-
PropTypes.element,
|
|
157
|
-
PropTypes.func
|
|
158
|
-
]),
|
|
159
|
-
|
|
160
|
-
transition: Transition.propTypes.type,
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Callback fired before the <Modal /> transitions in
|
|
164
|
-
*/
|
|
165
|
-
onEnter: PropTypes.func,
|
|
166
|
-
/**
|
|
167
|
-
* Callback fired as the <Modal /> begins to transition in
|
|
168
|
-
*/
|
|
169
|
-
onEntering: PropTypes.func,
|
|
170
|
-
/**
|
|
171
|
-
* Callback fired after the <Modal /> finishes transitioning in
|
|
172
|
-
*/
|
|
173
|
-
onEntered: PropTypes.func,
|
|
174
|
-
/**
|
|
175
|
-
* Callback fired right before the <Modal /> transitions out
|
|
176
|
-
*/
|
|
177
|
-
onExit: PropTypes.func,
|
|
178
|
-
/**
|
|
179
|
-
* Callback fired as the <Modal /> begins to transition out
|
|
180
|
-
*/
|
|
181
|
-
onExiting: PropTypes.func,
|
|
182
|
-
/**
|
|
183
|
-
* Callback fired after the <Modal /> finishes transitioning out
|
|
184
|
-
*/
|
|
185
|
-
onExited: PropTypes.func,
|
|
186
|
-
/**
|
|
187
|
-
* Constrain the Modal to the document window or its closest positioned parent
|
|
188
|
-
*/
|
|
189
|
-
constrain: PropTypes.oneOf(['window', 'parent']),
|
|
190
|
-
/**
|
|
191
|
-
* Should ModalBody handle overflow with scrollbars, or fit its
|
|
192
|
-
* content within its own height?
|
|
193
|
-
*/
|
|
194
|
-
overflow: PropTypes.oneOf(['scroll', 'fit']),
|
|
195
|
-
|
|
196
|
-
// eslint-disable-next-line react/require-default-props
|
|
197
|
-
makeStyles: PropTypes.func,
|
|
198
|
-
// eslint-disable-next-line react/require-default-props
|
|
199
|
-
styles: PropTypes.object
|
|
200
|
-
}
|
|
201
|
-
|
|
62
|
+
static propTypes = propTypes
|
|
63
|
+
static allowedProps = allowedProps
|
|
202
64
|
static defaultProps = {
|
|
203
65
|
open: false,
|
|
204
66
|
size: 'auto',
|
|
@@ -349,7 +211,7 @@ class Modal extends Component<ModalProps> {
|
|
|
349
211
|
shouldReturnFocus={shouldReturnFocus}
|
|
350
212
|
liveRegion={liveRegion}
|
|
351
213
|
onDismiss={onDismiss}
|
|
352
|
-
css={styles
|
|
214
|
+
css={styles?.modal}
|
|
353
215
|
ref={this.contentRef}
|
|
354
216
|
// aria-modal="true" see VO bug https://bugs.webkit.org/show_bug.cgi?id=174667
|
|
355
217
|
>
|
|
@@ -418,7 +280,7 @@ class Modal extends Component<ModalProps> {
|
|
|
418
280
|
)}
|
|
419
281
|
>
|
|
420
282
|
{constrain === 'parent' ? (
|
|
421
|
-
<span css={this.props.styles
|
|
283
|
+
<span css={this.props.styles?.constrainContext}>
|
|
422
284
|
{this.renderDialog(passthroughProps)}
|
|
423
285
|
</span>
|
|
424
286
|
) : (
|
|
@@ -0,0 +1,238 @@
|
|
|
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 {
|
|
29
|
+
element,
|
|
30
|
+
Children as ChildrenPropTypes
|
|
31
|
+
} from '@instructure/ui-prop-types'
|
|
32
|
+
import { Transition } from '@instructure/ui-motion'
|
|
33
|
+
import { ModalHeader } from './ModalHeader'
|
|
34
|
+
import { ModalBody } from './ModalBody'
|
|
35
|
+
import { ModalFooter } from './ModalFooter'
|
|
36
|
+
|
|
37
|
+
import type { AsElementType, PropValidators } from '@instructure/shared-types'
|
|
38
|
+
import type { PortalNode } from '@instructure/ui-portal'
|
|
39
|
+
import type { PositionMountNode } from '@instructure/ui-position'
|
|
40
|
+
import type { TransitionType } from '@instructure/ui-motion'
|
|
41
|
+
import type { WithStyleProps } from '@instructure/emotion'
|
|
42
|
+
|
|
43
|
+
type ModalOwnProps = {
|
|
44
|
+
label: string
|
|
45
|
+
children: React.ReactNode // TODO: enforceOrder([ModalHeader, ModalBody, ModalFooter], [ModalHeader, ModalBody], [ModalBody, ModalFooter], [ModalBody])
|
|
46
|
+
as?: AsElementType
|
|
47
|
+
size?: 'auto' | 'small' | 'medium' | 'large' | 'fullscreen'
|
|
48
|
+
variant?: 'default' | 'inverse'
|
|
49
|
+
open?: boolean
|
|
50
|
+
defaultFocusElement?: React.ReactElement | ((...args: any[]) => any)
|
|
51
|
+
shouldReturnFocus?: boolean
|
|
52
|
+
shouldCloseOnDocumentClick?: boolean
|
|
53
|
+
onOpen?: (DOMNode: PortalNode) => any
|
|
54
|
+
onClose?: (...args: any[]) => any
|
|
55
|
+
onDismiss?: (...args: any[]) => any
|
|
56
|
+
contentRef?: (...args: any[]) => any
|
|
57
|
+
mountNode?: PositionMountNode
|
|
58
|
+
insertAt?: 'bottom' | 'top'
|
|
59
|
+
liveRegion?:
|
|
60
|
+
| React.ReactElement[]
|
|
61
|
+
| React.ReactElement
|
|
62
|
+
| ((...args: any[]) => any)
|
|
63
|
+
transition?: TransitionType
|
|
64
|
+
onEnter?: (...args: any[]) => any
|
|
65
|
+
onEntering?: (...args: any[]) => any
|
|
66
|
+
onEntered?: (...args: any[]) => any
|
|
67
|
+
onExit?: (...args: any[]) => any
|
|
68
|
+
onExiting?: (...args: any[]) => any
|
|
69
|
+
onExited?: (...args: any[]) => any
|
|
70
|
+
constrain?: 'window' | 'parent'
|
|
71
|
+
overflow?: 'scroll' | 'fit'
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
type PropKeys = keyof ModalOwnProps
|
|
75
|
+
|
|
76
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
77
|
+
|
|
78
|
+
type ModalProps = ModalOwnProps & WithStyleProps
|
|
79
|
+
|
|
80
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
81
|
+
/**
|
|
82
|
+
* An accessible label for the `<Modal />` content
|
|
83
|
+
*/
|
|
84
|
+
label: PropTypes.string.isRequired,
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* The children to be rendered within the `<Modal />`
|
|
88
|
+
*/
|
|
89
|
+
children: ChildrenPropTypes.enforceOrder(
|
|
90
|
+
[ModalHeader, ModalBody, ModalFooter],
|
|
91
|
+
[ModalHeader, ModalBody],
|
|
92
|
+
[ModalBody, ModalFooter],
|
|
93
|
+
[ModalBody]
|
|
94
|
+
),
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* The element to render the dialog as, `span` by default
|
|
98
|
+
*/
|
|
99
|
+
as: PropTypes.elementType,
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* The size of the `<Modal />` content
|
|
103
|
+
*/
|
|
104
|
+
size: PropTypes.oneOf(['auto', 'small', 'medium', 'large', 'fullscreen']),
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Designates the background style of the `<Modal />`
|
|
108
|
+
*/
|
|
109
|
+
variant: PropTypes.oneOf(['default', 'inverse']),
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Whether or not the `<Modal />` is open
|
|
113
|
+
*/
|
|
114
|
+
open: PropTypes.bool,
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* An element or a function returning an element to focus by default
|
|
118
|
+
*/
|
|
119
|
+
defaultFocusElement: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Whether focus should be returned to the trigger when the `<Modal/>` is closed
|
|
123
|
+
*/
|
|
124
|
+
shouldReturnFocus: PropTypes.bool,
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Whether the `<Modal/>` should request close when the document is clicked
|
|
128
|
+
*/
|
|
129
|
+
shouldCloseOnDocumentClick: PropTypes.bool,
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Callback fired when `<Modal />` content has been mounted in the DOM
|
|
133
|
+
*/
|
|
134
|
+
onOpen: PropTypes.func,
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Callback fired when `<Modal />` has been unmounted from the DOM
|
|
138
|
+
*/
|
|
139
|
+
onClose: PropTypes.func,
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Callback fired when the `<Modal />` is requesting to be closed
|
|
143
|
+
*/
|
|
144
|
+
onDismiss: PropTypes.func,
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
*
|
|
148
|
+
* A function that returns a reference to the content element
|
|
149
|
+
*/
|
|
150
|
+
contentRef: PropTypes.func,
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* An element or a function returning an element to use as the mount node
|
|
154
|
+
* for the `<Modal />` (defaults to `document.body`)
|
|
155
|
+
*/
|
|
156
|
+
mountNode: PropTypes.oneOfType([element, PropTypes.func]),
|
|
157
|
+
/**
|
|
158
|
+
* Insert the element at the 'top' of the mountNode or at the 'bottom'
|
|
159
|
+
*/
|
|
160
|
+
insertAt: PropTypes.oneOf(['bottom', 'top']),
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* An element, function returning an element, or array of elements that will not be hidden from
|
|
164
|
+
* the screen reader when the `<Modal />` is open
|
|
165
|
+
*/
|
|
166
|
+
liveRegion: PropTypes.oneOfType([
|
|
167
|
+
PropTypes.arrayOf(PropTypes.element),
|
|
168
|
+
PropTypes.element,
|
|
169
|
+
PropTypes.func
|
|
170
|
+
]),
|
|
171
|
+
|
|
172
|
+
transition: Transition.propTypes.type,
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Callback fired before the <Modal /> transitions in
|
|
176
|
+
*/
|
|
177
|
+
onEnter: PropTypes.func,
|
|
178
|
+
/**
|
|
179
|
+
* Callback fired as the <Modal /> begins to transition in
|
|
180
|
+
*/
|
|
181
|
+
onEntering: PropTypes.func,
|
|
182
|
+
/**
|
|
183
|
+
* Callback fired after the <Modal /> finishes transitioning in
|
|
184
|
+
*/
|
|
185
|
+
onEntered: PropTypes.func,
|
|
186
|
+
/**
|
|
187
|
+
* Callback fired right before the <Modal /> transitions out
|
|
188
|
+
*/
|
|
189
|
+
onExit: PropTypes.func,
|
|
190
|
+
/**
|
|
191
|
+
* Callback fired as the <Modal /> begins to transition out
|
|
192
|
+
*/
|
|
193
|
+
onExiting: PropTypes.func,
|
|
194
|
+
/**
|
|
195
|
+
* Callback fired after the <Modal /> finishes transitioning out
|
|
196
|
+
*/
|
|
197
|
+
onExited: PropTypes.func,
|
|
198
|
+
/**
|
|
199
|
+
* Constrain the Modal to the document window or its closest positioned parent
|
|
200
|
+
*/
|
|
201
|
+
constrain: PropTypes.oneOf(['window', 'parent']),
|
|
202
|
+
/**
|
|
203
|
+
* Should ModalBody handle overflow with scrollbars, or fit its
|
|
204
|
+
* content within its own height?
|
|
205
|
+
*/
|
|
206
|
+
overflow: PropTypes.oneOf(['scroll', 'fit'])
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const allowedProps: AllowedPropKeys = [
|
|
210
|
+
'label',
|
|
211
|
+
'children',
|
|
212
|
+
'as',
|
|
213
|
+
'size',
|
|
214
|
+
'variant',
|
|
215
|
+
'open',
|
|
216
|
+
'defaultFocusElement',
|
|
217
|
+
'shouldReturnFocus',
|
|
218
|
+
'shouldCloseOnDocumentClick',
|
|
219
|
+
'onOpen',
|
|
220
|
+
'onClose',
|
|
221
|
+
'onDismiss',
|
|
222
|
+
'contentRef',
|
|
223
|
+
'mountNode',
|
|
224
|
+
'insertAt',
|
|
225
|
+
'liveRegion',
|
|
226
|
+
'transition',
|
|
227
|
+
'onEnter',
|
|
228
|
+
'onEntering',
|
|
229
|
+
'onEntered',
|
|
230
|
+
'onExit',
|
|
231
|
+
'onExiting',
|
|
232
|
+
'onExited',
|
|
233
|
+
'constrain',
|
|
234
|
+
'overflow'
|
|
235
|
+
]
|
|
236
|
+
|
|
237
|
+
export type { ModalProps }
|
|
238
|
+
export { propTypes, allowedProps }
|