@telus-uds/components-base 3.17.1 → 3.19.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 (44) hide show
  1. package/CHANGELOG.md +20 -4
  2. package/LICENSE +21 -0
  3. package/jest.config.cjs +10 -2
  4. package/lib/cjs/Box/Box.js +114 -62
  5. package/lib/cjs/Box/backgroundImageStylesMap.js +136 -28
  6. package/lib/cjs/Carousel/Carousel.js +1 -1
  7. package/lib/cjs/Modal/Modal.js +7 -1
  8. package/lib/cjs/Modal/ModalContent.js +6 -4
  9. package/lib/cjs/MultiSelectFilter/MultiSelectFilter.js +2 -2
  10. package/lib/cjs/StepTracker/Step.js +12 -1
  11. package/lib/cjs/StepTracker/StepTracker.js +15 -4
  12. package/lib/cjs/TabBar/TabBar.js +4 -2
  13. package/lib/cjs/TabBar/index.js +2 -0
  14. package/lib/cjs/Tooltip/Backdrop.js +1 -1
  15. package/lib/cjs/utils/index.js +9 -1
  16. package/lib/cjs/utils/isTouchDevice.js +34 -0
  17. package/lib/esm/Box/Box.js +113 -63
  18. package/lib/esm/Box/backgroundImageStylesMap.js +134 -27
  19. package/lib/esm/Carousel/Carousel.js +2 -2
  20. package/lib/esm/Modal/Modal.js +7 -1
  21. package/lib/esm/Modal/ModalContent.js +6 -4
  22. package/lib/esm/MultiSelectFilter/MultiSelectFilter.js +2 -2
  23. package/lib/esm/StepTracker/Step.js +12 -1
  24. package/lib/esm/StepTracker/StepTracker.js +15 -4
  25. package/lib/esm/TabBar/TabBar.js +4 -2
  26. package/lib/esm/TabBar/index.js +2 -0
  27. package/lib/esm/Tooltip/Backdrop.js +1 -1
  28. package/lib/esm/utils/index.js +2 -1
  29. package/lib/esm/utils/isTouchDevice.js +27 -0
  30. package/lib/package.json +2 -2
  31. package/package.json +2 -2
  32. package/src/Box/Box.jsx +97 -55
  33. package/src/Box/backgroundImageStylesMap.js +48 -15
  34. package/src/Carousel/Carousel.jsx +3 -2
  35. package/src/Modal/Modal.jsx +7 -1
  36. package/src/Modal/ModalContent.jsx +6 -3
  37. package/src/MultiSelectFilter/MultiSelectFilter.jsx +2 -2
  38. package/src/StepTracker/Step.jsx +47 -27
  39. package/src/StepTracker/StepTracker.jsx +9 -1
  40. package/src/TabBar/TabBar.jsx +3 -1
  41. package/src/TabBar/index.js +3 -0
  42. package/src/Tooltip/Backdrop.jsx +1 -1
  43. package/src/utils/index.js +1 -0
  44. package/src/utils/isTouchDevice.js +34 -0
@@ -137,12 +137,24 @@ const getStepTestID = (isCompleted, isCurrent) => {
137
137
 
138
138
  return testID
139
139
  }
140
+ const selectBarContainerStyles = (themeTokens, isCompleted, isCurrent) => ({
141
+ backgroundColor: isCompleted
142
+ ? themeTokens.barCompletedBackgroundColor
143
+ : themeTokens.barBackgroundColor,
144
+ height: themeTokens.barHeight,
145
+ ...(isCurrent && {
146
+ backgroundColor: themeTokens.barCurrentBackgroundColor
147
+ })
148
+ })
140
149
 
141
150
  /**
142
151
  * A single step of a StepTracker.
143
152
  */
