@pingux/astro 2.16.0-alpha.0 → 2.16.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/HelpHint/HelpHint.js +18 -3
- package/lib/cjs/components/HelpHint/HelpHint.stories.js +3 -9
- package/lib/cjs/components/Link/Link.js +14 -2
- package/lib/cjs/components/Link/Link.stories.js +5 -0
- package/lib/cjs/components/Link/Link.test.js +16 -0
- package/lib/components/HelpHint/HelpHint.js +18 -3
- package/lib/components/HelpHint/HelpHint.stories.js +3 -9
- package/lib/components/Link/Link.js +14 -2
- package/lib/components/Link/Link.stories.js +5 -0
- package/lib/components/Link/Link.test.js +16 -0
- package/package.json +1 -1
@@ -11,6 +11,7 @@ _Object$defineProperty(exports, "__esModule", {
|
|
11
11
|
exports["default"] = void 0;
|
12
12
|
var _setTimeout2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set-timeout"));
|
13
13
|
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
14
|
+
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
14
15
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
15
16
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
|
16
17
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
|
@@ -21,6 +22,7 @@ var _interactions = require("@react-aria/interactions");
|
|
21
22
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
22
23
|
var _ = require("../..");
|
23
24
|
var _hooks = require("../../hooks");
|
25
|
+
var _safariAgent = require("../../styles/safariAgent");
|
24
26
|
var _react2 = require("@emotion/react");
|
25
27
|
var _excluded = ["align", "arrowCrossOffset", "children", "className", "closeDelay", "direction", "hasNoArrow", "iconButtonProps", "isDarkMode", "isNotFlippable", "offset", "popoverProps"];
|
26
28
|
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
@@ -126,6 +128,19 @@ var HelpHint = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
126
128
|
isDarkMode: isDarkMode
|
127
129
|
}),
|
128
130
|
classNames = _useStatusClasses.classNames;
|
131
|
+
var addIsSafariCompatiblePropToLinkChildren = function addIsSafariCompatiblePropToLinkChildren(containerChildren) {
|
132
|
+
if (containerChildren) {
|
133
|
+
var _context2;
|
134
|
+
return (0, _map["default"])(_context2 = _react["default"].Children).call(_context2, containerChildren, function (child) {
|
135
|
+
if (! /*#__PURE__*/_react["default"].isValidElement(child)) return child;
|
136
|
+
return /*#__PURE__*/_react["default"].cloneElement(child, {
|
137
|
+
children: addIsSafariCompatiblePropToLinkChildren(child.props.children),
|
138
|
+
isSafariCompatible: child.type.displayName === 'Link'
|
139
|
+
});
|
140
|
+
});
|
141
|
+
}
|
142
|
+
return undefined;
|
143
|
+
};
|
129
144
|
return (0, _react2.jsx)(_.Box, (0, _extends2["default"])({}, others, {
|
130
145
|
ref: ref
|
131
146
|
}), (0, _react2.jsx)(_.IconButton, (0, _extends2["default"])({
|
@@ -144,18 +159,18 @@ var HelpHint = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
144
159
|
className: classNames,
|
145
160
|
direction: direction,
|
146
161
|
hasNoArrow: hasNoArrow,
|
147
|
-
isDismissable: !isOpen,
|
162
|
+
isDismissable: isFocusWithinOverlay ? !isOpen : true,
|
148
163
|
isNonModal: true,
|
149
164
|
isOpen: isOpen,
|
150
165
|
onClose: close,
|
151
166
|
placement: placement,
|
152
167
|
ref: overlayRef
|
153
|
-
}, (0, _reactAria.mergeProps)(overlayProps, positionProps, popoverProps, overlayHoverProps
|
168
|
+
}, (0, _reactAria.mergeProps)(overlayProps, positionProps, popoverProps, overlayHoverProps, focusWithinProps)), (0, _react2.jsx)(_reactAria.FocusScope, {
|
154
169
|
restoreFocus: true,
|
155
170
|
autoFocus: isFocusVisible
|
156
171
|
}, (0, _react2.jsx)(_.Box, {
|
157
172
|
variant: "helpHint.popoverContainer"
|
158
|
-
}, children))));
|
173
|
+
}, _safariAgent.isSafari ? addIsSafariCompatiblePropToLinkChildren(children) : children))));
|
159
174
|
});
|
160
175
|
HelpHint.propTypes = {
|
161
176
|
/** Props object that is spread directly into the popover element. */
|
@@ -11,7 +11,6 @@ var _react = _interopRequireDefault(require("react"));
|
|
11
11
|
var _storybookAddonDesigns = require("storybook-addon-designs");
|
12
12
|
var _storybookDocsLayout = _interopRequireDefault(require("../../../.storybook/storybookDocsLayout"));
|
13
13
|
var _index = require("../../index");
|
14
|
-
var _safariAgent = require("../../styles/safariAgent");
|
15
14
|
var _figmaLinks = require("../../utils/designUtils/figmaLinks.js");
|
16
15
|
var _HelpHint = _interopRequireDefault(require("./HelpHint.mdx"));
|
17
16
|
var _react2 = require("@emotion/react");
|
@@ -69,15 +68,10 @@ var ContentWithLink = function ContentWithLink() {
|
|
69
68
|
p: 70
|
70
69
|
}, (0, _react2.jsx)(_index.HelpHint, null, (0, _react2.jsx)(_index.Text, {
|
71
70
|
variant: "popover"
|
72
|
-
}, "Text of the popover right here... "),
|
73
|
-
href: "https://uilibrary.ping-eng.com/",
|
74
|
-
as: "a",
|
75
|
-
pl: "xs"
|
76
|
-
}, (0, _react2.jsx)(_index.Link, {
|
77
|
-
variant: "popover"
|
78
|
-
}, "Learn More")) : (0, _react2.jsx)(_index.Link, {
|
71
|
+
}, "Text of the popover right here... "), (0, _react2.jsx)(_index.Link, {
|
79
72
|
variant: "popover",
|
80
|
-
href: "https://uilibrary.ping-eng.com/"
|
73
|
+
href: "https://uilibrary.ping-eng.com/",
|
74
|
+
target: "_blank"
|
81
75
|
}, "Learn More")));
|
82
76
|
};
|
83
77
|
exports.ContentWithLink = ContentWithLink;
|
@@ -18,13 +18,14 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
18
18
|
var _themeUi = require("theme-ui");
|
19
19
|
var _hooks = require("../../hooks");
|
20
20
|
var _react2 = require("@emotion/react");
|
21
|
-
var _excluded = ["className", "isDisabled", "onPress"];
|
21
|
+
var _excluded = ["className", "isDisabled", "onPress", "isSafariCompatible"];
|
22
22
|
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
23
23
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
24
24
|
var Link = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
25
25
|
var className = props.className,
|
26
26
|
isDisabled = props.isDisabled,
|
27
27
|
onPress = props.onPress,
|
28
|
+
isSafariCompatible = props.isSafariCompatible,
|
28
29
|
others = (0, _objectWithoutProperties2["default"])(props, _excluded);
|
29
30
|
var linkRef = (0, _react.useRef)();
|
30
31
|
(0, _hooks.usePropWarning)(props, 'disabled', 'isDisabled');
|
@@ -52,6 +53,15 @@ var Link = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
52
53
|
isPressed: isPressed
|
53
54
|
}),
|
54
55
|
classNames = _useStatusClasses.classNames;
|
56
|
+
|
57
|
+
// This relates to UIP-6502. Due to browser inconsistencies
|
58
|
+
// react aria prevent default on pointer down
|
59
|
+
if (isSafariCompatible) {
|
60
|
+
delete linkProps.onPointerUp;
|
61
|
+
delete linkProps.onPointerDown;
|
62
|
+
delete pressProps.onPointerUp;
|
63
|
+
delete pressProps.onPointerDown;
|
64
|
+
}
|
55
65
|
return (0, _react2.jsx)(_themeUi.Link, (0, _extends2["default"])({
|
56
66
|
className: classNames,
|
57
67
|
ref: linkRef,
|
@@ -70,7 +80,9 @@ Link.propTypes = {
|
|
70
80
|
/** Specifies the window where the linked page is loaded */
|
71
81
|
target: _propTypes["default"].string,
|
72
82
|
/** The styling variation of the link. */
|
73
|
-
variant: _propTypes["default"].string
|
83
|
+
variant: _propTypes["default"].string,
|
84
|
+
/** Whether the link is clickable inside a popover in safari */
|
85
|
+
isSafariCompatible: _propTypes["default"].bool
|
74
86
|
};
|
75
87
|
Link.defaultProps = {
|
76
88
|
isDisabled: false,
|
@@ -57,4 +57,20 @@ test('link shows disabled status', function () {
|
|
57
57
|
});
|
58
58
|
var link = _testWrapper.screen.getByTestId(testId);
|
59
59
|
expect(link).toHaveClass('is-disabled');
|
60
|
+
});
|
61
|
+
test('link removes onPointer events when isSafariCompatible', function () {
|
62
|
+
var onPointerEvents = jest.fn();
|
63
|
+
getComponent({
|
64
|
+
href: 'blah',
|
65
|
+
isSafariCompatible: true,
|
66
|
+
onPointerDown: function onPointerDown() {
|
67
|
+
return onPointerEvents;
|
68
|
+
},
|
69
|
+
onPointerUp: function onPointerUp() {
|
70
|
+
return onPointerEvents;
|
71
|
+
}
|
72
|
+
});
|
73
|
+
var link = _testWrapper.screen.getByTestId(testId);
|
74
|
+
_userEvent["default"].click(link);
|
75
|
+
expect(onPointerEvents).not.toHaveBeenCalled();
|
60
76
|
});
|
@@ -4,6 +4,7 @@ import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectW
|
|
4
4
|
var _excluded = ["align", "arrowCrossOffset", "children", "className", "closeDelay", "direction", "hasNoArrow", "iconButtonProps", "isDarkMode", "isNotFlippable", "offset", "popoverProps"];
|
5
5
|
import _setTimeout from "@babel/runtime-corejs3/core-js-stable/set-timeout";
|
6
6
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
7
|
+
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
7
8
|
import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
8
9
|
import { FocusScope, mergeProps, useFocusRing, useFocusWithin, useOverlayPosition, useOverlayTrigger } from 'react-aria';
|
9
10
|
import { useOverlayTriggerState } from 'react-stately';
|
@@ -11,6 +12,7 @@ import { useHover } from '@react-aria/interactions';
|
|
11
12
|
import PropTypes from 'prop-types';
|
12
13
|
import { Box, Icon, IconButton, PopoverContainer } from '../..';
|
13
14
|
import { useStatusClasses } from '../../hooks';
|
15
|
+
import { isSafari } from '../../styles/safariAgent';
|
14
16
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
15
17
|
var HelpIcon = function HelpIcon() {
|
16
18
|
return ___EmotionJSX("svg", {
|
@@ -113,6 +115,19 @@ var HelpHint = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
113
115
|
isDarkMode: isDarkMode
|
114
116
|
}),
|
115
117
|
classNames = _useStatusClasses.classNames;
|
118
|
+
var addIsSafariCompatiblePropToLinkChildren = function addIsSafariCompatiblePropToLinkChildren(containerChildren) {
|
119
|
+
if (containerChildren) {
|
120
|
+
var _context2;
|
121
|
+
return _mapInstanceProperty(_context2 = React.Children).call(_context2, containerChildren, function (child) {
|
122
|
+
if (! /*#__PURE__*/React.isValidElement(child)) return child;
|
123
|
+
return /*#__PURE__*/React.cloneElement(child, {
|
124
|
+
children: addIsSafariCompatiblePropToLinkChildren(child.props.children),
|
125
|
+
isSafariCompatible: child.type.displayName === 'Link'
|
126
|
+
});
|
127
|
+
});
|
128
|
+
}
|
129
|
+
return undefined;
|
130
|
+
};
|
116
131
|
return ___EmotionJSX(Box, _extends({}, others, {
|
117
132
|
ref: ref
|
118
133
|
}), ___EmotionJSX(IconButton, _extends({
|
@@ -131,18 +146,18 @@ var HelpHint = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
131
146
|
className: classNames,
|
132
147
|
direction: direction,
|
133
148
|
hasNoArrow: hasNoArrow,
|
134
|
-
isDismissable: !isOpen,
|
149
|
+
isDismissable: isFocusWithinOverlay ? !isOpen : true,
|
135
150
|
isNonModal: true,
|
136
151
|
isOpen: isOpen,
|
137
152
|
onClose: close,
|
138
153
|
placement: placement,
|
139
154
|
ref: overlayRef
|
140
|
-
}, mergeProps(overlayProps, positionProps, popoverProps, overlayHoverProps
|
155
|
+
}, mergeProps(overlayProps, positionProps, popoverProps, overlayHoverProps, focusWithinProps)), ___EmotionJSX(FocusScope, {
|
141
156
|
restoreFocus: true,
|
142
157
|
autoFocus: isFocusVisible
|
143
158
|
}, ___EmotionJSX(Box, {
|
144
159
|
variant: "helpHint.popoverContainer"
|
145
|
-
}, children))));
|
160
|
+
}, isSafari ? addIsSafariCompatiblePropToLinkChildren(children) : children))));
|
146
161
|
});
|
147
162
|
HelpHint.propTypes = {
|
148
163
|
/** Props object that is spread directly into the popover element. */
|
@@ -3,7 +3,6 @@ import React from 'react';
|
|
3
3
|
import { withDesign } from 'storybook-addon-designs';
|
4
4
|
import DocsLayout from '../../../.storybook/storybookDocsLayout';
|
5
5
|
import { Box, HelpHint, Link, Text } from '../../index';
|
6
|
-
import { isSafari } from '../../styles/safariAgent';
|
7
6
|
import { FIGMA_LINKS } from '../../utils/designUtils/figmaLinks.js';
|
8
7
|
import HelpHintReadme from './HelpHint.mdx';
|
9
8
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
@@ -58,15 +57,10 @@ export var ContentWithLink = function ContentWithLink() {
|
|
58
57
|
p: 70
|
59
58
|
}, ___EmotionJSX(HelpHint, null, ___EmotionJSX(Text, {
|
60
59
|
variant: "popover"
|
61
|
-
}, "Text of the popover right here... "),
|
62
|
-
href: "https://uilibrary.ping-eng.com/",
|
63
|
-
as: "a",
|
64
|
-
pl: "xs"
|
65
|
-
}, ___EmotionJSX(Link, {
|
66
|
-
variant: "popover"
|
67
|
-
}, "Learn More")) : ___EmotionJSX(Link, {
|
60
|
+
}, "Text of the popover right here... "), ___EmotionJSX(Link, {
|
68
61
|
variant: "popover",
|
69
|
-
href: "https://uilibrary.ping-eng.com/"
|
62
|
+
href: "https://uilibrary.ping-eng.com/",
|
63
|
+
target: "_blank"
|
70
64
|
}, "Learn More")));
|
71
65
|
};
|
72
66
|
ContentWithLink.parameters = {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
2
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
3
|
-
var _excluded = ["className", "isDisabled", "onPress"];
|
3
|
+
var _excluded = ["className", "isDisabled", "onPress", "isSafariCompatible"];
|
4
4
|
import React, { forwardRef, useImperativeHandle, useRef } from 'react';
|
5
5
|
import { mergeProps, useFocusRing, useLink } from 'react-aria';
|
6
6
|
import { useHover, usePress } from '@react-aria/interactions';
|
@@ -12,6 +12,7 @@ var Link = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
12
12
|
var className = props.className,
|
13
13
|
isDisabled = props.isDisabled,
|
14
14
|
onPress = props.onPress,
|
15
|
+
isSafariCompatible = props.isSafariCompatible,
|
15
16
|
others = _objectWithoutProperties(props, _excluded);
|
16
17
|
var linkRef = useRef();
|
17
18
|
usePropWarning(props, 'disabled', 'isDisabled');
|
@@ -39,6 +40,15 @@ var Link = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
39
40
|
isPressed: isPressed
|
40
41
|
}),
|
41
42
|
classNames = _useStatusClasses.classNames;
|
43
|
+
|
44
|
+
// This relates to UIP-6502. Due to browser inconsistencies
|
45
|
+
// react aria prevent default on pointer down
|
46
|
+
if (isSafariCompatible) {
|
47
|
+
delete linkProps.onPointerUp;
|
48
|
+
delete linkProps.onPointerDown;
|
49
|
+
delete pressProps.onPointerUp;
|
50
|
+
delete pressProps.onPointerDown;
|
51
|
+
}
|
42
52
|
return ___EmotionJSX(ThemeUILink, _extends({
|
43
53
|
className: classNames,
|
44
54
|
ref: linkRef,
|
@@ -57,7 +67,9 @@ Link.propTypes = {
|
|
57
67
|
/** Specifies the window where the linked page is loaded */
|
58
68
|
target: PropTypes.string,
|
59
69
|
/** The styling variation of the link. */
|
60
|
-
variant: PropTypes.string
|
70
|
+
variant: PropTypes.string,
|
71
|
+
/** Whether the link is clickable inside a popover in safari */
|
72
|
+
isSafariCompatible: PropTypes.bool
|
61
73
|
};
|
62
74
|
Link.defaultProps = {
|
63
75
|
isDisabled: false,
|
@@ -54,4 +54,20 @@ test('link shows disabled status', function () {
|
|
54
54
|
});
|
55
55
|
var link = screen.getByTestId(testId);
|
56
56
|
expect(link).toHaveClass('is-disabled');
|
57
|
+
});
|
58
|
+
test('link removes onPointer events when isSafariCompatible', function () {
|
59
|
+
var onPointerEvents = jest.fn();
|
60
|
+
getComponent({
|
61
|
+
href: 'blah',
|
62
|
+
isSafariCompatible: true,
|
63
|
+
onPointerDown: function onPointerDown() {
|
64
|
+
return onPointerEvents;
|
65
|
+
},
|
66
|
+
onPointerUp: function onPointerUp() {
|
67
|
+
return onPointerEvents;
|
68
|
+
}
|
69
|
+
});
|
70
|
+
var link = screen.getByTestId(testId);
|
71
|
+
userEvent.click(link);
|
72
|
+
expect(onPointerEvents).not.toHaveBeenCalled();
|
57
73
|
});
|