@instructure/ui-modal 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 +49 -311
- package/es/Modal/{ModalBody → v1/ModalBody}/index.js +2 -2
- package/es/Modal/{ModalFooter → v1/ModalFooter}/index.js +1 -1
- package/es/Modal/{ModalHeader → v1/ModalHeader}/index.js +2 -2
- package/es/Modal/{index.js → v1/index.js} +2 -2
- package/es/Modal/v2/ModalBody/index.js +132 -0
- package/es/Modal/v2/ModalBody/props.js +26 -0
- package/es/Modal/v2/ModalBody/styles.js +68 -0
- package/es/Modal/v2/ModalContext.js +34 -0
- package/es/Modal/v2/ModalFooter/index.js +73 -0
- package/es/{index.js → Modal/v2/ModalFooter/props.js} +3 -1
- package/es/Modal/v2/ModalFooter/styles.js +60 -0
- package/es/Modal/v2/ModalHeader/index.js +112 -0
- package/es/Modal/v2/ModalHeader/props.js +26 -0
- package/es/Modal/v2/ModalHeader/styles.js +76 -0
- package/es/Modal/v2/index.js +259 -0
- package/es/Modal/v2/props.js +26 -0
- package/es/Modal/v2/styles.js +119 -0
- package/es/exports/a.js +24 -0
- package/es/exports/b.js +24 -0
- package/lib/Modal/{ModalBody → v1/ModalBody}/index.js +4 -4
- package/lib/Modal/{ModalFooter → v1/ModalFooter}/index.js +1 -1
- package/lib/Modal/{ModalHeader → v1/ModalHeader}/index.js +3 -3
- package/lib/Modal/v1/index.js +285 -0
- package/lib/Modal/v2/ModalBody/index.js +137 -0
- package/lib/Modal/v2/ModalBody/props.js +31 -0
- package/lib/Modal/v2/ModalBody/styles.js +74 -0
- package/lib/Modal/v2/ModalContext.js +39 -0
- package/lib/Modal/v2/ModalFooter/index.js +78 -0
- package/lib/Modal/v2/ModalFooter/props.js +31 -0
- package/lib/Modal/v2/ModalFooter/styles.js +66 -0
- package/lib/Modal/v2/ModalHeader/index.js +118 -0
- package/lib/Modal/v2/ModalHeader/props.js +31 -0
- package/lib/Modal/v2/ModalHeader/styles.js +82 -0
- package/lib/Modal/{index.js → v2/index.js} +3 -4
- package/lib/Modal/v2/props.js +31 -0
- package/lib/Modal/v2/styles.js +125 -0
- package/lib/{index.js → exports/a.js} +5 -5
- package/lib/exports/b.js +30 -0
- package/package.json +46 -24
- package/src/Modal/{ModalBody → v1/ModalBody}/index.tsx +2 -2
- package/src/Modal/{ModalFooter → v1/ModalFooter}/index.tsx +1 -1
- package/src/Modal/{ModalHeader → v1/ModalHeader}/index.tsx +3 -3
- package/src/Modal/{index.tsx → v1/index.tsx} +2 -2
- package/src/Modal/v2/ModalBody/index.tsx +164 -0
- package/src/Modal/v2/ModalBody/props.ts +72 -0
- package/src/Modal/v2/ModalBody/styles.ts +76 -0
- package/src/Modal/v2/ModalContext.ts +46 -0
- package/src/Modal/v2/ModalFooter/index.tsx +80 -0
- package/src/Modal/v2/ModalFooter/props.ts +50 -0
- package/src/Modal/v2/ModalFooter/styles.ts +74 -0
- package/src/Modal/v2/ModalHeader/index.tsx +138 -0
- package/src/Modal/v2/ModalHeader/props.ts +54 -0
- package/src/Modal/v2/ModalHeader/styles.ts +99 -0
- package/src/Modal/v2/README.md +673 -0
- package/src/Modal/v2/index.tsx +326 -0
- package/src/Modal/v2/props.ts +235 -0
- package/src/Modal/v2/styles.ts +130 -0
- package/src/{index.ts → exports/a.ts} +5 -5
- package/src/exports/b.ts +29 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Modal/v1/ModalBody/index.d.ts.map +1 -0
- package/types/Modal/v1/ModalBody/props.d.ts.map +1 -0
- package/types/Modal/v1/ModalBody/styles.d.ts.map +1 -0
- package/types/Modal/v1/ModalBody/theme.d.ts.map +1 -0
- package/types/Modal/v1/ModalContext.d.ts.map +1 -0
- package/types/Modal/v1/ModalFooter/index.d.ts.map +1 -0
- package/types/Modal/v1/ModalFooter/props.d.ts.map +1 -0
- package/types/Modal/v1/ModalFooter/styles.d.ts.map +1 -0
- package/types/Modal/v1/ModalFooter/theme.d.ts.map +1 -0
- package/types/Modal/v1/ModalHeader/index.d.ts.map +1 -0
- package/types/Modal/v1/ModalHeader/props.d.ts.map +1 -0
- package/types/Modal/v1/ModalHeader/styles.d.ts.map +1 -0
- package/types/Modal/v1/ModalHeader/theme.d.ts.map +1 -0
- package/types/Modal/v1/index.d.ts.map +1 -0
- package/types/Modal/v1/props.d.ts.map +1 -0
- package/types/Modal/v1/styles.d.ts.map +1 -0
- package/types/Modal/v1/theme.d.ts.map +1 -0
- package/types/Modal/v2/ModalBody/index.d.ts +36 -0
- package/types/Modal/v2/ModalBody/index.d.ts.map +1 -0
- package/types/Modal/v2/ModalBody/props.d.ts +23 -0
- package/types/Modal/v2/ModalBody/props.d.ts.map +1 -0
- package/types/Modal/v2/ModalBody/styles.d.ts +16 -0
- package/types/Modal/v2/ModalBody/styles.d.ts.map +1 -0
- package/types/Modal/v2/ModalContext.d.ts +17 -0
- package/types/Modal/v2/ModalContext.d.ts.map +1 -0
- package/types/Modal/v2/ModalFooter/index.d.ts +27 -0
- package/types/Modal/v2/ModalFooter/index.d.ts.map +1 -0
- package/types/Modal/v2/ModalFooter/props.d.ts +16 -0
- package/types/Modal/v2/ModalFooter/props.d.ts.map +1 -0
- package/types/Modal/v2/ModalFooter/styles.d.ts +16 -0
- package/types/Modal/v2/ModalFooter/styles.d.ts.map +1 -0
- package/types/Modal/v2/ModalHeader/index.d.ts +37 -0
- package/types/Modal/v2/ModalHeader/index.d.ts.map +1 -0
- package/types/Modal/v2/ModalHeader/props.d.ts +19 -0
- package/types/Modal/v2/ModalHeader/props.d.ts.map +1 -0
- package/types/Modal/v2/ModalHeader/styles.d.ts +16 -0
- package/types/Modal/v2/ModalHeader/styles.d.ts.map +1 -0
- package/types/Modal/v2/index.d.ts +54 -0
- package/types/Modal/v2/index.d.ts.map +1 -0
- package/types/Modal/v2/props.d.ts +132 -0
- package/types/Modal/v2/props.d.ts.map +1 -0
- package/types/Modal/v2/styles.d.ts +16 -0
- package/types/Modal/v2/styles.d.ts.map +1 -0
- package/types/exports/a.d.ts +6 -0
- package/types/exports/a.d.ts.map +1 -0
- package/types/exports/b.d.ts +6 -0
- package/types/exports/b.d.ts.map +1 -0
- package/types/Modal/ModalBody/index.d.ts.map +0 -1
- package/types/Modal/ModalBody/props.d.ts.map +0 -1
- package/types/Modal/ModalBody/styles.d.ts.map +0 -1
- package/types/Modal/ModalBody/theme.d.ts.map +0 -1
- package/types/Modal/ModalContext.d.ts.map +0 -1
- package/types/Modal/ModalFooter/index.d.ts.map +0 -1
- package/types/Modal/ModalFooter/props.d.ts.map +0 -1
- package/types/Modal/ModalFooter/styles.d.ts.map +0 -1
- package/types/Modal/ModalFooter/theme.d.ts.map +0 -1
- package/types/Modal/ModalHeader/index.d.ts.map +0 -1
- package/types/Modal/ModalHeader/props.d.ts.map +0 -1
- package/types/Modal/ModalHeader/styles.d.ts.map +0 -1
- package/types/Modal/ModalHeader/theme.d.ts.map +0 -1
- package/types/Modal/index.d.ts.map +0 -1
- package/types/Modal/props.d.ts.map +0 -1
- package/types/Modal/styles.d.ts.map +0 -1
- package/types/Modal/theme.d.ts.map +0 -1
- package/types/index.d.ts +0 -6
- package/types/index.d.ts.map +0 -1
- /package/es/Modal/{ModalBody → v1/ModalBody}/props.js +0 -0
- /package/es/Modal/{ModalBody → v1/ModalBody}/styles.js +0 -0
- /package/es/Modal/{ModalBody → v1/ModalBody}/theme.js +0 -0
- /package/es/Modal/{ModalContext.js → v1/ModalContext.js} +0 -0
- /package/es/Modal/{ModalFooter → v1/ModalFooter}/props.js +0 -0
- /package/es/Modal/{ModalFooter → v1/ModalFooter}/styles.js +0 -0
- /package/es/Modal/{ModalFooter → v1/ModalFooter}/theme.js +0 -0
- /package/es/Modal/{ModalHeader → v1/ModalHeader}/props.js +0 -0
- /package/es/Modal/{ModalHeader → v1/ModalHeader}/styles.js +0 -0
- /package/es/Modal/{ModalHeader → v1/ModalHeader}/theme.js +0 -0
- /package/es/Modal/{props.js → v1/props.js} +0 -0
- /package/es/Modal/{styles.js → v1/styles.js} +0 -0
- /package/es/Modal/{theme.js → v1/theme.js} +0 -0
- /package/lib/Modal/{ModalBody → v1/ModalBody}/props.js +0 -0
- /package/lib/Modal/{ModalBody → v1/ModalBody}/styles.js +0 -0
- /package/lib/Modal/{ModalBody → v1/ModalBody}/theme.js +0 -0
- /package/lib/Modal/{ModalContext.js → v1/ModalContext.js} +0 -0
- /package/lib/Modal/{ModalFooter → v1/ModalFooter}/props.js +0 -0
- /package/lib/Modal/{ModalFooter → v1/ModalFooter}/styles.js +0 -0
- /package/lib/Modal/{ModalFooter → v1/ModalFooter}/theme.js +0 -0
- /package/lib/Modal/{ModalHeader → v1/ModalHeader}/props.js +0 -0
- /package/lib/Modal/{ModalHeader → v1/ModalHeader}/styles.js +0 -0
- /package/lib/Modal/{ModalHeader → v1/ModalHeader}/theme.js +0 -0
- /package/lib/Modal/{props.js → v1/props.js} +0 -0
- /package/lib/Modal/{styles.js → v1/styles.js} +0 -0
- /package/lib/Modal/{theme.js → v1/theme.js} +0 -0
- /package/src/Modal/{ModalBody → v1/ModalBody}/props.ts +0 -0
- /package/src/Modal/{ModalBody → v1/ModalBody}/styles.ts +0 -0
- /package/src/Modal/{ModalBody → v1/ModalBody}/theme.ts +0 -0
- /package/src/Modal/{ModalContext.ts → v1/ModalContext.ts} +0 -0
- /package/src/Modal/{ModalFooter → v1/ModalFooter}/props.ts +0 -0
- /package/src/Modal/{ModalFooter → v1/ModalFooter}/styles.ts +0 -0
- /package/src/Modal/{ModalFooter → v1/ModalFooter}/theme.ts +0 -0
- /package/src/Modal/{ModalHeader → v1/ModalHeader}/props.ts +0 -0
- /package/src/Modal/{ModalHeader → v1/ModalHeader}/styles.ts +0 -0
- /package/src/Modal/{ModalHeader → v1/ModalHeader}/theme.ts +0 -0
- /package/src/Modal/{README.md → v1/README.md} +0 -0
- /package/src/Modal/{props.ts → v1/props.ts} +0 -0
- /package/src/Modal/{styles.ts → v1/styles.ts} +0 -0
- /package/src/Modal/{theme.ts → v1/theme.ts} +0 -0
- /package/types/Modal/{ModalBody → v1/ModalBody}/index.d.ts +0 -0
- /package/types/Modal/{ModalBody → v1/ModalBody}/props.d.ts +0 -0
- /package/types/Modal/{ModalBody → v1/ModalBody}/styles.d.ts +0 -0
- /package/types/Modal/{ModalBody → v1/ModalBody}/theme.d.ts +0 -0
- /package/types/Modal/{ModalContext.d.ts → v1/ModalContext.d.ts} +0 -0
- /package/types/Modal/{ModalFooter → v1/ModalFooter}/index.d.ts +0 -0
- /package/types/Modal/{ModalFooter → v1/ModalFooter}/props.d.ts +0 -0
- /package/types/Modal/{ModalFooter → v1/ModalFooter}/styles.d.ts +0 -0
- /package/types/Modal/{ModalFooter → v1/ModalFooter}/theme.d.ts +0 -0
- /package/types/Modal/{ModalHeader → v1/ModalHeader}/index.d.ts +0 -0
- /package/types/Modal/{ModalHeader → v1/ModalHeader}/props.d.ts +0 -0
- /package/types/Modal/{ModalHeader → v1/ModalHeader}/styles.d.ts +0 -0
- /package/types/Modal/{ModalHeader → v1/ModalHeader}/theme.d.ts +0 -0
- /package/types/Modal/{index.d.ts → v1/index.d.ts} +0 -0
- /package/types/Modal/{props.d.ts → v1/props.d.ts} +0 -0
- /package/types/Modal/{styles.d.ts → v1/styles.d.ts} +0 -0
- /package/types/Modal/{theme.d.ts → v1/theme.d.ts} +0 -0
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
import { Component } from 'react'
|
|
26
26
|
|
|
27
27
|
import { passthroughProps } from '@instructure/ui-react-utils'
|
|
28
|
-
import { withStyle } from '@instructure/emotion'
|
|
28
|
+
import { withStyleLegacy as withStyle } from '@instructure/emotion'
|
|
29
29
|
import generateStyle from './styles'
|
|
30
30
|
import generateComponentTheme from './theme'
|
|
31
31
|
|
|
@@ -29,10 +29,10 @@ import {
|
|
|
29
29
|
passthroughProps
|
|
30
30
|
} from '@instructure/ui-react-utils'
|
|
31
31
|
|
|
32
|
-
import { withStyle } from '@instructure/emotion'
|
|
32
|
+
import { withStyleLegacy as withStyle } from '@instructure/emotion'
|
|
33
33
|
|
|
34
|
-
import { CloseButton } from '@instructure/ui-buttons'
|
|
35
|
-
import type { CloseButtonProps } from '@instructure/ui-buttons'
|
|
34
|
+
import { CloseButton } from '@instructure/ui-buttons/v11_6'
|
|
35
|
+
import type { CloseButtonProps } from '@instructure/ui-buttons/v11_6'
|
|
36
36
|
|
|
37
37
|
import generateStyle from './styles'
|
|
38
38
|
import generateComponentTheme from './theme'
|
|
@@ -31,13 +31,13 @@ import { Transition } from '@instructure/ui-motion'
|
|
|
31
31
|
import { Portal } from '@instructure/ui-portal'
|
|
32
32
|
import type { PortalNode } from '@instructure/ui-portal'
|
|
33
33
|
import { Dialog } from '@instructure/ui-dialog'
|
|
34
|
-
import { Mask } from '@instructure/ui-overlays'
|
|
34
|
+
import { Mask } from '@instructure/ui-overlays/v11_6'
|
|
35
35
|
|
|
36
36
|
import { ModalHeader } from './ModalHeader'
|
|
37
37
|
import { ModalBody } from './ModalBody'
|
|
38
38
|
import { ModalFooter } from './ModalFooter'
|
|
39
39
|
|
|
40
|
-
import { withStyle } from '@instructure/emotion'
|
|
40
|
+
import { withStyleLegacy as withStyle } from '@instructure/emotion'
|
|
41
41
|
|
|
42
42
|
import generateStyle from './styles'
|
|
43
43
|
import generateComponentTheme from './theme'
|
|
@@ -0,0 +1,164 @@
|
|
|
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 } from 'react'
|
|
26
|
+
|
|
27
|
+
import { View } from '@instructure/ui-view/latest'
|
|
28
|
+
import { omitProps } from '@instructure/ui-react-utils'
|
|
29
|
+
import { getCSSStyleDeclaration } from '@instructure/ui-dom-utils'
|
|
30
|
+
|
|
31
|
+
import { withStyle } from '@instructure/emotion'
|
|
32
|
+
import generateStyle from './styles'
|
|
33
|
+
|
|
34
|
+
import { allowedProps } from './props'
|
|
35
|
+
import type { ModalBodyProps } from './props'
|
|
36
|
+
import { UIElement } from '@instructure/shared-types'
|
|
37
|
+
import ModalContext from '../ModalContext'
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
---
|
|
41
|
+
parent: Modal
|
|
42
|
+
id: Modal.Body
|
|
43
|
+
---
|
|
44
|
+
**/
|
|
45
|
+
@withStyle(generateStyle, 'ModalBody')
|
|
46
|
+
class ModalBody extends Component<ModalBodyProps> {
|
|
47
|
+
static readonly componentId = 'Modal.Body'
|
|
48
|
+
|
|
49
|
+
static allowedProps = allowedProps
|
|
50
|
+
static defaultProps = {
|
|
51
|
+
padding: 'medium',
|
|
52
|
+
as: 'div',
|
|
53
|
+
variant: 'default'
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
ref: UIElement | null = null
|
|
57
|
+
|
|
58
|
+
handleRef = (el: UIElement | null) => {
|
|
59
|
+
const { elementRef } = this.props
|
|
60
|
+
|
|
61
|
+
this.ref = el
|
|
62
|
+
|
|
63
|
+
if (typeof elementRef === 'function') {
|
|
64
|
+
elementRef(el)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
constructor(props: ModalBodyProps) {
|
|
69
|
+
super(props)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
componentDidMount() {
|
|
73
|
+
this.props.makeStyles?.()
|
|
74
|
+
|
|
75
|
+
// We detect if -moz- prefixed style is present to identify whether we are in Firefox browser
|
|
76
|
+
const style = this.ref && getCSSStyleDeclaration(this.ref)
|
|
77
|
+
const isFirefox = !!(
|
|
78
|
+
style &&
|
|
79
|
+
Array.prototype.slice
|
|
80
|
+
.call(style)
|
|
81
|
+
.join('')
|
|
82
|
+
.match(/(?:-moz-)/)
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
if (isFirefox) {
|
|
86
|
+
this.setState({ isFirefox })
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
componentDidUpdate() {
|
|
91
|
+
this.props.makeStyles?.()
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
getFinalRef(el: UIElement): Element | undefined {
|
|
95
|
+
if (!el) {
|
|
96
|
+
return undefined
|
|
97
|
+
}
|
|
98
|
+
if (el instanceof Element) {
|
|
99
|
+
return el
|
|
100
|
+
}
|
|
101
|
+
if ((el as unknown as { ref: UIElement }).ref) {
|
|
102
|
+
return this.getFinalRef((el as unknown as { ref: UIElement }).ref)
|
|
103
|
+
}
|
|
104
|
+
return undefined
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
render() {
|
|
108
|
+
const {
|
|
109
|
+
as,
|
|
110
|
+
elementRef,
|
|
111
|
+
overflow,
|
|
112
|
+
variant,
|
|
113
|
+
padding,
|
|
114
|
+
spacing,
|
|
115
|
+
children,
|
|
116
|
+
...rest
|
|
117
|
+
} = this.props
|
|
118
|
+
|
|
119
|
+
const passthroughProps = View.omitViewProps(
|
|
120
|
+
omitProps(rest, ModalBody.allowedProps),
|
|
121
|
+
ModalBody
|
|
122
|
+
)
|
|
123
|
+
const isFit = overflow === 'fit'
|
|
124
|
+
// this recursive function is needed because `ref` can be a React component.
|
|
125
|
+
// TODO rethink, the 'as' prop, likely its not a good idea to allow React
|
|
126
|
+
// components. See INSTUI-4674
|
|
127
|
+
const finalRef = this.getFinalRef(this.ref)
|
|
128
|
+
const hasScrollbar =
|
|
129
|
+
finalRef &&
|
|
130
|
+
Math.abs(
|
|
131
|
+
(finalRef.scrollHeight ?? 0) -
|
|
132
|
+
(finalRef.getBoundingClientRect()?.height ?? 0)
|
|
133
|
+
) > 1
|
|
134
|
+
return (
|
|
135
|
+
<ModalContext.Consumer>
|
|
136
|
+
{(value) => (
|
|
137
|
+
<View
|
|
138
|
+
{...passthroughProps}
|
|
139
|
+
display="block"
|
|
140
|
+
data-cid="ModalBody"
|
|
141
|
+
width={isFit ? '100%' : undefined}
|
|
142
|
+
height={isFit ? '100%' : undefined}
|
|
143
|
+
elementRef={this.handleRef}
|
|
144
|
+
as={as}
|
|
145
|
+
css={this.props.styles?.modalBody}
|
|
146
|
+
padding={spacing ? undefined : padding}
|
|
147
|
+
// check if there is a scrollbar, if so, the element has to be tabbable
|
|
148
|
+
{...(hasScrollbar
|
|
149
|
+
? {
|
|
150
|
+
tabIndex: 0,
|
|
151
|
+
'aria-label': value.bodyScrollAriaLabel
|
|
152
|
+
}
|
|
153
|
+
: {})}
|
|
154
|
+
>
|
|
155
|
+
{children}
|
|
156
|
+
</View>
|
|
157
|
+
)}
|
|
158
|
+
</ModalContext.Consumer>
|
|
159
|
+
)
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export default ModalBody
|
|
164
|
+
export { ModalBody }
|
|
@@ -0,0 +1,72 @@
|
|
|
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 {
|
|
27
|
+
Spacing,
|
|
28
|
+
WithStyleProps,
|
|
29
|
+
ComponentStyle
|
|
30
|
+
} from '@instructure/emotion'
|
|
31
|
+
import type {
|
|
32
|
+
AsElementType,
|
|
33
|
+
ModalBodyTheme,
|
|
34
|
+
OtherHTMLAttributes,
|
|
35
|
+
UIElement
|
|
36
|
+
} from '@instructure/shared-types'
|
|
37
|
+
|
|
38
|
+
type ModalBodyOwnProps = {
|
|
39
|
+
children?: React.ReactNode
|
|
40
|
+
padding?: Spacing
|
|
41
|
+
elementRef?: (element: UIElement | null) => void
|
|
42
|
+
as?: AsElementType
|
|
43
|
+
variant?: 'default' | 'inverse'
|
|
44
|
+
overflow?: 'scroll' | 'fit'
|
|
45
|
+
spacing?: 'default' | 'compact'
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
type PropKeys = keyof ModalBodyOwnProps
|
|
49
|
+
|
|
50
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
51
|
+
|
|
52
|
+
type ModalBodyProps = ModalBodyOwnProps &
|
|
53
|
+
WithStyleProps<ModalBodyTheme, ModalBodyStyle> &
|
|
54
|
+
OtherHTMLAttributes<ModalBodyOwnProps>
|
|
55
|
+
|
|
56
|
+
type ModalBodyStyle = ComponentStyle<'modalBody'>
|
|
57
|
+
|
|
58
|
+
type ModalBodyState = {
|
|
59
|
+
isFirefox: boolean
|
|
60
|
+
}
|
|
61
|
+
const allowedProps: AllowedPropKeys = [
|
|
62
|
+
'children',
|
|
63
|
+
'padding',
|
|
64
|
+
'elementRef',
|
|
65
|
+
'as',
|
|
66
|
+
'variant',
|
|
67
|
+
'overflow',
|
|
68
|
+
'spacing'
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
export type { ModalBodyProps, ModalBodyState, ModalBodyStyle }
|
|
72
|
+
export { allowedProps }
|
|
@@ -0,0 +1,76 @@
|
|
|
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 type { NewComponentTypes } from '@instructure/ui-themes'
|
|
26
|
+
import type { ModalBodyProps, ModalBodyStyle } from './props'
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* ---
|
|
30
|
+
* private: true
|
|
31
|
+
* ---
|
|
32
|
+
* Generates the style object from the theme and provided additional information
|
|
33
|
+
* @param {Object} componentTheme The theme variable object.
|
|
34
|
+
* @param {Object} props the props of the component, the style is applied to
|
|
35
|
+
* @param {Object} sharedTokens Shared theme token object
|
|
36
|
+
* @param {Object} state the state of the component, the style is applied to
|
|
37
|
+
* @return {Object} The final style object, which will be used in the component
|
|
38
|
+
*/
|
|
39
|
+
const generateStyle = (
|
|
40
|
+
componentTheme: NewComponentTypes['ModalBody'],
|
|
41
|
+
props: ModalBodyProps
|
|
42
|
+
): ModalBodyStyle => {
|
|
43
|
+
const { variant, spacing } = props
|
|
44
|
+
|
|
45
|
+
const sizeVariants = {
|
|
46
|
+
default: { padding: componentTheme.padding },
|
|
47
|
+
compact: { padding: componentTheme.paddingCompact }
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const backgroundStyle =
|
|
51
|
+
variant === 'inverse'
|
|
52
|
+
? {
|
|
53
|
+
background: componentTheme.inverseBackgroundColor
|
|
54
|
+
}
|
|
55
|
+
: {}
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
modalBody: {
|
|
59
|
+
label: 'modalBody',
|
|
60
|
+
borderRadius: 0,
|
|
61
|
+
boxSizing: 'border-box',
|
|
62
|
+
flex: '1 1 auto',
|
|
63
|
+
'&:focus': {
|
|
64
|
+
outline: 'none'
|
|
65
|
+
},
|
|
66
|
+
// ModalBody is set to scrollable above 20rem height
|
|
67
|
+
'@media (min-height: 20rem)': {
|
|
68
|
+
overflowY: 'auto'
|
|
69
|
+
},
|
|
70
|
+
...(spacing ? sizeVariants[spacing] : {}),
|
|
71
|
+
...backgroundStyle
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export default generateStyle
|
|
@@ -0,0 +1,46 @@
|
|
|
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 { createContext } from 'react'
|
|
26
|
+
|
|
27
|
+
type ModalContextType = {
|
|
28
|
+
/**
|
|
29
|
+
* Needed for setting the correct aria-label in the modal body when its scrollable.
|
|
30
|
+
* This is a value read from the Modal's Header.
|
|
31
|
+
*/
|
|
32
|
+
bodyScrollAriaLabel?: string
|
|
33
|
+
setBodyScrollAriaLabel?: (txt: string) => void
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* React context created by the `Modal` component
|
|
38
|
+
* @private
|
|
39
|
+
*/
|
|
40
|
+
const ModalContext = createContext<ModalContextType>({
|
|
41
|
+
bodyScrollAriaLabel: undefined
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
export default ModalContext
|
|
45
|
+
export { ModalContext }
|
|
46
|
+
export type { ModalContextType }
|
|
@@ -0,0 +1,80 @@
|
|
|
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 } from 'react'
|
|
26
|
+
|
|
27
|
+
import { passthroughProps } from '@instructure/ui-react-utils'
|
|
28
|
+
import { withStyle } from '@instructure/emotion'
|
|
29
|
+
import generateStyle from './styles'
|
|
30
|
+
|
|
31
|
+
import { allowedProps } from './props'
|
|
32
|
+
import type { ModalFooterProps } from './props'
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
---
|
|
36
|
+
parent: Modal
|
|
37
|
+
id: Modal.Footer
|
|
38
|
+
---
|
|
39
|
+
**/
|
|
40
|
+
@withStyle(generateStyle, 'ModalFooter')
|
|
41
|
+
class ModalFooter extends Component<ModalFooterProps> {
|
|
42
|
+
static readonly componentId = 'Modal.Footer'
|
|
43
|
+
|
|
44
|
+
static allowedProps = allowedProps
|
|
45
|
+
static defaultProps = {
|
|
46
|
+
variant: 'default'
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
ref: HTMLDivElement | null = null
|
|
50
|
+
|
|
51
|
+
handleRef = (el: HTMLDivElement | null) => {
|
|
52
|
+
this.ref = el
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
componentDidMount() {
|
|
56
|
+
this.props.makeStyles?.()
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
componentDidUpdate() {
|
|
60
|
+
this.props.makeStyles?.()
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
render() {
|
|
64
|
+
const { children, ...rest } = this.props
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<div
|
|
68
|
+
css={this.props.styles?.modalFooter}
|
|
69
|
+
{...passthroughProps(rest)}
|
|
70
|
+
ref={this.handleRef}
|
|
71
|
+
data-cid="ModalFooter"
|
|
72
|
+
>
|
|
73
|
+
{children}
|
|
74
|
+
</div>
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export default ModalFooter
|
|
80
|
+
export { ModalFooter }
|
|
@@ -0,0 +1,50 @@
|
|
|
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 {
|
|
27
|
+
ModalFooterTheme,
|
|
28
|
+
OtherHTMLAttributes
|
|
29
|
+
} from '@instructure/shared-types'
|
|
30
|
+
import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
|
|
31
|
+
|
|
32
|
+
type ModalFooterOwnProps = {
|
|
33
|
+
children?: React.ReactNode
|
|
34
|
+
variant?: 'default' | 'inverse'
|
|
35
|
+
spacing?: 'default' | 'compact'
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
type PropKeys = keyof ModalFooterOwnProps
|
|
39
|
+
|
|
40
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
41
|
+
|
|
42
|
+
type ModalFooterProps = ModalFooterOwnProps &
|
|
43
|
+
WithStyleProps<ModalFooterTheme, ModalFooterStyle> &
|
|
44
|
+
OtherHTMLAttributes<ModalFooterOwnProps>
|
|
45
|
+
|
|
46
|
+
type ModalFooterStyle = ComponentStyle<'modalFooter'>
|
|
47
|
+
const allowedProps: AllowedPropKeys = ['children', 'variant', 'spacing']
|
|
48
|
+
|
|
49
|
+
export type { ModalFooterProps, ModalFooterStyle }
|
|
50
|
+
export { allowedProps }
|
|
@@ -0,0 +1,74 @@
|
|
|
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 type { NewComponentTypes } from '@instructure/ui-themes'
|
|
26
|
+
import type { ModalFooterProps, ModalFooterStyle } from './props'
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* ---
|
|
30
|
+
* private: true
|
|
31
|
+
* ---
|
|
32
|
+
* Generates the style object from the theme and provided additional information
|
|
33
|
+
* @param {Object} componentTheme The theme variable object.
|
|
34
|
+
* @param {Object} props the props of the component, the style is applied to
|
|
35
|
+
* @param {Object} sharedTokens Shared theme token object
|
|
36
|
+
* @param {Object} state the state of the component, the style is applied to
|
|
37
|
+
* @return {Object} The final style object, which will be used in the component
|
|
38
|
+
*/
|
|
39
|
+
const generateStyle = (
|
|
40
|
+
componentTheme: NewComponentTypes['ModalFooter'],
|
|
41
|
+
props: ModalFooterProps
|
|
42
|
+
): ModalFooterStyle => {
|
|
43
|
+
const { variant, spacing } = props
|
|
44
|
+
|
|
45
|
+
const backgroundStyle =
|
|
46
|
+
variant === 'inverse'
|
|
47
|
+
? {
|
|
48
|
+
background: componentTheme.inverseBackgroundColor,
|
|
49
|
+
borderTop: `${componentTheme.borderWidth} solid ${componentTheme.inverseBorderColor}`
|
|
50
|
+
}
|
|
51
|
+
: {
|
|
52
|
+
background: componentTheme.backgroundColor,
|
|
53
|
+
borderTop: `${componentTheme.borderWidth} solid ${componentTheme.borderColor}`
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
modalFooter: {
|
|
58
|
+
label: 'modalFooter',
|
|
59
|
+
flex: '0 0 auto',
|
|
60
|
+
boxSizing: 'border-box',
|
|
61
|
+
padding:
|
|
62
|
+
spacing === 'compact'
|
|
63
|
+
? componentTheme.paddingCompact
|
|
64
|
+
: componentTheme.padding,
|
|
65
|
+
borderBottomRightRadius: componentTheme.borderRadius,
|
|
66
|
+
borderBottomLeftRadius: componentTheme.borderRadius,
|
|
67
|
+
display: 'flex',
|
|
68
|
+
justifyContent: 'flex-end',
|
|
69
|
+
...backgroundStyle
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export default generateStyle
|