@telus-uds/components-base 1.59.2 → 1.61.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 (90) hide show
  1. package/CHANGELOG.md +26 -2
  2. package/component-docs.json +526 -76
  3. package/lib/Autocomplete/Autocomplete.js +483 -0
  4. package/lib/Autocomplete/Loading.js +51 -0
  5. package/lib/Autocomplete/Suggestions.js +85 -0
  6. package/lib/Autocomplete/constants.js +14 -0
  7. package/lib/Autocomplete/dictionary.js +19 -0
  8. package/lib/Autocomplete/index.js +13 -0
  9. package/lib/Button/ButtonLink.js +7 -3
  10. package/lib/ExpandCollapse/Panel.js +7 -0
  11. package/lib/IconButton/IconButton.js +8 -0
  12. package/lib/Link/ChevronLink.js +9 -2
  13. package/lib/Link/LinkBase.js +14 -0
  14. package/lib/Link/TextButton.js +12 -1
  15. package/lib/Listbox/GroupControl.js +121 -0
  16. package/lib/Listbox/Listbox.js +198 -0
  17. package/lib/Listbox/ListboxGroup.js +142 -0
  18. package/lib/Listbox/ListboxItem.js +97 -0
  19. package/lib/Listbox/ListboxOverlay.js +106 -0
  20. package/lib/Listbox/PressableItem.js +0 -2
  21. package/lib/Listbox/index.js +5 -24
  22. package/lib/Pagination/dictionary.js +3 -3
  23. package/lib/Progress/ProgressBarBackground.js +2 -2
  24. package/lib/SideNav/Item.js +15 -5
  25. package/lib/Tags/Tags.js +6 -1
  26. package/lib/TextInput/TextInputBase.js +2 -0
  27. package/lib/Tooltip/Tooltip.js +6 -1
  28. package/lib/Tooltip/Tooltip.native.js +6 -1
  29. package/lib/Tooltip/shared.js +5 -0
  30. package/lib/index.js +17 -13
  31. package/lib/utils/useOverlaidPosition.js +6 -4
  32. package/lib-module/Autocomplete/Autocomplete.js +448 -0
  33. package/lib-module/Autocomplete/Loading.js +36 -0
  34. package/lib-module/Autocomplete/Suggestions.js +66 -0
  35. package/lib-module/Autocomplete/constants.js +4 -0
  36. package/lib-module/Autocomplete/dictionary.js +12 -0
  37. package/lib-module/Autocomplete/index.js +2 -0
  38. package/lib-module/Button/ButtonLink.js +4 -1
  39. package/lib-module/ExpandCollapse/Panel.js +7 -0
  40. package/lib-module/IconButton/IconButton.js +8 -0
  41. package/lib-module/Link/ChevronLink.js +10 -3
  42. package/lib-module/Link/LinkBase.js +14 -0
  43. package/lib-module/Link/TextButton.js +11 -1
  44. package/lib-module/Listbox/GroupControl.js +102 -0
  45. package/lib-module/Listbox/Listbox.js +172 -0
  46. package/lib-module/Listbox/ListboxGroup.js +117 -0
  47. package/lib-module/Listbox/ListboxItem.js +71 -0
  48. package/lib-module/Listbox/ListboxOverlay.js +80 -0
  49. package/lib-module/Listbox/PressableItem.js +0 -2
  50. package/lib-module/Listbox/index.js +2 -2
  51. package/lib-module/Pagination/dictionary.js +3 -3
  52. package/lib-module/Progress/ProgressBarBackground.js +2 -2
  53. package/lib-module/SideNav/Item.js +15 -5
  54. package/lib-module/Tags/Tags.js +6 -1
  55. package/lib-module/TextInput/TextInputBase.js +2 -0
  56. package/lib-module/Tooltip/Tooltip.js +6 -1
  57. package/lib-module/Tooltip/Tooltip.native.js +6 -1
  58. package/lib-module/Tooltip/shared.js +5 -0
  59. package/lib-module/index.js +2 -1
  60. package/lib-module/utils/useOverlaidPosition.js +5 -4
  61. package/package.json +5 -3
  62. package/src/Autocomplete/Autocomplete.jsx +411 -0
  63. package/src/Autocomplete/Loading.jsx +18 -0
  64. package/src/Autocomplete/Suggestions.jsx +54 -0
  65. package/src/Autocomplete/constants.js +4 -0
  66. package/src/Autocomplete/dictionary.js +12 -0
  67. package/src/Autocomplete/index.js +3 -0
  68. package/src/Button/ButtonLink.jsx +4 -1
  69. package/src/ExpandCollapse/Panel.jsx +11 -1
  70. package/src/IconButton/IconButton.jsx +7 -0
  71. package/src/Link/ChevronLink.jsx +10 -3
  72. package/src/Link/LinkBase.jsx +11 -0
  73. package/src/Link/TextButton.jsx +8 -2
  74. package/src/Listbox/GroupControl.jsx +93 -0
  75. package/src/Listbox/Listbox.jsx +165 -0
  76. package/src/Listbox/ListboxGroup.jsx +120 -0
  77. package/src/Listbox/ListboxItem.jsx +76 -0
  78. package/src/Listbox/ListboxOverlay.jsx +82 -0
  79. package/src/Listbox/PressableItem.jsx +0 -2
  80. package/src/Listbox/index.js +3 -2
  81. package/src/Pagination/dictionary.js +3 -3
  82. package/src/Progress/ProgressBarBackground.jsx +2 -2
  83. package/src/SideNav/Item.jsx +13 -5
  84. package/src/Tags/Tags.jsx +5 -1
  85. package/src/TextInput/TextInputBase.jsx +2 -0
  86. package/src/Tooltip/Tooltip.jsx +16 -2
  87. package/src/Tooltip/Tooltip.native.jsx +15 -2
  88. package/src/Tooltip/shared.js +4 -0
  89. package/src/index.js +2 -1
  90. package/src/utils/useOverlaidPosition.js +6 -5
