@pingux/astro 1.8.0-alpha.3 → 1.8.0-alpha.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/lib/cjs/components/Breadcrumbs/BreadcrumbItem.js +9 -2
- package/lib/cjs/components/Breadcrumbs/Breadcrumbs.js +18 -10
- package/lib/cjs/components/Breadcrumbs/Breadcrumbs.stories.js +16 -84
- package/lib/cjs/components/Breadcrumbs/Breadcrumbs.test.js +1 -1
- package/lib/cjs/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.js +4 -2
- package/lib/cjs/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.test.js +15 -4
- package/lib/cjs/styles/variants/buttons.js +9 -2
- package/lib/cjs/styles/variants/text.js +22 -0
- package/lib/components/Breadcrumbs/BreadcrumbItem.js +10 -3
- package/lib/components/Breadcrumbs/Breadcrumbs.js +19 -11
- package/lib/components/Breadcrumbs/Breadcrumbs.stories.js +14 -69
- package/lib/components/Breadcrumbs/Breadcrumbs.test.js +1 -1
- package/lib/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.js +4 -2
- package/lib/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.test.js +11 -4
- package/lib/styles/variants/buttons.js +9 -2
- package/lib/styles/variants/text.js +22 -0
- package/package.json +1 -1
@@ -87,6 +87,13 @@ var BreadcrumbItem = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
87
87
|
case 'Text':
|
88
88
|
return _index.Text;
|
89
89
|
|
90
|
+
case 'Link':
|
91
|
+
if (isCurrent) {
|
92
|
+
return _index.Text;
|
93
|
+
}
|
94
|
+
|
95
|
+
return _index.Link;
|
96
|
+
|
90
97
|
case 'Fragment':
|
91
98
|
return _react.Fragment;
|
92
99
|
|
@@ -109,7 +116,7 @@ var BreadcrumbItem = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
109
116
|
}
|
110
117
|
|
111
118
|
if (isCurrent) {
|
112
|
-
elementTypeProps.className = elementTypeProps.className ? "".concat(elementTypeProps.className, "
|
119
|
+
elementTypeProps.className = elementTypeProps.className ? "".concat(elementTypeProps.className, " is-current") : 'is-current';
|
113
120
|
}
|
114
121
|
|
115
122
|
return (0, _object.omit)(elementTypeProps, 'onClick', 'onKeyDown', 'onKeyUp');
|
@@ -135,7 +142,7 @@ BreadcrumbItem.propTypes = {
|
|
135
142
|
onAction: _propTypes["default"].func
|
136
143
|
};
|
137
144
|
BreadcrumbItem.defaultProps = {
|
138
|
-
elementType: '
|
145
|
+
elementType: 'Link'
|
139
146
|
};
|
140
147
|
BreadcrumbItem.displayName = 'BreadcrumbItem';
|
141
148
|
var _default = BreadcrumbItem;
|
@@ -77,26 +77,34 @@ var Breadcrumbs = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
77
77
|
});
|
78
78
|
var createBreadcrumb = (0, _react.useCallback)(function (child, idx) {
|
79
79
|
var isCurrentItem = (0, _isArray["default"])(filteredChildren) && filteredChildren.length > 1 ? idx === children.length - 1 : true;
|
80
|
-
return (0, _react2.jsx)(
|
81
|
-
|
80
|
+
return (0, _react2.jsx)(_index.Box, {
|
81
|
+
isRow: true,
|
82
|
+
sx: {
|
83
|
+
alignItems: 'center'
|
84
|
+
},
|
85
|
+
as: "li",
|
86
|
+
key: "li-".concat(child.key)
|
82
87
|
}, (0, _react2.jsx)(_BreadcrumbItem["default"], (0, _extends2["default"])({
|
83
88
|
"data-id": child['data-id'],
|
84
89
|
isCurrent: isCurrentItem,
|
85
90
|
onAction: onAction,
|
86
|
-
actionKey: child.key
|
91
|
+
actionKey: child.key,
|
92
|
+
variant: "text.breadcrumbLink"
|
87
93
|
}, child.props), child.props.children), icon && !isCurrentItem && (0, _react2.jsx)(_index.Icon, (0, _extends2["default"])({
|
88
|
-
|
94
|
+
"aria-hidden": "true",
|
95
|
+
icon: icon,
|
96
|
+
mx: 5,
|
97
|
+
size: 16
|
89
98
|
}, iconProps)));
|
90
99
|
}, [children.length, filteredChildren, icon, iconProps, onAction]);
|
91
|
-
return (0, _react2.jsx)(_index.Box, (0, _extends2["default"])({
|
100
|
+
return (0, _react2.jsx)("nav", null, (0, _react2.jsx)(_index.Box, (0, _extends2["default"])({
|
92
101
|
ref: breadcrumbsRef,
|
93
|
-
|
94
|
-
flexDirection: "row",
|
95
|
-
alignItems: "center",
|
102
|
+
isRow: true,
|
96
103
|
sx: {
|
97
104
|
overflow: 'auto'
|
98
|
-
}
|
99
|
-
|
105
|
+
},
|
106
|
+
as: "ol"
|
107
|
+
}, (0, _utils.mergeProps)(wrapperProps, others)), (0, _isArray["default"])(filteredChildren) ? (0, _map["default"])(filteredChildren).call(filteredChildren, createBreadcrumb) : createBreadcrumb(children)));
|
100
108
|
});
|
101
109
|
Breadcrumbs.propTypes = {
|
102
110
|
/** The icon to render in between each node. */
|
@@ -8,9 +8,7 @@ _Object$defineProperty(exports, "__esModule", {
|
|
8
8
|
value: true
|
9
9
|
});
|
10
10
|
|
11
|
-
exports["default"] = exports.WithSpan = exports.
|
12
|
-
|
13
|
-
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
11
|
+
exports["default"] = exports.WithSpan = exports.Default = void 0;
|
14
12
|
|
15
13
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
16
14
|
|
@@ -52,7 +50,6 @@ var _default = {
|
|
52
50
|
}
|
53
51
|
};
|
54
52
|
exports["default"] = _default;
|
55
|
-
var foldersArr = ['Folder 1', 'Folder 2', 'Folder 3'];
|
56
53
|
|
57
54
|
var Default = function Default(args) {
|
58
55
|
var onAction = function onAction(key) {
|
@@ -63,104 +60,39 @@ var Default = function Default(args) {
|
|
63
60
|
onAction: onAction
|
64
61
|
}, args), (0, _react2.jsx)(_collections.Item, {
|
65
62
|
key: "home",
|
66
|
-
|
67
|
-
|
63
|
+
"aria-label": "home",
|
64
|
+
variant: "buttons.link",
|
65
|
+
"data-id": "home",
|
66
|
+
href: "https://www.pingidentity.com"
|
68
67
|
}, "Home"), (0, _react2.jsx)(_collections.Item, {
|
69
68
|
key: "trendy",
|
70
|
-
|
71
|
-
|
69
|
+
"aria-label": "trendy",
|
70
|
+
variant: "buttons.link",
|
71
|
+
"data-id": "trendy",
|
72
|
+
href: "https://www.pingidentity.com"
|
72
73
|
}, "Trendy"), (0, _react2.jsx)(_collections.Item, {
|
73
74
|
key: "march 2020 assets",
|
74
|
-
|
75
|
-
|
75
|
+
"aria-label": "march-2020-assets",
|
76
|
+
variant: "buttons.link",
|
77
|
+
"data-id": "march",
|
78
|
+
href: "https://www.pingidentity.com"
|
76
79
|
}, "March 2020 Assets"));
|
77
80
|
};
|
78
81
|
|
79
82
|
exports.Default = Default;
|
80
83
|
|
81
|
-
var WithOnAction = function WithOnAction() {
|
82
|
-
// eslint-disable-next-line no-alert
|
83
|
-
var onAction = function onAction(key) {
|
84
|
-
return alert(key);
|
85
|
-
};
|
86
|
-
|
87
|
-
return (0, _react2.jsx)(_Breadcrumbs["default"], {
|
88
|
-
onAction: onAction,
|
89
|
-
icon: _ChevronRightIcon["default"]
|
90
|
-
}, (0, _react2.jsx)(_collections.Item, {
|
91
|
-
key: "home"
|
92
|
-
}, "Home"), (0, _react2.jsx)(_collections.Item, {
|
93
|
-
key: "trendy"
|
94
|
-
}, "Trendy"), (0, _react2.jsx)(_collections.Item, {
|
95
|
-
key: "march 2020 assets"
|
96
|
-
}, "March 2020 Assets"));
|
97
|
-
};
|
98
|
-
|
99
|
-
exports.WithOnAction = WithOnAction;
|
100
|
-
|
101
84
|
var WithSpan = function WithSpan() {
|
102
85
|
return (0, _react2.jsx)(_Breadcrumbs["default"], {
|
103
86
|
icon: _ChevronRightIcon["default"]
|
104
87
|
}, (0, _react2.jsx)(_collections.Item, {
|
105
88
|
key: "Parent",
|
89
|
+
"aria-label": "parent",
|
106
90
|
elementType: "span"
|
107
91
|
}, "Parent"), (0, _react2.jsx)(_collections.Item, {
|
108
92
|
key: "FonsVernall",
|
93
|
+
"aria-label": "fons-vernall",
|
109
94
|
elementType: "span"
|
110
95
|
}, "Fons Vernall"));
|
111
96
|
};
|
112
97
|
|
113
|
-
exports.WithSpan = WithSpan;
|
114
|
-
|
115
|
-
var WithIsCurrentItemClass = function WithIsCurrentItemClass(args) {
|
116
|
-
var styles = {
|
117
|
-
color: 'blue',
|
118
|
-
'&.isCurrent': {
|
119
|
-
color: 'red'
|
120
|
-
}
|
121
|
-
};
|
122
|
-
return (0, _react2.jsx)(_Breadcrumbs["default"], args, (0, _react2.jsx)(_collections.Item, {
|
123
|
-
key: "home",
|
124
|
-
sx: styles
|
125
|
-
}, "Home"), (0, _react2.jsx)(_collections.Item, {
|
126
|
-
key: "trendy",
|
127
|
-
sx: styles
|
128
|
-
}, "Trendy"), (0, _react2.jsx)(_collections.Item, {
|
129
|
-
key: "march 2020 assets",
|
130
|
-
isCurrent: true,
|
131
|
-
sx: styles
|
132
|
-
}, "March 2020 Assets"));
|
133
|
-
};
|
134
|
-
|
135
|
-
exports.WithIsCurrentItemClass = WithIsCurrentItemClass;
|
136
|
-
|
137
|
-
var WithDisabledLastItem = function WithDisabledLastItem(args) {
|
138
|
-
return (0, _react2.jsx)(_Breadcrumbs["default"], args, (0, _react2.jsx)(_collections.Item, {
|
139
|
-
key: "home",
|
140
|
-
elementType: "Button"
|
141
|
-
}, "Home"), (0, _react2.jsx)(_collections.Item, {
|
142
|
-
key: "trendy",
|
143
|
-
elementType: "Button"
|
144
|
-
}, "Trendy"), (0, _react2.jsx)(_collections.Item, {
|
145
|
-
key: "march 2020 assets",
|
146
|
-
elementType: "Button",
|
147
|
-
isDisabled: true
|
148
|
-
}, "March 2020 Assets"));
|
149
|
-
};
|
150
|
-
|
151
|
-
exports.WithDisabledLastItem = WithDisabledLastItem;
|
152
|
-
|
153
|
-
var WithHrefA = function WithHrefA(args) {
|
154
|
-
return (0, _react2.jsx)(_Breadcrumbs["default"], args, (0, _map["default"])(foldersArr).call(foldersArr, function (folder) {
|
155
|
-
return (0, _react2.jsx)(_collections.Item, {
|
156
|
-
elementType: "a",
|
157
|
-
href: "#",
|
158
|
-
key: folder,
|
159
|
-
style: {
|
160
|
-
whiteSpace: 'nowrap'
|
161
|
-
}
|
162
|
-
}, folder);
|
163
|
-
}));
|
164
|
-
};
|
165
|
-
|
166
|
-
exports.WithHrefA = WithHrefA;
|
98
|
+
exports.WithSpan = WithSpan;
|
@@ -94,7 +94,7 @@ test('breadcrumbItem should render breadcrumbItem as a html tag when appropriate
|
|
94
94
|
test('breadcrumbs will use onAction if provided', function () {
|
95
95
|
var mockOnAction = jest.fn();
|
96
96
|
getComponent({}, {
|
97
|
-
elementType: '
|
97
|
+
elementType: 'Link',
|
98
98
|
onAction: mockOnAction
|
99
99
|
});
|
100
100
|
|
@@ -290,13 +290,15 @@ var EnvironmentBreadcrumb = /*#__PURE__*/(0, _react.forwardRef)(function (props,
|
|
290
290
|
onAction: handleOnAction,
|
291
291
|
iconProps: {
|
292
292
|
color: 'neutral.70',
|
293
|
-
mx:
|
293
|
+
mx: 5,
|
294
|
+
size: 16
|
294
295
|
}
|
295
296
|
}, others), (0, _react2.jsx)(_index.Item, {
|
296
297
|
key: "name",
|
297
298
|
variant: "environmentBreadcrumb.current",
|
298
299
|
"data-testid": "name",
|
299
|
-
"aria-label": name
|
300
|
+
"aria-label": name,
|
301
|
+
elementType: "Button"
|
300
302
|
}, (0, _react2.jsx)(_index.Icon, {
|
301
303
|
icon: _HomeIcon["default"],
|
302
304
|
mr: 7
|
@@ -66,7 +66,8 @@ var onSelectionChange = jest.fn();
|
|
66
66
|
var getComponent = function getComponent(props) {
|
67
67
|
return (0, _testWrapper.render)((0, _react2.jsx)(_index.OverlayProvider, null, (0, _react2.jsx)(_index.EnvironmentBreadcrumb, (0, _extends2["default"])({}, defaultProps, props), function (item) {
|
68
68
|
return (0, _react2.jsx)(_index.Item, {
|
69
|
-
key: item.name
|
69
|
+
key: item.name,
|
70
|
+
"data-testid": item.name
|
70
71
|
}, item.name);
|
71
72
|
})));
|
72
73
|
};
|
@@ -115,10 +116,20 @@ afterAll(function () {
|
|
115
116
|
test('should render environment breadcrumb component by default', function () {
|
116
117
|
getComponent();
|
117
118
|
|
118
|
-
var
|
119
|
+
var breadcrumbList = _testWrapper.screen.getByTestId(testEnvBreadcrumb);
|
119
120
|
|
120
|
-
expect(
|
121
|
-
expect(
|
121
|
+
expect(breadcrumbList).toBeInstanceOf(HTMLOListElement);
|
122
|
+
expect(breadcrumbList).toBeInTheDocument();
|
123
|
+
|
124
|
+
var firstButton = _testWrapper.screen.getByTestId('name');
|
125
|
+
|
126
|
+
expect(firstButton).toBeInstanceOf(HTMLButtonElement);
|
127
|
+
expect(firstButton).toBeInTheDocument();
|
128
|
+
|
129
|
+
var lastButton = _testWrapper.screen.getByText('test-selected-item');
|
130
|
+
|
131
|
+
expect(lastButton).toBeInstanceOf(HTMLButtonElement);
|
132
|
+
expect(lastButton).toBeInTheDocument();
|
122
133
|
});
|
123
134
|
test('should display name', function () {
|
124
135
|
getComponent();
|
@@ -394,7 +394,9 @@ var text = _objectSpread(_objectSpread({}, base), {}, {
|
|
394
394
|
'&.is-hovered': {
|
395
395
|
textDecoration: 'underline'
|
396
396
|
},
|
397
|
-
'&.is-focused':
|
397
|
+
'&.is-focused': {
|
398
|
+
textDecoration: 'underline'
|
399
|
+
}
|
398
400
|
});
|
399
401
|
|
400
402
|
var quiet = {
|
@@ -496,9 +498,14 @@ var imageUpload = _objectSpread(_objectSpread({}, base), {}, {
|
|
496
498
|
});
|
497
499
|
|
498
500
|
var link = _objectSpread(_objectSpread({}, text), {}, {
|
501
|
+
textDecoration: 'none',
|
499
502
|
display: 'flex',
|
500
503
|
justifyContent: 'space-between',
|
501
|
-
width: 'max-content'
|
504
|
+
width: 'max-content',
|
505
|
+
'&.is-current': {
|
506
|
+
cursor: 'default',
|
507
|
+
color: 'text.primary'
|
508
|
+
}
|
502
509
|
});
|
503
510
|
|
504
511
|
var neutralText = _objectSpread(_objectSpread({}, link), {}, {
|
@@ -141,6 +141,27 @@ var expandableRow = {
|
|
141
141
|
}
|
142
142
|
}
|
143
143
|
};
|
144
|
+
var breadcrumbLink = {
|
145
|
+
color: 'active',
|
146
|
+
fontFamily: 'standard',
|
147
|
+
fontSize: '15px',
|
148
|
+
textDecoration: 'none',
|
149
|
+
outline: 'none',
|
150
|
+
'&.is-hovered': {
|
151
|
+
textDecoration: 'underline'
|
152
|
+
},
|
153
|
+
'&.is-focused': {
|
154
|
+
textDecoration: 'underline'
|
155
|
+
},
|
156
|
+
'&.is-disabled': {
|
157
|
+
pointerEvents: 'none'
|
158
|
+
},
|
159
|
+
'&.is-current': _objectSpread(_objectSpread({
|
160
|
+
pointerEvents: 'none'
|
161
|
+
}, base), {}, {
|
162
|
+
fontWeight: 1
|
163
|
+
})
|
164
|
+
};
|
144
165
|
|
145
166
|
var environmentBreadcrumb = _objectSpread(_objectSpread({}, base), {}, {
|
146
167
|
fontSize: 'sm',
|
@@ -234,6 +255,7 @@ var text = {
|
|
234
255
|
color: 'text.secondary',
|
235
256
|
fontFamily: 'standard'
|
236
257
|
}),
|
258
|
+
breadcrumbLink: breadcrumbLink,
|
237
259
|
buttonLabel: _objectSpread(_objectSpread({}, wordWrap), {}, {
|
238
260
|
fontSize: 'md',
|
239
261
|
fontWeight: 1,
|
@@ -20,7 +20,7 @@ import PropTypes from 'prop-types';
|
|
20
20
|
import { mergeProps } from '@react-aria/utils';
|
21
21
|
import { omit } from 'lodash/object';
|
22
22
|
import { usePropWarning } from '../../hooks/';
|
23
|
-
import { Button, IconButton, Text } from '../../index';
|
23
|
+
import { Button, IconButton, Text, Link } from '../../index';
|
24
24
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
25
25
|
var BreadcrumbItem = /*#__PURE__*/forwardRef(function (props, ref) {
|
26
26
|
var children = props.children,
|
@@ -52,6 +52,13 @@ var BreadcrumbItem = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
52
52
|
case 'Text':
|
53
53
|
return Text;
|
54
54
|
|
55
|
+
case 'Link':
|
56
|
+
if (isCurrent) {
|
57
|
+
return Text;
|
58
|
+
}
|
59
|
+
|
60
|
+
return Link;
|
61
|
+
|
55
62
|
case 'Fragment':
|
56
63
|
return Fragment;
|
57
64
|
|
@@ -74,7 +81,7 @@ var BreadcrumbItem = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
74
81
|
}
|
75
82
|
|
76
83
|
if (isCurrent) {
|
77
|
-
elementTypeProps.className = elementTypeProps.className ? "".concat(elementTypeProps.className, "
|
84
|
+
elementTypeProps.className = elementTypeProps.className ? "".concat(elementTypeProps.className, " is-current") : 'is-current';
|
78
85
|
}
|
79
86
|
|
80
87
|
return omit(elementTypeProps, 'onClick', 'onKeyDown', 'onKeyUp');
|
@@ -100,7 +107,7 @@ BreadcrumbItem.propTypes = {
|
|
100
107
|
onAction: PropTypes.func
|
101
108
|
};
|
102
109
|
BreadcrumbItem.defaultProps = {
|
103
|
-
elementType: '
|
110
|
+
elementType: 'Link'
|
104
111
|
};
|
105
112
|
BreadcrumbItem.displayName = 'BreadcrumbItem';
|
106
113
|
export default BreadcrumbItem;
|
@@ -4,7 +4,7 @@ import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/insta
|
|
4
4
|
import _Array$isArray from "@babel/runtime-corejs3/core-js-stable/array/is-array";
|
5
5
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
6
6
|
var _excluded = ["children", "icon", "iconProps", "onAction"];
|
7
|
-
import React, { forwardRef, useRef, useImperativeHandle,
|
7
|
+
import React, { forwardRef, useRef, useImperativeHandle, useCallback } from 'react';
|
8
8
|
import { useBreadcrumbs } from '@react-aria/breadcrumbs';
|
9
9
|
import PropTypes from 'prop-types';
|
10
10
|
import { mergeProps } from '@react-aria/utils';
|
@@ -43,26 +43,34 @@ var Breadcrumbs = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
43
43
|
});
|
44
44
|
var createBreadcrumb = useCallback(function (child, idx) {
|
45
45
|
var isCurrentItem = _Array$isArray(filteredChildren) && filteredChildren.length > 1 ? idx === children.length - 1 : true;
|
46
|
-
return ___EmotionJSX(
|
47
|
-
|
46
|
+
return ___EmotionJSX(Box, {
|
47
|
+
isRow: true,
|
48
|
+
sx: {
|
49
|
+
alignItems: 'center'
|
50
|
+
},
|
51
|
+
as: "li",
|
52
|
+
key: "li-".concat(child.key)
|
48
53
|
}, ___EmotionJSX(BreadcrumbItem, _extends({
|
49
54
|
"data-id": child['data-id'],
|
50
55
|
isCurrent: isCurrentItem,
|
51
56
|
onAction: onAction,
|
52
|
-
actionKey: child.key
|
57
|
+
actionKey: child.key,
|
58
|
+
variant: "text.breadcrumbLink"
|
53
59
|
}, child.props), child.props.children), icon && !isCurrentItem && ___EmotionJSX(Icon, _extends({
|
54
|
-
|
60
|
+
"aria-hidden": "true",
|
61
|
+
icon: icon,
|
62
|
+
mx: 5,
|
63
|
+
size: 16
|
55
64
|
}, iconProps)));
|
56
65
|
}, [children.length, filteredChildren, icon, iconProps, onAction]);
|
57
|
-
return ___EmotionJSX(Box, _extends({
|
66
|
+
return ___EmotionJSX("nav", null, ___EmotionJSX(Box, _extends({
|
58
67
|
ref: breadcrumbsRef,
|
59
|
-
|
60
|
-
flexDirection: "row",
|
61
|
-
alignItems: "center",
|
68
|
+
isRow: true,
|
62
69
|
sx: {
|
63
70
|
overflow: 'auto'
|
64
|
-
}
|
65
|
-
|
71
|
+
},
|
72
|
+
as: "ol"
|
73
|
+
}, mergeProps(wrapperProps, others)), _Array$isArray(filteredChildren) ? _mapInstanceProperty(filteredChildren).call(filteredChildren, createBreadcrumb) : createBreadcrumb(children)));
|
66
74
|
});
|
67
75
|
Breadcrumbs.propTypes = {
|
68
76
|
/** The icon to render in between each node. */
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
2
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
3
2
|
import React from 'react';
|
4
3
|
import { action } from '@storybook/addon-actions';
|
@@ -31,7 +30,6 @@ export default {
|
|
31
30
|
}
|
32
31
|
}
|
33
32
|
};
|
34
|
-
var foldersArr = ['Folder 1', 'Folder 2', 'Folder 3'];
|
35
33
|
export var Default = function Default(args) {
|
36
34
|
var onAction = function onAction(key) {
|
37
35
|
return action("onPress ".concat(key));
|
@@ -41,33 +39,22 @@ export var Default = function Default(args) {
|
|
41
39
|
onAction: onAction
|
42
40
|
}, args), ___EmotionJSX(Item, {
|
43
41
|
key: "home",
|
44
|
-
|
45
|
-
|
42
|
+
"aria-label": "home",
|
43
|
+
variant: "buttons.link",
|
44
|
+
"data-id": "home",
|
45
|
+
href: "https://www.pingidentity.com"
|
46
46
|
}, "Home"), ___EmotionJSX(Item, {
|
47
47
|
key: "trendy",
|
48
|
-
|
49
|
-
|
48
|
+
"aria-label": "trendy",
|
49
|
+
variant: "buttons.link",
|
50
|
+
"data-id": "trendy",
|
51
|
+
href: "https://www.pingidentity.com"
|
50
52
|
}, "Trendy"), ___EmotionJSX(Item, {
|
51
53
|
key: "march 2020 assets",
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
export var WithOnAction = function WithOnAction() {
|
57
|
-
// eslint-disable-next-line no-alert
|
58
|
-
var onAction = function onAction(key) {
|
59
|
-
return alert(key);
|
60
|
-
};
|
61
|
-
|
62
|
-
return ___EmotionJSX(Breadcrumbs, {
|
63
|
-
onAction: onAction,
|
64
|
-
icon: ChevronRightIcon
|
65
|
-
}, ___EmotionJSX(Item, {
|
66
|
-
key: "home"
|
67
|
-
}, "Home"), ___EmotionJSX(Item, {
|
68
|
-
key: "trendy"
|
69
|
-
}, "Trendy"), ___EmotionJSX(Item, {
|
70
|
-
key: "march 2020 assets"
|
54
|
+
"aria-label": "march-2020-assets",
|
55
|
+
variant: "buttons.link",
|
56
|
+
"data-id": "march",
|
57
|
+
href: "https://www.pingidentity.com"
|
71
58
|
}, "March 2020 Assets"));
|
72
59
|
};
|
73
60
|
export var WithSpan = function WithSpan() {
|
@@ -75,53 +62,11 @@ export var WithSpan = function WithSpan() {
|
|
75
62
|
icon: ChevronRightIcon
|
76
63
|
}, ___EmotionJSX(Item, {
|
77
64
|
key: "Parent",
|
65
|
+
"aria-label": "parent",
|
78
66
|
elementType: "span"
|
79
67
|
}, "Parent"), ___EmotionJSX(Item, {
|
80
68
|
key: "FonsVernall",
|
69
|
+
"aria-label": "fons-vernall",
|
81
70
|
elementType: "span"
|
82
71
|
}, "Fons Vernall"));
|
83
|
-
};
|
84
|
-
export var WithIsCurrentItemClass = function WithIsCurrentItemClass(args) {
|
85
|
-
var styles = {
|
86
|
-
color: 'blue',
|
87
|
-
'&.isCurrent': {
|
88
|
-
color: 'red'
|
89
|
-
}
|
90
|
-
};
|
91
|
-
return ___EmotionJSX(Breadcrumbs, args, ___EmotionJSX(Item, {
|
92
|
-
key: "home",
|
93
|
-
sx: styles
|
94
|
-
}, "Home"), ___EmotionJSX(Item, {
|
95
|
-
key: "trendy",
|
96
|
-
sx: styles
|
97
|
-
}, "Trendy"), ___EmotionJSX(Item, {
|
98
|
-
key: "march 2020 assets",
|
99
|
-
isCurrent: true,
|
100
|
-
sx: styles
|
101
|
-
}, "March 2020 Assets"));
|
102
|
-
};
|
103
|
-
export var WithDisabledLastItem = function WithDisabledLastItem(args) {
|
104
|
-
return ___EmotionJSX(Breadcrumbs, args, ___EmotionJSX(Item, {
|
105
|
-
key: "home",
|
106
|
-
elementType: "Button"
|
107
|
-
}, "Home"), ___EmotionJSX(Item, {
|
108
|
-
key: "trendy",
|
109
|
-
elementType: "Button"
|
110
|
-
}, "Trendy"), ___EmotionJSX(Item, {
|
111
|
-
key: "march 2020 assets",
|
112
|
-
elementType: "Button",
|
113
|
-
isDisabled: true
|
114
|
-
}, "March 2020 Assets"));
|
115
|
-
};
|
116
|
-
export var WithHrefA = function WithHrefA(args) {
|
117
|
-
return ___EmotionJSX(Breadcrumbs, args, _mapInstanceProperty(foldersArr).call(foldersArr, function (folder) {
|
118
|
-
return ___EmotionJSX(Item, {
|
119
|
-
elementType: "a",
|
120
|
-
href: "#",
|
121
|
-
key: folder,
|
122
|
-
style: {
|
123
|
-
whiteSpace: 'nowrap'
|
124
|
-
}
|
125
|
-
}, folder);
|
126
|
-
}));
|
127
72
|
};
|
@@ -78,7 +78,7 @@ test('breadcrumbItem should render breadcrumbItem as a html tag when appropriate
|
|
78
78
|
test('breadcrumbs will use onAction if provided', function () {
|
79
79
|
var mockOnAction = jest.fn();
|
80
80
|
getComponent({}, {
|
81
|
-
elementType: '
|
81
|
+
elementType: 'Link',
|
82
82
|
onAction: mockOnAction
|
83
83
|
});
|
84
84
|
userEvent.click(screen.getByText(testItemsArr[0]));
|
@@ -240,13 +240,15 @@ var EnvironmentBreadcrumb = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
240
240
|
onAction: handleOnAction,
|
241
241
|
iconProps: {
|
242
242
|
color: 'neutral.70',
|
243
|
-
mx:
|
243
|
+
mx: 5,
|
244
|
+
size: 16
|
244
245
|
}
|
245
246
|
}, others), ___EmotionJSX(Item, {
|
246
247
|
key: "name",
|
247
248
|
variant: "environmentBreadcrumb.current",
|
248
249
|
"data-testid": "name",
|
249
|
-
"aria-label": name
|
250
|
+
"aria-label": name,
|
251
|
+
elementType: "Button"
|
250
252
|
}, ___EmotionJSX(Icon, {
|
251
253
|
icon: HomeIcon,
|
252
254
|
mr: 7
|
@@ -52,7 +52,8 @@ var onSelectionChange = jest.fn();
|
|
52
52
|
var getComponent = function getComponent(props) {
|
53
53
|
return render(___EmotionJSX(OverlayProvider, null, ___EmotionJSX(EnvironmentBreadcrumb, _extends({}, defaultProps, props), function (item) {
|
54
54
|
return ___EmotionJSX(Item, {
|
55
|
-
key: item.name
|
55
|
+
key: item.name,
|
56
|
+
"data-testid": item.name
|
56
57
|
}, item.name);
|
57
58
|
})));
|
58
59
|
};
|
@@ -100,9 +101,15 @@ afterAll(function () {
|
|
100
101
|
});
|
101
102
|
test('should render environment breadcrumb component by default', function () {
|
102
103
|
getComponent();
|
103
|
-
var
|
104
|
-
expect(
|
105
|
-
expect(
|
104
|
+
var breadcrumbList = screen.getByTestId(testEnvBreadcrumb);
|
105
|
+
expect(breadcrumbList).toBeInstanceOf(HTMLOListElement);
|
106
|
+
expect(breadcrumbList).toBeInTheDocument();
|
107
|
+
var firstButton = screen.getByTestId('name');
|
108
|
+
expect(firstButton).toBeInstanceOf(HTMLButtonElement);
|
109
|
+
expect(firstButton).toBeInTheDocument();
|
110
|
+
var lastButton = screen.getByText('test-selected-item');
|
111
|
+
expect(lastButton).toBeInstanceOf(HTMLButtonElement);
|
112
|
+
expect(lastButton).toBeInTheDocument();
|
106
113
|
});
|
107
114
|
test('should display name', function () {
|
108
115
|
getComponent();
|
@@ -374,7 +374,9 @@ var text = _objectSpread(_objectSpread({}, base), {}, {
|
|
374
374
|
'&.is-hovered': {
|
375
375
|
textDecoration: 'underline'
|
376
376
|
},
|
377
|
-
'&.is-focused':
|
377
|
+
'&.is-focused': {
|
378
|
+
textDecoration: 'underline'
|
379
|
+
}
|
378
380
|
});
|
379
381
|
|
380
382
|
var quiet = {
|
@@ -476,9 +478,14 @@ var imageUpload = _objectSpread(_objectSpread({}, base), {}, {
|
|
476
478
|
});
|
477
479
|
|
478
480
|
var link = _objectSpread(_objectSpread({}, text), {}, {
|
481
|
+
textDecoration: 'none',
|
479
482
|
display: 'flex',
|
480
483
|
justifyContent: 'space-between',
|
481
|
-
width: 'max-content'
|
484
|
+
width: 'max-content',
|
485
|
+
'&.is-current': {
|
486
|
+
cursor: 'default',
|
487
|
+
color: 'text.primary'
|
488
|
+
}
|
482
489
|
});
|
483
490
|
|
484
491
|
var neutralText = _objectSpread(_objectSpread({}, link), {}, {
|
@@ -123,6 +123,27 @@ var expandableRow = {
|
|
123
123
|
}
|
124
124
|
}
|
125
125
|
};
|
126
|
+
var breadcrumbLink = {
|
127
|
+
color: 'active',
|
128
|
+
fontFamily: 'standard',
|
129
|
+
fontSize: '15px',
|
130
|
+
textDecoration: 'none',
|
131
|
+
outline: 'none',
|
132
|
+
'&.is-hovered': {
|
133
|
+
textDecoration: 'underline'
|
134
|
+
},
|
135
|
+
'&.is-focused': {
|
136
|
+
textDecoration: 'underline'
|
137
|
+
},
|
138
|
+
'&.is-disabled': {
|
139
|
+
pointerEvents: 'none'
|
140
|
+
},
|
141
|
+
'&.is-current': _objectSpread(_objectSpread({
|
142
|
+
pointerEvents: 'none'
|
143
|
+
}, base), {}, {
|
144
|
+
fontWeight: 1
|
145
|
+
})
|
146
|
+
};
|
126
147
|
|
127
148
|
var environmentBreadcrumb = _objectSpread(_objectSpread({}, base), {}, {
|
128
149
|
fontSize: 'sm',
|
@@ -216,6 +237,7 @@ export var text = {
|
|
216
237
|
color: 'text.secondary',
|
217
238
|
fontFamily: 'standard'
|
218
239
|
}),
|
240
|
+
breadcrumbLink: breadcrumbLink,
|
219
241
|
buttonLabel: _objectSpread(_objectSpread({}, wordWrap), {}, {
|
220
242
|
fontSize: 'md',
|
221
243
|
fontWeight: 1,
|