@elliemae/ds-tabs 2.2.0-alpha.2 → 2.2.0-beta.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 (102) hide show
  1. package/cjs/DSTabs.js +40 -58
  2. package/cjs/DSTabsCTX.js +25 -51
  3. package/cjs/DSTabsDatatestid.js +14 -42
  4. package/cjs/DSTabsTypes.js +2 -27
  5. package/cjs/config/useCrossRef.js +11 -38
  6. package/cjs/config/useTabs.js +36 -53
  7. package/cjs/defaultProps.js +13 -39
  8. package/cjs/exportsRelated/DSTab.js +32 -46
  9. package/cjs/index.js +17 -38
  10. package/cjs/parts/carousel/Carousel.js +53 -61
  11. package/cjs/parts/carousel/styles.js +63 -77
  12. package/cjs/parts/carousel/useCarousel.js +49 -51
  13. package/cjs/parts/carousel/useCarouselCallbacks.js +36 -53
  14. package/cjs/parts/tabBar/TabBar.js +120 -124
  15. package/cjs/parts/tabBar/styles.js +195 -289
  16. package/cjs/parts/tabBar/useTabBar.js +55 -67
  17. package/cjs/parts/tabsContent/TabsContent.js +45 -49
  18. package/cjs/parts/tabsContent/styles.js +15 -39
  19. package/cjs/parts/tabsPanel/TabsPanels.js +58 -60
  20. package/cjs/parts/tabsPanel/styles.js +23 -43
  21. package/cjs/propTypes.js +29 -54
  22. package/cjs/utils/constants.js +16 -44
  23. package/cjs/utils/helpers.js +22 -46
  24. package/cjs/utils/hooks/useKeyboardNavigation.js +43 -59
  25. package/cjs/utils/hooks/useTabsCallbacks.js +33 -49
  26. package/esm/DSTabs.js +25 -24
  27. package/esm/DSTabsCTX.js +20 -22
  28. package/esm/DSTabsDatatestid.js +10 -13
  29. package/esm/DSTabsTypes.js +1 -2
  30. package/esm/config/useCrossRef.js +4 -6
  31. package/esm/config/useTabs.js +22 -14
  32. package/esm/defaultProps.js +8 -9
  33. package/esm/exportsRelated/DSTab.js +19 -15
  34. package/esm/index.js +4 -9
  35. package/esm/parts/carousel/Carousel.js +38 -25
  36. package/esm/parts/carousel/styles.js +52 -48
  37. package/esm/parts/carousel/useCarousel.js +34 -15
  38. package/esm/parts/carousel/useCarouselCallbacks.js +28 -20
  39. package/esm/parts/tabBar/TabBar.js +102 -93
  40. package/esm/parts/tabBar/styles.js +183 -262
  41. package/esm/parts/tabBar/useTabBar.js +36 -27
  42. package/esm/parts/tabsContent/TabsContent.js +35 -19
  43. package/esm/parts/tabsContent/styles.js +7 -10
  44. package/esm/parts/tabsPanel/TabsPanels.js +45 -28
  45. package/esm/parts/tabsPanel/styles.js +15 -14
  46. package/esm/propTypes.js +24 -25
  47. package/esm/utils/constants.js +8 -15
  48. package/esm/utils/helpers.js +11 -16
  49. package/esm/utils/hooks/useKeyboardNavigation.js +39 -30
  50. package/esm/utils/hooks/useTabsCallbacks.js +27 -18
  51. package/package.json +6 -6
  52. package/types/DSTabs.d.ts +2 -2
  53. package/cjs/DSTabs.js.map +0 -7
  54. package/cjs/DSTabsCTX.js.map +0 -7
  55. package/cjs/DSTabsDatatestid.js.map +0 -7
  56. package/cjs/DSTabsTypes.js.map +0 -7
  57. package/cjs/config/useCrossRef.js.map +0 -7
  58. package/cjs/config/useTabs.js.map +0 -7
  59. package/cjs/defaultProps.js.map +0 -7
  60. package/cjs/exportsRelated/DSTab.js.map +0 -7
  61. package/cjs/index.js.map +0 -7
  62. package/cjs/parts/carousel/Carousel.js.map +0 -7
  63. package/cjs/parts/carousel/styles.js.map +0 -7
  64. package/cjs/parts/carousel/useCarousel.js.map +0 -7
  65. package/cjs/parts/carousel/useCarouselCallbacks.js.map +0 -7
  66. package/cjs/parts/tabBar/TabBar.js.map +0 -7
  67. package/cjs/parts/tabBar/styles.js.map +0 -7
  68. package/cjs/parts/tabBar/useTabBar.js.map +0 -7
  69. package/cjs/parts/tabsContent/TabsContent.js.map +0 -7
  70. package/cjs/parts/tabsContent/styles.js.map +0 -7
  71. package/cjs/parts/tabsPanel/TabsPanels.js.map +0 -7
  72. package/cjs/parts/tabsPanel/styles.js.map +0 -7
  73. package/cjs/propTypes.js.map +0 -7
  74. package/cjs/utils/constants.js.map +0 -7
  75. package/cjs/utils/helpers.js.map +0 -7
  76. package/cjs/utils/hooks/useKeyboardNavigation.js.map +0 -7
  77. package/cjs/utils/hooks/useTabsCallbacks.js.map +0 -7
  78. package/esm/DSTabs.js.map +0 -7
  79. package/esm/DSTabsCTX.js.map +0 -7
  80. package/esm/DSTabsDatatestid.js.map +0 -7
  81. package/esm/DSTabsTypes.js.map +0 -7
  82. package/esm/config/useCrossRef.js.map +0 -7
  83. package/esm/config/useTabs.js.map +0 -7
  84. package/esm/defaultProps.js.map +0 -7
  85. package/esm/exportsRelated/DSTab.js.map +0 -7
  86. package/esm/index.js.map +0 -7
  87. package/esm/parts/carousel/Carousel.js.map +0 -7
  88. package/esm/parts/carousel/styles.js.map +0 -7
  89. package/esm/parts/carousel/useCarousel.js.map +0 -7
  90. package/esm/parts/carousel/useCarouselCallbacks.js.map +0 -7
  91. package/esm/parts/tabBar/TabBar.js.map +0 -7
  92. package/esm/parts/tabBar/styles.js.map +0 -7
  93. package/esm/parts/tabBar/useTabBar.js.map +0 -7
  94. package/esm/parts/tabsContent/TabsContent.js.map +0 -7
  95. package/esm/parts/tabsContent/styles.js.map +0 -7
  96. package/esm/parts/tabsPanel/TabsPanels.js.map +0 -7
  97. package/esm/parts/tabsPanel/styles.js.map +0 -7
  98. package/esm/propTypes.js.map +0 -7
  99. package/esm/utils/constants.js.map +0 -7
  100. package/esm/utils/helpers.js.map +0 -7
  101. package/esm/utils/hooks/useKeyboardNavigation.js.map +0 -7
  102. package/esm/utils/hooks/useTabsCallbacks.js.map +0 -7
