@telus-uds/components-base 1.49.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.
Files changed (32) hide show
  1. package/CHANGELOG.md +27 -2
  2. package/component-docs.json +110 -14
  3. package/lib/Link/LinkBase.js +1 -1
  4. package/lib/MultiSelectFilter/ModalOverlay.js +24 -8
  5. package/lib/MultiSelectFilter/MultiSelectFilter.js +154 -21
  6. package/lib/QuickLinksFeature/QuickLinksFeatureItem.js +62 -41
  7. package/lib/StepTracker/Step.js +35 -14
  8. package/lib/StepTracker/StepTracker.js +5 -2
  9. package/lib/StepTracker/dictionary.js +24 -4
  10. package/lib/TextInput/TextInput.js +17 -15
  11. package/lib/ThemeProvider/ThemeProvider.js +7 -1
  12. package/lib-module/Link/LinkBase.js +1 -1
  13. package/lib-module/MultiSelectFilter/ModalOverlay.js +25 -9
  14. package/lib-module/MultiSelectFilter/MultiSelectFilter.js +154 -23
  15. package/lib-module/QuickLinksFeature/QuickLinksFeatureItem.js +64 -43
  16. package/lib-module/StepTracker/Step.js +35 -14
  17. package/lib-module/StepTracker/StepTracker.js +5 -2
  18. package/lib-module/StepTracker/dictionary.js +24 -4
  19. package/lib-module/TextInput/TextInput.js +19 -15
  20. package/lib-module/ThemeProvider/ThemeProvider.js +8 -2
  21. package/package.json +2 -2
  22. package/src/Card/CardBase.jsx +0 -1
  23. package/src/Link/LinkBase.jsx +3 -1
  24. package/src/MultiSelectFilter/ModalOverlay.jsx +30 -6
  25. package/src/MultiSelectFilter/MultiSelectFilter.jsx +142 -20
  26. package/src/QuickLinksFeature/QuickLinksFeatureItem.jsx +42 -35
  27. package/src/StepTracker/Step.jsx +34 -10
  28. package/src/StepTracker/StepTracker.jsx +11 -2
  29. package/src/StepTracker/dictionary.js +24 -4
  30. package/src/TextInput/TextInput.jsx +8 -5
  31. package/src/ThemeProvider/ThemeProvider.jsx +9 -2
  32. package/src/Typography/Typography.jsx +1 -0
@@ -56,6 +56,7 @@ const selectContainerStyle = _ref => {
56
56
  } = _ref;
57
57
  return {
58
58
  textAlign,
59
+ outline: 'red',
59
60
  width: contentMaxDimension,
60
61
  overflow: 'hidden'
61
62
  };
@@ -67,6 +68,15 @@ const selectImageContainerStyle = contentMaxDimension => ({
67
68
  justifyContent: 'center',
68
69
  alignItems: 'center'
69
70
  });
71
+
72
+ const selectLinkToken = _ref2 => {
73
+ let {
74
+ outerBorderColor
75
+ } = _ref2;
76
+ return {
77
+ outerBorderColor
78
+ };
79
+ };
70
80
  /**
71
81
  * Component export along with QuickLinksFeature to be used as children
72
82
  *
@@ -74,7 +84,7 @@ const selectImageContainerStyle = contentMaxDimension => ({
74
84
  */
75
85
 
76
86
 
77
- const QuickLinksFeatureItem = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
87
+ const QuickLinksFeatureItem = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) => {
78
88
  let {
79
89
  tokens,
80
90
  variant,
@@ -82,52 +92,63 @@ const QuickLinksFeatureItem = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) =
82
92
  imageAccessibilityLabel,
83
93
  imageSource,
84
94
  ...rest
85
- } = _ref2;
95
+ } = _ref3;
86
96
  const viewport = (0, _ViewportProvider.useViewport)();
87
97
  const getTokens = (0, _ThemeProvider.useThemeTokensCallback)('QuickLinksFeatureItem', tokens, variant);
