@desynova-digital/components 8.19.53 → 8.19.55

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.
@@ -9,9 +9,10 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument
9
9
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
10
10
 
11
11
  var _templateObject = _taggedTemplateLiteral(['\n height: 100%;\n'], ['\n height: 100%;\n']),
12
- _templateObject2 = _taggedTemplateLiteral(['\n width: 100%;\n font-family: SFUIText-Medium;\n font-size: 14px;\n padding: 20px 15px;\n line-height: 19px;\n text-transform: uppercase;\n color: ', ';\n cursor: ', ';\n pointer-events: ', ';\n border-bottom: 1px solid ', ';\n text-align: center;\n &:hover {\n color: ', ';\n ', ';\n }\n'], ['\n width: 100%;\n font-family: SFUIText-Medium;\n font-size: 14px;\n padding: 20px 15px;\n line-height: 19px;\n text-transform: uppercase;\n color: ', ';\n cursor: ', ';\n pointer-events: ', ';\n border-bottom: 1px solid ', ';\n text-align: center;\n &:hover {\n color: ', ';\n ', ';\n }\n']),
13
- _templateObject3 = _taggedTemplateLiteral(['\n display: flex;\n justify-content: stretch;\n align-items: center;\n background: ', ';\n\n &.tab-list{\n align-items: stretch;\n }\n'], ['\n display: flex;\n justify-content: stretch;\n align-items: center;\n background: ', ';\n\n &.tab-list{\n align-items: stretch;\n }\n']),
14
- _templateObject4 = _taggedTemplateLiteral(['\n background:', ';\n display: flex;\n justify-content: stretch;\n align-items: center;\n'], ['\n background:', ';\n display: flex;\n justify-content: stretch;\n align-items: center;\n']);
12
+ _templateObject2 = _taggedTemplateLiteral(['\n width: 100%;\n font-family: SFUIText-Medium;\n font-size: 14px;\n padding: 20px 15px;\n line-height: 19px;\n text-transform: uppercase;\n position: relative;\n color: ', ';\n cursor: ', ';\n pointer-events: ', ';\n border-bottom: 1px solid\n ', ';\n text-align: center;\n &:hover {\n color: ', ';\n ', ';\n }\n &:hover {\n .option-list {\n opacity: 1;\n pointer-events: all;\n }\n }\n'], ['\n width: 100%;\n font-family: SFUIText-Medium;\n font-size: 14px;\n padding: 20px 15px;\n line-height: 19px;\n text-transform: uppercase;\n position: relative;\n color: ', ';\n cursor: ', ';\n pointer-events: ', ';\n border-bottom: 1px solid\n ', ';\n text-align: center;\n &:hover {\n color: ', ';\n ', ';\n }\n &:hover {\n .option-list {\n opacity: 1;\n pointer-events: all;\n }\n }\n']),
13
+ _templateObject3 = _taggedTemplateLiteral(['\n position: absolute;\n display: flex;\n padding: 15px;\n flex-direction: column;\n gap: 10px;\n z-index: 5;\n border-radius: 10px;\n background: #15212f;\n top: 72px;\n width: 130px;\n color: #fff;\n left: 50%;\n transform: translate(-50%, -50%);\n transition: opacity 0.3s ease-out;\n text-transform: capitalize;\n justify-content: center;\n align-items: center;\n pointer-events: none;\n opacity: 0;\n .active {\n color: #07d5cd;\n }\n .option {\n cursor: pointer;\n font-family: \'SFUIText-Regular\';\n font-size: 10px;\n font-style: normal;\n font-weight: 300;\n line-height: 18px;\n display: flex;\n align-self: stretch;\n &:hover {\n color: #07d5cd;\n }\n }\n &:before {\n content: \'\';\n position: absolute;\n width: 0;\n height: 0;\n border-left: 5px solid transparent;\n border-right: 5px solid transparent;\n border-bottom: 5px solid #00cec6;\n top: -5px;\n left: 50%;\n transform: translate(-50%);\n border-radius: 5px;\n }\n'], ['\n position: absolute;\n display: flex;\n padding: 15px;\n flex-direction: column;\n gap: 10px;\n z-index: 5;\n border-radius: 10px;\n background: #15212f;\n top: 72px;\n width: 130px;\n color: #fff;\n left: 50%;\n transform: translate(-50%, -50%);\n transition: opacity 0.3s ease-out;\n text-transform: capitalize;\n justify-content: center;\n align-items: center;\n pointer-events: none;\n opacity: 0;\n .active {\n color: #07d5cd;\n }\n .option {\n cursor: pointer;\n font-family: \'SFUIText-Regular\';\n font-size: 10px;\n font-style: normal;\n font-weight: 300;\n line-height: 18px;\n display: flex;\n align-self: stretch;\n &:hover {\n color: #07d5cd;\n }\n }\n &:before {\n content: \'\';\n position: absolute;\n width: 0;\n height: 0;\n border-left: 5px solid transparent;\n border-right: 5px solid transparent;\n border-bottom: 5px solid #00cec6;\n top: -5px;\n left: 50%;\n transform: translate(-50%);\n border-radius: 5px;\n }\n']),
14
+ _templateObject4 = _taggedTemplateLiteral(['\n display: flex;\n justify-content: stretch;\n align-items: center;\n background: ', ';\n\n &.tab-list {\n align-items: stretch;\n }\n'], ['\n display: flex;\n justify-content: stretch;\n align-items: center;\n background: ', ';\n\n &.tab-list {\n align-items: stretch;\n }\n']),
15
+ _templateObject5 = _taggedTemplateLiteral(['\n background: ', ';\n display: flex;\n justify-content: stretch;\n align-items: center;\n'], ['\n background: ', ';\n display: flex;\n justify-content: stretch;\n align-items: center;\n']);
15
16
 
