@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,44 +1,27 @@
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 TabBar_exports = {};
29
- __export(TabBar_exports, {
30
- TabBar: () => TabBar
31
- });
32
- var React = __toESM(require("react"));
33
- var import_react = __toESM(require("react"));
34
- var import_Carousel = __toESM(require("../carousel/Carousel"));
35
- var import_useTabBar = __toESM(require("./useTabBar"));
36
- var import_styles = __toESM(require("./styles"));
37
- var import_DSTabsCTX = __toESM(require("../../DSTabsCTX"));
38
- var import_useKeyboardNavigation = __toESM(require("../../utils/hooks/useKeyboardNavigation"));
39
- var import_constants = __toESM(require("../../utils/constants"));
40
- var import_useTabsCallbacks = __toESM(require("../../utils/hooks/useTabsCallbacks"));
41
- var import_DSTabsDatatestid = __toESM(require("../../DSTabsDatatestid"));
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _jsx = require('@babel/runtime/helpers/jsx');
6
+ require('core-js/modules/esnext.async-iterator.map.js');
7
+ require('core-js/modules/esnext.iterator.map.js');
8
+ var React = require('react');
9
+ var Carousel = require('../carousel/Carousel.js');
10
+ var useTabBar = require('./useTabBar.js');
11
+ var styles = require('./styles.js');
12
+ var DSTabsCTX = require('../../DSTabsCTX.js');
13
+ var useKeyboardNavigation = require('../../utils/hooks/useKeyboardNavigation.js');
14
+ var constants = require('../../utils/constants.js');
15
+ var useTabsCallbacks = require('../../utils/hooks/useTabsCallbacks.js');
16
+ var DSTabsDatatestid = require('../../DSTabsDatatestid.js');
17
+ var jsxRuntime = require('react/jsx-runtime');
18
+
19
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
20
+
21
+ var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
22
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
23
+
24
+ var _StyledRequiredMark;
42
25
  const TabBar = () => {
43
26
  const {
44
27
  tabsRef,
@@ -46,119 +29,132 @@ const TabBar = () => {
46
29
  tabsListRef,
47
30
  tabsRefAsArray,
48
31
  actualActiveTab,
49
- props: { type, fixedTabsHeaders, withCarousel, isDSMobile, showSeparator, children: tabs }
50
- } = (0, import_react.useContext)(import_DSTabsCTX.DSTabsContext);
51
- const { lastTabInternalRef, firstSubtabInternalRef } = (0, import_react.useContext)(import_DSTabsCTX.DSTabsCrossRefContext);
52
- const { handleOnTabChange } = (0, import_useTabsCallbacks.useTabsCallbacks)();
53
- const { handleOnKeyDown } = (0, import_useKeyboardNavigation.useKeyboardNavigation)();
54
- const { indicatorStyle, mobileGradients, updateMobileGradients, updateIndicatorStyle } = (0, import_useTabBar.useTabBar)();
55
- const renderTabs = (0, import_react.useMemo)(() => {
32
+ props: {
33
+ type,
34
+ fixedTabsHeaders,
35
+ withCarousel,
36
+ isDSMobile,
37
+ showSeparator,
38
+ children: tabs
39
+ }
40
+ } = React.useContext(DSTabsCTX.DSTabsContext);
41
+ const {
42
+ lastTabInternalRef,
43
+ firstSubtabInternalRef
44
+ } = React.useContext(DSTabsCTX.DSTabsCrossRefContext);
45
+ const {
46
+ handleOnTabChange
47
+ } = useTabsCallbacks.useTabsCallbacks();
48
+ const {
49
+ handleOnKeyDown
50
+ } = useKeyboardNavigation.useKeyboardNavigation();
51
+ const {
52
+ indicatorStyle,
53
+ mobileGradients,
54
+ updateMobileGradients,
55
+ updateIndicatorStyle
56
+ } = useTabBar.useTabBar();
57
+ const renderTabs = React.useMemo(() => {
56
58
  const availableTabIndexes = [];
57
- return import_react.default.Children.map(tabs, (tab, index) => {
58
- const { tabId = "", title = "", style, required = false, disabled = false, ref, onClick, onKeyDown } = tab.props;
59
- if (!disabled)
60
- availableTabIndexes.push(index);
61
- return /* @__PURE__ */ import_react.default.createElement(import_styles.StyledTabButton, {
62
- key: tabId,
59
+ return React__default["default"].Children.map(tabs, (tab, index) => {
60
+ const {
61
+ tabId = '',
62
+ title = '',
63
+ style,
64
+ required = false,
65
+ disabled = false,
66
+ ref,
67
+ onClick,
68
+ onKeyDown
69
+ } = tab.props;
70
+ if (!disabled) availableTabIndexes.push(index);
71
+ return /*#__PURE__*/jsxRuntime.jsxs(styles.StyledTabButton, {
63
72
  role: "tab",
64
- ref: (t) => {
73
+ ref: t => {
65
74
  if (tabsRefAsArray.current && focusableTabsRef.current && tabsRef.current) {
66
75
  tabsRefAsArray.current[index] = t;
67
- if (!disabled && !focusableTabsRef.current.includes(t))
68
- focusableTabsRef.current.push(t);
76
+ if (!disabled && !focusableTabsRef.current.includes(t)) focusableTabsRef.current.push(t);
69
77
  tabsRef.current[index] = t;
70
- if (type === import_constants.TabTypes.SUBTABS && firstSubtabInternalRef && index === availableTabIndexes[0]) {
78
+
79
+ if (type === constants.TabTypes.SUBTABS && firstSubtabInternalRef && index === availableTabIndexes[0]) {
71
80
  firstSubtabInternalRef.current = t;
72
81
  }
73
- if (type !== import_constants.TabTypes.SUBTABS && index === availableTabIndexes[availableTabIndexes.length - 1]) {
82
+
83
+ if (type !== constants.TabTypes.SUBTABS && index === availableTabIndexes[availableTabIndexes.length - 1]) {
74
84
  lastTabInternalRef.current = t;
75
85
  }
76
- if (ref)
77
- ref.current = t;
86
+
87
+ if (ref) ref.current = t;
78
88
  }
79
89
  },
80
90
  type: "button",
81
91
  "aria-controls": tabId,
82
92
  "aria-selected": actualActiveTab === tabId,
83
93
  "aria-disabled": disabled,
84
- "aria-labelledby": `${tabId}-label`,
85
- isDSMobile,
86
- fixedTabsHeaders,
94
+ "aria-labelledby": "".concat(tabId, "-label"),
95
+ isDSMobile: isDSMobile,
96
+ fixedTabsHeaders: fixedTabsHeaders,
87
97
  tabType: type,
88
- title,
98
+ title: title,
89
99
  "data-required": required,
90
100
  "data-tab-id": tabId,
91
101
  "data-index": index,
92
- withCarousel,
102
+ withCarousel: withCarousel,
93
103
  isActive: actualActiveTab === tabId,
94
- disabled,
95
- showSeparator: showSeparator && type !== import_constants.TabTypes.NORMAL,
96
- "data-testid": type === import_constants.TabTypes.NORMAL ? import_DSTabsDatatestid.DSTabsDatatestid.TAB_BUTTON : import_DSTabsDatatestid.DSTabsDatatestid.SUBTAB_BUTTON,
97
- id: `${tabId}-label`,
98
- onClick: (e) => {
104
+ disabled: disabled,
105
+ showSeparator: showSeparator && type !== constants.TabTypes.NORMAL,
106
+ "data-testid": type === constants.TabTypes.NORMAL ? DSTabsDatatestid.DSTabsDatatestid.TAB_BUTTON : DSTabsDatatestid.DSTabsDatatestid.SUBTAB_BUTTON,
107
+ id: "".concat(tabId, "-label"),
108
+ onClick: e => {
99
109
  if (!disabled) {
100
110
  handleOnTabChange(tabId, e);
101
111
  updateIndicatorStyle();
102
112
  }
103
- if (onClick && !disabled)
104
- onClick(tabId, e);
113
+
114
+ if (onClick && !disabled) onClick(tabId, e);
105
115
  },
106
- onKeyDown: (e) => {
107
- if (e.key === "Enter")
108
- e.stopPropagation();
109
- if (!disabled)
110
- handleOnKeyDown(e);
111
- if (onKeyDown && !disabled)
112
- onKeyDown(e);
116
+ onKeyDown: e => {
117
+ if (e.key === 'Enter') e.stopPropagation();
118
+ if (!disabled) handleOnKeyDown(e);
119
+ if (onKeyDown && !disabled) onKeyDown(e);
113
120
  },
114
- style
115
- }, title, required && /* @__PURE__ */ import_react.default.createElement(import_styles.StyledRequiredMark, null, "\u25CF"));
121
+ style: style,
122
+ children: [title, required && (_StyledRequiredMark || (_StyledRequiredMark = /*#__PURE__*/_jsx__default["default"](styles.StyledRequiredMark, {}, void 0, "\u25CF")))]
123
+ }, tabId);
116
124
  });
117
- }, [
118
- tabs,
119
- actualActiveTab,
120
- isDSMobile,
121
- fixedTabsHeaders,
122
- type,
123
- withCarousel,
124
- showSeparator,
125
- tabsRefAsArray,
126
- focusableTabsRef,
127
- tabsRef,
128
- firstSubtabInternalRef,
129
- lastTabInternalRef,
130
- handleOnTabChange,
131
- updateIndicatorStyle,
132
- handleOnKeyDown
133
- ]);
134
- if (type === import_constants.TabTypes.SUBTABS && !isDSMobile) {
135
- return /* @__PURE__ */ import_react.default.createElement(import_styles.StyledSubTabsList, {
136
- withCarousel,
137
- "data-testid": import_DSTabsDatatestid.DSTabsDatatestid.SUB_TAB_LIST,
125
+ }, [tabs, actualActiveTab, isDSMobile, fixedTabsHeaders, type, withCarousel, showSeparator, tabsRefAsArray, focusableTabsRef, tabsRef, firstSubtabInternalRef, lastTabInternalRef, handleOnTabChange, updateIndicatorStyle, handleOnKeyDown]);
126
+
127
+ if (type === constants.TabTypes.SUBTABS && !isDSMobile) {
128
+ return /*#__PURE__*/jsxRuntime.jsx(styles.StyledSubTabsList, {
129
+ withCarousel: withCarousel,
130
+ "data-testid": DSTabsDatatestid.DSTabsDatatestid.SUB_TAB_LIST,
138
131
  ref: tabsListRef,
139
- role: "tablist"
140
- }, withCarousel ? /* @__PURE__ */ import_react.default.createElement(import_Carousel.Carousel, null, renderTabs) : renderTabs);
132
+ role: "tablist",
133
+ children: withCarousel ? /*#__PURE__*/_jsx__default["default"](Carousel.Carousel, {}, void 0, renderTabs) : renderTabs
134
+ });
141
135
  }
142
- return /* @__PURE__ */ import_react.default.createElement(import_styles.StyledTabList, {
143
- withCarousel,
136
+
137
+ return /*#__PURE__*/jsxRuntime.jsxs(styles.StyledTabList, {
138
+ withCarousel: withCarousel,
144
139
  ref: tabsListRef,
145
140
  role: "tablist",
146
- "data-testid": import_DSTabsDatatestid.DSTabsDatatestid.TAB_LIST,
147
- isDSMobile,
148
- fixedTabsHeaders,
149
- mobileGradients,
141
+ "data-testid": DSTabsDatatestid.DSTabsDatatestid.TAB_LIST,
142
+ isDSMobile: isDSMobile,
143
+ fixedTabsHeaders: fixedTabsHeaders,
144
+ mobileGradients: mobileGradients,
150
145
  onScroll: updateMobileGradients,
151
- indicatorStyle,
152
- tabType: type
153
- }, /* @__PURE__ */ import_react.default.createElement(import_styles.StyledTabWrapper, {
154
- isDSMobile,
155
- fixedTabsHeaders
156
- }, !isDSMobile && withCarousel ? /* @__PURE__ */ import_react.default.createElement(import_Carousel.Carousel, {
157
- updateIndicatorStyle
158
- }, renderTabs) : renderTabs), /* @__PURE__ */ import_react.default.createElement(import_styles.StyledSelectionIndicator, {
159
- isDSMobile,
160
- tabType: type
161
- }));
146
+ indicatorStyle: indicatorStyle,
147
+ tabType: type,
148
+ children: [/*#__PURE__*/_jsx__default["default"](styles.StyledTabWrapper, {
149
+ isDSMobile: isDSMobile,
150
+ fixedTabsHeaders: fixedTabsHeaders
151
+ }, void 0, !isDSMobile && withCarousel ? /*#__PURE__*/_jsx__default["default"](Carousel.Carousel, {
152
+ updateIndicatorStyle: updateIndicatorStyle
153
+ }, void 0, renderTabs) : renderTabs), /*#__PURE__*/_jsx__default["default"](styles.StyledSelectionIndicator, {
154
+ isDSMobile: isDSMobile,
155
+ tabType: type
156
+ })]
157
+ });
162
158
  };
163
- module.exports = __toCommonJS(TabBar_exports);
164
- //# sourceMappingURL=TabBar.js.map
159
+
160
+ exports.TabBar = TabBar;