@elliemae/ds-tabs 1.60.0 → 2.0.0-alpha.12

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 (130) hide show
  1. package/cjs/DSTabs.js +29 -150
  2. package/cjs/DSTabsCTX.js +30 -0
  3. package/cjs/DSTabsDatatestid.js +18 -0
  4. package/cjs/DSTabsTypes.js +2 -0
  5. package/cjs/config/useCrossRef.js +17 -0
  6. package/cjs/config/useTabs.js +51 -0
  7. package/cjs/defaultProps.js +27 -0
  8. package/cjs/exportsRelated/DSTab.js +32 -0
  9. package/cjs/index.js +5 -35
  10. package/cjs/parts/carousel/Carousel.js +71 -0
  11. package/cjs/parts/carousel/styles.js +60 -0
  12. package/cjs/parts/carousel/useCarousel.js +78 -0
  13. package/cjs/parts/carousel/useCarouselCallbacks.js +72 -0
  14. package/cjs/parts/tabBar/TabBar.js +160 -0
  15. package/cjs/parts/tabBar/styles.js +199 -0
  16. package/cjs/parts/tabBar/useTabBar.js +98 -0
  17. package/cjs/parts/tabsContent/TabsContent.js +49 -0
  18. package/cjs/parts/tabsContent/styles.js +15 -0
  19. package/cjs/parts/tabsPanel/TabsPanels.js +77 -0
  20. package/cjs/parts/tabsPanel/styles.js +25 -0
  21. package/cjs/propTypes.js +33 -0
  22. package/cjs/utils/constants.js +29 -0
  23. package/cjs/utils/helpers.js +47 -0
  24. package/cjs/utils/hooks/useKeyboardNavigation.js +61 -0
  25. package/cjs/utils/hooks/useTabsCallbacks.js +59 -0
  26. package/esm/DSTabs.js +31 -152
  27. package/esm/DSTabsCTX.js +25 -0
  28. package/esm/DSTabsDatatestid.js +14 -0
  29. package/esm/DSTabsTypes.js +1 -0
  30. package/esm/config/useCrossRef.js +13 -0
  31. package/esm/config/useTabs.js +47 -0
  32. package/esm/defaultProps.js +23 -0
  33. package/esm/exportsRelated/DSTab.js +21 -0
  34. package/esm/index.js +4 -33
  35. package/esm/parts/carousel/Carousel.js +63 -0
  36. package/esm/parts/carousel/styles.js +49 -0
  37. package/esm/parts/carousel/useCarousel.js +70 -0
  38. package/esm/parts/carousel/useCarouselCallbacks.js +68 -0
  39. package/esm/parts/tabBar/TabBar.js +151 -0
  40. package/esm/parts/tabBar/styles.js +185 -0
  41. package/esm/parts/tabBar/useTabBar.js +90 -0
  42. package/esm/parts/tabsContent/TabsContent.js +40 -0
  43. package/esm/parts/tabsContent/styles.js +7 -0
  44. package/esm/parts/tabsPanel/TabsPanels.js +67 -0
  45. package/esm/parts/tabsPanel/styles.js +17 -0
  46. package/esm/propTypes.js +28 -0
  47. package/esm/utils/constants.js +21 -0
  48. package/esm/utils/helpers.js +37 -0
  49. package/esm/utils/hooks/useKeyboardNavigation.js +57 -0
  50. package/esm/utils/hooks/useTabsCallbacks.js +55 -0
  51. package/package.json +134 -18
  52. package/types/DSTabs.d.ts +14 -0
  53. package/types/DSTabsCTX.d.ts +4 -0
  54. package/types/DSTabsDatatestid.d.ts +12 -0
  55. package/types/DSTabsTypes.d.ts +202 -0
  56. package/types/config/useCrossRef.d.ts +2 -0
  57. package/types/config/useTabs.d.ts +2 -0
  58. package/types/defaultProps.d.ts +2 -0
  59. package/types/exportsRelated/DSTab.d.ts +14 -0
  60. package/types/index.d.ts +5 -0
  61. package/types/parts/carousel/Carousel.d.ts +3 -0
  62. package/types/parts/carousel/styles.d.ts +9 -0
  63. package/types/parts/carousel/useCarousel.d.ts +2 -0
  64. package/types/parts/carousel/useCarouselCallbacks.d.ts +2 -0
  65. package/types/parts/tabBar/TabBar.d.ts +2 -0
  66. package/types/parts/tabBar/styles.d.ts +7 -0
  67. package/types/parts/tabBar/useTabBar.d.ts +2 -0
  68. package/types/parts/tabsContent/TabsContent.d.ts +2 -0
  69. package/types/parts/tabsContent/styles.d.ts +1 -0
  70. package/types/parts/tabsPanel/TabsPanels.d.ts +2 -0
  71. package/types/parts/tabsPanel/styles.d.ts +2 -0
  72. package/types/propTypes.d.ts +54 -0
  73. package/types/tests/DSTabs.callbacks.test.d.ts +1 -0
  74. package/types/tests/DSTabs.func.test.d.ts +1 -0
  75. package/types/tests/DSTabs.keyboard.test.d.ts +1 -0
  76. package/types/tests/DSTabs.test.d.ts +1 -0
  77. package/types/utils/constants.d.ts +19 -0
  78. package/types/utils/helpers.d.ts +8 -0
  79. package/types/utils/hooks/useKeyboardNavigation.d.ts +2 -0
  80. package/types/utils/hooks/useTabsCallbacks.d.ts +2 -0
  81. package/Carousel/package.json +0 -10
  82. package/DSTab/package.json +0 -10
  83. package/DSTabs/package.json +0 -10
  84. package/PanelContainer/package.json +0 -10
  85. package/SubTabBar/package.json +0 -10
  86. package/TabBar/package.json +0 -10
  87. package/TabTypes/package.json +0 -10
  88. package/TabsImpl/package.json +0 -10
  89. package/TabsPanels/package.json +0 -10
  90. package/cjs/Carousel.js +0 -219
  91. package/cjs/Carousel.js.map +0 -1
  92. package/cjs/DSTab.js +0 -50
  93. package/cjs/DSTab.js.map +0 -1
  94. package/cjs/DSTabs.js.map +0 -1
  95. package/cjs/PanelContainer.js +0 -45
  96. package/cjs/PanelContainer.js.map +0 -1
  97. package/cjs/SubTabBar.js +0 -81
  98. package/cjs/SubTabBar.js.map +0 -1
  99. package/cjs/TabBar.js +0 -480
  100. package/cjs/TabBar.js.map +0 -1
  101. package/cjs/TabTypes.js +0 -17
  102. package/cjs/TabTypes.js.map +0 -1
  103. package/cjs/TabsImpl.js +0 -173
  104. package/cjs/TabsImpl.js.map +0 -1
  105. package/cjs/TabsPanels.js +0 -116
  106. package/cjs/TabsPanels.js.map +0 -1
  107. package/cjs/index.js.map +0 -1
  108. package/cjs/useResize.js +0 -25
  109. package/cjs/useResize.js.map +0 -1
  110. package/esm/Carousel.js +0 -209
  111. package/esm/Carousel.js.map +0 -1
  112. package/esm/DSTab.js +0 -40
  113. package/esm/DSTab.js.map +0 -1
  114. package/esm/DSTabs.js.map +0 -1
  115. package/esm/PanelContainer.js +0 -37
  116. package/esm/PanelContainer.js.map +0 -1
  117. package/esm/SubTabBar.js +0 -74
  118. package/esm/SubTabBar.js.map +0 -1
  119. package/esm/TabBar.js +0 -464
  120. package/esm/TabBar.js.map +0 -1
  121. package/esm/TabTypes.js +0 -12
  122. package/esm/TabTypes.js.map +0 -1
  123. package/esm/TabsImpl.js +0 -163
  124. package/esm/TabsImpl.js.map +0 -1
  125. package/esm/TabsPanels.js +0 -103
  126. package/esm/TabsPanels.js.map +0 -1
  127. package/esm/index.js.map +0 -1
  128. package/esm/useResize.js +0 -21
  129. package/esm/useResize.js.map +0 -1
  130. package/useResize/package.json +0 -10
