@razorpay/blade 11.31.2 → 11.32.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 (47) hide show
  1. package/build/lib/native/tokens/global/size.js +1 -1
  2. package/build/lib/native/tokens/global/size.js.map +1 -1
  3. package/build/lib/native/utils/componentZIndices.js +1 -1
  4. package/build/lib/native/utils/componentZIndices.js.map +1 -1
  5. package/build/lib/web/development/components/Menu/VisualSubComponents/MenuHeaderFooter.web.js +5 -4
  6. package/build/lib/web/development/components/Menu/VisualSubComponents/MenuHeaderFooter.web.js.map +1 -1
  7. package/build/lib/web/development/components/TopNav/TabNav/TabNav.web.js +103 -124
  8. package/build/lib/web/development/components/TopNav/TabNav/TabNav.web.js.map +1 -1
  9. package/build/lib/web/development/components/TopNav/TabNav/TabNavContext.js.map +1 -1
  10. package/build/lib/web/development/components/TopNav/TabNav/TabNavItem.web.js +38 -45
  11. package/build/lib/web/development/components/TopNav/TabNav/TabNavItem.web.js.map +1 -1
  12. package/build/lib/web/development/components/TopNav/TabNav/index.js +1 -1
  13. package/build/lib/web/development/components/TopNav/TabNav/utils.js +17 -30
  14. package/build/lib/web/development/components/TopNav/TabNav/utils.js.map +1 -1
  15. package/build/lib/web/development/components/TopNav/TopNav.web.js +34 -87
  16. package/build/lib/web/development/components/TopNav/TopNav.web.js.map +1 -1
  17. package/build/lib/web/development/components/index.js +1 -1
  18. package/build/lib/web/development/tokens/global/size.js +2 -0
  19. package/build/lib/web/development/tokens/global/size.js.map +1 -1
  20. package/build/lib/web/development/utils/componentZIndices.js +2 -1
  21. package/build/lib/web/development/utils/componentZIndices.js.map +1 -1
  22. package/build/lib/web/production/components/Menu/VisualSubComponents/MenuHeaderFooter.web.js +5 -4
  23. package/build/lib/web/production/components/Menu/VisualSubComponents/MenuHeaderFooter.web.js.map +1 -1
  24. package/build/lib/web/production/components/TopNav/TabNav/TabNav.web.js +103 -124
  25. package/build/lib/web/production/components/TopNav/TabNav/TabNav.web.js.map +1 -1
  26. package/build/lib/web/production/components/TopNav/TabNav/TabNavContext.js.map +1 -1
  27. package/build/lib/web/production/components/TopNav/TabNav/TabNavItem.web.js +38 -45
  28. package/build/lib/web/production/components/TopNav/TabNav/TabNavItem.web.js.map +1 -1
  29. package/build/lib/web/production/components/TopNav/TabNav/index.js +1 -1
  30. package/build/lib/web/production/components/TopNav/TabNav/utils.js +17 -30
  31. package/build/lib/web/production/components/TopNav/TabNav/utils.js.map +1 -1
  32. package/build/lib/web/production/components/TopNav/TopNav.web.js +34 -87
  33. package/build/lib/web/production/components/TopNav/TopNav.web.js.map +1 -1
  34. package/build/lib/web/production/components/index.js +1 -1
  35. package/build/lib/web/production/tokens/global/size.js +2 -0
  36. package/build/lib/web/production/tokens/global/size.js.map +1 -1
  37. package/build/lib/web/production/utils/componentZIndices.js +2 -1
  38. package/build/lib/web/production/utils/componentZIndices.js.map +1 -1
  39. package/build/types/components/index.d.ts +59 -47
  40. package/build/types/components/index.native.d.ts +21 -7
  41. package/build/types/tokens/index.d.ts +2 -0
  42. package/build/types/tokens/index.native.d.ts +2 -0
  43. package/package.json +1 -1
  44. package/build/lib/web/development/components/TopNav/TopNavContext.js +0 -13
  45. package/build/lib/web/development/components/TopNav/TopNavContext.js.map +0 -1
  46. package/build/lib/web/production/components/TopNav/TopNavContext.js +0 -13
  47. package/build/lib/web/production/components/TopNav/TopNavContext.js.map +0 -1
@@ -1,4 +1,4 @@
1
- var size={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,10:10,12:12,14:14,15:15,16:16,18:18,20:20,24:24,28:28,30:30,32:32,33:33,36:36,40:40,44:44,48:48,52:52,56:56,60:60,64:64,72:72,80:80,100:100,120:120,140:140,160:160,176:176,200:200,240:240,245:245,256:256,264:264,300:300,314:314,360:360,400:400,584:584,640:640,760:760,800:800,1024:1024,1136:1136};
1
+ var size={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,10:10,12:12,14:14,15:15,16:16,18:18,20:20,24:24,28:28,30:30,32:32,33:33,36:36,40:40,44:44,48:48,52:52,56:56,60:60,64:64,72:72,80:80,100:100,120:120,140:140,160:160,176:176,200:200,208:208,240:240,245:245,256:256,264:264,300:300,314:314,360:360,400:400,584:584,640:640,760:760,800:800,1024:1024,1136:1136};
2
2
 
3
3
  export { size };
4
4
  //# sourceMappingURL=size.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"size.js","sources":["../../../../../src/tokens/global/size.ts"],"sourcesContent":["/**\n * Size tokens are currently not exposed for users (therefore not available in theme)\n */\nexport const size = {\n /** 0 px */\n 0: 0,\n /** 1 px */\n 1: 1,\n /** 2 px */\n 2: 2,\n /** 3 px */\n 3: 3,\n /** 4 px */\n 4: 4,\n /** 5 px */\n 5: 5,\n /** 6 px */\n 6: 6,\n /** 7 px */\n 7: 7,\n /** 8 px */\n 8: 8,\n /** 10 px */\n 10: 10,\n /** 12 px */\n 12: 12,\n /** 14 px */\n 14: 14,\n /** 15 px */\n 15: 15,\n /** 16 px */\n 16: 16,\n /** 18 px */\n 18: 18,\n /** 20 px */\n 20: 20,\n /** 24 px */\n 24: 24,\n /** 28 px */\n 28: 28,\n /** 32 px */\n 30: 30,\n /** 32 px */\n 32: 32,\n /** 33 px */\n 33: 33,\n /** 36 px */\n 36: 36,\n /** 40 px */\n 40: 40,\n /** 44 px */\n 44: 44,\n /** 48 px */\n 48: 48,\n /** 52 px */\n 52: 52,\n /** 56 px */\n 56: 56,\n /** 60 px */\n 60: 60,\n /** 64 px */\n 64: 64,\n /** 72 px */\n 72: 72,\n /** 80 px */\n 80: 80,\n /** 100 px */\n 100: 100,\n /** 120 px */\n 120: 120,\n /** 140 px */\n 140: 140,\n /** 160 px */\n 160: 160,\n /** 176 px */\n 176: 176,\n /** 200 px */\n 200: 200,\n /** 240 px */\n 240: 240,\n /** 245 px */\n 245: 245,\n /** 256 px */\n 256: 256,\n /** 264 px */\n 264: 264,\n /** 300 px */\n 300: 300,\n /** 314 px */\n 314: 314,\n /** 360 px */\n 360: 360,\n /** 400 px */\n 400: 400,\n /** 584 px */\n 584: 584,\n /** 640 px */\n 640: 640,\n /** 760 px */\n 760: 760,\n /** 800 px */\n 800: 800,\n /** 1024 px */\n 1024: 1024,\n /** 1136 px */\n 1136: 1136,\n} as const;\n\nexport type Size = typeof size;\n"],"names":["size"],"mappings":"AAGa,IAAAA,IAAI,CAAG,CAElB,CAAC,CAAE,CAAC,CAEJ,CAAC,CAAE,CAAC,CAEJ,CAAC,CAAE,CAAC,CAEJ,CAAC,CAAE,CAAC,CAEJ,CAAC,CAAE,CAAC,CAEJ,CAAC,CAAE,CAAC,CAEJ,CAAC,CAAE,CAAC,CAEJ,CAAC,CAAE,CAAC,CAEJ,CAAC,CAAE,CAAC,CAEJ,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,IAAI,CAAE,IAAI,CAEV,IAAI,CAAE,IACR;;;;"}
