@dhis2-ui/tab 9.11.0 → 9.11.1-beta.1
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/build/cjs/index.js +0 -2
- package/build/cjs/tab/features/accepts_children/index.js +0 -1
- package/build/cjs/tab/features/accepts_icon/index.js +0 -1
- package/build/cjs/tab/features/is_clickable/index.js +2 -3
- package/build/cjs/tab/index.js +0 -1
- package/build/cjs/tab/tab.e2e.stories.js +28 -0
- package/build/cjs/tab/tab.js +8 -25
- package/build/cjs/tab-bar/animated-side-scroll.js +0 -7
- package/build/cjs/tab-bar/detect-horizontal-scrollbar-height.js +12 -3
- package/build/cjs/tab-bar/features/accepts_children/index.js +0 -1
- package/build/cjs/tab-bar/features/auto_hides_scroll_buttons/index.js +0 -1
- package/build/cjs/tab-bar/index.js +0 -1
- package/build/cjs/tab-bar/scroll-bar.js +7 -44
- package/build/cjs/tab-bar/scroll-button.js +2 -10
- package/build/cjs/tab-bar/tab-bar.e2e.stories.js +31 -0
- package/build/cjs/tab-bar/tab-bar.js +4 -15
- package/build/cjs/tab-bar/{tab-bar.stories.js → tab-bar.prod.stories.js} +23 -29
- package/build/cjs/tab-bar/tabs.js +6 -25
- package/build/es/tab/features/is_clickable/index.js +2 -2
- package/build/es/tab/tab.e2e.stories.js +17 -0
- package/build/es/tab/tab.js +4 -9
- package/build/es/tab-bar/animated-side-scroll.js +0 -6
- package/build/es/tab-bar/detect-horizontal-scrollbar-height.js +12 -2
- package/build/es/tab-bar/scroll-bar.js +4 -31
- package/build/es/tab-bar/scroll-button.js +1 -1
- package/build/es/tab-bar/{tab-bar.stories.e2e.js → tab-bar.e2e.stories.js} +8 -5
- package/build/es/tab-bar/tab-bar.js +3 -9
- package/build/es/tab-bar/{tab-bar.stories.js → tab-bar.prod.stories.js} +21 -6
- package/build/es/tab-bar/tabs.js +3 -14
- package/package.json +7 -7
- package/build/cjs/tab/tab.stories.e2e.js +0 -19
- package/build/cjs/tab-bar/tab-bar.stories.e2e.js +0 -26
- package/build/es/tab/tab.stories.e2e.js +0 -12
package/build/cjs/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
|
|
4
|
-
|
|
5
4
|
(0, _cypressCucumberPreprocessor.Given)('a Tab with children is rendered', () => {
|
|
6
5
|
cy.visitStory('Tab', 'With children');
|
|
7
6
|
cy.get('[data-test="dhis2-uicore-tab"]').should('be.visible');
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
|
|
4
|
-
|
|
5
4
|
(0, _cypressCucumberPreprocessor.Given)('a Tab with an icon is rendered', () => {
|
|
6
5
|
cy.visitStory('Tab', 'With icon');
|
|
7
6
|
cy.get('[data-test="dhis2-uicore-tab"]').should('be.visible');
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
|
|
4
|
-
|
|
5
4
|
(0, _cypressCucumberPreprocessor.Given)('a Tab with onClick handler is rendered', () => {
|
|
6
|
-
cy.visitStory('Tab', 'With
|
|
5
|
+
cy.visitStory('Tab', 'With on click');
|
|
7
6
|
});
|
|
8
7
|
(0, _cypressCucumberPreprocessor.Given)('a disabled Tab with onClick handler is rendered', () => {
|
|
9
|
-
cy.visitStory('Tab', 'With
|
|
8
|
+
cy.visitStory('Tab', 'With on click and disabled');
|
|
10
9
|
});
|
|
11
10
|
(0, _cypressCucumberPreprocessor.When)('the Tab is clicked', () => {
|
|
12
11
|
cy.get('[data-test="dhis2-uicore-tab"]').click();
|
package/build/cjs/tab/index.js
CHANGED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.WithOnClickAndDisabled = exports.WithOnClick = exports.WithIcon = exports.WithChildren = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _tab = require("./tab.js");
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
window.onClick = window.Cypress && window.Cypress.cy.stub();
|
|
11
|
+
var _default = exports.default = {
|
|
12
|
+
title: 'Tab'
|
|
13
|
+
};
|
|
14
|
+
const WithOnClick = () => /*#__PURE__*/_react.default.createElement(_tab.Tab, {
|
|
15
|
+
onClick: window.onClick
|
|
16
|
+
}, "Tab A");
|
|
17
|
+
exports.WithOnClick = WithOnClick;
|
|
18
|
+
const WithChildren = () => /*#__PURE__*/_react.default.createElement(_tab.Tab, null, "I am a child");
|
|
19
|
+
exports.WithChildren = WithChildren;
|
|
20
|
+
const WithIcon = () => /*#__PURE__*/_react.default.createElement(_tab.Tab, {
|
|
21
|
+
icon: /*#__PURE__*/_react.default.createElement("div", null, "Icon")
|
|
22
|
+
}, "Children");
|
|
23
|
+
exports.WithIcon = WithIcon;
|
|
24
|
+
const WithOnClickAndDisabled = () => /*#__PURE__*/_react.default.createElement(_tab.Tab, {
|
|
25
|
+
onClick: window.onClick,
|
|
26
|
+
disabled: true
|
|
27
|
+
}, "Tab A");
|
|
28
|
+
exports.WithOnClickAndDisabled = WithOnClickAndDisabled;
|
package/build/cjs/tab/tab.js
CHANGED
|
@@ -4,26 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Tab = void 0;
|
|
7
|
-
|
|
8
7
|
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
9
|
-
|
|
10
|
-
var _tooltip = require("@dhis2-ui/tooltip");
|
|
11
|
-
|
|
12
8
|
var _uiConstants = require("@dhis2/ui-constants");
|
|
13
|
-
|
|
9
|
+
var _tooltip = require("@dhis2-ui/tooltip");
|
|
14
10
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
15
|
-
|
|
16
11
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
17
|
-
|
|
18
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
19
|
-
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
-
|
|
26
|
-
const Tab = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
13
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
14
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
15
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
+
const Tab = exports.Tab = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
27
17
|
let {
|
|
28
18
|
icon,
|
|
29
19
|
onClick,
|
|
@@ -34,18 +24,15 @@ const Tab = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
34
24
|
dataTest
|
|
35
25
|
} = _ref;
|
|
36
26
|
let tabRef = (0, _react.useRef)(null);
|
|
37
|
-
|
|
38
27
|
if (ref) {
|
|
39
28
|
tabRef = ref;
|
|
40
29
|
}
|
|
41
|
-
|
|
42
30
|
const [isOverflowing, setIsOverflowing] = (0, _react.useState)(false);
|
|
43
31
|
(0, _react.useEffect)(() => {
|
|
44
32
|
const checkOverflow = () => {
|
|
45
33
|
const isOverflow = tabRef.current.scrollWidth > tabRef.current.clientWidth;
|
|
46
34
|
setIsOverflowing(isOverflow);
|
|
47
35
|
};
|
|
48
|
-
|
|
49
36
|
checkOverflow();
|
|
50
37
|
}, []);
|
|
51
38
|
return /*#__PURE__*/_react.default.createElement("button", {
|
|
@@ -57,10 +44,10 @@ const Tab = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
57
44
|
"aria-disabled": disabled ? 'true' : 'false',
|
|
58
45
|
onFocus: disabled ? undefined : event => onClick({}, event),
|
|
59
46
|
tabIndex: -1,
|
|
60
|
-
className: _style.default.dynamic([["2433456263", [_uiConstants.colors.grey400, _uiConstants.colors.grey600, _uiConstants.theme.focus, _uiConstants.colors.grey600, _uiConstants.colors.grey900, _uiConstants.colors.grey600, _uiConstants.colors.grey800, _uiConstants.theme.primary800, _uiConstants.theme.primary700, _uiConstants.theme.primary700, _uiConstants.theme.primary700, _uiConstants.colors.grey500, _uiConstants.colors.grey500]]]) + " " +
|
|
47
|
+
className: _style.default.dynamic([["2433456263", [_uiConstants.colors.grey400, _uiConstants.colors.grey600, _uiConstants.theme.focus, _uiConstants.colors.grey600, _uiConstants.colors.grey900, _uiConstants.colors.grey600, _uiConstants.colors.grey800, _uiConstants.theme.primary800, _uiConstants.theme.primary700, _uiConstants.theme.primary700, _uiConstants.theme.primary700, _uiConstants.colors.grey500, _uiConstants.colors.grey500]]]) + " " + `${(0, _classnames.default)('tab', className, {
|
|
61
48
|
selected,
|
|
62
49
|
disabled
|
|
63
|
-
})
|
|
50
|
+
})}`
|
|
64
51
|
}, icon, isOverflowing ? /*#__PURE__*/_react.default.createElement(_tooltip.Tooltip, {
|
|
65
52
|
content: children,
|
|
66
53
|
maxWidth: '100%'
|
|
@@ -73,10 +60,8 @@ const Tab = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
|
73
60
|
}, children), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
74
61
|
id: "2433456263",
|
|
75
62
|
dynamic: [_uiConstants.colors.grey400, _uiConstants.colors.grey600, _uiConstants.theme.focus, _uiConstants.colors.grey600, _uiConstants.colors.grey900, _uiConstants.colors.grey600, _uiConstants.colors.grey800, _uiConstants.theme.primary800, _uiConstants.theme.primary700, _uiConstants.theme.primary700, _uiConstants.theme.primary700, _uiConstants.colors.grey500, _uiConstants.colors.grey500]
|
|
76
|
-
}, [
|
|
63
|
+
}, [`button.__jsx-style-dynamic-selector{-webkit-box-flex:0;-webkit-flex-grow:0;-ms-flex-positive:0;flex-grow:0;position:relative;display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;vertical-align:bottom;height:100%;padding:16px 16px 11px;background-color:transparent;outline:none;border:none;border-bottom:1px solid ${_uiConstants.colors.grey400};color:${_uiConstants.colors.grey600};font-size:14px;line-height:20px;cursor:pointer;}`, ".fixed>button.__jsx-style-dynamic-selector{-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;}", "button.__jsx-style-dynamic-selector::after{content:' ';display:block;position:absolute;bottom:-1px;inset-inline-start:0;height:4px;width:100%;background-color:transparent;}", "span.__jsx-style-dynamic-selector{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;max-width:320px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;-webkit-transition:fill 150ms ease-in-out;transition:fill 150ms ease-in-out;}", `button.__jsx-style-dynamic-selector:focus{outline:3px solid ${_uiConstants.theme.focus};outline-offset:-3px;}`, "button.__jsx-style-dynamic-selector:focus.__jsx-style-dynamic-selector:not(:focus-visible){outline:none;}", `button.__jsx-style-dynamic-selector>svg{fill:${_uiConstants.colors.grey600};width:14px;height:14px;margin:0 4px 0 0;}`, `button.__jsx-style-dynamic-selector:hover{color:${_uiConstants.colors.grey900};}`, `button.__jsx-style-dynamic-selector:hover.__jsx-style-dynamic-selector::after{background-color:${_uiConstants.colors.grey600};height:2px;}`, `button.__jsx-style-dynamic-selector:active.__jsx-style-dynamic-selector::after{background-color:${_uiConstants.colors.grey800};}`, `button.selected.__jsx-style-dynamic-selector{color:${_uiConstants.theme.primary800};}`, `button.selected.__jsx-style-dynamic-selector::after{background-color:${_uiConstants.theme.primary700};-webkit-transition:background-color 150ms ease-in-out;transition:background-color 150ms ease-in-out;}`, `button.selected.__jsx-style-dynamic-selector:hover.__jsx-style-dynamic-selector::after{background-color:${_uiConstants.theme.primary700};height:4px;}`, `button.selected.__jsx-style-dynamic-selector>svg{fill:${_uiConstants.theme.primary700};}`, `button.disabled.__jsx-style-dynamic-selector{color:${_uiConstants.colors.grey500};cursor:not-allowed;}`, "button.disabled.__jsx-style-dynamic-selector:hover,button.selected.__jsx-style-dynamic-selector:hover{background-color:transparent;}", `button.disabled.__jsx-style-dynamic-selector>svg{fill:${_uiConstants.colors.grey500};}`]));
|
|
77
64
|
});
|
|
78
|
-
|
|
79
|
-
exports.Tab = Tab;
|
|
80
65
|
Tab.defaultProps = {
|
|
81
66
|
dataTest: 'dhis2-uicore-tab'
|
|
82
67
|
};
|
|
@@ -86,10 +71,8 @@ Tab.propTypes = {
|
|
|
86
71
|
dataTest: _propTypes.default.string,
|
|
87
72
|
disabled: _propTypes.default.bool,
|
|
88
73
|
icon: _propTypes.default.element,
|
|
89
|
-
|
|
90
74
|
/** Indicates this tab is selected */
|
|
91
75
|
selected: _propTypes.default.bool,
|
|
92
|
-
|
|
93
76
|
/** Called with the signature `({}, event)` */
|
|
94
77
|
onClick: _propTypes.default.func
|
|
95
78
|
};
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.animatedSideScroll = animatedSideScroll;
|
|
7
7
|
const DURATION = 250;
|
|
8
8
|
const SCROLL_STEP = 0.5;
|
|
9
|
-
|
|
10
9
|
function animatedSideScroll(scrollBox, callback) {
|
|
11
10
|
let goBackwards = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
12
11
|
const startValue = scrollBox.scrollLeft;
|
|
@@ -21,13 +20,11 @@ function animatedSideScroll(scrollBox, callback) {
|
|
|
21
20
|
});
|
|
22
21
|
window.requestAnimationFrame(step);
|
|
23
22
|
}
|
|
24
|
-
|
|
25
23
|
function getEndValue(scrollBox, startValue, goBackwards) {
|
|
26
24
|
const scrollDistance = scrollBox.clientWidth * SCROLL_STEP;
|
|
27
25
|
const inverter = goBackwards ? -1 : 1;
|
|
28
26
|
return Math.floor(startValue + scrollDistance * inverter);
|
|
29
27
|
}
|
|
30
|
-
|
|
31
28
|
function createFrameStepper(_ref) {
|
|
32
29
|
let {
|
|
33
30
|
scrollBox,
|
|
@@ -41,7 +38,6 @@ function createFrameStepper(_ref) {
|
|
|
41
38
|
if (!startTimestamp) {
|
|
42
39
|
startTimestamp = timestamp;
|
|
43
40
|
}
|
|
44
|
-
|
|
45
41
|
elapsedTime = timestamp - startTimestamp;
|
|
46
42
|
scrollValue = easeInOutQuad({
|
|
47
43
|
currentTime: elapsedTime,
|
|
@@ -49,12 +45,10 @@ function createFrameStepper(_ref) {
|
|
|
49
45
|
startValue,
|
|
50
46
|
change
|
|
51
47
|
});
|
|
52
|
-
|
|
53
48
|
if (elapsedTime >= DURATION) {
|
|
54
49
|
if (scrollValue !== endValue) {
|
|
55
50
|
scrollBox.scrollLeft = endValue;
|
|
56
51
|
}
|
|
57
|
-
|
|
58
52
|
callback && callback();
|
|
59
53
|
} else {
|
|
60
54
|
scrollBox.scrollLeft = scrollValue;
|
|
@@ -62,7 +56,6 @@ function createFrameStepper(_ref) {
|
|
|
62
56
|
}
|
|
63
57
|
};
|
|
64
58
|
}
|
|
65
|
-
|
|
66
59
|
function easeInOutQuad(_ref2) {
|
|
67
60
|
let {
|
|
68
61
|
currentTime,
|
|
@@ -6,13 +6,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.detectHorizontalScrollbarHeight = detectHorizontalScrollbarHeight;
|
|
7
7
|
let horizontalScrollbarHeight;
|
|
8
8
|
const className = '__vertical-scrollbar-height-test__';
|
|
9
|
-
const styles =
|
|
10
|
-
|
|
9
|
+
const styles = `
|
|
10
|
+
.${className} {
|
|
11
|
+
position: absolute;
|
|
12
|
+
top: -9999px;
|
|
13
|
+
width: 100px;
|
|
14
|
+
height: 100px;
|
|
15
|
+
overflow-x: scroll;
|
|
16
|
+
}
|
|
17
|
+
.${className}::-webkit-scrollbar {
|
|
18
|
+
display: none;
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
11
21
|
function detectHorizontalScrollbarHeight() {
|
|
12
22
|
if (horizontalScrollbarHeight) {
|
|
13
23
|
return horizontalScrollbarHeight;
|
|
14
24
|
}
|
|
15
|
-
|
|
16
25
|
const style = document.createElement('style');
|
|
17
26
|
style.innerHTML = styles;
|
|
18
27
|
const el = document.createElement('div');
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
|
|
4
|
-
|
|
5
4
|
(0, _cypressCucumberPreprocessor.Given)('a TabBar with children is rendered', () => {
|
|
6
5
|
cy.visitStory('TabBar', 'With children');
|
|
7
6
|
cy.get('[data-test="dhis2-uicore-tabbar"]').should('be.visible');
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
|
|
4
|
-
|
|
5
4
|
(0, _cypressCucumberPreprocessor.Given)('a tabbar with enough space for all tabs is rendered', () => {
|
|
6
5
|
cy.viewport(1024, 768);
|
|
7
6
|
cy.visitStory('TabBar', 'Scrollable with some tabs');
|
|
@@ -4,43 +4,27 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.ScrollBar = void 0;
|
|
7
|
-
|
|
8
7
|
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
9
|
-
|
|
10
8
|
var _uiIcons = require("@dhis2/ui-icons");
|
|
11
|
-
|
|
12
9
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
-
|
|
14
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
-
|
|
16
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
17
|
-
|
|
18
12
|
var _animatedSideScroll = require("./animated-side-scroll.js");
|
|
19
|
-
|
|
20
13
|
var _detectHorizontalScrollbarHeight = require("./detect-horizontal-scrollbar-height.js");
|
|
21
|
-
|
|
22
14
|
var _scrollButton = require("./scroll-button.js");
|
|
23
|
-
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
function
|
|
29
|
-
|
|
30
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
31
|
-
|
|
15
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
16
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
17
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
19
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
20
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
32
21
|
class ScrollBar extends _react.Component {
|
|
33
22
|
constructor(props) {
|
|
34
23
|
super(props);
|
|
35
|
-
|
|
36
24
|
_defineProperty(this, "scrollBox", /*#__PURE__*/(0, _react.createRef)());
|
|
37
|
-
|
|
38
25
|
_defineProperty(this, "scrollArea", /*#__PURE__*/(0, _react.createRef)());
|
|
39
|
-
|
|
40
26
|
_defineProperty(this, "horizontalScrollBarHeight", (0, _detectHorizontalScrollbarHeight.detectHorizontalScrollbarHeight)());
|
|
41
|
-
|
|
42
27
|
_defineProperty(this, "scrollBoxResizeObserver", null);
|
|
43
|
-
|
|
44
28
|
_defineProperty(this, "calculateShouldHideButtons", () => {
|
|
45
29
|
this.setState({
|
|
46
30
|
hideScrollButtonsInitialized: false
|
|
@@ -57,31 +41,24 @@ class ScrollBar extends _react.Component {
|
|
|
57
41
|
this.setState({
|
|
58
42
|
hideScrollButtons
|
|
59
43
|
});
|
|
60
|
-
|
|
61
44
|
if (!hideScrollButtons) {
|
|
62
45
|
if (this.state.scrolledToStart) {
|
|
63
46
|
this.scrollLeft();
|
|
64
47
|
}
|
|
65
|
-
|
|
66
48
|
if (this.state.scrolledToEnd) {
|
|
67
49
|
this.scrollRight();
|
|
68
50
|
}
|
|
69
51
|
}
|
|
70
|
-
|
|
71
52
|
this.setState({
|
|
72
53
|
hideScrollButtonsInitialized: true
|
|
73
54
|
});
|
|
74
55
|
});
|
|
75
|
-
|
|
76
56
|
_defineProperty(this, "scrollRight", () => this.scroll());
|
|
77
|
-
|
|
78
57
|
_defineProperty(this, "scrollLeft", () => this.scroll(true));
|
|
79
|
-
|
|
80
58
|
_defineProperty(this, "animatedScrollCallback", () => {
|
|
81
59
|
this.updateScrolledToStates();
|
|
82
60
|
this.attachSideScrollListener();
|
|
83
61
|
});
|
|
84
|
-
|
|
85
62
|
_defineProperty(this, "updateScrolledToStates", () => {
|
|
86
63
|
const {
|
|
87
64
|
scrollLeft,
|
|
@@ -92,7 +69,6 @@ class ScrollBar extends _react.Component {
|
|
|
92
69
|
} = this.scrollArea.current;
|
|
93
70
|
const scrolledToStart = scrollLeft <= 0;
|
|
94
71
|
const scrolledToEnd = scrollLeft + offsetWidth >= areaOffsetWidth;
|
|
95
|
-
|
|
96
72
|
if (this.state.scrolledToStart !== scrolledToStart || this.state.scrolledToEnd !== scrolledToEnd) {
|
|
97
73
|
this.setState({
|
|
98
74
|
scrolledToStart,
|
|
@@ -100,7 +76,6 @@ class ScrollBar extends _react.Component {
|
|
|
100
76
|
});
|
|
101
77
|
}
|
|
102
78
|
});
|
|
103
|
-
|
|
104
79
|
this.state = {
|
|
105
80
|
scrolledToStart: true,
|
|
106
81
|
scrolledToEnd: false,
|
|
@@ -111,18 +86,15 @@ class ScrollBar extends _react.Component {
|
|
|
111
86
|
};
|
|
112
87
|
this.scrollBoxResizeObserver = new ResizeObserver(this.calculateShouldHideButtons);
|
|
113
88
|
}
|
|
114
|
-
|
|
115
89
|
componentDidMount() {
|
|
116
90
|
this.scrollSelectedTabIntoView();
|
|
117
91
|
this.attachSideScrollListener();
|
|
118
92
|
this.manageShouldHideButtons();
|
|
119
93
|
}
|
|
120
|
-
|
|
121
94
|
componentWillUnmount() {
|
|
122
95
|
this.removeSideScrollListener();
|
|
123
96
|
this.scrollBoxResizeObserver.disconnect();
|
|
124
97
|
}
|
|
125
|
-
|
|
126
98
|
manageShouldHideButtons() {
|
|
127
99
|
const {
|
|
128
100
|
current: scrollBox
|
|
@@ -130,33 +102,26 @@ class ScrollBar extends _react.Component {
|
|
|
130
102
|
this.scrollBoxResizeObserver.observe(scrollBox);
|
|
131
103
|
this.calculateShouldHideButtons();
|
|
132
104
|
}
|
|
133
|
-
|
|
134
105
|
scroll(goBackwards) {
|
|
135
106
|
this.removeSideScrollListener();
|
|
136
107
|
(0, _animatedSideScroll.animatedSideScroll)(this.scrollBox.current, this.animatedScrollCallback, goBackwards);
|
|
137
108
|
}
|
|
138
|
-
|
|
139
109
|
scrollSelectedTabIntoView() {
|
|
140
110
|
const scrollBoxEl = this.scrollBox.current;
|
|
141
111
|
const tab = scrollBoxEl.querySelector('.tab.selected');
|
|
142
|
-
|
|
143
112
|
if (tab) {
|
|
144
113
|
const tabEnd = tab.offsetLeft + tab.offsetWidth;
|
|
145
|
-
|
|
146
114
|
if (tabEnd > scrollBoxEl.offsetWidth) {
|
|
147
115
|
scrollBoxEl.scrollLeft = tabEnd - scrollBoxEl.offsetWidth;
|
|
148
116
|
}
|
|
149
117
|
}
|
|
150
118
|
}
|
|
151
|
-
|
|
152
119
|
attachSideScrollListener() {
|
|
153
120
|
this.scrollBox.current.addEventListener('scroll', this.updateScrolledToStates);
|
|
154
121
|
}
|
|
155
|
-
|
|
156
122
|
removeSideScrollListener() {
|
|
157
123
|
this.scrollBox.current.removeEventListener('scroll', this.updateScrolledToStates);
|
|
158
124
|
}
|
|
159
|
-
|
|
160
125
|
render() {
|
|
161
126
|
const {
|
|
162
127
|
scrolledToStart,
|
|
@@ -192,13 +157,11 @@ class ScrollBar extends _react.Component {
|
|
|
192
157
|
}, /*#__PURE__*/_react.default.createElement(_uiIcons.IconChevronRight16, null)), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
193
158
|
id: "4174900658",
|
|
194
159
|
dynamic: [-this.horizontalScrollBarHeight]
|
|
195
|
-
}, [
|
|
160
|
+
}, [`.scroll-box.__jsx-style-dynamic-selector{margin-bottom:${-this.horizontalScrollBarHeight}px;}`]), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
196
161
|
id: "191575146"
|
|
197
162
|
}, [".scroll-bar.jsx-191575146{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-wrap:nowrap;-ms-flex-wrap:nowrap;flex-wrap:nowrap;}", ".scroll-box-clipper.jsx-191575146{overflow-y:hidden;-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;}", ".scroll-box.jsx-191575146{-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;overflow-x:scroll;-webkit-overflow-scrolling:touch;display:-ms-flexbox;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}", ".scroll-box.jsx-191575146::-webkit-scrollbar{display:none;}", ".scroll-area.jsx-191575146{position:relative;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex:1 0 auto;-ms-flex:1 0 auto;flex:1 0 auto;overflow-x:hidden;}"]));
|
|
198
163
|
}
|
|
199
|
-
|
|
200
164
|
}
|
|
201
|
-
|
|
202
165
|
exports.ScrollBar = ScrollBar;
|
|
203
166
|
ScrollBar.propTypes = {
|
|
204
167
|
children: _propTypes.default.node.isRequired,
|
|
@@ -4,19 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.ScrollButton = void 0;
|
|
7
|
-
|
|
8
7
|
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
9
|
-
|
|
10
8
|
var _uiConstants = require("@dhis2/ui-constants");
|
|
11
|
-
|
|
12
9
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
-
|
|
14
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
-
|
|
16
11
|
var _react = _interopRequireDefault(require("react"));
|
|
17
|
-
|
|
18
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
20
13
|
const ScrollButton = _ref => {
|
|
21
14
|
let {
|
|
22
15
|
children,
|
|
@@ -33,9 +26,8 @@ const ScrollButton = _ref => {
|
|
|
33
26
|
}, children, /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
34
27
|
id: "2701682090",
|
|
35
28
|
dynamic: [_uiConstants.colors.white, _uiConstants.colors.grey400, _uiConstants.colors.grey600, _uiConstants.colors.grey100, _uiConstants.colors.grey200, _uiConstants.colors.grey500]
|
|
36
|
-
}, [
|
|
29
|
+
}, [`.scroll-button.__jsx-style-dynamic-selector{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;color:inherit;background-color:${_uiConstants.colors.white};border:none;border-bottom:1px solid ${_uiConstants.colors.grey400};outline:none;padding:16px 16px 11px 16px;cursor:pointer;}`, ".scroll-button.hidden.__jsx-style-dynamic-selector{display:none;}", `.scroll-button.__jsx-style-dynamic-selector svg{width:20px;height:20px;fill:${_uiConstants.colors.grey600};-webkit-transition:opacity 150ms ease-in-out;transition:opacity 150ms ease-in-out;opacity:1;}`, `.scroll-button.__jsx-style-dynamic-selector:hover{background-color:${_uiConstants.colors.grey100};}`, `.scroll-button.__jsx-style-dynamic-selector:active{background-color:${_uiConstants.colors.grey200};}`, ".scroll-button.disabled.__jsx-style-dynamic-selector{cursor:not-allowed;}", ".scroll-button.disabled.__jsx-style-dynamic-selector:hover{background-color:transparent;}", `.scroll-button.disabled.__jsx-style-dynamic-selector svg{fill:${_uiConstants.colors.grey500};}`]));
|
|
37
30
|
};
|
|
38
|
-
|
|
39
31
|
exports.ScrollButton = ScrollButton;
|
|
40
32
|
ScrollButton.displayName = 'ScrollButton';
|
|
41
33
|
ScrollButton.propTypes = {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.WithChildren = exports.ScrollableWithSomeTabs = exports.ScrollableWithChildren = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _index = require("../tab/index.js");
|
|
9
|
+
var _index2 = require("./index.js");
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
var _default = exports.default = {
|
|
12
|
+
title: 'TabBar'
|
|
13
|
+
};
|
|
14
|
+
const WithChildren = () => /*#__PURE__*/_react.default.createElement(_index2.TabBar, null, "I am a child");
|
|
15
|
+
exports.WithChildren = WithChildren;
|
|
16
|
+
const ScrollableWithChildren = () => /*#__PURE__*/_react.default.createElement(_index2.TabBar, {
|
|
17
|
+
scrollable: true
|
|
18
|
+
}, "I am a child");
|
|
19
|
+
exports.ScrollableWithChildren = ScrollableWithChildren;
|
|
20
|
+
const ScrollableWithSomeTabs = () => {
|
|
21
|
+
const TabStaticWidth = () => /*#__PURE__*/_react.default.createElement(_index.Tab, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
22
|
+
style: {
|
|
23
|
+
width: 100,
|
|
24
|
+
border: '1px solid black'
|
|
25
|
+
}
|
|
26
|
+
}, "Foo"));
|
|
27
|
+
return /*#__PURE__*/_react.default.createElement(_index2.TabBar, {
|
|
28
|
+
scrollable: true
|
|
29
|
+
}, /*#__PURE__*/_react.default.createElement(TabStaticWidth, null), /*#__PURE__*/_react.default.createElement(TabStaticWidth, null), /*#__PURE__*/_react.default.createElement(TabStaticWidth, null));
|
|
30
|
+
};
|
|
31
|
+
exports.ScrollableWithSomeTabs = ScrollableWithSomeTabs;
|
|
@@ -4,17 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.TabBar = void 0;
|
|
7
|
-
|
|
8
7
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
9
|
var _scrollBar = require("./scroll-bar.js");
|
|
13
|
-
|
|
14
10
|
var _tabs = require("./tabs.js");
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
12
|
const TabBar = _ref => {
|
|
19
13
|
let {
|
|
20
14
|
fixed,
|
|
@@ -23,28 +17,25 @@ const TabBar = _ref => {
|
|
|
23
17
|
scrollable,
|
|
24
18
|
dataTest
|
|
25
19
|
} = _ref;
|
|
26
|
-
|
|
27
20
|
if (scrollable) {
|
|
28
21
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
29
22
|
className: className,
|
|
30
23
|
"data-test": dataTest
|
|
31
24
|
}, /*#__PURE__*/_react.default.createElement(_scrollBar.ScrollBar, {
|
|
32
|
-
dataTest:
|
|
25
|
+
dataTest: `${dataTest}-scrollbar`
|
|
33
26
|
}, /*#__PURE__*/_react.default.createElement(_tabs.Tabs, {
|
|
34
27
|
fixed: fixed,
|
|
35
|
-
dataTest:
|
|
28
|
+
dataTest: `${dataTest}-tabs`
|
|
36
29
|
}, children)));
|
|
37
30
|
}
|
|
38
|
-
|
|
39
31
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
40
32
|
className: className,
|
|
41
33
|
"data-test": dataTest
|
|
42
34
|
}, /*#__PURE__*/_react.default.createElement(_tabs.Tabs, {
|
|
43
35
|
fixed: fixed,
|
|
44
|
-
dataTest:
|
|
36
|
+
dataTest: `${dataTest}-tabs`
|
|
45
37
|
}, children));
|
|
46
38
|
};
|
|
47
|
-
|
|
48
39
|
exports.TabBar = TabBar;
|
|
49
40
|
TabBar.defaultProps = {
|
|
50
41
|
dataTest: 'dhis2-uicore-tabbar'
|
|
@@ -53,10 +44,8 @@ TabBar.propTypes = {
|
|
|
53
44
|
children: _propTypes.default.node,
|
|
54
45
|
className: _propTypes.default.string,
|
|
55
46
|
dataTest: _propTypes.default.string,
|
|
56
|
-
|
|
57
47
|
/** Fixed tabs fill the width of their container. If false (i.e. fluid), tabs take up an amount of space defined by the tab name. Fluid tabs should be used most of the time. */
|
|
58
48
|
fixed: _propTypes.default.bool,
|
|
59
|
-
|
|
60
49
|
/** Enables horizontal scrolling for many tabs that don't fit the width of the container */
|
|
61
50
|
scrollable: _propTypes.default.bool
|
|
62
51
|
};
|