@telus-uds/components-base 1.50.0 → 1.51.1

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 (70) hide show
  1. package/CHANGELOG.md +22 -2
  2. package/component-docs.json +160 -46
  3. package/lib/A11yText/index.js +8 -0
  4. package/lib/Divider/Divider.js +4 -0
  5. package/lib/IconButton/IconButton.js +16 -0
  6. package/lib/Link/ChevronLink.js +4 -0
  7. package/lib/Link/LinkBase.js +1 -1
  8. package/lib/Modal/Modal.js +16 -0
  9. package/lib/MultiSelectFilter/ModalOverlay.js +24 -8
  10. package/lib/MultiSelectFilter/MultiSelectFilter.js +154 -21
  11. package/lib/Pagination/PageButton.js +12 -0
  12. package/lib/Pagination/Pagination.js +12 -0
  13. package/lib/QuickLinks/QuickLinks.js +12 -0
  14. package/lib/QuickLinksFeature/QuickLinksFeatureItem.js +62 -41
  15. package/lib/Responsive/Responsive.js +7 -0
  16. package/lib/Select/Group.js +4 -0
  17. package/lib/Select/Group.native.js +4 -0
  18. package/lib/Select/Item.js +4 -0
  19. package/lib/SideNav/ItemsGroup.js +4 -0
  20. package/lib/SideNav/SideNav.js +8 -0
  21. package/lib/StepTracker/Step.js +35 -14
  22. package/lib/StepTracker/StepTracker.js +21 -2
  23. package/lib/StepTracker/dictionary.js +24 -4
  24. package/lib/Tabs/Tabs.js +20 -0
  25. package/lib-module/A11yText/index.js +8 -0
  26. package/lib-module/Divider/Divider.js +4 -0
  27. package/lib-module/IconButton/IconButton.js +16 -0
  28. package/lib-module/Link/ChevronLink.js +4 -0
  29. package/lib-module/Link/LinkBase.js +1 -1
  30. package/lib-module/Modal/Modal.js +16 -0
  31. package/lib-module/MultiSelectFilter/ModalOverlay.js +25 -9
  32. package/lib-module/MultiSelectFilter/MultiSelectFilter.js +154 -23
  33. package/lib-module/Pagination/PageButton.js +12 -0
  34. package/lib-module/Pagination/Pagination.js +12 -0
  35. package/lib-module/QuickLinks/QuickLinks.js +12 -0
  36. package/lib-module/QuickLinksFeature/QuickLinksFeatureItem.js +64 -43
  37. package/lib-module/Responsive/Responsive.js +7 -0
  38. package/lib-module/Select/Group.js +4 -0
  39. package/lib-module/Select/Group.native.js +4 -0
  40. package/lib-module/Select/Item.js +4 -0
  41. package/lib-module/SideNav/ItemsGroup.js +4 -0
  42. package/lib-module/SideNav/SideNav.js +8 -0
  43. package/lib-module/StepTracker/Step.js +35 -14
  44. package/lib-module/StepTracker/StepTracker.js +21 -2
  45. package/lib-module/StepTracker/dictionary.js +24 -4
  46. package/lib-module/Tabs/Tabs.js +20 -0
  47. package/package.json +2 -2
  48. package/src/A11yText/index.jsx +6 -0
  49. package/src/Divider/Divider.jsx +3 -0
  50. package/src/IconButton/IconButton.jsx +12 -0
  51. package/src/Link/ChevronLink.jsx +3 -0
  52. package/src/Link/LinkBase.jsx +3 -1
  53. package/src/Modal/Modal.jsx +12 -0
  54. package/src/MultiSelectFilter/ModalOverlay.jsx +30 -6
  55. package/src/MultiSelectFilter/MultiSelectFilter.jsx +142 -20
  56. package/src/Pagination/PageButton.jsx +9 -0
  57. package/src/Pagination/Pagination.jsx +9 -0
  58. package/src/QuickLinks/QuickLinks.jsx +9 -0
  59. package/src/QuickLinksFeature/QuickLinksFeatureItem.jsx +42 -35
  60. package/src/Responsive/Responsive.jsx +6 -0
  61. package/src/Select/Group.jsx +3 -0
  62. package/src/Select/Group.native.jsx +3 -0
  63. package/src/Select/Item.jsx +3 -0
  64. package/src/SideNav/ItemsGroup.jsx +3 -0
  65. package/src/SideNav/SideNav.jsx +6 -0
  66. package/src/StepTracker/Step.jsx +34 -10
  67. package/src/StepTracker/StepTracker.jsx +23 -2
  68. package/src/StepTracker/dictionary.js +24 -4
  69. package/src/Tabs/Tabs.jsx +15 -0
  70. package/src/Typography/Typography.jsx +1 -0