88
- const [hover, setHover] = (0, _react.useState)(false);
89
- const {
90
- contentDirection,
91
- contentSpace,
92
- contentAlignItems,
93
- contentMaxDimension,
94
- imageDimension,
95
- textAlign
96
- } = getTokens({
97
- viewport,
98
- hover
99
- });
100
98
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Link.Link, {
101
99
  ref: ref,
102
- tokens: state => {
103
- setHover(state.hover);
104
- return getTokens(state);
105
- },
106
100
  ...selectProps(rest),
107
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
108
- style: selectContainerStyle({
101
+ tokens: state => selectLinkToken(getTokens(state)),
102
+ children: _ref4 => {
103
+ let {
104
+ hovered: hover,
105
+ pressed,
106
+ focused: focus
107
+ } = _ref4;
108
+ const {
109
+ contentDirection,
110
+ contentSpace,
111
+ contentAlignItems,
109
112
  contentMaxDimension,
110
- textAlign
111
- }),
112
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_StackView.StackWrap, {
113
- direction: contentDirection,
114
- space: contentSpace,
115
- tokens: {
116
- alignItems: contentAlignItems
117
- },
118
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
119
- style: selectImageContainerStyle(contentMaxDimension),
120
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Image.default, {
121
- accessibilityIgnoresInvertColors: true,
122
- imageAccessibilityLabel: imageAccessibilityLabel,
123
- source: imageSource,
124
- style: selectImageStyle(imageDimension)
125
- })
126
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
127
- children: children
128
- })]
129
- })
130
- })
113
+ imageDimension,
114
+ textLine,
115
+ gap,
116
+ ...themeTokens
117
+ } = getTokens({
118
+ viewport,
119
+ hover,
120
+ pressed,
121
+ focus
122
+ });
123
+ const textStyle = { ...(0, _ThemeProvider.applyTextStyles)(themeTokens),
124
+ textDecorationLine: textLine
125
+ };
126
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
127
+ style: selectContainerStyle({ ...themeTokens,
128
+ contentMaxDimension
129
+ }),
130
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_StackView.StackWrap, {
131
+ direction: contentDirection,
132
+ space: contentSpace,
133
+ gap: gap,
134
+ tokens: {
135
+ alignItems: contentAlignItems
136
+ },
137
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
138
+ style: selectImageContainerStyle(contentMaxDimension),
139
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Image.default, {
140
+ accessibilityIgnoresInvertColors: true,
141
+ imageAccessibilityLabel: imageAccessibilityLabel,
142
+ source: imageSource,
143
+ style: selectImageStyle(imageDimension)
144
+ })
145
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
146
+ style: textStyle,
147
+ children: children
148
+ })]
149
+ })
150
+ });
151
+ }
131
152
  });
132
153
  });
133
154
  QuickLinksFeatureItem.displayName = 'QuickLinksFeatureItem';
@@ -96,17 +96,18 @@ const selectKnobStyles = (_ref4, isCompleted, isCurrent) => {
96
96
  height: knobSize,
97
97
  width: knobSize,
98
98
  ...(isCompleted && {
99
- backgroundColor: knobCompletedBackgroundColor,
100
- borderColor: knobCompletedBorderColor,
101
- paddingLeft: knobCompletedPaddingLeft,
102
- paddingTop: knobCompletedPaddingTop
103
- }),
104
- ...(isCurrent && {
105
99
  backgroundColor: knobCurrentBackgroundColor,
106
100
  borderColor: knobCurrentBorderColor,
107
101
  borderWidth: knobCurrentBorderWidth,
108
102
  paddingLeft: knobCurrentPaddingLeft,
109
103
  paddingTop: knobCurrentPaddingTop
104
+ }),
105
+ ...(isCurrent && {
106
+ backgroundColor: knobCompletedBackgroundColor,
107
+ borderColor: knobCompletedBorderColor,
108
+ borderWidth: knobCurrentBorderWidth,
109
+ paddingLeft: knobCompletedPaddingLeft,
110
+ paddingTop: knobCompletedPaddingTop
110
111
  })
111
112
  };
112
113
  };
@@ -128,7 +129,26 @@ const selectLabelContainerStyles = _ref5 => {
128
129
  };
129
130
  };
130
131
 
