@dnb/eufemia 9.23.0-beta.3 → 9.23.0-beta.4
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.
- package/CHANGELOG.md +16 -0
- package/cjs/components/accordion/style/dnb-accordion.css +92 -0
- package/cjs/components/accordion/style/dnb-accordion.min.css +1 -1
- package/cjs/components/accordion/style/dnb-accordion.scss +3 -0
- package/cjs/components/autocomplete/style/dnb-autocomplete.css +1652 -64
- package/cjs/components/autocomplete/style/dnb-autocomplete.min.css +2 -2
- package/cjs/components/autocomplete/style/dnb-autocomplete.scss +1 -2
- package/cjs/components/button/style/dnb-button.css +192 -0
- package/cjs/components/button/style/dnb-button.min.css +1 -1
- package/cjs/components/button/style/dnb-button.scss +1 -1
- package/cjs/components/date-picker/style/dnb-date-picker.css +729 -0
- package/cjs/components/date-picker/style/dnb-date-picker.min.css +2 -2
- package/cjs/components/dialog/style/dnb-dialog.css +1870 -79
- package/cjs/components/dialog/style/dnb-dialog.min.css +1 -1
- package/cjs/components/dialog/style/dnb-dialog.scss +1 -1
- package/cjs/components/drawer/style/dnb-drawer.css +1870 -79
- package/cjs/components/drawer/style/dnb-drawer.min.css +1 -1
- package/cjs/components/drawer/style/dnb-drawer.scss +1 -1
- package/cjs/components/dropdown/style/dnb-dropdown.css +192 -0
- package/cjs/components/dropdown/style/dnb-dropdown.min.css +1 -1
- package/cjs/components/dropdown/style/themes/dnb-dropdown-theme-ui.css +12 -11
- package/cjs/components/dropdown/style/themes/dnb-dropdown-theme-ui.min.css +1 -1
- package/cjs/components/dropdown/style/themes/dnb-dropdown-theme-ui.scss +4 -1
- package/cjs/components/global-error/style/dnb-global-error.css +192 -0
- package/cjs/components/global-error/style/dnb-global-error.min.css +1 -1
- package/cjs/components/global-status/style/dnb-global-status.css +192 -0
- package/cjs/components/global-status/style/dnb-global-status.min.css +1 -1
- package/cjs/components/help-button/style/dnb-help-button.css +773 -0
- package/cjs/components/help-button/style/dnb-help-button.min.css +1 -1
- package/cjs/components/help-button/style/dnb-help-button.scss +3 -0
- package/cjs/components/icon/Icon.d.ts +1 -1
- package/cjs/components/icon-primary/IconPrimary.d.ts +1 -1
- package/cjs/components/input/style/dnb-input.css +371 -0
- package/cjs/components/input/style/dnb-input.min.css +1 -1
- package/cjs/components/input/style/dnb-input.scss +1 -0
- package/cjs/components/input-masked/style/dnb-input-masked.css +371 -0
- package/cjs/components/input-masked/style/dnb-input-masked.min.css +1 -1
- package/cjs/components/modal/style/dnb-modal.css +268 -0
- package/cjs/components/modal/style/dnb-modal.min.css +1 -1
- package/cjs/components/modal/style/dnb-modal.scss +1 -1
- package/cjs/components/pagination/style/dnb-pagination.css +192 -0
- package/cjs/components/pagination/style/dnb-pagination.min.css +1 -1
- package/cjs/components/slider/style/dnb-slider.css +192 -0
- package/cjs/components/slider/style/dnb-slider.min.css +1 -1
- package/cjs/components/step-indicator/style/dnb-step-indicator.css +773 -0
- package/cjs/components/step-indicator/style/dnb-step-indicator.min.css +1 -1
- package/cjs/components/step-indicator/style/dnb-step-indicator.scss +2 -0
- package/cjs/components/tabs/Tabs.d.ts +6 -0
- package/cjs/components/tabs/Tabs.js +147 -151
- package/cjs/components/tabs/style/_tabs.scss +83 -60
- package/cjs/components/tabs/style/dnb-tabs.css +189 -181
- package/cjs/components/tabs/style/dnb-tabs.min.css +1 -1
- package/cjs/components/tag/style/dnb-tag.css +192 -0
- package/cjs/components/tag/style/dnb-tag.min.css +1 -1
- package/cjs/components/toggle-button/style/dnb-toggle-button.css +192 -0
- package/cjs/components/toggle-button/style/dnb-toggle-button.min.css +1 -1
- package/cjs/components/toggle-button/style/dnb-toggle-button.scss +2 -0
- package/cjs/shared/Eufemia.js +1 -1
- package/cjs/style/dnb-ui-components.css +189 -181
- package/cjs/style/dnb-ui-components.min.css +1 -1
- package/cjs/style/themes/theme-open-banking/dnb-theme-open-banking.css +12 -11
- package/cjs/style/themes/theme-open-banking/dnb-theme-open-banking.min.css +1 -1
- package/cjs/style/themes/theme-ui/dnb-theme-ui.css +12 -11
- package/cjs/style/themes/theme-ui/dnb-theme-ui.min.css +1 -1
- package/components/accordion/style/dnb-accordion.css +92 -0
- package/components/accordion/style/dnb-accordion.min.css +1 -1
- package/components/accordion/style/dnb-accordion.scss +3 -0
- package/components/autocomplete/style/dnb-autocomplete.css +1652 -64
- package/components/autocomplete/style/dnb-autocomplete.min.css +2 -2
- package/components/autocomplete/style/dnb-autocomplete.scss +1 -2
- package/components/button/style/dnb-button.css +192 -0
- package/components/button/style/dnb-button.min.css +1 -1
- package/components/button/style/dnb-button.scss +1 -1
- package/components/date-picker/style/dnb-date-picker.css +729 -0
- package/components/date-picker/style/dnb-date-picker.min.css +2 -2
- package/components/dialog/style/dnb-dialog.css +1870 -79
- package/components/dialog/style/dnb-dialog.min.css +1 -1
- package/components/dialog/style/dnb-dialog.scss +1 -1
- package/components/drawer/style/dnb-drawer.css +1870 -79
- package/components/drawer/style/dnb-drawer.min.css +1 -1
- package/components/drawer/style/dnb-drawer.scss +1 -1
- package/components/dropdown/style/dnb-dropdown.css +192 -0
- package/components/dropdown/style/dnb-dropdown.min.css +1 -1
- package/components/dropdown/style/themes/dnb-dropdown-theme-ui.css +12 -11
- package/components/dropdown/style/themes/dnb-dropdown-theme-ui.min.css +1 -1
- package/components/dropdown/style/themes/dnb-dropdown-theme-ui.scss +4 -1
- package/components/global-error/style/dnb-global-error.css +192 -0
- package/components/global-error/style/dnb-global-error.min.css +1 -1
- package/components/global-status/style/dnb-global-status.css +192 -0
- package/components/global-status/style/dnb-global-status.min.css +1 -1
- package/components/help-button/style/dnb-help-button.css +773 -0
- package/components/help-button/style/dnb-help-button.min.css +1 -1
- package/components/help-button/style/dnb-help-button.scss +3 -0
- package/components/icon/Icon.d.ts +1 -1
- package/components/icon-primary/IconPrimary.d.ts +1 -1
- package/components/input/style/dnb-input.css +371 -0
- package/components/input/style/dnb-input.min.css +1 -1
- package/components/input/style/dnb-input.scss +1 -0
- package/components/input-masked/style/dnb-input-masked.css +371 -0
- package/components/input-masked/style/dnb-input-masked.min.css +1 -1
- package/components/modal/style/dnb-modal.css +268 -0
- package/components/modal/style/dnb-modal.min.css +1 -1
- package/components/modal/style/dnb-modal.scss +1 -1
- package/components/pagination/style/dnb-pagination.css +192 -0
- package/components/pagination/style/dnb-pagination.min.css +1 -1
- package/components/slider/style/dnb-slider.css +192 -0
- package/components/slider/style/dnb-slider.min.css +1 -1
- package/components/step-indicator/style/dnb-step-indicator.css +773 -0
- package/components/step-indicator/style/dnb-step-indicator.min.css +1 -1
- package/components/step-indicator/style/dnb-step-indicator.scss +2 -0
- package/components/tabs/Tabs.d.ts +6 -0
- package/components/tabs/Tabs.js +146 -150
- package/components/tabs/style/_tabs.scss +83 -60
- package/components/tabs/style/dnb-tabs.css +189 -181
- package/components/tabs/style/dnb-tabs.min.css +1 -1
- package/components/tag/style/dnb-tag.css +192 -0
- package/components/tag/style/dnb-tag.min.css +1 -1
- package/components/toggle-button/style/dnb-toggle-button.css +192 -0
- package/components/toggle-button/style/dnb-toggle-button.min.css +1 -1
- package/components/toggle-button/style/dnb-toggle-button.scss +2 -0
- package/es/components/accordion/style/dnb-accordion.css +92 -0
- package/es/components/accordion/style/dnb-accordion.min.css +1 -1
- package/es/components/accordion/style/dnb-accordion.scss +3 -0
- package/es/components/autocomplete/style/dnb-autocomplete.css +1652 -64
- package/es/components/autocomplete/style/dnb-autocomplete.min.css +2 -2
- package/es/components/autocomplete/style/dnb-autocomplete.scss +1 -2
- package/es/components/button/style/dnb-button.css +192 -0
- package/es/components/button/style/dnb-button.min.css +1 -1
- package/es/components/button/style/dnb-button.scss +1 -1
- package/es/components/date-picker/style/dnb-date-picker.css +729 -0
- package/es/components/date-picker/style/dnb-date-picker.min.css +2 -2
- package/es/components/dialog/style/dnb-dialog.css +1870 -79
- package/es/components/dialog/style/dnb-dialog.min.css +1 -1
- package/es/components/dialog/style/dnb-dialog.scss +1 -1
- package/es/components/drawer/style/dnb-drawer.css +1870 -79
- package/es/components/drawer/style/dnb-drawer.min.css +1 -1
- package/es/components/drawer/style/dnb-drawer.scss +1 -1
- package/es/components/dropdown/style/dnb-dropdown.css +192 -0
- package/es/components/dropdown/style/dnb-dropdown.min.css +1 -1
- package/es/components/dropdown/style/themes/dnb-dropdown-theme-ui.css +12 -11
- package/es/components/dropdown/style/themes/dnb-dropdown-theme-ui.min.css +1 -1
- package/es/components/dropdown/style/themes/dnb-dropdown-theme-ui.scss +4 -1
- package/es/components/global-error/style/dnb-global-error.css +192 -0
- package/es/components/global-error/style/dnb-global-error.min.css +1 -1
- package/es/components/global-status/style/dnb-global-status.css +192 -0
- package/es/components/global-status/style/dnb-global-status.min.css +1 -1
- package/es/components/help-button/style/dnb-help-button.css +773 -0
- package/es/components/help-button/style/dnb-help-button.min.css +1 -1
- package/es/components/help-button/style/dnb-help-button.scss +3 -0
- package/es/components/icon/Icon.d.ts +1 -1
- package/es/components/icon-primary/IconPrimary.d.ts +1 -1
- package/es/components/input/style/dnb-input.css +371 -0
- package/es/components/input/style/dnb-input.min.css +1 -1
- package/es/components/input/style/dnb-input.scss +1 -0
- package/es/components/input-masked/style/dnb-input-masked.css +371 -0
- package/es/components/input-masked/style/dnb-input-masked.min.css +1 -1
- package/es/components/modal/style/dnb-modal.css +268 -0
- package/es/components/modal/style/dnb-modal.min.css +1 -1
- package/es/components/modal/style/dnb-modal.scss +1 -1
- package/es/components/pagination/style/dnb-pagination.css +192 -0
- package/es/components/pagination/style/dnb-pagination.min.css +1 -1
- package/es/components/slider/style/dnb-slider.css +192 -0
- package/es/components/slider/style/dnb-slider.min.css +1 -1
- package/es/components/step-indicator/style/dnb-step-indicator.css +773 -0
- package/es/components/step-indicator/style/dnb-step-indicator.min.css +1 -1
- package/es/components/step-indicator/style/dnb-step-indicator.scss +2 -0
- package/es/components/tabs/Tabs.d.ts +6 -0
- package/es/components/tabs/Tabs.js +110 -114
- package/es/components/tabs/style/_tabs.scss +83 -60
- package/es/components/tabs/style/dnb-tabs.css +189 -181
- package/es/components/tabs/style/dnb-tabs.min.css +1 -1
- package/es/components/tag/style/dnb-tag.css +192 -0
- package/es/components/tag/style/dnb-tag.min.css +1 -1
- package/es/components/toggle-button/style/dnb-toggle-button.css +192 -0
- package/es/components/toggle-button/style/dnb-toggle-button.min.css +1 -1
- package/es/components/toggle-button/style/dnb-toggle-button.scss +2 -0
- package/es/shared/Eufemia.js +1 -1
- package/es/style/dnb-ui-components.css +189 -181
- package/es/style/dnb-ui-components.min.css +1 -1
- package/es/style/themes/theme-open-banking/dnb-theme-open-banking.css +12 -11
- package/es/style/themes/theme-open-banking/dnb-theme-open-banking.min.css +1 -1
- package/es/style/themes/theme-ui/dnb-theme-ui.css +12 -11
- package/es/style/themes/theme-ui/dnb-theme-ui.min.css +1 -1
- package/esm/dnb-ui-basis.min.mjs +1 -1
- package/esm/dnb-ui-components.min.mjs +1 -1
- package/esm/dnb-ui-elements.min.mjs +1 -1
- package/esm/dnb-ui-extensions.min.mjs +1 -1
- package/esm/dnb-ui-lib.min.mjs +2 -2
- package/esm/dnb-ui-web-components.min.mjs +2 -2
- package/package.json +1 -1
- package/shared/Eufemia.js +1 -1
- package/style/dnb-ui-components.css +189 -181
- package/style/dnb-ui-components.min.css +1 -1
- package/style/themes/theme-open-banking/dnb-theme-open-banking.css +12 -11
- package/style/themes/theme-open-banking/dnb-theme-open-banking.min.css +1 -1
- package/style/themes/theme-ui/dnb-theme-ui.css +12 -11
- package/style/themes/theme-ui/dnb-theme-ui.min.css +1 -1
- package/umd/dnb-ui-basis.min.js +1 -1
- package/umd/dnb-ui-components.min.js +1 -1
- package/umd/dnb-ui-elements.min.js +1 -1
- package/umd/dnb-ui-extensions.min.js +1 -1
- package/umd/dnb-ui-lib.min.js +2 -2
- package/umd/dnb-ui-web-components.min.js +4 -4
package/components/tabs/Tabs.js
CHANGED
|
@@ -23,9 +23,9 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
23
23
|
|
|
24
24
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
25
25
|
|
|
26
|
-
import "core-js/modules/es.parse-float.js";
|
|
27
26
|
import "core-js/modules/es.array.filter.js";
|
|
28
27
|
import "core-js/modules/es.object.to-string.js";
|
|
28
|
+
import "core-js/modules/es.parse-float.js";
|
|
29
29
|
import "core-js/modules/es.array.reduce.js";
|
|
30
30
|
import "core-js/modules/es.array.map.js";
|
|
31
31
|
import "core-js/modules/es.array.concat.js";
|
|
@@ -68,18 +68,26 @@ var Tabs = function (_React$PureComponent) {
|
|
|
68
68
|
if (_this._isMounted) {
|
|
69
69
|
_this.addScrollBehaviour();
|
|
70
70
|
|
|
71
|
-
_this.
|
|
71
|
+
_this.setScrollbarState();
|
|
72
|
+
|
|
73
|
+
_this.scrollToTab({
|
|
74
|
+
type: 'focus',
|
|
75
|
+
behavior: 'auto'
|
|
76
|
+
});
|
|
72
77
|
|
|
73
|
-
_this.scrollToTab(
|
|
78
|
+
_this.scrollToTab({
|
|
79
|
+
type: 'selected',
|
|
80
|
+
behavior: 'auto'
|
|
81
|
+
});
|
|
74
82
|
|
|
75
|
-
if (_this.
|
|
76
|
-
_this.setState(null, _this.
|
|
83
|
+
if (_this.hasLastUsedTab() !== null) {
|
|
84
|
+
_this.setState(null, _this.setFocusOnTabButton);
|
|
77
85
|
}
|
|
78
86
|
}
|
|
79
87
|
});
|
|
80
88
|
|
|
81
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
82
|
-
var hasScrollbar = _this.
|
|
89
|
+
_defineProperty(_assertThisInitialized(_this), "setScrollbarState", function () {
|
|
90
|
+
var hasScrollbar = _this.hasScrollbar();
|
|
83
91
|
|
|
84
92
|
if (hasScrollbar !== _this.state.hasScrollbar) {
|
|
85
93
|
_this.setState({
|
|
@@ -87,42 +95,14 @@ var Tabs = function (_React$PureComponent) {
|
|
|
87
95
|
});
|
|
88
96
|
}
|
|
89
97
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
if (Math.ceil(window.innerWidth / 16) <= 40 || _this.isAtEdge()) {
|
|
93
|
-
if (!_this._tabsRef.current.style.marginLeft) {
|
|
94
|
-
var tabsStyle = window.getComputedStyle(_this._tabsRef.current);
|
|
95
|
-
|
|
96
|
-
if (!(Math.abs(parseFloat(tabsStyle.marginLeft)) > 0)) {
|
|
97
|
-
var diff = window.innerWidth - _this._tabsRef.current.offsetWidth;
|
|
98
|
-
var val = Math.round(diff / 16) / 2 * 16;
|
|
99
|
-
_this._tabsRef.current.style.marginLeft = "-".concat(val, "px");
|
|
100
|
-
_this._tabsRef.current.style.marginRight = "-".concat(val, "px");
|
|
101
|
-
|
|
102
|
-
if (val < 32) {
|
|
103
|
-
val = 32;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
var tablistStyle = window.getComputedStyle(_this._tablistRef.current);
|
|
107
|
-
_this._tablistRef.current.style.paddingLeft = "".concat((parseFloat(tablistStyle.paddingLeft) || 0) + val, "px");
|
|
108
|
-
_this._tablistRef.current.style.paddingRight = "".concat((parseFloat(tablistStyle.paddingRight) || 0) + val, "px");
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
} else {
|
|
112
|
-
_this._tabsRef.current.style.marginLeft = '';
|
|
113
|
-
_this._tabsRef.current.style.marginRight = '';
|
|
114
|
-
_this._tablistRef.current.style.paddingLeft = '';
|
|
115
|
-
_this._tablistRef.current.style.paddingRight = '';
|
|
116
|
-
}
|
|
117
|
-
} catch (e) {}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
_this.setState({
|
|
121
|
-
atEdge: _this.isAtEdge()
|
|
122
|
-
});
|
|
98
|
+
return hasScrollbar;
|
|
99
|
+
});
|
|
123
100
|
|
|
124
|
-
|
|
125
|
-
|
|
101
|
+
_defineProperty(_assertThisInitialized(_this), "onResizeHandler", function () {
|
|
102
|
+
if (_this.setScrollbarState()) {
|
|
103
|
+
_this.scrollToTab({
|
|
104
|
+
type: 'selected'
|
|
105
|
+
});
|
|
126
106
|
}
|
|
127
107
|
});
|
|
128
108
|
|
|
@@ -167,7 +147,9 @@ var Tabs = function (_React$PureComponent) {
|
|
|
167
147
|
|
|
168
148
|
_this.focusTab(key, e, 'step');
|
|
169
149
|
|
|
170
|
-
_this.scrollToTab(
|
|
150
|
+
_this.scrollToTab({
|
|
151
|
+
type: 'focus'
|
|
152
|
+
});
|
|
171
153
|
});
|
|
172
154
|
|
|
173
155
|
_defineProperty(_assertThisInitialized(_this), "focusLastTab", function (e) {
|
|
@@ -175,31 +157,41 @@ var Tabs = function (_React$PureComponent) {
|
|
|
175
157
|
|
|
176
158
|
_this.focusTab(key, e, 'step');
|
|
177
159
|
|
|
178
|
-
_this.scrollToTab(
|
|
160
|
+
_this.scrollToTab({
|
|
161
|
+
type: 'focus'
|
|
162
|
+
});
|
|
179
163
|
});
|
|
180
164
|
|
|
181
165
|
_defineProperty(_assertThisInitialized(_this), "focusPrevTab", function (e) {
|
|
182
166
|
_this.focusTab(-1, e, 'step');
|
|
183
167
|
|
|
184
|
-
_this.scrollToTab(
|
|
168
|
+
_this.scrollToTab({
|
|
169
|
+
type: 'focus'
|
|
170
|
+
});
|
|
185
171
|
});
|
|
186
172
|
|
|
187
173
|
_defineProperty(_assertThisInitialized(_this), "focusNextTab", function (e) {
|
|
188
174
|
_this.focusTab(+1, e, 'step');
|
|
189
175
|
|
|
190
|
-
_this.scrollToTab(
|
|
176
|
+
_this.scrollToTab({
|
|
177
|
+
type: 'focus'
|
|
178
|
+
});
|
|
191
179
|
});
|
|
192
180
|
|
|
193
181
|
_defineProperty(_assertThisInitialized(_this), "openPrevTab", function (e) {
|
|
194
182
|
_this.openTab(-1, e, 'step');
|
|
195
183
|
|
|
196
|
-
_this.scrollToTab(
|
|
184
|
+
_this.scrollToTab({
|
|
185
|
+
type: 'selected'
|
|
186
|
+
});
|
|
197
187
|
});
|
|
198
188
|
|
|
199
189
|
_defineProperty(_assertThisInitialized(_this), "openNextTab", function (e) {
|
|
200
190
|
_this.openTab(+1, e, 'step');
|
|
201
191
|
|
|
202
|
-
_this.scrollToTab(
|
|
192
|
+
_this.scrollToTab({
|
|
193
|
+
type: 'selected'
|
|
194
|
+
});
|
|
203
195
|
});
|
|
204
196
|
|
|
205
197
|
_defineProperty(_assertThisInitialized(_this), "handleVerticalScroll", function () {
|
|
@@ -211,14 +203,20 @@ var Tabs = function (_React$PureComponent) {
|
|
|
211
203
|
}
|
|
212
204
|
});
|
|
213
205
|
|
|
206
|
+
_defineProperty(_assertThisInitialized(_this), "onMouseDown", function (event) {
|
|
207
|
+
event.preventDefault();
|
|
208
|
+
});
|
|
209
|
+
|
|
214
210
|
_defineProperty(_assertThisInitialized(_this), "onKeyDownHandler", function (event) {
|
|
215
211
|
switch (keycode(event)) {
|
|
216
212
|
case 'enter':
|
|
217
213
|
try {
|
|
218
214
|
var elem = document.getElementById("".concat(_this._id, "-content"));
|
|
219
|
-
elem.focus(
|
|
215
|
+
elem.focus({
|
|
216
|
+
preventScroll: true
|
|
217
|
+
});
|
|
220
218
|
} catch (e) {
|
|
221
|
-
|
|
219
|
+
_this.warnAboutMissingContainer();
|
|
222
220
|
}
|
|
223
221
|
|
|
224
222
|
break;
|
|
@@ -248,7 +246,9 @@ var Tabs = function (_React$PureComponent) {
|
|
|
248
246
|
if (ret !== false) {
|
|
249
247
|
_this.openTab(selected_key, event);
|
|
250
248
|
|
|
251
|
-
_this.scrollToTab(
|
|
249
|
+
_this.scrollToTab({
|
|
250
|
+
type: 'selected'
|
|
251
|
+
});
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
254
|
});
|
|
@@ -291,7 +291,7 @@ var Tabs = function (_React$PureComponent) {
|
|
|
291
291
|
_this.setState({
|
|
292
292
|
focus_key: focus_key,
|
|
293
293
|
_listenForPropChanges: false
|
|
294
|
-
}, _this.
|
|
294
|
+
}, _this.setFocusOnTabButton);
|
|
295
295
|
|
|
296
296
|
dispatchCustomElementEvent(_assertThisInitialized(_this), 'on_focus', _this.getEventArgs({
|
|
297
297
|
event: event,
|
|
@@ -301,14 +301,16 @@ var Tabs = function (_React$PureComponent) {
|
|
|
301
301
|
_this.setWhatInput();
|
|
302
302
|
});
|
|
303
303
|
|
|
304
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
304
|
+
_defineProperty(_assertThisInitialized(_this), "setFocusOnTabButton", function () {
|
|
305
305
|
try {
|
|
306
306
|
var elem = _this._tablistRef.current.querySelector('.dnb-tabs__button.focus');
|
|
307
307
|
|
|
308
|
-
elem.focus(
|
|
308
|
+
elem.focus({
|
|
309
|
+
preventScroll: true
|
|
310
|
+
});
|
|
309
311
|
|
|
310
312
|
if (!document.getElementById("".concat(_this._id, "-content")) && typeof process !== 'undefined' && process.env.NODE_ENV !== 'test') {
|
|
311
|
-
|
|
313
|
+
_this.warnAboutMissingContainer();
|
|
312
314
|
}
|
|
313
315
|
} catch (e) {
|
|
314
316
|
warn(e);
|
|
@@ -431,21 +433,20 @@ var Tabs = function (_React$PureComponent) {
|
|
|
431
433
|
align = _this$props3.align,
|
|
432
434
|
tabs_style = _this$props3.tabs_style,
|
|
433
435
|
tabs_spacing = _this$props3.tabs_spacing,
|
|
434
|
-
no_border = _this$props3.no_border
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
atEdge = _this$state.atEdge;
|
|
436
|
+
no_border = _this$props3.no_border,
|
|
437
|
+
nav_button_edge = _this$props3.nav_button_edge;
|
|
438
|
+
var hasScrollbar = _this.state.hasScrollbar;
|
|
438
439
|
return React.createElement("div", _extends({
|
|
439
|
-
className: classnames('dnb-tabs__tabs', className, align && "dnb-tabs__tabs--".concat(align), tabs_style && "dnb-section dnb-section--".concat(tabs_style), tabs_spacing && "dnb-section--spacing-".concat(isTrue(tabs_spacing) ? 'default' : tabs_spacing), hasScrollbar && 'dnb-tabs--has-scrollbar',
|
|
440
|
+
className: classnames('dnb-tabs__tabs', className, align && "dnb-tabs__tabs--".concat(align), tabs_style && "dnb-section dnb-section--".concat(tabs_style), tabs_spacing && "dnb-section--spacing-".concat(isTrue(tabs_spacing) ? 'default' : tabs_spacing), hasScrollbar && 'dnb-tabs--has-scrollbar', nav_button_edge && 'dnb-tabs--at-edge', no_border && 'dnb-tabs__tabs--no-border'),
|
|
440
441
|
ref: _this._tabsRef
|
|
441
442
|
}, rest), React.createElement(ScrollNavButton, {
|
|
442
443
|
onMouseDown: _this.openPrevTab,
|
|
443
444
|
icon: "chevron_left",
|
|
444
|
-
className: classnames(hasScrollbar && 'dnb-tabs__scroll-nav-button--visible', _this.state.isFirst && 'dnb-tabs__scroll-nav-button--hide')
|
|
445
|
+
className: classnames(hasScrollbar && typeof _this.state.isFirst !== 'undefined' && 'dnb-tabs__scroll-nav-button--visible', _this.state.isFirst && 'dnb-tabs__scroll-nav-button--hide')
|
|
445
446
|
}), children, React.createElement(ScrollNavButton, {
|
|
446
447
|
onMouseDown: _this.openNextTab,
|
|
447
448
|
icon: "chevron_right",
|
|
448
|
-
className: classnames(hasScrollbar && 'dnb-tabs__scroll-nav-button--visible', _this.state.isLast && 'dnb-tabs__scroll-nav-button--hide')
|
|
449
|
+
className: classnames(hasScrollbar && typeof _this.state.isLast !== 'undefined' && 'dnb-tabs__scroll-nav-button--visible', _this.state.isLast && 'dnb-tabs__scroll-nav-button--hide')
|
|
449
450
|
}));
|
|
450
451
|
});
|
|
451
452
|
|
|
@@ -517,6 +518,7 @@ var Tabs = function (_React$PureComponent) {
|
|
|
517
518
|
onMouseEnter: _this.onMouseEnterHandler,
|
|
518
519
|
onClick: _this.onClickHandler,
|
|
519
520
|
onKeyUp: _this.onKeyDownHandler,
|
|
521
|
+
onMouseDown: _this.onMouseDown,
|
|
520
522
|
"data-tab-key": key
|
|
521
523
|
}, itemParams), React.createElement("span", {
|
|
522
524
|
className: classnames('dnb-tabs__button__title', createSkeletonClass('font', skeleton, _this.context))
|
|
@@ -561,7 +563,6 @@ var Tabs = function (_React$PureComponent) {
|
|
|
561
563
|
|
|
562
564
|
_this.state = {
|
|
563
565
|
data: data,
|
|
564
|
-
lastPosition: lastPosition,
|
|
565
566
|
selected_key: _selected_key,
|
|
566
567
|
focus_key: _selected_key,
|
|
567
568
|
atEdge: false,
|
|
@@ -607,8 +608,6 @@ var Tabs = function (_React$PureComponent) {
|
|
|
607
608
|
this._eventEmitter = null;
|
|
608
609
|
}
|
|
609
610
|
|
|
610
|
-
clearTimeout(this._scrollToTabTimeout);
|
|
611
|
-
|
|
612
611
|
if (typeof window !== 'undefined') {
|
|
613
612
|
window.removeEventListener('resize', this.onResizeHandler);
|
|
614
613
|
window.removeEventListener('load', this.init);
|
|
@@ -617,14 +616,16 @@ var Tabs = function (_React$PureComponent) {
|
|
|
617
616
|
}, {
|
|
618
617
|
key: "componentDidUpdate",
|
|
619
618
|
value: function componentDidUpdate(props) {
|
|
620
|
-
this.
|
|
619
|
+
if (this._eventEmitter && (this.props.selected_key !== props.selected_key || this.props.data !== props.data)) {
|
|
620
|
+
this.onResizeHandler();
|
|
621
621
|
|
|
622
|
-
|
|
623
|
-
|
|
622
|
+
if (this._eventEmitter) {
|
|
623
|
+
var selected_key = this.state.selected_key;
|
|
624
624
|
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
625
|
+
this._eventEmitter.update(this.getEventArgs({
|
|
626
|
+
selected_key: selected_key
|
|
627
|
+
}));
|
|
628
|
+
}
|
|
628
629
|
}
|
|
629
630
|
}
|
|
630
631
|
}, {
|
|
@@ -632,8 +633,8 @@ var Tabs = function (_React$PureComponent) {
|
|
|
632
633
|
value: function getLastPosition() {
|
|
633
634
|
if (typeof window !== 'undefined') {
|
|
634
635
|
try {
|
|
635
|
-
var pos = parseFloat(window.localStorage.getItem(
|
|
636
|
-
window.localStorage.removeItem(
|
|
636
|
+
var pos = parseFloat(window.localStorage.getItem("tabs-pos-".concat(this._id))) || -1;
|
|
637
|
+
window.localStorage.removeItem("tabs-pos-".concat(this._id));
|
|
637
638
|
return pos;
|
|
638
639
|
} catch (e) {
|
|
639
640
|
warn(e);
|
|
@@ -643,12 +644,12 @@ var Tabs = function (_React$PureComponent) {
|
|
|
643
644
|
return -1;
|
|
644
645
|
}
|
|
645
646
|
}, {
|
|
646
|
-
key: "
|
|
647
|
-
value: function
|
|
647
|
+
key: "hasLastUsedTab",
|
|
648
|
+
value: function hasLastUsedTab() {
|
|
648
649
|
if (typeof window !== 'undefined') {
|
|
649
650
|
try {
|
|
650
|
-
var key = window.localStorage.getItem(
|
|
651
|
-
window.localStorage.removeItem(
|
|
651
|
+
var key = window.localStorage.getItem("tabs-last-".concat(this._id)) || null;
|
|
652
|
+
window.localStorage.removeItem("tabs-last-".concat(this._id));
|
|
652
653
|
return key;
|
|
653
654
|
} catch (e) {
|
|
654
655
|
warn(e);
|
|
@@ -662,7 +663,7 @@ var Tabs = function (_React$PureComponent) {
|
|
|
662
663
|
value: function saveLastUsedTab() {
|
|
663
664
|
if (typeof window !== 'undefined') {
|
|
664
665
|
try {
|
|
665
|
-
window.localStorage.setItem(
|
|
666
|
+
window.localStorage.setItem("tabs-last-".concat(this._id), this.state.selected_key);
|
|
666
667
|
} catch (e) {
|
|
667
668
|
warn(e);
|
|
668
669
|
}
|
|
@@ -675,7 +676,7 @@ var Tabs = function (_React$PureComponent) {
|
|
|
675
676
|
|
|
676
677
|
if (typeof window !== 'undefined') {
|
|
677
678
|
try {
|
|
678
|
-
window.localStorage.setItem(
|
|
679
|
+
window.localStorage.setItem("tabs-pos-".concat(this._id), pos);
|
|
679
680
|
} catch (e) {
|
|
680
681
|
warn(e);
|
|
681
682
|
}
|
|
@@ -686,53 +687,33 @@ var Tabs = function (_React$PureComponent) {
|
|
|
686
687
|
value: function hasScrollbar() {
|
|
687
688
|
return this._tablistRef.current.scrollWidth - 1 > this._tablistRef.current.offsetWidth;
|
|
688
689
|
}
|
|
689
|
-
}, {
|
|
690
|
-
key: "isAtEdge",
|
|
691
|
-
value: function isAtEdge() {
|
|
692
|
-
if (!this._hasScrollbar || typeof window === 'undefined') {
|
|
693
|
-
return false;
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
try {
|
|
697
|
-
var padding = parseFloat(window.getComputedStyle(this._tablistRef.current).paddingLeft);
|
|
698
|
-
var width = this._tablistRef.current.offsetWidth + 2 + 64 - padding;
|
|
699
|
-
var screenWidth = window.innerWidth;
|
|
700
|
-
return width >= screenWidth;
|
|
701
|
-
} catch (e) {}
|
|
702
|
-
|
|
703
|
-
return false;
|
|
704
|
-
}
|
|
705
690
|
}, {
|
|
706
691
|
key: "addScrollBehaviour",
|
|
707
692
|
value: function addScrollBehaviour() {
|
|
708
|
-
this.onResizeHandler();
|
|
709
|
-
|
|
710
693
|
if (typeof window !== 'undefined') {
|
|
711
694
|
window.addEventListener('resize', this.onResizeHandler);
|
|
712
695
|
}
|
|
713
696
|
}
|
|
714
|
-
}, {
|
|
715
|
-
key: "scrollToLastPosition",
|
|
716
|
-
value: function scrollToLastPosition() {
|
|
717
|
-
try {
|
|
718
|
-
this._tablistRef.current.style.scrollBehavior = 'auto';
|
|
719
|
-
this._tablistRef.current.scrollLeft = this.state.lastPosition;
|
|
720
|
-
this._tablistRef.current.style.scrollBehavior = 'smooth';
|
|
721
|
-
} catch (e) {}
|
|
722
|
-
}
|
|
723
697
|
}, {
|
|
724
698
|
key: "scrollToTab",
|
|
725
|
-
value: function scrollToTab(
|
|
699
|
+
value: function scrollToTab(_ref7) {
|
|
726
700
|
var _this2 = this;
|
|
727
701
|
|
|
702
|
+
var type = _ref7.type,
|
|
703
|
+
_ref7$behavior = _ref7.behavior,
|
|
704
|
+
behavior = _ref7$behavior === void 0 ? 'smooth' : _ref7$behavior;
|
|
705
|
+
|
|
728
706
|
if (typeof window === 'undefined') {
|
|
729
707
|
return;
|
|
730
708
|
}
|
|
731
709
|
|
|
732
|
-
|
|
733
|
-
|
|
710
|
+
if (window.IS_TEST) {
|
|
711
|
+
behavior = 'auto';
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
var delay = function delay() {
|
|
734
715
|
try {
|
|
735
|
-
if (
|
|
716
|
+
if (_this2.state.hasScrollbar && _this2._tablistRef.current) {
|
|
736
717
|
var first = _this2._tablistRef.current.querySelector('.dnb-tabs__button__snap:first-of-type');
|
|
737
718
|
|
|
738
719
|
var isFirst = first.classList.contains(type);
|
|
@@ -746,21 +727,23 @@ var Tabs = function (_React$PureComponent) {
|
|
|
746
727
|
var style = window.getComputedStyle(_this2._tabsRef.current);
|
|
747
728
|
var margin = parseFloat(style.marginLeft);
|
|
748
729
|
var padding = margin < 0 ? parseFloat(style.paddingLeft) : 0;
|
|
730
|
+
var leftPadding = (margin < 0 ? Math.abs(margin) : 0) + padding + parseFloat(window.getComputedStyle(first).paddingLeft);
|
|
731
|
+
var offsetLeft = elem.offsetLeft;
|
|
732
|
+
var left = elem && !isFirst ? offsetLeft - leftPadding : 0;
|
|
749
733
|
|
|
750
|
-
if (
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
padding = parseFloat(window.getComputedStyle(navButton).width);
|
|
734
|
+
if (behavior === 'auto') {
|
|
735
|
+
_this2._tablistRef.current.style.scrollBehavior = 'auto';
|
|
754
736
|
}
|
|
755
737
|
|
|
756
|
-
var leftPadding = (margin < 0 ? Math.abs(margin) : 0) + padding + parseFloat(window.getComputedStyle(first).paddingLeft);
|
|
757
|
-
var left = elem && !isFirst ? elem.offsetLeft - leftPadding : 0;
|
|
758
|
-
|
|
759
738
|
_this2._tablistRef.current.scrollTo({
|
|
760
739
|
left: left,
|
|
761
|
-
behavior:
|
|
740
|
+
behavior: behavior
|
|
762
741
|
});
|
|
763
742
|
|
|
743
|
+
if (behavior === 'auto') {
|
|
744
|
+
_this2._tablistRef.current.style.scrollBehavior = '';
|
|
745
|
+
}
|
|
746
|
+
|
|
764
747
|
_this2.setState({
|
|
765
748
|
isFirst: isFirst,
|
|
766
749
|
isLast: isLast
|
|
@@ -769,17 +752,23 @@ var Tabs = function (_React$PureComponent) {
|
|
|
769
752
|
} catch (e) {
|
|
770
753
|
warn(e);
|
|
771
754
|
}
|
|
772
|
-
}
|
|
755
|
+
};
|
|
756
|
+
|
|
757
|
+
if (window.IS_TEST) {
|
|
758
|
+
delay();
|
|
759
|
+
} else {
|
|
760
|
+
window.requestAnimationFrame(delay);
|
|
761
|
+
}
|
|
773
762
|
}
|
|
774
763
|
}, {
|
|
775
764
|
key: "getStepKey",
|
|
776
765
|
value: function getStepKey(useKey, stateKey) {
|
|
777
|
-
var currentData = this.state.data.filter(function (
|
|
778
|
-
var disabled =
|
|
766
|
+
var currentData = this.state.data.filter(function (_ref8) {
|
|
767
|
+
var disabled = _ref8.disabled;
|
|
779
768
|
return !disabled;
|
|
780
769
|
});
|
|
781
|
-
var currentIndex = currentData.reduce(function (acc,
|
|
782
|
-
var key =
|
|
770
|
+
var currentIndex = currentData.reduce(function (acc, _ref9, i) {
|
|
771
|
+
var key = _ref9.key;
|
|
783
772
|
return key == stateKey ? i : acc;
|
|
784
773
|
}, -1);
|
|
785
774
|
var nextIndex = currentIndex + useKey;
|
|
@@ -792,8 +781,8 @@ var Tabs = function (_React$PureComponent) {
|
|
|
792
781
|
nextIndex = 0;
|
|
793
782
|
}
|
|
794
783
|
|
|
795
|
-
return currentData.reduce(function (acc,
|
|
796
|
-
var key =
|
|
784
|
+
return currentData.reduce(function (acc, _ref10, i) {
|
|
785
|
+
var key = _ref10.key;
|
|
797
786
|
return i === nextIndex ? key : acc;
|
|
798
787
|
}, null);
|
|
799
788
|
}
|
|
@@ -807,12 +796,17 @@ var Tabs = function (_React$PureComponent) {
|
|
|
807
796
|
value: function resetWhatInput() {
|
|
808
797
|
whatInput.specificKeys([9]);
|
|
809
798
|
}
|
|
799
|
+
}, {
|
|
800
|
+
key: "warnAboutMissingContainer",
|
|
801
|
+
value: function warnAboutMissingContainer() {
|
|
802
|
+
warn("Could not find the required <Tabs.Content id=\"".concat(this._id, "-content\" ... /> that provides role=\"tabpanel\""));
|
|
803
|
+
}
|
|
810
804
|
}, {
|
|
811
805
|
key: "getEventArgs",
|
|
812
806
|
value: function getEventArgs(args) {
|
|
813
|
-
var _this$
|
|
814
|
-
selected_key = _this$
|
|
815
|
-
focus_key = _this$
|
|
807
|
+
var _this$state = this.state,
|
|
808
|
+
selected_key = _this$state.selected_key,
|
|
809
|
+
focus_key = _this$state.focus_key;
|
|
816
810
|
var key = typeof args.selected_key !== 'undefined' ? args.selected_key : selected_key;
|
|
817
811
|
return _objectSpread({
|
|
818
812
|
key: key,
|
|
@@ -836,18 +830,18 @@ var Tabs = function (_React$PureComponent) {
|
|
|
836
830
|
value: function renderCachedContent() {
|
|
837
831
|
var _this3 = this;
|
|
838
832
|
|
|
839
|
-
var _this$
|
|
840
|
-
selected_key = _this$
|
|
841
|
-
data = _this$
|
|
833
|
+
var _this$state2 = this.state,
|
|
834
|
+
selected_key = _this$state2.selected_key,
|
|
835
|
+
data = _this$state2.data;
|
|
842
836
|
var _this$props4 = this.props,
|
|
843
837
|
prevent_rerender = _this$props4.prevent_rerender,
|
|
844
838
|
prerender = _this$props4.prerender;
|
|
845
839
|
|
|
846
840
|
if (isTrue(prerender)) {
|
|
847
|
-
this._cache = Object.entries(data).reduce(function (acc,
|
|
848
|
-
var
|
|
849
|
-
idx =
|
|
850
|
-
cur =
|
|
841
|
+
this._cache = Object.entries(data).reduce(function (acc, _ref11) {
|
|
842
|
+
var _ref12 = _slicedToArray(_ref11, 2),
|
|
843
|
+
idx = _ref12[0],
|
|
844
|
+
cur = _ref12[1];
|
|
851
845
|
|
|
852
846
|
acc[cur.key] = _objectSpread(_objectSpread({}, cur), {}, {
|
|
853
847
|
content: _this3.getContent(cur.key)
|
|
@@ -860,10 +854,10 @@ var Tabs = function (_React$PureComponent) {
|
|
|
860
854
|
}));
|
|
861
855
|
}
|
|
862
856
|
|
|
863
|
-
var cachedContent = Object.entries(this._cache).map(function (
|
|
864
|
-
var
|
|
865
|
-
key =
|
|
866
|
-
content =
|
|
857
|
+
var cachedContent = Object.entries(this._cache).map(function (_ref13) {
|
|
858
|
+
var _ref14 = _slicedToArray(_ref13, 2),
|
|
859
|
+
key = _ref14[0],
|
|
860
|
+
content = _ref14[1].content;
|
|
867
861
|
|
|
868
862
|
var params = {};
|
|
869
863
|
|
|
@@ -932,14 +926,14 @@ var Tabs = function (_React$PureComponent) {
|
|
|
932
926
|
var useKey = selected_key;
|
|
933
927
|
|
|
934
928
|
if (!useKey) {
|
|
935
|
-
useKey = data.reduce(function (acc,
|
|
936
|
-
var selected =
|
|
937
|
-
key =
|
|
929
|
+
useKey = data.reduce(function (acc, _ref15) {
|
|
930
|
+
var selected = _ref15.selected,
|
|
931
|
+
key = _ref15.key;
|
|
938
932
|
return selected ? key : acc;
|
|
939
933
|
}, null) || data[0] && data[0].key;
|
|
940
934
|
} else {
|
|
941
|
-
var keyExists = data.findIndex(function (
|
|
942
|
-
var key =
|
|
935
|
+
var keyExists = data.findIndex(function (_ref16) {
|
|
936
|
+
var key = _ref16.key;
|
|
943
937
|
return key == selected_key;
|
|
944
938
|
});
|
|
945
939
|
|
|
@@ -1016,10 +1010,10 @@ var Tabs = function (_React$PureComponent) {
|
|
|
1016
1010
|
} else if (typeof data === 'string') {
|
|
1017
1011
|
res = data[0] === '[' ? JSON.parse(data) : [];
|
|
1018
1012
|
} else if (data && _typeof(data) === 'object') {
|
|
1019
|
-
res = Object.entries(data).reduce(function (acc,
|
|
1020
|
-
var
|
|
1021
|
-
key =
|
|
1022
|
-
obj =
|
|
1013
|
+
res = Object.entries(data).reduce(function (acc, _ref17) {
|
|
1014
|
+
var _ref18 = _slicedToArray(_ref17, 2),
|
|
1015
|
+
key = _ref18[0],
|
|
1016
|
+
obj = _ref18[1];
|
|
1023
1017
|
|
|
1024
1018
|
if (obj) {
|
|
1025
1019
|
acc.push(_objectSpread({
|
|
@@ -1055,6 +1049,7 @@ _defineProperty(Tabs, "defaultProps", {
|
|
|
1055
1049
|
tabs_style: null,
|
|
1056
1050
|
tabs_spacing: null,
|
|
1057
1051
|
no_border: false,
|
|
1052
|
+
nav_button_edge: false,
|
|
1058
1053
|
use_hash: false,
|
|
1059
1054
|
prerender: false,
|
|
1060
1055
|
prevent_rerender: false,
|
|
@@ -1097,6 +1092,7 @@ process.env.NODE_ENV !== "production" ? Tabs.propTypes = _objectSpread(_objectSp
|
|
|
1097
1092
|
tabs_style: PropTypes.string,
|
|
1098
1093
|
tabs_spacing: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
1099
1094
|
no_border: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
1095
|
+
nav_button_edge: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
1100
1096
|
use_hash: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
1101
1097
|
prerender: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
1102
1098
|
prevent_rerender: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
@@ -1113,8 +1109,8 @@ process.env.NODE_ENV !== "production" ? Tabs.propTypes = _objectSpread(_objectSp
|
|
|
1113
1109
|
on_click: PropTypes.func,
|
|
1114
1110
|
on_focus: PropTypes.func
|
|
1115
1111
|
}) : void 0;
|
|
1116
|
-
export var Dummy = function Dummy(
|
|
1117
|
-
var children =
|
|
1112
|
+
export var Dummy = function Dummy(_ref19) {
|
|
1113
|
+
var children = _ref19.children;
|
|
1118
1114
|
return React.createElement("span", {
|
|
1119
1115
|
"aria-hidden": true,
|
|
1120
1116
|
hidden: true,
|