@pingux/astro 2.50.0-alpha.0 → 2.50.0-alpha.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/lib/cjs/components/Breadcrumbs/Breadcrumb.styles.d.ts +61 -0
- package/lib/cjs/components/Breadcrumbs/BreadcrumbItem.d.ts +11 -0
- package/lib/cjs/components/Breadcrumbs/BreadcrumbItem.js +4 -22
- package/lib/cjs/components/Breadcrumbs/Breadcrumbs.d.ts +4 -0
- package/lib/cjs/components/Breadcrumbs/Breadcrumbs.js +7 -23
- package/lib/cjs/components/Breadcrumbs/Breadcrumbs.stories.d.ts +6 -0
- package/lib/cjs/components/Breadcrumbs/Breadcrumbs.stories.js +3 -4
- package/lib/cjs/components/Breadcrumbs/Breadcrumbs.test.d.ts +1 -0
- package/lib/cjs/components/Breadcrumbs/Breadcrumbs.test.js +3 -2
- package/lib/cjs/components/Breadcrumbs/index.d.ts +2 -0
- package/lib/cjs/types/breadCrumbs.d.ts +31 -0
- package/lib/cjs/types/breadCrumbs.js +6 -0
- package/lib/cjs/types/index.d.ts +1 -0
- package/lib/cjs/types/index.js +38 -27
- package/lib/cjs/types/item.d.ts +2 -0
- package/lib/components/Breadcrumbs/BreadcrumbItem.js +6 -24
- package/lib/components/Breadcrumbs/Breadcrumbs.js +9 -25
- package/lib/components/Breadcrumbs/Breadcrumbs.stories.js +3 -4
- package/lib/components/Breadcrumbs/Breadcrumbs.test.js +3 -2
- package/lib/types/breadCrumbs.js +1 -0
- package/lib/types/index.js +1 -0
- package/package.json +1 -1
@@ -0,0 +1,61 @@
|
|
1
|
+
declare const _default: {
|
2
|
+
containerLi: {
|
3
|
+
flex: string;
|
4
|
+
minWidth: string;
|
5
|
+
'&.is-current': {
|
6
|
+
flex: string;
|
7
|
+
};
|
8
|
+
};
|
9
|
+
containerOl: {
|
10
|
+
alignItems: string;
|
11
|
+
minHeight: number;
|
12
|
+
paddingInlineStart: string;
|
13
|
+
'a.is-hovered.is-current ': {
|
14
|
+
textDecoration: string;
|
15
|
+
};
|
16
|
+
};
|
17
|
+
link: {
|
18
|
+
display: string;
|
19
|
+
minWidth: string;
|
20
|
+
'&.is-current': {
|
21
|
+
color: string;
|
22
|
+
textDecoration: string;
|
23
|
+
cursor: string;
|
24
|
+
};
|
25
|
+
lineHeight: string;
|
26
|
+
textDecoration: string;
|
27
|
+
justifyContent: string;
|
28
|
+
width: string;
|
29
|
+
'&.is-focused': {
|
30
|
+
boxShadow: string;
|
31
|
+
outline: string;
|
32
|
+
outlineColor: string;
|
33
|
+
outlineOffset: string;
|
34
|
+
};
|
35
|
+
bg: string;
|
36
|
+
border: string;
|
37
|
+
borderColor: string;
|
38
|
+
color: string;
|
39
|
+
height: string;
|
40
|
+
padding: string;
|
41
|
+
'&.is-hovered': {
|
42
|
+
textDecoration: string;
|
43
|
+
};
|
44
|
+
fontSize: string;
|
45
|
+
fontWeight: number;
|
46
|
+
fontFamily: string;
|
47
|
+
overflowWrap: string;
|
48
|
+
maxWidth: string;
|
49
|
+
wordWrap: string;
|
50
|
+
wordBreak: string;
|
51
|
+
cursor: string;
|
52
|
+
outline: string;
|
53
|
+
alignItems: string;
|
54
|
+
borderRadius: string;
|
55
|
+
flexShrink: number;
|
56
|
+
whiteSpace: string;
|
57
|
+
textOverflow: string;
|
58
|
+
overflow: string;
|
59
|
+
};
|
60
|
+
};
|
61
|
+
export default _default;
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { breadCrumbItemProps } from '../../types';
|
3
|
+
export declare const ELEMENT_TYPE: {
|
4
|
+
BUTTON: string;
|
5
|
+
ICON_BUTTON: string;
|
6
|
+
TEXT: string;
|
7
|
+
LINK: string;
|
8
|
+
FRAGMENT: string;
|
9
|
+
};
|
10
|
+
declare const BreadcrumbItem: React.ForwardRefExoticComponent<breadCrumbItemProps & React.RefAttributes<HTMLElement>>;
|
11
|
+
export default BreadcrumbItem;
|
@@ -21,7 +21,6 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-c
|
|
21
21
|
var _react = _interopRequireWildcard(require("react"));
|
22
22
|
var _reactAria = require("react-aria");
|
23
23
|
var _object = require("lodash/object");
|
24
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
25
24
|
var _hooks = require("../../hooks");
|
26
25
|
var _index = require("../../index");
|
27
26
|
var _react2 = require("@emotion/react");
|
@@ -45,15 +44,11 @@ var BreadcrumbItem = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
45
44
|
actionKey = props.actionKey,
|
46
45
|
isCurrent = props.isCurrent,
|
47
46
|
others = (0, _objectWithoutProperties2["default"])(props, _excluded);
|
48
|
-
var itemRef = (0,
|
47
|
+
var itemRef = (0, _hooks.useLocalOrForwardRef)(ref);
|
49
48
|
(0, _hooks.usePropWarning)(props, 'disabled', 'isDisabled');
|
50
|
-
/* istanbul ignore next */
|
51
|
-
(0, _react.useImperativeHandle)(ref, function () {
|
52
|
-
return itemRef.current;
|
53
|
-
});
|
54
49
|
var _useBreadcrumbItem = (0, _reactAria.useBreadcrumbItem)(_objectSpread({}, props), itemRef),
|
55
50
|
itemProps = _useBreadcrumbItem.itemProps;
|
56
|
-
var
|
51
|
+
var BreadcrumbItemElementType = (0, _react.useMemo)(function () {
|
57
52
|
switch (elementType) {
|
58
53
|
case ELEMENT_TYPE.BUTTON:
|
59
54
|
return _index.Button;
|
@@ -91,23 +86,10 @@ var BreadcrumbItem = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
91
86
|
}, elementProps);
|
92
87
|
return (0, _react2.jsx)(_index.Box, {
|
93
88
|
as: "li",
|
94
|
-
className: isCurrent
|
89
|
+
className: isCurrent ? 'is-current' : '',
|
95
90
|
variant: "variants.breadcrumb.containerLi"
|
96
|
-
}, (0, _react2.jsx)(
|
91
|
+
}, (0, _react2.jsx)(BreadcrumbItemElementType, elementVariantProps, children));
|
97
92
|
});
|
98
|
-
BreadcrumbItem.propTypes = {
|
99
|
-
actionKey: _propTypes["default"].string,
|
100
|
-
/** Whether the breadcrumb item represents the current page. */
|
101
|
-
isCurrent: _propTypes["default"].bool,
|
102
|
-
/** The HTML element used to render the breadcrumb link, e.g. 'a', or 'span'.
|
103
|
-
* Also can be passed 'Button', 'Icon', 'IconButton', 'Text' - will be used
|
104
|
-
* appropriate component from Astro library.
|
105
|
-
* */
|
106
|
-
elementType: _propTypes["default"].elementType,
|
107
|
-
/** Whether the breadcrumb item is disabled. */
|
108
|
-
isDisabled: _propTypes["default"].bool,
|
109
|
-
onAction: _propTypes["default"].func
|
110
|
-
};
|
111
93
|
BreadcrumbItem.defaultProps = {
|
112
94
|
elementType: 'Link'
|
113
95
|
};
|
@@ -16,7 +16,6 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/e
|
|
16
16
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
|
17
17
|
var _react = _interopRequireWildcard(require("react"));
|
18
18
|
var _reactAria = require("react-aria");
|
19
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
20
19
|
var _hooks = require("../../hooks");
|
21
20
|
var _index = require("../../index");
|
22
21
|
var _BreadcrumbItem = _interopRequireDefault(require("./BreadcrumbItem"));
|
@@ -30,20 +29,17 @@ var Breadcrumbs = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
30
29
|
iconProps = props.iconProps,
|
31
30
|
onAction = props.onAction,
|
32
31
|
others = (0, _objectWithoutProperties2["default"])(props, _excluded);
|
32
|
+
|
33
33
|
// the following filters undefined values passed as a child
|
34
34
|
var filteredChildren = (0, _isArray["default"])(children) ? (0, _filter["default"])(children).call(children, function (child) {
|
35
35
|
return child;
|
36
36
|
}) : children;
|
37
37
|
var _useBreadcrumbs = (0, _reactAria.useBreadcrumbs)(props),
|
38
38
|
wrapperProps = _useBreadcrumbs.navProps;
|
39
|
-
var breadcrumbsRef = (0,
|
39
|
+
var breadcrumbsRef = (0, _hooks.useLocalOrForwardRef)(ref);
|
40
40
|
(0, _hooks.usePropWarning)(props, 'disabled', 'isDisabled');
|
41
|
-
/* istanbul ignore next */
|
42
|
-
(0, _react.useImperativeHandle)(ref, function () {
|
43
|
-
return breadcrumbsRef.current;
|
44
|
-
});
|
45
41
|
var createBreadcrumb = (0, _react.useCallback)(function (child, idx) {
|
46
|
-
var isCurrentItem = (0, _isArray["default"])(filteredChildren) && filteredChildren.length > 1 ? idx === children.length - 1 : true;
|
42
|
+
var isCurrentItem = idx && (0, _isArray["default"])(children) && (0, _isArray["default"])(filteredChildren) && filteredChildren.length > 1 ? idx === children.length - 1 : true;
|
47
43
|
return (0, _react2.jsx)(_react["default"].Fragment, {
|
48
44
|
key: "li-".concat(child.key)
|
49
45
|
}, (0, _react2.jsx)(_BreadcrumbItem["default"], (0, _extends2["default"])({
|
@@ -53,14 +49,15 @@ var Breadcrumbs = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
53
49
|
onAction: onAction
|
54
50
|
}, child.props), child.props.children), icon && !isCurrentItem && (0, _react2.jsx)(_index.Icon, (0, _extends2["default"])({
|
55
51
|
"aria-hidden": "true",
|
56
|
-
icon: icon,
|
57
52
|
mx: 5,
|
58
53
|
size: "xs",
|
59
54
|
title: {
|
60
55
|
name: 'Breadcrumb Separator'
|
61
56
|
}
|
62
|
-
}, iconProps
|
63
|
-
|
57
|
+
}, iconProps, {
|
58
|
+
icon: icon
|
59
|
+
})));
|
60
|
+
}, [(0, _isArray["default"])(children) && children.length, filteredChildren, icon, iconProps, onAction]);
|
64
61
|
return (0, _react2.jsx)("nav", {
|
65
62
|
"aria-label": "Breadcrumb"
|
66
63
|
}, (0, _react2.jsx)(_index.Box, (0, _extends2["default"])({
|
@@ -70,19 +67,6 @@ var Breadcrumbs = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
70
67
|
variant: "variants.breadcrumb.containerOl"
|
71
68
|
}, (0, _reactAria.mergeProps)(wrapperProps, others)), (0, _isArray["default"])(filteredChildren) ? (0, _map["default"])(filteredChildren).call(filteredChildren, createBreadcrumb) : createBreadcrumb(children)));
|
72
69
|
});
|
73
|
-
Breadcrumbs.propTypes = {
|
74
|
-
/** The icon to render in between each node. */
|
75
|
-
icon: _propTypes["default"].elementType,
|
76
|
-
/** Props object passed along to the Icon component. */
|
77
|
-
iconProps: _propTypes["default"].shape({}),
|
78
|
-
/** Whether the Breadcrumbs are disabled. */
|
79
|
-
isDisabled: _propTypes["default"].bool,
|
80
|
-
/** Defines a string value that labels the current element. */
|
81
|
-
'aria-label': _propTypes["default"].string,
|
82
|
-
/** Called when an item is acted upon (usually selection via press). */
|
83
|
-
/** (key: Key) => void. */
|
84
|
-
onAction: _propTypes["default"].func
|
85
|
-
};
|
86
70
|
Breadcrumbs.displayName = 'Breadcrumbs';
|
87
71
|
var _default = Breadcrumbs;
|
88
72
|
exports["default"] = _default;
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import { StoryFn } from '@storybook/react';
|
2
|
+
import { breadCrumbsProps } from '../../types';
|
3
|
+
declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, import("@storybook/types").Args>;
|
4
|
+
export default _default;
|
5
|
+
export declare const Default: StoryFn<breadCrumbsProps>;
|
6
|
+
export declare const Overflowing: StoryFn;
|
@@ -14,7 +14,7 @@ var _addonActions = require("@storybook/addon-actions");
|
|
14
14
|
var _storybookAddonDesigns = require("storybook-addon-designs");
|
15
15
|
var _storybookDocsLayout = _interopRequireDefault(require("../../../.storybook/storybookDocsLayout"));
|
16
16
|
var _index = require("../../index");
|
17
|
-
var _figmaLinks = require("../../utils/designUtils/figmaLinks
|
17
|
+
var _figmaLinks = require("../../utils/designUtils/figmaLinks");
|
18
18
|
var _Breadcrumbs = _interopRequireDefault(require("./Breadcrumbs.mdx"));
|
19
19
|
var _react2 = require("@emotion/react");
|
20
20
|
var _default = {
|
@@ -50,9 +50,8 @@ var Default = function Default(args) {
|
|
50
50
|
var onAction = function onAction(key) {
|
51
51
|
return (0, _addonActions.action)("onPress ".concat(key));
|
52
52
|
};
|
53
|
-
return (0, _react2.jsx)(_index.Breadcrumbs, (0, _extends2["default"])({
|
54
|
-
onAction: onAction
|
55
|
-
}, args, {
|
53
|
+
return (0, _react2.jsx)(_index.Breadcrumbs, (0, _extends2["default"])({}, args, {
|
54
|
+
onAction: onAction,
|
56
55
|
icon: _ChevronRightIcon["default"]
|
57
56
|
}), (0, _react2.jsx)(_reactStately.Item, {
|
58
57
|
"aria-label": "home",
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -54,10 +54,11 @@ test('should render nodes from the children', function () {
|
|
54
54
|
test('should render correct amount of icons', function () {
|
55
55
|
getComponent({
|
56
56
|
iconProps: {
|
57
|
-
'data-testid': testIconId
|
57
|
+
'data-testid': testIconId,
|
58
|
+
icon: _ChevronRightIcon["default"]
|
58
59
|
}
|
59
60
|
});
|
60
|
-
expect(_testWrapper.screen.getAllByTestId(testIconId).length).toBe(testItemsArr.length -
|
61
|
+
expect(_testWrapper.screen.getAllByTestId(testIconId).length).toBe(testItemsArr.length - 2);
|
61
62
|
});
|
62
63
|
test('breadcrumbItem should render breadcrumbItem as a Text component when appropriate elementType passed', function () {
|
63
64
|
getComponent({}, {
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import { type ElementType } from 'react';
|
2
|
+
import { TestingAttributes } from './shared/test';
|
3
|
+
import { BoxProps } from './box';
|
4
|
+
import { IconProps } from './icon';
|
5
|
+
export interface breadCrumbsProps extends BoxProps, TestingAttributes {
|
6
|
+
/** The icon to render in between each node. */
|
7
|
+
icon?: ElementType;
|
8
|
+
/** Props object passed along to the Icon component. */
|
9
|
+
iconProps?: IconProps;
|
10
|
+
/** Whether the Breadcrumbs are disabled. */
|
11
|
+
isDisabled?: boolean;
|
12
|
+
/** Defines a string value that labels the current element. */
|
13
|
+
'aria-label'?: string;
|
14
|
+
/** Called when an item is acted upon (usually selection via press). */
|
15
|
+
/** (key: Key) => void. */
|
16
|
+
onAction?: (key: unknown) => void;
|
17
|
+
}
|
18
|
+
export interface breadCrumbItemProps extends BoxProps, TestingAttributes {
|
19
|
+
actionKey?: string;
|
20
|
+
/** Whether the breadcrumb item represents the current page. */
|
21
|
+
isCurrent?: boolean;
|
22
|
+
/** The HTML element used to render the breadcrumb link, e.g. 'a', or 'span'.
|
23
|
+
* Also can be passed 'Button', 'Icon', 'IconButton', 'Text' - will be used
|
24
|
+
* appropriate component from Astro library.
|
25
|
+
* */
|
26
|
+
elementType?: string | ElementType;
|
27
|
+
/** Whether the breadcrumb item is disabled. */
|
28
|
+
isDisabled?: boolean;
|
29
|
+
onAction?: (key: unknown) => void;
|
30
|
+
onPress?: () => void;
|
31
|
+
}
|
package/lib/cjs/types/index.d.ts
CHANGED
package/lib/cjs/types/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _context, _context2, _context3, _context4, _context5, _context6, _context7, _context8, _context9, _context10, _context11, _context12, _context13, _context14, _context15, _context16, _context17, _context18, _context19, _context20, _context21, _context22, _context23, _context24, _context25, _context26, _context27, _context28, _context29;
|
3
|
+
var _context, _context2, _context3, _context4, _context5, _context6, _context7, _context8, _context9, _context10, _context11, _context12, _context13, _context14, _context15, _context16, _context17, _context18, _context19, _context20, _context21, _context22, _context23, _context24, _context25, _context26, _context27, _context28, _context29, _context30;
|
4
4
|
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
5
5
|
var _forEachInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/for-each");
|
6
6
|
var _Object$keys = require("@babel/runtime-corejs3/core-js-stable/object/keys");
|
@@ -40,8 +40,19 @@ _forEachInstanceProperty(_context3 = _Object$keys(_bracket)).call(_context3, fun
|
|
40
40
|
}
|
41
41
|
});
|
42
42
|
});
|
43
|
+
var _breadCrumbs = require("./breadCrumbs");
|
44
|
+
_forEachInstanceProperty(_context4 = _Object$keys(_breadCrumbs)).call(_context4, function (key) {
|
45
|
+
if (key === "default" || key === "__esModule") return;
|
46
|
+
if (key in exports && exports[key] === _breadCrumbs[key]) return;
|
47
|
+
_Object$defineProperty(exports, key, {
|
48
|
+
enumerable: true,
|
49
|
+
get: function get() {
|
50
|
+
return _breadCrumbs[key];
|
51
|
+
}
|
52
|
+
});
|
53
|
+
});
|
43
54
|
var _button = require("./button");
|
44
|
-
_forEachInstanceProperty(
|
55
|
+
_forEachInstanceProperty(_context5 = _Object$keys(_button)).call(_context5, function (key) {
|
45
56
|
if (key === "default" || key === "__esModule") return;
|
46
57
|
if (key in exports && exports[key] === _button[key]) return;
|
47
58
|
_Object$defineProperty(exports, key, {
|
@@ -52,7 +63,7 @@ _forEachInstanceProperty(_context4 = _Object$keys(_button)).call(_context4, func
|
|
52
63
|
});
|
53
64
|
});
|
54
65
|
var _buttonBar = require("./buttonBar");
|
55
|
-
_forEachInstanceProperty(
|
66
|
+
_forEachInstanceProperty(_context6 = _Object$keys(_buttonBar)).call(_context6, function (key) {
|
56
67
|
if (key === "default" || key === "__esModule") return;
|
57
68
|
if (key in exports && exports[key] === _buttonBar[key]) return;
|
58
69
|
_Object$defineProperty(exports, key, {
|
@@ -63,7 +74,7 @@ _forEachInstanceProperty(_context5 = _Object$keys(_buttonBar)).call(_context5, f
|
|
63
74
|
});
|
64
75
|
});
|
65
76
|
var _card = require("./card");
|
66
|
-
_forEachInstanceProperty(
|
77
|
+
_forEachInstanceProperty(_context7 = _Object$keys(_card)).call(_context7, function (key) {
|
67
78
|
if (key === "default" || key === "__esModule") return;
|
68
79
|
if (key in exports && exports[key] === _card[key]) return;
|
69
80
|
_Object$defineProperty(exports, key, {
|
@@ -74,7 +85,7 @@ _forEachInstanceProperty(_context6 = _Object$keys(_card)).call(_context6, functi
|
|
74
85
|
});
|
75
86
|
});
|
76
87
|
var _fieldHelperText = require("./fieldHelperText");
|
77
|
-
_forEachInstanceProperty(
|
88
|
+
_forEachInstanceProperty(_context8 = _Object$keys(_fieldHelperText)).call(_context8, function (key) {
|
78
89
|
if (key === "default" || key === "__esModule") return;
|
79
90
|
if (key in exports && exports[key] === _fieldHelperText[key]) return;
|
80
91
|
_Object$defineProperty(exports, key, {
|
@@ -85,7 +96,7 @@ _forEachInstanceProperty(_context7 = _Object$keys(_fieldHelperText)).call(_conte
|
|
85
96
|
});
|
86
97
|
});
|
87
98
|
var _helpHint = require("./helpHint");
|
88
|
-
_forEachInstanceProperty(
|
99
|
+
_forEachInstanceProperty(_context9 = _Object$keys(_helpHint)).call(_context9, function (key) {
|
89
100
|
if (key === "default" || key === "__esModule") return;
|
90
101
|
if (key in exports && exports[key] === _helpHint[key]) return;
|
91
102
|
_Object$defineProperty(exports, key, {
|
@@ -96,7 +107,7 @@ _forEachInstanceProperty(_context8 = _Object$keys(_helpHint)).call(_context8, fu
|
|
96
107
|
});
|
97
108
|
});
|
98
109
|
var _icon = require("./icon");
|
99
|
-
_forEachInstanceProperty(
|
110
|
+
_forEachInstanceProperty(_context10 = _Object$keys(_icon)).call(_context10, function (key) {
|
100
111
|
if (key === "default" || key === "__esModule") return;
|
101
112
|
if (key in exports && exports[key] === _icon[key]) return;
|
102
113
|
_Object$defineProperty(exports, key, {
|
@@ -107,7 +118,7 @@ _forEachInstanceProperty(_context9 = _Object$keys(_icon)).call(_context9, functi
|
|
107
118
|
});
|
108
119
|
});
|
109
120
|
var _iconBadge = require("./iconBadge");
|
110
|
-
_forEachInstanceProperty(
|
121
|
+
_forEachInstanceProperty(_context11 = _Object$keys(_iconBadge)).call(_context11, function (key) {
|
111
122
|
if (key === "default" || key === "__esModule") return;
|
112
123
|
if (key in exports && exports[key] === _iconBadge[key]) return;
|
113
124
|
_Object$defineProperty(exports, key, {
|
@@ -118,7 +129,7 @@ _forEachInstanceProperty(_context10 = _Object$keys(_iconBadge)).call(_context10,
|
|
118
129
|
});
|
119
130
|
});
|
120
131
|
var _iconButton = require("./iconButton");
|
121
|
-
_forEachInstanceProperty(
|
132
|
+
_forEachInstanceProperty(_context12 = _Object$keys(_iconButton)).call(_context12, function (key) {
|
122
133
|
if (key === "default" || key === "__esModule") return;
|
123
134
|
if (key in exports && exports[key] === _iconButton[key]) return;
|
124
135
|
_Object$defineProperty(exports, key, {
|
@@ -129,7 +140,7 @@ _forEachInstanceProperty(_context11 = _Object$keys(_iconButton)).call(_context11
|
|
129
140
|
});
|
130
141
|
});
|
131
142
|
var _input = require("./input");
|
132
|
-
_forEachInstanceProperty(
|
143
|
+
_forEachInstanceProperty(_context13 = _Object$keys(_input)).call(_context13, function (key) {
|
133
144
|
if (key === "default" || key === "__esModule") return;
|
134
145
|
if (key in exports && exports[key] === _input[key]) return;
|
135
146
|
_Object$defineProperty(exports, key, {
|
@@ -140,7 +151,7 @@ _forEachInstanceProperty(_context12 = _Object$keys(_input)).call(_context12, fun
|
|
140
151
|
});
|
141
152
|
});
|
142
153
|
var _item = require("./item");
|
143
|
-
_forEachInstanceProperty(
|
154
|
+
_forEachInstanceProperty(_context14 = _Object$keys(_item)).call(_context14, function (key) {
|
144
155
|
if (key === "default" || key === "__esModule") return;
|
145
156
|
if (key in exports && exports[key] === _item[key]) return;
|
146
157
|
_Object$defineProperty(exports, key, {
|
@@ -151,7 +162,7 @@ _forEachInstanceProperty(_context13 = _Object$keys(_item)).call(_context13, func
|
|
151
162
|
});
|
152
163
|
});
|
153
164
|
var _link = require("./link");
|
154
|
-
_forEachInstanceProperty(
|
165
|
+
_forEachInstanceProperty(_context15 = _Object$keys(_link)).call(_context15, function (key) {
|
155
166
|
if (key === "default" || key === "__esModule") return;
|
156
167
|
if (key in exports && exports[key] === _link[key]) return;
|
157
168
|
_Object$defineProperty(exports, key, {
|
@@ -162,7 +173,7 @@ _forEachInstanceProperty(_context14 = _Object$keys(_link)).call(_context14, func
|
|
162
173
|
});
|
163
174
|
});
|
164
175
|
var _listItem = require("./listItem");
|
165
|
-
_forEachInstanceProperty(
|
176
|
+
_forEachInstanceProperty(_context16 = _Object$keys(_listItem)).call(_context16, function (key) {
|
166
177
|
if (key === "default" || key === "__esModule") return;
|
167
178
|
if (key in exports && exports[key] === _listItem[key]) return;
|
168
179
|
_Object$defineProperty(exports, key, {
|
@@ -173,7 +184,7 @@ _forEachInstanceProperty(_context15 = _Object$keys(_listItem)).call(_context15,
|
|
173
184
|
});
|
174
185
|
});
|
175
186
|
var _loader = require("./loader");
|
176
|
-
_forEachInstanceProperty(
|
187
|
+
_forEachInstanceProperty(_context17 = _Object$keys(_loader)).call(_context17, function (key) {
|
177
188
|
if (key === "default" || key === "__esModule") return;
|
178
189
|
if (key in exports && exports[key] === _loader[key]) return;
|
179
190
|
_Object$defineProperty(exports, key, {
|
@@ -184,7 +195,7 @@ _forEachInstanceProperty(_context16 = _Object$keys(_loader)).call(_context16, fu
|
|
184
195
|
});
|
185
196
|
});
|
186
197
|
var _menu = require("./menu");
|
187
|
-
_forEachInstanceProperty(
|
198
|
+
_forEachInstanceProperty(_context18 = _Object$keys(_menu)).call(_context18, function (key) {
|
188
199
|
if (key === "default" || key === "__esModule") return;
|
189
200
|
if (key in exports && exports[key] === _menu[key]) return;
|
190
201
|
_Object$defineProperty(exports, key, {
|
@@ -195,7 +206,7 @@ _forEachInstanceProperty(_context17 = _Object$keys(_menu)).call(_context17, func
|
|
195
206
|
});
|
196
207
|
});
|
197
208
|
var _menuItem = require("./menuItem");
|
198
|
-
_forEachInstanceProperty(
|
209
|
+
_forEachInstanceProperty(_context19 = _Object$keys(_menuItem)).call(_context19, function (key) {
|
199
210
|
if (key === "default" || key === "__esModule") return;
|
200
211
|
if (key in exports && exports[key] === _menuItem[key]) return;
|
201
212
|
_Object$defineProperty(exports, key, {
|
@@ -206,7 +217,7 @@ _forEachInstanceProperty(_context18 = _Object$keys(_menuItem)).call(_context18,
|
|
206
217
|
});
|
207
218
|
});
|
208
219
|
var _overlayPanel = require("./overlayPanel");
|
209
|
-
_forEachInstanceProperty(
|
220
|
+
_forEachInstanceProperty(_context20 = _Object$keys(_overlayPanel)).call(_context20, function (key) {
|
210
221
|
if (key === "default" || key === "__esModule") return;
|
211
222
|
if (key in exports && exports[key] === _overlayPanel[key]) return;
|
212
223
|
_Object$defineProperty(exports, key, {
|
@@ -217,7 +228,7 @@ _forEachInstanceProperty(_context19 = _Object$keys(_overlayPanel)).call(_context
|
|
217
228
|
});
|
218
229
|
});
|
219
230
|
var _popoverContainer = require("./popoverContainer");
|
220
|
-
_forEachInstanceProperty(
|
231
|
+
_forEachInstanceProperty(_context21 = _Object$keys(_popoverContainer)).call(_context21, function (key) {
|
221
232
|
if (key === "default" || key === "__esModule") return;
|
222
233
|
if (key in exports && exports[key] === _popoverContainer[key]) return;
|
223
234
|
_Object$defineProperty(exports, key, {
|
@@ -228,7 +239,7 @@ _forEachInstanceProperty(_context20 = _Object$keys(_popoverContainer)).call(_con
|
|
228
239
|
});
|
229
240
|
});
|
230
241
|
var _popoverMenu = require("./popoverMenu");
|
231
|
-
_forEachInstanceProperty(
|
242
|
+
_forEachInstanceProperty(_context22 = _Object$keys(_popoverMenu)).call(_context22, function (key) {
|
232
243
|
if (key === "default" || key === "__esModule") return;
|
233
244
|
if (key in exports && exports[key] === _popoverMenu[key]) return;
|
234
245
|
_Object$defineProperty(exports, key, {
|
@@ -239,7 +250,7 @@ _forEachInstanceProperty(_context21 = _Object$keys(_popoverMenu)).call(_context2
|
|
239
250
|
});
|
240
251
|
});
|
241
252
|
var _requirementsList = require("./requirementsList");
|
242
|
-
_forEachInstanceProperty(
|
253
|
+
_forEachInstanceProperty(_context23 = _Object$keys(_requirementsList)).call(_context23, function (key) {
|
243
254
|
if (key === "default" || key === "__esModule") return;
|
244
255
|
if (key in exports && exports[key] === _requirementsList[key]) return;
|
245
256
|
_Object$defineProperty(exports, key, {
|
@@ -250,7 +261,7 @@ _forEachInstanceProperty(_context22 = _Object$keys(_requirementsList)).call(_con
|
|
250
261
|
});
|
251
262
|
});
|
252
263
|
var _rockerButtonGroup = require("./rockerButtonGroup");
|
253
|
-
_forEachInstanceProperty(
|
264
|
+
_forEachInstanceProperty(_context24 = _Object$keys(_rockerButtonGroup)).call(_context24, function (key) {
|
254
265
|
if (key === "default" || key === "__esModule") return;
|
255
266
|
if (key in exports && exports[key] === _rockerButtonGroup[key]) return;
|
256
267
|
_Object$defineProperty(exports, key, {
|
@@ -261,7 +272,7 @@ _forEachInstanceProperty(_context23 = _Object$keys(_rockerButtonGroup)).call(_co
|
|
261
272
|
});
|
262
273
|
});
|
263
274
|
var _scrollBox = require("./scrollBox");
|
264
|
-
_forEachInstanceProperty(
|
275
|
+
_forEachInstanceProperty(_context25 = _Object$keys(_scrollBox)).call(_context25, function (key) {
|
265
276
|
if (key === "default" || key === "__esModule") return;
|
266
277
|
if (key in exports && exports[key] === _scrollBox[key]) return;
|
267
278
|
_Object$defineProperty(exports, key, {
|
@@ -272,7 +283,7 @@ _forEachInstanceProperty(_context24 = _Object$keys(_scrollBox)).call(_context24,
|
|
272
283
|
});
|
273
284
|
});
|
274
285
|
var _separator = require("./separator");
|
275
|
-
_forEachInstanceProperty(
|
286
|
+
_forEachInstanceProperty(_context26 = _Object$keys(_separator)).call(_context26, function (key) {
|
276
287
|
if (key === "default" || key === "__esModule") return;
|
277
288
|
if (key in exports && exports[key] === _separator[key]) return;
|
278
289
|
_Object$defineProperty(exports, key, {
|
@@ -283,7 +294,7 @@ _forEachInstanceProperty(_context25 = _Object$keys(_separator)).call(_context25,
|
|
283
294
|
});
|
284
295
|
});
|
285
296
|
var _shared = require("./shared");
|
286
|
-
_forEachInstanceProperty(
|
297
|
+
_forEachInstanceProperty(_context27 = _Object$keys(_shared)).call(_context27, function (key) {
|
287
298
|
if (key === "default" || key === "__esModule") return;
|
288
299
|
if (key in exports && exports[key] === _shared[key]) return;
|
289
300
|
_Object$defineProperty(exports, key, {
|
@@ -294,7 +305,7 @@ _forEachInstanceProperty(_context26 = _Object$keys(_shared)).call(_context26, fu
|
|
294
305
|
});
|
295
306
|
});
|
296
307
|
var _table = require("./table");
|
297
|
-
_forEachInstanceProperty(
|
308
|
+
_forEachInstanceProperty(_context28 = _Object$keys(_table)).call(_context28, function (key) {
|
298
309
|
if (key === "default" || key === "__esModule") return;
|
299
310
|
if (key in exports && exports[key] === _table[key]) return;
|
300
311
|
_Object$defineProperty(exports, key, {
|
@@ -305,7 +316,7 @@ _forEachInstanceProperty(_context27 = _Object$keys(_table)).call(_context27, fun
|
|
305
316
|
});
|
306
317
|
});
|
307
318
|
var _text = require("./text");
|
308
|
-
_forEachInstanceProperty(
|
319
|
+
_forEachInstanceProperty(_context29 = _Object$keys(_text)).call(_context29, function (key) {
|
309
320
|
if (key === "default" || key === "__esModule") return;
|
310
321
|
if (key in exports && exports[key] === _text[key]) return;
|
311
322
|
_Object$defineProperty(exports, key, {
|
@@ -316,7 +327,7 @@ _forEachInstanceProperty(_context28 = _Object$keys(_text)).call(_context28, func
|
|
316
327
|
});
|
317
328
|
});
|
318
329
|
var _tooltipTrigger = require("./tooltipTrigger");
|
319
|
-
_forEachInstanceProperty(
|
330
|
+
_forEachInstanceProperty(_context30 = _Object$keys(_tooltipTrigger)).call(_context30, function (key) {
|
320
331
|
if (key === "default" || key === "__esModule") return;
|
321
332
|
if (key in exports && exports[key] === _tooltipTrigger[key]) return;
|
322
333
|
_Object$defineProperty(exports, key, {
|
package/lib/cjs/types/item.d.ts
CHANGED
@@ -12,11 +12,10 @@ var _excluded = ["children", "elementType", "onAction", "actionKey", "isCurrent"
|
|
12
12
|
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
13
13
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
14
14
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
15
|
-
import React, { forwardRef, Fragment, useCallback,
|
15
|
+
import React, { forwardRef, Fragment, useCallback, useMemo } from 'react';
|
16
16
|
import { mergeProps, useBreadcrumbItem } from 'react-aria';
|
17
17
|
import { omit } from 'lodash/object';
|
18
|
-
import
|
19
|
-
import { usePropWarning } from '../../hooks';
|
18
|
+
import { useLocalOrForwardRef, usePropWarning } from '../../hooks';
|
20
19
|
import { Box, Button, IconButton, Link, Text } from '../../index';
|
21
20
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
22
21
|
export var ELEMENT_TYPE = {
|
@@ -33,15 +32,11 @@ var BreadcrumbItem = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
33
32
|
actionKey = props.actionKey,
|
34
33
|
isCurrent = props.isCurrent,
|
35
34
|
others = _objectWithoutProperties(props, _excluded);
|
36
|
-
var itemRef =
|
35
|
+
var itemRef = useLocalOrForwardRef(ref);
|
37
36
|
usePropWarning(props, 'disabled', 'isDisabled');
|
38
|
-
/* istanbul ignore next */
|
39
|
-
useImperativeHandle(ref, function () {
|
40
|
-
return itemRef.current;
|
41
|
-
});
|
42
37
|
var _useBreadcrumbItem = useBreadcrumbItem(_objectSpread({}, props), itemRef),
|
43
38
|
itemProps = _useBreadcrumbItem.itemProps;
|
44
|
-
var
|
39
|
+
var BreadcrumbItemElementType = useMemo(function () {
|
45
40
|
switch (elementType) {
|
46
41
|
case ELEMENT_TYPE.BUTTON:
|
47
42
|
return Button;
|
@@ -79,23 +74,10 @@ var BreadcrumbItem = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
79
74
|
}, elementProps);
|
80
75
|
return ___EmotionJSX(Box, {
|
81
76
|
as: "li",
|
82
|
-
className: isCurrent
|
77
|
+
className: isCurrent ? 'is-current' : '',
|
83
78
|
variant: "variants.breadcrumb.containerLi"
|
84
|
-
}, ___EmotionJSX(
|
79
|
+
}, ___EmotionJSX(BreadcrumbItemElementType, elementVariantProps, children));
|
85
80
|
});
|
86
|
-
BreadcrumbItem.propTypes = {
|
87
|
-
actionKey: PropTypes.string,
|
88
|
-
/** Whether the breadcrumb item represents the current page. */
|
89
|
-
isCurrent: PropTypes.bool,
|
90
|
-
/** The HTML element used to render the breadcrumb link, e.g. 'a', or 'span'.
|
91
|
-
* Also can be passed 'Button', 'Icon', 'IconButton', 'Text' - will be used
|
92
|
-
* appropriate component from Astro library.
|
93
|
-
* */
|
94
|
-
elementType: PropTypes.elementType,
|
95
|
-
/** Whether the breadcrumb item is disabled. */
|
96
|
-
isDisabled: PropTypes.bool,
|
97
|
-
onAction: PropTypes.func
|
98
|
-
};
|
99
81
|
BreadcrumbItem.defaultProps = {
|
100
82
|
elementType: 'Link'
|
101
83
|
};
|
@@ -4,10 +4,9 @@ var _excluded = ["children", "icon", "iconProps", "onAction"];
|
|
4
4
|
import _Array$isArray from "@babel/runtime-corejs3/core-js-stable/array/is-array";
|
5
5
|
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
6
6
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
7
|
-
import React, { forwardRef, useCallback
|
7
|
+
import React, { forwardRef, useCallback } from 'react';
|
8
8
|
import { mergeProps, useBreadcrumbs } from 'react-aria';
|
9
|
-
import
|
10
|
-
import { usePropWarning } from '../../hooks';
|
9
|
+
import { useLocalOrForwardRef, usePropWarning } from '../../hooks';
|
11
10
|
import { Box, Icon } from '../../index';
|
12
11
|
import BreadcrumbItem from './BreadcrumbItem';
|
13
12
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
@@ -17,20 +16,17 @@ var Breadcrumbs = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
17
16
|
iconProps = props.iconProps,
|
18
17
|
onAction = props.onAction,
|
19
18
|
others = _objectWithoutProperties(props, _excluded);
|
19
|
+
|
20
20
|
// the following filters undefined values passed as a child
|
21
21
|
var filteredChildren = _Array$isArray(children) ? _filterInstanceProperty(children).call(children, function (child) {
|
22
22
|
return child;
|
23
23
|
}) : children;
|
24
24
|
var _useBreadcrumbs = useBreadcrumbs(props),
|
25
25
|
wrapperProps = _useBreadcrumbs.navProps;
|
26
|
-
var breadcrumbsRef =
|
26
|
+
var breadcrumbsRef = useLocalOrForwardRef(ref);
|
27
27
|
usePropWarning(props, 'disabled', 'isDisabled');
|
28
|
-
/* istanbul ignore next */
|
29
|
-
useImperativeHandle(ref, function () {
|
30
|
-
return breadcrumbsRef.current;
|
31
|
-
});
|
32
28
|
var createBreadcrumb = useCallback(function (child, idx) {
|
33
|
-
var isCurrentItem = _Array$isArray(filteredChildren) && filteredChildren.length > 1 ? idx === children.length - 1 : true;
|
29
|
+
var isCurrentItem = idx && _Array$isArray(children) && _Array$isArray(filteredChildren) && filteredChildren.length > 1 ? idx === children.length - 1 : true;
|
34
30
|
return ___EmotionJSX(React.Fragment, {
|
35
31
|
key: "li-".concat(child.key)
|
36
32
|
}, ___EmotionJSX(BreadcrumbItem, _extends({
|
@@ -40,14 +36,15 @@ var Breadcrumbs = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
40
36
|
onAction: onAction
|
41
37
|
}, child.props), child.props.children), icon && !isCurrentItem && ___EmotionJSX(Icon, _extends({
|
42
38
|
"aria-hidden": "true",
|
43
|
-
icon: icon,
|
44
39
|
mx: 5,
|
45
40
|
size: "xs",
|
46
41
|
title: {
|
47
42
|
name: 'Breadcrumb Separator'
|
48
43
|
}
|
49
|
-
}, iconProps
|
50
|
-
|
44
|
+
}, iconProps, {
|
45
|
+
icon: icon
|
46
|
+
})));
|
47
|
+
}, [_Array$isArray(children) && children.length, filteredChildren, icon, iconProps, onAction]);
|
51
48
|
return ___EmotionJSX("nav", {
|
52
49
|
"aria-label": "Breadcrumb"
|
53
50
|
}, ___EmotionJSX(Box, _extends({
|
@@ -57,18 +54,5 @@ var Breadcrumbs = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
57
54
|
variant: "variants.breadcrumb.containerOl"
|
58
55
|
}, mergeProps(wrapperProps, others)), _Array$isArray(filteredChildren) ? _mapInstanceProperty(filteredChildren).call(filteredChildren, createBreadcrumb) : createBreadcrumb(children)));
|
59
56
|
});
|
60
|
-
Breadcrumbs.propTypes = {
|
61
|
-
/** The icon to render in between each node. */
|
62
|
-
icon: PropTypes.elementType,
|
63
|
-
/** Props object passed along to the Icon component. */
|
64
|
-
iconProps: PropTypes.shape({}),
|
65
|
-
/** Whether the Breadcrumbs are disabled. */
|
66
|
-
isDisabled: PropTypes.bool,
|
67
|
-
/** Defines a string value that labels the current element. */
|
68
|
-
'aria-label': PropTypes.string,
|
69
|
-
/** Called when an item is acted upon (usually selection via press). */
|
70
|
-
/** (key: Key) => void. */
|
71
|
-
onAction: PropTypes.func
|
72
|
-
};
|
73
57
|
Breadcrumbs.displayName = 'Breadcrumbs';
|
74
58
|
export default Breadcrumbs;
|
@@ -6,7 +6,7 @@ import { action } from '@storybook/addon-actions';
|
|
6
6
|
import { withDesign } from 'storybook-addon-designs';
|
7
7
|
import DocsLayout from '../../../.storybook/storybookDocsLayout';
|
8
8
|
import { Box, Breadcrumbs } from '../../index';
|
9
|
-
import { FIGMA_LINKS } from '../../utils/designUtils/figmaLinks
|
9
|
+
import { FIGMA_LINKS } from '../../utils/designUtils/figmaLinks';
|
10
10
|
import BreadcrumbsReadme from './Breadcrumbs.mdx';
|
11
11
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
12
12
|
export default {
|
@@ -41,9 +41,8 @@ export var Default = function Default(args) {
|
|
41
41
|
var onAction = function onAction(key) {
|
42
42
|
return action("onPress ".concat(key));
|
43
43
|
};
|
44
|
-
return ___EmotionJSX(Breadcrumbs, _extends({
|
45
|
-
onAction: onAction
|
46
|
-
}, args, {
|
44
|
+
return ___EmotionJSX(Breadcrumbs, _extends({}, args, {
|
45
|
+
onAction: onAction,
|
47
46
|
icon: ChevronRightIcon
|
48
47
|
}), ___EmotionJSX(Item, {
|
49
48
|
"aria-label": "home",
|
@@ -51,10 +51,11 @@ test('should render nodes from the children', function () {
|
|
51
51
|
test('should render correct amount of icons', function () {
|
52
52
|
getComponent({
|
53
53
|
iconProps: {
|
54
|
-
'data-testid': testIconId
|
54
|
+
'data-testid': testIconId,
|
55
|
+
icon: ChevronRightIcon
|
55
56
|
}
|
56
57
|
});
|
57
|
-
expect(screen.getAllByTestId(testIconId).length).toBe(testItemsArr.length -
|
58
|
+
expect(screen.getAllByTestId(testIconId).length).toBe(testItemsArr.length - 2);
|
58
59
|
});
|
59
60
|
test('breadcrumbItem should render breadcrumbItem as a Text component when appropriate elementType passed', function () {
|
60
61
|
getComponent({}, {
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
package/lib/types/index.js
CHANGED