@telus-uds/components-base 1.94.0 → 1.96.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 (68) hide show
  1. package/CHANGELOG.md +41 -2
  2. package/lib/Autocomplete/Autocomplete.js +38 -3
  3. package/lib/Card/CardBase.js +4 -0
  4. package/lib/DownloadApp/DownloadApp.js +168 -0
  5. package/lib/DownloadApp/dictionary.js +17 -0
  6. package/lib/DownloadApp/index.js +10 -0
  7. package/lib/Icon/IconText.js +19 -2
  8. package/lib/Link/LinkBase.js +2 -2
  9. package/lib/List/ListItemBase.js +2 -1
  10. package/lib/Modal/Modal.js +34 -13
  11. package/lib/Modal/ModalContent.js +1 -1
  12. package/lib/Modal/WebModal.js +1 -0
  13. package/lib/Notification/Notification.js +5 -5
  14. package/lib/PriceLockup/PriceLockup.js +11 -3
  15. package/lib/Progress/Progress.js +5 -2
  16. package/lib/Progress/ProgressBar.js +4 -1
  17. package/lib/TabBar/TabBar.js +133 -0
  18. package/lib/TabBar/TabBarItem.js +184 -0
  19. package/lib/TabBar/index.js +10 -0
  20. package/lib/TextInput/TextInputBase.js +2 -1
  21. package/lib/Tooltip/getTooltipPosition.js +8 -9
  22. package/lib/Typography/Typography.js +42 -19
  23. package/lib/index.js +23 -0
  24. package/lib-module/Autocomplete/Autocomplete.js +38 -3
  25. package/lib-module/Card/CardBase.js +4 -0
  26. package/lib-module/DownloadApp/DownloadApp.js +160 -0
  27. package/lib-module/DownloadApp/dictionary.js +10 -0
  28. package/lib-module/DownloadApp/index.js +2 -0
  29. package/lib-module/Icon/IconText.js +19 -2
  30. package/lib-module/Link/LinkBase.js +2 -2
  31. package/lib-module/List/ListItemBase.js +2 -1
  32. package/lib-module/Modal/Modal.js +34 -13
  33. package/lib-module/Modal/ModalContent.js +1 -1
  34. package/lib-module/Modal/WebModal.js +1 -0
  35. package/lib-module/Notification/Notification.js +5 -5
  36. package/lib-module/PriceLockup/PriceLockup.js +11 -3
  37. package/lib-module/Progress/Progress.js +6 -3
  38. package/lib-module/Progress/ProgressBar.js +5 -2
  39. package/lib-module/TabBar/TabBar.js +125 -0
  40. package/lib-module/TabBar/TabBarItem.js +177 -0
  41. package/lib-module/TabBar/index.js +2 -0
  42. package/lib-module/TextInput/TextInputBase.js +2 -1
  43. package/lib-module/Tooltip/getTooltipPosition.js +8 -9
  44. package/lib-module/Typography/Typography.js +42 -19
  45. package/lib-module/index.js +3 -1
  46. package/package.json +2 -2
  47. package/src/Autocomplete/Autocomplete.jsx +43 -3
  48. package/src/Card/CardBase.jsx +6 -0
  49. package/src/DownloadApp/DownloadApp.jsx +165 -0
  50. package/src/DownloadApp/dictionary.js +10 -0
  51. package/src/DownloadApp/index.js +3 -0
  52. package/src/Icon/IconText.jsx +21 -4
  53. package/src/Link/LinkBase.jsx +2 -2
  54. package/src/List/ListItemBase.jsx +1 -1
  55. package/src/Modal/Modal.jsx +40 -14
  56. package/src/Modal/ModalContent.jsx +1 -1
  57. package/src/Modal/WebModal.jsx +1 -1
  58. package/src/Notification/Notification.jsx +5 -5
  59. package/src/PriceLockup/PriceLockup.jsx +9 -1
  60. package/src/Progress/Progress.jsx +6 -3
  61. package/src/Progress/ProgressBar.jsx +4 -2
  62. package/src/TabBar/TabBar.jsx +123 -0
  63. package/src/TabBar/TabBarItem.jsx +149 -0
  64. package/src/TabBar/index.js +3 -0
  65. package/src/TextInput/TextInputBase.jsx +1 -1
  66. package/src/Tooltip/getTooltipPosition.js +11 -12
  67. package/src/Typography/Typography.jsx +37 -13
  68. package/src/index.js +4 -1
