@dnanpm/styleguide 3.5.0 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/build/assets/fonts/fonts.css +129 -129
- package/build/cjs/components/Button/ButtonIcon.js +4 -0
- package/build/cjs/components/PriorityNavigation/PriorityNavigation.d.ts +9 -1
- package/build/cjs/components/PriorityNavigation/PriorityNavigation.js +23 -8
- package/build/cjs/components/PriorityNavigation/__tests__/PriorityNavigation.spec.d.ts +1 -1
- package/build/cjs/components/PriorityNavigationItem/PriorityNavigationItem.d.ts +11 -3
- package/build/cjs/components/PriorityNavigationItem/PriorityNavigationItem.js +19 -11
- package/build/cjs/components/PriorityNavigationItem/__tests__/PriorityNavigationItem.spec.d.ts +1 -1
- package/build/cjs/components/Tab/Tab.d.ts +21 -10
- package/build/cjs/components/Tab/Tab.js +37 -25
- package/build/cjs/components/Tab/__tests__/Tab.spec.d.ts +1 -0
- package/build/cjs/components/Tabs/Tabs.d.ts +24 -1
- package/build/cjs/components/Tabs/Tabs.js +66 -15
- package/build/cjs/components/Tabs/__tests__/Tabs.spec.d.ts +1 -0
- package/build/es/build/assets/fonts/fonts.css +129 -129
- package/build/es/components/Button/ButtonIcon.js +4 -0
- package/build/es/components/PriorityNavigation/PriorityNavigation.d.ts +9 -1
- package/build/es/components/PriorityNavigation/PriorityNavigation.js +25 -10
- package/build/es/components/PriorityNavigation/__tests__/PriorityNavigation.spec.d.ts +1 -1
- package/build/es/components/PriorityNavigationItem/PriorityNavigationItem.d.ts +11 -3
- package/build/es/components/PriorityNavigationItem/PriorityNavigationItem.js +19 -11
- package/build/es/components/PriorityNavigationItem/__tests__/PriorityNavigationItem.spec.d.ts +1 -1
- package/build/es/components/Tab/Tab.d.ts +21 -10
- package/build/es/components/Tab/Tab.js +37 -25
- package/build/es/components/Tab/__tests__/Tab.spec.d.ts +1 -0
- package/build/es/components/Tabs/Tabs.d.ts +24 -1
- package/build/es/components/Tabs/Tabs.js +66 -15
- package/build/es/components/Tabs/__tests__/Tabs.spec.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,129 +1,129 @@
|
|
|
1
|
-
/* "DNA Text" font definition */
|
|
2
|
-
@font-face {
|
|
3
|
-
font-family: 'DNA Text';
|
|
4
|
-
font-style: normal;
|
|
5
|
-
font-weight: 400;
|
|
6
|
-
font-display: swap;
|
|
7
|
-
src: url('https://
|
|
8
|
-
url('https://
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
@font-face {
|
|
12
|
-
font-family: 'DNA Text';
|
|
13
|
-
font-style: normal;
|
|
14
|
-
font-weight: 500;
|
|
15
|
-
font-display: swap;
|
|
16
|
-
src: url('https://
|
|
17
|
-
url('https://
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
@font-face {
|
|
21
|
-
font-family: 'DNA Text';
|
|
22
|
-
font-style: normal;
|
|
23
|
-
font-weight: 700;
|
|
24
|
-
font-display: swap;
|
|
25
|
-
src: url('https://
|
|
26
|
-
url('https://
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/* "DNA Heading" font definition */
|
|
30
|
-
@font-face {
|
|
31
|
-
font-family: 'DNA Heading';
|
|
32
|
-
font-style: normal;
|
|
33
|
-
font-weight: 600;
|
|
34
|
-
font-display: swap;
|
|
35
|
-
src: url('https://
|
|
36
|
-
url('https://
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
@font-face {
|
|
40
|
-
font-family: 'DNA Heading';
|
|
41
|
-
font-style: normal;
|
|
42
|
-
font-weight: 700;
|
|
43
|
-
font-display: swap;
|
|
44
|
-
src: url('https://
|
|
45
|
-
url('https://
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
@font-face {
|
|
49
|
-
font-family: 'DNA Heading';
|
|
50
|
-
font-style: normal;
|
|
51
|
-
font-weight: 900;
|
|
52
|
-
font-display: swap;
|
|
53
|
-
src: url('https://
|
|
54
|
-
url('https://
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/* "DNA Numerals" font definition */
|
|
58
|
-
@font-face {
|
|
59
|
-
font-family: 'DNA Numerals';
|
|
60
|
-
font-style: normal;
|
|
61
|
-
font-weight: 700;
|
|
62
|
-
font-display: swap;
|
|
63
|
-
src: url('https://
|
|
64
|
-
url('https://
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/* Direct definitons of DNA fonts */
|
|
68
|
-
@font-face {
|
|
69
|
-
font-family: 'DNA Text Regular';
|
|
70
|
-
font-style: normal;
|
|
71
|
-
font-weight: 400;
|
|
72
|
-
font-display: swap;
|
|
73
|
-
src: url('https://
|
|
74
|
-
url('https://
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
@font-face {
|
|
78
|
-
font-family: 'DNA Text Medium';
|
|
79
|
-
font-style: normal;
|
|
80
|
-
font-weight: 500;
|
|
81
|
-
font-display: swap;
|
|
82
|
-
src: url('https://
|
|
83
|
-
url('https://
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
@font-face {
|
|
87
|
-
font-family: 'DNA Text Bold';
|
|
88
|
-
font-style: normal;
|
|
89
|
-
font-weight: 700;
|
|
90
|
-
font-display: swap;
|
|
91
|
-
src: url('https://
|
|
92
|
-
url('https://
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
@font-face {
|
|
96
|
-
font-family: 'DNA Heading Demi Bold';
|
|
97
|
-
font-style: normal;
|
|
98
|
-
font-weight: 600;
|
|
99
|
-
font-display: swap;
|
|
100
|
-
src: url('https://
|
|
101
|
-
url('https://
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
@font-face {
|
|
105
|
-
font-family: 'DNA Heading Bold';
|
|
106
|
-
font-style: normal;
|
|
107
|
-
font-weight: 700;
|
|
108
|
-
font-display: swap;
|
|
109
|
-
src: url('https://
|
|
110
|
-
url('https://
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
@font-face {
|
|
114
|
-
font-family: 'DNA Heading Black';
|
|
115
|
-
font-style: normal;
|
|
116
|
-
font-weight: 900;
|
|
117
|
-
font-display: swap;
|
|
118
|
-
src: url('https://
|
|
119
|
-
url('https://
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
@font-face {
|
|
123
|
-
font-family: 'DNA Numerals Bold';
|
|
124
|
-
font-style: normal;
|
|
125
|
-
font-weight: 700;
|
|
126
|
-
font-display: swap;
|
|
127
|
-
src: url('https://
|
|
128
|
-
url('https://
|
|
129
|
-
}
|
|
1
|
+
/* "DNA Text" font definition */
|
|
2
|
+
@font-face {
|
|
3
|
+
font-family: 'DNA Text';
|
|
4
|
+
font-style: normal;
|
|
5
|
+
font-weight: 400;
|
|
6
|
+
font-display: swap;
|
|
7
|
+
src: url('https://www.dna.fi/fonts/DNAText-Regular.woff2') format('woff2'),
|
|
8
|
+
url('https://www.dna.fi/fonts/DNAText-Regular.woff') format('woff');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
@font-face {
|
|
12
|
+
font-family: 'DNA Text';
|
|
13
|
+
font-style: normal;
|
|
14
|
+
font-weight: 500;
|
|
15
|
+
font-display: swap;
|
|
16
|
+
src: url('https://www.dna.fi/fonts/DNAText-Medium.woff2') format('woff2'),
|
|
17
|
+
url('https://www.dna.fi/fonts/DNAText-Medium.woff') format('woff');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@font-face {
|
|
21
|
+
font-family: 'DNA Text';
|
|
22
|
+
font-style: normal;
|
|
23
|
+
font-weight: 700;
|
|
24
|
+
font-display: swap;
|
|
25
|
+
src: url('https://www.dna.fi/fonts/DNAText-Bold.woff2') format('woff2'),
|
|
26
|
+
url('https://www.dna.fi/fonts/DNAText-Bold.woff') format('woff');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* "DNA Heading" font definition */
|
|
30
|
+
@font-face {
|
|
31
|
+
font-family: 'DNA Heading';
|
|
32
|
+
font-style: normal;
|
|
33
|
+
font-weight: 600;
|
|
34
|
+
font-display: swap;
|
|
35
|
+
src: url('https://www.dna.fi/fonts/DNAHeading-DemiBold.woff2') format('woff2'),
|
|
36
|
+
url('https://www.dna.fi/fonts/DNAHeading-DemiBold.woff') format('woff');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@font-face {
|
|
40
|
+
font-family: 'DNA Heading';
|
|
41
|
+
font-style: normal;
|
|
42
|
+
font-weight: 700;
|
|
43
|
+
font-display: swap;
|
|
44
|
+
src: url('https://www.dna.fi/fonts/DNAHeading-Bold.woff2') format('woff2'),
|
|
45
|
+
url('https://www.dna.fi/fonts/DNAHeading-Bold.woff') format('woff');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@font-face {
|
|
49
|
+
font-family: 'DNA Heading';
|
|
50
|
+
font-style: normal;
|
|
51
|
+
font-weight: 900;
|
|
52
|
+
font-display: swap;
|
|
53
|
+
src: url('https://www.dna.fi/fonts/DNAHeading-Black.woff2') format('woff2'),
|
|
54
|
+
url('https://www.dna.fi/fonts/DNAHeading-Black.woff') format('woff');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/* "DNA Numerals" font definition */
|
|
58
|
+
@font-face {
|
|
59
|
+
font-family: 'DNA Numerals';
|
|
60
|
+
font-style: normal;
|
|
61
|
+
font-weight: 700;
|
|
62
|
+
font-display: swap;
|
|
63
|
+
src: url('https://www.dna.fi/fonts/DNANumerals-Bold.woff2') format('woff2'),
|
|
64
|
+
url('https://www.dna.fi/fonts/DNANumerals-Bold.woff') format('woff');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/* Direct definitons of DNA fonts */
|
|
68
|
+
@font-face {
|
|
69
|
+
font-family: 'DNA Text Regular';
|
|
70
|
+
font-style: normal;
|
|
71
|
+
font-weight: 400;
|
|
72
|
+
font-display: swap;
|
|
73
|
+
src: url('https://www.dna.fi/fonts/DNAText-Regular.woff2') format('woff2'),
|
|
74
|
+
url('https://www.dna.fi/fonts/DNAText-Regular.woff') format('woff');
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@font-face {
|
|
78
|
+
font-family: 'DNA Text Medium';
|
|
79
|
+
font-style: normal;
|
|
80
|
+
font-weight: 500;
|
|
81
|
+
font-display: swap;
|
|
82
|
+
src: url('https://www.dna.fi/fonts/DNAText-Medium.woff2') format('woff2'),
|
|
83
|
+
url('https://www.dna.fi/fonts/DNAText-Medium.woff') format('woff');
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@font-face {
|
|
87
|
+
font-family: 'DNA Text Bold';
|
|
88
|
+
font-style: normal;
|
|
89
|
+
font-weight: 700;
|
|
90
|
+
font-display: swap;
|
|
91
|
+
src: url('https://www.dna.fi/fonts/DNAText-Bold.woff2') format('woff2'),
|
|
92
|
+
url('https://www.dna.fi/fonts/DNAText-Bold.woff') format('woff');
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
@font-face {
|
|
96
|
+
font-family: 'DNA Heading Demi Bold';
|
|
97
|
+
font-style: normal;
|
|
98
|
+
font-weight: 600;
|
|
99
|
+
font-display: swap;
|
|
100
|
+
src: url('https://www.dna.fi/fonts/DNAHeading-DemiBold.woff2') format('woff2'),
|
|
101
|
+
url('https://www.dna.fi/fonts/DNAHeading-DemiBold.woff') format('woff');
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
@font-face {
|
|
105
|
+
font-family: 'DNA Heading Bold';
|
|
106
|
+
font-style: normal;
|
|
107
|
+
font-weight: 700;
|
|
108
|
+
font-display: swap;
|
|
109
|
+
src: url('https://www.dna.fi/fonts/DNAHeading-Bold.woff2') format('woff2'),
|
|
110
|
+
url('https://www.dna.fi/fonts/DNAHeading-Bold.woff') format('woff');
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
@font-face {
|
|
114
|
+
font-family: 'DNA Heading Black';
|
|
115
|
+
font-style: normal;
|
|
116
|
+
font-weight: 900;
|
|
117
|
+
font-display: swap;
|
|
118
|
+
src: url('https://www.dna.fi/fonts/DNAHeading-Black.woff2') format('woff2'),
|
|
119
|
+
url('https://www.dna.fi/fonts/DNAHeading-Black.woff') format('woff');
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
@font-face {
|
|
123
|
+
font-family: 'DNA Numerals Bold';
|
|
124
|
+
font-style: normal;
|
|
125
|
+
font-weight: 700;
|
|
126
|
+
font-display: swap;
|
|
127
|
+
src: url('https://www.dna.fi/fonts/DNANumerals-Bold.woff2') format('woff2'),
|
|
128
|
+
url('https://www.dna.fi/fonts/DNANumerals-Bold.woff') format('woff');
|
|
129
|
+
}
|
|
@@ -29,6 +29,10 @@ const ButtonElement = styled__default["default"].button `
|
|
|
29
29
|
border: 2px solid transparent;
|
|
30
30
|
padding: ${styledUtils.getDividedSize(theme["default"].base.baseWidth, 5)} 0;
|
|
31
31
|
|
|
32
|
+
& svg {
|
|
33
|
+
pointer-events: none;
|
|
34
|
+
}
|
|
35
|
+
|
|
32
36
|
${({ isReversed }) => isReversed && `flex-direction: row-reverse;`}
|
|
33
37
|
|
|
34
38
|
&:focus {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
1
|
+
import type { KeyboardEvent, MouseEvent, ReactNode } from 'react';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
interface Props {
|
|
4
4
|
/**
|
|
@@ -9,6 +9,14 @@ interface Props {
|
|
|
9
9
|
* Content of the component
|
|
10
10
|
*/
|
|
11
11
|
children?: ReactNode;
|
|
12
|
+
/**
|
|
13
|
+
* Allows to pass common mouse click callback to all children
|
|
14
|
+
*/
|
|
15
|
+
onClick?: (e: MouseEvent<HTMLElement>) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Allows to pass common keyboard key down callback to all children
|
|
18
|
+
*/
|
|
19
|
+
onKeyDown?: (e: KeyboardEvent<HTMLElement>) => void;
|
|
12
20
|
/**
|
|
13
21
|
* Allows to define aria-label attribute for nav HTML element
|
|
14
22
|
*/
|
|
@@ -103,11 +103,15 @@ const DropdownList = styled["default"](CoreULStyles) `
|
|
|
103
103
|
${common["default"]({ elevation: 'low' })}
|
|
104
104
|
`;
|
|
105
105
|
const reducer = (state, action) => {
|
|
106
|
-
var _a;
|
|
106
|
+
var _a, _b;
|
|
107
107
|
switch (action.type) {
|
|
108
|
+
case 'resetNavigationState': {
|
|
109
|
+
const navigationItems = React.Children.toArray((_a = action === null || action === void 0 ? void 0 : action.payload) === null || _a === void 0 ? void 0 : _a.navigationItems);
|
|
110
|
+
return Object.assign(Object.assign({}, state), { navigationItems: navigationItems.slice(0, navigationItems.length - state.lastItemWidth.length), dropdownItems: navigationItems.slice(navigationItems.length - state.lastItemWidth.length) });
|
|
111
|
+
}
|
|
108
112
|
case 'moveItemToDropdown': {
|
|
109
113
|
const lastChild = state.navigationItems[state.navigationItems.length - 1];
|
|
110
|
-
return Object.assign(Object.assign(Object.assign({}, state), { navigationItems: state.navigationItems.slice(0, -1), dropdownItems: [lastChild, ...state.dropdownItems] }), (((
|
|
114
|
+
return Object.assign(Object.assign(Object.assign({}, state), { navigationItems: state.navigationItems.slice(0, -1), dropdownItems: [lastChild, ...state.dropdownItems] }), (((_b = action === null || action === void 0 ? void 0 : action.payload) === null || _b === void 0 ? void 0 : _b.lastItem) && {
|
|
111
115
|
lastItemWidth: [...state.lastItemWidth, action.payload.lastItem.clientWidth],
|
|
112
116
|
}));
|
|
113
117
|
}
|
|
@@ -164,7 +168,7 @@ const PriorityNavigation = (_a) => {
|
|
|
164
168
|
const toggleDropdown = () => setIsDropdownOpen(!isDropdownOpen);
|
|
165
169
|
const navigationItems = React.useRef(new Map()).current;
|
|
166
170
|
const initialState = {
|
|
167
|
-
navigationItems: props.children,
|
|
171
|
+
navigationItems: React.Children.toArray(props.children),
|
|
168
172
|
dropdownItems: [],
|
|
169
173
|
lastItemWidth: [],
|
|
170
174
|
};
|
|
@@ -197,6 +201,9 @@ const PriorityNavigation = (_a) => {
|
|
|
197
201
|
child.type === PriorityNavigationItem["default"] &&
|
|
198
202
|
child.props.isActive));
|
|
199
203
|
useOutsideClick["default"](listsContainerRef, () => {
|
|
204
|
+
if (isMobileNavigationOpen) {
|
|
205
|
+
setIsMobileNavigationOpen(false);
|
|
206
|
+
}
|
|
200
207
|
if (isDropdownOpen) {
|
|
201
208
|
setIsDropdownOpen(false);
|
|
202
209
|
}
|
|
@@ -212,16 +219,24 @@ const PriorityNavigation = (_a) => {
|
|
|
212
219
|
checkHorizontalOverflow,
|
|
213
220
|
isMobile,
|
|
214
221
|
]);
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
222
|
+
React.useEffect(() => {
|
|
223
|
+
dispatch({
|
|
224
|
+
type: 'resetNavigationState',
|
|
225
|
+
payload: {
|
|
226
|
+
navigationItems: props.children,
|
|
227
|
+
},
|
|
228
|
+
});
|
|
229
|
+
setIsMobileNavigationOpen(false);
|
|
230
|
+
}, [props.children]);
|
|
219
231
|
return (React__default["default"].createElement(Container, { id: props.id, "aria-label": props.navigationLabel, className: props.className, "data-testid": dataTestId },
|
|
220
232
|
React__default["default"].createElement(ListsContainer, { ref: listsContainerRef },
|
|
221
233
|
isMobile && selectedItem && (React__default["default"].createElement(MobileDropdown, { onClick: toggleMobileNavigation },
|
|
222
234
|
selectedItem,
|
|
223
235
|
React__default["default"].createElement(Icon["default"], { icon: isMobileNavigationOpen ? icons.ChevronUp : icons.ChevronDown }))),
|
|
224
|
-
React__default["default"].createElement(NavigationList, { ref: navigationListRef, isMobileNavigationOpen: isMobileNavigationOpen },
|
|
236
|
+
React__default["default"].createElement(NavigationList, { ref: navigationListRef, isMobileNavigationOpen: isMobileNavigationOpen }, React.Children.map([...state.navigationItems, ...(isMobile ? state.dropdownItems : [])], (navigationItem, index) => React.isValidElement(navigationItem) &&
|
|
237
|
+
navigationItem.type === PriorityNavigationItem["default"] && (React__default["default"].createElement(PriorityNavigationItem["default"], { id: navigationItem.props.id, key: navigationItem.key, onClick: navigationItem.props.onClick || props.onClick, onKeyDown: navigationItem.props.onKeyDown || props.onKeyDown, isActive: navigationItem.props.isActive, className: navigationItem.props.className, "data-testid": navigationItem.props['data-testid'], innerRef: instance => instance && navigationItems.set(index, instance) },
|
|
238
|
+
navigationItem.props.children,
|
|
239
|
+
navigationItem.props.isActive && isMobile && (React__default["default"].createElement(Icon["default"], { icon: icons.Check, color: theme["default"].color.default.pink })))))),
|
|
225
240
|
!isMobile && Boolean(state.dropdownItems.length) && (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
226
241
|
React__default["default"].createElement(ButtonIcon["default"], { onClick: toggleDropdown, icon: isDropdownOpen ? icons.ChevronUp : icons.ChevronDown, isReversed: true }, dropdownButtonLabel),
|
|
227
242
|
React__default["default"].createElement(DropdownList, { isDropdownOpen: isDropdownOpen }, state.dropdownItems))))));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ReactNode, RefObject } from 'react';
|
|
1
|
+
import type { KeyboardEvent, MouseEvent, ReactNode, RefObject } from 'react';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
export interface Props {
|
|
4
4
|
/**
|
|
@@ -10,13 +10,21 @@ export interface Props {
|
|
|
10
10
|
*/
|
|
11
11
|
children?: ReactNode;
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* On component mouse click callback
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
onClick?: (e: MouseEvent<HTMLElement>) => void;
|
|
16
|
+
/**
|
|
17
|
+
* On component keyboard key down callback
|
|
18
|
+
*/
|
|
19
|
+
onKeyDown?: (e: KeyboardEvent<HTMLElement>) => void;
|
|
16
20
|
/**
|
|
17
21
|
* Allows to set component as active
|
|
18
22
|
*/
|
|
19
23
|
isActive?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* A ref object, or a ref callback function
|
|
26
|
+
*/
|
|
27
|
+
innerRef?: RefObject<HTMLLIElement> | ((instance: HTMLLIElement | null) => void) | null;
|
|
20
28
|
/**
|
|
21
29
|
* Allows to pass a custom className
|
|
22
30
|
*/
|
|
@@ -21,6 +21,20 @@ const Element = styled["default"].li `
|
|
|
21
21
|
padding: 1rem 1.25rem;
|
|
22
22
|
flex-shrink: 0;
|
|
23
23
|
|
|
24
|
+
${({ onClick }) => onClick &&
|
|
25
|
+
`
|
|
26
|
+
cursor: pointer;
|
|
27
|
+
`};
|
|
28
|
+
|
|
29
|
+
&:focus-within {
|
|
30
|
+
& > * {
|
|
31
|
+
border-radius: ${theme["default"].radius.s};
|
|
32
|
+
border: 2px solid ${theme["default"].color.focus.light};
|
|
33
|
+
box-shadow: 0px 0px 0px 2px ${theme["default"].color.focus.dark};
|
|
34
|
+
outline: none;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
24
38
|
${({ isActive }) => styledUtils.media.md `
|
|
25
39
|
justify-content: center;
|
|
26
40
|
padding: 1rem 0;
|
|
@@ -29,26 +43,20 @@ const Element = styled["default"].li `
|
|
|
29
43
|
border-bottom: 3px solid ${isActive ? theme["default"].color.text.pink : 'transparent'};
|
|
30
44
|
`}
|
|
31
45
|
|
|
32
|
-
&
|
|
46
|
+
& > * {
|
|
33
47
|
display: block;
|
|
34
48
|
color: ${({ isActive }) => (isActive ? theme["default"].color.text.pink : theme["default"].color.text.black)};
|
|
35
49
|
${({ isActive }) => isActive && `font-weight: ${theme["default"].fontWeight.bold}`};
|
|
36
50
|
border: 2px solid transparent;
|
|
37
51
|
|
|
38
|
-
&:
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
box-shadow: 0px 0px 0px 2px ${theme["default"].color.focus.dark};
|
|
42
|
-
outline: none;
|
|
52
|
+
&:hover {
|
|
53
|
+
color: ${theme["default"].color.hover.pink};
|
|
54
|
+
text-decoration: none;
|
|
43
55
|
}
|
|
44
56
|
|
|
45
57
|
${styledUtils.media.md `
|
|
46
58
|
margin: auto;
|
|
47
59
|
`}
|
|
48
|
-
|
|
49
|
-
&:hover {
|
|
50
|
-
color: ${theme["default"].color.hover.pink};
|
|
51
|
-
}
|
|
52
60
|
}
|
|
53
61
|
`;
|
|
54
62
|
/**
|
|
@@ -56,7 +64,7 @@ const Element = styled["default"].li `
|
|
|
56
64
|
*/
|
|
57
65
|
const PriorityNavigationItem = (_a) => {
|
|
58
66
|
var { 'data-testid': dataTestId } = _a, props = tslib.__rest(_a, ['data-testid']);
|
|
59
|
-
return (React__default["default"].createElement(Element, { id: props.id, ref: props.innerRef, isActive: props.isActive, className: props.className, "data-testid": dataTestId }, props.children));
|
|
67
|
+
return (React__default["default"].createElement(Element, { id: props.id, ref: props.innerRef, onClick: props.onClick, onKeyDown: props.onKeyDown, isActive: props.isActive, className: props.className, "data-testid": dataTestId }, props.children));
|
|
60
68
|
};
|
|
61
69
|
|
|
62
70
|
exports["default"] = PriorityNavigationItem;
|
package/build/cjs/components/PriorityNavigationItem/__tests__/PriorityNavigationItem.spec.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
1
|
+
import type { MouseEvent, ReactNode } from 'react';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
type Type = '
|
|
3
|
+
type Type = 'box' | 'panel' | 'underlined';
|
|
4
4
|
/**
|
|
5
|
-
* @deprecated Use `
|
|
5
|
+
* @deprecated Use `box`, `panel` or `underlined` types
|
|
6
6
|
*/
|
|
7
|
-
type TypeDeprecated = 'gray';
|
|
7
|
+
type TypeDeprecated = 'default' | 'gray';
|
|
8
8
|
export interface Props {
|
|
9
9
|
/**
|
|
10
10
|
* Unique ID for the component
|
|
@@ -15,14 +15,16 @@ export interface Props {
|
|
|
15
15
|
*/
|
|
16
16
|
label: string;
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
18
|
+
* Allows to change the styling of component
|
|
19
19
|
*
|
|
20
|
-
* @param {Type}
|
|
21
|
-
* @param {Type}
|
|
20
|
+
* @param {Type} box Uses Box component as wrapper for content container
|
|
21
|
+
* @param {Type} panel Content container remains unstyled
|
|
22
|
+
* @param {Type} underlined Tab label is visually similar to anchor, with content container unstyled
|
|
22
23
|
*
|
|
23
|
-
* @param {TypeDeprecated}
|
|
24
|
+
* @param {TypeDeprecated} default DEPRECATED Use `box` type
|
|
25
|
+
* @param {TypeDeprecated} gray DEPRECATED Use `box`, `panel` or `underlined` types
|
|
24
26
|
*
|
|
25
|
-
* @default '
|
|
27
|
+
* @default 'box'
|
|
26
28
|
*/
|
|
27
29
|
type?: Type | TypeDeprecated;
|
|
28
30
|
/**
|
|
@@ -45,10 +47,19 @@ export interface Props {
|
|
|
45
47
|
* Allows to set tab as active
|
|
46
48
|
*/
|
|
47
49
|
isActive?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Allows to enable updated internal state management.
|
|
52
|
+
* Note: In updated internal state management, this component acts as truly stateless and can be controlled with `isActive` property.
|
|
53
|
+
*
|
|
54
|
+
* @deprecated Will be removed in next major release
|
|
55
|
+
*/
|
|
56
|
+
isStateless?: boolean;
|
|
48
57
|
/**
|
|
49
58
|
* On tab label click callback
|
|
59
|
+
*
|
|
60
|
+
* @deprecated Parameter `tab` has been deprecated. Use `e` parameter instead
|
|
50
61
|
*/
|
|
51
|
-
onClick?: (tab: string) => void;
|
|
62
|
+
onClick?: (tab: string, e?: MouseEvent<HTMLElement>) => void;
|
|
52
63
|
/**
|
|
53
64
|
* Allows to pass testid string for testing purposes
|
|
54
65
|
*/
|
|
@@ -7,6 +7,8 @@ var React = require('react');
|
|
|
7
7
|
var styled = require('../../themes/styled.js');
|
|
8
8
|
var theme = require('../../themes/theme.js');
|
|
9
9
|
var styledUtils = require('../../utils/styledUtils.js');
|
|
10
|
+
var Box = require('../Box/Box.js');
|
|
11
|
+
var Divider = require('../Divider/Divider.js');
|
|
10
12
|
|
|
11
13
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
14
|
|
|
@@ -18,26 +20,13 @@ const TabLabel = styled["default"].li `
|
|
|
18
20
|
list-style: none;
|
|
19
21
|
font-size: ${theme["default"].fontSize.default};
|
|
20
22
|
line-height: ${theme["default"].lineHeight.default};
|
|
21
|
-
font-weight: ${theme["default"].fontWeight.book};
|
|
23
|
+
font-weight: ${({ isActive }) => (isActive ? theme["default"].fontWeight.bold : theme["default"].fontWeight.book)};
|
|
22
24
|
background-color: ${({ isActive }) => isActive ? theme["default"].color.background.white.default : theme["default"].color.background.sand.E01};
|
|
25
|
+
border-radius: ${theme["default"].radius.default} ${theme["default"].radius.default} 0 0;
|
|
23
26
|
border: 1px solid ${theme["default"].color.line.L03};
|
|
24
27
|
border-bottom: 0 none;
|
|
25
28
|
padding: 0.625rem 1.25rem;
|
|
26
29
|
cursor: pointer;
|
|
27
|
-
|
|
28
|
-
&& + * {
|
|
29
|
-
border-right: 0 none;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
&:first-child {
|
|
33
|
-
border-right: 0 none;
|
|
34
|
-
border-radius: ${theme["default"].radius.default} 0 0 0;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
&&:last-child {
|
|
38
|
-
border-right: 1px solid ${theme["default"].color.line.L03};
|
|
39
|
-
border-radius: 0 ${theme["default"].radius.default} 0 0;
|
|
40
|
-
}
|
|
41
30
|
`;
|
|
42
31
|
const TabStyle = styled["default"].li `
|
|
43
32
|
display: inline-block;
|
|
@@ -49,11 +38,6 @@ const TabStyle = styled["default"].li `
|
|
|
49
38
|
font-size: ${theme["default"].fontSize.default};
|
|
50
39
|
line-height: ${theme["default"].lineHeight.default};
|
|
51
40
|
font-weight: ${theme["default"].fontWeight.book};
|
|
52
|
-
margin-right: ${styledUtils.getMultipliedSize(theme["default"].base.baseHeight, 2)};
|
|
53
|
-
|
|
54
|
-
&:last-child {
|
|
55
|
-
margin-right: 0;
|
|
56
|
-
}
|
|
57
41
|
|
|
58
42
|
${({ isActive }) => isActive &&
|
|
59
43
|
`
|
|
@@ -64,7 +48,6 @@ const TabStyle = styled["default"].li `
|
|
|
64
48
|
${({ $type }) => $type === 'underlined' &&
|
|
65
49
|
`
|
|
66
50
|
padding: ${styledUtils.getMultipliedSize(theme["default"].base.baseHeight, 1.6)} 0;
|
|
67
|
-
margin-right: ${styledUtils.getMultipliedSize(theme["default"].base.baseHeight, 3)};
|
|
68
51
|
`}
|
|
69
52
|
|
|
70
53
|
${({ isActive, $type }) => isActive &&
|
|
@@ -74,15 +57,44 @@ const TabStyle = styled["default"].li `
|
|
|
74
57
|
background-color: transparent;
|
|
75
58
|
`}
|
|
76
59
|
`;
|
|
60
|
+
const ContentContainer = styled["default"].div `
|
|
61
|
+
${({ $type }) => {
|
|
62
|
+
if ($type === 'box' || $type === 'default') {
|
|
63
|
+
return `
|
|
64
|
+
border-top-left-radius: 0;
|
|
65
|
+
`;
|
|
66
|
+
}
|
|
67
|
+
if ($type === 'panel') {
|
|
68
|
+
return `
|
|
69
|
+
border-top: 1px solid ${theme["default"].color.line.L03};
|
|
70
|
+
`;
|
|
71
|
+
}
|
|
72
|
+
if ($type === 'underlined' || $type === 'gray') {
|
|
73
|
+
return `
|
|
74
|
+
margin-top: ${theme["default"].grid.gutter};
|
|
75
|
+
`;
|
|
76
|
+
}
|
|
77
|
+
return '';
|
|
78
|
+
}}
|
|
79
|
+
`;
|
|
77
80
|
/** @visibleName Tab */
|
|
78
81
|
const Tab = (_a) => {
|
|
79
|
-
var { type = '
|
|
80
|
-
const onClickHandler = () => {
|
|
82
|
+
var { type = 'box', 'data-testid': dataTestId } = _a, props = tslib.__rest(_a, ["type", 'data-testid']);
|
|
83
|
+
const onClickHandler = (e) => {
|
|
81
84
|
if (props.onClick) {
|
|
82
|
-
props.onClick(props.label);
|
|
85
|
+
props.onClick(props.label, e);
|
|
83
86
|
}
|
|
84
87
|
};
|
|
85
|
-
return type === '
|
|
88
|
+
return type === 'box' || type === 'default' || type === 'panel' ? (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
89
|
+
React__default["default"].createElement(TabLabel, { role: "tab", id: props.id, "$type": type, "aria-selected": props.activeTab ? props.activeTab === props.label : props.isActive, isActive: props.activeTab ? props.activeTab === props.label : props.isActive, onClick: onClickHandler }, props.label),
|
|
90
|
+
props.isStateless &&
|
|
91
|
+
(props.children && (props.activeTab === props.label || props.isActive) ? (React__default["default"].createElement(ContentContainer, { role: "tabpanel", "$type": props.tabStyle || type, as: (type === 'box' || type === 'default') && !props.tabStyle
|
|
92
|
+
? Box["default"]
|
|
93
|
+
: undefined }, props.children)) : (React__default["default"].createElement(Divider["default"], { margin: "0" }))))) : (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
94
|
+
React__default["default"].createElement(TabStyle, { role: "tab", id: props.id, "$type": props.tabStyle || type, "aria-selected": props.activeTab ? props.activeTab === props.label : props.isActive, isActive: props.activeTab ? props.activeTab === props.label : props.isActive, onClick: onClickHandler }, props.label),
|
|
95
|
+
props.isStateless &&
|
|
96
|
+
props.children &&
|
|
97
|
+
(props.activeTab === props.label || props.isActive) && (React__default["default"].createElement(ContentContainer, { role: "tabpanel", "$type": props.tabStyle || type }, props.children))));
|
|
86
98
|
};
|
|
87
99
|
|
|
88
100
|
exports["default"] = Tab;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|