@telus-uds/components-base 1.50.0 → 1.51.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.
@@ -1,4 +1,4 @@
1
- import React, { forwardRef, useState } from 'react';
1
+ import React, { forwardRef } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import Image from "react-native-web/dist/exports/Image";
4
4
  import Platform from "react-native-web/dist/exports/Platform";
@@ -6,7 +6,7 @@ import Text from "react-native-web/dist/exports/Text";
6
6
  import View from "react-native-web/dist/exports/View";
7
7
  import { getTokensPropType, variantProp, withLinkRouter, a11yProps, linkProps, selectSystemProps } from '../utils';
8
8
  import { useViewport } from '../ViewportProvider';
9
- import { useThemeTokensCallback } from '../ThemeProvider';
9
+ import { applyTextStyles, useThemeTokensCallback } from '../ThemeProvider';
10
10
  import { Link } from '../Link';
11
11
  import { StackWrap } from '../StackView'; // pass through and type relevant system props - add more sets for interactive components
12
12
 
@@ -32,6 +32,7 @@ const selectContainerStyle = _ref => {
32
32
  } = _ref;
33
33
  return {
34
34
  textAlign,
35
+ outline: 'red',
35
36
  width: contentMaxDimension,
36
37
  overflow: 'hidden'
37
38
  };
@@ -43,6 +44,15 @@ const selectImageContainerStyle = contentMaxDimension => ({
43
44
  justifyContent: 'center',
44
45
  alignItems: 'center'
45
46
  });
47
+
48
+ const selectLinkToken = _ref2 => {
49
+ let {
50
+ outerBorderColor
51
+ } = _ref2;
52
+ return {
53
+ outerBorderColor
54
+ };
55
+ };
46
56
  /**
47
57
  * Component export along with QuickLinksFeature to be used as children
48
58
  *
@@ -50,7 +60,7 @@ const selectImageContainerStyle = contentMaxDimension => ({
50
60
  */
51
61
 
52
62
 
53
- const QuickLinksFeatureItem = /*#__PURE__*/forwardRef((_ref2, ref) => {
63
+ const QuickLinksFeatureItem = /*#__PURE__*/forwardRef((_ref3, ref) => {
54
64
  let {
55
65
  tokens,
56
66
  variant,
@@ -58,52 +68,63 @@ const QuickLinksFeatureItem = /*#__PURE__*/forwardRef((_ref2, ref) => {
58
68
  imageAccessibilityLabel,
59
69
  imageSource,
60
70
  ...rest
61
- } = _ref2;
71
+ } = _ref3;
62
72
  const viewport = useViewport();
63
73
  const getTokens = useThemeTokensCallback('QuickLinksFeatureItem', tokens, variant);
64
- const [hover, setHover] = useState(false);
65
- const {
66
- contentDirection,
67
- contentSpace,
68
- contentAlignItems,
69
- contentMaxDimension,
70
- imageDimension,
71
- textAlign
72
- } = getTokens({
73
- viewport,
74
- hover
75
- });
76
74
  return /*#__PURE__*/_jsx(Link, {
77
75
  ref: ref,
78
- tokens: state => {
79
- setHover(state.hover);
80
- return getTokens(state);
81
- },
82
76
  ...selectProps(rest),
83
- children: /*#__PURE__*/_jsx(View, {
84
- style: selectContainerStyle({
77
+ tokens: state => selectLinkToken(getTokens(state)),
78
+ children: _ref4 => {
79
+ let {
80
+ hovered: hover,
81
+ pressed,
82
+ focused: focus
83
+ } = _ref4;
84
+ const {
85
+ contentDirection,
86
+ contentSpace,
87
+ contentAlignItems,
85
88
  contentMaxDimension,
86
- textAlign
87
- }),
88
- children: /*#__PURE__*/_jsxs(StackWrap, {
89
- direction: contentDirection,
90
- space: contentSpace,
91
- tokens: {
92
- alignItems: contentAlignItems
93
- },
94
- children: [/*#__PURE__*/_jsx(View, {
95
- style: selectImageContainerStyle(contentMaxDimension),
96
- children: /*#__PURE__*/_jsx(Image, {
97
- accessibilityIgnoresInvertColors: true,
98
- imageAccessibilityLabel: imageAccessibilityLabel,
99
- source: imageSource,
100
- style: selectImageStyle(imageDimension)
101
- })
102
- }), /*#__PURE__*/_jsx(Text, {
103
- children: children
104
- })]
105
- })
106
- })
89
+ imageDimension,
90
+ textLine,
91
+ gap,
92
+ ...themeTokens
93
+ } = getTokens({
94
+ viewport,
95
+ hover,
96
+ pressed,
97
+ focus
98
+ });
99
+ const textStyle = { ...applyTextStyles(themeTokens),
100
+ textDecorationLine: textLine
101
+ };
102
+ return /*#__PURE__*/_jsx(View, {
103
+ style: selectContainerStyle({ ...themeTokens,
104
+ contentMaxDimension
105
+ }),
106
+ children: /*#__PURE__*/_jsxs(StackWrap, {
107
+ direction: contentDirection,
108
+ space: contentSpace,
109
+ gap: gap,
110
+ tokens: {
111
+ alignItems: contentAlignItems
112
+ },
113
+ children: [/*#__PURE__*/_jsx(View, {
114
+ style: selectImageContainerStyle(contentMaxDimension),
115
+ children: /*#__PURE__*/_jsx(Image, {
116
+ accessibilityIgnoresInvertColors: true,
117
+ imageAccessibilityLabel: imageAccessibilityLabel,
118
+ source: imageSource,
119
+ style: selectImageStyle(imageDimension)
120
+ })
121
+ }), /*#__PURE__*/_jsx(Text, {
122
+ style: textStyle,
123
+ children: children
124
+ })]
125
+ })
126
+ });
127
+ }
107
128
  });
108
129
  });
109
130
  QuickLinksFeatureItem.displayName = 'QuickLinksFeatureItem';
@@ -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
@@ -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
  };
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.33.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.0"
76
76
  }
@@ -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
  }}
@@ -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'),