@dhis2-ui/tab 9.11.0 → 9.11.1-beta.10
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
|
@@ -3,7 +3,6 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { Tab } from '../tab/index.js';
|
|
5
5
|
import { TabBar } from './index.js';
|
|
6
|
-
|
|
7
6
|
function AttachFile(_ref) {
|
|
8
7
|
let {
|
|
9
8
|
className
|
|
@@ -19,28 +18,44 @@ function AttachFile(_ref) {
|
|
|
19
18
|
id: "4098137027"
|
|
20
19
|
}, ["svg.jsx-4098137027{fill:inherit;height:24px;width:24px;vertical-align:middle;pointer-events:none;}"]));
|
|
21
20
|
}
|
|
22
|
-
|
|
23
21
|
AttachFile.propTypes = {
|
|
24
22
|
className: PropTypes.string
|
|
25
23
|
};
|
|
26
24
|
const subtitle = 'Ssed to divide content into categories and/or sections';
|
|
27
|
-
const description =
|
|
25
|
+
const description = `
|
|
26
|
+
Use tabs to split related content into separate sections.
|
|
27
|
+
|
|
28
|
+
- Each tab should contain content that relates to one another, but the content should not overlap.
|
|
29
|
+
- Tabs are especially useful for splitting up content that may be relevant to different user groups, instead of displaying overwhelming amounts of information on a single page.
|
|
30
|
+
- Do not use tabs to compare content.
|
|
31
|
+
- Do not use tabs for sequential content that needs to be done in order.
|
|
32
|
+
- Do not use tabs for content that needs to be viewed at the same time.
|
|
33
|
+
- The number of tabs is less important than splitting content into understandable, predictable groups. Do not group together unrelated content in order to reduce tab count. Users struggle more with unpredictable tabs than too many tabs.
|
|
34
|
+
|
|
35
|
+
#### Naming
|
|
36
|
+
|
|
37
|
+
Give tabs short, understandable names. Try to find a word or very short phrase that summarizes the content. If you cannot find a suitable word this may mean you are trying to fit too much content under a single tab. The content of a tab should be obvious from its name.
|
|
28
38
|
|
|
39
|
+
For example: Do use "Legends" instead of "Set up legends", Do use "Data analysis" instead of "Options for analysis of data",
|
|
40
|
+
|
|
41
|
+
Do not repeat a term across tabs. If tabs are used inside a 'Options' modal, it is enough to use tab names "Data", "Legend", "Style". Do not repeat 'options' for all, e.g. "Data options", "Legend options" etc.
|
|
42
|
+
|
|
43
|
+
\`\`\`js
|
|
44
|
+
import { TabBar, Tab } from '@dhis2/ui'
|
|
45
|
+
\`\`\`
|
|
46
|
+
`;
|
|
29
47
|
const Wrapper = fn => /*#__PURE__*/React.createElement("div", {
|
|
30
48
|
style: {
|
|
31
49
|
maxWidth: 700
|
|
32
50
|
}
|
|
33
51
|
}, fn(), /*#__PURE__*/React.createElement("p", null, "Max-width of this container is 700 px"));
|
|
34
|
-
|
|
35
52
|
window.onClick = (payload, event) => {
|
|
36
53
|
console.log('onClick payload', payload);
|
|
37
54
|
console.log('onClick event', event);
|
|
38
55
|
};
|
|
39
|
-
|
|
40
56
|
const onClick = function () {
|
|
41
57
|
return window.onClick(...arguments);
|
|
42
58
|
};
|
|
43
|
-
|
|
44
59
|
export default {
|
|
45
60
|
title: 'Tab Bar',
|
|
46
61
|
component: TabBar,
|
package/build/es/tab-bar/tabs.js
CHANGED
|
@@ -3,7 +3,6 @@ import { colors } from '@dhis2/ui-constants';
|
|
|
3
3
|
import cx from 'classnames';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import React, { useRef, useMemo } from 'react';
|
|
6
|
-
|
|
7
6
|
const Tabs = _ref => {
|
|
8
7
|
let {
|
|
9
8
|
children,
|
|
@@ -12,37 +11,29 @@ const Tabs = _ref => {
|
|
|
12
11
|
} = _ref;
|
|
13
12
|
const tabContainer = useRef(null);
|
|
14
13
|
const childrenRefs = useMemo(() => React.Children.map(children, () => /*#__PURE__*/React.createRef()), [children]);
|
|
15
|
-
|
|
16
14
|
const handleKeyDown = event => {
|
|
17
15
|
const currentFocus = document.activeElement;
|
|
18
|
-
|
|
19
16
|
if (tabContainer.current && tabContainer.current === currentFocus) {
|
|
20
17
|
if (childrenRefs.length > 0 && childrenRefs[0].current) {
|
|
21
18
|
childrenRefs[0].current.focus();
|
|
22
19
|
}
|
|
23
|
-
|
|
24
20
|
return;
|
|
25
21
|
}
|
|
26
|
-
|
|
27
22
|
const currentIndex = childrenRefs.findIndex(ref => ref.current === currentFocus);
|
|
28
|
-
|
|
29
23
|
if (currentIndex === -1) {
|
|
30
24
|
return;
|
|
31
25
|
}
|
|
32
|
-
|
|
33
26
|
if (event.key === 'ArrowRight') {
|
|
34
27
|
event.preventDefault();
|
|
35
28
|
const nextIndex = (currentIndex + 1) % childrenRefs.length;
|
|
36
29
|
childrenRefs[nextIndex].current.focus();
|
|
37
30
|
}
|
|
38
|
-
|
|
39
31
|
if (event.key === 'ArrowLeft') {
|
|
40
32
|
event.preventDefault();
|
|
41
33
|
const prevIndex = (currentIndex - 1 + childrenRefs.length) % childrenRefs.length;
|
|
42
34
|
childrenRefs[prevIndex].current.focus();
|
|
43
35
|
}
|
|
44
36
|
};
|
|
45
|
-
|
|
46
37
|
return /*#__PURE__*/React.createElement("div", {
|
|
47
38
|
ref: tabContainer,
|
|
48
39
|
"data-test": dataTest,
|
|
@@ -57,9 +48,8 @@ const Tabs = _ref => {
|
|
|
57
48
|
return /*#__PURE__*/React.cloneElement(child, {
|
|
58
49
|
ref: childrenRefs[index]
|
|
59
50
|
});
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
51
|
+
}
|
|
52
|
+
// Wrap non-element children e.g string in a <span>
|
|
63
53
|
return /*#__PURE__*/React.createElement("span", {
|
|
64
54
|
ref: childrenRefs[index],
|
|
65
55
|
tabIndex: -1,
|
|
@@ -68,9 +58,8 @@ const Tabs = _ref => {
|
|
|
68
58
|
}), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
69
59
|
id: "771129571",
|
|
70
60
|
dynamic: [colors.grey400, colors.white]
|
|
71
|
-
}, [
|
|
61
|
+
}, [`div.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:flex-start;-webkit-box-align:flex-start;-ms-flex-align:flex-start;align-items:flex-start;position:relative;overflow:hidden;box-shadow:inset 0 -1px 0 0 ${colors.grey400};-webkit-flex-wrap:nowrap;-ms-flex-wrap:nowrap;flex-wrap:nowrap;-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;background:${colors.white};}`]));
|
|
72
62
|
};
|
|
73
|
-
|
|
74
63
|
Tabs.propTypes = {
|
|
75
64
|
dataTest: PropTypes.string.isRequired,
|
|
76
65
|
children: PropTypes.node,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dhis2-ui/tab",
|
|
3
|
-
"version": "9.11.
|
|
3
|
+
"version": "9.11.1-beta.10",
|
|
4
4
|
"description": "UI Tabs",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,20 +22,20 @@
|
|
|
22
22
|
"access": "public"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
|
-
"start": "
|
|
25
|
+
"start": "storybook dev -c ../../storybook/config --port 5000",
|
|
26
26
|
"build": "d2-app-scripts build",
|
|
27
27
|
"test": "d2-app-scripts test --jestConfig ../../jest.config.shared.js"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"react": "^16.
|
|
31
|
-
"react-dom": "^16.
|
|
30
|
+
"react": "^16.13",
|
|
31
|
+
"react-dom": "^16.13",
|
|
32
32
|
"styled-jsx": "^4"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@dhis2-ui/tooltip": "9.11.
|
|
35
|
+
"@dhis2-ui/tooltip": "9.11.1-beta.10",
|
|
36
36
|
"@dhis2/prop-types": "^3.1.2",
|
|
37
|
-
"@dhis2/ui-constants": "9.11.
|
|
38
|
-
"@dhis2/ui-icons": "9.11.
|
|
37
|
+
"@dhis2/ui-constants": "9.11.1-beta.10",
|
|
38
|
+
"@dhis2/ui-icons": "9.11.1-beta.10",
|
|
39
39
|
"classnames": "^2.3.1",
|
|
40
40
|
"prop-types": "^15.7.2"
|
|
41
41
|
},
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _react = require("@storybook/react");
|
|
4
|
-
|
|
5
|
-
var _react2 = _interopRequireDefault(require("react"));
|
|
6
|
-
|
|
7
|
-
var _tab = require("./tab.js");
|
|
8
|
-
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
11
|
-
window.onClick = window.Cypress && window.Cypress.cy.stub();
|
|
12
|
-
(0, _react.storiesOf)('Tab', module).add('With onClick', () => /*#__PURE__*/_react2.default.createElement(_tab.Tab, {
|
|
13
|
-
onClick: window.onClick
|
|
14
|
-
}, "Tab A")).add('With children', () => /*#__PURE__*/_react2.default.createElement(_tab.Tab, null, "I am a child")).add('With icon', () => /*#__PURE__*/_react2.default.createElement(_tab.Tab, {
|
|
15
|
-
icon: /*#__PURE__*/_react2.default.createElement("div", null, "Icon")
|
|
16
|
-
}, "Children")).add('With onClick and disabled', () => /*#__PURE__*/_react2.default.createElement(_tab.Tab, {
|
|
17
|
-
onClick: window.onClick,
|
|
18
|
-
disabled: true
|
|
19
|
-
}, "Tab A"));
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _react = require("@storybook/react");
|
|
4
|
-
|
|
5
|
-
var _react2 = _interopRequireDefault(require("react"));
|
|
6
|
-
|
|
7
|
-
var _index = require("../tab/index.js");
|
|
8
|
-
|
|
9
|
-
var _index2 = require("./index.js");
|
|
10
|
-
|
|
11
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
|
|
13
|
-
(0, _react.storiesOf)('TabBar', module).add('With children', () => /*#__PURE__*/_react2.default.createElement(_index2.TabBar, null, "I am a child")).add('Scrollable with children', () => /*#__PURE__*/_react2.default.createElement(_index2.TabBar, {
|
|
14
|
-
scrollable: true
|
|
15
|
-
}, "I am a child")).add('Scrollable with some tabs', () => {
|
|
16
|
-
const TabStaticWidth = () => /*#__PURE__*/_react2.default.createElement(_index.Tab, null, /*#__PURE__*/_react2.default.createElement("div", {
|
|
17
|
-
style: {
|
|
18
|
-
width: 100,
|
|
19
|
-
border: '1px solid black'
|
|
20
|
-
}
|
|
21
|
-
}, "Foo"));
|
|
22
|
-
|
|
23
|
-
return /*#__PURE__*/_react2.default.createElement(_index2.TabBar, {
|
|
24
|
-
scrollable: true
|
|
25
|
-
}, /*#__PURE__*/_react2.default.createElement(TabStaticWidth, null), /*#__PURE__*/_react2.default.createElement(TabStaticWidth, null), /*#__PURE__*/_react2.default.createElement(TabStaticWidth, null));
|
|
26
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { storiesOf } from '@storybook/react';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { Tab } from './tab.js';
|
|
4
|
-
window.onClick = window.Cypress && window.Cypress.cy.stub();
|
|
5
|
-
storiesOf('Tab', module).add('With onClick', () => /*#__PURE__*/React.createElement(Tab, {
|
|
6
|
-
onClick: window.onClick
|
|
7
|
-
}, "Tab A")).add('With children', () => /*#__PURE__*/React.createElement(Tab, null, "I am a child")).add('With icon', () => /*#__PURE__*/React.createElement(Tab, {
|
|
8
|
-
icon: /*#__PURE__*/React.createElement("div", null, "Icon")
|
|
9
|
-
}, "Children")).add('With onClick and disabled', () => /*#__PURE__*/React.createElement(Tab, {
|
|
10
|
-
onClick: window.onClick,
|
|
11
|
-
disabled: true
|
|
12
|
-
}, "Tab A"));
|