@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.
Files changed (67) hide show
  1. package/CHANGELOG.md +42 -2
  2. package/lib/Autocomplete/Autocomplete.js +36 -2
  3. package/lib/Card/CardBase.js +4 -0
  4. package/lib/Carousel/Carousel.js +1 -1
  5. package/lib/Carousel/CarouselItem/CarouselItem.js +15 -19
  6. package/lib/InputLabel/InputLabel.js +2 -3
  7. package/lib/List/ListItemBase.js +3 -1
  8. package/lib/Listbox/GroupControl.js +4 -0
  9. package/lib/Modal/Modal.js +34 -13
  10. package/lib/Modal/ModalContent.js +4 -3
  11. package/lib/Modal/WebModal.js +1 -0
  12. package/lib/Notification/Notification.js +5 -5
  13. package/lib/Pagination/Pagination.js +9 -2
  14. package/lib/Pagination/constants.js +12 -0
  15. package/lib/Pagination/usePagination.js +13 -3
  16. package/lib/PriceLockup/PriceLockup.js +11 -3
  17. package/lib/Progress/Progress.js +5 -2
  18. package/lib/Progress/ProgressBar.js +4 -1
  19. package/lib/Tooltip/Tooltip.native.js +31 -3
  20. package/lib/Tooltip/shared.js +5 -0
  21. package/lib/Typography/Typography.js +42 -19
  22. package/lib/index.js +7 -0
  23. package/lib-module/Autocomplete/Autocomplete.js +36 -2
  24. package/lib-module/Card/CardBase.js +4 -0
  25. package/lib-module/Carousel/Carousel.js +1 -1
  26. package/lib-module/Carousel/CarouselItem/CarouselItem.js +15 -19
  27. package/lib-module/InputLabel/InputLabel.js +2 -3
  28. package/lib-module/List/ListItemBase.js +3 -1
  29. package/lib-module/Listbox/GroupControl.js +4 -0
  30. package/lib-module/Modal/Modal.js +34 -13
  31. package/lib-module/Modal/ModalContent.js +4 -3
  32. package/lib-module/Modal/WebModal.js +1 -0
  33. package/lib-module/Notification/Notification.js +5 -5
  34. package/lib-module/Pagination/Pagination.js +9 -2
  35. package/lib-module/Pagination/constants.js +3 -0
  36. package/lib-module/Pagination/usePagination.js +13 -3
  37. package/lib-module/PriceLockup/PriceLockup.js +11 -3
  38. package/lib-module/Progress/Progress.js +6 -3
  39. package/lib-module/Progress/ProgressBar.js +5 -2
  40. package/lib-module/Tooltip/Tooltip.native.js +31 -3
  41. package/lib-module/Tooltip/shared.js +5 -0
  42. package/lib-module/Typography/Typography.js +42 -19
  43. package/lib-module/index.js +1 -1
  44. package/package.json +2 -2
  45. package/src/Autocomplete/Autocomplete.jsx +41 -2
  46. package/src/Card/CardBase.jsx +6 -0
  47. package/src/Carousel/Carousel.jsx +1 -1
  48. package/src/Carousel/CarouselItem/CarouselItem.jsx +16 -22
  49. package/src/InputLabel/InputLabel.jsx +2 -3
  50. package/src/List/ListItemBase.jsx +6 -1
  51. package/src/Listbox/GroupControl.jsx +6 -1
  52. package/src/Modal/Modal.jsx +40 -14
  53. package/src/Modal/ModalContent.jsx +4 -3
  54. package/src/Modal/WebModal.jsx +1 -1
  55. package/src/Notification/Notification.jsx +5 -5
  56. package/src/Pagination/Pagination.jsx +9 -2
  57. package/src/Pagination/constants.js +3 -0
  58. package/src/Pagination/usePagination.js +14 -3
  59. package/src/PriceLockup/PriceLockup.jsx +9 -1
  60. package/src/Progress/Progress.jsx +6 -3
  61. package/src/Progress/ProgressBar.jsx +4 -2
  62. package/src/Tooltip/Tooltip.native.jsx +31 -3
  63. package/src/Tooltip/shared.js +5 -0
  64. package/src/Typography/Typography.jsx +37 -13
  65. package/src/index.js +2 -1
  66. package/types/FileUpload.d.ts +40 -0
  67. 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) => control(getPressableState(pressableState), variant)
286
+ ? (pressableState) =>
287
+ control(getPressableState(pressableState), variant, tooltipButtonTokens)
260
288
  : control}
261
289
  </Pressable>
262
290
  {isOpen && (
@@ -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 === 'object' && (child?.type === 'sub' || child?.type === 'sup')) {
179
- const childStyles = child?.props?.style || {}
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
- return child
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
@@ -81,7 +81,8 @@ export {
81
81
  getThemeTokens,
82
82
  applyOuterBorder,
83
83
  applyTextStyles,
84
- applyShadowToken
84
+ applyShadowToken,
85
+ useResponsiveThemeTokens
85
86
  } from './ThemeProvider'
86
87
 
87
88
  export * from './utils'
@@ -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