@@ -0,0 +1,160 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import Pressable from "react-native-web/dist/exports/Pressable";
4
+ import Platform from "react-native-web/dist/exports/Platform";
5
+ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
6
+ import { a11yProps, linkProps, hrefAttrsProp, viewProps, getTokensPropType, resolvePressableTokens, variantProp, copyPropTypes, selectSystemProps, useCopy } from '../utils';
7
+ import { useThemeTokensCallback } from '../ThemeProvider';
8
+ import defaultDictionary from './dictionary';
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, linkProps, viewProps]);
11
+ const selectOuterStyles = _ref => {
12
+ let {
13
+ borderColor,
14
+ borderWidth,
15
+ borderGap,
16
+ borderRadius,
17
+ padding
18
+ } = _ref;
19
+ return {
20
+ outline: 'none',
21
+ borderColor,
22
+ borderWidth,
23
+ borderGap,
24
+ borderRadius,
25
+ padding
26
+ };
27
+ };
28
+ const DownloadApp = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
29
+ let {
30
+ copy = 'en',
31
+ dictionary = defaultDictionary,
32
+ type = 'ios',
33
+ href,
34
+ onPress,
35
+ tokens = {},
36
+ variant = {},
37
+ ...props
38
+ } = _ref2;
39
+ const getCopy = useCopy({
40
+ dictionary,
41
+ copy
42
+ });
43
+ const {
44
+ hrefAttrs,
45
+ rest
46
+ } = hrefAttrsProp.bundle(props);
47
+ const selectedProps = selectProps({
48
+ accessibilityRole: href ? 'link' : 'button',
49
+ href,
50
+ onPress: linkProps.handleHref({
51
+ href,
52
+ onPress
53
+ }),
54
+ hrefAttrs,
55
+ ...rest
56
+ });
57
+ const getDownloadAppTokens = useThemeTokensCallback('DownloadApp', tokens, variant);
58
+ const resolveDownloadAppTokens = pressableState => {
59
+ const themeTokens = resolvePressableTokens(getDownloadAppTokens, pressableState, {});
60
+ return selectOuterStyles(themeTokens);
61
+ };
62
+ const {
63
+ androidENIcon,
64
+ androidFRIcon,
65
+ iosENIcon,
66
+ iosFRIcon
67
+ } = getDownloadAppTokens();
68
+ const imageResources = {
69
+ en: {
70
+ android: androidENIcon,
71
+ ios: iosENIcon
72
+ },
73
+ fr: {
74
+ android: androidFRIcon,
75
+ ios: iosFRIcon
76
+ }
77
+ };
78
+ const IconComponent = imageResources[copy][type];
79
+ return /*#__PURE__*/_jsx(Pressable, {
80
+ ref: ref,
81
+ style: pressState => [resolveDownloadAppTokens(pressState), staticStyles.row],
82
+ ...selectedProps,
83
+ children: /*#__PURE__*/_jsx(IconComponent, {
84
+ style: staticImageSizes[type][copy],
85
+ alt: type === 'ios' ? getCopy('altTextIos') : getCopy('altTextAndroid')
86
+ })
87
+ });
88
+ });
89
+ DownloadApp.displayName = 'DownloadApp';
90
+ const dictionaryContentShape = PropTypes.shape({
91
+ altTextAndroid: PropTypes.string.isRequired,
92
+ altTextIos: PropTypes.string.isRequired
93
+ });
94
+ DownloadApp.propTypes = {
95
+ ...selectedSystemPropTypes,
96
+ copy: copyPropTypes,
97
+ /**
98
+ * Override the default dictionary, by passing the complete dictionary object for `en` and `fr`
99
+ */
100
+ dictionary: PropTypes.shape({
101
+ en: dictionaryContentShape,
102
+ fr: dictionaryContentShape
103
+ }),
104
+ /**
105
+ * Select the type of image to show.
106
+ */
107
+ type: PropTypes.oneOf(['android', 'ios']),
108
+ /**
109
+ * It's a simple link that opens the Download Button instead of the onPress function.
110
+ */
111
+ href: PropTypes.string,
112
+ /**
113
+ * Function called when the button is pressed. Required unless the button has a href.
114
+ */
115
+ onPress: PropTypes.func,
116
+ /**
117
+ * DownloadApp tokens.
118
+ */
119
+ tokens: getTokensPropType('DownloadApp'),
120
+ /**
121
+ * DownloadApp variant.
122
+ */
123
+ variant: variantProp.propType
124
+ };
125
+ const staticStyles = StyleSheet.create({
126
+ row: {
127
+ ...Platform.select({
128
+ web: {
129
+ display: 'inline-flex',
130
+ width: 'fit-content'
131
+ },
132
+ default: {
133
+ alignSelf: 'flex-start'
134
+ }
135
+ })
136
+ }
137
+ });
138
+ const staticImageSizes = {
139
+ android: {
140
+ en: {
141
+ width: 162,
142
+ height: 48
143
+ },
144
+ fr: {
145
+ width: 162,
146
+ height: 48
147
+ }
148
+ },
149
+ ios: {
150
+ en: {
151
+ width: 144,
152
+ height: 48
153
+ },
154
+ fr: {
155
+ width: 152,
156
+ height: 48
157
+ }
158
+ }
159
+ };
160
+ export default DownloadApp;
@@ -0,0 +1,10 @@
1
+ export default {
2
+ en: {
3
+ altTextAndroid: 'Get it on Google Play',
4
+ altTextIos: 'Download on the App Store'
5
+ },
6
+ fr: {
7
+ altTextAndroid: 'Disponible sur Google Play',
8
+ altTextIos: 'Télécharger dans l’App Store'
9
+ }
10
+ };
@@ -0,0 +1,2 @@
1
+ import DownloadApp from './DownloadApp';
2
+ export default DownloadApp;
@@ -2,6 +2,8 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import Platform from "react-native-web/dist/exports/Platform";
4
4
  import View from "react-native-web/dist/exports/View";