1
+ {"version":3,"file":"size.js","sources":["../../../../../src/tokens/global/size.ts"],"sourcesContent":["/**\n * Size tokens are currently not exposed for users (therefore not available in theme)\n */\nexport const size = {\n /** 0 px */\n 0: 0,\n /** 1 px */\n 1: 1,\n /** 2 px */\n 2: 2,\n /** 3 px */\n 3: 3,\n /** 4 px */\n 4: 4,\n /** 5 px */\n 5: 5,\n /** 6 px */\n 6: 6,\n /** 7 px */\n 7: 7,\n /** 8 px */\n 8: 8,\n /** 10 px */\n 10: 10,\n /** 12 px */\n 12: 12,\n /** 14 px */\n 14: 14,\n /** 15 px */\n 15: 15,\n /** 16 px */\n 16: 16,\n /** 18 px */\n 18: 18,\n /** 20 px */\n 20: 20,\n /** 24 px */\n 24: 24,\n /** 28 px */\n 28: 28,\n /** 32 px */\n 30: 30,\n /** 32 px */\n 32: 32,\n /** 33 px */\n 33: 33,\n /** 36 px */\n 36: 36,\n /** 40 px */\n 40: 40,\n /** 44 px */\n 44: 44,\n /** 48 px */\n 48: 48,\n /** 52 px */\n 52: 52,\n /** 56 px */\n 56: 56,\n /** 60 px */\n 60: 60,\n /** 64 px */\n 64: 64,\n /** 72 px */\n 72: 72,\n /** 80 px */\n 80: 80,\n /** 100 px */\n 100: 100,\n /** 120 px */\n 120: 120,\n /** 140 px */\n 140: 140,\n /** 160 px */\n 160: 160,\n /** 176 px */\n 176: 176,\n /** 200 px */\n 200: 200,\n /** 208 px */\n 208: 208,\n /** 240 px */\n 240: 240,\n /** 245 px */\n 245: 245,\n /** 256 px */\n 256: 256,\n /** 264 px */\n 264: 264,\n /** 300 px */\n 300: 300,\n /** 314 px */\n 314: 314,\n /** 360 px */\n 360: 360,\n /** 400 px */\n 400: 400,\n /** 584 px */\n 584: 584,\n /** 640 px */\n 640: 640,\n /** 760 px */\n 760: 760,\n /** 800 px */\n 800: 800,\n /** 1024 px */\n 1024: 1024,\n /** 1136 px */\n 1136: 1136,\n} as const;\n\nexport type Size = typeof size;\n"],"names":["size"],"mappings":"AAGa,IAAAA,IAAI,CAAG,CAElB,CAAC,CAAE,CAAC,CAEJ,CAAC,CAAE,CAAC,CAEJ,CAAC,CAAE,CAAC,CAEJ,CAAC,CAAE,CAAC,CAEJ,CAAC,CAAE,CAAC,CAEJ,CAAC,CAAE,CAAC,CAEJ,CAAC,CAAE,CAAC,CAEJ,CAAC,CAAE,CAAC,CAEJ,CAAC,CAAE,CAAC,CAEJ,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,EAAE,CAAE,EAAE,CAEN,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,GAAG,CAAE,GAAG,CAER,IAAI,CAAE,IAAI,CAEV,IAAI,CAAE,IACR;;;;"}
@@ -1,4 +1,4 @@
1
- var componentZIndices={bottomSheet:100,modal:1000,drawer:1001,dropdownOverlay:1002,tourMask:1100,popover:1100,tooltip:1100};
1
+ var componentZIndices={bottomSheet:100,modal:1000,drawer:1001,dropdownOverlay:1002,tourMask:1100,popover:1100,tooltip:1100,topnav:100};
2
2
 
3
3
  export { componentZIndices };
4
4
  //# sourceMappingURL=componentZIndices.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"componentZIndices.js","sources":["../../../../src/utils/componentZIndices.ts"],"sourcesContent":["// TODO: Move these properly to tokens at some point\nexport const componentZIndices = {\n bottomSheet: 100,\n modal: 1000,\n drawer: 1001,\n dropdownOverlay: 1002,\n tourMask: 1100,\n popover: 1100,\n tooltip: 1100,\n};\n"],"names":["componentZIndices","bottomSheet","modal","drawer","dropdownOverlay","tourMask","popover","tooltip"],"mappings":"AACa,IAAAA,iBAAiB,CAAG,CAC/BC,WAAW,CAAE,GAAG,CAChBC,KAAK,CAAE,IAAI,CACXC,MAAM,CAAE,IAAI,CACZC,eAAe,CAAE,IAAI,CACrBC,QAAQ,CAAE,IAAI,CACdC,OAAO,CAAE,IAAI,CACbC,OAAO,CAAE,IACX;;;;"}
1
+ {"version":3,"file":"componentZIndices.js","sources":["../../../../src/utils/componentZIndices.ts"],"sourcesContent":["// TODO: Move these properly to tokens at some point\nexport const componentZIndices = {\n bottomSheet: 100,\n modal: 1000,\n drawer: 1001,\n dropdownOverlay: 1002,\n tourMask: 1100,\n popover: 1100,\n tooltip: 1100,\n topnav: 100,\n};\n"],"names":["componentZIndices","bottomSheet","modal","drawer","dropdownOverlay","tourMask","popover","tooltip","topnav"],"mappings":"AACa,IAAAA,iBAAiB,CAAG,CAC/BC,WAAW,CAAE,GAAG,CAChBC,KAAK,CAAE,IAAI,CACXC,MAAM,CAAE,IAAI,CACZC,eAAe,CAAE,IAAI,CACrBC,QAAQ,CAAE,IAAI,CACdC,OAAO,CAAE,IAAI,CACbC,OAAO,CAAE,IAAI,CACbC,MAAM,CAAE,GACV;;;;"}
@@ -6,9 +6,9 @@ import { BaseHeader } from '../../BaseHeaderFooter/BaseHeader.js';
6
6
  import '../../../utils/assignWithoutSideEffects/index.js';
7
7
  import { MetaConstants } from '../../../utils/metaAttribute/metaConstants.js';
8
8
  import '../../Box/index.js';
9
- import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
10
- import { assignWithoutSideEffects } from '../../../utils/assignWithoutSideEffects/assignWithoutSideEffects.js';
9
+ import { jsxs, jsx } from 'react/jsx-runtime';
11
10
  import { Box } from '../../Box/Box.js';
11
+ import { assignWithoutSideEffects } from '../../../utils/assignWithoutSideEffects/assignWithoutSideEffects.js';
12
12
 
13
13
  /* eslint-disable @typescript-eslint/prefer-nullish-coalescing */