@@ -3,8 +3,8 @@ import { ImageBackground, StyleSheet } from 'react-native'
3
3
 
4
4
  import { variantProp } from '../utils'
5
5
 
6
- const inactiveBackground = `%3Csvg xmlns='http://www.w3.org/2000/svg' width='100%25' height='24'%3E%3Cdefs%3E%3Cpattern id='DisabledProgress7' patternUnits='userSpaceOnUse' width='8' height='8'%3E%3Crect width='8' height='8' fill='%23B2B9BF'%3E%3C/rect%3E%3Ccircle cx='4' cy='4' r='2' fill='%23676E73' stroke='%23676E73' stroke-width='0'%3E%3C/circle%3E%3Ccircle cx='0' cy='0' r='2' fill='%23676E73' stroke='%23676E73' stroke-width='0'%3E%3C/circle%3E%3Ccircle cx='0' cy='8' r='2' fill='%23676E73' stroke='%23676E73' stroke-width='0'%3E%3C/circle%3E%3Ccircle cx='8' cy='0' r='2' fill='%23676E73' stroke='%23676E73' stroke-width='0'%3E%3C/circle%3E%3Ccircle cx='8' cy='8' r='2' fill='%23676E73' stroke='%23676E73' stroke-width='0'%3E%3C/circle%3E%3C/pattern%3E%3C/defs%3E%3Cpath d='M 0 0 L 0 140 L 2000 2000 L 2000 0 Z' style='fill: url("%23DisabledProgress7");'%3E%3C/path%3E%3C/svg%3E`
7
- const negativeBackground = `%3Csvg xmlns='http://www.w3.org/2000/svg' width='100%25' height='24'%3E%3Cdefs%3E%3Cpattern id='NegativeProgress6' patternUnits='userSpaceOnUse' width='8' height='8'%3E%3Crect width='8' height='8' fill='%23C12335'%3E%3C/rect%3E%3Cpath d='M 0,8 l 8,-8 M -2,2 l 4,-4 M 6,10 l 4,-4' stroke-width='2' shape-rendering='auto' stroke='%23e7adb4' stroke-linecap='square'%3E%3C/path%3E%3C/pattern%3E%3C/defs%3E%3Cpath d='M 0 0 L 0 140 L 2000 2000 L 2000 0 Z' style='fill: url("%23NegativeProgress6");'%3E%3C/path%3E%3C/svg%3E`
6
+ const inactiveBackground = `%3Csvg xmlns='http://www.w3.org/2000/svg' width='100%25' height='24'%3E%3Cdefs%3E%3Cpattern id='inactive' patternUnits='userSpaceOnUse' width='8' height='8'%3E%3Crect width='8' height='8' fill='rgba(255, 255, 255, 0)'%3E%3C/rect%3E%3Ccircle cx='4' cy='4' r='2' fill='rgba(0, 0, 0, 0.4)' stroke='rgba(0, 0, 0, 0.4)' stroke-width='0'%3E%3C/circle%3E%3Ccircle cx='0' cy='0' r='2' fill='rgba(0, 0, 0, 0.4)' stroke='rgba(0, 0, 0, 0.4)' stroke-width='0'%3E%3C/circle%3E%3Ccircle cx='0' cy='8' r='2' fill='rgba(0, 0, 0, 0.4)' stroke='rgba(0, 0, 0, 0.4)' stroke-width='0'%3E%3C/circle%3E%3Ccircle cx='8' cy='0' r='2' fill='rgba(0, 0, 0, 0.4)' stroke='rgba(0, 0, 0, 0.4)' stroke-width='0'%3E%3C/circle%3E%3Ccircle cx='8' cy='8' r='2' fill='rgba(0, 0, 0, 0.4)' stroke='rgba(0, 0, 0, 0.4)' stroke-width='0'%3E%3C/circle%3E%3C/pattern%3E%3C/defs%3E%3Cpath d='M 0 0 L 0 140 L 2000 2000 L 2000 0 Z' style='fill: url("%23inactive");'%3E%3C/path%3E%3C/svg%3E`
7
+ const negativeBackground = `%3Csvg xmlns='http://www.w3.org/2000/svg' width='100%25' height='24'%3E%3Cdefs%3E%3Cpattern id='negative' patternUnits='userSpaceOnUse' width='8' height='8'%3E%3Crect width='8' height='8' fill='rgba(255, 255, 255, 0)'%3E%3C/rect%3E%3Cpath d='M 0,8 l 8,-8 M -2,2 l 4,-4 M 6,10 l 4,-4' stroke-width='1' shape-rendering='auto' stroke='rgba(255, 255, 255, 0.4)' stroke-linecap='square'%3E%3C/path%3E%3C/pattern%3E%3C/defs%3E%3Cpath d='M 0 0 L 0 140 L 2000 2000 L 2000 0 Z' style='fill: url("%23negative");'%3E%3C/path%3E%3C/svg%3E`
8
8
  const ProgressBarBackground = forwardRef(({ variant }, ref) => {
9
9
  let source = null
10
10
  if (variant?.inactive) {
@@ -111,12 +111,12 @@ Item.propTypes = {
111
111
  */
112
112
  children: PropTypes.node.isRequired,
113
113
  /**
114
- * @ignore
114
+ *
115
115
  * Set internally in `SideNav` render function - used to keep track of active item.
116
116
  */
117
117
  itemId: PropTypes.string,
118
118
  /**
119
- * @ignore
119
+ *
120
120
  * Set internally in `SideNav` render function - used to keep track of expanded items groups.
121
121
  */
122
122
  groupId: PropTypes.string,
@@ -128,17 +128,25 @@ Item.propTypes = {
128
128
  */
129
129
  hrefAttrs: PropTypes.shape(hrefAttrsProp.types),
130
130
  /**
131
- * @ignore
131
+ *
132
132
  * Set internally in `SideNav` render function.
133
133
  */
134
134
  isActive: PropTypes.bool,
135
135
  /**
136
- * @ignore
136
+ *
137
137
  * Set internally in `SideNav.ItemsGroup` render function. Used to mark expanded `ItemsGroup` parent.
138
138
  */
139
139
  isExpanded: PropTypes.bool,
140
140
  tokens: getTokensPropType('SideNavItem'),
141
- variant: variantProp.propType
141
+ variant: variantProp.propType,
142
+ /**
143
+ * Accesibility Role
144
+ */
145
+ accessibilityRole: PropTypes.string,
146
+ /**
147
+ * test ID
148
+ */
149
+ testID: PropTypes.number
142
150
  }
143
151
 
144
152
  export default Item
package/src/Tags/Tags.jsx CHANGED
@@ -249,7 +249,11 @@ Tags.propTypes = {
249
249
  * managing its own selected state, a default set of selections may be provided.
250
250
  * Changing the `initialValues` does not change the user's selections.
251
251
  */
252
- initialValues: PropTypes.arrayOf(PropTypes.string)
252
+ initialValues: PropTypes.arrayOf(PropTypes.string),
253
+ /**
254
+ * AccesibilityRole for the Tags
255
+ */
256
+ accessibilityRole: PropTypes.string
253
257
  }
254
258
 
255
259
  export default Tags
@@ -341,6 +341,8 @@ export default TextInputBase
341
341
  const staticStyles = StyleSheet.create({
342
342
  buttonsContainer: {
343
343
  position: 'absolute',
344
+ flexDirection: 'row',
345
+ alignItems: 'center',
344
346
  right: 0,
345
347
  top: 0,
346
348
  bottom: 0,
@@ -82,7 +82,10 @@ const defaultControl = (pressableState, variant) => (
82
82
  * - Tooltips may also be useful when vertical space is an issue.
83
83
  */
84
84
  const Tooltip = forwardRef(
85
- ({ children, content, position = 'auto', copy = 'en', tokens, variant, ...rest }, ref) => {
85
+ (
86
+ { children, content, position = 'auto', copy = 'en', tokens, variant, inline = false, ...rest },
87
+ ref
88
+ ) => {
86
89
  const [isOpen, setIsOpen] = useState(false)
87
90
  const arrowRef = useRef()
88
91
 
@@ -157,7 +160,18 @@ const Tooltip = forwardRef(
157
160
  control === defaultControl ? { top: 10, bottom: 10, left: 10, right: 10 } : undefined
158
161
 
159
162
  return (
160
- <View style={staticStyles.container} {...selectProps(rest)} ref={ref}>
163
+ <View
164
+ style={[
165
+ staticStyles.container,
166
+ Platform.select({
167
+ web: {
168
+ display: inline ? 'inline-block' : 'flex'
169
+ }
170
+ })
171
+ ]}
172
+ {...selectProps(rest)}
173
+ ref={ref}
174
+ >
161
175
  <Pressable
162
176
  onPress={toggleIsOpen}
163
177
  ref={reference}
@@ -108,7 +108,10 @@ const defaultControl = (pressableState, variant) => (
108
108
  * - Tooltips may also be useful when vertical space is an issue.
109
109
  */
110
110
  const Tooltip = forwardRef(
111
- ({ children, content, position = 'auto', copy = 'en', tokens, variant, ...rest }, ref) => {
111
+ (
112
+ { children, content, position = 'auto', copy = 'en', tokens, variant, inline = false, ...rest },
113
+ ref
114
+ ) => {
112
115
  const [isOpen, setIsOpen] = useState(false)
113
116
 
114
117
  const controlRef = useRef()
@@ -217,7 +220,17 @@ const Tooltip = forwardRef(
217
220
  control === defaultControl ? { top: 10, bottom: 10, left: 10, right: 10 } : undefined
218
221
 
219
222
  return (
220
- <View style={staticStyles.container} {...selectProps(rest)}>
223
+ <View
224
+ style={[
225
+ staticStyles.container,
226
+ Platform.select({
227
+ web: {
228
+ display: inline ? 'inline-block' : 'flex'
229
+ }
230
+ })
231
+ ]}
232
+ {...selectProps(rest)}
233
+ >
221
234
  <Pressable
222
235
  onPress={toggleIsOpen}
223
236
  ref={controlRef}
@@ -20,6 +20,10 @@ const propTypes = {
20
20
  * Use to place the tooltip in a specific location (only if it fits within viewport).
21
21
  */
22
22
  position: PropTypes.oneOf(['auto', 'above', 'right', 'below', 'left']),
23
+ /**
24
+ * Display tooltip icon button as an inline element.
25
+ */
26
+ inline: PropTypes.bool,
23
27
  tokens: getTokensPropType('Tooltip'),
24
28
  variant: variantProp.propType
25
29
  }
package/src/index.js CHANGED
@@ -1,10 +1,11 @@
1
1
  export { default as A11yText } from './A11yText'
2
2
  export { default as ActivityIndicator } from './ActivityIndicator'
3
+ export { default as Autocomplete } from './Autocomplete'
3
4
  export { default as Box } from './Box'
4
5
  export * from './Button'
5
6
  export { default as Card, PressableCardBase } from './Card'
6
7
  export * from './Carousel'
7
- export * from './Listbox'
8
+ export { default as Listbox } from './Listbox'
8
9
  export { default as Checkbox } from './Checkbox'
9
10
  export * from './Checkbox'
10
11
  export { default as Divider } from './Divider'
@@ -1,5 +1,5 @@
1
1
  import { useCallback, useEffect, useRef, useState } from 'react'
2
- import { Dimensions } from 'react-native'
2
+ import { Dimensions, Platform } from 'react-native'
3
3
 
4
4
  const adjustHorizontalToFit = (initialOffset, windowWidth, sourceWidth) => {
5
5
  const offset = Math.max(0, initialOffset)
@@ -169,8 +169,9 @@ const useOverlaidPosition = ({
169
169
  const readyToShow = Boolean(isShown && sourceRef.current)
170
170
  useEffect(() => {
171
171
  const handleDimensionsChange = ({ window }) => {
172
- sourceRef.current?.measureInWindow((x, y, width, height) => {
173
- // Could add a debouncer here if there's too many rerenders during gradual resizes
172
+ const measurementFunction = Platform.OS === 'web' ? 'measureInWindow' : 'measure'
173
+
174
+ sourceRef.current?.[measurementFunction]((x, y, width, height) => {
174
175
  setWindowDimensions(window)
175
176
  setSourceLayout({ x, y, width, height })
176
177
  })
@@ -181,9 +182,9 @@ const useOverlaidPosition = ({
181
182
  if (typeof subscription?.remove === 'function') {
182
183
  // React Native >=0.65.0
183
184
  subscription.remove()
184
- } else if (typeof Dimensions.removeEventListener === 'function') {
185
+ } else if (typeof Dimensions.remove === 'function') {
185
186
  // React Native <0.65.0
186
- Dimensions.removeEventListener('change', handleDimensionsChange)
187
+ Dimensions.remove('change', handleDimensionsChange)
187
188
  }
188
189
  setSourceLayout(null)
189
190
  setTargetDimensions(null)