5
+ import Text from "react-native-web/dist/exports/Text";
6
+ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
5
7
  import Icon, { iconComponentPropTypes } from './Icon';
6
8
  import { getStackedContent } from '../StackView';
7
9
  import { spacingProps } from '../utils';
@@ -15,6 +17,7 @@ import { spacingProps } from '../utils';
15
17
  * - within a container with `flexDirection: 'row'`
16
18
  */
17
19
  import { jsx as _jsx } from "react/jsx-runtime";
20
+ import { jsxs as _jsxs } from "react/jsx-runtime";
18
21
  const IconText = /*#__PURE__*/React.forwardRef((_ref, ref) => {
19
22
  var _iconProps$tokens, _iconProps$tokens2;
20
23
  let {
@@ -59,6 +62,15 @@ const IconText = /*#__PURE__*/React.forwardRef((_ref, ref) => {
59
62
  });
60
63
  const mobile = Platform.OS === 'android' ? iconAdjustedAndroid : iconAdjustedIOS;
61
64
  const adjustedContainer = Platform.OS === 'web' ? iconContent : mobile;
65
+ const adjustedContainerWithPosition = /*#__PURE__*/_jsx(View, {
66
+ style: staticStyles.adjustedContainer,
67
+ children: adjustedContainer
68
+ });
69
+ if (iconPosition === 'inline') {
70
+ return /*#__PURE__*/_jsxs(Text, {
71
+ children: [children, " ", adjustedContainerWithPosition]
72
+ });
73
+ }
62
74
  return getStackedContent(iconPosition === 'left' ? [adjustedContainer, children] : [children, adjustedContainer], {
63
75
  space,
64
76
  direction: 'row'
@@ -73,9 +85,9 @@ IconText.propTypes = {
73
85
  */
74
86
  space: spacingProps.types.spacingValue,
75
87
  /**
76
- * Whether the icon should be to the left of the content or the right of the content.
88
+ * Whether the icon should be to the left of the content, the right of the content or inline with the content.
77
89
  */
78
- iconPosition: PropTypes.oneOf(['left', 'right']),
90
+ iconPosition: PropTypes.oneOf(['left', 'right', 'inline']),
79
91
  /**
80
92
  * A valid UDS icon component imported from a UDS palette.
81
93
  */
@@ -94,4 +106,9 @@ IconText.propTypes = {
94
106
  /* eslint-enable react/no-unused-prop-types */
95
107
  };
96
108
 
109
+ const staticStyles = StyleSheet.create({
110
+ adjustedContainer: {
111
+ position: 'absolute'
112
+ }
113
+ });
97
114
  export default IconText;
@@ -238,9 +238,9 @@ LinkBase.propTypes = {
238
238
  */
239
239
  icon: PropTypes.elementType,
240
240
  /**
241
- * When `icon` is provided, use `iconPosition` to place the Icon to the left or right side of Link.
241
+ * When `icon` is provided, use `iconPosition` to place the Icon to the left, right or inline with Link.
242
242
  */
243
- iconPosition: PropTypes.oneOf(['left', 'right']),
243
+ iconPosition: PropTypes.oneOf(['left', 'right', 'inline']),
244
244
  /**
245
245
  * On Web if href is passed, React Native Web maps this object's props to
246
246
  * `rel`, `target` and `download` attrs.
@@ -129,7 +129,8 @@ const staticStyles = StyleSheet.create({
129
129
  },
130
130
  titleAndContentContainer: {
131
131
  flexDirection: 'column',
132
- flexShrink: 1
132
+ flexShrink: 1,
133
+ flexGrow: 1
133
134
  }
134
135
  });
135
136
  ListItemBase.propTypes = {
@@ -99,6 +99,7 @@ const selectScrollViewStyles = () => ({
99
99
  * - Don’t use modals consecutively
100
100
  */
101
101
  const Modal = /*#__PURE__*/React.forwardRef((_ref5, ref) => {
102
+ var _modalContentRef$curr2;
102
103
  let {
103
104
  children,
104
105
  isOpen,
@@ -127,6 +128,8 @@ const Modal = /*#__PURE__*/React.forwardRef((_ref5, ref) => {
127
128
  maxWidth
128
129
  });
129
130
  const modalRef = useScrollBlocking(isOpen);
131
+ const modalBodyRef = React.useRef(ref);
132
+ const modalContentRef = React.useRef(null);
130
133
  const {
131
134
  closeIcon: CloseIconComponent
132
135
  } = themeTokens;
@@ -141,6 +144,25 @@ const Modal = /*#__PURE__*/React.forwardRef((_ref5, ref) => {
141
144
  const handleKeyUp = event => {
142
145
  if (event.key === 'Escape') onClose();
143
146
  };
147
+ const manageFocus = React.useCallback(event => {
148
+ if (event.key === 'Tab') {
149
+ var _modalBodyRef$current;
150
+ const focusableElements = Array.from(modalBodyRef === null || modalBodyRef === void 0 ? void 0 : (_modalBodyRef$current = modalBodyRef.current) === null || _modalBodyRef$current === void 0 ? void 0 : _modalBodyRef$current.querySelectorAll(`
151
+ a[href], button, textarea, input, select,
152
+ [tabindex]:not([tabindex="-1"]),
153
+ [contenteditable="true"]
154
+ `));
155
+ const firstElement = focusableElements[0];
156
+ const lastElement = focusableElements[focusableElements.length - 1];
157
+ if (event.shiftKey && document.activeElement === firstElement) {
158
+ event.preventDefault();
159
+ lastElement.focus();
160
+ } else if (!event.shiftKey && document.activeElement === lastElement) {
161
+ event.preventDefault();
162
+ firstElement.focus();
163
+ }
164
+ }
165
+ }, [modalBodyRef]);
144
166
 
145
167
  // Show the custom react node passed to `closedButton` or the default close button if `closeButton` is `undefined`.
146
168
  // Hide the close button if `closeButton` is `null`.
@@ -151,22 +173,20 @@ const Modal = /*#__PURE__*/React.forwardRef((_ref5, ref) => {
151
173
  const closeButtonRef = React.useRef(null);
152
174
  React.useEffect(() => {
153
175
  if (Platform.OS === 'web') {
154
- const handleFocus = () => {
155
- // If the focus is on the last item of the web modal container, move it to the close button
156
- if (document.activeElement === focusTrapRef.current) {
157
- closeButtonRef.current.focus();
158
- }
159
- return undefined;
160
- };
161
-
162
- // Add an event listener to manage focus in the web modal container
163
- document.addEventListener('focusin', handleFocus);
176
+ // Add an event listener to manage keydown and focus in the web modal container
177
+ document.addEventListener('keydown', manageFocus);
164
178
 
165
179
  // Clean up the event listener
166
- return () => document.removeEventListener('focusin', handleFocus);
180
+ return () => document.removeEventListener('keydown', manageFocus);
167
181
  }
168
182
  return undefined;
169
- }, []);
183
+ }, [manageFocus]);
184
+ React.useEffect(() => {
185
+ if (isOpen) {
186
+ var _modalContentRef$curr;
187
+ modalContentRef === null || modalContentRef === void 0 ? void 0 : (_modalContentRef$curr = modalContentRef.current) === null || _modalContentRef$curr === void 0 ? void 0 : _modalContentRef$curr.focus();
188
+ }
189
+ }, [isOpen, modalContentRef === null || modalContentRef === void 0 ? void 0 : (_modalContentRef$curr2 = modalContentRef.current) === null || _modalContentRef$curr2 === void 0 ? void 0 : _modalContentRef$curr2.focus]);
170
190
  if (!isOpen) {
171
191
  return null;
172
192
  }
@@ -179,7 +199,7 @@ const Modal = /*#__PURE__*/React.forwardRef((_ref5, ref) => {
179
199
  pointerEvents: "box-none" // don't capture backdrop press events
180
200
  ,
181
201
  children: /*#__PURE__*/_jsxs(View, {
182
- ref: ref,
202
+ ref: modalBodyRef,
183
203
  style: [staticStyles.modal, selectModalStyles(themeTokens)],
184
204
  onKeyUp: handleKeyUp,
185
205
  children: [showCloseButton && /*#__PURE__*/_jsx(View, {
@@ -224,6 +244,7 @@ const Modal = /*#__PURE__*/React.forwardRef((_ref5, ref) => {
224
244
  if (Platform.OS === 'web') {
225
245
  return /*#__PURE__*/_jsxs(WebModal, {
226
246
  ...selectProps(rest),
247
+ ref: modalContentRef,
227
248
  children: [content, /*#__PURE__*/_jsx(View, {
228
249
  accessibilityRole: "button",
229
250
  ref: focusTrapRef
@@ -156,7 +156,7 @@ const styles = StyleSheet.create({
156
156
  minHeight: Platform.OS === 'web' ? '100%' : 'auto'
157
157
  },
158
158
  cancelButton: {
159
- flex: 1
159
+ display: 'flex'
160
160
  }
161
161
  });
162
162
  ModalContent.propTypes = {
@@ -24,6 +24,7 @@ const WebModal = /*#__PURE__*/React.forwardRef((_ref, ref) => {
24
24
  children: /*#__PURE__*/_jsx(View, {
25
25
  style: staticStyles.container,
26
26
  ...selectProps(rest),
27
+ focusable: true,
27
28
  ref: ref,
28
29
  children: /*#__PURE__*/_jsx("div", {
29
30
  style: staticStyles.content,
@@ -99,19 +99,19 @@ const getMediaQueryStyles = (themeTokens, themeOptions, mediaIdsRef, dismissible
99
99
  justifyContent: 'space-between',
100
100
  ...createMediaQueryStyles({
101
101
  xs: {
102
- width: (themeOptions === null || themeOptions === void 0 ? void 0 : (_themeOptions$content = themeOptions.contentMaxWidth) === null || _themeOptions$content === void 0 ? void 0 : _themeOptions$content.xs) || '100%'
102
+ maxWidth: (themeOptions === null || themeOptions === void 0 ? void 0 : (_themeOptions$content = themeOptions.contentMaxWidth) === null || _themeOptions$content === void 0 ? void 0 : _themeOptions$content.xs) || '100%'
103
103
  },
104
104
  md: {
105
- width: (themeOptions === null || themeOptions === void 0 ? void 0 : (_themeOptions$content2 = themeOptions.contentMaxWidth) === null || _themeOptions$content2 === void 0 ? void 0 : _themeOptions$content2.md) || '100%'
105
+ maxWidth: (themeOptions === null || themeOptions === void 0 ? void 0 : (_themeOptions$content2 = themeOptions.contentMaxWidth) === null || _themeOptions$content2 === void 0 ? void 0 : _themeOptions$content2.md) || '100%'
106
106
  },
107
107
  lg: {
108
- width: (themeOptions === null || themeOptions === void 0 ? void 0 : (_themeOptions$content3 = themeOptions.contentMaxWidth) === null || _themeOptions$content3 === void 0 ? void 0 : _themeOptions$content3.lg) || '100%'
108
+ maxWidth: (themeOptions === null || themeOptions === void 0 ? void 0 : (_themeOptions$content3 = themeOptions.contentMaxWidth) === null || _themeOptions$content3 === void 0 ? void 0 : _themeOptions$content3.lg) || '100%'
109
109
  },
110
110
  sm: {
111
- width: (themeOptions === null || themeOptions === void 0 ? void 0 : (_themeOptions$content4 = themeOptions.contentMaxWidth) === null || _themeOptions$content4 === void 0 ? void 0 : _themeOptions$content4.sm) || '100%'
111
+ maxWidth: (themeOptions === null || themeOptions === void 0 ? void 0 : (_themeOptions$content4 = themeOptions.contentMaxWidth) === null || _themeOptions$content4 === void 0 ? void 0 : _themeOptions$content4.sm) || '100%'
112
112
  },
113
113
  xl: {
114
- width: (themeOptions === null || themeOptions === void 0 ? void 0 : (_themeOptions$content5 = themeOptions.contentMaxWidth) === null || _themeOptions$content5 === void 0 ? void 0 : _themeOptions$content5.xl) || '100%'
114
+ maxWidth: (themeOptions === null || themeOptions === void 0 ? void 0 : (_themeOptions$content5 = themeOptions.contentMaxWidth) === null || _themeOptions$content5 === void 0 ? void 0 : _themeOptions$content5.xl) || '100%'
115
115
  }
116
116
  })
117
117
  }
@@ -87,7 +87,15 @@ const selectBottomTextTypographyTokens = _ref6 => {
87
87
  lineHeight: bottomTextLineHeight
88
88
  };
89
89
  };
90
- const PriceLockup = /*#__PURE__*/React.forwardRef((_ref7, ref) => {
90
+ const selectContainertokens = _ref7 => {
91
+ let {
92
+ alignItemsText
93
+ } = _ref7;
94
+ return {
95
+ alignItems: alignItemsText
96
+ };
97
+ };
98
+ const PriceLockup = /*#__PURE__*/React.forwardRef((_ref8, ref) => {
91
99
  let {
92
100
  size = 'medium',
93
101
  signDirection = 'left',
@@ -104,7 +112,7 @@ const PriceLockup = /*#__PURE__*/React.forwardRef((_ref7, ref) => {
104
112
  tokens: priceLockupTokens,
105
113
  variant = {},
106
114
  ...rest
107
- } = _ref7;
115
+ } = _ref8;
108
116
  const viewport = useViewport();
109
117
  const {
110
118
  footnoteMarginTop,
@@ -129,7 +137,7 @@ const PriceLockup = /*#__PURE__*/React.forwardRef((_ref7, ref) => {
129
137
  const topTextTypographyTokens = selectTopTextTypographyTokens(themeTokens);
130
138
  const bottomTextTypographyTokens = selectBottomTextTypographyTokens(themeTokens);
131
139
  return /*#__PURE__*/_jsxs(View, {
132
- style: [staticStyles.priceLockupContainer],
140
+ style: [staticStyles.priceLockupContainer, selectContainertokens(themeTokens)],
133
141
  ref: ref,
134
142
  ...selectProps(rest),
135
143
  children: [topText ? /*#__PURE__*/_jsx(View, {
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import View from "react-native-web/dist/exports/View";
4
- import { useThemeTokens } from '../ThemeProvider';
4
+ import { applyShadowToken, useThemeTokens } from '../ThemeProvider';
5
5
  import { a11yProps, getTokensPropType, selectSystemProps, variantProp, viewProps } from '../utils';
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
7
7
  const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
@@ -11,14 +11,16 @@ const selectProgressStyles = _ref => {
11
11
  borderWidth,
12
12
  borderColor,
13
13
  borderRadius,
14
- height
14
+ height,
15
+ shadow
15
16
  } = _ref;
16
17
  return {
17
18
  backgroundColor,
18
19
  borderWidth,
19
20
  borderColor,
20
21
  borderRadius,
21
- height
22
+ height,
23
+ ...applyShadowToken(shadow)
22
24
  };
23
25
  };
24
26
 
@@ -38,6 +40,7 @@ const selectProgressStyles = _ref => {
38
40
  * - `borderRadius` for the rounded corners,
39
41
  * - `borderWidth` to change the border width.
40
42
  * - `height` to control the height of the progress bars displayed within the progress bar container.
43
+ * - `shadow` to apply a box shadow to the progress bar container.
41
44
  *
42
45
  * ## Variants
43
46
  *
@@ -4,7 +4,7 @@ import Platform from "react-native-web/dist/exports/Platform";
4
4
  import StyleSheet from "react-native-web/dist/exports/StyleSheet";
5
5
  import View from "react-native-web/dist/exports/View";
6
6
  import ProgressBarBackground from './ProgressBarBackground';
7
- import { useThemeTokens } from '../ThemeProvider';
7
+ import { applyShadowToken, useThemeTokens } from '../ThemeProvider';
8
8
  import { a11yProps, getTokensPropType, selectSystemProps, variantProp, viewProps } from '../utils';
9
9
  import { jsx as _jsx } from "react/jsx-runtime";
10
10
  const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
@@ -13,13 +13,15 @@ const selectBarStyles = (_ref, percentage) => {
13
13
  backgroundColor,
14
14
  borderRadius,
15
15
  outlineWidth,
16
- outlineColor
16
+ outlineColor,
17
+ shadow
17
18
  } = _ref;
18
19
  return {
19
20
  backgroundColor,
20
21
  borderRadius,
21
22
  outlineWidth,
22
23
  outlineColor,
24
+ ...applyShadowToken(shadow),
23
25
  width: `${percentage}%`
24
26
  };
25
27
  };
@@ -39,6 +41,7 @@ const selectBarStyles = (_ref, percentage) => {
39
41
  * - `borderRadius` for the rounded corners,
40
42
  * - `outlineColor` to control the color of the border (outline),
41
43
  * - `outlineWidth` to change the outline width.
44
+ * - `shadow` to apply a box shadow to the progress bar.
42
45
  *
43
46
  * ## Variants
44
47
  *
@@ -0,0 +1,125 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import View from "react-native-web/dist/exports/View";
4
+ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
5
+ import TabBarItem from './TabBarItem';
6
+ import { useThemeTokens } from '../ThemeProvider';
7
+ import { variantProp, getTokensPropType, selectSystemProps, a11yProps, viewProps } from '../utils';
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ const selectTabBarContainerStyles = _ref => {
10
+ let {
11
+ paddingTop,
12
+ paddingBottom,
13
+ borderTopWidth,
14
+ borderTopColor,
15
+ backgroundColor
16
+ } = _ref;
17
+ return {
18
+ paddingTop,
19
+ paddingBottom,
20
+ borderTopWidth,
21
+ borderTopColor,
22
+ backgroundColor
23
+ };
24
+ };
25
+ const selectTabBarItemContainerStyles = _ref2 => {
26
+ let {
27
+ paddingLeft,
28
+ paddingRight,
29
+ gap
30
+ } = _ref2;
31
+ return {
32
+ paddingLeft,
33
+ paddingRight,
34
+ gap
35
+ };
36
+ };
37
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
38
+
39
+ /**
40
+ * TabBar component renders a navigation bar with multiple TabBarItems.
41
+ * It allows users to switch between different views or sections.
42
+ *
43
+ * @component
44
+ * @example
45
+ * const items = [
46
+ * { id: '1', label: 'Home', icon: <HomeIcon />, iconActive: <HomeActiveIcon /> },
47
+ * { id: '2', label: 'Profile', icon: <ProfileIcon />, iconActive: <ProfileActiveIcon /> },
48
+ * ]
49
+ * return (
50
+ * <TabBar
51
+ * items={items}
52
+ * initiallySelectedItem="1"
53
+ * onChange={(itemId) => console.log(itemId)}
54
+ * />
55
+ * )
56
+ */
57
+
58
+ const TabBar = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
59
+ let {
60
+ items = [],
61
+ initiallySelectedItem = '0',
62
+ onChange,
63
+ variant,
64
+ tokens,
65
+ ...rest
66
+ } = _ref3;
67
+ const [isSelected, setIsSelected] = React.useState(initiallySelectedItem);
68
+ const themeTokens = useThemeTokens('TabBar', tokens, variant);
69
+ const handlePress = itemId => {
70
+ setIsSelected(itemId);
71
+ onChange === null || onChange === void 0 ? void 0 : onChange(itemId);
72
+ };
73
+ return /*#__PURE__*/_jsx(View, {
74
+ ref: ref,
75
+ style: [styles.tabBar, selectTabBarContainerStyles(themeTokens)],
76
+ ...selectProps(rest),
77
+ children: /*#__PURE__*/_jsx(View, {
78
+ style: [styles.tabBarItem, selectTabBarItemContainerStyles(themeTokens)],
79
+ children: items.map((item, index) => /*#__PURE__*/_jsx(TabBarItem, {
80
+ label: item.label,
81
+ href: item.href,
82
+ isSelected: isSelected === item.id,
83
+ icon: item.icon,
84
+ iconActive: item.iconActive,
85
+ onPress: () => handlePress(item.id),
86
+ id: `tab-item-${index}`,
87
+ accessibilityRole: "tablist"
88
+ }, item.id))
89
+ })
90
+ });
91
+ });
92
+ TabBar.displayName = 'TabBar';
93
+ TabBar.propTypes = {
94
+ ...selectedSystemPropTypes,
95
+ /** Array of TabBarItems to be displayed in TabBar */
96
+ items: PropTypes.arrayOf(PropTypes.shape({
97
+ id: PropTypes.string.isRequired,
98
+ icon: PropTypes.node,
99
+ iconActive: PropTypes.node,
100
+ label: PropTypes.string.isRequired,
101
+ href: PropTypes.string
102
+ })).isRequired,
103
+ /** Id of the initially selected item. */
104
+ initiallySelectedItem: PropTypes.number,
105
+ /** Callback function to handle item selection change. */
106
+ onChange: PropTypes.func,
107
+ /** Variant of TabBar for styling purposes. */
108
+ variant: variantProp.propType,
109
+ /** Tokens for theming and styling. */
110
+ tokens: getTokensPropType('TabBar')
111
+ };
112
+ const styles = StyleSheet.create({
113
+ tabBar: {
114
+ flex: 1,
115
+ justifyContent: 'center',
116
+ alignItems: 'center'
117
+ },
118
+ tabBarItem: {
119
+ flex: 1,
120
+ flexDirection: 'row',
121
+ justifyContent: 'space-between',
122
+ width: '100%'
123
+ }
124
+ });
125
+ export default TabBar;