131
- const selectLabelStyles = (_ref6, themeOptions, isCurrent) => {
132
+ const selectStepLabelStyles = (_ref6, themeOptions, isCurrent) => {
133
+ let {
134
+ stepLabelColor,
135
+ labelCurrentColor,
136
+ stepLabelFontWeight,
137
+ stepLabelFontSize,
138
+ stepLabelFontName,
139
+ stepLabelLineHeight
140
+ } = _ref6;
141
+ return (0, _ThemeProvider.applyTextStyles)({
142
+ color: isCurrent ? labelCurrentColor : stepLabelColor,
143
+ fontSize: stepLabelFontSize,
144
+ lineHeight: stepLabelLineHeight,
145
+ fontWeight: stepLabelFontWeight,
146
+ fontName: stepLabelFontName,
147
+ themeOptions
148
+ });
149
+ };
150
+
151
+ const selectLabelStyles = (_ref7, themeOptions, isCurrent) => {
132
152
  let {
133
153
  labelColor,
134
154
  labelCurrentColor,
@@ -137,7 +157,7 @@ const selectLabelStyles = (_ref6, themeOptions, isCurrent) => {
137
157
  labelFontWeight,
138
158
  labelFontName,
139
159
  labelLineHeight
140
- } = _ref6;
160
+ } = _ref7;
141
161
  return (0, _ThemeProvider.applyTextStyles)({
142
162
  color: isCurrent ? labelCurrentColor : labelColor,
143
163
  fontSize: labelFontSize,
@@ -164,7 +184,7 @@ const getStepTestID = (isCompleted, isCurrent) => {
164
184
  */
165
185
 
166
186
 
167
- const Step = _ref7 => {
187
+ const Step = _ref8 => {
168
188
  let {
169
189
  label,
170
190
  name,
@@ -173,11 +193,12 @@ const Step = _ref7 => {
173
193
  stepIndex = 0,
174
194
  tokens,
175
195
  ...rest
176
- } = _ref7;
196
+ } = _ref8;
177
197
  const {
178
198
  completedIcon,
179
199
  showStepLabel,
180
200
  showStepName,
201
+ textStepTrackerLabel,
181
202
  ...themeTokens
182
203
  } = tokens;
183
204
  const isFirst = stepIndex === 0;
@@ -211,11 +232,11 @@ const Step = _ref7 => {
211
232
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
212
233
  style: [staticStyles.knob, selectKnobStyles(themeTokens, isCompleted, isCurrent)],
213
234
  testID: getStepTestID(isCompleted, isCurrent),
214
- children: [isCompleted && completedIcon && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.default, {
235
+ children: [(isCompleted && completedIcon || isCurrent && !completedIcon) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
236
+ style: selectCurrentInnerStyles(themeTokens)
237
+ }), isCurrent && completedIcon && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.default, {
215
238
  icon: completedIcon,
216
239
  tokens: selectCompletedIconTokens(themeTokens)
217
- }), isCurrent && /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
218
- style: selectCurrentInnerStyles(themeTokens)
219
240
  })]
220
241
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
221
242
  style: [staticStyles.connector, !isLast && selectConnectorStyles(themeTokens, isCompleted)]
@@ -223,7 +244,7 @@ const Step = _ref7 => {
223
244
  }), showStepLabel && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
224
245
  style: [staticStyles.stepLabelContainer, selectLabelContainerStyles(tokens)],
225
246
  children: [showStepName && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.default, {
226
- style: [staticStyles.centeredText, selectLabelStyles(tokens, themeOptions, isCurrent)],
247
+ style: [staticStyles.centeredText, selectStepLabelStyles(tokens, themeOptions, isCurrent)],
227
248
  children: name
228
249
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_StackView.default, {
229
250
  direction: "row",
@@ -131,13 +131,16 @@ const StepTracker = /*#__PURE__*/(0, _react.forwardRef)((_ref4, ref) => {
131
131
  } = (0, _ThemeProvider.useThemeTokens)('StepTracker', tokens, variant, {
132
132
  viewport
133
133
  });
134
+ const {
135
+ textStepTrackerLabel
136
+ } = themeTokens;
134
137
  const getCopy = (0, _useCopy.default)({
135
138
  dictionary,
136
139
  copy
137
140
  });
138
- 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]) : '';
141
+ 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]) : '';
139
142
 
140
- const getStepLabel = index => themeTokens.showStepLabel ? getCopy('stepLabel').replace('%{stepNumber}', index + 1) : '';
143
+ const getStepLabel = index => themeTokens.showStepLabel ? (typeof copy === 'string' ? getCopy(textStepTrackerLabel ?? 1).stepLabel : getCopy('stepLabel')).replace('%{stepNumber}', index + 1) : '';
141
144
 
142
145
  const {
143
146
  themeOptions
@@ -6,12 +6,32 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _default = {
8
8
  en: {
9
- stepLabel: 'Step %{stepNumber}',
10
- stepTrackerLabel: 'Step %{stepNumber} of %{stepCount}: %{stepLabel}'
9
+ 1: {
10
+ stepLabel: 'Step %{stepNumber}',
11
+ stepTrackerLabel: 'Step %{stepNumber} of %{stepCount}: %{stepLabel}'
12
+ },
13
+ 2: {
14
+ stepLabel: '%{stepNumber}.',
15
+ stepTrackerLabel: 'Step %{stepNumber} of %{stepCount}: %{stepLabel}'
16
+ },
17
+ 3: {
18
+ stepLabel: 'Step %{stepNumber}',
19
+ stepTrackerLabel: 'Step %{stepNumber} of %{stepCount}: %{stepLabel}'
20
+ }
11
21
  },
12
22
  fr: {
13
- stepLabel: 'Étape %{stepNumber}',
14
- stepTrackerLabel: 'Étape %{stepNumber} sur %{stepCount}: %{stepLabel}'
23
+ 1: {
24
+ stepLabel: 'Étape %{stepNumber}',
25
+ stepTrackerLabel: 'Étape %{stepNumber} sur %{stepCount}: %{stepLabel}'
26
+ },
27
+ 2: {
28
+ stepLabel: '%{stepNumber}.',
29
+ stepTrackerLabel: 'Étape %{stepNumber} sur %{stepCount}: %{stepLabel}'
30
+ },
31
+ 3: {
32
+ stepLabel: 'Étape %{stepNumber}',
33
+ stepTrackerLabel: 'Étape %{stepNumber} sur %{stepCount}: %{stepLabel}'
34
+ }
15
35
  }
16
36
  };
17
37
  exports.default = _default;
@@ -62,21 +62,23 @@ const TextInput = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
62
62
  validation: supportsProps.validation
63
63
  }
64
64
  };
65
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputSupports.default, {
66
- nativeID: nativeID,
67
- ...supportsProps,
68
- children: _ref2 => {
69
- let {
70
- inputId,
71
- ...propsFromInputSupports
72
- } = _ref2;
73
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextInputBase.default, {
74
- ref: ref,
75
- nativeID: inputId,
76
- ...propsFromInputSupports,
77
- ...inputProps
78
- });
79
- }
65
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
66
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_InputSupports.default, {
67
+ nativeID: nativeID,
68
+ ...supportsProps,
69
+ children: _ref2 => {
70
+ let {
71
+ inputId,
72
+ ...propsFromInputSupports
73
+ } = _ref2;
74
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextInputBase.default, {
75
+ ref: ref,
76
+ nativeID: inputId,
77
+ ...propsFromInputSupports,
78
+ ...inputProps
79
+ });
80
+ }
81
+ }), rest.children]
80
82
  });
