@pingux/astro 2.49.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.
Files changed (27) hide show
  1. package/lib/cjs/components/Breadcrumbs/Breadcrumb.styles.d.ts +61 -0
  2. package/lib/cjs/components/Breadcrumbs/BreadcrumbItem.d.ts +11 -0
  3. package/lib/cjs/components/Breadcrumbs/BreadcrumbItem.js +4 -22
  4. package/lib/cjs/components/Breadcrumbs/Breadcrumbs.d.ts +4 -0
  5. package/lib/cjs/components/Breadcrumbs/Breadcrumbs.js +7 -23
  6. package/lib/cjs/components/Breadcrumbs/Breadcrumbs.stories.d.ts +6 -0
  7. package/lib/cjs/components/Breadcrumbs/Breadcrumbs.stories.js +3 -4
  8. package/lib/cjs/components/Breadcrumbs/Breadcrumbs.test.d.ts +1 -0
  9. package/lib/cjs/components/Breadcrumbs/Breadcrumbs.test.js +3 -2
  10. package/lib/cjs/components/Breadcrumbs/index.d.ts +2 -0
  11. package/lib/cjs/components/Button/Button.stories.js +11 -0
  12. package/lib/cjs/components/Button/Buttons.styles.d.ts +256 -212
  13. package/lib/cjs/components/Button/Buttons.styles.js +10 -6
  14. package/lib/cjs/types/breadCrumbs.d.ts +31 -0
  15. package/lib/cjs/types/breadCrumbs.js +6 -0
  16. package/lib/cjs/types/index.d.ts +1 -0
  17. package/lib/cjs/types/index.js +38 -27
  18. package/lib/cjs/types/item.d.ts +2 -0
  19. package/lib/components/Breadcrumbs/BreadcrumbItem.js +6 -24
  20. package/lib/components/Breadcrumbs/Breadcrumbs.js +9 -25
  21. package/lib/components/Breadcrumbs/Breadcrumbs.stories.js +3 -4
  22. package/lib/components/Breadcrumbs/Breadcrumbs.test.js +3 -2
  23. package/lib/components/Button/Button.stories.js +11 -0
  24. package/lib/components/Button/Buttons.styles.js +10 -6
  25. package/lib/types/breadCrumbs.js +1 -0
  26. package/lib/types/index.js +1 -0
  27. 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, _react.useRef)();
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 ElementType = (0, _react.useMemo)(function () {
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 && 'is-current',
89
+ className: isCurrent ? 'is-current' : '',
95
90
  variant: "variants.breadcrumb.containerLi"
96
- }, (0, _react2.jsx)(ElementType, elementVariantProps, children));
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
  };
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { breadCrumbsProps } from '../../types';
3
+ declare const Breadcrumbs: React.ForwardRefExoticComponent<breadCrumbsProps & React.RefAttributes<HTMLElement>>;
4
+ export default Breadcrumbs;
@@ -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, _react.useRef)();
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
- }, [children.length, filteredChildren, icon, iconProps, onAction]);
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.ts");
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",
@@ -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 - 1);
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,2 @@
1
+ export { default as BreadcrumbItem } from './BreadcrumbItem';
2
+ export { default } from './Breadcrumbs';
@@ -116,6 +116,17 @@ var TextIconButton = function TextIconButton() {
116
116
  title: {
117
117
  name: 'Add Circle Icon'
118
118
  }
119
+ }), "Button Text"), (0, _react2.jsx)(_index.Button, {
120
+ mb: "sm",
121
+ variant: "primaryWithIcon"
122
+ }, (0, _react2.jsx)(_index.Icon, {
123
+ icon: _PlusIcon["default"],
124
+ mr: "xs",
125
+ color: "white",
126
+ size: 20,
127
+ title: {
128
+ name: 'Add Circle Icon'
129
+ }
119
130
  }), "Button Text"), (0, _react2.jsx)(_index.Button, {
120
131
  mb: "sm",
121
132
  mr: "auto",