@telus-uds/components-web 2.10.0 → 2.12.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 (60) hide show
  1. package/CHANGELOG.md +33 -2
  2. package/component-docs.json +76 -11
  3. package/lib/BlockQuote/BlockQuote.js +4 -1
  4. package/lib/Card/Card.js +2 -0
  5. package/lib/DatePicker/DatePicker.js +23 -12
  6. package/lib/ExpandCollapseMini/ExpandCollapseMini.js +5 -10
  7. package/lib/ExpandCollapseMini/ExpandCollapseMiniControl.js +32 -7
  8. package/lib/Footnote/FootnoteLink.js +1 -2
  9. package/lib/Listbox/GroupControl.js +44 -28
  10. package/lib/Listbox/Listbox.js +54 -47
  11. package/lib/Listbox/ListboxGroup.js +36 -20
  12. package/lib/Listbox/ListboxItem.js +14 -51
  13. package/lib/Listbox/ListboxOverlay.js +1 -1
  14. package/lib/PriceLockup/PriceLockup.js +6 -1
  15. package/lib/Video/ControlBar/ControlBar.js +13 -10
  16. package/lib/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.js +4 -1
  17. package/lib/VideoPicker/VideoPicker.js +1 -1
  18. package/lib/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.js +14 -2
  19. package/lib/utils/index.js +3 -3
  20. package/lib-module/BlockQuote/BlockQuote.js +4 -1
  21. package/lib-module/Card/Card.js +2 -0
  22. package/lib-module/DatePicker/DatePicker.js +23 -12
  23. package/lib-module/ExpandCollapseMini/ExpandCollapseMini.js +6 -11
  24. package/lib-module/ExpandCollapseMini/ExpandCollapseMiniControl.js +32 -7
  25. package/lib-module/Footnote/FootnoteLink.js +1 -2
  26. package/lib-module/Listbox/GroupControl.js +45 -29
  27. package/lib-module/Listbox/Listbox.js +54 -46
  28. package/lib-module/Listbox/ListboxGroup.js +37 -21
  29. package/lib-module/Listbox/ListboxItem.js +15 -51
  30. package/lib-module/Listbox/ListboxOverlay.js +1 -1
  31. package/lib-module/PriceLockup/PriceLockup.js +7 -2
  32. package/lib-module/Video/ControlBar/ControlBar.js +14 -11
  33. package/lib-module/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.js +4 -1
  34. package/lib-module/VideoPicker/VideoPicker.js +1 -1
  35. package/lib-module/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.js +14 -2
  36. package/lib-module/utils/index.js +1 -1
  37. package/package.json +3 -3
  38. package/src/BlockQuote/BlockQuote.jsx +13 -1
  39. package/src/Card/Card.jsx +12 -8
  40. package/src/DatePicker/DatePicker.jsx +22 -12
  41. package/src/ExpandCollapseMini/ExpandCollapseMini.jsx +9 -6
  42. package/src/ExpandCollapseMini/ExpandCollapseMiniControl.jsx +21 -4
  43. package/src/Footnote/FootnoteLink.jsx +1 -2
  44. package/src/Listbox/GroupControl.jsx +50 -33
  45. package/src/Listbox/Listbox.jsx +59 -50
  46. package/src/Listbox/ListboxGroup.jsx +34 -19
  47. package/src/Listbox/ListboxItem.jsx +26 -48
  48. package/src/Listbox/ListboxOverlay.jsx +1 -1
  49. package/src/PriceLockup/PriceLockup.jsx +7 -2
  50. package/src/Video/ControlBar/ControlBar.jsx +17 -13
  51. package/src/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.jsx +2 -1
  52. package/src/VideoPicker/VideoPicker.jsx +1 -1
  53. package/src/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.jsx +8 -1
  54. package/src/utils/index.js +1 -1
  55. package/lib/Listbox/PressableItem.js +0 -149
  56. package/lib/utils/htmlAttrs.js +0 -33
  57. package/lib-module/Listbox/PressableItem.js +0 -128
  58. package/lib-module/utils/htmlAttrs.js +0 -22
  59. package/src/Listbox/PressableItem.jsx +0 -121
  60. package/src/utils/htmlAttrs.js +0 -29
@@ -2,9 +2,13 @@
2
2
  import React, { forwardRef } from 'react'
3
3
  import PropTypes from 'prop-types'
4
4
  import styled from 'styled-components'
5
- import { selectSystemProps, withLinkRouter, useThemeTokens } from '@telus-uds/components-base'
5
+ import {
6
+ selectSystemProps,
7
+ withLinkRouter,
8
+ useThemeTokensCallback,
9
+ PressableItem
10
+ } from '@telus-uds/components-base'
6
11
  import { htmlAttrs } from '../utils'
7
- import PressableItem from './PressableItem'
8
12
 
9
13
  const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs])
10
14
 
@@ -17,36 +21,11 @@ const StyledItemContainer = styled.li({
17
21
  }
18
22
  })
19
23
 