81
83
  });
82
84
  TextInput.displayName = 'TextInput';
@@ -45,6 +45,11 @@ const ThemeProvider = _ref => {
45
45
  themeOptions = {}
46
46
  } = _ref;
47
47
  const [theme, setTheme] = (0, _react.useState)(defaultTheme);
48
+ (0, _react.useEffect)(() => {
49
+ if (theme.metadata.name !== defaultTheme.metadata.name) {
50
+ setTheme(defaultTheme);
51
+ }
52
+ }, [theme.metadata.name, defaultTheme]);
48
53
  const appliedThemeOptions = { ...defaultThemeOptions,
49
54
  ...themeOptions
50
55
  }; // Validate the theme tokens version on every render.
@@ -67,7 +72,8 @@ ThemeProvider.propTypes = {
67
72
  children: _propTypes.default.node.isRequired,
68
73
  defaultTheme: _propTypes.default.shape({
69
74
  metadata: _propTypes.default.shape({
70
- themeTokensVersion: _propTypes.default.string.isRequired
75
+ themeTokensVersion: _propTypes.default.string.isRequired,
76
+ name: _propTypes.default.string.isRequired
71
77
  }).isRequired
72
78
  }).isRequired,
73
79
 
@@ -201,7 +201,7 @@ const LinkBase = /*#__PURE__*/forwardRef((_ref6, ref) => {
201
201
  },
202
202
  children: /*#__PURE__*/_jsx(Text, {
203
203
  style: [textStyles, blockTextStyles, staticStyles.baseline],
204
- children: children
204
+ children: typeof children === 'function' ? children(linkState) : children
205
205
  })
206
206
  });