@@ -78,17 +78,18 @@ const selectKnobStyles = (_ref4, isCompleted, isCurrent) => {
78
78
  height: knobSize,
79
79
  width: knobSize,
80
80
  ...(isCompleted && {
81
- backgroundColor: knobCompletedBackgroundColor,
82
- borderColor: knobCompletedBorderColor,
83
- paddingLeft: knobCompletedPaddingLeft,
84
- paddingTop: knobCompletedPaddingTop
85
- }),
86
- ...(isCurrent && {
87
81
  backgroundColor: knobCurrentBackgroundColor,
88
82
  borderColor: knobCurrentBorderColor,
89
83
  borderWidth: knobCurrentBorderWidth,
90
84
  paddingLeft: knobCurrentPaddingLeft,
91
85
  paddingTop: knobCurrentPaddingTop
86
+ }),
87
+ ...(isCurrent && {
88
+ backgroundColor: knobCompletedBackgroundColor,
89
+ borderColor: knobCompletedBorderColor,
90
+ borderWidth: knobCurrentBorderWidth,
91
+ paddingLeft: knobCompletedPaddingLeft,
92
+ paddingTop: knobCompletedPaddingTop
92
93
  })
93
94
  };
94
95
  };
@@ -110,7 +111,26 @@ const selectLabelContainerStyles = _ref5 => {
110
111
  };
111
112
  };
112
113
 
