@telus-uds/components-web 2.9.0 → 2.11.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 (90) hide show
  1. package/CHANGELOG.md +28 -2
  2. package/component-docs.json +94 -81
  3. package/lib/BlockQuote/BlockQuote.js +53 -5
  4. package/lib/Callout/Callout.js +12 -0
  5. package/lib/DatePicker/CalendarContainer.js +24 -0
  6. package/lib/DatePicker/DatePicker.js +26 -9
  7. package/lib/Disclaimer/Disclaimer.js +0 -4
  8. package/lib/ExpandCollapseMini/ExpandCollapseMini.js +4 -0
  9. package/lib/ExpandCollapseMini/ExpandCollapseMiniControl.js +16 -0
  10. package/lib/IconButton/IconButton.js +8 -0
  11. package/lib/Listbox/GroupControl.js +44 -28
  12. package/lib/Listbox/Listbox.js +62 -47
  13. package/lib/Listbox/ListboxGroup.js +36 -20
  14. package/lib/Listbox/ListboxItem.js +14 -51
  15. package/lib/Listbox/ListboxOverlay.js +1 -1
  16. package/lib/NavigationBar/NavigationBar.js +4 -0
  17. package/lib/OrderedList/Item.js +4 -0
  18. package/lib/Paragraph/Paragraph.js +4 -0
  19. package/lib/PreviewCard/AuthorDate.js +7 -0
  20. package/lib/PriceLockup/PriceLockup.js +48 -0
  21. package/lib/QuantitySelector/QuantitySelector.js +51 -0
  22. package/lib/Span/Span.js +4 -0
  23. package/lib/Table/Table.js +4 -0
  24. package/lib/Toast/Toast.js +16 -0
  25. package/lib/Video/ControlBar/ControlBar.js +13 -10
  26. package/lib/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.js +4 -1
  27. package/lib/VideoPicker/VideoPicker.js +1 -1
  28. package/lib/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.js +14 -2
  29. package/lib/utils/index.js +3 -3
  30. package/lib-module/BlockQuote/BlockQuote.js +54 -6
  31. package/lib-module/Callout/Callout.js +12 -0
  32. package/lib-module/DatePicker/CalendarContainer.js +24 -0
  33. package/lib-module/DatePicker/DatePicker.js +26 -9
  34. package/lib-module/Disclaimer/Disclaimer.js +0 -4
  35. package/lib-module/ExpandCollapseMini/ExpandCollapseMini.js +4 -0
  36. package/lib-module/ExpandCollapseMini/ExpandCollapseMiniControl.js +16 -0
  37. package/lib-module/IconButton/IconButton.js +8 -0
  38. package/lib-module/Listbox/GroupControl.js +45 -29
  39. package/lib-module/Listbox/Listbox.js +62 -46
  40. package/lib-module/Listbox/ListboxGroup.js +37 -21
  41. package/lib-module/Listbox/ListboxItem.js +15 -51
  42. package/lib-module/Listbox/ListboxOverlay.js +1 -1
  43. package/lib-module/NavigationBar/NavigationBar.js +4 -0
  44. package/lib-module/OrderedList/Item.js +4 -0
  45. package/lib-module/Paragraph/Paragraph.js +4 -0
  46. package/lib-module/PreviewCard/AuthorDate.js +7 -0
  47. package/lib-module/PriceLockup/PriceLockup.js +48 -0
  48. package/lib-module/QuantitySelector/QuantitySelector.js +51 -0
  49. package/lib-module/Span/Span.js +4 -0
  50. package/lib-module/Table/Table.js +4 -0
  51. package/lib-module/Toast/Toast.js +16 -0
  52. package/lib-module/Video/ControlBar/ControlBar.js +14 -11
  53. package/lib-module/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.js +4 -1
  54. package/lib-module/VideoPicker/VideoPicker.js +1 -1
  55. package/lib-module/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.js +14 -2
  56. package/lib-module/utils/index.js +1 -1
  57. package/package.json +3 -3
  58. package/src/BlockQuote/BlockQuote.jsx +66 -7
  59. package/src/Callout/Callout.jsx +9 -0
  60. package/src/DatePicker/CalendarContainer.jsx +24 -0
  61. package/src/DatePicker/DatePicker.jsx +25 -9
  62. package/src/Disclaimer/Disclaimer.jsx +0 -3
  63. package/src/ExpandCollapseMini/ExpandCollapseMini.jsx +3 -0
  64. package/src/ExpandCollapseMini/ExpandCollapseMiniControl.jsx +12 -0
  65. package/src/IconButton/IconButton.jsx +6 -0
  66. package/src/Listbox/GroupControl.jsx +50 -33
  67. package/src/Listbox/Listbox.jsx +65 -50
  68. package/src/Listbox/ListboxGroup.jsx +34 -19
  69. package/src/Listbox/ListboxItem.jsx +26 -48
  70. package/src/Listbox/ListboxOverlay.jsx +1 -1
  71. package/src/NavigationBar/NavigationBar.jsx +3 -0
  72. package/src/OrderedList/Item.jsx +3 -0
  73. package/src/Paragraph/Paragraph.jsx +3 -0
  74. package/src/PreviewCard/AuthorDate.jsx +6 -0
  75. package/src/PriceLockup/PriceLockup.jsx +37 -0
  76. package/src/QuantitySelector/QuantitySelector.jsx +39 -0
  77. package/src/Span/Span.jsx +3 -0
  78. package/src/Table/Table.jsx +3 -0
  79. package/src/Toast/Toast.jsx +12 -0
  80. package/src/Video/ControlBar/ControlBar.jsx +17 -13
  81. package/src/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.jsx +2 -1
  82. package/src/VideoPicker/VideoPicker.jsx +1 -1
  83. package/src/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.jsx +8 -1
  84. package/src/utils/index.js +1 -1
  85. package/lib/Listbox/PressableItem.js +0 -149
  86. package/lib/utils/htmlAttrs.js +0 -33
  87. package/lib-module/Listbox/PressableItem.js +0 -128
  88. package/lib-module/utils/htmlAttrs.js +0 -22
  89. package/src/Listbox/PressableItem.jsx +0 -121
  90. package/src/utils/htmlAttrs.js +0 -29