144
153
  const Step = React.forwardRef(
145
- ({ label, name, status = 0, stepCount = 0, stepIndex = 0, tokens, ...rest }, ref) => {
154
+ (
155
+ { label, name, status = 0, stepCount = 0, stepIndex = 0, tokens, isBarVariant, ...rest },
156
+ ref
157
+ ) => {
146
158
  const { completedIcon, showStepLabel, showStepName, textStepTrackerLabel, ...themeTokens } =
147
159
  tokens
148
160
  const isFirst = stepIndex === 0
@@ -162,35 +174,43 @@ const Step = React.forwardRef(
162
174
  ref={ref}
163
175
  {...selectProps(rest)}
164
176
  >
165
- <StackView
166
- direction="row"
167
- space={0}
168
- tokens={{ alignItems: 'center', flexGrow: 0, justifyContent: 'center' }}
169
- >
177
+ {isBarVariant && (
170
178
  <View
171
- style={[
172
- staticStyles.connector,
173
- !isFirst && selectConnectorStyles(themeTokens, isActive)
174
- ]}
175
- />
176
- <View
177
- style={[staticStyles.knob, selectKnobStyles(themeTokens, isCompleted, isCurrent)]}
179
+ style={selectBarContainerStyles(themeTokens, isCompleted, isCurrent)}
178
180
  testID={getStepTestID(isCompleted, isCurrent)}
179
- >
180
- {isCompleted && completedIcon && (
181
- <Icon icon={completedIcon} tokens={selectCompletedIconTokens(themeTokens)} />
182
- )}
183
- {((isCurrent && completedIcon) || (isCurrent && !completedIcon)) && (
184
- <View style={selectCurrentInnerStyles(themeTokens)} />
185
- )}
186
- </View>
187
- <View
188
- style={[
189
- staticStyles.connector,
190
- !isLast && selectConnectorStyles(themeTokens, isCompleted)
191
- ]}
192
181
  />
193
- </StackView>
182
+ )}
183
+ {!isBarVariant && (
184
+ <StackView
185
+ direction="row"
186
+ space={0}
187
+ tokens={{ alignItems: 'center', flexGrow: 0, justifyContent: 'center' }}
188
+ >
189
+ <View
190
+ style={[
191
+ staticStyles.connector,
192
+ !isFirst && selectConnectorStyles(themeTokens, isActive)
193
+ ]}
194
+ />
195
+ <View
196
+ style={[staticStyles.knob, selectKnobStyles(themeTokens, isCompleted, isCurrent)]}
197
+ testID={getStepTestID(isCompleted, isCurrent)}
198
+ >
199
+ {isCompleted && completedIcon && (
200
+ <Icon icon={completedIcon} tokens={selectCompletedIconTokens(themeTokens)} />
201
+ )}
202
+ {((isCurrent && completedIcon) || (isCurrent && !completedIcon)) && (
203
+ <View style={selectCurrentInnerStyles(themeTokens)} />
204
+ )}
205
+ </View>
206
+ <View
207
+ style={[
208
+ staticStyles.connector,
209
+ !isLast && selectConnectorStyles(themeTokens, isCompleted)
210
+ ]}
211
+ />
212
+ </StackView>
213
+ )}
194
214
  {showStepLabel && (
195
215
  <View style={[staticStyles.stepLabelContainer, selectLabelContainerStyles(tokens)]}>
196
216
  {showStepName && (
@@ -9,6 +9,8 @@ import useCopy from '../utils/useCopy'
9
9
  import Step from './Step'
10
10
  import defaultDictionary from './dictionary'
11
11
 
12
+ const STYLE_BAR_VARIANT = 'bar'
13
+
12
14
  const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps])
13
15
 
14
16
  const selectContainerStyles = ({
@@ -38,6 +40,10 @@ const selectStepTrackerLabelStyles = (
38
40
  themeOptions
39
41
  })
40
42
 
43
+ const selectStepsContainerStyles = ({ barGap }) => ({
44
+ gap: barGap
45
+ })
46
+
41
47
  /**
42
48
  * StepTracker component shows the current position in a sequence of steps.
43
49
  *
@@ -83,6 +89,7 @@ const StepTracker = React.forwardRef(
83
89
  },
84
90
  ref
85
91
  ) => {
92
+ const isBarVariant = variant?.style === STYLE_BAR_VARIANT
86
93
  const viewport = useViewport()
87
94
  const { showStepTrackerLabel, ...themeTokens } = useThemeTokens(
88
95
  'StepTracker',
@@ -135,7 +142,7 @@ const StepTracker = React.forwardRef(
135
142
  <View ref={ref} style={selectContainerStyles(themeTokens)} {...selectedProps}>
136
143
  <StackView space={0}>
137
144
  <View
138
- style={staticStyles.stepsContainer}
145
+ style={[staticStyles.stepsContainer, selectStepsContainerStyles(themeTokens)]}
139
146
  accessibilityRole={stepsContainerAccessibilityRole}
140
147
  >
141
148
  {steps.map((label, index) => {
@@ -150,6 +157,7 @@ const StepTracker = React.forwardRef(
150
157
  tokens={themeTokens}
151
158
  accessibilityRole={stepAccessibilityRole}
152
159
  accessibilityCurrent={current === index && Platform.OS === 'web' && 'step'}
160
+ isBarVariant={isBarVariant}
153
161
  />
154
162
  )
155
163
  })}
@@ -74,6 +74,7 @@ const TabBar = React.forwardRef(
74
74
  onPress={() => handlePress(item.id)}
75
75
  id={`tab-item-${index}`}
76
76
  accessibilityRole="tablist"
77
+ tokens={item.tokens}
77
78
  />
78
79
  ))}
79
80
  </View>
@@ -93,7 +94,8 @@ TabBar.propTypes = {
93
94
  icon: PropTypes.node,
94
95
  iconActive: PropTypes.node,
95
96
  label: PropTypes.string.isRequired,
96
- href: PropTypes.string
97
+ href: PropTypes.string,
98
+ tokens: getTokensPropType('TabBarItem')
97
99
  })
98
100
  ).isRequired,
99
101
  /** Id of the initially selected item. */
@@ -1,3 +1,6 @@
1
1
  import TabBar from './TabBar'
2
+ import TabBarItem from './TabBarItem'
3
+
4
+ TabBar.Item = TabBarItem
2
5
 
3
6
  export default TabBar
@@ -16,7 +16,7 @@ function createPortalNode(nodeId) {
16
16
  left: ${window.scrollX}px;
17
17
  right: 0;
18
18
  bottom: 0;
19
- z-index: 9999;
19
+ z-index: 100000;
20
20
  pointer-events: none;
21
21
  `
22
22
 
@@ -25,3 +25,4 @@ export { default as convertFromMegaByteToByte } from './convertFromMegaByteToByt
25
25
  export { default as formatImageSource } from './formatImageSource'
26
26
  export { default as getSpacingScale } from './getSpacingScale'
27
27
  export { default as useVariants } from './useVariants'
28
+ export { default as isTouchDevice } from './isTouchDevice'
@@ -0,0 +1,34 @@
1
+ import { Platform } from 'react-native'
2
+
3
+ /**
4
+ * Determines if the current device supports touch interactions
5
+ *
6
+ * @returns {boolean} True if the device supports touch, false otherwise
7
+ */
8
+ const isTouchDevice = () => {
9
+ if (Platform.OS !== 'web') {
10
+ return true
11
+ }
12
+
13
+ if (typeof window !== 'undefined') {
14
+ if ('ontouchstart' in window) {
15
+ return true
16
+ }
17
+
18
+ if (window.navigator && window.navigator.maxTouchPoints > 0) {
19
+ return true
20
+ }
21
+
22
+ if (window.navigator && window.navigator.msMaxTouchPoints > 0) {
23
+ return true
24
+ }
25
+
26
+ if (window.matchMedia && window.matchMedia('(pointer: coarse)').matches) {
27
+ return true
28
+ }
29
+ }
30
+
31
+ return false
32
+ }
33
+
34
+ export default isTouchDevice