@telus-uds/components-web 2.25.0 → 2.26.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.
package/CHANGELOG.md CHANGED
@@ -1,12 +1,35 @@
1
1
  # Change Log - @telus-uds/components-web
2
2
 
3
- This log was last generated on Sat, 18 Nov 2023 02:25:11 GMT and should not be manually modified.
3
+ This log was last generated on Fri, 01 Dec 2023 20:57:37 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 2.26.0
8
+
9
+ Fri, 01 Dec 2023 20:57:37 GMT
10
+
11
+ ### Minor changes
12
+
13
+ - `Card`: Add interactive section (shahzaibkhalidmalik@outlook.com)
14
+ - Bump @telus-uds/components-base to v1.71.0
15
+ - Bump @telus-uds/system-theme-tokens to v2.47.0
16
+
17
+ ### Patches
18
+
19
+ - fix tokens type for Multiselect props (email not defined)
20
+
21
+ ## 2.25.1
22
+
23
+ Mon, 27 Nov 2023 21:20:44 GMT
24
+
25
+ ### Patches
26
+
27
+ - TS defenitions for WebVideo (srikanthkhari@gmail.com)
28
+ - Bump @telus-uds/components-base to v1.70.0
29
+
7
30
  ## 2.25.0
8
31
 
9
- Sat, 18 Nov 2023 02:25:11 GMT
32
+ Sat, 18 Nov 2023 02:32:49 GMT
10
33
 
11
34
  ### Minor changes
12
35
 
package/lib/Card/Card.js CHANGED
@@ -16,27 +16,6 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
16
16
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
17
  /* eslint-disable react/require-default-props */
18
18
 
19
- const selectCardBaseTokens = _ref => {
20
- let {
21
- backgroundColor,
22
- borderColor,
23
- gradient,
24
- borderWidth,
25
- borderRadius,
26
- shadow,
27
- minWidth
28
- } = _ref;
29
- return {
30
- backgroundColor,
31
- borderColor,
32
- gradient,
33
- borderWidth,
34
- borderRadius,
35
- shadow,
36
- minWidth
37
- };
38
- };
39
-
40
19
  // Passes React Native-oriented system props through UDS Card
41
20
  const [selectProps, selectedSystemPropTypes] = (0, _componentsBase.selectSystemProps)([_componentsBase.a11yProps, _componentsBase.viewProps]);
42
21
 