@@ -156,9 +156,21 @@ const Toast = ({ toast, copy, headline, link, tokens, variant = {}, ...rest }) =
156
156
 
157
157
  Toast.propTypes = {
158
158
  ...selectedSystemPropTypes,
159
+ /**
160
+ * If true, the toast will be displayed
161
+ */
159
162
  toast: PropTypes.bool,
163
+ /**
164
+ * The copy to display in the toast
165
+ */
160
166
  copy: PropTypes.string.isRequired,
167
+ /**
168
+ * The headline to display in the toast (before copy)
169
+ */
161
170
  headline: PropTypes.string,
171
+ /**
172
+ * The link to display in the toast (after copy)
173
+ */
162
174
  link: PropTypes.shape({
163
175
  href: PropTypes.string.isRequired,
164
176
  text: PropTypes.string.isRequired,
@@ -2,7 +2,13 @@ import React from 'react'
2
2
  import PropTypes from 'prop-types'
3
3
  import styled from 'styled-components'
4
4
 
5
- import { StackView, useThemeTokens, selectSystemProps, Icon } from '@telus-uds/components-base'
5
+ import {
6
+ StackView,
7
+ useThemeTokens,
8
+ selectSystemProps,
9
+ Icon,
10
+ useViewport
11
+ } from '@telus-uds/components-base'
6
12
 
7
13
  import VideoProgressBar from './Controls/VideoProgressBar/VideoProgressBar'
8
14
  import VolumeSlider from './Controls/VolumeSlider/VolumeSlider'
@@ -24,11 +30,11 @@ const ControlBarContainer = styled.div(({ isHidden, isMobile }) => ({
24
30
  display: isMobile ? 'none' : undefined
25
31
  }))
26
32
 
27
- const StyledControlBar = styled.div(({ padding }) => ({
33
+ const StyledControlBar = styled.div(({ padding, height }) => ({
28
34
  boxSizing: 'border-box',
29
35
  position: 'absolute',
30
36
  width: '100%',
31
- height: 56,
37
+ height,
32
38
  padding,
33
39
  bottom: 0,
34
40
  backgroundColor: 'rgba(42, 44, 46, 0.85)', // TODO: replace with opaque greyThunder
@@ -89,21 +95,21 @@ const ControlBar = ({
89
95
  variant,
90
96
  ...rest
91
97
  }) => {
98
+ const viewport = useViewport()
92
99
  const {
93
100
  paddingTop,
94
101
  paddingBottom,
95
- paddingLeft: paddingLeftDefault,
96
- paddingRight: paddingRightDefault,
97
- paddingLeftCompactMode,
98
- paddingRightCompactMode,
102
+ paddingLeft,
103
+ paddingRight,
99
104
  menuBottom,
100
105
  menuRight,
101
106
  menuMarginLeft,
102
107
  captionsIcon,
103
108
  settingsIcon,
104
109
  minimizeIcon,
105
- maximizeIcon
106
- } = useThemeTokens('VideoControlBar', tokens, variant)
110
+ maximizeIcon,
111
+ height
112
+ } = useThemeTokens('VideoControlBar', tokens, variant, { viewport })
107
113
 
108
114
  const parseVideoQuality = () => {
109
115
  return sources.map((source) => {
@@ -122,21 +128,19 @@ const ControlBar = ({
122
128
  return parsed
123
129
  }
124
130
 
125
- const paddingLeft =
126
- videoPlayerWidth > compactModeThreshold ? paddingLeftDefault : paddingLeftCompactMode
127
- const paddingRight =
128
- videoPlayerWidth > compactModeThreshold ? paddingRightDefault : paddingRightCompactMode
129
131
  const menuContainerStyleProps = { menuBottom, menuRight, menuMarginLeft }
130
132
 
131
133
  return (
132
134
  <ControlBarContainer isHidden={isHidden} isMobile={isMobile} {...selectProps(rest)}>
133
135
  <StyledControlBar
134
136
  padding={`${paddingTop}px ${paddingRight}px ${paddingBottom}px ${paddingLeft}px`}
137
+ height={`${height}px`}
135
138
  >
136
139
  <VideoProgressBarContainer>
137
140
  <VideoProgressBar
138
141
  copy={copy}
139
142
  videoPlayer={videoPlayer}
143
+ playing={videoPlaying}
140
144
  videoLength={videoLength}
141
145
  videoCurrentTime={videoCurrentTime}
142
146
  videoBufferEnd={videoBufferEnd}
@@ -106,6 +106,7 @@ const VideoProgressBar = ({
106
106
  videoLength,
107
107
  videoCurrentTime,
108
108
  videoBufferEnd,
109
+ playing,
109
110
  setSeek,
110
111
  resetInactivityTimer,
111
112
  tokens,
@@ -121,7 +122,7 @@ const VideoProgressBar = ({
121
122
  trackGradientStart,
122
123
  trackGradientEnd,
123
124
  rangeBackground
124
- } = useThemeTokens('VideoProgressBar', tokens, variant)
125
+ } = useThemeTokens('VideoProgressBar', tokens, variant, { playing })
125
126
 
126
127
  const videoProgressBar = React.createRef()
127
128
 
@@ -85,7 +85,7 @@ const VideoPicker = ({
85
85
  }, [selectedVideo])
86
86
 
87
87
  // `frame` variant should only work on larger screens
88
- const isFramed = frame && [viewports.md, viewports.lg, viewports.xl].includes(viewport)
88
+ const isFramed = frame && [viewports.lg, viewports.xl].includes(viewport)
89
89
 
90
90
  const hasSlider = !frame && [viewports.md, viewports.lg, viewports.xl].includes(viewport)
91
91
 
@@ -77,6 +77,11 @@ const selectButtonContentTokens = ({
77
77
  buttonPaddingRight
78
78
  })
79
79
 
80
+ const getLabelTokens = ({ labelFontName: fontName, labelFontWeight: fontWeight }) => ({
81
+ fontName,
82
+ fontWeight
83
+ })
84
+
80
85
  const SplashButtonWithDetails = ({ label, tokens, variant, copy, videoLength }) => {
81
86
  const { buttonContentChildrenBackground } = useThemeTokens(
82
87
  'SplashButtonWithDetails',
@@ -102,7 +107,9 @@ const SplashButtonWithDetails = ({ label, tokens, variant, copy, videoLength })
102
107
  <PlayIcon size={13} color={playIconColor} />
103
108
  </PlayIconContainer>
104
109
  <DetailsContainer {...selectDetailsContainerTokens(themeTokens)}>
105
- <Typography variant={{ bold: true }}>{label}</Typography>
110
+ <Typography variant={{ bold: true }} tokens={getLabelTokens(themeTokens)}>
111
+ {label}
112
+ </Typography>
106
113
  <Typography
107
114
  variant={{
108
115
  colour: 'secondary' /* TODO: this is not the same color as in designs */,
@@ -1,7 +1,7 @@
1
+ import { htmlAttrs } from '@telus-uds/components-base'
1
2
  import { warn, deprecate } from './logger'
2
3
  import { transformGradient } from './transforms'
3
4
  import useTypographyTheme from './useTypographyTheme'
4
- import htmlAttrs from './htmlAttrs'
5
5
  import media from './media'
6
6
  import ssrStyles from './ssr'
7
7
  import renderStructuredContent from './renderStructuredContent'
@@ -1,149 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _react = _interopRequireWildcard(require("react"));
9
-
10
- var _propTypes = _interopRequireDefault(require("prop-types"));
11
-
12
- var _componentsBase = require("@telus-uds/components-base");
13
-
14
- var _styledComponents = _interopRequireDefault(require("styled-components"));
15
-
16
- var _utils = require("../utils");
17
-
18
- var _jsxRuntime = require("react/jsx-runtime");
19
-
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
22
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
-
24
- 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; }
25
-
26
- /* eslint-disable react/require-default-props */
27
- const [selectProps, selectedSystemPropTypes] = (0, _componentsBase.selectSystemProps)([_utils.htmlAttrs]);
28
-
29
- const getItemStyles = _ref => {
30
- let {
31
- tokens
32
- } = _ref;
33
- return {
34
- fontFamily: `${tokens.groupFontName}${tokens.groupFontWeight}normal`,
35
- fontSize: tokens.itemFontSize,
36
- paddingTop: tokens.itemPaddingTop,
37
- paddingBottom: tokens.itemPaddingBottom,
38
- paddingLeft: tokens.itemPaddingLeft,
39
- paddingRight: tokens.itemPaddingRight,
40
- borderWidth: tokens.itemBorderWidth,
41
- width: '100%',
42
- backgroundColor: tokens.itemBackgroundColor,
43
- color: tokens.groupColor,
44
- display: tokens.itemDisplay,
45
- outline: tokens.itemOutline,
46
- textDecoration: tokens.itemTextDecoration
47
- };
48
- };
49
-
50
- const StyledLink = /*#__PURE__*/_styledComponents.default.a.withConfig({
51
- displayName: "PressableItem__StyledLink",
52
- componentId: "components-web__sc-1h6cvsc-0"
53
- })(_ref2 => {
54
- let {
55
- isChild,
56
- tokens
57
- } = _ref2;
58
- return { ...getItemStyles({
59
- isChild,
60
- tokens
61
- }),
62
- borderLeft: isChild ? `${tokens.itemBorderWidth}px solid ${tokens.itemBorderBackgroundColor}` : 'none',
63
- cursor: 'pointer',
64
- [`&:hover, &:focus, &:active`]: {
65
- color: tokens.itemColor
66
- },
67
- '&:hover': {
68
- backgroundColor: tokens.groupBackgroundColor
69
- },
70
- // Highlighting for pressable items that are not links per se
71
- // TODO: find a better way to display and style a pressable link
72
- '&:hover > div, &:hover > div > span': {
73
- color: `${tokens.itemColor} !important`
74
- },
75
- '&:focus': {
76
- border: `${tokens.groupBorderWidth}px solid ${tokens.itemBorderLeftColor}`,
77
- borderLeft: isChild && `${tokens.itemBorderWidth}px solid ${tokens.itemBorderLeftColor}`,
78
- borderRadius: !isChild && tokens.groupBorderRadius,
79
- paddingLeft: !isChild && `calc(${tokens.itemPaddingLeft}px - ${tokens.groupBorderWidth}px)`,
80
- paddingRight: `calc(${tokens.itemPaddingRight}px - ${tokens.groupBorderWidth}px)`,
81
- paddingTop: `calc(${tokens.itemPaddingTop}px - ${tokens.groupBorderWidth}px)`,
82
- paddingBottom: `calc(${tokens.itemPaddingBottom}px - ${tokens.groupBorderWidth}px)`,
83
- backgroundColor: tokens.groupBackgroundColor
84
- },
85
- '&:active': {
86
- backgroundColor: tokens.itemBorderBackgroundColor
87
- }
88
- };
89
- });
90
-
91
- const PressableItem = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) => {
92
- let {
93
- children,
94
- href,
95
- isChild = false,
96
- onBlur,
97
- onPress,
98
- tabIndex = 0,
99
- nextItemRef,
100
- prevItemRef,
101
- tokens,
102
- variant = {},
103
- ...rest
104
- } = _ref3;
105
-
106
- const handleKeyPress = event => {
107
- if (['Enter', ' '].includes(event === null || event === void 0 ? void 0 : event.key)) {
108
- onPress === null || onPress === void 0 ? void 0 : onPress(event);
109
- } else if ((event === null || event === void 0 ? void 0 : event.key) === 'ArrowDown' && nextItemRef !== null && nextItemRef !== void 0 && nextItemRef.current) {
110
- nextItemRef.current.focus();
111
- } else if ((event === null || event === void 0 ? void 0 : event.key) === 'ArrowUp' && prevItemRef !== null && prevItemRef !== void 0 && prevItemRef.current) {
112
- prevItemRef.current.focus();
113
- }
114
- };
115
-
116
- const systemTokens = (0, _componentsBase.useThemeTokens)('ListBox', tokens, variant, {
117
- isChild,
118
- hover: true
119
- });
120
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledLink, {
121
- isChild: isChild,
122
- tokens: systemTokens,
123
- onBlur: onBlur,
124
- onClick: onPress,
125
- onKeyPress: handleKeyPress,
126
- ref: ref,
127
- tabIndex: tabIndex,
128
- ...(href && {
129
- href
130
- }),
131
- ...(onPress && {
132
- onClick: onPress
133
- }),
134
- ...selectProps(rest),
135
- children: children
136
- });
137
- });
138
- PressableItem.displayName = 'PressableItem';
139
- PressableItem.propTypes = { ...selectedSystemPropTypes,
140
- href: _propTypes.default.string,
141
- isChild: _propTypes.default.bool,
142
- children: _propTypes.default.node.isRequired,
143
- onBlur: _propTypes.default.func,
144
- onPress: _propTypes.default.func,
145
- nextItemRef: _propTypes.default.object,
146
- prevItemRef: _propTypes.default.object
147
- };
148
- var _default = PressableItem;
149
- exports.default = _default;
@@ -1,33 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _propTypes = _interopRequireDefault(require("prop-types"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
- const htmlAttrTypes = {
13
- dataSet: _propTypes.default.object,
14
- id: _propTypes.default.string,
15
- loading: _propTypes.default.oneOf(['eager', 'lazy']),
16
- // @todo figure out if we need to enum all the possible roles or maybe use
17
- // an npm package
18
- role: _propTypes.default.string,
19
- src: _propTypes.default.string,
20
- tabIndex: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
21
- testID: _propTypes.default.string,
22
- title: _propTypes.default.string
23
- };
24
- var _default = {
25
- types: htmlAttrTypes,
26
- select: props => Object.entries(props).reduce((items, _ref) => {
27
- let [key, value] = _ref;
28
- return Object.keys(htmlAttrTypes).includes(key) || /^(data|aria)-/.test(key) ? { ...items,
29
- [key]: value
30
- } : items;
31
- }, {})
32
- };
33
- exports.default = _default;
@@ -1,128 +0,0 @@
1
- /* eslint-disable react/require-default-props */
2
- import React, { forwardRef } from 'react';
3
- import PropTypes from 'prop-types';
4
- import { selectSystemProps, useThemeTokens } from '@telus-uds/components-base';
5
- import styled from 'styled-components';
6
- import { htmlAttrs } from '../utils';
7
- import { jsx as _jsx } from "react/jsx-runtime";
8
- const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs]);
9
-
10
- const getItemStyles = _ref => {
11
- let {
12
- tokens
13
- } = _ref;
14
- return {
15
- fontFamily: `${tokens.groupFontName}${tokens.groupFontWeight}normal`,
16
- fontSize: tokens.itemFontSize,
17
- paddingTop: tokens.itemPaddingTop,
18
- paddingBottom: tokens.itemPaddingBottom,
19
- paddingLeft: tokens.itemPaddingLeft,
20
- paddingRight: tokens.itemPaddingRight,
21
- borderWidth: tokens.itemBorderWidth,
22
- width: '100%',
23
- backgroundColor: tokens.itemBackgroundColor,
24
- color: tokens.groupColor,
25
- display: tokens.itemDisplay,
26
- outline: tokens.itemOutline,
27
- textDecoration: tokens.itemTextDecoration
28
- };
29
- };
30
-
31
- const StyledLink = /*#__PURE__*/styled.a.withConfig({
32
- displayName: "PressableItem__StyledLink",
33
- componentId: "components-web__sc-1h6cvsc-0"
34
- })(_ref2 => {
35
- let {
36
- isChild,
37
- tokens
38
- } = _ref2;
39
- return { ...getItemStyles({
40
- isChild,
41
- tokens
42
- }),
43
- borderLeft: isChild ? `${tokens.itemBorderWidth}px solid ${tokens.itemBorderBackgroundColor}` : 'none',
44
- cursor: 'pointer',
45
- [`&:hover, &:focus, &:active`]: {
46
- color: tokens.itemColor
47
- },
48
- '&:hover': {
49
- backgroundColor: tokens.groupBackgroundColor
50
- },
51
- // Highlighting for pressable items that are not links per se
52
- // TODO: find a better way to display and style a pressable link
53
- '&:hover > div, &:hover > div > span': {
54
- color: `${tokens.itemColor} !important`
55
- },
56
- '&:focus': {
57
- border: `${tokens.groupBorderWidth}px solid ${tokens.itemBorderLeftColor}`,
58
- borderLeft: isChild && `${tokens.itemBorderWidth}px solid ${tokens.itemBorderLeftColor}`,
59
- borderRadius: !isChild && tokens.groupBorderRadius,
60
- paddingLeft: !isChild && `calc(${tokens.itemPaddingLeft}px - ${tokens.groupBorderWidth}px)`,
61
- paddingRight: `calc(${tokens.itemPaddingRight}px - ${tokens.groupBorderWidth}px)`,
62
- paddingTop: `calc(${tokens.itemPaddingTop}px - ${tokens.groupBorderWidth}px)`,
63
- paddingBottom: `calc(${tokens.itemPaddingBottom}px - ${tokens.groupBorderWidth}px)`,
64
- backgroundColor: tokens.groupBackgroundColor
65
- },
66
- '&:active': {
67
- backgroundColor: tokens.itemBorderBackgroundColor
68
- }
69
- };
70
- });
71
- const PressableItem = /*#__PURE__*/forwardRef((_ref3, ref) => {
72
- let {
73
- children,
74
- href,
75
- isChild = false,
76
- onBlur,
77
- onPress,
78
- tabIndex = 0,
79
- nextItemRef,
80
- prevItemRef,
81
- tokens,
82
- variant = {},
83
- ...rest
84
- } = _ref3;
85
-
86
- const handleKeyPress = event => {
87
- if (['Enter', ' '].includes(event === null || event === void 0 ? void 0 : event.key)) {
88
- onPress === null || onPress === void 0 ? void 0 : onPress(event);
89
- } else if ((event === null || event === void 0 ? void 0 : event.key) === 'ArrowDown' && nextItemRef !== null && nextItemRef !== void 0 && nextItemRef.current) {
90
- nextItemRef.current.focus();
91
- } else if ((event === null || event === void 0 ? void 0 : event.key) === 'ArrowUp' && prevItemRef !== null && prevItemRef !== void 0 && prevItemRef.current) {
92
- prevItemRef.current.focus();
93
- }
94
- };
95
-
96
- const systemTokens = useThemeTokens('ListBox', tokens, variant, {
97
- isChild,
98
- hover: true
99
- });
100
- return /*#__PURE__*/_jsx(StyledLink, {
101
- isChild: isChild,
102
- tokens: systemTokens,
103
- onBlur: onBlur,
104
- onClick: onPress,
105
- onKeyPress: handleKeyPress,
106
- ref: ref,
107
- tabIndex: tabIndex,
108
- ...(href && {
109
- href
110
- }),
111
- ...(onPress && {
112
- onClick: onPress
113
- }),
114
- ...selectProps(rest),
115
- children: children
116
- });
117
- });
118
- PressableItem.displayName = 'PressableItem';
119
- PressableItem.propTypes = { ...selectedSystemPropTypes,
120
- href: PropTypes.string,
121
- isChild: PropTypes.bool,
122
- children: PropTypes.node.isRequired,
123
- onBlur: PropTypes.func,
124
- onPress: PropTypes.func,
125
- nextItemRef: PropTypes.object,
126
- prevItemRef: PropTypes.object
127
- };
128
- export default PressableItem;
@@ -1,22 +0,0 @@
1
- import PropTypes from 'prop-types';
2
- const htmlAttrTypes = {
3
- dataSet: PropTypes.object,
4
- id: PropTypes.string,
5
- loading: PropTypes.oneOf(['eager', 'lazy']),
6
- // @todo figure out if we need to enum all the possible roles or maybe use
7
- // an npm package
8
- role: PropTypes.string,
9
- src: PropTypes.string,
10
- tabIndex: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
11
- testID: PropTypes.string,
12
- title: PropTypes.string
13
- };
14
- export default {
15
- types: htmlAttrTypes,
16
- select: props => Object.entries(props).reduce((items, _ref) => {
17
- let [key, value] = _ref;
18
- return Object.keys(htmlAttrTypes).includes(key) || /^(data|aria)-/.test(key) ? { ...items,
19
- [key]: value
20
- } : items;
21
- }, {})
22
- };
@@ -1,121 +0,0 @@
1
- /* eslint-disable react/require-default-props */
2
- import React, { forwardRef } from 'react'
3
- import PropTypes from 'prop-types'
4
- import { selectSystemProps, useThemeTokens } from '@telus-uds/components-base'
5
- import styled from 'styled-components'
6
- import { htmlAttrs } from '../utils'
7
-
8
- const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs])
9
-
10
- const getItemStyles = ({ tokens }) => ({
11
- fontFamily: `${tokens.groupFontName}${tokens.groupFontWeight}normal`,
12
- fontSize: tokens.itemFontSize,
13
- paddingTop: tokens.itemPaddingTop,
14
- paddingBottom: tokens.itemPaddingBottom,
15
- paddingLeft: tokens.itemPaddingLeft,
16
- paddingRight: tokens.itemPaddingRight,
17
- borderWidth: tokens.itemBorderWidth,
18
- width: '100%',
19
- backgroundColor: tokens.itemBackgroundColor,
20
- color: tokens.groupColor,
21
- display: tokens.itemDisplay,
22
- outline: tokens.itemOutline,
23
- textDecoration: tokens.itemTextDecoration
24
- })
25
-
26
- const StyledLink = styled.a(({ isChild, tokens }) => ({
27
- ...getItemStyles({ isChild, tokens }),
28
- borderLeft: isChild
29
- ? `${tokens.itemBorderWidth}px solid ${tokens.itemBorderBackgroundColor}`
30
- : 'none',
31
- cursor: 'pointer',
32
-
33
- [`&:hover, &:focus, &:active`]: {
34
- color: tokens.itemColor
35
- },
36
-
37
- '&:hover': {
38
- backgroundColor: tokens.groupBackgroundColor
39
- },
40
-
41
- // Highlighting for pressable items that are not links per se
42
- // TODO: find a better way to display and style a pressable link
43
- '&:hover > div, &:hover > div > span': {
44
- color: `${tokens.itemColor} !important`
45
- },
46
-
47
- '&:focus': {
48
- border: `${tokens.groupBorderWidth}px solid ${tokens.itemBorderLeftColor}`,
49
- borderLeft: isChild && `${tokens.itemBorderWidth}px solid ${tokens.itemBorderLeftColor}`,
50
- borderRadius: !isChild && tokens.groupBorderRadius,
51
- paddingLeft: !isChild && `calc(${tokens.itemPaddingLeft}px - ${tokens.groupBorderWidth}px)`,
52
- paddingRight: `calc(${tokens.itemPaddingRight}px - ${tokens.groupBorderWidth}px)`,
53
- paddingTop: `calc(${tokens.itemPaddingTop}px - ${tokens.groupBorderWidth}px)`,
54
- paddingBottom: `calc(${tokens.itemPaddingBottom}px - ${tokens.groupBorderWidth}px)`,
55
- backgroundColor: tokens.groupBackgroundColor
56
- },
57
-
58
- '&:active': {
59
- backgroundColor: tokens.itemBorderBackgroundColor
60
- }
61
- }))
62
-
63
- const PressableItem = forwardRef(
64
- (
65
- {
66
- children,
67
- href,
68
- isChild = false,
69
- onBlur,
70
- onPress,
71
- tabIndex = 0,
72
- nextItemRef,
73
- prevItemRef,
74
- tokens,
75
- variant = {},
76
- ...rest
77
- },
78
- ref
79
- ) => {
80
- const handleKeyPress = (event) => {
81
- if (['Enter', ' '].includes(event?.key)) {
82
- onPress?.(event)
83
- } else if (event?.key === 'ArrowDown' && nextItemRef?.current) {
84
- nextItemRef.current.focus()
85
- } else if (event?.key === 'ArrowUp' && prevItemRef?.current) {
86
- prevItemRef.current.focus()
87
- }
88
- }
89
- const systemTokens = useThemeTokens('ListBox', tokens, variant, { isChild, hover: true })
90
-
91
- return (
92
- <StyledLink
93
- isChild={isChild}
94
- tokens={systemTokens}
95
- onBlur={onBlur}
96
- onClick={onPress}
97
- onKeyPress={handleKeyPress}
98
- ref={ref}
99
- tabIndex={tabIndex}
100
- {...(href && { href })}
101
- {...(onPress && { onClick: onPress })}
102
- {...selectProps(rest)}
103
- >
104
- {children}
105
- </StyledLink>
106
- )
107
- }
108
- )
109
- PressableItem.displayName = 'PressableItem'
110
- PressableItem.propTypes = {
111
- ...selectedSystemPropTypes,
112
- href: PropTypes.string,
113
- isChild: PropTypes.bool,
114
- children: PropTypes.node.isRequired,
115
- onBlur: PropTypes.func,
116
- onPress: PropTypes.func,
117
- nextItemRef: PropTypes.object,
118
- prevItemRef: PropTypes.object
119
- }
120
-
121
- export default PressableItem
@@ -1,29 +0,0 @@
1
- import PropTypes from 'prop-types'
2
-
3
- const htmlAttrTypes = {
4
- dataSet: PropTypes.object,
5
- id: PropTypes.string,
6
- loading: PropTypes.oneOf(['eager', 'lazy']),
7
- // @todo figure out if we need to enum all the possible roles or maybe use
8
- // an npm package
9
- role: PropTypes.string,
10
- src: PropTypes.string,
11
- tabIndex: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
12
- testID: PropTypes.string,
13
- title: PropTypes.string
14
- }
15
-
16
- export default {
17
- types: htmlAttrTypes,
18
- select: (props) =>
19
- Object.entries(props).reduce(
20
- (items, [key, value]) =>
21
- Object.keys(htmlAttrTypes).includes(key) || /^(data|aria)-/.test(key)
22
- ? {
23
- ...items,
24
- [key]: value
25
- }
26
- : items,
27
- {}
28
- )
29
- }