@hero-design/rn 8.119.1 → 8.120.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,5 +1,11 @@
1
1
  # @hero-design/rn
2
2
 
3
+ ## 8.120.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#4874](https://github.com/Thinkei/hero-design/pull/4874) [`c3c35f0c8d2825138330aaae0ae383b624b8e067`](https://github.com/Thinkei/hero-design/commit/c3c35f0c8d2825138330aaae0ae383b624b8e067) Thanks [@ttkien](https://github.com/ttkien)! - [BottomNavigation] add badge count
8
+
3
9
  ## 8.119.1
4
10
 
5
11
  ### Patch Changes
package/es/index.js CHANGED
@@ -10399,10 +10399,12 @@ var BottomNavigation = function BottomNavigation(_ref) {
10399
10399
  })), /*#__PURE__*/React__default.createElement(BottomBarWrapper, {
10400
10400
  themeInsets: insets
10401
10401
  }, /*#__PURE__*/React__default.createElement(BottomBar, null, tabs.map(function (tab) {
10402
+ var _badge$count, _badge$testID;
10402
10403
  var key = tab.key,
10403
10404
  icon = tab.icon,
10404
10405
  title = tab.title,
10405
- testID = tab.testID;
10406
+ testID = tab.testID,
10407
+ badge = tab.badge;
10406
10408
  var active = selectedTabKey === key;
10407
10409
  var inactiveIcon = getInactiveIcon(icon);
10408
10410
  return /*#__PURE__*/React__default.createElement(TouchableWithoutFeedback, {
@@ -10411,11 +10413,16 @@ var BottomNavigation = function BottomNavigation(_ref) {
10411
10413
  return onTabPress(key);
10412
10414
  },
10413
10415
  testID: testID
10414
- }, /*#__PURE__*/React__default.createElement(BottomBarItem, null, /*#__PURE__*/React__default.createElement(Icon, {
10416
+ }, /*#__PURE__*/React__default.createElement(BottomBarItem, null, /*#__PURE__*/React__default.createElement(Status, {
10417
+ content: (_badge$count = badge === null || badge === void 0 ? void 0 : badge.count) !== null && _badge$count !== void 0 ? _badge$count : 0,
10418
+ visible: !!badge && badge.count > 0,
10419
+ max: badge === null || badge === void 0 ? void 0 : badge.max,
10420
+ testID: (_badge$testID = badge === null || badge === void 0 ? void 0 : badge.testID) !== null && _badge$testID !== void 0 ? _badge$testID : "bottom-nav-badge-".concat(key)
10421
+ }, /*#__PURE__*/React__default.createElement(Icon, {
10415
10422
  icon: active ? icon : inactiveIcon,
10416
10423
  intent: active ? 'primary' : 'muted',
10417
10424
  testID: "hero-icon-".concat(icon)
10418
- }), !!title && /*#__PURE__*/React__default.createElement(StyledBottomBarText, {
10425
+ })), !!title && /*#__PURE__*/React__default.createElement(StyledBottomBarText, {
10419
10426
  intent: active ? 'primary' : 'muted',
10420
10427
  numberOfLines: 1
10421
10428
  }, title)));
package/lib/index.js CHANGED
@@ -10428,10 +10428,12 @@ var BottomNavigation = function BottomNavigation(_ref) {
10428
10428
  })), /*#__PURE__*/React__namespace.default.createElement(BottomBarWrapper, {
10429
10429
  themeInsets: insets
10430
10430
  }, /*#__PURE__*/React__namespace.default.createElement(BottomBar, null, tabs.map(function (tab) {
10431
+ var _badge$count, _badge$testID;
10431
10432
  var key = tab.key,
10432
10433
  icon = tab.icon,
10433
10434
  title = tab.title,
10434
- testID = tab.testID;
10435
+ testID = tab.testID,
10436
+ badge = tab.badge;
10435
10437
  var active = selectedTabKey === key;
10436
10438
  var inactiveIcon = getInactiveIcon(icon);
10437
10439
  return /*#__PURE__*/React__namespace.default.createElement(reactNative.TouchableWithoutFeedback, {
@@ -10440,11 +10442,16 @@ var BottomNavigation = function BottomNavigation(_ref) {
10440
10442
  return onTabPress(key);
10441
10443
  },
10442
10444
  testID: testID
10443
- }, /*#__PURE__*/React__namespace.default.createElement(BottomBarItem, null, /*#__PURE__*/React__namespace.default.createElement(Icon, {
10445
+ }, /*#__PURE__*/React__namespace.default.createElement(BottomBarItem, null, /*#__PURE__*/React__namespace.default.createElement(Status, {
10446
+ content: (_badge$count = badge === null || badge === void 0 ? void 0 : badge.count) !== null && _badge$count !== void 0 ? _badge$count : 0,
10447
+ visible: !!badge && badge.count > 0,
10448
+ max: badge === null || badge === void 0 ? void 0 : badge.max,
10449
+ testID: (_badge$testID = badge === null || badge === void 0 ? void 0 : badge.testID) !== null && _badge$testID !== void 0 ? _badge$testID : "bottom-nav-badge-".concat(key)
10450
+ }, /*#__PURE__*/React__namespace.default.createElement(Icon, {
10444
10451
  icon: active ? icon : inactiveIcon,
10445
10452
  intent: active ? 'primary' : 'muted',
10446
10453
  testID: "hero-icon-".concat(icon)
10447
- }), !!title && /*#__PURE__*/React__namespace.default.createElement(StyledBottomBarText, {
10454
+ })), !!title && /*#__PURE__*/React__namespace.default.createElement(StyledBottomBarText, {
10448
10455
  intent: active ? 'primary' : 'muted',
10449
10456
  numberOfLines: 1
10450
10457
  }, title)));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hero-design/rn",
3
- "version": "8.119.1",
3
+ "version": "8.120.0",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -16,6 +16,7 @@ import {
16
16
  } from './StyledBottomNavigation';
17
17
  import { isIOS } from '../../utils/helpers';
18
18
  import type { IconName } from '../Icon';
19
+ import Count from '../Badge/Count';
19
20
 
20
21
  export type BottomNavigationTabType = {
21
22
  key: string;
@@ -23,8 +24,18 @@ export type BottomNavigationTabType = {
23
24
  icon: IconName;
24
25
  component: ReactNode;
25
26
  testID?: string;
27
+ /**
28
+ * Badge to display on the tab icon.
29
+ */
30
+ badge?: {
31
+ /** The number to display on the badge. */
32
+ count: number;
33
+ /** Maximum number before showing `${max}+`. Defaults to 99. */
34
+ max?: number;
35
+ /** Testing id for the badge wrapper. */
36
+ testID?: string;
37
+ };
26
38
  };
27
-
28
39
  interface BottomNavigationProps extends ViewProps {
29
40
  /**
30
41
  * Callback which is called on tab press, receiving key of upcoming active Tab.
@@ -42,13 +53,7 @@ interface BottomNavigationProps extends ViewProps {
42
53
  /**
43
54
  * List of Tabs to be rendered. Each Tab must have an unique key.
44
55
  */
45
- tabs: {
46
- key: string;
47
- title?: string;
48
- icon: IconName;
49
- component: ReactNode;
50
- testID?: string;
51
- }[];
56
+ tabs: BottomNavigationTabType[];
52
57
  /**
53
58
  * Additional style.
54
59
  */
@@ -124,7 +129,7 @@ const BottomNavigation = ({
124
129
  <BottomBarWrapper themeInsets={insets}>
125
130
  <BottomBar>
126
131
  {tabs.map((tab) => {
127
- const { key, icon, title, testID } = tab;
132
+ const { key, icon, title, testID, badge } = tab;
128
133
  const active = selectedTabKey === key;
129
134
  const inactiveIcon = getInactiveIcon(icon);
130
135
 
@@ -135,11 +140,18 @@ const BottomNavigation = ({
135
140
  testID={testID}
136
141
  >
137
142
  <BottomBarItem>
138
- <Icon
139
- icon={active ? icon : inactiveIcon}
140
- intent={active ? 'primary' : 'muted'}
141
- testID={`hero-icon-${icon}`}
142
- />
143
+ <Count
144
+ content={badge?.count ?? 0}
145
+ visible={!!badge && badge.count > 0}
146
+ max={badge?.max}
147
+ testID={badge?.testID ?? `bottom-nav-badge-${key}`}
148
+ >
149
+ <Icon
150
+ icon={active ? icon : inactiveIcon}
151
+ intent={active ? 'primary' : 'muted'}
152
+ testID={`hero-icon-${icon}`}
153
+ />
154
+ </Count>
143
155
  {!!title && (
144
156
  <StyledBottomBarText
145
157
  intent={active ? 'primary' : 'muted'}
@@ -7,6 +7,17 @@ export type BottomNavigationTabType = {
7
7
  icon: IconName;
8
8
  component: ReactNode;
9
9
  testID?: string;
10
+ /**
11
+ * Badge to display on the tab icon.
12
+ */
13
+ badge?: {
14
+ /** The number to display on the badge. */
15
+ count: number;
16
+ /** Maximum number before showing `${max}+`. Defaults to 99. */
17
+ max?: number;
18
+ /** Testing id for the badge wrapper. */
19
+ testID?: string;
20
+ };
10
21
  };
11
22
  interface BottomNavigationProps extends ViewProps {
12
23
  /**
@@ -25,13 +36,7 @@ interface BottomNavigationProps extends ViewProps {
25
36
  /**
26
37
  * List of Tabs to be rendered. Each Tab must have an unique key.
27
38
  */
28
- tabs: {
29
- key: string;
30
- title?: string;
31
- icon: IconName;
32
- component: ReactNode;
33
- testID?: string;
34
- }[];
39
+ tabs: BottomNavigationTabType[];
35
40
  /**
36
41
  * Additional style.
37
42
  */