207
207
  }
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
3
3
  import View from "react-native-web/dist/exports/View";
4
4
  import StyleSheet from "react-native-web/dist/exports/StyleSheet";
5
5
  import { Portal } from '@gorhom/portal';
6
- import { selectTokens, useCopy, copyPropTypes, getTokensPropType, variantProp } from '../utils';
6
+ import { useCopy, copyPropTypes, getTokensPropType, variantProp } from '../utils';
7
7
  import { useViewport } from '../ViewportProvider';
8
8
  import { useThemeTokens } from '../ThemeProvider';
9
9
  import dictionary from './dictionary';
@@ -16,7 +16,6 @@ const staticStyles = StyleSheet.create({
16
16
  flex: 1,
17
17
  // Grow to maxWidth when possible, shrink when not possible
18
18
  position: 'absolute',
19
- height: 330,
20
19
  zIndex: 10000 // Position on top of all the other overlays, including backdrops and modals
21
20
 
22
21
  },
@@ -62,6 +61,11 @@ const ModalOverlay = /*#__PURE__*/forwardRef((_ref3, ref) => {
62
61
  let {
63
62
  children,
64
63
  isReady = false,
64
+ maxHeight,
65
+ maxHeightSize,
66
+ maxWidthSize,
67
+ minHeight,
68
+ minWidth,
65
69
  overlaidPosition,
66
70
  onLayout,
67
71
  variant,
@@ -74,9 +78,18 @@ const ModalOverlay = /*#__PURE__*/forwardRef((_ref3, ref) => {
74
78
  viewport,
75
79
  maxWidth: false
76
80
  });
81
+ const containerWidthHeight = {
82
+ minWidth,
83
+ minHeight,
84
+ ...(tokens.maxWidth && maxWidthSize && {
85
+ maxWidth: maxWidthSize
86
+ }),
87
+ ...(maxHeight && maxHeightSize && {
88
+ maxHeight: maxHeightSize
89
+ })
90
+ };
77
91
  const {
78
- closeIcon: CloseIconComponent,
79
- maxWidth
92
+ closeIcon: CloseIconComponent
80
93
  } = themeTokens;
81
94
  const getCopy = useCopy({
82
95
  dictionary,
@@ -87,9 +100,7 @@ const ModalOverlay = /*#__PURE__*/forwardRef((_ref3, ref) => {
87
100
  children: /*#__PURE__*/_jsx(View, {
88
101
  ref: ref,
89
102
  onLayout: onLayout,
90
- style: [overlaidPosition, {
91
- minWidth: maxWidth
92
- }, staticStyles.positioner, !isReady && staticStyles.hidden],
103
+ style: [overlaidPosition, containerWidthHeight, staticStyles.positioner, !isReady && staticStyles.hidden],
93
104
  children: /*#__PURE__*/_jsxs(Card, {
94
105
  tokens: selectPaddingContainerStyles(themeTokens),
95
106
  children: [/*#__PURE__*/_jsx(View, {
@@ -98,8 +109,7 @@ const ModalOverlay = /*#__PURE__*/forwardRef((_ref3, ref) => {
98
109
  onPress: onClose,
99
110
  icon: CloseIconComponent,
100
111
  accessibilityRole: "button",
101
- accessibilityLabel: closeLabel,
102
- tokens: selectTokens('IconButton', themeTokens, 'close')
112
+ accessibilityLabel: closeLabel
103
113
  })
104
114
  }), children]
105
115
  })
@@ -115,6 +125,12 @@ ModalOverlay.propTypes = {
115
125
  left: PropTypes.number,
116
126
  width: PropTypes.number
117
127
  }),
128
+ minWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
129
+ minHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
130
+ maxHeightSize: PropTypes.number,
131
+ maxWidthSize: PropTypes.number,
132
+ maxHeight: PropTypes.bool,
133
+ maxWidth: PropTypes.bool,
118
134
  onLayout: PropTypes.func,
119
135
  variant: variantProp.propType,
120
136
  tokens: getTokensPropType('Modal'),