16
17
  var _react = require('react');
17
18
 
@@ -48,7 +49,7 @@ var TabLink = _styledComponents2.default.a(_templateObject2, function (props) {
48
49
  }, function (props) {
49
50
  return props.selected ? 'default' : 'pointer';
50
51
  }, function (props) {
51
- return props.selected ? 'none' : 'all';
52
+ return props.selected && !props.allowPointerEvents ? 'none' : 'all';
52
53
  }, function (props) {
53
54
  return props.selected ? _tokens.colors[props.theme].tabs.navsSelectedBorder : _tokens.colors[props.theme].tabs.navsDefaultBorder;
54
55
  }, function (props) {
@@ -56,12 +57,13 @@ var TabLink = _styledComponents2.default.a(_templateObject2, function (props) {
56
57
  }, function (props) {
57
58
  return !props.selected ? 'border-bottom: 1px solid' + _tokens.colors[props.theme].tabs.navsSelectedBorder : null;
58
59
  });
60
+ var OptionList = _styledComponents2.default.div(_templateObject3);
59
61
 
60
- var TabLinkGroup = _styledComponents2.default.div(_templateObject3, function (props) {
62
+ var TabLinkGroup = _styledComponents2.default.div(_templateObject4, function (props) {
61
63
  return _tokens.colors[props.theme].tabs.navsBackground;
62
64
  });
63
65
 
64
- var TabContent = _styledComponents2.default.div(_templateObject4, function (props) {
66
+ var TabContent = _styledComponents2.default.div(_templateObject5, function (props) {
65
67
  return _tokens.colors[props.theme].tabs.contentBackground;
66
68
  });
67
69
 
@@ -81,7 +83,12 @@ var Tabs = function (_React$Component) {
81
83
  return child ? _react2.default.cloneElement(child, { theme: props.theme }) : null;
82
84
  });
83
85
  }
84
- _this.state = { selectedIndex: _this.getSelectedTabFromChildProps(_this.tabs) };
86
+
87
+ // Initialize separate state for selected indices of main tabs and nested tabs
88
+ _this.state = {
89
+ selectedMainTabIndex: _this.getSelectedTabFromChildProps(_this.tabs),
90
+ selectedNestedTabIndex: null
91
+ };
85
92
  return _this;
86
93
  }
87
94
 
@@ -93,8 +100,8 @@ var Tabs = function (_React$Component) {
93
100
  if (!cosmosKey) return;
94
101
 
95
102
  var storedIndex = tabStore[cosmosKey];
96
- if (storedIndex && storedIndex !== this.state.selectedIndex) {
97
- this.setState({ selectedIndex: tabStore[cosmosKey] });
103
+ if (storedIndex && storedIndex !== this.state.selectedMainTabIndex) {
104
+ this.setState({ selectedMainTabIndex: tabStore[cosmosKey] });
98
105
  }
99
106
  }
100
107
  }, {
@@ -130,9 +137,8 @@ var Tabs = function (_React$Component) {
130
137
  if (cosmosKey) {
131
138
  tabStore[cosmosKey] = nextIndex;
132
139
  }
133
-
134
- this.setState({ selectedIndex: nextIndex });
135
140
  }
141
+ this.setState({ selectedIndex: nextIndex, selectedNestedTabIndex: null });
136
142
  }
137
143
  }
138
144
  }, {
@@ -144,10 +150,63 @@ var Tabs = function (_React$Component) {
144
150
 
145
151
  return selectedIndex;
146
152
  }
153
+ }, {
154
+ key: 'changeNestedTab',
155
+ value: function changeNestedTab(nextIndex, parentTabIndex) {
156
+ // Deselect main tab when changing the nested tab
157
+ this.setState({ selectedNestedTabIndex: nextIndex, selectedIndex: null });
158
+ if (this.props.onSelect) {
159
+ this.props.onSelect(nextIndex, parentTabIndex);
160
+ }
161
+ }
162
+ }, {
163
+ key: 'renderNestedTabs',
164
+ value: function renderNestedTabs(tab, index) {
165
+ var _this2 = this;
166
+
167
+ if (!tab.props.children || !Array.isArray(tab.props.children)) {
168
+ return null;
169
+ }
170
+
171
+ var parentTabRef = _react2.default.createRef();
172
+
173
+ return _react2.default.createElement(
174
+ _react2.default.Fragment,
175
+ null,
176
+ _react2.default.createElement(
177
+ TabLink,
178
+ {
179
+ ref: parentTabRef,
180
+ selected: this.state.selectedIndex === index,
181
+ allowPointerEvents: true,
182
+ key: tab.props.label,
183
+ theme: this.props.theme,
184
+ className: this.state.selectedIndex === index ? 'tab-list-item active' : 'tab-list-item' },
185
+ tab.props.label,
186
+ _react2.default.createElement(
187
+ OptionList,
188
+ { className: 'option-list', style: {} },
189
+ tab.props.children.map(function (nestedTab, nestedIndex) {
190
+ return nestedTab ? _react2.default.createElement(
191
+ 'div',
192
+ {
193
+ key: nestedTab.props.label,
194
+ className: _this2.state.selectedNestedTabIndex === nestedIndex ? 'option active' : 'option',
195
+ theme: _this2.props.theme,
196
+ onClick: function onClick() {
197
+ return _this2.changeNestedTab(nestedIndex, index);
198
+ } },
199
+ nestedTab.props.label
200
+ ) : null;
201
+ })
202
+ )
203
+ )
204
+ );
205
+ }
147
206
  }, {
148
207
  key: 'render',
149
208
  value: function render() {
150
- var _this2 = this;
209
+ var _this3 = this;
151
210
 
152
211
  var selectedIndex = this.getSelectedTabFromPropsOrState();
153
212
 
@@ -161,17 +220,20 @@ var Tabs = function (_React$Component) {
161
220
  return val1.props.index - val2.props.index;
162
221
  }).map(function (tab, index) {
163
222
  return _react2.default.createElement(
164
- TabLink,
165
- {
166
- onClick: function onClick() {
167
- return _this2.changeTab(index);
168
- },
169
- key: tab.props.label,
170
- selected: selectedIndex === index,
171
- theme: _this2.props.theme,
172
- className: selectedIndex === index ? 'tab-list-item active' : 'tab-list-item'
173
- },
174
- tab.props.label
223
+ _react2.default.Fragment,
224
+ null,
225
+ !tab.props.abstract ? _react2.default.createElement(
226
+ TabLink,
227
+ {
228
+ onClick: function onClick() {
229
+ return _this3.changeTab(index);
230
+ },
231
+ key: tab.props.label,
232
+ selected: selectedIndex === index,
233
+ theme: _this3.props.theme,
234
+ className: selectedIndex === index ? 'tab-list-item active' : 'tab-list-item' },
235
+ tab.props.label
236
+ ) : _this3.renderNestedTabs(tab, index)
175
237
  );
176
238
  })
177
239
  ),
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@desynova-digital/components",
3
- "version": "8.19.53",
3
+ "version": "8.19.55",
4
4
  "description": "Components for Desynova Digital",
5
5
  "main": "index.js",
6
6
  "author": "desynova-digital",
7
7
  "license": "MIT",
8
8
  "repository": "desynova-digital",
9
9
  "dependencies": {
10
- "@desynova-digital/tokens": "8.19.53",
10
+ "@desynova-digital/tokens": "8.19.55",
11
11
  "prop-types": "^15.7.2",
12
12
  "styled-components": "^4.3.2"
13
13
  },