@@ -75,8 +54,11 @@ const Card = /*#__PURE__*/(0, _react.forwardRef)(function () {
75
54
  footerPadding,
76
55
  fullBleedImage,
77
56
  fullBleedContent = fullBleedImage,
78
- tokens,
57
+ tokens = {},
79
58
  variant,
59
+ interactiveCard,
60
+ onPress,
61
+ dataSet,
80
62
  ...rest
81
63
  } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
82
64
  fullBleedContent: {
@@ -93,9 +75,15 @@ const Card = /*#__PURE__*/(0, _react.forwardRef)(function () {
93
75
 
94
76
  // If the card has rounded corners and a full bleed image, we need to apply
95
77
  // those corners on the image as well, but partially
96
- const cardTokens = (0, _componentsBase.useThemeTokens)('Card', tokens, variant);
78
+ const {
79
+ borderRadius
80
+ } = (0, _componentsBase.useThemeTokens)('Card', tokens, variant);
81
+ const getThemeTokens = (0, _componentsBase.useThemeTokensCallback)('Card', interactiveCard === null || interactiveCard === void 0 ? void 0 : interactiveCard.tokens, {
82
+ interactive: true,
83
+ ...((interactiveCard === null || interactiveCard === void 0 ? void 0 : interactiveCard.variant) || {})
84
+ });
97
85
  const hasFooter = Boolean(footer);
98
- const fullBleedBorderRadius = (0, _FullBleedContent.getFullBleedBorderRadius)(cardTokens === null || cardTokens === void 0 ? void 0 : cardTokens.borderRadius, fullBleedContentPosition, hasFooter);
86
+ const fullBleedBorderRadius = (0, _FullBleedContent.getFullBleedBorderRadius)(borderRadius, fullBleedContentPosition, hasFooter);
99
87
 
100
88
  // Make multiple cards in a row have equal heights with even space between content items
101
89
  const columnFlex = {
@@ -103,30 +91,46 @@ const Card = /*#__PURE__*/(0, _react.forwardRef)(function () {
103
91
  flexShrink: 1,
104
92
  justifyContent: 'space-between'
105
93
  };
94
+ // When interactive area is present, spacing tokens should only be applied
95
+ // to individual Card sections, not Card as a whole
96
+ const {
97
+ paddingTop,
98
+ paddingBottom,
99
+ paddingLeft,
100
+ paddingRight,
101
+ ...restOfTokens
102
+ } = tokens;
106
103
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Card, {
107
104
  ref: ref,
108
105
  variant: {
109
106
  ...variant,
110
107
  padding: 'custom'
111
108
  },
112
- tokens: selectCardBaseTokens(cardTokens),
109
+ tokens: restOfTokens,
113
110
  ...selectProps(rest),
114
111
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_componentsBase.StackView, {
115
112
  space: 0,
116
113
  tokens: columnFlex,
117
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_componentsBase.StackView, {
114
+ children: [interactiveCard !== null && interactiveCard !== void 0 && interactiveCard.body ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.PressableCardBase, {
115
+ ref: ref,
116
+ tokens: getThemeTokens,
117
+ dataSet: dataSet,
118
+ onPress: onPress,
119
+ ...selectProps(rest),
120
+ children: interactiveCard === null || interactiveCard === void 0 ? void 0 : interactiveCard.body
121
+ }) : null, /*#__PURE__*/(0, _jsxRuntime.jsxs)(_componentsBase.StackView, {
118
122
  direction: contentStackDirection,
119
123
  tokens: {
120
124
  ...columnFlex,
121
125
  alignItems: contentStackAlign
122
126
  },
123
127
  space: 0,
124
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_CardContent.default, {
128
+ children: [children ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_CardContent.default, {
125
129
  tokens: tokens,
126
130
  variant: variant,
127
131
  withFooter: hasFooter,
128
132
  children: children
129
- }), fullBleedContentPosition !== 'none' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_FullBleedContent.default, {
133
+ }) : null, fullBleedContentPosition !== 'none' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_FullBleedContent.default, {
130
134
  borderRadius: fullBleedBorderRadius,
131
135
  ...fullBleedContentProps
132
136
  })]
@@ -179,7 +183,20 @@ Card.propTypes = {
179
183
  /**
180
184
  * Card variant.
181
185
  */
182
- variant: _componentsBase.variantProp.propType
186
+ variant: _componentsBase.variantProp.propType,
187
+ /**
188
+ * Function to call on pressing the card.
189
+ * Note: This is only available when `interactive` variant is used.
190
+ */
191
+ onPress: _propTypes.default.func,
192
+ /**
193
+ * Object to set interactive card's properties
194
+ */
195
+ interactiveCard: _propTypes.default.shape({
196
+ body: _propTypes.default.node,
197
+ tokens: (0, _componentsBase.getTokensPropType)('Card'),
198
+ variant: _componentsBase.variantProp.propType
199
+ })
183
200
  };
184
201
  var _default = Card;
185
202
  exports.default = _default;
@@ -111,8 +111,7 @@ const WaffleGrid = _ref2 => {
111
111
  (0, _jsxRuntime.jsx)(_Image.default, {
112
112
  src: child.image,
113
113
  alt: child.imageAltText,
114
- width: 96,
115
- height: 128
114
+ width: 96
116
115
  }) :
117
116
  // Otherwise it must be an arbitrary content, which we just display by itself
118
117
  child.image, /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Typography, {
@@ -1,34 +1,14 @@
1
1
  /* eslint-disable react/require-default-props */
2
2
  import React, { forwardRef } from 'react';
3
3
  import PropTypes from 'prop-types';
4
- import { Card as CardBase, getTokensPropType, paddingProp, responsiveProps, selectSystemProps, StackView, useThemeTokens, variantProp, a11yProps, viewProps } from '@telus-uds/components-base';
4
+ import { Card as CardBase, getTokensPropType, paddingProp, responsiveProps, selectSystemProps, StackView, useThemeTokens, useThemeTokensCallback, variantProp, a11yProps, viewProps, PressableCardBase } from '@telus-uds/components-base';
5
5
  import CardContent from './CardContent';
6
6
  import CardFooter from './CardFooter';
7
7
  import FullBleedContent, { getFullBleedBorderRadius, useFullBleedContentProps } from '../shared/FullBleedContent';
8
- import { jsx as _jsx } from "react/jsx-runtime";
9
- import { jsxs as _jsxs } from "react/jsx-runtime";
10
- const selectCardBaseTokens = _ref => {
11
- let {
12
- backgroundColor,
13
- borderColor,
14
- gradient,
15
- borderWidth,
16
- borderRadius,
17
- shadow,
18
- minWidth
19
- } = _ref;
20
- return {
21
- backgroundColor,
22
- borderColor,
23
- gradient,
24
- borderWidth,
25
- borderRadius,
26
- shadow,
27
- minWidth
28
- };
29
- };
30
8
 
31
9
  // Passes React Native-oriented system props through UDS Card
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ import { jsxs as _jsxs } from "react/jsx-runtime";
32
12
  const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
33
13
 
34
14
  /**
@@ -66,8 +46,11 @@ const Card = /*#__PURE__*/forwardRef(function () {
66
46
  footerPadding,
67
47
  fullBleedImage,
68
48
  fullBleedContent = fullBleedImage,
69
- tokens,
49
+ tokens = {},
70
50
  variant,
51
+ interactiveCard,
52
+ onPress,
53
+ dataSet,
71
54
  ...rest
72
55
  } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
73
56
  fullBleedContent: {
@@ -84,9 +67,15 @@ const Card = /*#__PURE__*/forwardRef(function () {
84
67
 
85
68
  // If the card has rounded corners and a full bleed image, we need to apply
86
69
  // those corners on the image as well, but partially
87
- const cardTokens = useThemeTokens('Card', tokens, variant);
70
+ const {
71
+ borderRadius
72
+ } = useThemeTokens('Card', tokens, variant);
73
+ const getThemeTokens = useThemeTokensCallback('Card', interactiveCard === null || interactiveCard === void 0 ? void 0 : interactiveCard.tokens, {
74
+ interactive: true,
75
+ ...((interactiveCard === null || interactiveCard === void 0 ? void 0 : interactiveCard.variant) || {})
76
+ });
88
77
  const hasFooter = Boolean(footer);
89
- const fullBleedBorderRadius = getFullBleedBorderRadius(cardTokens === null || cardTokens === void 0 ? void 0 : cardTokens.borderRadius, fullBleedContentPosition, hasFooter);
78
+ const fullBleedBorderRadius = getFullBleedBorderRadius(borderRadius, fullBleedContentPosition, hasFooter);
90
79
 
91
80
  // Make multiple cards in a row have equal heights with even space between content items
92
81
  const columnFlex = {
@@ -94,30 +83,46 @@ const Card = /*#__PURE__*/forwardRef(function () {
94
83
  flexShrink: 1,
95
84
  justifyContent: 'space-between'
96
85
  };
86
+ // When interactive area is present, spacing tokens should only be applied
87
+ // to individual Card sections, not Card as a whole
88
+ const {
89
+ paddingTop,
90
+ paddingBottom,
91
+ paddingLeft,
92
+ paddingRight,
93
+ ...restOfTokens
94
+ } = tokens;
97
95
  return /*#__PURE__*/_jsx(CardBase, {
98
96
  ref: ref,
99
97
  variant: {
100
98
  ...variant,
101
99
  padding: 'custom'
102
100
  },
103
- tokens: selectCardBaseTokens(cardTokens),
101
+ tokens: restOfTokens,
104
102
  ...selectProps(rest),
105
103
  children: /*#__PURE__*/_jsxs(StackView, {
106
104
  space: 0,
107
105
  tokens: columnFlex,
108
- children: [/*#__PURE__*/_jsxs(StackView, {
106
+ children: [interactiveCard !== null && interactiveCard !== void 0 && interactiveCard.body ? /*#__PURE__*/_jsx(PressableCardBase, {
107
+ ref: ref,
108
+ tokens: getThemeTokens,
109
+ dataSet: dataSet,
110
+ onPress: onPress,
111
+ ...selectProps(rest),
112
+ children: interactiveCard === null || interactiveCard === void 0 ? void 0 : interactiveCard.body
113
+ }) : null, /*#__PURE__*/_jsxs(StackView, {
109
114
  direction: contentStackDirection,
110
115
  tokens: {
111
116
  ...columnFlex,
112
117
  alignItems: contentStackAlign
113
118
  },
114
119
  space: 0,
115
- children: [/*#__PURE__*/_jsx(CardContent, {
120
+ children: [children ? /*#__PURE__*/_jsx(CardContent, {
116
121
  tokens: tokens,
117
122
  variant: variant,
118
123
  withFooter: hasFooter,
119
124
  children: children
120
- }), fullBleedContentPosition !== 'none' && /*#__PURE__*/_jsx(FullBleedContent, {
125
+ }) : null, fullBleedContentPosition !== 'none' && /*#__PURE__*/_jsx(FullBleedContent, {
121
126
  borderRadius: fullBleedBorderRadius,
122
127
  ...fullBleedContentProps
123
128
  })]
@@ -170,6 +175,19 @@ Card.propTypes = {
170
175
  /**
171
176
  * Card variant.
172
177
  */
173
- variant: variantProp.propType
178
+ variant: variantProp.propType,
179
+ /**
180
+ * Function to call on pressing the card.
181
+ * Note: This is only available when `interactive` variant is used.
182
+ */
183
+ onPress: PropTypes.func,
184
+ /**
185
+ * Object to set interactive card's properties
186
+ */
187
+ interactiveCard: PropTypes.shape({
188
+ body: PropTypes.node,
189
+ tokens: getTokensPropType('Card'),
190
+ variant: variantProp.propType
191
+ })
174
192
  };
175
193
  export default Card;
@@ -104,8 +104,7 @@ const WaffleGrid = _ref2 => {
104
104
  _jsx(Image, {
105
105
  src: child.image,
106
106
  alt: child.imageAltText,
107
- width: 96,
108
- height: 128
107
+ width: 96
109
108
  }) :
110
109
  // Otherwise it must be an arbitrary content, which we just display by itself
111
110
  child.image, /*#__PURE__*/_jsx(Typography, {
package/package.json CHANGED
@@ -5,14 +5,14 @@
5
5
  ],
6
6
  "dependencies": {
7
7
  "@gorhom/portal": "^1.0.14",
8
- "@telus-uds/components-base": "1.69.0",
8
+ "@telus-uds/components-base": "1.71.0",
9
9
  "@telus-uds/system-constants": "^1.3.0",
10
10
  "fscreen": "^1.2.0",
11
11
  "lodash.omit": "^4.5.0",
12
12
  "react-dates": "^21.8.0",
13
13
  "react-helmet-async": "^1.3.0",
14
14
  "react-moment-proptypes": "^1.8.1",
15
- "@telus-uds/system-theme-tokens": "^2.46.0",
15
+ "@telus-uds/system-theme-tokens": "^2.47.0",
16
16
  "prop-types": "^15.7.2",
17
17
  "lodash.throttle": "^4.1.1",
18
18
  "react-youtube": "^10.1.0",
@@ -62,5 +62,5 @@
62
62
  "skip": true
63
63
  },
64
64
  "types": "types/index.d.ts",
65
- "version": "2.25.0"
65
+ "version": "2.26.0"
66
66
  }
package/src/Card/Card.jsx CHANGED
@@ -9,9 +9,11 @@ import {
9
9
  selectSystemProps,
10
10
  StackView,
11
11
  useThemeTokens,
12
+ useThemeTokensCallback,
12
13
  variantProp,
13
14
  a11yProps,
14
- viewProps
15
+ viewProps,
16
+ PressableCardBase
15
17
  } from '@telus-uds/components-base'
16
18
  import CardContent from './CardContent'
17
19
  import CardFooter from './CardFooter'
@@ -20,26 +22,6 @@ import FullBleedContent, {
20
22
  useFullBleedContentProps
21
23
  } from '../shared/FullBleedContent'
22
24
 
23
- const selectCardBaseTokens = ({
24
- backgroundColor,
25
- borderColor,
26
- gradient,
27
- borderWidth,
28
- borderRadius,
29
- shadow,
30
- minWidth
31
- }) => {
32
- return {
33
- backgroundColor,
34
- borderColor,
35
- gradient,
36
- borderWidth,
37
- borderRadius,
38
- shadow,
39
- minWidth
40
- }
41
- }
42
-
43
25
  // Passes React Native-oriented system props through UDS Card
44
26
  const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps])
45
27
 
@@ -79,8 +61,11 @@ const Card = forwardRef(
79
61
  footerPadding,
80
62
  fullBleedImage,
81
63
  fullBleedContent = fullBleedImage,
82
- tokens,
64
+ tokens = {},
83
65
  variant,
66
+ interactiveCard,
67
+ onPress,
68
+ dataSet,
84
69
  ...rest
85
70
  } = {
86
71
  fullBleedContent: { position: null }
@@ -96,10 +81,14 @@ const Card = forwardRef(
96
81
 
97
82
  // If the card has rounded corners and a full bleed image, we need to apply
98
83
  // those corners on the image as well, but partially
99
- const cardTokens = useThemeTokens('Card', tokens, variant)
84
+ const { borderRadius } = useThemeTokens('Card', tokens, variant)
85
+ const getThemeTokens = useThemeTokensCallback('Card', interactiveCard?.tokens, {
86
+ interactive: true,
87
+ ...(interactiveCard?.variant || {})
88
+ })
100
89
  const hasFooter = Boolean(footer)
101
90
  const fullBleedBorderRadius = getFullBleedBorderRadius(
102
- cardTokens?.borderRadius,
91
+ borderRadius,
103
92
  fullBleedContentPosition,
104
93
  hasFooter
105
94
  )
@@ -110,23 +99,39 @@ const Card = forwardRef(
110
99
  flexShrink: 1,
111
100
  justifyContent: 'space-between'
112
101
  }
102
+ // When interactive area is present, spacing tokens should only be applied
103
+ // to individual Card sections, not Card as a whole
104
+ const { paddingTop, paddingBottom, paddingLeft, paddingRight, ...restOfTokens } = tokens
113
105
 
114
106
  return (
115
107
  <CardBase
116
108
  ref={ref}
117
109
  variant={{ ...variant, padding: 'custom' }}
118
- tokens={selectCardBaseTokens(cardTokens)}
110
+ tokens={restOfTokens}
119
111
  {...selectProps(rest)}
120
112
  >
121
113
  <StackView space={0} tokens={columnFlex}>
114
+ {interactiveCard?.body ? (
115
+ <PressableCardBase
116
+ ref={ref}
117
+ tokens={getThemeTokens}
118
+ dataSet={dataSet}
119
+ onPress={onPress}
120
+ {...selectProps(rest)}
121
+ >
122
+ {interactiveCard?.body}
123
+ </PressableCardBase>
124
+ ) : null}
122
125
  <StackView
123
126
  direction={contentStackDirection}
124
127
  tokens={{ ...columnFlex, alignItems: contentStackAlign }}
125
128
  space={0}
126
129
  >
127
- <CardContent tokens={tokens} variant={variant} withFooter={hasFooter}>
128
- {children}
129
- </CardContent>
130
+ {children ? (
131
+ <CardContent tokens={tokens} variant={variant} withFooter={hasFooter}>
132
+ {children}
133
+ </CardContent>
134
+ ) : null}
130
135
  {fullBleedContentPosition !== 'none' && (
131
136
  <FullBleedContent borderRadius={fullBleedBorderRadius} {...fullBleedContentProps} />
132
137
  )}
@@ -184,7 +189,20 @@ Card.propTypes = {
184
189
  /**
185
190
  * Card variant.
186
191
  */
187
- variant: variantProp.propType
192
+ variant: variantProp.propType,
193
+ /**
194
+ * Function to call on pressing the card.
195
+ * Note: This is only available when `interactive` variant is used.
196
+ */
197
+ onPress: PropTypes.func,
198
+ /**
199
+ * Object to set interactive card's properties
200
+ */
201
+ interactiveCard: PropTypes.shape({
202
+ body: PropTypes.node,
203
+ tokens: getTokensPropType('Card'),
204
+ variant: variantProp.propType
205
+ })
188
206
  }
189
207
 
190
208
  export default Card
@@ -93,7 +93,7 @@ const WaffleGrid = ({
93
93
  <Center>
94
94
  {typeof child.image === 'string' ? (
95
95
  // Assuming that string passed is the image URL
96
- <Image src={child.image} alt={child.imageAltText} width={96} height={128} />
96
+ <Image src={child.image} alt={child.imageAltText} width={96} />
97
97
  ) : (
98
98
  // Otherwise it must be an arbitrary content, which we just display by itself
99
99
  child.image
@@ -1,4 +1,5 @@
1
1
  import type { ComponentType } from 'react'
2
+ import type { Tokens } from './common'
2
3
 
3
4
  interface MultiSelectFilterItem {
4
5
  label: string
@@ -10,7 +11,7 @@ export interface MultiSelectFilterProps {
10
11
  subtitle?: string
11
12
  id?: string
12
13
  variant?: string
13
- tokens?: []
14
+ tokens?: Tokens
14
15
  items: MultiSelectFilterItem[]
15
16
  values?: string[]
16
17
  initialValues?: string[]
@@ -10,6 +10,9 @@ export interface WebVideoProps extends HTMLAttrs {
10
10
  videoLength: number
11
11
  copy?: 'en' | 'fr'
12
12
  onStart?: () => void
13
+ onPlay?: () => void
14
+ onEnd?: () => void
15
+ onPause?: () => void
13
16
  }
14
17
 
15
18
  declare const WebVideo: ComponentType<WebVideoProps>