113
- const selectLabelStyles = (_ref6, themeOptions, isCurrent) => {
114
+ const selectStepLabelStyles = (_ref6, themeOptions, isCurrent) => {
115
+ let {
116
+ stepLabelColor,
117
+ labelCurrentColor,
118
+ stepLabelFontWeight,
119
+ stepLabelFontSize,
120
+ stepLabelFontName,
121
+ stepLabelLineHeight
122
+ } = _ref6;
123
+ return applyTextStyles({
124
+ color: isCurrent ? labelCurrentColor : stepLabelColor,
125
+ fontSize: stepLabelFontSize,
126
+ lineHeight: stepLabelLineHeight,
127
+ fontWeight: stepLabelFontWeight,
128
+ fontName: stepLabelFontName,
129
+ themeOptions
130
+ });
131
+ };
132
+
133
+ const selectLabelStyles = (_ref7, themeOptions, isCurrent) => {
114
134
  let {
115
135
  labelColor,
116
136
  labelCurrentColor,
@@ -119,7 +139,7 @@ const selectLabelStyles = (_ref6, themeOptions, isCurrent) => {
119
139
  labelFontWeight,
120
140
  labelFontName,
121
141
  labelLineHeight
122
- } = _ref6;
142
+ } = _ref7;
123
143
  return applyTextStyles({
124
144
  color: isCurrent ? labelCurrentColor : labelColor,
125
145
  fontSize: labelFontSize,
@@ -146,7 +166,7 @@ const getStepTestID = (isCompleted, isCurrent) => {
146
166
  */
147
167
 
148
168
 
149
- const Step = _ref7 => {
169
+ const Step = _ref8 => {
150
170
  let {
151
171
  label,
152
172
  name,
@@ -155,11 +175,12 @@ const Step = _ref7 => {
155
175
  stepIndex = 0,
156
176
  tokens,
157
177
  ...rest
158
- } = _ref7;
178
+ } = _ref8;
159
179
  const {
160
180
  completedIcon,
161
181
  showStepLabel,
162
182
  showStepName,
183
+ textStepTrackerLabel,
163
184
  ...themeTokens
164
185
  } = tokens;
165
186
  const isFirst = stepIndex === 0;
@@ -193,11 +214,11 @@ const Step = _ref7 => {
193
214
  }), /*#__PURE__*/_jsxs(View, {
194
215
  style: [staticStyles.knob, selectKnobStyles(themeTokens, isCompleted, isCurrent)],
195
216
  testID: getStepTestID(isCompleted, isCurrent),
196
- children: [isCompleted && completedIcon && /*#__PURE__*/_jsx(Icon, {
217
+ children: [(isCompleted && completedIcon || isCurrent && !completedIcon) && /*#__PURE__*/_jsx(View, {
218
+ style: selectCurrentInnerStyles(themeTokens)
219
+ }), isCurrent && completedIcon && /*#__PURE__*/_jsx(Icon, {
197
220
  icon: completedIcon,
198
221
  tokens: selectCompletedIconTokens(themeTokens)
199
- }), isCurrent && /*#__PURE__*/_jsx(View, {
200
- style: selectCurrentInnerStyles(themeTokens)
201
222
  })]
202
223
  }), /*#__PURE__*/_jsx(View, {
203
224
  style: [staticStyles.connector, !isLast && selectConnectorStyles(themeTokens, isCompleted)]
@@ -205,7 +226,7 @@ const Step = _ref7 => {
205
226
  }), showStepLabel && /*#__PURE__*/_jsxs(View, {
206
227
  style: [staticStyles.stepLabelContainer, selectLabelContainerStyles(tokens)],
207
228
  children: [showStepName && /*#__PURE__*/_jsx(Text, {
208
- style: [staticStyles.centeredText, selectLabelStyles(tokens, themeOptions, isCurrent)],
229
+ style: [staticStyles.centeredText, selectStepLabelStyles(tokens, themeOptions, isCurrent)],
209
230
  children: name
210
231
  }), /*#__PURE__*/_jsx(StackView, {
211
232
  direction: "row",
@@ -106,13 +106,16 @@ const StepTracker = /*#__PURE__*/forwardRef((_ref4, ref) => {
106
106
  } = useThemeTokens('StepTracker', tokens, variant, {
107
107
  viewport
108
108
  });
109
+ const {
110
+ textStepTrackerLabel
111
+ } = themeTokens;
109
112
  const getCopy = useCopy({
110
113
  dictionary,
111
114
  copy
112
115
  });
113
- const stepTrackerLabel = showStepTrackerLabel ? getCopy('stepTrackerLabel').replace('%{stepNumber}', current < steps.length ? current + 1 : steps.length).replace('%{stepCount}', steps.length).replace('%{stepLabel}', current < steps.length ? steps[current] : steps[steps.length - 1]) : '';
116
+ const stepTrackerLabel = showStepTrackerLabel ? (typeof copy === 'string' ? getCopy(textStepTrackerLabel ?? 1).stepTrackerLabel : getCopy('stepTrackerLabel')).replace('%{stepNumber}', current < steps.length ? current + 1 : steps.length).replace('%{stepCount}', steps.length).replace('%{stepLabel}', current < steps.length ? steps[current] : steps[steps.length - 1]) : '';
114
117
 
115
- const getStepLabel = index => themeTokens.showStepLabel ? getCopy('stepLabel').replace('%{stepNumber}', index + 1) : '';
118
+ const getStepLabel = index => themeTokens.showStepLabel ? (typeof copy === 'string' ? getCopy(textStepTrackerLabel ?? 1).stepLabel : getCopy('stepLabel')).replace('%{stepNumber}', index + 1) : '';
116
119
 
117
120
  const {
118
121
  themeOptions
@@ -165,12 +168,28 @@ const dictionaryContentShape = PropTypes.shape({
165
168
  stepTrackerLabel: PropTypes.string.isRequired
166
169
  });
167
170
  StepTracker.propTypes = { ...selectedSystemPropTypes,
171
+
172
+ /**
173
+ * The current step, 0-based number
174
+ */
168
175
  current: PropTypes.number,
176
+
177
+ /**
178
+ * The language to use for the labels
179
+ */
169
180
  copy: PropTypes.oneOfType([PropTypes.oneOf(['en', 'fr']), dictionaryContentShape]),
181
+
182
+ /**
183
+ * Custom dictionary containing the labels to use for the steps
184
+ */
170
185
  dictionary: PropTypes.shape({
171
186
  en: dictionaryContentShape,
172
187
  fr: dictionaryContentShape
173
188
  }),
189
+
190
+ /**
191
+ * An array of strings defining the step titles
192
+ */
174
193
  steps: PropTypes.arrayOf(PropTypes.string),
175
194
  tokens: getTokensPropType('StepTracker'),
176
195
  variant: variantProp.propType
@@ -1,10 +1,30 @@
1
1
  export default {
2
2
  en: {
3
- stepLabel: 'Step %{stepNumber}',
4
- stepTrackerLabel: 'Step %{stepNumber} of %{stepCount}: %{stepLabel}'
3
+ 1: {
4
+ stepLabel: 'Step %{stepNumber}',
5
+ stepTrackerLabel: 'Step %{stepNumber} of %{stepCount}: %{stepLabel}'
6
+ },
7
+ 2: {
8
+ stepLabel: '%{stepNumber}.',
9
+ stepTrackerLabel: 'Step %{stepNumber} of %{stepCount}: %{stepLabel}'
10
+ },
11
+ 3: {
12
+ stepLabel: 'Step %{stepNumber}',
13
+ stepTrackerLabel: 'Step %{stepNumber} of %{stepCount}: %{stepLabel}'
14
+ }
5
15
  },
6
16
  fr: {
7
- stepLabel: 'Étape %{stepNumber}',
8
- stepTrackerLabel: 'Étape %{stepNumber} sur %{stepCount}: %{stepLabel}'
17
+ 1: {
18
+ stepLabel: 'Étape %{stepNumber}',
19
+ stepTrackerLabel: 'Étape %{stepNumber} sur %{stepCount}: %{stepLabel}'
20
+ },
21
+ 2: {
22
+ stepLabel: '%{stepNumber}.',
23
+ stepTrackerLabel: 'Étape %{stepNumber} sur %{stepCount}: %{stepLabel}'
24
+ },
25
+ 3: {
26
+ stepLabel: 'Étape %{stepNumber}',
27
+ stepTrackerLabel: 'Étape %{stepNumber} sur %{stepCount}: %{stepLabel}'
28
+ }
9
29
  }
10
30
  };
@@ -132,6 +132,10 @@ const Tabs = /*#__PURE__*/forwardRef((_ref, ref) => {
132
132
  Tabs.displayName = 'Tabs';
133
133
  Tabs.propTypes = { ...selectedSystemPropTypes,
134
134
  ...withLinkRouter.PropTypes,
135
+
136
+ /**
137
+ * Array of `TabsItem`s
138
+ */
135
139
  items: PropTypes.arrayOf(PropTypes.shape({ ...selectedItemPropTypes,
136
140
  ...withLinkRouter.PropTypes,
137
141
  href: PropTypes.string,
@@ -139,11 +143,27 @@ Tabs.propTypes = { ...selectedSystemPropTypes,
139
143
  id: PropTypes.string,
140
144
  ref: ABBPropTypes.ref()
141
145
  })),
146
+
147
+ /**
148
+ * `id` property of the current tab in the items array
149
+ */
142
150
  value: PropTypes.string,
143
151
  initialValue: PropTypes.string,
152
+
153
+ /**
154
+ * Callback for when the selected tab changes
155
+ */
144
156
  onChange: PropTypes.func,
145
157
  tokens: getTokensPropType('Tabs'),
158
+
159
+ /**
160
+ * Custom tokens for `TabsItem`
161
+ */
146
162
  itemTokens: getTokensPropType('TabsItem'),
163
+
164
+ /**
165
+ * Custom tokens for `HorizontalScrollButton`
166
+ */
147
167
  scrollButtonTokens: getTokensPropType('HorizontalScrollButton'),
148
168
  variant: variantProp.propType
149
169
  };
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "@floating-ui/react-native": "^0.8.1",
12
12
  "@gorhom/portal": "^1.0.14",
13
13
  "@telus-uds/system-constants": "^1.2.1",
14
- "@telus-uds/system-theme-tokens": "^2.32.0",
14
+ "@telus-uds/system-theme-tokens": "^2.34.0",
15
15
  "airbnb-prop-types": "^2.16.0",
16
16
  "lodash.debounce": "^4.0.8",
17
17
  "lodash.merge": "^4.6.2",
@@ -72,5 +72,5 @@
72
72
  "standard-engine": {
73
73
  "skip": true
74
74
  },
75
- "version": "1.50.0"
75
+ "version": "1.51.1"
76
76
  }
@@ -31,7 +31,13 @@ A11yText.displayName = 'A11yText'
31
31
 
32
32
  A11yText.propTypes = {
33
33
  ...selectedSystemPropTypes,
34
+ /**
35
+ * Text to be read by screen readers
36
+ */
34
37
  text: PropTypes.string.isRequired,
38
+ /**
39
+ * Whether text should be rendered as a heading
40
+ */
35
41
  heading: PropTypes.bool
36
42
  }
37
43
 
@@ -101,6 +101,9 @@ Divider.displayName = 'Divider'
101
101
  Divider.propTypes = {
102
102
  ...selectedSystemPropTypes,
103
103
  tokens: getTokensPropType('Divider'),
104
+ /**
105
+ * A number referring to a position on the space scale to create space on either side of the divider
106
+ */
104
107
  space: spacingProps.types.spacingValue,
105
108
  variant: variantProp.propType,
106
109
  /**
@@ -108,9 +108,21 @@ IconButton.propTypes = {
108
108
  ...selectedSystemPropTypes,
109
109
  variant: variantProp.propType,
110
110
  tokens: getTokensPropType('IconButton'),
111
+ /**
112
+ * Defines the icon to be rendered
113
+ */
111
114
  icon: PropTypes.elementType.isRequired,
115
+ /**
116
+ * URL to navigate to when the `Iconbutton` is pressed
117
+ */
112
118
  href: PropTypes.string,
119
+ /**
120
+ * URL options to navigate to when the `Iconbutton` is pressed
121
+ */
113
122
  hrefAttrs: PropTypes.shape(hrefAttrsProp.types),
123
+ /**
124
+ * Function to execute when the `Iconbutton` is pressed
125
+ */
114
126
  onPress: PropTypes.func
115
127
  }
116
128
 
@@ -48,6 +48,9 @@ ChevronLink.displayName = 'ChevronLink'
48
48
  ChevronLink.propTypes = {
49
49
  ...LinkBase.propTypes,
50
50
  tokens: getTokensPropType('ChevronLink', 'Link'),
51
+ /**
52
+ * Changes direction of chevron icon
53
+ */
51
54
  direction: PropTypes.oneOf(['left', 'right'])
52
55
  }
53
56
 
@@ -183,7 +183,9 @@ const LinkBase = forwardRef(
183
183
  space={iconSpace}
184
184
  iconProps={{ ...iconProps, tokens: iconTokens }}
185
185
  >
186
- <Text style={[textStyles, blockTextStyles, staticStyles.baseline]}>{children}</Text>
186
+ <Text style={[textStyles, blockTextStyles, staticStyles.baseline]}>
187
+ {typeof children === 'function' ? children(linkState) : children}
188
+ </Text>
187
189
  </IconText>
188
190
  )
189
191
  }}
@@ -161,9 +161,21 @@ Modal.displayName = 'Modal'
161
161
  Modal.propTypes = {
162
162
  ...selectedSystemPropTypes,
163
163
  children: PropTypes.oneOfType([PropTypes.node, PropTypes.arrayOf(PropTypes.node)]),
164
+ /**
165
+ * To define the locale of the copy
166
+ */
164
167
  copy: copyPropTypes,
168
+ /**
169
+ * Setting this to `true` will open the `Modal`
170
+ */
165
171
  isOpen: PropTypes.bool,
172
+ /**
173
+ * This function is triggered when the `Modal` is closed
174
+ */
166
175
  onClose: PropTypes.func,
176
+ /**
177
+ * `max-width` is applied to the `Modal` container
178
+ */
167
179
  maxWidth: PropTypes.bool,
168
180
  tokens: getTokensPropType('Modal'),
169
181
  variant: variantProp.propType,
@@ -2,7 +2,7 @@ import React, { forwardRef } from 'react'
2
2
  import PropTypes from 'prop-types'
3
3
  import { View, StyleSheet } from 'react-native'
4
4
  import { Portal } from '@gorhom/portal'
5
- import { selectTokens, useCopy, copyPropTypes, getTokensPropType, variantProp } from '../utils'
5
+ import { useCopy, copyPropTypes, getTokensPropType, variantProp } from '../utils'
6
6
  import { useViewport } from '../ViewportProvider'
7
7
  import { useThemeTokens } from '../ThemeProvider'
8
8
  import dictionary from './dictionary'
@@ -14,7 +14,6 @@ const staticStyles = StyleSheet.create({
14
14
  positioner: {
15
15
  flex: 1, // Grow to maxWidth when possible, shrink when not possible
16
16
  position: 'absolute',
17
- height: 330,
18
17
  zIndex: 10000 // Position on top of all the other overlays, including backdrops and modals
19
18
  },
20
19
  closeButtonContainer: {
@@ -44,13 +43,33 @@ const selectPaddingContainerStyles = ({ paddingTop, paddingLeft, paddingRight })
44
43
 
45
44
  const ModalOverlay = forwardRef(
46
45
  (
47
- { children, isReady = false, overlaidPosition, onLayout, variant, tokens, copy, onClose },
46
+ {
47
+ children,
48
+ isReady = false,
49
+ maxHeight,
50
+ maxHeightSize,
51
+ maxWidthSize,
52
+ minHeight,
53
+ minWidth,
54
+ overlaidPosition,
55
+ onLayout,
56
+ variant,
57
+ tokens,
58
+ copy,
59
+ onClose
60
+ },
48
61
  ref
49
62
  ) => {
50
63
  const viewport = useViewport()
51
64
  const themeTokens = useThemeTokens('Modal', tokens, variant, { viewport, maxWidth: false })
65
+ const containerWidthHeight = {
66
+ minWidth,
67
+ minHeight,
68
+ ...(tokens.maxWidth && maxWidthSize && { maxWidth: maxWidthSize }),
69
+ ...(maxHeight && maxHeightSize && { maxHeight: maxHeightSize })
70
+ }
52
71
 
53
- const { closeIcon: CloseIconComponent, maxWidth } = themeTokens
72
+ const { closeIcon: CloseIconComponent } = themeTokens
54
73
 
55
74
  const getCopy = useCopy({ dictionary, copy })
56
75
  const closeLabel = getCopy('closeButton')
@@ -62,7 +81,7 @@ const ModalOverlay = forwardRef(
62
81
  onLayout={onLayout}
63
82
  style={[
64
83
  overlaidPosition,
65
- { minWidth: maxWidth },
84
+ containerWidthHeight,
66
85
  staticStyles.positioner,
67
86
  !isReady && staticStyles.hidden
68
87
  ]}
@@ -79,7 +98,6 @@ const ModalOverlay = forwardRef(
79
98
  icon={CloseIconComponent}
80
99
  accessibilityRole="button"
81
100
  accessibilityLabel={closeLabel}
82
- tokens={selectTokens('IconButton', themeTokens, 'close')}
83
101
  />
84
102
  </View>
85
103
  {children}
@@ -99,6 +117,12 @@ ModalOverlay.propTypes = {
99
117
  left: PropTypes.number,
100
118
  width: PropTypes.number
101
119
  }),
120
+ minWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
121
+ minHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
122
+ maxHeightSize: PropTypes.number,
123
+ maxWidthSize: PropTypes.number,
124
+ maxHeight: PropTypes.bool,
125
+ maxWidth: PropTypes.bool,
102
126
  onLayout: PropTypes.func,
103
127
  variant: variantProp.propType,
104
128
  tokens: getTokensPropType('Modal'),