package/esm/DSTabs.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"DSTabs.js","sources":["../../src/DSTabs.tsx"],"sourcesContent":["/* eslint-disable react/no-unused-prop-types */\nimport React from 'react';\nimport { PropTypes, describe } from 'react-desc';\nimport { TabTypes } from './TabTypes';\nimport TabsImpl from './TabsImpl';\nimport DSTab from './DSTab';\n\nconst DSTabs = ({\n containerProps = {},\n innerRef,\n animated = true,\n enableMouseEvents = false,\n allowTextSelection = false,\n onTabChange = () => null,\n tabsListAriaLabel = 'Tab list',\n type = TabTypes.NORMAL,\n tabBarExtraContent = undefined,\n children: tabs,\n onlyRenderActiveTab = false,\n activeTab,\n withCarousel = false,\n firstSubtabRef,\n lastTabRef,\n flexibleTabsHeaders,\n fixedTabsHeaders,\n isDSMobile = false,\n}) => (\n <TabsImpl\n activeTab={activeTab}\n firstSubtabRef={firstSubtabRef}\n lastTabRef={lastTabRef}\n allowTextSelection={allowTextSelection}\n animated={animated}\n containerProps={containerProps}\n enableMouseEvents={enableMouseEvents}\n innerRef={innerRef}\n onlyRenderActiveTab={onlyRenderActiveTab}\n onTabChange={onTabChange}\n tabBarExtraContent={tabBarExtraContent}\n tabsListAriaLabel={tabsListAriaLabel}\n type={type}\n withCarousel={withCarousel}\n flexibleTabsHeaders={flexibleTabsHeaders}\n fixedTabsHeaders={fixedTabsHeaders}\n isDSMobile={isDSMobile}\n >\n {tabs}\n </TabsImpl>\n);\n\nconst props = {\n /** Whether the tab transition should animate or not */\n animated: PropTypes.bool.description(\n 'Whether the tab transition should animate or not',\n ),\n /** Enables tab transition with mouse drag events */\n enableMouseEvents: PropTypes.bool.description(\n 'Enables tab transition with mouse drag events',\n ),\n /** Allow text selection when mouse drag events are active */\n allowTextSelection: PropTypes.bool.description(\n 'Allow text selection when mouse drag events are active',\n ),\n /** Handler when a user clicks on a different tab */\n onTabChange: PropTypes.func.description(\n 'Handler when a user clicks on a different tab',\n ),\n /** Tab type */\n type: PropTypes.oneOf(['normal', 'subtabs']).description('Tab type'),\n /** Extra content next to the tabs pills */\n tabBarExtraContent: PropTypes.element.description(\n 'Extra content next to the tabs pills',\n ),\n /** Only renders the active tab in the DOM */\n onlyRenderActiveTab: PropTypes.bool.description(\n 'Only renders the active tab in the DOM',\n ),\n /** Mobile only flexible tabs mode */\n flexibleTabsHeaders: PropTypes.bool.description(\n 'Mobile only flexible tabs mode',\n ),\n /** Mobile only fixed tabs mode */\n fixedTabsHeaders: PropTypes.bool.description('Mobile only fixed tabs mode'),\n /** Whether or not it's a ds-tab from DSMobile tabs */\n isDSMobile: PropTypes.bool.description(\n \"Whether or not it's a ds-tab from DSMobile tabs\",\n ),\n /** Activate carousel behavior */\n withCarousel: PropTypes.bool.description('Activate carousel behavior'),\n /** The active tabId */\n activeTab: PropTypes.string.description('The active tabId'),\n /** tabs children */\n children: PropTypes.arrayOf(\n PropTypes.shape({\n type: PropTypes.instanceOf([\n PropTypes.instanceOf(DSTab),\n PropTypes.array,\n ]),\n }),\n ).isRequired.description('tabs children'),\n /** Aria label for the list */\n tabsListAriaLabel: PropTypes.string.description('Aria label for the list'),\n /** Additional properties for the container */\n containerProps: PropTypes.object.description(\n 'Additional properties for the container',\n ),\n /** REF */\n innerRef: PropTypes.oneOfType([\n PropTypes.func,\n PropTypes.shape({ current: PropTypes.any }),\n ]).description('REF'),\n /** internal ref to handle keyboard a11y behavior */\n firstSubtabRef: PropTypes.oneOfType([\n PropTypes.func,\n PropTypes.shape({ current: PropTypes.any }),\n ]).description('internal ref to handle keyboard a11y behavior'),\n /** internal ref to handle keyboard a11y behavior */\n lastTabRef: PropTypes.oneOfType([\n PropTypes.func,\n PropTypes.shape({ current: PropTypes.any }),\n ]).description('internal ref to handle keyboard a11y behavior'),\n};\n\nDSTabs.propTypes = props;\nconst DSTabsWithSchema = describe(DSTabs);\nDSTabsWithSchema.propTypes = props;\n\nexport { DSTabs, DSTabsWithSchema };\nexport default DSTabs;\n"],"names":["DSTabs","containerProps","innerRef","animated","enableMouseEvents","allowTextSelection","onTabChange","tabsListAriaLabel","type","TabTypes","NORMAL","tabBarExtraContent","undefined","tabs","children","onlyRenderActiveTab","activeTab","withCarousel","firstSubtabRef","lastTabRef","flexibleTabsHeaders","fixedTabsHeaders","isDSMobile","props","PropTypes","bool","description","func","oneOf","element","string","arrayOf","shape","instanceOf","DSTab","array","isRequired","object","oneOfType","current","any","propTypes","DSTabsWithSchema","describe"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;IAOMA,MAAM,GAAG,SAATA,MAAS;AAAA,iCACbC,cADa;AAAA,MACbA,cADa,oCACI,EADJ;AAAA,MAEbC,QAFa,QAEbA,QAFa;AAAA,2BAGbC,QAHa;AAAA,MAGbA,QAHa,8BAGF,IAHE;AAAA,mCAIbC,iBAJa;AAAA,MAIbA,iBAJa,sCAIO,KAJP;AAAA,mCAKbC,kBALa;AAAA,MAKbA,kBALa,sCAKQ,KALR;AAAA,8BAMbC,WANa;AAAA,MAMbA,WANa,iCAMC;AAAA,WAAM,IAAN;AAAA,GAND;AAAA,mCAObC,iBAPa;AAAA,MAObA,iBAPa,sCAOO,UAPP;AAAA,uBAQbC,IARa;AAAA,MAQbA,IARa,0BAQNC,QAAQ,CAACC,MARH;AAAA,mCASbC,kBATa;AAAA,MASbA,kBATa,sCASQC,SATR;AAAA,MAUHC,IAVG,QAUbC,QAVa;AAAA,mCAWbC,mBAXa;AAAA,MAWbA,mBAXa,sCAWS,KAXT;AAAA,MAYbC,SAZa,QAYbA,SAZa;AAAA,+BAabC,YAba;AAAA,MAabA,YAba,kCAaE,KAbF;AAAA,MAcbC,cAda,QAcbA,cAda;AAAA,MAebC,UAfa,QAebA,UAfa;AAAA,MAgBbC,mBAhBa,QAgBbA,mBAhBa;AAAA,MAiBbC,gBAjBa,QAiBbA,gBAjBa;AAAA,6BAkBbC,UAlBa;AAAA,MAkBbA,UAlBa,gCAkBA,KAlBA;AAAA,sBAoBb,oBAAC,QAAD;AACE,IAAA,SAAS,EAAEN,SADb;AAEE,IAAA,cAAc,EAAEE,cAFlB;AAGE,IAAA,UAAU,EAAEC,UAHd;AAIE,IAAA,kBAAkB,EAAEd,kBAJtB;AAKE,IAAA,QAAQ,EAAEF,QALZ;AAME,IAAA,cAAc,EAAEF,cANlB;AAOE,IAAA,iBAAiB,EAAEG,iBAPrB;AAQE,IAAA,QAAQ,EAAEF,QARZ;AASE,IAAA,mBAAmB,EAAEa,mBATvB;AAUE,IAAA,WAAW,EAAET,WAVf;AAWE,IAAA,kBAAkB,EAAEK,kBAXtB;AAYE,IAAA,iBAAiB,EAAEJ,iBAZrB;AAaE,IAAA,IAAI,EAAEC,IAbR;AAcE,IAAA,YAAY,EAAES,YAdhB;AAeE,IAAA,mBAAmB,EAAEG,mBAfvB;AAgBE,IAAA,gBAAgB,EAAEC,gBAhBpB;AAiBE,IAAA,UAAU,EAAEC;AAjBd,KAmBGT,IAnBH,CApBa;AAAA;;AA2Cf,IAAMU,KAAK,GAAG;AACZ;AACApB,EAAAA,QAAQ,EAAEqB,SAAS,CAACC,IAAV,CAAeC,WAAf,CACR,kDADQ,CAFE;;AAKZ;AACAtB,EAAAA,iBAAiB,EAAEoB,SAAS,CAACC,IAAV,CAAeC,WAAf,CACjB,+CADiB,CANP;;AASZ;AACArB,EAAAA,kBAAkB,EAAEmB,SAAS,CAACC,IAAV,CAAeC,WAAf,CAClB,wDADkB,CAVR;;AAaZ;AACApB,EAAAA,WAAW,EAAEkB,SAAS,CAACG,IAAV,CAAeD,WAAf,CACX,+CADW,CAdD;;AAiBZ;AACAlB,EAAAA,IAAI,EAAEgB,SAAS,CAACI,KAAV,CAAgB,CAAC,QAAD,EAAW,SAAX,CAAhB,EAAuCF,WAAvC,CAAmD,UAAnD,CAlBM;;AAmBZ;AACAf,EAAAA,kBAAkB,EAAEa,SAAS,CAACK,OAAV,CAAkBH,WAAlB,CAClB,sCADkB,CApBR;;AAuBZ;AACAX,EAAAA,mBAAmB,EAAES,SAAS,CAACC,IAAV,CAAeC,WAAf,CACnB,wCADmB,CAxBT;;AA2BZ;AACAN,EAAAA,mBAAmB,EAAEI,SAAS,CAACC,IAAV,CAAeC,WAAf,CACnB,gCADmB,CA5BT;;AA+BZ;AACAL,EAAAA,gBAAgB,EAAEG,SAAS,CAACC,IAAV,CAAeC,WAAf,CAA2B,6BAA3B,CAhCN;;AAiCZ;AACAJ,EAAAA,UAAU,EAAEE,SAAS,CAACC,IAAV,CAAeC,WAAf,CACV,iDADU,CAlCA;;AAqCZ;AACAT,EAAAA,YAAY,EAAEO,SAAS,CAACC,IAAV,CAAeC,WAAf,CAA2B,4BAA3B,CAtCF;;AAuCZ;AACAV,EAAAA,SAAS,EAAEQ,SAAS,CAACM,MAAV,CAAiBJ,WAAjB,CAA6B,kBAA7B,CAxCC;;AAyCZ;AACAZ,EAAAA,QAAQ,EAAEU,SAAS,CAACO,OAAV,CACRP,SAAS,CAACQ,KAAV,CAAgB;AACdxB,IAAAA,IAAI,EAAEgB,SAAS,CAACS,UAAV,CAAqB,CACzBT,SAAS,CAACS,UAAV,CAAqBC,KAArB,CADyB,EAEzBV,SAAS,CAACW,KAFe,CAArB;AADQ,GAAhB,CADQ,EAORC,UAPQ,CAOGV,WAPH,CAOe,eAPf,CA1CE;;AAkDZ;AACAnB,EAAAA,iBAAiB,EAAEiB,SAAS,CAACM,MAAV,CAAiBJ,WAAjB,CAA6B,yBAA7B,CAnDP;;AAoDZ;AACAzB,EAAAA,cAAc,EAAEuB,SAAS,CAACa,MAAV,CAAiBX,WAAjB,CACd,yCADc,CArDJ;;AAwDZ;AACAxB,EAAAA,QAAQ,EAAEsB,SAAS,CAACc,SAAV,CAAoB,CAC5Bd,SAAS,CAACG,IADkB,EAE5BH,SAAS,CAACQ,KAAV,CAAgB;AAAEO,IAAAA,OAAO,EAAEf,SAAS,CAACgB;AAArB,GAAhB,CAF4B,CAApB,EAGPd,WAHO,CAGK,KAHL,CAzDE;;AA6DZ;AACAR,EAAAA,cAAc,EAAEM,SAAS,CAACc,SAAV,CAAoB,CAClCd,SAAS,CAACG,IADwB,EAElCH,SAAS,CAACQ,KAAV,CAAgB;AAAEO,IAAAA,OAAO,EAAEf,SAAS,CAACgB;AAArB,GAAhB,CAFkC,CAApB,EAGbd,WAHa,CAGD,+CAHC,CA9DJ;;AAkEZ;AACAP,EAAAA,UAAU,EAAEK,SAAS,CAACc,SAAV,CAAoB,CAC9Bd,SAAS,CAACG,IADoB,EAE9BH,SAAS,CAACQ,KAAV,CAAgB;AAAEO,IAAAA,OAAO,EAAEf,SAAS,CAACgB;AAArB,GAAhB,CAF8B,CAApB,EAGTd,WAHS,CAGG,+CAHH;AAnEA,CAAd;AAyEA1B,MAAM,CAACyC,SAAP,GAAmBlB,KAAnB;IACMmB,gBAAgB,GAAGC,QAAQ,CAAC3C,MAAD;AACjC0C,gBAAgB,CAACD,SAAjB,GAA6BlB,KAA7B;;;;"}
@@ -1,37 +0,0 @@
1
- import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
2
- import React from 'react';
3
- import PropTypes from 'prop-types';
4
- import { aggregatedClasses } from '@elliemae/ds-classnames';
5
-
6
- var _excluded = ["children", "lastTabRef", "firstSubtabRef"];
7
- var blockName = 'tabs-panels';
8
- var PC = aggregatedClasses('div')(blockName, 'panel');
9
-
10
- var PanelContainer = function PanelContainer(_ref) {
11
- var children = _ref.children,
12
- lastTabRef = _ref.lastTabRef,
13
- firstSubtabRef = _ref.firstSubtabRef,
14
- rest = _objectWithoutProperties(_ref, _excluded);
15
-
16
- // inject ref to handle focus on first subtab child
17
- var child = React.Children.map(children, function (c, i) {
18
- return i === 0 && c ? /*#__PURE__*/React.cloneElement(c, {
19
- firstSubtabRef: firstSubtabRef,
20
- lastTabRef: lastTabRef
21
- }) : c;
22
- });
23
- return /*#__PURE__*/React.createElement(PC, rest, child);
24
- };
25
-
26
- PanelContainer.propTypes = {
27
- children: PropTypes.any,
28
- firstSubtabRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
29
- current: PropTypes.any
30
- })]),
31
- lastTabRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
32
- current: PropTypes.any
33
- })])
34
- };
35
-
36
- export { PanelContainer as default };
37
- //# sourceMappingURL=PanelContainer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PanelContainer.js","sources":["../../src/PanelContainer.tsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { aggregatedClasses } from '@elliemae/ds-classnames';\nconst blockName = 'tabs-panels';\n\nconst PC = aggregatedClasses('div')(blockName, 'panel');\n\nconst PanelContainer = ({ children, lastTabRef, firstSubtabRef, ...rest }) => {\n // inject ref to handle focus on first subtab child\n const child = React.Children.map(children, (c, i) =>\n i === 0 && c ? React.cloneElement(c, { firstSubtabRef, lastTabRef }) : c,\n );\n return <PC {...rest}>{child}</PC>;\n};\n\nPanelContainer.propTypes = {\n children: PropTypes.any,\n firstSubtabRef: PropTypes.oneOfType([\n PropTypes.func,\n PropTypes.shape({ current: PropTypes.any }),\n ]),\n lastTabRef: PropTypes.oneOfType([\n PropTypes.func,\n PropTypes.shape({ current: PropTypes.any }),\n ]),\n};\n\nexport default PanelContainer;\n"],"names":["blockName","PC","aggregatedClasses","PanelContainer","children","lastTabRef","firstSubtabRef","rest","child","React","Children","map","c","i","cloneElement","propTypes","PropTypes","any","oneOfType","func","shape","current"],"mappings":";;;;;;AAGA,IAAMA,SAAS,GAAG,aAAlB;AAEA,IAAMC,EAAE,GAAGC,iBAAiB,CAAC,KAAD,CAAjB,CAAyBF,SAAzB,EAAoC,OAApC,CAAX;;IAEMG,cAAc,GAAG,SAAjBA,cAAiB,OAAuD;AAAA,MAApDC,QAAoD,QAApDA,QAAoD;AAAA,MAA1CC,UAA0C,QAA1CA,UAA0C;AAAA,MAA9BC,cAA8B,QAA9BA,cAA8B;AAAA,MAAXC,IAAW;;AAC5E;AACA,MAAMC,KAAK,GAAGC,KAAK,CAACC,QAAN,CAAeC,GAAf,CAAmBP,QAAnB,EAA6B,UAACQ,CAAD,EAAIC,CAAJ;AAAA,WACzCA,CAAC,KAAK,CAAN,IAAWD,CAAX,gBAAeH,KAAK,CAACK,YAAN,CAAmBF,CAAnB,EAAsB;AAAEN,MAAAA,cAAc,EAAdA,cAAF;AAAkBD,MAAAA,UAAU,EAAVA;AAAlB,KAAtB,CAAf,GAAuEO,CAD9B;AAAA,GAA7B,CAAd;AAGA,sBAAO,oBAAC,EAAD,EAAQL,IAAR,EAAeC,KAAf,CAAP;AACD;;AAEDL,cAAc,CAACY,SAAf,GAA2B;AACzBX,EAAAA,QAAQ,EAAEY,SAAS,CAACC,GADK;AAEzBX,EAAAA,cAAc,EAAEU,SAAS,CAACE,SAAV,CAAoB,CAClCF,SAAS,CAACG,IADwB,EAElCH,SAAS,CAACI,KAAV,CAAgB;AAAEC,IAAAA,OAAO,EAAEL,SAAS,CAACC;AAArB,GAAhB,CAFkC,CAApB,CAFS;AAMzBZ,EAAAA,UAAU,EAAEW,SAAS,CAACE,SAAV,CAAoB,CAC9BF,SAAS,CAACG,IADoB,EAE9BH,SAAS,CAACI,KAAV,CAAgB;AAAEC,IAAAA,OAAO,EAAEL,SAAS,CAACC;AAArB,GAAhB,CAF8B,CAApB;AANa,CAA3B;;;;"}
package/esm/SubTabBar.js DELETED
@@ -1,74 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { aggregatedClasses } from '@elliemae/ds-classnames';
4
- import TabBar from './TabBar.js';
5
- import Carousel from './Carousel.js';
6
- import '@babel/runtime/helpers/esm/classCallCheck';
7
- import '@babel/runtime/helpers/esm/createClass';
8
- import '@babel/runtime/helpers/esm/assertThisInitialized';
9
- import '@babel/runtime/helpers/esm/inherits';
10
- import '@babel/runtime/helpers/esm/possibleConstructorReturn';
11
- import '@babel/runtime/helpers/esm/getPrototypeOf';
12
- import 'lodash';
13
- import '@elliemae/ds-form/RequiredMark';
14
- import 'memoize-one';
15
- import 'resize-observer';
16
- import 'styled-components';
17
- import '@babel/runtime/helpers/esm/slicedToArray';
18
- import '@elliemae/ds-icons';
19
- import '@elliemae/ds-button';
20
- import './useResize.js';
21
-
22
- var blockName = 'tabs-tab-bar';
23
- var SubTabList = aggregatedClasses('div')(blockName, 'subtabs-list', function (_ref) {
24
- var withCarousel = _ref.withCarousel;
25
- return {
26
- carousel: withCarousel
27
- };
28
- });
29
-
30
- var SubTabBar = function SubTabBar(_ref2) {
31
- var withCarousel = _ref2.withCarousel,
32
- _ref2$tabs = _ref2.tabs,
33
- tabs = _ref2$tabs === void 0 ? [] : _ref2$tabs,
34
- _ref2$activeTab = _ref2.activeTab,
35
- activeTab = _ref2$activeTab === void 0 ? '' : _ref2$activeTab,
36
- _ref2$onTabClick = _ref2.onTabClick,
37
- onTabClick = _ref2$onTabClick === void 0 ? function () {
38
- return null;
39
- } : _ref2$onTabClick,
40
- firstSubtabRef = _ref2.firstSubtabRef,
41
- handleUpArrow = _ref2.handleUpArrow;
42
- return /*#__PURE__*/React.createElement(TabBar, {
43
- activeTab: activeTab,
44
- onTabClick: onTabClick,
45
- handleUpArrow: handleUpArrow,
46
- firstSubtabRef: firstSubtabRef,
47
- renderCustomTabBar: function renderCustomTabBar(_ref3) {
48
- var tabsComponents = _ref3.tabsComponents,
49
- innerRef = _ref3.innerRef;
50
- return /*#__PURE__*/React.createElement(SubTabList, {
51
- withCarousel: withCarousel,
52
- innerRef: innerRef,
53
- "data-testid": "subtabs-list"
54
- }, withCarousel ? /*#__PURE__*/React.createElement(Carousel, null, tabsComponents) : tabsComponents);
55
- },
56
- showSelectionIndicator: false,
57
- showSeparator: true,
58
- tabs: tabs
59
- });
60
- };
61
-
62
- SubTabBar.propTypes = {
63
- tabs: PropTypes.arrayOf(PropTypes.element).isRequired,
64
- activeTab: PropTypes.string,
65
- onTabClick: PropTypes.func.isRequired,
66
- withCarousel: PropTypes.bool,
67
- handleUpArrow: PropTypes.func,
68
- firstSubtabRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
69
- current: PropTypes.any
70
- })])
71
- };
72
-
73
- export { SubTabBar as default };
74
- //# sourceMappingURL=SubTabBar.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SubTabBar.js","sources":["../../src/SubTabBar.tsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { aggregatedClasses } from '@elliemae/ds-classnames';\nimport TabBar from './TabBar';\nimport Carousel from './Carousel';\n\nconst blockName = 'tabs-tab-bar';\n\nconst SubTabList = aggregatedClasses('div')(\n blockName,\n 'subtabs-list',\n ({ withCarousel }) => ({ carousel: withCarousel }),\n);\n\nconst SubTabBar = ({\n withCarousel,\n tabs = [],\n activeTab = '',\n onTabClick = () => null,\n firstSubtabRef,\n handleUpArrow,\n}) => (\n <TabBar\n activeTab={activeTab}\n onTabClick={onTabClick}\n handleUpArrow={handleUpArrow}\n firstSubtabRef={firstSubtabRef}\n renderCustomTabBar={({ tabsComponents, innerRef }) => (\n <SubTabList\n withCarousel={withCarousel}\n innerRef={innerRef}\n data-testid=\"subtabs-list\"\n >\n {withCarousel ? <Carousel>{tabsComponents}</Carousel> : tabsComponents}\n </SubTabList>\n )}\n showSelectionIndicator={false}\n showSeparator\n tabs={tabs}\n />\n);\n\nSubTabBar.propTypes = {\n tabs: PropTypes.arrayOf(PropTypes.element).isRequired,\n activeTab: PropTypes.string,\n onTabClick: PropTypes.func.isRequired,\n withCarousel: PropTypes.bool,\n handleUpArrow: PropTypes.func,\n firstSubtabRef: PropTypes.oneOfType([\n PropTypes.func,\n PropTypes.shape({ current: PropTypes.any }),\n ]),\n};\n\nexport default SubTabBar;\n"],"names":["blockName","SubTabList","aggregatedClasses","withCarousel","carousel","SubTabBar","tabs","activeTab","onTabClick","firstSubtabRef","handleUpArrow","tabsComponents","innerRef","propTypes","PropTypes","arrayOf","element","isRequired","string","func","bool","oneOfType","shape","current","any"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAMA,IAAMA,SAAS,GAAG,cAAlB;AAEA,IAAMC,UAAU,GAAGC,iBAAiB,CAAC,KAAD,CAAjB,CACjBF,SADiB,EAEjB,cAFiB,EAGjB;AAAA,MAAGG,YAAH,QAAGA,YAAH;AAAA,SAAuB;AAAEC,IAAAA,QAAQ,EAAED;AAAZ,GAAvB;AAAA,CAHiB,CAAnB;;IAMME,SAAS,GAAG,SAAZA,SAAY;AAAA,MAChBF,YADgB,SAChBA,YADgB;AAAA,yBAEhBG,IAFgB;AAAA,MAEhBA,IAFgB,2BAET,EAFS;AAAA,8BAGhBC,SAHgB;AAAA,MAGhBA,SAHgB,gCAGJ,EAHI;AAAA,+BAIhBC,UAJgB;AAAA,MAIhBA,UAJgB,iCAIH;AAAA,WAAM,IAAN;AAAA,GAJG;AAAA,MAKhBC,cALgB,SAKhBA,cALgB;AAAA,MAMhBC,aANgB,SAMhBA,aANgB;AAAA,sBAQhB,oBAAC,MAAD;AACE,IAAA,SAAS,EAAEH,SADb;AAEE,IAAA,UAAU,EAAEC,UAFd;AAGE,IAAA,aAAa,EAAEE,aAHjB;AAIE,IAAA,cAAc,EAAED,cAJlB;AAKE,IAAA,kBAAkB,EAAE;AAAA,UAAGE,cAAH,SAAGA,cAAH;AAAA,UAAmBC,QAAnB,SAAmBA,QAAnB;AAAA,0BAClB,oBAAC,UAAD;AACE,QAAA,YAAY,EAAET,YADhB;AAEE,QAAA,QAAQ,EAAES,QAFZ;AAGE,uBAAY;AAHd,SAKGT,YAAY,gBAAG,oBAAC,QAAD,QAAWQ,cAAX,CAAH,GAA2CA,cAL1D,CADkB;AAAA,KALtB;AAcE,IAAA,sBAAsB,EAAE,KAd1B;AAeE,IAAA,aAAa,MAff;AAgBE,IAAA,IAAI,EAAEL;AAhBR,IARgB;AAAA;;AA4BlBD,SAAS,CAACQ,SAAV,GAAsB;AACpBP,EAAAA,IAAI,EAAEQ,SAAS,CAACC,OAAV,CAAkBD,SAAS,CAACE,OAA5B,EAAqCC,UADvB;AAEpBV,EAAAA,SAAS,EAAEO,SAAS,CAACI,MAFD;AAGpBV,EAAAA,UAAU,EAAEM,SAAS,CAACK,IAAV,CAAeF,UAHP;AAIpBd,EAAAA,YAAY,EAAEW,SAAS,CAACM,IAJJ;AAKpBV,EAAAA,aAAa,EAAEI,SAAS,CAACK,IALL;AAMpBV,EAAAA,cAAc,EAAEK,SAAS,CAACO,SAAV,CAAoB,CAClCP,SAAS,CAACK,IADwB,EAElCL,SAAS,CAACQ,KAAV,CAAgB;AAAEC,IAAAA,OAAO,EAAET,SAAS,CAACU;AAArB,GAAhB,CAFkC,CAApB;AANI,CAAtB;;;;"}
package/esm/TabBar.js DELETED
@@ -1,464 +0,0 @@
1
- import _classCallCheck from '@babel/runtime/helpers/esm/classCallCheck';
2
- import _createClass from '@babel/runtime/helpers/esm/createClass';
3
- import _assertThisInitialized from '@babel/runtime/helpers/esm/assertThisInitialized';
4
- import _inherits from '@babel/runtime/helpers/esm/inherits';
5
- import _possibleConstructorReturn from '@babel/runtime/helpers/esm/possibleConstructorReturn';
6
- import _getPrototypeOf from '@babel/runtime/helpers/esm/getPrototypeOf';
7
- import React, { Component } from 'react';
8
- import { debounce } from 'lodash';
9
- import PropTypes from 'prop-types';
10
- import { aggregatedClasses } from '@elliemae/ds-classnames';
11
- import RequiredMark from '@elliemae/ds-form/RequiredMark';
12
- import memoizeOne from 'memoize-one';
13
- import { ResizeObserver } from 'resize-observer';
14
- import styled from 'styled-components';
15
- import Carousel from './Carousel.js';
16
- import '@babel/runtime/helpers/esm/slicedToArray';
17
- import '@elliemae/ds-icons';
18
- import '@elliemae/ds-button';
19
- import './useResize.js';
20
-
21
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
22
-
23
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
24
- var blockName = 'tabs-tab-bar';
25
- var gradientWidth = 24;
26
- var StyledTabWrapper = /*#__PURE__*/styled.div.withConfig({
27
- componentId: "sc-7sdovg-0"
28
- })(["display:flex;flex:1;flex-wrap:nowrap;", ";"], function (_ref) {
29
- var flexibleTabsHeaders = _ref.flexibleTabsHeaders;
30
- return flexibleTabsHeaders ? '' : 'overflow-x: hidden';
31
- });
32
- var StyledTabList = aggregatedClasses('div')(blockName, 'list', function (_ref2) {
33
- var withCarousel = _ref2.withCarousel,
34
- flexibleTabsHeaders = _ref2.flexibleTabsHeaders,
35
- fixedTabsHeaders = _ref2.fixedTabsHeaders,
36
- isDSMobile = _ref2.isDSMobile,
37
- withLeftGradients = _ref2.withLeftGradients,
38
- withRightGradients = _ref2.withRightGradients;
39
- return {
40
- carousel: withCarousel,
41
- 'flexible-table-headers': isDSMobile && flexibleTabsHeaders,
42
- 'fixed-table-headers': isDSMobile && fixedTabsHeaders,
43
- 'left-gradients': isDSMobile && flexibleTabsHeaders && withLeftGradients,
44
- 'right-gradients': isDSMobile && flexibleTabsHeaders && withRightGradients
45
- };
46
- }, {
47
- propsToRemoveFromFinalElement: ['withCarousel', 'flexibleTabsHeaders', 'fixedTabsHeaders', 'withLeftGradients', 'withRightGradients', 'isDSMobile']
48
- });
49
- var TabContainer = aggregatedClasses('button', {
50
- role: 'tab'
51
- })(blockName, 'tab', function (_ref3) {
52
- var isActive = _ref3.isActive,
53
- showSeparator = _ref3.showSeparator,
54
- disabled = _ref3.disabled;
55
- return {
56
- active: isActive,
57
- separator: showSeparator,
58
- disabled: disabled
59
- };
60
- });
61
- var SelectionIndicator = aggregatedClasses('div')(blockName, 'selection-indicator');
62
-
63
- var TabBar = /*#__PURE__*/function (_Component) {
64
- _inherits(TabBar, _Component);
65
-
66
- var _super = _createSuper(TabBar);
67
-
68
- function TabBar(_props) {
69
- var _this;
70
-
71
- _classCallCheck(this, TabBar);
72
-
73
- _this = _super.call(this, _props);
74
-
75
- _this.handleTabClick = function (tabId, e) {
76
- var _assertThisInitialize = _assertThisInitialized(_this),
77
- tabListRef = _assertThisInitialize.tabListRef,
78
- props = _assertThisInitialize.props;
79
-
80
- var onTabClick = props.onTabClick,
81
- flexibleTabsHeaders = props.flexibleTabsHeaders,
82
- isDSMobile = props.isDSMobile;
83
-
84
- if (isDSMobile && flexibleTabsHeaders) {
85
- var tabListDomEl = tabListRef.current;
86
- var el = e.target;
87
- var offsetLeft = el.offsetLeft;
88
-
89
- var _el$getBoundingClient = el.getBoundingClientRect(),
90
- elWidth = _el$getBoundingClient.width;
91
-
92
- var _tabListDomEl$getBoun = tabListDomEl.getBoundingClientRect(),
93
- listWidth = _tabListDomEl$getBoun.width;
94
-
95
- var extraSideSpace = listWidth - elWidth;
96
- var leftOffsetToCenter = extraSideSpace > 0 ? extraSideSpace / 2 : 0;
97
- var centeredLeftOffset = offsetLeft > leftOffsetToCenter ? offsetLeft - leftOffsetToCenter : 0;
98
- tabListDomEl.scrollTo({
99
- top: 0,
100
- left: centeredLeftOffset,
101
- behavior: 'smooth'
102
- });
103
- }
104
-
105
- e.preventDefault();
106
- onTabClick(tabId);
107
- };
108
-
109
- _this.handleKeyPress = function (tabId, e, index) {
110
- var _this$props = _this.props,
111
- tabs = _this$props.tabs,
112
- handleDownArrow = _this$props.handleDownArrow,
113
- handleUpArrow = _this$props.handleUpArrow;
114
-
115
- if (e.keyCode === 39) {
116
- var _this$tabsRef;
117
-
118
- var nextTab = tabs[index + 1];
119
- if (!nextTab && handleDownArrow) handleDownArrow(e);
120
- if (!nextTab) return; // const { props } = nextTab
121
- // onTabClick(props.tabId)
122
-
123
- (_this$tabsRef = _this.tabsRef[index + 1]) === null || _this$tabsRef === void 0 ? void 0 : _this$tabsRef.focus();
124
- }
125
-
126
- if (e.keyCode === 37) {
127
- var _this$tabsRef2;
128
-
129
- var _nextTab = tabs[index - 1];
130
- if (!_nextTab && handleUpArrow) handleUpArrow(e);
131
- if (!_nextTab) return; // const { props } = nextTab
132
- // onTabClick(props.tabId)
133
-
134
- (_this$tabsRef2 = _this.tabsRef[index - 1]) === null || _this$tabsRef2 === void 0 ? void 0 : _this$tabsRef2.focus();
135
- }
136
-
137
- if (e.keyCode === 40 && handleDownArrow) {
138
- handleDownArrow(e);
139
- }
140
-
141
- if (e.keyCode === 38 && handleUpArrow) {
142
- handleUpArrow(e);
143
- }
144
- };
145
-
146
- _this.handleTabsHeadersHorizontalScroll = debounce(function () {
147
- var _assertThisInitialize2 = _assertThisInitialized(_this),
148
- tabListRef = _assertThisInitialize2.tabListRef,
149
- props = _assertThisInitialize2.props;
150
-
151
- var flexibleTabsHeaders = props.flexibleTabsHeaders,
152
- isDSMobile = props.isDSMobile;
153
-
154
- if (isDSMobile && flexibleTabsHeaders) {
155
- var tabListDomEl = tabListRef.current;
156
- var scrollLeft = tabListDomEl.scrollLeft,
157
- scrollWidth = tabListDomEl.scrollWidth,
158
- clientWidth = tabListDomEl.clientWidth;
159
-
160
- var withLeftGradients = _this.shouldHaveLeftGradient(scrollLeft, gradientWidth);
161
-
162
- var withRightGradients = _this.shouldHaveRightGradient(scrollLeft, gradientWidth, clientWidth, scrollWidth);
163
-
164
- _this.setState({
165
- withLeftGradients: withLeftGradients,
166
- withRightGradients: withRightGradients
167
- });
168
- }
169
- }, 50);
170
- _this.renderTabs = memoizeOne(function (activeTab, tabs) {
171
- var showSeparator = _this.props.showSeparator;
172
- return React.Children.map(tabs, function (tab, index) {
173
- var _tab$props = tab.props,
174
- tabId = _tab$props.tabId,
175
- title = _tab$props.title,
176
- style = _tab$props.style,
177
- required = _tab$props.required,
178
- disabled = _tab$props.disabled;
179
- var isActive = activeTab === tabId;
180
- return [/*#__PURE__*/React.createElement(TabContainer, {
181
- key: tabId // eslint-disable-next-line no-return-assign
182
- ,
183
- ref: function ref(t) {
184
- _this.tabsRef[index] = t;
185
-
186
- if (index === 0 && _this.props.firstSubtabRef) {
187
- _this.props.firstSubtabRef.current = t;
188
- }
189
-
190
- if (index === tabs.length - 1 && _this.props.lastTabRef) {
191
- _this.props.lastTabRef.current = t;
192
- }
193
- },
194
- "aria-controls": tabId,
195
- "aria-selected": isActive,
196
- "aria-disabled": !!disabled,
197
- classProps: {
198
- isActive: isActive,
199
- showSeparator: showSeparator,
200
- disabled: disabled
201
- },
202
- "data-tab-id": tabId,
203
- id: "".concat(tabId, "-label"),
204
- onClick: function onClick(e) {
205
- if (!disabled) _this.handleTabClick(tabId, e, index);
206
- },
207
- onKeyDown: function onKeyDown(e) {
208
- if (!disabled) _this.handleKeyPress(tabId, e, index);
209
- },
210
- style: style,
211
- tabIndex: 0
212
- }, title, /*#__PURE__*/React.createElement(RequiredMark, {
213
- required: required
214
- }))];
215
- }, null);
216
- });
217
- _this.tabListRef = /*#__PURE__*/React.createRef();
218
- _this.resizeObserver = new ResizeObserver(function () {
219
- return _this.setIndicatorStyle();
220
- });
221
- _this.state = {
222
- indicatorStyle: null,
223
- withLeftGradients: false,
224
- withRightGradients: false
225
- };
226
- _this.setIndicatorStyle = _this.setIndicatorStyle.bind(_assertThisInitialized(_this));
227
- _this.getIndicatorStyles = _this.getIndicatorStyles.bind(_assertThisInitialized(_this));
228
- _this.handleGradients = _this.handleGradients.bind(_assertThisInitialized(_this));
229
- _this.handleTabsHeadersHorizontalScroll = _this.handleTabsHeadersHorizontalScroll.bind(_assertThisInitialized(_this));
230
- _this.tabsRef = {};
231
- _this.setIndicatorStyle = _this.setIndicatorStyle.bind(_assertThisInitialized(_this));
232
- return _this;
233
- }
234
-
235
- _createClass(TabBar, [{
236
- key: "componentDidMount",
237
- value: function componentDidMount() {
238
- var showSelectionIndicator = this.props.showSelectionIndicator;
239
- this.resizeObserver.observe(this.tabListRef.current);
240
-
241
- if (showSelectionIndicator) {
242
- this.setIndicatorStyle();
243
- }
244
-
245
- window.addEventListener('resize', this.handleGradients);
246
- window.addEventListener('orientationchange', this.handleGradients);
247
- this.handleGradients();
248
- }
249
- }, {
250
- key: "componentDidUpdate",
251
- value: function componentDidUpdate(prevProps) {
252
- var _this$props2 = this.props,
253
- activeTab = _this$props2.activeTab,
254
- showSelectionIndicator = _this$props2.showSelectionIndicator;
255
-
256
- if (showSelectionIndicator && prevProps.activeTab !== activeTab) {
257
- this.setIndicatorStyle(activeTab);
258
- }
259
- }
260
- }, {
261
- key: "componentWillUnmount",
262
- value: function componentWillUnmount() {
263
- this.resizeObserver.unobserve(this.tabListRef.current);
264
- window.removeEventListener('resize', this.handleGradients);
265
- window.removeEventListener('orientationchange', this.handleGradients);
266
- }
267
- }, {
268
- key: "handleGradients",
269
- value: function handleGradients() {
270
- var _this$tabListRef$curr = this.tabListRef.current,
271
- scrollLeft = _this$tabListRef$curr.scrollLeft,
272
- scrollWidth = _this$tabListRef$curr.scrollWidth,
273
- clientWidth = _this$tabListRef$curr.clientWidth;
274
- var withLeftGradients = this.shouldHaveLeftGradient(scrollLeft, gradientWidth);
275
- var withRightGradients = this.shouldHaveRightGradient(scrollLeft, gradientWidth, clientWidth, scrollWidth);
276
- this.setState({
277
- withLeftGradients: withLeftGradients,
278
- withRightGradients: withRightGradients
279
- });
280
- }
281
- }, {
282
- key: "shouldHaveLeftGradient",
283
- value: function shouldHaveLeftGradient(scrollLeft, gWidth) {
284
- return Math.abs(scrollLeft) > gWidth;
285
- } // eslint-disable-next-line max-params
286
-
287
- }, {
288
- key: "shouldHaveRightGradient",
289
- value: function shouldHaveRightGradient(scrollLeft, gWidth, clientWidth, scrollWidth) {
290
- return Math.abs(scrollLeft) <= scrollWidth - (clientWidth + gWidth);
291
- }
292
- }, {
293
- key: "setIndicatorStyle",
294
- value: function setIndicatorStyle() {
295
- var _this2 = this;
296
-
297
- var activeTab = this.props.activeTab;
298
- setTimeout(function () {
299
- return _this2.setState({
300
- indicatorStyle: _this2.getIndicatorStyles(activeTab)
301
- });
302
- }, 100);
303
- }
304
- }, {
305
- key: "getActiveTabElement",
306
- value: function getActiveTabElement(activeTab) {
307
- var tabListEl = this.tabListRef.current;
308
- var tabSelector = "[data-tab-id=\"".concat(activeTab, "\"]");
309
- return tabListEl && tabListEl.querySelector(tabSelector);
310
- }
311
- }, {
312
- key: "isElementVisible",
313
- value: function isElementVisible(el, holder) {
314
- var _el$getBoundingClient2 = el.getBoundingClientRect(),
315
- left = _el$getBoundingClient2.left,
316
- right = _el$getBoundingClient2.right,
317
- width = _el$getBoundingClient2.width;
318
-
319
- var holderRect = holder.getBoundingClientRect();
320
- return left <= holderRect.left ? holderRect.left - left <= width : right - holderRect.right <= width;
321
- }
322
- }, {
323
- key: "getVisibleDimensions",
324
- value: function getVisibleDimensions(node, referenceNode) {
325
- var pos = node.getBoundingClientRect();
326
- var referencePos = referenceNode.getBoundingClientRect();
327
- return {
328
- width: Math.min(node.clientWidth, referencePos.left + referenceNode.clientWidth - pos.left, node.clientWidth - (referencePos.left - pos.left)),
329
- height: Math.min(node.clientHeight, referencePos.top + referenceNode.clientHeight - pos.top, node.clientHeight - (referencePos.top - pos.top))
330
- };
331
- }
332
- }, {
333
- key: "getIndicatorStyles",
334
- value: function getIndicatorStyles(activeTab) {
335
- var tabListEl = this.tabListRef.current;
336
- var withCarousel = this.props.withCarousel;
337
- var activeTabEl = this.getActiveTabElement(activeTab);
338
- if (!activeTabEl || !this.isElementVisible(activeTabEl, tabListEl)) return null;
339
- var clientHeight = activeTabEl.clientHeight,
340
- clientWidth = activeTabEl.clientWidth,
341
- offsetTop = activeTabEl.offsetTop,
342
- offsetLeft = activeTabEl.offsetLeft;
343
-
344
- var _activeTabEl$getBound = activeTabEl.getBoundingClientRect(),
345
- left = _activeTabEl$getBound.left;
346
-
347
- var leftOff = withCarousel ? Math.max(0, left - tabListEl.getBoundingClientRect().left) : offsetLeft;
348
- var width = withCarousel ? this.getVisibleDimensions(activeTabEl, tabListEl).width + 2 : clientWidth + 2;
349
- return {
350
- height: clientHeight,
351
- left: "".concat(Math.floor(leftOff), "px"),
352
- // using left and top for ie compatibility
353
- top: "".concat(Math.floor(offsetTop), "px"),
354
- width: width
355
- };
356
- }
357
- }, {
358
- key: "render",
359
- value: function render() {
360
- var _this$props3 = this.props,
361
- id = _this$props3.id,
362
- tabs = _this$props3.tabs,
363
- activeTab = _this$props3.activeTab,
364
- renderCustomTabBar = _this$props3.renderCustomTabBar,
365
- withCarousel = _this$props3.withCarousel,
366
- isDSMobile = _this$props3.isDSMobile,
367
- flexibleTabsHeaders = _this$props3.flexibleTabsHeaders,
368
- fixedTabsHeaders = _this$props3.fixedTabsHeaders;
369
- var _this$state = this.state,
370
- indicatorStyle = _this$state.indicatorStyle,
371
- withLeftGradients = _this$state.withLeftGradients,
372
- withRightGradients = _this$state.withRightGradients;
373
-
374
- if (renderCustomTabBar) {
375
- return renderCustomTabBar({
376
- innerRef: this.tabListRef,
377
- withCarousel: withCarousel,
378
- tabsComponents: this.renderTabs(activeTab, tabs)
379
- });
380
- }
381
-
382
- var shouldUseCarousel = !isDSMobile && withCarousel;
383
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(StyledTabList, {
384
- withCarousel: withCarousel,
385
- "aria-label": id,
386
- innerRef: this.tabListRef,
387
- role: "tablist",
388
- "data-testid": "tab-list",
389
- isDSMobile: isDSMobile,
390
- flexibleTabsHeaders: flexibleTabsHeaders,
391
- withLeftGradients: withLeftGradients,
392
- withRightGradients: withRightGradients,
393
- fixedTabsHeaders: fixedTabsHeaders,
394
- onScroll: this.handleTabsHeadersHorizontalScroll,
395
- style: {
396
- width: '100%'
397
- }
398
- }, /*#__PURE__*/React.createElement(StyledTabWrapper, {
399
- isDSMobile: isDSMobile,
400
- flexibleTabsHeaders: flexibleTabsHeaders,
401
- fixedTabsHeaders: fixedTabsHeaders
402
- }, shouldUseCarousel ? /*#__PURE__*/React.createElement(Carousel, {
403
- onScroll: this.setIndicatorStyle
404
- }, this.renderTabs(activeTab, tabs)) : null, !shouldUseCarousel ? this.renderTabs(activeTab, tabs) : null, /*#__PURE__*/React.createElement(SelectionIndicator, {
405
- style: indicatorStyle
406
- }))));
407
- }
408
- }]);
409
-
410
- return TabBar;
411
- }(Component);
412
-
413
- TabBar.defaultProps = {
414
- showSelectionIndicator: true,
415
- showSeparator: false,
416
- isDSMobile: false
417
- };
418
- TabBar.propTypes = {
419
- /** Separator between tabs */
420
- showSeparator: PropTypes.bool,
421
-
422
- /** Blue border under selected tab */
423
- showSelectionIndicator: PropTypes.bool,
424
-
425
- /** Tab list id */
426
- id: PropTypes.string,
427
-
428
- /** Array of tabs */
429
- tabs: PropTypes.arrayOf(PropTypes.element).isRequired,
430
-
431
- /** Renders a custom tabbar */
432
- renderCustomTabBar: PropTypes.func,
433
-
434
- /** tabId of active tab */
435
- activeTab: PropTypes.string,
436
-
437
- /** on tab click callback */
438
- onTabClick: PropTypes.func,
439
-
440
- /** carousel behavior */
441
- withCarousel: PropTypes.bool,
442
- handleDownArrow: PropTypes.func,
443
- handleUpArrow: PropTypes.func,
444
- firstSubtabRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
445
- current: PropTypes.any
446
- })]),
447
- lastTabRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
448
- current: PropTypes.any
449
- })]),
450
-
451
- /** Whether or not it's a ds-tab from DSMobile tabs */
452
- isDSMobile: PropTypes.bool,
453
-
454
- /** DSMobile only flexible tabs mode */
455
- flexibleTabsHeaders: PropTypes.bool,
456
-
457
- /** DSMobile only fixed tabs mode */
458
- fixedTabsHeaders: PropTypes.bool
459
- /** Whether we are in mobile mode or not */
460
-
461
- };
462
-
463
- export { TabBar as default };
464
- //# sourceMappingURL=TabBar.js.map