14
14
  var _MenuHeader = function _MenuHeader(_ref) {
@@ -18,7 +18,8 @@ var _MenuHeader = function _MenuHeader(_ref) {
18
18
  titleSuffix = _ref.titleSuffix,
19
19
  trailing = _ref.trailing,
20
20
  testID = _ref.testID;
21
- return /*#__PURE__*/jsxs(Fragment, {
21
+ return /*#__PURE__*/jsxs(Box, {
22
+ marginBottom: "spacing.3",
22
23
  children: [/*#__PURE__*/jsx(BaseHeader, {
23
24
  title: title,
24
25
  subtitle: subtitle,
@@ -47,7 +48,7 @@ var _MenuFooter = function _MenuFooter(_ref2) {
47
48
  var children = _ref2.children,
48
49
  testID = _ref2.testID;
49
50
  return /*#__PURE__*/jsxs(Box, {
50
- marginTop: "spacing.2",
51
+ marginTop: "spacing.3",
51
52
  children: [/*#__PURE__*/jsx(MenuDivider, {}), /*#__PURE__*/jsx(BaseFooter, {
52
53
  metaComponentName: MetaConstants.MenuFooter,
53
54
  showDivider: false,
@@ -1 +1 @@
1
- {"version":3,"file":"MenuHeaderFooter.web.js","sources":["../../../../../../../src/components/Menu/VisualSubComponents/MenuHeaderFooter.web.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/prefer-nullish-coalescing */\nimport React from 'react';\nimport { footerPaddingTop, headerMarginBottom, overlayPaddingX } from '../tokens';\nimport type { MenuFooterProps, MenuHeaderProps } from '../types';\nimport { MenuDivider } from './MenuDivider';\nimport { BaseFooter } from '~components/BaseHeaderFooter/BaseFooter';\nimport { BaseHeader } from '~components/BaseHeaderFooter/BaseHeader';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { MetaConstants } from '~utils/metaAttribute/metaConstants';\nimport { Box } from '~components/Box';\n\nconst _MenuHeader = ({\n title,\n subtitle,\n leading,\n titleSuffix,\n trailing,\n testID,\n}: MenuHeaderProps): React.ReactElement => {\n return (\n <>\n <BaseHeader\n title={title}\n subtitle={subtitle}\n leading={leading}\n trailing={trailing}\n titleSuffix={titleSuffix}\n metaComponentName={MetaConstants.MenuHeader}\n testID={testID}\n // back button\n showBackButton={false}\n // close button\n showCloseButton={false}\n paddingX={overlayPaddingX}\n marginTop=\"spacing.0\"\n marginBottom={headerMarginBottom}\n showDivider={false}\n />\n <MenuDivider />\n </>\n );\n};\n\nconst MenuHeader = assignWithoutSideEffects(_MenuHeader, {\n componentId: 'MenuHeader',\n});\n\nconst _MenuFooter = ({ children, testID }: MenuFooterProps): React.ReactElement => {\n return (\n <Box marginTop=\"spacing.2\">\n <MenuDivider />\n <BaseFooter\n metaComponentName={MetaConstants.MenuFooter}\n showDivider={false}\n padding={[footerPaddingTop, overlayPaddingX, 'spacing.0', overlayPaddingX]}\n testID={testID}\n >\n {children}\n </BaseFooter>\n </Box>\n );\n};\n\nconst MenuFooter = assignWithoutSideEffects(_MenuFooter, {\n componentId: 'MenuFooter',\n});\n\nexport { MenuHeader, MenuFooter };\n"],"names":["_MenuHeader","_ref","title","subtitle","leading","titleSuffix","trailing","testID","_jsxs","_Fragment","children","_jsx","BaseHeader","metaComponentName","MetaConstants","MenuHeader","showBackButton","showCloseButton","paddingX","overlayPaddingX","marginTop","marginBottom","headerMarginBottom","showDivider","MenuDivider","assignWithoutSideEffects","componentId","_MenuFooter","_ref2","Box","BaseFooter","MenuFooter","padding","footerPaddingTop"],"mappings":";;;;;;;;;;;;AAAA;AAWA,IAAMA,WAAW,GAAG,SAAdA,WAAWA,CAAAC,IAAA,EAO0B;AAAA,EAAA,IANzCC,KAAK,GAAAD,IAAA,CAALC,KAAK;IACLC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;IACRC,OAAO,GAAAH,IAAA,CAAPG,OAAO;IACPC,WAAW,GAAAJ,IAAA,CAAXI,WAAW;IACXC,QAAQ,GAAAL,IAAA,CAARK,QAAQ;IACRC,MAAM,GAAAN,IAAA,CAANM,MAAM,CAAA;EAEN,oBACEC,IAAA,CAAAC,QAAA,EAAA;IAAAC,QAAA,EAAA,cACEC,GAAA,CAACC,UAAU,EAAA;AACTV,MAAAA,KAAK,EAAEA,KAAM;AACbC,MAAAA,QAAQ,EAAEA,QAAS;AACnBC,MAAAA,OAAO,EAAEA,OAAQ;AACjBE,MAAAA,QAAQ,EAAEA,QAAS;AACnBD,MAAAA,WAAW,EAAEA,WAAY;MACzBQ,iBAAiB,EAAEC,aAAa,CAACC,UAAW;AAC5CR,MAAAA,MAAM,EAAEA,MAAAA;AACR;AAAA;AACAS,MAAAA,cAAc,EAAE,KAAA;AAChB;AAAA;AACAC,MAAAA,eAAe,EAAE,KAAM;AACvBC,MAAAA,QAAQ,EAAEC,eAAgB;AAC1BC,MAAAA,SAAS,EAAC,WAAW;AACrBC,MAAAA,YAAY,EAAEC,kBAAmB;AACjCC,MAAAA,WAAW,EAAE,KAAA;AAAM,KACpB,CAAC,eACFZ,GAAA,CAACa,WAAW,IAAE,CAAC,CAAA;AAAA,GACf,CAAC,CAAA;AAEP,CAAC,CAAA;AAED,IAAMT,UAAU,gBAAGU,wBAAwB,CAACzB,WAAW,EAAE;AACvD0B,EAAAA,WAAW,EAAE,YAAA;AACf,CAAC,EAAC;AAEF,IAAMC,WAAW,GAAG,SAAdA,WAAWA,CAAAC,KAAA,EAAkE;AAAA,EAAA,IAA5DlB,QAAQ,GAAAkB,KAAA,CAARlB,QAAQ;IAAEH,MAAM,GAAAqB,KAAA,CAANrB,MAAM,CAAA;EACrC,oBACEC,IAAA,CAACqB,GAAG,EAAA;AAACT,IAAAA,SAAS,EAAC,WAAW;IAAAV,QAAA,EAAA,cACxBC,GAAA,CAACa,WAAW,IAAE,CAAC,eACfb,GAAA,CAACmB,UAAU,EAAA;MACTjB,iBAAiB,EAAEC,aAAa,CAACiB,UAAW;AAC5CR,MAAAA,WAAW,EAAE,KAAM;MACnBS,OAAO,EAAE,CAACC,gBAAgB,EAAEd,eAAe,EAAE,WAAW,EAAEA,eAAe,CAAE;AAC3EZ,MAAAA,MAAM,EAAEA,MAAO;AAAAG,MAAAA,QAAA,EAEdA,QAAAA;AAAQ,KACC,CAAC,CAAA;AAAA,GACV,CAAC,CAAA;AAEV,CAAC,CAAA;AAED,IAAMqB,UAAU,gBAAGN,wBAAwB,CAACE,WAAW,EAAE;AACvDD,EAAAA,WAAW,EAAE,YAAA;AACf,CAAC;;;;"}
1
+ {"version":3,"file":"MenuHeaderFooter.web.js","sources":["../../../../../../../src/components/Menu/VisualSubComponents/MenuHeaderFooter.web.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/prefer-nullish-coalescing */\nimport React from 'react';\nimport { footerPaddingTop, headerMarginBottom, overlayPaddingX } from '../tokens';\nimport type { MenuFooterProps, MenuHeaderProps } from '../types';\nimport { MenuDivider } from './MenuDivider';\nimport { BaseFooter } from '~components/BaseHeaderFooter/BaseFooter';\nimport { BaseHeader } from '~components/BaseHeaderFooter/BaseHeader';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { MetaConstants } from '~utils/metaAttribute/metaConstants';\nimport { Box } from '~components/Box';\n\nconst _MenuHeader = ({\n title,\n subtitle,\n leading,\n titleSuffix,\n trailing,\n testID,\n}: MenuHeaderProps): React.ReactElement => {\n return (\n <Box marginBottom=\"spacing.3\">\n <BaseHeader\n title={title}\n subtitle={subtitle}\n leading={leading}\n trailing={trailing}\n titleSuffix={titleSuffix}\n metaComponentName={MetaConstants.MenuHeader}\n testID={testID}\n // back button\n showBackButton={false}\n // close button\n showCloseButton={false}\n paddingX={overlayPaddingX}\n marginTop=\"spacing.0\"\n marginBottom={headerMarginBottom}\n showDivider={false}\n />\n <MenuDivider />\n </Box>\n );\n};\n\nconst MenuHeader = assignWithoutSideEffects(_MenuHeader, {\n componentId: 'MenuHeader',\n});\n\nconst _MenuFooter = ({ children, testID }: MenuFooterProps): React.ReactElement => {\n return (\n <Box marginTop=\"spacing.3\">\n <MenuDivider />\n <BaseFooter\n metaComponentName={MetaConstants.MenuFooter}\n showDivider={false}\n padding={[footerPaddingTop, overlayPaddingX, 'spacing.0', overlayPaddingX]}\n testID={testID}\n >\n {children}\n </BaseFooter>\n </Box>\n );\n};\n\nconst MenuFooter = assignWithoutSideEffects(_MenuFooter, {\n componentId: 'MenuFooter',\n});\n\nexport { MenuHeader, MenuFooter };\n"],"names":["_MenuHeader","_ref","title","subtitle","leading","titleSuffix","trailing","testID","_jsxs","Box","marginBottom","children","_jsx","BaseHeader","metaComponentName","MetaConstants","MenuHeader","showBackButton","showCloseButton","paddingX","overlayPaddingX","marginTop","headerMarginBottom","showDivider","MenuDivider","assignWithoutSideEffects","componentId","_MenuFooter","_ref2","BaseFooter","MenuFooter","padding","footerPaddingTop"],"mappings":";;;;;;;;;;;;AAAA;AAWA,IAAMA,WAAW,GAAG,SAAdA,WAAWA,CAAAC,IAAA,EAO0B;AAAA,EAAA,IANzCC,KAAK,GAAAD,IAAA,CAALC,KAAK;IACLC,QAAQ,GA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AAA,cACxBC,GAAA,CAACY,WAAW,IAAE,CAAC,eACfZ,GAAA,CAACiB,UAAU,EAAA;MACTf,iBAAiB,EAAEC,aAAa,CAACe,UAAW;AAC5CP,MAAAA,WAAW,EAAE,KAAM;MACnBQ,OAAO,EAAE,CAACC,gBAAgB,EAAEZ,eAAe,EAAE,WAAW,EAAEA,eAAe,CAAE;AAC3Eb,MAAAA,MAAM,EAAEA,MAAO;AAAAI,MAAAA,QAAA,EAEdA,QAAAA;AAAQ,KACC,CAAC,CAAA;AAAA,GACV,CAAC,CAAA;AAEV,CAAC,CAAA;AAED,IAAMmB,UAAU,gBAAGL,wBAAwB,CAACE,WAAW,EAAE;AACvDD,EAAAA,WAAW,EAAE,YAAA;AACf,CAAC;;;;"}
@@ -1,172 +1,151 @@
1
1
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
2
- import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
3
2
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
3
+ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
4
4
  import React__default from 'react';
5
- import styled from 'styled-components';
6
- import { useTopNavContext } from '../TopNavContext.js';
7
- import { MIXED_BG_COLOR, useHasOverflow, approximatelyEqual } from './utils.js';
5
+ import ReactDOM from 'react-dom';
8
6
  import { TabNavContext } from './TabNavContext.js';
7
+ import { useResize } from './utils.js';
9
8
  import '../../Box/BaseBox/index.js';
10
9
  import '../../Box/styledProps/index.js';
11
- import '../../Button/index.js';
12
10
  import '../../Divider/index.js';
13
- import '../../Icons/index.js';
14
11
  import '../../../utils/index.js';
15
12
  import '../../../tokens/global/index.js';
16
- import getIn from '../../../utils/lodashButBetter/get.js';
17
13
  import '../../../utils/metaAttribute/index.js';
18
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
19
- import { BaseBox } from '../../Box/BaseBox/BaseBox.web.js';
20
- import { makeMotionTime } from '../../../utils/makeMotionTime/makeMotionTime.web.js';
14
+ import '../../Box/index.js';
15
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
16
+ import { Box } from '../../Box/Box.js';
17
+ import { Divider } from '../../Divider/Divider.js';
21
18
  import { makeSize } from '../../../utils/makeSize/makeSize.js';
19
+ import { size } from '../../../tokens/global/size.js';
20
+ import { BaseBox } from '../../Box/BaseBox/BaseBox.web.js';
22
21
  import { getStyledProps } from '../../Box/styledProps/getStyledProps.js';
23
22
  import { metaAttribute } from '../../../utils/metaAttribute/metaAttribute.web.js';
24
23
  import { MetaConstants } from '../../../utils/metaAttribute/metaConstants.js';
25
- import Button from '../../Button/Button/Button.js';
26
- import ChevronLeftIcon from '../../Icons/ChevronLeftIcon/ChevronLeftIcon.js';
27
- import { Divider } from '../../Divider/Divider.js';
28
- import { size } from '../../../tokens/global/size.js';
29
- import ChevronRightIcon from '../../Icons/ChevronRightIcon/ChevronRightIcon.js';
30
24
 
31
- var _excluded = ["children"];
25
+ var _excluded = ["children"],
26
+ _excluded2 = ["children", "items"];
32
27
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
33
28
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
34
- var GRADIENT_WIDTH = 54;
35
- var GRADIENT_OFFSET = -8;
36
- var OFFSET_BOTTOM = -12;
37
- var SCROLL_AMOUNT = 200;
38
- var ScrollableArea = /*#__PURE__*/styled(BaseBox).withConfig({
39
- displayName: "TabNavweb__ScrollableArea",
40
- componentId: "sc-1ww6x3k-0"
41
- })(function () {
42
- return {
43
- '&::-webkit-scrollbar': {
44
- display: 'none'
45
- }
46
- };
47
- });
48
- var GradientOverlay = /*#__PURE__*/styled(BaseBox).withConfig({
49
- displayName: "TabNavweb__GradientOverlay",
50
- componentId: "sc-1ww6x3k-1"
51
- })(function (_ref) {
52
- var theme = _ref.theme,
53
- shouldShow = _ref.shouldShow,
54
- variant = _ref.variant,
55
- $color = _ref.$color;
56
- var color = getIn(theme.colors, $color, MIXED_BG_COLOR);
57
- return _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
58
- position: 'absolute'
59
- }, variant, 0), "pointerEvents", shouldShow ? 'auto' : 'none'), "transform", shouldShow ? 'scale(1)' : 'scale(0.5)'), "opacity", shouldShow ? 1 : 0), "transitionTimingFunction", "".concat(theme.motion.easing.standard.revealing)), "transitionDuration", "".concat(makeMotionTime(theme.motion.duration.xquick))), "transitionProperty", 'opacity, transform'), "zIndex", 1), ':before', _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
60
- content: "''",
61
- pointerEvents: 'none',
62
- position: 'absolute'
63
- }, variant, 0), "top", makeSize(GRADIENT_OFFSET)), "bottom", makeSize(GRADIENT_OFFSET)), "width", makeSize(GRADIENT_WIDTH)), "background", "linear-gradient(to ".concat(variant, ", transparent 0%, ").concat(color, " 30%, ").concat(color, " 100%);")));
64
- });
65
- var TabNav = function TabNav(_ref3) {
66
- var children = _ref3.children,
67
- styledProps = _objectWithoutProperties(_ref3, _excluded);
29
+ var TabNavItems = function TabNavItems(_ref) {
30
+ var children = _ref.children,
31
+ props = _objectWithoutProperties(_ref, _excluded);
32
+ return /*#__PURE__*/jsxs(Box, _objectSpread(_objectSpread({}, props), {}, {
33
+ display: "flex",
34
+ width: "100%",
35
+ gap: "spacing.0",
36
+ position: "relative",
37
+ left: "-1px",
38
+ children: [React__default.Children.map(children, function (child, index) {
39
+ return /*#__PURE__*/jsxs(Fragment, {
40
+ children: [index > 0 ? /*#__PURE__*/jsx(Divider, {
41
+ margin: "auto",
42
+ variant: "muted",
43
+ orientation: "vertical",
44
+ height: makeSize(size[16])
45
+ }) : null, /*#__PURE__*/React__default.cloneElement(child, {
46
+ __isInsideTabNavItems: true,
47
+ __index: index
48
+ })]
49
+ });
50
+ }), /*#__PURE__*/jsx(Divider, {
51
+ margin: "auto",
52
+ variant: "muted",
53
+ orientation: "vertical",
54
+ height: makeSize(size[16])
55
+ })]
56
+ }));
57
+ };
58
+ var TabNav = function TabNav(_ref2) {
59
+ var children = _ref2.children,
60
+ items = _ref2.items,
61
+ styledProps = _objectWithoutProperties(_ref2, _excluded2);
68
62
  var ref = React__default.useRef(null);
69
- var hasOverflow = useHasOverflow(ref);
70
- var _React$useState = React__default.useState('start'),
63
+ var _React$useState = React__default.useState(items),
71
64
  _React$useState2 = _slicedToArray(_React$useState, 2),
72
- scrollStatus = _React$useState2[0],
73
- setScrollStatus = _React$useState2[1];
74
- var _useTopNavContext = useTopNavContext(),
75
- backgroundColor = _useTopNavContext.backgroundColor;
65
+ controlledItems = _React$useState2[0],
66
+ setControlledItems = _React$useState2[1];
67
+ var overflowingItems = controlledItems.filter(function (item) {
68
+ var _item$isAlwaysOverflo;
69
+ return (_item$isAlwaysOverflo = item.isAlwaysOverflowing) !== null && _item$isAlwaysOverflo !== void 0 ? _item$isAlwaysOverflo : item.isOverflowing;
70
+ });
71
+ var _items = controlledItems.filter(function (item) {
72
+ return !item.isAlwaysOverflowing && !item.isOverflowing;
73
+ });
76
74
 
77
- // Check if the scroll is at start, end or middle
78
- var handleScrollStatus = React__default.useCallback(function (e) {
79
- var target = e.target;
80
- var isAtStart = target.scrollLeft === 0;
81
- var isAtEnd = approximatelyEqual(target.scrollLeft, target.scrollWidth - target.offsetWidth);
82
- if (isAtStart) {
83
- setScrollStatus('start');
84
- } else if (isAtEnd) {
85
- setScrollStatus('end');
75
+ // We need to memoize this callback otherwise it will cause infinite re-renders
76
+ // Because the ResizeObserver callback will be a new reference on every render
77
+ // and it will trigger a re-render
78
+ var resizeCallback = React__default.useCallback(function (resizeInfo) {
79
+ var target = resizeInfo.target;
80
+ var updateItems = function updateItems() {
81
+ setControlledItems(function (items) {
82
+ return items.map(function (item, index) {
83
+ // never overflow the first item
84
+ if (index === 0) return _objectSpread(_objectSpread({}, item), {}, {
85
+ isOverflowing: false
86
+ });
87
+ // add padding to the offsetX to account the "More" menu's width changing due to the selection state (eg: More:ProdctName)
88
+ // Currently, hardcoding this to 150, we can make this dynamic too but that's causing layout thrashing
89
+ // because first we need to calculate the width of the "More" menu and then update the items
90
+ var padding = 150;
91
+ var offset = item.offsetX + padding - target.getBoundingClientRect().left;
92
+ if (offset > target.offsetWidth) {
93
+ return _objectSpread(_objectSpread({}, item), {}, {
94
+ isOverflowing: true
95
+ });
96
+ } else {
97
+ return _objectSpread(_objectSpread({}, item), {}, {
98
+ isOverflowing: false
99
+ });
100
+ }
101
+ });
102
+ });
103
+ };
104
+ // https://github.com/webpack/webpack/issues/14814
105
+ var flushSync = ReactDOM['flushSync'.toString()];
106
+ // Using flushSync to avoid layout thrashing,
107
+ // this will force React to flush all pending updates and only then update the DOM
108
+ if (flushSync !== undefined) {
109
+ flushSync(updateItems);
86
110
  } else {
87
- setScrollStatus('middle');
111
+ updateItems();
88
112
  }
89
113
  }, []);
90
- var scrollRight = function scrollRight() {
91
- if (!ref.current) return;
92
- ref.current.scrollBy({
93
- behavior: 'smooth',
94
- left: SCROLL_AMOUNT
95
- });
96
- };
97
- var scrollLeft = function scrollLeft() {
98
- if (!ref.current) return;
99
- ref.current.scrollBy({
100
- behavior: 'smooth',
101
- left: -SCROLL_AMOUNT
102
- });
103
- };
114
+ useResize(ref, resizeCallback);
104
115
  return /*#__PURE__*/jsx(TabNavContext.Provider, {
105
116
  value: {
106
117
  containerRef: ref,
107
- hasOverflow: hasOverflow
118
+ controlledItems: controlledItems,
119
+ setControlledItems: setControlledItems
108
120
  },
109
- children: /*#__PURE__*/jsxs(BaseBox, _objectSpread(_objectSpread(_objectSpread({
121
+ children: /*#__PURE__*/jsx(BaseBox, _objectSpread(_objectSpread(_objectSpread({
110
122
  as: "nav",
111
123
  display: "flex",
112
124
  width: "100%",
113
125
  alignItems: "center",
114
- position: "relative",
115
- marginBottom: makeSize(OFFSET_BOTTOM)
126
+ alignSelf: "end",
127
+ position: "relative"
116
128
  }, getStyledProps(styledProps)), metaAttribute({
117
129
  name: MetaConstants.TabNav
118
130
  })), {}, {
119
- children: [/*#__PURE__*/jsx(GradientOverlay, {
120
- variant: "left",
121
- $color: backgroundColor,
122
- shouldShow: hasOverflow && scrollStatus !== 'start',
123
- children: /*#__PURE__*/jsx(Button, {
124
- size: "xsmall",
125
- variant: "tertiary",
126
- icon: ChevronLeftIcon,
127
- accessibilityLabel: "Scroll Left",
128
- onClick: scrollLeft
129
- })
130
- }), /*#__PURE__*/jsx(ScrollableArea, {
131
- ref: ref,
132
- onScroll: handleScrollStatus,
131
+ ref: ref,
132
+ children: /*#__PURE__*/jsx(BaseBox, {
133
133
  display: "flex",
134
134
  width: "100%",
135
135
  position: "relative",
136
- whiteSpace: "nowrap",
137
- gap: "spacing.0",
138
- overflowY: "hidden",
139
- overflowX: "auto",
140
136
  children: /*#__PURE__*/jsx(BaseBox, {
141
137
  display: "flex",
142
138
  flexDirection: "row",
143
139
  width: "max-content",
144
- children: React__default.Children.map(children, function (child, index) {
145
- return /*#__PURE__*/jsxs(Fragment, {
146
- children: [index > 0 ? /*#__PURE__*/jsx(Divider, {
147
- margin: "auto",
148
- variant: "muted",
149
- orientation: "vertical",
150
- height: makeSize(size[16])
151
- }) : null, child]
152
- });
140
+ children: children({
141
+ items: _items,
142
+ overflowingItems: overflowingItems
153
143
  })
154
144
  })
155
- }), /*#__PURE__*/jsx(GradientOverlay, {
156
- variant: "right",
157
- $color: backgroundColor,
158
- shouldShow: hasOverflow && scrollStatus !== 'end',
159
- children: /*#__PURE__*/jsx(Button, {
160
- size: "xsmall",
161
- variant: "tertiary",
162
- icon: ChevronRightIcon,
163
- accessibilityLabel: "Scroll Right",
164
- onClick: scrollRight
165
- })
166
- })]
145
+ })
167
146
  }))
168
147
  });
169
148
  };
170
149
 
171
- export { TabNav };
150
+ export { TabNav, TabNavItems };
172
151
  //# sourceMappingURL=TabNav.web.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TabNav.web.js","sources":["../../../../../../../src/components/TopNav/TabNav/TabNav.web.tsx"],"sourcesContent":["import React from 'react';\nimport styled from 'styled-components';\nimport { useTopNavContext } from '../TopNavContext';\nimport { approximatelyEqual, MIXED_BG_COLOR, useHasOverflow } from './utils';\nimport { TabNavContext } from './TabNavContext';\nimport BaseBox from '~components/Box/BaseBox';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport { getStyledProps } from '~components/Box/styledProps';\nimport { Button } from '~components/Button';\nimport { Divider } from '~components/Divider';\nimport { ChevronLeftIcon, ChevronRightIcon } from '~components/Icons';\nimport { makeMotionTime, makeSize } from '~utils';\nimport { size } from '~tokens/global';\nimport getIn from '~utils/lodashButBetter/get';\nimport type { BoxProps } from '~components/Box';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\n\nconst GRADIENT_WIDTH = 54 as const;\nconst GRADIENT_OFFSET = -8 as const;\nconst OFFSET_BOTTOM = -12 as const;\nconst SCROLL_AMOUNT = 200;\n\ntype TabNavProps = {\n children: React.ReactNode;\n};\n\nconst ScrollableArea = styled(BaseBox)(() => {\n return {\n '&::-webkit-scrollbar': { display: 'none' },\n };\n});\n\nconst GradientOverlay = styled(BaseBox)<{\n shouldShow?: boolean;\n variant: 'left' | 'right';\n $color: BoxProps['backgroundColor'];\n}>(({ theme, shouldShow, variant, $color }) => {\n const color = getIn(theme.colors, $color as never, MIXED_BG_COLOR);\n\n return {\n position: 'absolute',\n [variant]: 0,\n pointerEvents: shouldShow ? 'auto' : 'none',\n transform: shouldShow ? 'scale(1)' : 'scale(0.5)',\n opacity: shouldShow ? 1 : 0,\n transitionTimingFunction: `${theme.motion.easing.standard.revealing}`,\n transitionDuration: `${makeMotionTime(theme.motion.duration.xquick)}`,\n transitionProperty: 'opacity, transform',\n zIndex: 1,\n ':before': {\n content: \"''\",\n pointerEvents: 'none',\n position: 'absolute',\n [variant]: 0,\n top: makeSize(GRADIENT_OFFSET),\n bottom: makeSize(GRADIENT_OFFSET),\n width: makeSize(GRADIENT_WIDTH),\n background: `linear-gradient(to ${variant}, transparent 0%, ${color} 30%, ${color} 100%);`,\n },\n };\n});\n\nconst TabNav = ({\n children,\n ...styledProps\n}: TabNavProps & StyledPropsBlade): React.ReactElement => {\n const ref = React.useRef<HTMLDivElement>(null);\n const hasOverflow = useHasOverflow(ref);\n const [scrollStatus, setScrollStatus] = React.useState<'start' | 'end' | 'middle'>('start');\n const { backgroundColor } = useTopNavContext();\n\n // Check if the scroll is at start, end or middle\n const handleScrollStatus = React.useCallback(\n (e: React.UIEvent<HTMLDivElement, UIEvent>): void => {\n const target = e.target as HTMLDivElement;\n const isAtStart = target.scrollLeft === 0;\n const isAtEnd = approximatelyEqual(\n target.scrollLeft,\n target.scrollWidth - target.offsetWidth,\n );\n\n if (isAtStart) {\n setScrollStatus('start');\n } else if (isAtEnd) {\n setScrollStatus('end');\n } else {\n setScrollStatus('middle');\n }\n },\n [],\n );\n\n const scrollRight = (): void => {\n if (!ref.current) return;\n ref.current.scrollBy({\n behavior: 'smooth',\n left: SCROLL_AMOUNT,\n });\n };\n\n const scrollLeft = (): void => {\n if (!ref.current) return;\n ref.current.scrollBy({\n behavior: 'smooth',\n left: -SCROLL_AMOUNT,\n });\n };\n\n return (\n <TabNavContext.Provider value={{ containerRef: ref, hasOverflow }}>\n <BaseBox\n as=\"nav\"\n display=\"flex\"\n width=\"100%\"\n alignItems=\"center\"\n position=\"relative\"\n marginBottom={makeSize(OFFSET_BOTTOM)}\n {...getStyledProps(styledProps)}\n {...metaAttribute({ name: MetaConstants.TabNav })}\n >\n <GradientOverlay\n variant=\"left\"\n $color={backgroundColor}\n shouldShow={hasOverflow && scrollStatus !== 'start'}\n >\n <Button\n size=\"xsmall\"\n variant=\"tertiary\"\n icon={ChevronLeftIcon}\n accessibilityLabel=\"Scroll Left\"\n onClick={scrollLeft}\n />\n </GradientOverlay>\n <ScrollableArea\n ref={ref}\n onScroll={handleScrollStatus}\n display=\"flex\"\n width=\"100%\"\n position=\"relative\"\n whiteSpace=\"nowrap\"\n gap=\"spacing.0\"\n overflowY=\"hidden\"\n overflowX=\"auto\"\n >\n <BaseBox display=\"flex\" flexDirection=\"row\" width=\"max-content\">\n {React.Children.map(children, (child, index) => {\n return (\n <>\n {index > 0 ? (\n <Divider\n margin=\"auto\"\n variant=\"muted\"\n orientation=\"vertical\"\n height={makeSize(size[16])}\n />\n ) : null}\n {child}\n </>\n );\n })}\n </BaseBox>\n </ScrollableArea>\n <GradientOverlay\n variant=\"right\"\n $color={backgroundColor}\n shouldShow={hasOverflow && scrollStatus !== 'end'}\n >\n <Button\n size=\"xsmall\"\n variant=\"tertiary\"\n icon={ChevronRightIcon}\n accessibilityLabel=\"Scroll Right\"\n onClick={scrollRight}\n />\n </GradientOverlay>\n </BaseBox>\n </TabNavContext.Provider>\n );\n};\n\nexport { TabNav };\n"],"names":["GRADIENT_WIDTH","GRADIENT_OFFSET","OFFSET_BOTTOM","SCROLL_AMOUNT","ScrollableArea","styled","BaseBox","withConfig","displayName","componentId","display","GradientOverlay","_ref","theme","shouldShow","variant","$color","color","getIn","colors","MIXED_BG_COLOR","_defineProperty","position","concat","motion","easing","standard","revealing","makeMotionTime","duration","xquick","content","pointerEvents","makeSize","TabNav","_ref3","children","styledProps","_objectWithoutProperties","_excluded","ref","React","useRef","hasOverflow","useHasOverflow","_React$useState","useState","_React$useState2","_slicedToArray","scrollStatus","setScrollStatus","_useTopNavContext","useTopNavContext","backgroundColor","handleScrollStatus","useCallback","e","target","isAtStart","scrollLeft","isAtEnd","approximatelyEqual","scrollWidth","offsetWidth","scrollRight","current","scrollBy","behavior","left","_jsx","TabNavContext","Provider","value","containerRef","_jsxs","_objectSpread","as","width","alignItems","marginBottom","getStyledProps","metaAttribute","name","MetaConstants","Button","size","icon","ChevronLeftIcon","accessibilityLabel","onClick","onScroll","whiteSpace","gap","overflowY","overflowX","flexDirection","Children","map","child","index","_Fragment","Divider","margin","orientation","height","ChevronRightIcon"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,IAAMA,cAAc,GAAG,EAAW,CAAA;AAClC,IAAMC,eAAe,GAAG,CAAC,CAAU,CAAA;AACnC,IAAMC,aAAa,GAAG,CAAC,EAAW,CAAA;AAClC,IAAMC,aAAa,GAAG,GAAG,CAAA;AAMzB,IAAMC,cAAc,gBAAGC,MAAM,CAACC,OAAO,CAAC,CAAAC,UAAA,CAAA;EAAAC,WAAA,EAAA,2BAAA;EAAAC,WAAA,EAAA,cAAA;AAAA,CAAA,CAAA,CAAC,YAAM;EAC3C,OAAO;AACL,IAAA,sBAAsB,EAAE;AAAEC,MAAAA,OAAO,EAAE,MAAA;AAAO,KAAA;GAC3C,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,IAAMC,eAAe,gBAAGN,MAAM,CAACC,OAAO,CAAC,CAAAC,UAAA,CAAA;EAAAC,WAAA,EAAA,4BAAA;EAAAC,WAAA,EAAA,cAAA;AAAA,CAIpC,CAAA,CAAA,UAAAG,IAAA,EAA4C;AAAA,EAAA,IAAzCC,KAAK,GAAAD,IAAA,CAALC,KAAK;IAAEC,UAAU,GAAAF,IAAA,CAAVE,UAAU;IAAEC,OAAO,GAAAH,IAAA,CAAPG,OAAO;IAAEC,MAAM,GAAAJ,IAAA,CAANI,MAAM,CAAA;EACtC,IAAMC,KAAK,GAAGC,KAAK,CAACL,KAAK,CAACM,MAAM,EAAEH,MAAM,EAAWI,cAAc,CAAC,CAAA;AAElE,EAAA,OAAAC,eAAA,CAAAA,eAAA,CAAAA,eAAA,CAAAA,eAAA,CAAAA,eAAA,CAAAA,eAAA,CAAAA,eAAA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EACPa,KAAK,CAAA;AAAA,aACN,CAAC,CAAA;WAEN,CAAA;SACM,CAAA;AAAC,OACI,CAAC,eACjB7B,GAAA,CAAC1D,eAAe,EAAA;AACdI,QAAAA,OAAO,EAAC,OAAO;AACfC,QAAAA,MAAM,EAAEqC,eAAgB;AACxBvC,QAAAA,UAAU,EAAE6B,WAAW,IAAIM,YAAY,KAAK,KAAM;QAAAb,QAAA,eAElDiC,GAAA,CAACe,MAAM,EAAA;AACLC,UAAAA,IAAI,EAAC,QAAQ;AACbtE,UAAAA,OAAO,EAAC,UAAU;AAClBuE,UAAAA,IAAI,EAAEmB,gBAAiB;AACvBjB,UAAAA,kBAAkB,EAAC,cAAc;AACjCC,UAAAA,OAAO,EAAEzB,WAAAA;SACV,CAAA;AAAC,OACa,CAAC,CAAA;KACX,CAAA,CAAA;AAAC,GACY,CAAC,CAAA;AAE7B;;;;"}
1
+ {"version":3,"file":"TabNav.web.js","sources":["../../../../../../../src/components/TopNav/TabNav/TabNav.web.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable consistent-return */\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport { TabNavContext } from './TabNavContext';\nimport { useResize } from './utils';\nimport type { TabNavItemData, TabNavProps } from './types';\nimport BaseBox from '~components/Box/BaseBox';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport { getStyledProps } from '~components/Box/styledProps';\nimport { Divider } from '~components/Divider';\nimport { makeSize } from '~utils';\nimport { size } from '~tokens/global';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport type { BoxProps } from '~components/Box';\nimport { Box } from '~components/Box';\n\nconst TabNavItems = ({ children, ...props }: BoxProps): React.ReactElement => {\n return (\n <Box {...props} display=\"flex\" width=\"100%\" gap=\"spacing.0\" position=\"relative\" left=\"-1px\">\n {React.Children.map(children, (child, index) => {\n return (\n <>\n {index > 0 ? (\n <Divider\n margin=\"auto\"\n variant=\"muted\"\n orientation=\"vertical\"\n height={makeSize(size[16])}\n />\n ) : null}\n {React.cloneElement(child as React.ReactElement, {\n __isInsideTabNavItems: true,\n __index: index,\n })}\n </>\n );\n })}\n <Divider margin=\"auto\" variant=\"muted\" orientation=\"vertical\" height={makeSize(size[16])} />\n </Box>\n );\n};\n\nconst TabNav = ({\n children,\n items,\n ...styledProps\n}: TabNavProps & StyledPropsBlade): React.ReactElement => {\n const ref = React.useRef<HTMLDivElement>(null);\n const [controlledItems, setControlledItems] = React.useState<TabNavItemData[]>(items);\n\n const overflowingItems = controlledItems.filter(\n (item) => item.isAlwaysOverflowing ?? item.isOverflowing,\n );\n const _items = controlledItems.filter((item) => !item.isAlwaysOverflowing && !item.isOverflowing);\n\n // We need to memoize this callback otherwise it will cause infinite re-renders\n // Because the ResizeObserver callback will be a new reference on every render\n // and it will trigger a re-render\n const resizeCallback = React.useCallback((resizeInfo: ResizeObserverEntry): void => {\n const target = resizeInfo.target as HTMLElement;\n const updateItems = (): void => {\n setControlledItems((items) => {\n return items.map((item, index) => {\n // never overflow the first item\n if (index === 0) return { ...item, isOverflowing: false };\n // add padding to the offsetX to account the \"More\" menu's width changing due to the selection state (eg: More:ProdctName)\n // Currently, hardcoding this to 150, we can make this dynamic too but that's causing layout thrashing\n // because first we need to calculate the width of the \"More\" menu and then update the items\n const padding = 150;\n const offset = (item.offsetX! + padding)! - target.getBoundingClientRect().left;\n if (offset > target.offsetWidth) {\n return { ...item, isOverflowing: true };\n } else {\n return { ...item, isOverflowing: false };\n }\n });\n });\n };\n // https://github.com/webpack/webpack/issues/14814\n const flushSync = (ReactDOM as any)['flushSync'.toString()];\n // Using flushSync to avoid layout thrashing,\n // this will force React to flush all pending updates and only then update the DOM\n if (flushSync !== undefined) {\n flushSync(updateItems);\n } else {\n updateItems();\n }\n }, []);\n\n useResize(ref, resizeCallback);\n\n return (\n <TabNavContext.Provider value={{ containerRef: ref, controlledItems, setControlledItems }}>\n <BaseBox\n as=\"nav\"\n display=\"flex\"\n width=\"100%\"\n alignItems=\"center\"\n alignSelf=\"end\"\n position=\"relative\"\n {...getStyledProps(styledProps)}\n {...metaAttribute({ name: MetaConstants.TabNav })}\n ref={ref}\n >\n <BaseBox display=\"flex\" width=\"100%\" position=\"relative\">\n <BaseBox display=\"flex\" flexDirection=\"row\" width=\"max-content\">\n {children({ items: _items, overflowingItems })}\n </BaseBox>\n </BaseBox>\n </BaseBox>\n </TabNavContext.Provider>\n );\n};\n\nexport { TabNav, TabNavItems };\n"],"names":["TabNavItems","_ref","children","props","_objectWithoutProperties","_excluded","_jsxs","Box","_objectSpread","display","width","gap","position","left","React","Children","map","child","index","_Fragment","_jsx","Divider","margin","variant","orientation","height","makeSize","size","cloneElement","__isInsideTabNavItems","__index","TabNav","_ref2","items","styledProps","_excluded2","ref","useRef","_React$useState","useState","_React$useState2","_slicedToArray","controlledItems","setControlledItems","overflowingItems","filter","item","_item$isAlwaysOverflo","isAlwaysOverflowing","isOverflowing","_items","resizeCallback","useCallback","resizeInfo","target","updateItems","padding","offset","offsetX","getBoundingClientRect","offsetWidth","flushSync","ReactDOM","toString","undefined","useResize","TabNavContext","Provider","value","containerRef","BaseBox","as","alignItems","alignSelf","getStyledProps","metaAttribute","name","MetaConstants","flexDirection"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,IAAMA,WAAW,GAAG,SAAdA,WAAWA,CAAAC,IAAA,EAA6D;AAAA,EAAA,IAAvDC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;AAAKC,IAAAA,KAAK,GAAAC,wBAAA,CAAAH,IAAA,EAAAI,SAAA,CAAA,CAAA;EACvC,oBACEC,IAAA,CAACC,GAAG,EAAAC,aAAA,CAAAA,aAAA,KAAKL,KAAK,CAAA,EAAA,EAAA,EAAA;AAAEM,IAAAA,OAAO,EAAC,MAAM;AAACC,IAAAA,KAAK,EAAC,MAAM;AAACC,IAAAA,GAAG,EAAC,WAAW;AAACC,IAAAA,QAAQ,EAAC,UAAU;AAACC,IAAAA,IAA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ACZ8D,MAAAA,UAAU,EAAC,QAAQ;AACnBC,MAAAA,SAAS,EAAC,KAAK;AACf7D,MAAAA,QAAQ,EAAC,UAAA;AAAU,KAAA,EACf8D,cAAc,CAACxC,WAAW,CAAC,CAAA,EAC3ByC,aAAa,CAAC;MAAEC,IAAI,EAAEC,aAAa,CAAC9C,MAAAA;AAAO,KAAC,CAAC,CAAA,EAAA,EAAA,EAAA;AACjDK,MAAAA,GAAG,EAAEA,GAAI;MAAAlC,QAAA,eAETkB,GAAA,CAACkD,OAAO,EAAA;AAAC7D,QAAAA,OAAO,EAAC,MAAM;AAACC,QAAAA,KAAK,EAAC,MAAM;AAACE,QAAAA,QAAQ,EAAC,UAAU;QAAAV,QAAA,eACtDkB,GAAA,CAACkD,OAAO,EAAA;AAAC7D,UAAAA,OAAO,EAAC,MAAM;AAACqE,UAAAA,aAAa,EAAC,KAAK;AAACpE,UAAAA,KAAK,EAAC,aAAa;UAAAR,QAAA,EAC5DA,QAAQ,CAAC;AAAE+B,YAAAA,KAAK,EAAEiB,MAAM;AAAEN,YAAAA,gBAAgB,EAAhBA,gBAAAA;WAAkB,CAAA;SACtC,CAAA;OACF,CAAA;KACF,CAAA,CAAA;AAAC,GACY,CAAC,CAAA;AAE7B;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"TabNavContext.js","sources":["../../../../../../../src/components/TopNav/TabNav/TabNavContext.tsx"],"sourcesContent":["import React from 'react';\nimport { throwBladeError } from '~utils/logger';\n\ntype TabNavContextProps = {\n containerRef: React.RefObject<HTMLDivElement>;\n hasOverflow: boolean;\n};\nconst TabNavContext = React.createContext<TabNavContextProps | null>(null);\n\nconst useTabNavContext = (): TabNavContextProps => {\n const context = React.useContext(TabNavContext);\n if (!context) {\n throwBladeError({\n message: 'useTabNavContext must be used within a TabNavProvider',\n moduleName: 'TabNav',\n });\n }\n return context!;\n};\n\nexport { TabNavContext, useTabNavContext };\n"],"names":["TabNavContext","React","createContext","useTabNavContext","context","useContext","throwBladeError","message","moduleName"],"mappings":";;;;AAOA,IAAMA,aAAa,gBAAGC,cAAK,CAACC,aAAa,CAA4B,IAAI,EAAC;AAE1E,IAAMC,gBAAgB,GAAG,SAAnBA,gBAAgBA,GAA6B;AACjD,EAAA,IAAMC,OAAO,GAAGH,cAAK,CAACI,UAAU,CAACL,aAAa,CAAC,CAAA;EAC/C,IAAI,CAACI,OAAO,EAAE;AACZE,IAAAA,eAAe,CAAC;AACdC,MAAAA,OAAO,EAAE,uDAAuD;AAChEC,MAAAA,UAAU,EAAE,QAAA;AACd,KAAC,CAAC,CAAA;AACJ,GAAA;AACA,EAAA,OAAOJ,OAAO,CAAA;AAChB;;;;"}
1
+ {"version":3,"file":"TabNavContext.js","sources":["../../../../../../../src/components/TopNav/TabNav/TabNavContext.tsx"],"sourcesContent":["import React from 'react';\nimport type { TabNavItemData } from './types';\nimport { throwBladeError } from '~utils/logger';\n\ntype TabNavContextProps = {\n containerRef: React.RefObject<HTMLDivElement>;\n controlledItems: TabNavItemData[];\n setControlledItems: React.Dispatch<React.SetStateAction<TabNavItemData[]>>;\n};\nconst TabNavContext = React.createContext<TabNavContextProps | null>(null);\n\nconst useTabNavContext = (): TabNavContextProps => {\n const context = React.useContext(TabNavContext);\n if (!context) {\n throwBladeError({\n message: 'useTabNavContext must be used within a TabNavProvider',\n moduleName: 'TabNav',\n });\n }\n return context!;\n};\n\nexport { TabNavContext, useTabNavContext };\n"],"names":["TabNavContext","React","createContext","useTabNavContext","context","useContext","throwBladeError","message","moduleName"],"mappings":";;;;AASA,IAAMA,aAAa,gBAAGC,cAAK,CAACC,aAAa,CAA4B,IAAI,EAAC;AAE1E,IAAMC,gBAAgB,GAAG,SAAnBA,gBAAgBA,GAA6B;AACjD,EAAA,IAAMC,OAAO,GAAGH,cAAK,CAACI,UAAU,CAACL,aAAa,CAAC,CAAA;EAC/C,IAAI,CAACI,OAAO,EAAE;AACZE,IAAAA,eAAe,CAAC;AACdC,MAAAA,OAAO,EAAE,uDAAuD;AAChEC,MAAAA,UAAU,EAAE,QAAA;AACd,KAAC,CAAC,CAAA;AACJ,GAAA;AACA,EAAA,OAAOJ,OAAO,CAAA;AAChB;;;;"}
@@ -2,7 +2,6 @@ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProper
2
2
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
3
3
  import React__default from 'react';
4
4
  import styled from 'styled-components';
5
- import { useTopNavContext } from '../TopNavContext.js';
6
5
  import { useTabNavContext } from './TabNavContext.js';
7
6
  import { MIXED_BG_COLOR } from './utils.js';
8
7
  import '../../Box/BaseBox/index.js';
@@ -11,10 +10,8 @@ import '../../../utils/index.js';
11
10
  import '../../../utils/assignWithoutSideEffects/index.js';
12
11
  import '../../../utils/makeAccessible/index.js';
13
12
  import '../../../tokens/global/index.js';
14
- import { useIsomorphicLayoutEffect } from '../../../utils/useIsomorphicLayoutEffect.js';
15
- import { mergeRefs } from '../../../utils/useMergeRefs.js';
16
- import getIn from '../../../utils/lodashButBetter/get.js';
17
13
  import '../../../utils/metaAttribute/index.js';
14
+ import { useIsomorphicLayoutEffect } from '../../../utils/useIsomorphicLayoutEffect.js';
18
15
  import { jsxs, jsx } from 'react/jsx-runtime';
19
16
  import { makeSpace } from '../../../utils/makeSpace/makeSpace.js';
20
17
  import { makeBorderSize } from '../../../utils/makeBorderSize/makeBorderSize.js';
@@ -27,7 +24,7 @@ import { MetaConstants } from '../../../utils/metaAttribute/metaConstants.js';
27
24
  import { makeAccessible } from '../../../utils/makeAccessible/makeAccessible.web.js';
28
25
  import { assignWithoutSideEffects } from '../../../utils/assignWithoutSideEffects/assignWithoutSideEffects.js';
29
26
 
30
- var _excluded = ["as", "children", "isActive", "icon", "trailing", "accessibilityLabel", "href", "target"];
27
+ var _excluded = ["as", "title", "isActive", "icon", "trailing", "accessibilityLabel", "href", "target", "__isInsideTabNavItems", "__index"];
31
28
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
32
29
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
33
30
  var StyledTabNavItem = /*#__PURE__*/styled.a.withConfig({
@@ -55,6 +52,12 @@ var StyledTabNavItem = /*#__PURE__*/styled.a.withConfig({
55
52
  paddingLeft: makeSpace(theme.spacing[4]),
56
53
  paddingRight: makeSpace(theme.spacing[4]),
57
54
  borderRadius: makeBorderSize(theme.border.radius.medium),
55
+ // reset button styles
56
+ border: 'none',
57
+ background: 'none',
58
+ '&[aria-expanded="true"]': $isActive ? {} : {
59
+ backgroundColor: theme.colors.interactive.background.gray["default"]
60
+ },
58
61
  '&:hover': $isActive ? {} : {
59
62
  backgroundColor: theme.colors.interactive.background.gray["default"]
60
63
  }
@@ -65,16 +68,15 @@ var StyledTabNavItemWrapper = /*#__PURE__*/styled(BaseBox).withConfig({
65
68
  componentId: "sc-1eiaez7-1"
66
69
  })(function (_ref2) {
67
70
  var theme = _ref2.theme,
68
- isActive = _ref2.isActive,
69
- dividerHiderColor = _ref2.dividerHiderColor;
71
+ isActive = _ref2.isActive;
70
72
  var dividerHiderStyle = {
71
73
  content: '""',
72
74
  position: 'absolute',
73
75
  top: '50%',
74
76
  transform: 'translateY(-50%)',
75
77
  width: makeSize(size[1]),
76
- height: '50%',
77
- backgroundColor: getIn(theme.colors, dividerHiderColor, MIXED_BG_COLOR)
78
+ height: makeSize(size[16]),
79
+ backgroundColor: MIXED_BG_COLOR
78
80
  };
79
81
  return _objectSpread({
80
82
  position: 'relative',
@@ -83,14 +85,12 @@ var StyledTabNavItemWrapper = /*#__PURE__*/styled(BaseBox).withConfig({
83
85
  backgroundColor: isActive ? theme.colors.surface.background.gray.intense : 'transparent',
84
86
  borderColor: isActive ? theme.colors.surface.border.gray.muted : 'transparent',
85
87
  borderStyle: 'solid',
86
- borderBottomWidth: 0,
87
88
  borderWidth: makeBorderSize(theme.border.width.thin),
89
+ borderBottomWidth: 0,
88
90
  borderTopLeftRadius: makeBorderSize(theme.border.radius.medium),
89
91
  borderTopRightRadius: makeBorderSize(theme.border.radius.medium),
90
- // Animation
91
- transform: isActive ? "translateY(".concat(makeSize(size[2]), ")") : 'none',
92
92
  transition: "".concat(makeMotionTime(theme.motion.duration.moderate), " ").concat(theme.motion.easing.standard.effective),
93
- transitionProperty: 'background, transform'
93
+ transitionProperty: 'background'
94
94
  }, isActive ? {
95
95
  ':before, :after': dividerHiderStyle,
96
96
  ':before': {
@@ -125,56 +125,49 @@ var SelectedBar = /*#__PURE__*/styled(BaseBox).withConfig({
125
125
  });
126
126
  var _TabNavItem = function _TabNavItem(_ref4, ref) {
127
127
  var as = _ref4.as,
128
- children = _ref4.children,
128
+ title = _ref4.title,
129
129
  isActive = _ref4.isActive,
130
130
  Icon = _ref4.icon,
131
131
  trailing = _ref4.trailing,
132
132
  accessibilityLabel = _ref4.accessibilityLabel,
133
133
  href = _ref4.href,
134
134
  target = _ref4.target,
135
+ __isInsideTabNavItems = _ref4.__isInsideTabNavItems,
136
+ __index = _ref4.__index,
135
137
  props = _objectWithoutProperties(_ref4, _excluded);
136
138
  var _useTabNavContext = useTabNavContext(),
137
- containerRef = _useTabNavContext.containerRef,
138
- hasOverflow = _useTabNavContext.hasOverflow;
139
- var _useTopNavContext = useTopNavContext(),
140
- backgroundColor = _useTopNavContext.backgroundColor;
141
- var linkRef = React__default.useRef(null);
139
+ setControlledItems = _useTabNavContext.setControlledItems;
140
+ var bodyRef = React__default.useRef(null);
142
141
 
143
- // Scroll the active tab into view
144
- // Only if the tab is very close to the edge
145
- // Or if the tab is out of view
142
+ // Update the controlledItems with the tabWidth and offsetX
146
143
  useIsomorphicLayoutEffect(function () {
147
- if (!isActive || !hasOverflow) return;
148
- if (!('requestAnimationFrame' in window)) return;
149
- window.requestAnimationFrame(function () {
150
- if (!linkRef.current || !containerRef.current) return;
151
- var buffer = 100;
152
- var container = containerRef.current;
153
- var linkElement = linkRef.current;
154
- var containerRect = container.getBoundingClientRect();
155
- var linkRect = linkElement.getBoundingClientRect();
156
- var isCloseToStart = linkRect.left < containerRect.left + buffer;
157
- var isCloseToEnd = linkRect.right > containerRect.right - buffer;
158
- if (isCloseToStart || isCloseToEnd) {
159
- linkElement.scrollIntoView({
160
- behavior: 'smooth',
161
- inline: 'center',
162
- block: 'nearest'
144
+ if (!bodyRef.current) return;
145
+ if (!__isInsideTabNavItems) return;
146
+ setControlledItems(function (prev) {
147
+ return prev.map(function (item, index) {
148
+ var _bodyRef$current;
149
+ if (index !== __index) return item;
150
+ var bounds = bodyRef === null || bodyRef === void 0 ? void 0 : (_bodyRef$current = bodyRef.current) === null || _bodyRef$current === void 0 ? void 0 : _bodyRef$current.getBoundingClientRect();
151
+ var tabWidth = bounds.width;
152
+ var offsetX = bounds.right;
153
+ return _objectSpread(_objectSpread({}, item), {}, {
154
+ tabWidth: tabWidth,
155
+ offsetX: offsetX
163
156
  });
164
- }
157
+ });
165
158
  });
166
- }, [hasOverflow, isActive]);
159
+ }, [__isInsideTabNavItems, __index, setControlledItems]);
167
160
  return /*#__PURE__*/jsxs(StyledTabNavItemWrapper, _objectSpread(_objectSpread({
168
- isActive: isActive,
169
- dividerHiderColor: backgroundColor
161
+ ref: bodyRef,
162
+ isActive: isActive
170
163
  }, metaAttribute({
171
164
  name: MetaConstants.TabNavItem
172
165
  })), {}, {
173
166
  children: [/*#__PURE__*/jsx(SelectedBar, {
174
167
  isActive: isActive
175
168
  }), /*#__PURE__*/jsxs(StyledTabNavItem, _objectSpread(_objectSpread(_objectSpread({
176
- ref: mergeRefs(ref, linkRef),
177
- as: as !== null && as !== void 0 ? as : 'a',
169
+ ref: ref,
170
+ as: as !== null && as !== void 0 ? as : href ? 'a' : 'button',
178
171
  to: href,
179
172
  href: as ? undefined : href,
180
173
  target: target,
@@ -186,7 +179,7 @@ var _TabNavItem = function _TabNavItem(_ref4, ref) {
186
179
  children: [Icon ? /*#__PURE__*/jsx(Icon, {
187
180
  size: "large",
188
181
  color: isActive ? 'interactive.icon.gray.normal' : 'surface.icon.gray.subtle'
189
- }) : null, children, trailing ? trailing : null]
182
+ }) : null, title, trailing ? trailing : null]
190
183
  }))]
191
184
  }));
192
185
  };