@instructure/ui-alerts 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 +36 -295
- package/es/Alert/{index.js → v1/index.js} +3 -3
- package/es/Alert/v2/index.js +263 -0
- package/es/Alert/v2/props.js +26 -0
- package/es/Alert/v2/styles.js +134 -0
- package/es/{index.js → exports/a.js} +1 -1
- package/{src/index.ts → es/exports/b.js} +1 -2
- package/lib/Alert/{index.js → v1/index.js} +9 -9
- package/lib/Alert/v2/index.js +270 -0
- package/lib/Alert/v2/props.js +31 -0
- package/lib/Alert/v2/styles.js +140 -0
- package/lib/{index.js → exports/a.js} +2 -2
- package/lib/exports/b.js +12 -0
- package/package.json +44 -22
- package/src/Alert/{index.tsx → v1/index.tsx} +4 -4
- package/src/Alert/v2/README.md +249 -0
- package/src/Alert/v2/index.tsx +349 -0
- package/src/Alert/v2/props.ts +148 -0
- package/src/Alert/v2/styles.ts +137 -0
- package/src/exports/a.ts +25 -0
- package/src/exports/b.ts +25 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Alert/{index.d.ts → v1/index.d.ts} +1 -1
- package/types/Alert/v1/index.d.ts.map +1 -0
- package/types/Alert/v1/props.d.ts.map +1 -0
- package/types/Alert/v1/styles.d.ts.map +1 -0
- package/types/Alert/v1/theme.d.ts.map +1 -0
- package/types/Alert/v2/index.d.ts +73 -0
- package/types/Alert/v2/index.d.ts.map +1 -0
- package/types/Alert/v2/props.d.ts +92 -0
- package/types/Alert/v2/props.d.ts.map +1 -0
- package/types/Alert/v2/styles.d.ts +15 -0
- package/types/Alert/v2/styles.d.ts.map +1 -0
- package/types/exports/a.d.ts +3 -0
- package/types/exports/a.d.ts.map +1 -0
- package/types/exports/b.d.ts +3 -0
- package/types/exports/b.d.ts.map +1 -0
- package/types/Alert/index.d.ts.map +0 -1
- package/types/Alert/props.d.ts.map +0 -1
- package/types/Alert/styles.d.ts.map +0 -1
- package/types/Alert/theme.d.ts.map +0 -1
- package/types/index.d.ts +0 -3
- package/types/index.d.ts.map +0 -1
- /package/es/Alert/{props.js → v1/props.js} +0 -0
- /package/es/Alert/{styles.js → v1/styles.js} +0 -0
- /package/es/Alert/{theme.js → v1/theme.js} +0 -0
- /package/lib/Alert/{props.js → v1/props.js} +0 -0
- /package/lib/Alert/{styles.js → v1/styles.js} +0 -0
- /package/lib/Alert/{theme.js → v1/theme.js} +0 -0
- /package/src/Alert/{README.md → v1/README.md} +0 -0
- /package/src/Alert/{props.ts → v1/props.ts} +0 -0
- /package/src/Alert/{styles.ts → v1/styles.ts} +0 -0
- /package/src/Alert/{theme.ts → v1/theme.ts} +0 -0
- /package/types/Alert/{props.d.ts → v1/props.d.ts} +0 -0
- /package/types/Alert/{styles.d.ts → v1/styles.d.ts} +0 -0
- /package/types/Alert/{theme.d.ts → v1/theme.d.ts} +0 -0
|
@@ -0,0 +1,148 @@
|
|
|
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 { ReactNode } from 'react'
|
|
26
|
+
|
|
27
|
+
import type {
|
|
28
|
+
Spacing,
|
|
29
|
+
WithStyleProps,
|
|
30
|
+
ComponentStyle
|
|
31
|
+
} from '@instructure/emotion'
|
|
32
|
+
import type { AlertTheme, Renderable } from '@instructure/shared-types'
|
|
33
|
+
import type { WithDeterministicIdProps } from '@instructure/ui-react-utils'
|
|
34
|
+
|
|
35
|
+
type AlertOwnProps = {
|
|
36
|
+
/**
|
|
37
|
+
* content to be rendered within Alert
|
|
38
|
+
*/
|
|
39
|
+
children?: ReactNode
|
|
40
|
+
/**
|
|
41
|
+
* Determines color and icon
|
|
42
|
+
*/
|
|
43
|
+
variant?: 'info' | 'success' | 'warning' | 'error'
|
|
44
|
+
/**
|
|
45
|
+
* How the screen reader should announce the alert variant. While the `variant` prop sets the color and icon for the alert component, this label should be a textual representation of that information. So e.g. if the variant is `info`, this label could be "Information," or "Information alert,". Note the `,` at the end of the label which helps the screenreader to be more natural sounding.
|
|
46
|
+
*/
|
|
47
|
+
variantScreenReaderLabel?: string
|
|
48
|
+
/**
|
|
49
|
+
* A DOM element or function that returns an element where screenreader alerts will be placed.
|
|
50
|
+
*/
|
|
51
|
+
liveRegion?: Element | null | (() => Element | null | undefined)
|
|
52
|
+
/**
|
|
53
|
+
* Choose the politeness level of screenreader alerts, sets the value of
|
|
54
|
+
* `aria-live`.
|
|
55
|
+
*
|
|
56
|
+
* When regions are specified as `polite`, assistive technologies will notify
|
|
57
|
+
* users of updates but generally do not interrupt the current task,
|
|
58
|
+
* and updates take low priority.
|
|
59
|
+
*
|
|
60
|
+
* When regions are specified as `assertive`, assistive technologies will
|
|
61
|
+
* immediately notify the user, and could potentially clear the speech queue
|
|
62
|
+
* of previous updates.
|
|
63
|
+
*/
|
|
64
|
+
liveRegionPoliteness?: 'polite' | 'assertive'
|
|
65
|
+
/**
|
|
66
|
+
* Value for the `aria-atomic` attribute.
|
|
67
|
+
* `aria-atomic` controls how much is read when a change happens. Should only
|
|
68
|
+
* the specific thing that changed be read or should the entire element be
|
|
69
|
+
* read.
|
|
70
|
+
*/
|
|
71
|
+
isLiveRegionAtomic?: boolean
|
|
72
|
+
/**
|
|
73
|
+
* If the alert should only be visible to screen readers
|
|
74
|
+
*/
|
|
75
|
+
screenReaderOnly?: boolean
|
|
76
|
+
/**
|
|
77
|
+
* Milliseconds until the Alert is dismissed automatically
|
|
78
|
+
*/
|
|
79
|
+
timeout?: number
|
|
80
|
+
/**
|
|
81
|
+
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
82
|
+
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
83
|
+
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
84
|
+
*/
|
|
85
|
+
margin?: Spacing
|
|
86
|
+
/**
|
|
87
|
+
* Close button label. Can be a React component
|
|
88
|
+
*/
|
|
89
|
+
renderCloseButtonLabel?: Renderable
|
|
90
|
+
/**
|
|
91
|
+
* Callback after the alert is closed
|
|
92
|
+
*/
|
|
93
|
+
onDismiss?: () => void
|
|
94
|
+
/**
|
|
95
|
+
* Transition used to make the alert appear and disappear
|
|
96
|
+
*/
|
|
97
|
+
transition?: 'none' | 'fade'
|
|
98
|
+
/**
|
|
99
|
+
* if open transitions from truthy to falsey, it's a signal to close and unmount the alert.
|
|
100
|
+
* This is necessary to close the alert from the outside and still run the transition.
|
|
101
|
+
*/
|
|
102
|
+
open?: boolean
|
|
103
|
+
/**
|
|
104
|
+
* If the alert should have a shadow.
|
|
105
|
+
*/
|
|
106
|
+
hasShadow: boolean
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* An icon, or function that returns an icon. Setting it will override the variant's icon.
|
|
110
|
+
*/
|
|
111
|
+
renderCustomIcon?: Renderable
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
type PropKeys = keyof AlertOwnProps
|
|
115
|
+
|
|
116
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
117
|
+
|
|
118
|
+
type AlertProps = AlertOwnProps &
|
|
119
|
+
WithStyleProps<AlertTheme, AlertStyle> &
|
|
120
|
+
WithDeterministicIdProps
|
|
121
|
+
|
|
122
|
+
type AlertStyle = ComponentStyle<
|
|
123
|
+
'alert' | 'icon' | 'closeButton' | 'content' | 'variantScreenReaderLabel'
|
|
124
|
+
>
|
|
125
|
+
|
|
126
|
+
const allowedProps: AllowedPropKeys = [
|
|
127
|
+
'children',
|
|
128
|
+
'variant',
|
|
129
|
+
'margin',
|
|
130
|
+
'liveRegion',
|
|
131
|
+
'liveRegionPoliteness',
|
|
132
|
+
'isLiveRegionAtomic',
|
|
133
|
+
'screenReaderOnly',
|
|
134
|
+
'timeout',
|
|
135
|
+
'renderCloseButtonLabel',
|
|
136
|
+
'onDismiss',
|
|
137
|
+
'transition',
|
|
138
|
+
'open',
|
|
139
|
+
'hasShadow',
|
|
140
|
+
'renderCustomIcon'
|
|
141
|
+
]
|
|
142
|
+
|
|
143
|
+
type AlertState = {
|
|
144
|
+
open: boolean
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export type { AlertProps, AlertStyle, AlertState }
|
|
148
|
+
export { allowedProps }
|
|
@@ -0,0 +1,137 @@
|
|
|
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, SharedTokens } from '@instructure/ui-themes'
|
|
26
|
+
import { boxShadowObjectsToCSSString } from '@instructure/ui-themes'
|
|
27
|
+
import type { AlertProps, AlertStyle } from './props'
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* ---
|
|
31
|
+
* private: true
|
|
32
|
+
* ---
|
|
33
|
+
* Generates the style object from the theme and provided additional information
|
|
34
|
+
* @param {Object} componentTheme The theme variable object.
|
|
35
|
+
* @param {Object} props the props of the component, the style is applied to
|
|
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['Alert'],
|
|
41
|
+
props: AlertProps,
|
|
42
|
+
sharedTokens: SharedTokens
|
|
43
|
+
): AlertStyle => {
|
|
44
|
+
const { variant, hasShadow } = props
|
|
45
|
+
|
|
46
|
+
const variantStyles = {
|
|
47
|
+
error: {
|
|
48
|
+
alert: { borderColor: componentTheme.dangerBorderColor },
|
|
49
|
+
icon: {
|
|
50
|
+
background: componentTheme.dangerIconBackground,
|
|
51
|
+
borderRightColor: componentTheme.dangerIconBackground
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
info: {
|
|
55
|
+
alert: { borderColor: componentTheme.infoBorderColor },
|
|
56
|
+
icon: {
|
|
57
|
+
background: componentTheme.infoIconBackground,
|
|
58
|
+
borderRightColor: componentTheme.infoIconBackground
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
success: {
|
|
62
|
+
alert: { borderColor: componentTheme.successBorderColor },
|
|
63
|
+
icon: {
|
|
64
|
+
backgroundColor: componentTheme.successIconBackground,
|
|
65
|
+
borderRightColor: componentTheme.successIconBackground
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
warning: {
|
|
69
|
+
alert: { borderColor: componentTheme.warningBorderColor },
|
|
70
|
+
icon: {
|
|
71
|
+
background: componentTheme.warningIconBackground,
|
|
72
|
+
borderRightColor: componentTheme.warningIconBackground
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
alert: {
|
|
79
|
+
label: 'alert',
|
|
80
|
+
color: componentTheme.color,
|
|
81
|
+
background: componentTheme.background,
|
|
82
|
+
boxSizing: 'border-box',
|
|
83
|
+
display: 'flex',
|
|
84
|
+
minWidth: '12rem',
|
|
85
|
+
borderWidth: componentTheme.borderWidth,
|
|
86
|
+
borderStyle: componentTheme.borderStyle,
|
|
87
|
+
borderRadius: componentTheme.borderRadius,
|
|
88
|
+
...variantStyles[variant!].alert,
|
|
89
|
+
...(hasShadow && {
|
|
90
|
+
boxShadow: boxShadowObjectsToCSSString(
|
|
91
|
+
sharedTokens.boxShadow.elevation4
|
|
92
|
+
)
|
|
93
|
+
})
|
|
94
|
+
},
|
|
95
|
+
icon: {
|
|
96
|
+
color: componentTheme.iconColor,
|
|
97
|
+
boxSizing: 'border-box',
|
|
98
|
+
flex: '0 0 2.5rem',
|
|
99
|
+
display: 'flex',
|
|
100
|
+
alignItems: 'center',
|
|
101
|
+
justifyContent: 'center',
|
|
102
|
+
fontSize: '1.125rem',
|
|
103
|
+
borderRight: `${componentTheme.borderWidth} ${componentTheme.borderStyle}`,
|
|
104
|
+
margin: -1,
|
|
105
|
+
borderStartStartRadius: componentTheme.borderRadius,
|
|
106
|
+
borderEndStartRadius: componentTheme.borderRadius,
|
|
107
|
+
...variantStyles[variant!].icon
|
|
108
|
+
},
|
|
109
|
+
closeButton: {
|
|
110
|
+
boxSizing: 'border-box',
|
|
111
|
+
display: 'flex',
|
|
112
|
+
alignItems: 'flex-start',
|
|
113
|
+
order: 1,
|
|
114
|
+
marginTop: componentTheme.closeButtonMarginTop,
|
|
115
|
+
marginRight: componentTheme.closeButtonMarginRight
|
|
116
|
+
},
|
|
117
|
+
content: {
|
|
118
|
+
boxSizing: 'border-box',
|
|
119
|
+
flex: 1,
|
|
120
|
+
minWidth: '0.0625rem',
|
|
121
|
+
fontSize: componentTheme.contentFontSize,
|
|
122
|
+
fontFamily: componentTheme.contentFontFamily,
|
|
123
|
+
fontWeight: componentTheme.contentFontWeight,
|
|
124
|
+
lineHeight: componentTheme.contentLineHeight,
|
|
125
|
+
padding: `${componentTheme.contentPaddingVertical} ${componentTheme.contentPaddingHorizontal}`
|
|
126
|
+
},
|
|
127
|
+
variantScreenReaderLabel: {
|
|
128
|
+
position: 'absolute',
|
|
129
|
+
height: '1px',
|
|
130
|
+
width: '1px',
|
|
131
|
+
overflow: 'hidden',
|
|
132
|
+
margin: '-1px'
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export default generateStyle
|
package/src/exports/a.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
export { Alert } from '../Alert/v1'
|
|
25
|
+
export type { AlertProps } from '../Alert/v1/props'
|
package/src/exports/b.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
export { Alert } from '../Alert/v2'
|
|
25
|
+
export type { AlertProps } from '../Alert/v2/props'
|