@@ -1,77 +1,61 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __reExport = (target, module2, copyDefault, desc) => {
13
- if (module2 && typeof module2 === "object" || typeof module2 === "function") {
14
- for (let key of __getOwnPropNames(module2))
15
- if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
16
- __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
17
- }
18
- return target;
19
- };
20
- var __toESM = (module2, isNodeMode) => {
21
- return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
22
- };
23
- var __toCommonJS = /* @__PURE__ */ ((cache) => {
24
- return (module2, temp) => {
25
- return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
26
- };
27
- })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
28
- var useKeyboardNavigation_exports = {};
29
- __export(useKeyboardNavigation_exports, {
30
- useKeyboardNavigation: () => useKeyboardNavigation
31
- });
32
- var React = __toESM(require("react"));
33
- var import_react = __toESM(require("react"));
34
- var import_DSTabsCTX = __toESM(require("../../DSTabsCTX"));
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+ var DSTabsCTX = require('../../DSTabsCTX.js');
7
+
8
+ /* eslint-disable max-statements */
35
9
  const useKeyboardNavigation = () => {
36
- const { focusableTabsRef } = (0, import_react.useContext)(import_DSTabsCTX.DSTabsContext);
37
- const { firstSubtabInternalRef, lastTabInternalRef } = (0, import_react.useContext)(import_DSTabsCTX.DSTabsCrossRefContext);
38
- const handleOnKeyDown = (0, import_react.useCallback)((e) => {
39
- if (e.key === "ArrowRight" && focusableTabsRef.current) {
10
+ const {
11
+ focusableTabsRef
12
+ } = React.useContext(DSTabsCTX.DSTabsContext);
13
+ const {
14
+ firstSubtabInternalRef,
15
+ lastTabInternalRef
16
+ } = React.useContext(DSTabsCTX.DSTabsCrossRefContext);
17
+ const handleOnKeyDown = React.useCallback(e => {
18
+ if (e.key === 'ArrowRight' && focusableTabsRef.current) {
19
+ var _focusableTabsRef$cur, _focusableTabsRef$cur2;
20
+
40
21
  e.preventDefault();
41
22
  e.stopPropagation();
42
- const nextTab = focusableTabsRef.current[focusableTabsRef?.current?.indexOf?.(e.target) + 1];
43
- if (nextTab)
44
- nextTab.focus();
45
- if (!nextTab)
46
- return;
23
+ const nextTab = focusableTabsRef.current[(focusableTabsRef === null || focusableTabsRef === void 0 ? void 0 : (_focusableTabsRef$cur = focusableTabsRef.current) === null || _focusableTabsRef$cur === void 0 ? void 0 : (_focusableTabsRef$cur2 = _focusableTabsRef$cur.indexOf) === null || _focusableTabsRef$cur2 === void 0 ? void 0 : _focusableTabsRef$cur2.call(_focusableTabsRef$cur, e.target)) + 1];
24
+ if (nextTab) nextTab.focus();
25
+ if (!nextTab) return;
47
26
  }
48
- if (e.key === "ArrowLeft" && focusableTabsRef.current) {
27
+
28
+ if (e.key === 'ArrowLeft' && focusableTabsRef.current) {
29
+ var _focusableTabsRef$cur3, _focusableTabsRef$cur4;
30
+
49
31
  e.preventDefault();
50
32
  e.stopPropagation();
51
- const prevTab = focusableTabsRef.current[focusableTabsRef?.current?.indexOf?.(e.target) - 1];
52
- if (prevTab)
53
- prevTab.focus();
54
- if (!prevTab)
55
- return;
33
+ const prevTab = focusableTabsRef.current[(focusableTabsRef === null || focusableTabsRef === void 0 ? void 0 : (_focusableTabsRef$cur3 = focusableTabsRef.current) === null || _focusableTabsRef$cur3 === void 0 ? void 0 : (_focusableTabsRef$cur4 = _focusableTabsRef$cur3.indexOf) === null || _focusableTabsRef$cur4 === void 0 ? void 0 : _focusableTabsRef$cur4.call(_focusableTabsRef$cur3, e.target)) - 1];
34
+ if (prevTab) prevTab.focus();
35
+ if (!prevTab) return;
56
36
  }
57
- if (e.key === "ArrowDown") {
37
+
38
+ if (e.key === 'ArrowDown') {
39
+ var _firstSubtabInternalR;
40
+
58
41
  e.preventDefault();
59
42
  e.stopPropagation();
60
- const canFocusCrossTabs = firstSubtabInternalRef?.current && lastTabInternalRef?.current;
61
- if (canFocusCrossTabs)
62
- firstSubtabInternalRef.current?.focus();
43
+ const canFocusCrossTabs = (firstSubtabInternalRef === null || firstSubtabInternalRef === void 0 ? void 0 : firstSubtabInternalRef.current) && (lastTabInternalRef === null || lastTabInternalRef === void 0 ? void 0 : lastTabInternalRef.current);
44
+ if (canFocusCrossTabs) (_firstSubtabInternalR = firstSubtabInternalRef.current) === null || _firstSubtabInternalR === void 0 ? void 0 : _firstSubtabInternalR.focus();
63
45
  }
64
- if (e.key === "ArrowUp") {
46
+
47
+ if (e.key === 'ArrowUp') {
48
+ var _lastTabInternalRef$c;
49
+
65
50
  e.preventDefault();
66
51
  e.stopPropagation();
67
- const canFocusCrossTabs = firstSubtabInternalRef?.current && lastTabInternalRef?.current;
68
- if (canFocusCrossTabs)
69
- lastTabInternalRef.current?.focus();
52
+ const canFocusCrossTabs = (firstSubtabInternalRef === null || firstSubtabInternalRef === void 0 ? void 0 : firstSubtabInternalRef.current) && (lastTabInternalRef === null || lastTabInternalRef === void 0 ? void 0 : lastTabInternalRef.current);
53
+ if (canFocusCrossTabs) (_lastTabInternalRef$c = lastTabInternalRef.current) === null || _lastTabInternalRef$c === void 0 ? void 0 : _lastTabInternalRef$c.focus();
70
54
  }
71
55
  }, [firstSubtabInternalRef, lastTabInternalRef, focusableTabsRef]);
72
56
  return {
73
57
  handleOnKeyDown
74
58
  };
75
59
  };
76
- module.exports = __toCommonJS(useKeyboardNavigation_exports);
77
- //# sourceMappingURL=useKeyboardNavigation.js.map
60
+
61
+ exports.useKeyboardNavigation = useKeyboardNavigation;
@@ -1,75 +1,59 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __reExport = (target, module2, copyDefault, desc) => {
13
- if (module2 && typeof module2 === "object" || typeof module2 === "function") {
14
- for (let key of __getOwnPropNames(module2))
15
- if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
16
- __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
17
- }
18
- return target;
19
- };
20
- var __toESM = (module2, isNodeMode) => {
21
- return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
22
- };
23
- var __toCommonJS = /* @__PURE__ */ ((cache) => {
24
- return (module2, temp) => {
25
- return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
26
- };
27
- })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
28
- var useTabsCallbacks_exports = {};
29
- __export(useTabsCallbacks_exports, {
30
- useTabsCallbacks: () => useTabsCallbacks
31
- });
32
- var React = __toESM(require("react"));
33
- var import_react = __toESM(require("react"));
34
- var import_DSTabsCTX = __toESM(require("../../DSTabsCTX"));
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+ var DSTabsCTX = require('../../DSTabsCTX.js');
7
+
35
8
  const useTabsCallbacks = () => {
36
9
  const {
37
10
  setInternalActiveTab,
38
11
  tabsListRef,
39
- props: { onTabChange, isDSMobile, allowTextSelection, fixedTabsHeaders }
40
- } = (0, import_react.useContext)(import_DSTabsCTX.DSTabsContext);
41
- const centerTabWhenTabChangeMobile = (0, import_react.useCallback)((e) => {
12
+ props: {
13
+ onTabChange,
14
+ isDSMobile,
15
+ allowTextSelection,
16
+ fixedTabsHeaders
17
+ }
18
+ } = React.useContext(DSTabsCTX.DSTabsContext);
19
+ const centerTabWhenTabChangeMobile = React.useCallback(e => {
42
20
  if (tabsListRef.current) {
43
- const { offsetLeft } = e?.target;
44
- const { width: tabWidth } = (e?.target).getBoundingClientRect();
45
- const { width: listWidth } = tabsListRef.current.getBoundingClientRect();
21
+ const {
22
+ offsetLeft
23
+ } = e === null || e === void 0 ? void 0 : e.target;
24
+ const {
25
+ width: tabWidth
26
+ } = (e === null || e === void 0 ? void 0 : e.target).getBoundingClientRect();
27
+ const {
28
+ width: listWidth
29
+ } = tabsListRef.current.getBoundingClientRect();
46
30
  const extraSideSpace = listWidth - tabWidth;
47
31
  const leftOffsetToCenter = extraSideSpace > 0 ? extraSideSpace / 2 : 0;
48
32
  const centeredLeftOffset = offsetLeft > leftOffsetToCenter ? offsetLeft - leftOffsetToCenter : 0;
49
33
  tabsListRef.current.scrollTo({
50
34
  top: 0,
51
35
  left: centeredLeftOffset,
52
- behavior: "smooth"
36
+ behavior: 'smooth'
53
37
  });
54
- e?.preventDefault();
38
+ e === null || e === void 0 ? void 0 : e.preventDefault();
55
39
  }
56
40
  }, [tabsListRef]);
57
- const handleOnTabChange = (0, import_react.useCallback)((tabId, e) => {
41
+ const handleOnTabChange = React.useCallback((tabId, e) => {
58
42
  setInternalActiveTab(tabId);
59
43
  onTabChange(tabId, e);
44
+
60
45
  if (isDSMobile && !fixedTabsHeaders && e) {
61
46
  centerTabWhenTabChangeMobile(e);
62
47
  }
63
48
  }, [centerTabWhenTabChangeMobile, fixedTabsHeaders, isDSMobile, onTabChange, setInternalActiveTab]);
64
- const handleOnMouseDown = (0, import_react.useCallback)((e) => {
65
- const role = e.target.getAttribute("role");
66
- if (role !== "tabpanel" && allowTextSelection)
67
- e.stopPropagation();
49
+ const handleOnMouseDown = React.useCallback(e => {
50
+ const role = e.target.getAttribute('role');
51
+ if (role !== 'tabpanel' && allowTextSelection) e.stopPropagation();
68
52
  }, [allowTextSelection]);
69
53
  return {
70
54
  handleOnTabChange,
71
55
  handleOnMouseDown
72
56
  };
73
57
  };
74
- module.exports = __toCommonJS(useTabsCallbacks_exports);
75
- //# sourceMappingURL=useTabsCallbacks.js.map
58
+
59
+ exports.useTabsCallbacks = useTabsCallbacks;
package/esm/DSTabs.js CHANGED
@@ -1,34 +1,35 @@
1
- import * as React from "react";
2
- import React2 from "react";
3
- import { describe } from "react-desc";
4
- import { tabsPropTypes } from "./propTypes";
5
- import { DSTabsContext, DSTabsCrossRefContext } from "./DSTabsCTX";
6
- import { TabsContent } from "./parts/tabsContent/TabsContent";
7
- import { useTabs } from "./config/useTabs";
8
- import { useCrossRef } from "./config/useCrossRef";
9
- import { TabTypes } from "./utils/constants";
10
- const DSTabs = (props) => {
1
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
2
+ import { describe } from 'react-desc';
3
+ import { tabsPropTypes } from './propTypes.js';
4
+ import { DSTabsContext, DSTabsCrossRefContext } from './DSTabsCTX.js';
5
+ import { TabsContent } from './parts/tabsContent/TabsContent.js';
6
+ import { useTabs } from './config/useTabs.js';
7
+ import { useCrossRef } from './config/useCrossRef.js';
8
+ import { TabTypes } from './utils/constants.js';
9
+
10
+ var _TabsContent, _TabsContent2;
11
+
12
+ const DSTabs = props => {
11
13
  const ctx = useTabs(props);
12
14
  const crossRefsCtx = useCrossRef();
13
- const { type } = props;
15
+ const {
16
+ type
17
+ } = props;
18
+
14
19
  if (type === TabTypes.SUBTABS) {
15
- return /* @__PURE__ */ React2.createElement(DSTabsContext.Provider, {
20
+ return /*#__PURE__*/_jsx(DSTabsContext.Provider, {
16
21
  value: ctx
17
- }, /* @__PURE__ */ React2.createElement(TabsContent, null));
22
+ }, void 0, _TabsContent || (_TabsContent = /*#__PURE__*/_jsx(TabsContent, {})));
18
23
  }
19
- return /* @__PURE__ */ React2.createElement(DSTabsCrossRefContext.Provider, {
24
+
25
+ return /*#__PURE__*/_jsx(DSTabsCrossRefContext.Provider, {
20
26
  value: crossRefsCtx
21
- }, /* @__PURE__ */ React2.createElement(DSTabsContext.Provider, {
27
+ }, void 0, /*#__PURE__*/_jsx(DSTabsContext.Provider, {
22
28
  value: ctx
23
- }, /* @__PURE__ */ React2.createElement(TabsContent, null)));
29
+ }, void 0, _TabsContent2 || (_TabsContent2 = /*#__PURE__*/_jsx(TabsContent, {}))));
24
30
  };
25
- DSTabs.propTypes = tabsPropTypes;
31
+
26
32
  const DSTabsWithSchema = describe(DSTabs);
27
33
  DSTabsWithSchema.propTypes = tabsPropTypes;
28
- var DSTabs_default = DSTabs;
29
- export {
30
- DSTabs,
31
- DSTabsWithSchema,
32
- DSTabs_default as default
33
- };
34
- //# sourceMappingURL=DSTabs.js.map
34
+
35
+ export { DSTabs, DSTabsWithSchema, DSTabs as default };
package/esm/DSTabsCTX.js CHANGED
@@ -1,27 +1,25 @@
1
- import * as React from "react";
2
- import { createContext, createRef } from "react";
3
- import { tabsDefaultProps as defaultProps } from "./defaultProps";
4
- const noop = () => {
5
- };
1
+ import { createContext, createRef } from 'react';
2
+ import { tabsDefaultProps } from './defaultProps.js';
3
+
4
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
5
+ const noop = () => {};
6
+
6
7
  const defaultContext = {
7
- props: defaultProps,
8
- tabsRef: createRef(),
9
- tabsListRef: createRef(),
10
- carouselOnlyListRef: createRef(),
11
- focusableTabsRef: createRef(),
12
- tabsRefAsArray: createRef(),
13
- actualActiveTabRef: createRef(),
8
+ props: tabsDefaultProps,
9
+ tabsRef: /*#__PURE__*/createRef(),
10
+ tabsListRef: /*#__PURE__*/createRef(),
11
+ carouselOnlyListRef: /*#__PURE__*/createRef(),
12
+ focusableTabsRef: /*#__PURE__*/createRef(),
13
+ tabsRefAsArray: /*#__PURE__*/createRef(),
14
+ actualActiveTabRef: /*#__PURE__*/createRef(),
14
15
  setInternalActiveTab: noop,
15
- actualActiveTab: ""
16
+ actualActiveTab: ''
16
17
  };
17
18
  const defaultCrossRefsContext = {
18
- lastTabInternalRef: createRef(),
19
- firstSubtabInternalRef: createRef()
20
- };
21
- const DSTabsContext = createContext(defaultContext);
22
- const DSTabsCrossRefContext = createContext(defaultCrossRefsContext);
23
- export {
24
- DSTabsContext,
25
- DSTabsCrossRefContext
19
+ lastTabInternalRef: /*#__PURE__*/createRef(),
20
+ firstSubtabInternalRef: /*#__PURE__*/createRef()
26
21
  };
27
- //# sourceMappingURL=DSTabsCTX.js.map
22
+ const DSTabsContext = /*#__PURE__*/createContext(defaultContext);
23
+ const DSTabsCrossRefContext = /*#__PURE__*/createContext(defaultCrossRefsContext);
24
+
25
+ export { DSTabsContext, DSTabsCrossRefContext };
@@ -1,17 +1,14 @@
1
- import * as React from "react";
2
1
  const DSTabsDatatestid = {
3
- TABS_CONTAINER: "ds-tabs-container",
4
- TAB_BUTTON: "ds-tabs-tab-button",
5
- SUBTAB_BUTTON: "ds-tabs-subtab-button",
6
- TAB_PANEL: "ds-tabs-tab-panel",
7
- SUB_TAB_LIST: "subtabs-list",
8
- TAB_LIST: "tab-list",
2
+ TABS_CONTAINER: 'ds-tabs-container',
3
+ TAB_BUTTON: 'ds-tabs-tab-button',
4
+ SUBTAB_BUTTON: 'ds-tabs-subtab-button',
5
+ TAB_PANEL: 'ds-tabs-tab-panel',
6
+ SUB_TAB_LIST: 'subtabs-list',
7
+ TAB_LIST: 'tab-list',
9
8
  CAROUSEL: {
10
- BUTTON_RIGHT: "chevron-right",
11
- BUTTON_LEFT: "chevron-left"
9
+ BUTTON_RIGHT: 'chevron-right',
10
+ BUTTON_LEFT: 'chevron-left'
12
11
  }
13
12
  };
14
- export {
15
- DSTabsDatatestid
16
- };
17
- //# sourceMappingURL=DSTabsDatatestid.js.map
13
+
14
+ export { DSTabsDatatestid };
@@ -1,2 +1 @@
1
- import * as React from "react";
2
- //# sourceMappingURL=DSTabsTypes.js.map
1
+
@@ -1,5 +1,5 @@
1
- import * as React from "react";
2
- import { useRef, useMemo } from "react";
1
+ import { useRef, useMemo } from 'react';
2
+
3
3
  const useCrossRef = () => {
4
4
  const firstSubtabInternalRef = useRef();
5
5
  const lastTabInternalRef = useRef();
@@ -9,7 +9,5 @@ const useCrossRef = () => {
9
9
  }), []);
10
10
  return ctx;
11
11
  };
12
- export {
13
- useCrossRef
14
- };
15
- //# sourceMappingURL=useCrossRef.js.map
12
+
13
+ export { useCrossRef };
@@ -1,24 +1,34 @@
1
- import * as React from "react";
2
- import { useRef, useState, useMemo, useEffect } from "react";
3
- import { useMemoMergePropsWithDefault } from "@elliemae/ds-props-helpers";
4
- import { tabsDefaultProps } from "../defaultProps";
5
- const useTabs = (props) => {
1
+ import 'core-js/modules/web.dom-collections.iterator.js';
2
+ import 'core-js/modules/esnext.async-iterator.find.js';
3
+ import 'core-js/modules/esnext.iterator.constructor.js';
4
+ import 'core-js/modules/esnext.iterator.find.js';
5
+ import { useRef, useState, useMemo, useEffect } from 'react';
6
+ import { useMemoMergePropsWithDefault } from '@elliemae/ds-props-helpers';
7
+ import { tabsDefaultProps } from '../defaultProps.js';
8
+
9
+ const useTabs = props => {
10
+ var _children$, _children$$props;
11
+
6
12
  const propsWithDefaults = useMemoMergePropsWithDefault(props, tabsDefaultProps);
7
- const { activeTab, children } = propsWithDefaults;
13
+ const {
14
+ activeTab,
15
+ children
16
+ } = propsWithDefaults;
8
17
  const tabsRef = useRef({});
9
18
  const tabsRefAsArray = useRef([]);
10
19
  const focusableTabsRef = useRef([]);
11
20
  const carouselOnlyListRef = useRef(null);
12
21
  const tabsListRef = useRef(null);
13
22
  const actualActiveTabRef = useRef(null);
14
- const [internalActiveTab, setInternalActiveTab] = useState(children?.[0]?.props?.tabId);
23
+ const [internalActiveTab, setInternalActiveTab] = useState(children === null || children === void 0 ? void 0 : (_children$ = children[0]) === null || _children$ === void 0 ? void 0 : (_children$$props = _children$.props) === null || _children$$props === void 0 ? void 0 : _children$$props.tabId);
15
24
  const actualActiveTab = useMemo(() => {
16
- if (activeTab !== void 0)
17
- return activeTab;
25
+ if (activeTab !== undefined) return activeTab;
18
26
  return internalActiveTab;
19
27
  }, [activeTab, internalActiveTab]);
20
28
  useEffect(() => {
21
- actualActiveTabRef.current = focusableTabsRef.current.find((el) => el.dataset.tabId === actualActiveTab) ?? null;
29
+ var _focusableTabsRef$cur;
30
+
31
+ actualActiveTabRef.current = (_focusableTabsRef$cur = focusableTabsRef.current.find(el => el.dataset.tabId === actualActiveTab)) !== null && _focusableTabsRef$cur !== void 0 ? _focusableTabsRef$cur : null;
22
32
  }, [actualActiveTab]);
23
33
  const ctx = useMemo(() => ({
24
34
  props: propsWithDefaults,
@@ -33,7 +43,5 @@ const useTabs = (props) => {
33
43
  }), [actualActiveTab, propsWithDefaults]);
34
44
  return ctx;
35
45
  };
36
- export {
37
- useTabs
38
- };
39
- //# sourceMappingURL=useTabs.js.map
46
+
47
+ export { useTabs };
@@ -1,14 +1,15 @@
1
- import * as React from "react";
2
- import { TabTypes } from "./utils/constants";
3
- const noop = () => {
4
- };
1
+ import { TabTypes } from './utils/constants.js';
2
+
3
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
4
+ const noop = () => {};
5
+
5
6
  const tabsDefaultProps = {
6
7
  containerProps: {},
7
8
  animated: true,
8
9
  enableMouseEvents: false,
9
10
  allowTextSelection: false,
10
11
  onTabChange: noop,
11
- tabsListAriaLabel: "Tab list",
12
+ tabsListAriaLabel: 'Tab list',
12
13
  type: TabTypes.NORMAL,
13
14
  onlyRenderActiveTab: false,
14
15
  withCarousel: false,
@@ -18,7 +19,5 @@ const tabsDefaultProps = {
18
19
  fixedTabsHeaders: false,
19
20
  showSeparator: true
20
21
  };
21
- export {
22
- tabsDefaultProps
23
- };
24
- //# sourceMappingURL=defaultProps.js.map
22
+
23
+ export { tabsDefaultProps };
@@ -1,17 +1,21 @@
1
- import * as React from "react";
2
- import React2 from "react";
3
- import { describe } from "react-desc";
4
- import { tabPropTypes } from "../propTypes";
5
- const DSTab = (props) => /* @__PURE__ */ React2.createElement(React2.Fragment, {
6
- ...props
7
- });
8
- DSTab.propTypes = tabPropTypes;
1
+ import 'core-js/modules/esnext.async-iterator.filter.js';
2
+ import 'core-js/modules/esnext.iterator.constructor.js';
3
+ import 'core-js/modules/esnext.iterator.filter.js';
4
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
5
+ import 'core-js/modules/esnext.iterator.for-each.js';
6
+ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
7
+ import React from 'react';
8
+ import { describe } from 'react-desc';
9
+ import { tabPropTypes } from '../propTypes.js';
10
+ import { jsx } from 'react/jsx-runtime';
11
+
12
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
13
+
14
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
15
+
16
+ const DSTab = props => /*#__PURE__*/jsx(React.Fragment, _objectSpread({}, props));
17
+
9
18
  const DSTabWithSchema = describe(DSTab);
10
19
  DSTabWithSchema.propTypes = tabPropTypes;
11
- var DSTab_default = DSTab;
12
- export {
13
- DSTab,
14
- DSTabWithSchema,
15
- DSTab_default as default
16
- };
17
- //# sourceMappingURL=DSTab.js.map
20
+
21
+ export { DSTab, DSTabWithSchema, DSTab as default };
package/esm/index.js CHANGED
@@ -1,9 +1,4 @@
1
- import * as React from "react";
2
- export * from "./exportsRelated/DSTab";
3
- export * from "./DSTabs";
4
- import { TabTypes } from "./utils/constants";
5
- export * from "./DSTabsDatatestid";
6
- export {
7
- TabTypes
8
- };
9
- //# sourceMappingURL=index.js.map
1
+ export { DSTab, DSTabWithSchema } from './exportsRelated/DSTab.js';
2
+ export { DSTabs, DSTabsWithSchema } from './DSTabs.js';
3
+ export { TabTypes } from './utils/constants.js';
4
+ export { DSTabsDatatestid } from './DSTabsDatatestid.js';
@@ -1,48 +1,61 @@
1
- import * as React from "react";
2
- import { useContext } from "react";
3
- import { DSIconSizes } from "@elliemae/ds-icon";
4
- import { BUTTON_TYPES } from "@elliemae/ds-button";
5
- import { ChevronRight, ChevronLeft } from "@elliemae/ds-icons";
6
- import { StyledCarouselBtn, StyledCarouselButtonWrapper, StyledCarouselWrapper, StyledChildrenWrap } from "./styles";
7
- import { useCarousel } from "./useCarousel";
8
- import { DSTabsContext } from "../../DSTabsCTX";
9
- import { DSTabsDatatestid } from "../../DSTabsDatatestid";
10
- const Carousel = ({ children, updateIndicatorStyle }) => {
11
- const { showChevrons, leftButtonOnClick, rightButtonOnClick, handleOnClick, handleOnScroll } = useCarousel({
1
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
2
+ import { useContext } from 'react';
3
+ import { DSIconSizes } from '@elliemae/ds-icon';
4
+ import { BUTTON_TYPES } from '@elliemae/ds-button';
5
+ import { ChevronLeft, ChevronRight } from '@elliemae/ds-icons';
6
+ import { StyledCarouselWrapper, StyledCarouselButtonWrapper, StyledCarouselBtn, StyledChildrenWrap } from './styles.js';
7
+ import { useCarousel } from './useCarousel.js';
8
+ import { DSTabsContext } from '../../DSTabsCTX.js';
9
+ import { DSTabsDatatestid } from '../../DSTabsDatatestid.js';
10
+ import { jsx } from 'react/jsx-runtime';
11
+
12
+ const Carousel = _ref => {
13
+ let {
14
+ children,
15
+ updateIndicatorStyle
16
+ } = _ref;
17
+ const {
18
+ showChevrons,
19
+ leftButtonOnClick,
20
+ rightButtonOnClick,
21
+ handleOnClick,
22
+ handleOnScroll
23
+ } = useCarousel({
12
24
  updateIndicatorStyle
13
25
  });
14
26
  const {
15
27
  carouselOnlyListRef,
16
- props: { type }
28
+ props: {
29
+ type
30
+ }
17
31
  } = useContext(DSTabsContext);
18
- return /* @__PURE__ */ React.createElement(StyledCarouselWrapper, null, showChevrons.left && /* @__PURE__ */ React.createElement(StyledCarouselButtonWrapper, {
32
+ return /*#__PURE__*/_jsx(StyledCarouselWrapper, {}, void 0, showChevrons.left && /*#__PURE__*/_jsx(StyledCarouselButtonWrapper, {
19
33
  tabType: type
20
- }, /* @__PURE__ */ React.createElement(StyledCarouselBtn, {
34
+ }, void 0, /*#__PURE__*/_jsx(StyledCarouselBtn, {
21
35
  size: "s",
22
36
  onClick: leftButtonOnClick,
23
37
  tabIndex: -1,
24
38
  "data-testid": DSTabsDatatestid.CAROUSEL.BUTTON_LEFT,
25
39
  buttonType: BUTTON_TYPES.ICON
26
- }, /* @__PURE__ */ React.createElement(ChevronLeft, {
40
+ }, void 0, /*#__PURE__*/_jsx(ChevronLeft, {
27
41
  size: DSIconSizes.S
28
- }))), showChevrons.right && /* @__PURE__ */ React.createElement(StyledCarouselButtonWrapper, {
42
+ }))), showChevrons.right && /*#__PURE__*/_jsx(StyledCarouselButtonWrapper, {
29
43
  tabType: type,
30
44
  right: showChevrons.right
31
- }, /* @__PURE__ */ React.createElement(StyledCarouselBtn, {
45
+ }, void 0, /*#__PURE__*/_jsx(StyledCarouselBtn, {
32
46
  size: "s",
33
47
  onClick: rightButtonOnClick,
34
48
  tabIndex: -1,
35
49
  "data-testid": DSTabsDatatestid.CAROUSEL.BUTTON_RIGHT,
36
50
  buttonType: BUTTON_TYPES.ICON
37
- }, /* @__PURE__ */ React.createElement(ChevronRight, {
51
+ }, void 0, /*#__PURE__*/_jsx(ChevronRight, {
38
52
  size: DSIconSizes.S
39
- }))), /* @__PURE__ */ React.createElement(StyledChildrenWrap, {
53
+ }))), /*#__PURE__*/jsx(StyledChildrenWrap, {
40
54
  ref: carouselOnlyListRef,
41
55
  onClick: handleOnClick,
42
- onScroll: handleOnScroll
43
- }, children));
44
- };
45
- export {
46
- Carousel
56
+ onScroll: handleOnScroll,
57
+ children: children
58
+ }));
47
59
  };
48
- //# sourceMappingURL=Carousel.js.map
60
+
61
+ export { Carousel };