@telus-uds/components-base 1.95.0 → 1.97.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 +42 -2
- package/lib/Autocomplete/Autocomplete.js +36 -2
- package/lib/Card/CardBase.js +4 -0
- package/lib/Carousel/Carousel.js +1 -1
- package/lib/Carousel/CarouselItem/CarouselItem.js +15 -19
- package/lib/InputLabel/InputLabel.js +2 -3
- package/lib/List/ListItemBase.js +3 -1
- package/lib/Listbox/GroupControl.js +4 -0
- package/lib/Modal/Modal.js +34 -13
- package/lib/Modal/ModalContent.js +4 -3
- package/lib/Modal/WebModal.js +1 -0
- package/lib/Notification/Notification.js +5 -5
- package/lib/Pagination/Pagination.js +9 -2
- package/lib/Pagination/constants.js +12 -0
- package/lib/Pagination/usePagination.js +13 -3
- package/lib/PriceLockup/PriceLockup.js +11 -3
- package/lib/Progress/Progress.js +5 -2
- package/lib/Progress/ProgressBar.js +4 -1
- package/lib/Tooltip/Tooltip.native.js +31 -3
- package/lib/Tooltip/shared.js +5 -0
- package/lib/Typography/Typography.js +42 -19
- package/lib/index.js +7 -0
- package/lib-module/Autocomplete/Autocomplete.js +36 -2
- package/lib-module/Card/CardBase.js +4 -0
- package/lib-module/Carousel/Carousel.js +1 -1
- package/lib-module/Carousel/CarouselItem/CarouselItem.js +15 -19
- package/lib-module/InputLabel/InputLabel.js +2 -3
- package/lib-module/List/ListItemBase.js +3 -1
- package/lib-module/Listbox/GroupControl.js +4 -0
- package/lib-module/Modal/Modal.js +34 -13
- package/lib-module/Modal/ModalContent.js +4 -3
- package/lib-module/Modal/WebModal.js +1 -0
- package/lib-module/Notification/Notification.js +5 -5
- package/lib-module/Pagination/Pagination.js +9 -2
- package/lib-module/Pagination/constants.js +3 -0
- package/lib-module/Pagination/usePagination.js +13 -3
- package/lib-module/PriceLockup/PriceLockup.js +11 -3
- package/lib-module/Progress/Progress.js +6 -3
- package/lib-module/Progress/ProgressBar.js +5 -2
- package/lib-module/Tooltip/Tooltip.native.js +31 -3
- package/lib-module/Tooltip/shared.js +5 -0
- package/lib-module/Typography/Typography.js +42 -19
- package/lib-module/index.js +1 -1
- package/package.json +2 -2
- package/src/Autocomplete/Autocomplete.jsx +41 -2
- package/src/Card/CardBase.jsx +6 -0
- package/src/Carousel/Carousel.jsx +1 -1
- package/src/Carousel/CarouselItem/CarouselItem.jsx +16 -22
- package/src/InputLabel/InputLabel.jsx +2 -3
- package/src/List/ListItemBase.jsx +6 -1
- package/src/Listbox/GroupControl.jsx +6 -1
- package/src/Modal/Modal.jsx +40 -14
- package/src/Modal/ModalContent.jsx +4 -3
- package/src/Modal/WebModal.jsx +1 -1
- package/src/Notification/Notification.jsx +5 -5
- package/src/Pagination/Pagination.jsx +9 -2
- package/src/Pagination/constants.js +3 -0
- package/src/Pagination/usePagination.js +14 -3
- package/src/PriceLockup/PriceLockup.jsx +9 -1
- package/src/Progress/Progress.jsx +6 -3
- package/src/Progress/ProgressBar.jsx +4 -2
- package/src/Tooltip/Tooltip.native.jsx +31 -3
- package/src/Tooltip/shared.js +5 -0
- package/src/Typography/Typography.jsx +37 -13
- package/src/index.js +2 -1
- package/types/FileUpload.d.ts +40 -0
- package/types/index.d.ts +3 -0
|
@@ -2,7 +2,7 @@ import React from 'react'
|
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import { View } from 'react-native'
|
|
4
4
|
|
|
5
|
-
import { useThemeTokens } from '../ThemeProvider'
|
|
5
|
+
import { applyShadowToken, useThemeTokens } from '../ThemeProvider'
|
|
6
6
|
import { a11yProps, getTokensPropType, selectSystemProps, variantProp, viewProps } from '../utils'
|
|
7
7
|
|
|
8
8
|
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps])
|
|
@@ -12,13 +12,15 @@ const selectProgressStyles = ({
|
|
|
12
12
|
borderWidth,
|
|
13
13
|
borderColor,
|
|
14
14
|
borderRadius,
|
|
15
|
-
height
|
|
15
|
+
height,
|
|
16
|
+
shadow
|
|
16
17
|
}) => ({
|
|
17
18
|
backgroundColor,
|
|
18
19
|
borderWidth,
|
|
19
20
|
borderColor,
|
|
20
21
|
borderRadius,
|
|
21
|
-
height
|
|
22
|
+
height,
|
|
23
|
+
...applyShadowToken(shadow)
|
|
22
24
|
})
|
|
23
25
|
|
|
24
26
|
/**
|
|
@@ -37,6 +39,7 @@ const selectProgressStyles = ({
|
|
|
37
39
|
* - `borderRadius` for the rounded corners,
|
|
38
40
|
* - `borderWidth` to change the border width.
|
|
39
41
|
* - `height` to control the height of the progress bars displayed within the progress bar container.
|
|
42
|
+
* - `shadow` to apply a box shadow to the progress bar container.
|
|
40
43
|
*
|
|
41
44
|
* ## Variants
|
|
42
45
|
*
|
|
@@ -3,19 +3,20 @@ import PropTypes from 'prop-types'
|
|
|
3
3
|
import { Platform, StyleSheet, View } from 'react-native'
|
|
4
4
|
|
|
5
5
|
import ProgressBarBackground from './ProgressBarBackground'
|
|
6
|
-
import { useThemeTokens } from '../ThemeProvider'
|
|
6
|
+
import { applyShadowToken, useThemeTokens } from '../ThemeProvider'
|
|
7
7
|
import { a11yProps, getTokensPropType, selectSystemProps, variantProp, viewProps } from '../utils'
|
|
8
8
|
|
|
9
9
|
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps])
|
|
10
10
|
|
|
11
11
|
const selectBarStyles = (
|
|
12
|
-
{ backgroundColor, borderRadius, outlineWidth, outlineColor },
|
|
12
|
+
{ backgroundColor, borderRadius, outlineWidth, outlineColor, shadow },
|
|
13
13
|
percentage
|
|
14
14
|
) => ({
|
|
15
15
|
backgroundColor,
|
|
16
16
|
borderRadius,
|
|
17
17
|
outlineWidth,
|
|
18
18
|
outlineColor,
|
|
19
|
+
...applyShadowToken(shadow),
|
|
19
20
|
width: `${percentage}%`
|
|
20
21
|
})
|
|
21
22
|
|
|
@@ -34,6 +35,7 @@ const selectBarStyles = (
|
|
|
34
35
|
* - `borderRadius` for the rounded corners,
|
|
35
36
|
* - `outlineColor` to control the color of the border (outline),
|
|
36
37
|
* - `outlineWidth` to change the outline width.
|
|
38
|
+
* - `shadow` to apply a box shadow to the progress bar.
|
|
37
39
|
*
|
|
38
40
|
* ## Variants
|
|
39
41
|
*
|
|
@@ -88,8 +88,8 @@ const selectArrowStyles = (
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
const selectTextStyles = (tokens) => applyTextStyles(selectTokens('Typography', tokens))
|
|
91
|
-
const defaultControl = (pressableState, variant) => (
|
|
92
|
-
<TooltipButton pressableState={pressableState} variant={variant} />
|
|
91
|
+
const defaultControl = (pressableState, variant, tokens) => (
|
|
92
|
+
<TooltipButton pressableState={pressableState} variant={variant} tokens={tokens} />
|
|
93
93
|
)
|
|
94
94
|
|
|
95
95
|
/**
|
|
@@ -119,6 +119,8 @@ const Tooltip = React.forwardRef(
|
|
|
119
119
|
variant,
|
|
120
120
|
inline = false,
|
|
121
121
|
nativeID,
|
|
122
|
+
activateOnHover = false,
|
|
123
|
+
tooltipButtonTokens,
|
|
122
124
|
...rest
|
|
123
125
|
},
|
|
124
126
|
ref
|
|
@@ -227,6 +229,31 @@ const Tooltip = React.forwardRef(
|
|
|
227
229
|
tooltipPosition
|
|
228
230
|
])
|
|
229
231
|
|
|
232
|
+
React.useEffect(() => {
|
|
233
|
+
if (Platform.OS !== 'web') {
|
|
234
|
+
return undefined
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
const handleHover = (event) => {
|
|
238
|
+
if (activateOnHover) {
|
|
239
|
+
const isInsideControl = controlRef.current && controlRef.current.contains(event.target)
|
|
240
|
+
if (isInsideControl) {
|
|
241
|
+
if (!isOpen) {
|
|
242
|
+
setIsOpen(!isOpen)
|
|
243
|
+
}
|
|
244
|
+
} else {
|
|
245
|
+
close()
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
document.addEventListener('mouseover', handleHover, { capture: true })
|
|
251
|
+
|
|
252
|
+
return () => {
|
|
253
|
+
document.removeEventListener('mouseover', handleHover, { capture: true })
|
|
254
|
+
}
|
|
255
|
+
}, [controlLayout, activateOnHover, isOpen, onPress])
|
|
256
|
+
|
|
230
257
|
const control = children !== undefined ? children : defaultControl
|
|
231
258
|
const pressableStyles =
|
|
232
259
|
control === defaultControl ? Platform.select({ web: { outline: 'none' } }) : undefined
|
|
@@ -256,7 +283,8 @@ const Tooltip = React.forwardRef(
|
|
|
256
283
|
nativeID={nativeID}
|
|
257
284
|
>
|
|
258
285
|
{typeof control === 'function'
|
|
259
|
-
? (pressableState) =>
|
|
286
|
+
? (pressableState) =>
|
|
287
|
+
control(getPressableState(pressableState), variant, tooltipButtonTokens)
|
|
260
288
|
: control}
|
|
261
289
|
</Pressable>
|
|
262
290
|
{isOpen && (
|
package/src/Tooltip/shared.js
CHANGED
|
@@ -32,6 +32,11 @@ const propTypes = {
|
|
|
32
32
|
* The `id` of the tooltip button.
|
|
33
33
|
*/
|
|
34
34
|
nativeID: PropTypes.string,
|
|
35
|
+
/**
|
|
36
|
+
* Set to `true` to open the tooltip on hover
|
|
37
|
+
*/
|
|
38
|
+
activateOnHover: PropTypes.bool,
|
|
39
|
+
tooltipButtonTokens: getTokensPropType('TooltipButton'),
|
|
35
40
|
tokens: getTokensPropType('Tooltip'),
|
|
36
41
|
variant: variantProp.propType
|
|
37
42
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
|
-
import { Text, View } from 'react-native'
|
|
3
|
+
import { Text, View, Platform } from 'react-native'
|
|
4
4
|
|
|
5
5
|
import { useResponsiveThemeTokens, useTheme, useThemeTokens } from '../ThemeProvider'
|
|
6
6
|
import { applyTextStyles } from '../ThemeProvider/utils'
|
|
@@ -54,6 +54,16 @@ const selectTextStyles = (
|
|
|
54
54
|
gradient
|
|
55
55
|
})
|
|
56
56
|
|
|
57
|
+
const HALF_FONT_SIZE = 2
|
|
58
|
+
const QUARTER_FONT_SIZE = 4
|
|
59
|
+
|
|
60
|
+
const selectMobileSubSupStyles = ({ fontSize }, type) => ({
|
|
61
|
+
fontSize: fontSize / HALF_FONT_SIZE,
|
|
62
|
+
lineHeight: fontSize,
|
|
63
|
+
position: 'relative',
|
|
64
|
+
top: type === 'sub' ? fontSize / QUARTER_FONT_SIZE : -fontSize / QUARTER_FONT_SIZE
|
|
65
|
+
})
|
|
66
|
+
|
|
57
67
|
// General-purpose flexible theme-neutral base component for text
|
|
58
68
|
const Typography = React.forwardRef(
|
|
59
69
|
(
|
|
@@ -175,19 +185,33 @@ const Typography = React.forwardRef(
|
|
|
175
185
|
}
|
|
176
186
|
|
|
177
187
|
const resetTagStyling = (child) => {
|
|
178
|
-
if (typeof child
|
|
179
|
-
|
|
180
|
-
const supFontSize = childStyles.fontSize ?? themeTokens.superScriptFontSize
|
|
181
|
-
const sanitizedChild = React.cloneElement(child, {
|
|
182
|
-
style: {
|
|
183
|
-
...childStyles,
|
|
184
|
-
...(supFontSize ? { fontSize: supFontSize } : {}),
|
|
185
|
-
lineHeight: 0
|
|
186
|
-
}
|
|
187
|
-
})
|
|
188
|
-
return sanitizedChild
|
|
188
|
+
if (typeof child !== 'object' || !(child?.type === 'sub' || child?.type === 'sup')) {
|
|
189
|
+
return child
|
|
189
190
|
}
|
|
190
|
-
|
|
191
|
+
|
|
192
|
+
const childStyles = child?.props?.style || {}
|
|
193
|
+
const supFontSize = childStyles.fontSize ?? themeTokens.superScriptFontSize
|
|
194
|
+
const isMobile = Platform.OS === 'ios' || Platform.OS === 'android'
|
|
195
|
+
const isSubSup = child?.type === 'sub' || child?.type === 'sup'
|
|
196
|
+
|
|
197
|
+
const mobileStyles =
|
|
198
|
+
isMobile && isSubSup ? selectMobileSubSupStyles(themeTokens, child?.type) : {}
|
|
199
|
+
const defaultStyles = !isMobile && isSubSup ? { fontSize: supFontSize, lineHeight: 0 } : {}
|
|
200
|
+
|
|
201
|
+
const sanitizedChild = React.cloneElement(
|
|
202
|
+
isMobile && isSubSup ? (
|
|
203
|
+
<View>
|
|
204
|
+
<Text style={[childStyles, mobileStyles]}>{child.props.children}</Text>
|
|
205
|
+
</View>
|
|
206
|
+
) : (
|
|
207
|
+
child
|
|
208
|
+
),
|
|
209
|
+
{
|
|
210
|
+
style: { ...childStyles, ...defaultStyles }
|
|
211
|
+
}
|
|
212
|
+
)
|
|
213
|
+
|
|
214
|
+
return sanitizedChild
|
|
191
215
|
}
|
|
192
216
|
|
|
193
217
|
const sanitizeChildren = () => {
|
package/src/index.js
CHANGED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ComponentType } from 'react'
|
|
2
|
+
|
|
3
|
+
export interface FileUploadTokens {
|
|
4
|
+
buttonBackgroundColor?: string
|
|
5
|
+
buttonBorderColor?: string
|
|
6
|
+
buttonBorderRadius?: number
|
|
7
|
+
buttonBorderWidth?: string
|
|
8
|
+
buttonTextColor?: string
|
|
9
|
+
buttonHeight?: string
|
|
10
|
+
buttonMinWidth?: string
|
|
11
|
+
buttonWidth?: string
|
|
12
|
+
notificationBackgroundColor?: string
|
|
13
|
+
notificationBorderColor?: string
|
|
14
|
+
notificationBorderRadius?: number
|
|
15
|
+
notificationTextColor?: string
|
|
16
|
+
notificationDismissButtonGap?: string
|
|
17
|
+
notificationDismissIcon?: string
|
|
18
|
+
notificationDismissIconColor?: string
|
|
19
|
+
notificationIcon?: string
|
|
20
|
+
notificationIconColor?: string
|
|
21
|
+
notificationIconGap?: string
|
|
22
|
+
notificationIconSize?: number
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface FileUploadProps {
|
|
26
|
+
tokens?: FileUploadTokens
|
|
27
|
+
variant?: Record<string, any>
|
|
28
|
+
copy?: 'en' | 'fr'
|
|
29
|
+
fileTypes?: string[]
|
|
30
|
+
allowMultipleFiles?: boolean
|
|
31
|
+
maxFileSize?: number
|
|
32
|
+
maxFilesCount?: number
|
|
33
|
+
onUpload?: (files: any) => void
|
|
34
|
+
onDelete?: (file: any) => void
|
|
35
|
+
documentPicker?: Record<string, any>
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
declare const FileUpload: ComponentType<FileUploadProps>
|
|
39
|
+
|
|
40
|
+
export default FileUpload
|
package/types/index.d.ts
CHANGED
|
@@ -30,6 +30,9 @@ export {
|
|
|
30
30
|
ExpandCollapsePanelProps
|
|
31
31
|
} from './ExpandCollapse'
|
|
32
32
|
|
|
33
|
+
export { default as FileUpload } from './FileUpload'
|
|
34
|
+
export { FileUploadTokens, FileUploadProps } from './FileUpload'
|
|
35
|
+
|
|
33
36
|
export { default as HorizontalScrollButton } from './HorizontalScrollButton'
|
|
34
37
|
export { HorizontalScrollButtonTokens } from './HorizontalScrollButton'
|
|
35
38
|
|