20
- const getSelectedItemStyles = ({ tokens }) => ({
21
- display: tokens.itemDisplay,
22
- fontFamily: `${tokens.itemFontName}${tokens.itemFontWeight}normal`,
23
- fontSize: tokens.itemFontSize,
24
- paddingTop: tokens.itemPaddingTop,
25
- paddingBottom: tokens.itemPaddingBottom,
26
- paddingLeft: tokens.itemPaddingLeft,
27
- paddingRight: tokens.itemPaddingRight,
28
- color: tokens.itemColor,
29
- textDecoration: tokens.itemTextDecoration,
30
- backgroundColor: tokens.itemBackgroundColor,
31
- outline: tokens.itemOutline,
32
- borderWidth: tokens.itemBorderWidth,
33
- width: '100%'
34
- })
35
-
36
- const SelectedItem = styled.div(({ isChild, tokens }) => ({
37
- ...getSelectedItemStyles({ tokens }),
38
- borderLeft: isChild
39
- ? `${tokens.itemBorderLeftWidth}px solid ${tokens.itemBorderLeftColor}`
40
- : 'none'
41
- }))
42
-
43
24
  const ListboxItem = forwardRef(
44
25
  (
45
26
  {
46
27
  href,
47
28
  label,
48
- onPress,
49
- selected = false,
50
29
  isChild = false,
51
30
  onBlur,
52
31
  nextItemRef,
@@ -55,32 +34,32 @@ const ListboxItem = forwardRef(
55
34
  variant = {},
56
35
  LinkRouter,
57
36
  linkRouterProps,
37
+ id,
38
+ onPress = () => {},
39
+
58
40
  ...rest
59
41
  },
60
42
  ref
61
43
  ) => {
62
- const selectedProps = selectProps(rest)
63
- const systemTokens = useThemeTokens('ListBox', tokens, variant, { isChild })
44
+ const selectedProps = selectProps({ href, ...rest })
64
45
 
46
+ const getTokens = useThemeTokensCallback('Listbox', tokens, variant, { isChild })
65
47
  return (
66
48
  <StyledItemContainer isChild={isChild} {...selectedProps} role="option">
67
- {selected ? (
68
- <SelectedItem isChild={isChild} tokens={systemTokens}>
69
- {label}
70
- </SelectedItem>
71
- ) : (
72
- <PressableItem
73
- href={href}
74
- isChild={isChild}
75
- onPress={onPress}
76
- onBlur={onBlur}
77
- nextItemRef={nextItemRef}
78
- prevItemRef={prevItemRef}
79
- ref={ref}
80
- >
81
- {label}
82
- </PressableItem>
83
- )}
49
+ <PressableItem
50
+ href={href}
51
+ isChild={isChild}
52
+ onPress={onPress}
53
+ onBlur={onBlur}
54
+ nextItemRef={nextItemRef}
55
+ prevItemRef={prevItemRef}
56
+ ref={ref}
57
+ tokens={getTokens}
58
+ selectedProps={selectedProps}
59
+ id={id}
60
+ >
61
+ {label}
62
+ </PressableItem>
84
63
  </StyledItemContainer>
85
64
  )
86
65
  }
@@ -95,8 +74,7 @@ ListboxItem.propTypes = {
95
74
  label: PropTypes.node.isRequired,
96
75
  nextItemRef: PropTypes.object,
97
76
  prevItemRef: PropTypes.object,
98
- onPress: PropTypes.func,
99
- selected: PropTypes.bool
77
+ onPress: PropTypes.func
100
78
  }
101
79
 
102
80
  export default withLinkRouter(ListboxItem)
@@ -23,7 +23,7 @@ const paddingHorizontal = 0
23
23
 
24
24
  const DropdownOverlay = forwardRef(
25
25
  ({ children, isReady = false, overlaidPosition, maxWidth, minWidth, onLayout }, ref) => {
26
- const systemTokens = useThemeTokens('ListBox', {}, {})
26
+ const systemTokens = useThemeTokens('Listbox', {}, {})
27
27
 
28
28
  return (
29
29
  <WebPortal>
@@ -6,7 +6,8 @@ import {
6
6
  selectSystemProps,
7
7
  Typography,
8
8
  useThemeTokens,
9
- useViewport
9
+ useViewport,
10
+ getTokensPropType
10
11
  } from '@telus-uds/components-base'
11
12
  import styled from 'styled-components'
12
13
  import FootnoteLink from '../Footnote/FootnoteLink'
@@ -273,7 +274,11 @@ PriceLockup.propTypes = {
273
274
  *
274
275
  * **Note:** a11yText will override strikethrough price, so it must include price (ie. "was 50 dollars per month")
275
276
  */
276
- a11yText: PropTypes.string
277
+ a11yText: PropTypes.string,
278
+ /**
279
+ * `PriceLockup` tokens
280
+ */
281
+ tokens: getTokensPropType('PriceLockup')
277
282
  }
278
283
 
279
284
  export default PriceLockup
@@ -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
- };