@pingux/astro 2.16.0-alpha.0 → 2.16.0-alpha.2
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/Calendar/Calendar.js +37 -30
- 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/Calendar/Calendar.js +38 -31
- 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
@@ -64,51 +64,62 @@ var Calendar = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
64
64
|
prevButtonProps = _useCalendar.prevButtonProps,
|
65
65
|
nextButtonProps = _useCalendar.nextButtonProps,
|
66
66
|
title = _useCalendar.title;
|
67
|
-
|
68
|
-
/**
|
69
|
-
* Grabs the currently displayed date for yearly navigation.
|
70
|
-
*/
|
71
|
-
|
72
|
-
var _useState = (0, _react.useState)(),
|
67
|
+
var _useState = (0, _react.useState)(null),
|
73
68
|
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
74
|
-
|
75
|
-
|
76
|
-
var
|
77
|
-
|
78
|
-
}, [state.visibleRange.start]);
|
69
|
+
yearChangeDirection = _useState2[0],
|
70
|
+
setYearChangeDirection = _useState2[1];
|
71
|
+
var previousYearRef = (0, _react.useRef)(null);
|
72
|
+
var nextYearRef = (0, _react.useRef)(null);
|
79
73
|
var nav = {
|
80
74
|
NEXT: 'next',
|
81
75
|
PREVIOUS: 'previous'
|
82
76
|
};
|
83
77
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
78
|
+
// after updating visible year, reapplies focus to corresponding year buttons
|
79
|
+
(0, _react.useEffect)(function () {
|
80
|
+
if (yearChangeDirection === nav.NEXT) {
|
81
|
+
nextYearRef.current.focus();
|
82
|
+
}
|
83
|
+
if (yearChangeDirection === nav.PREVIOUS) {
|
84
|
+
previousYearRef.current.focus();
|
85
|
+
}
|
86
|
+
setYearChangeDirection(null);
|
87
|
+
}, [nav.NEXT, nav.PREVIOUS, yearChangeDirection]);
|
88
88
|
|
89
|
-
|
90
|
-
|
89
|
+
// update visible year
|
90
|
+
var handleYearSelection = function handleYearSelection(navigation) {
|
91
91
|
if (navigation === nav.PREVIOUS) {
|
92
|
-
|
92
|
+
var previousYear = state.focusedDate.subtract({
|
93
93
|
years: 1
|
94
94
|
});
|
95
|
-
|
96
|
-
|
95
|
+
state.setFocusedDate(previousYear);
|
96
|
+
}
|
97
|
+
if (navigation === nav.NEXT) {
|
98
|
+
var nextYear = state.focusedDate.add({
|
97
99
|
years: 1
|
98
100
|
});
|
101
|
+
state.setFocusedDate(nextYear);
|
99
102
|
}
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
+
setYearChangeDirection(navigation);
|
104
|
+
};
|
105
|
+
var renderTitle = (0, _react2.jsx)(_index.Text, {
|
106
|
+
variant: "itemTitle",
|
107
|
+
role: "heading",
|
108
|
+
"aria-level": "3",
|
109
|
+
fontWeight: 3
|
110
|
+
}, title);
|
103
111
|
return (0, _react2.jsx)(_index.Box, (0, _extends2["default"])({}, calendarProps, {
|
104
112
|
ref: calenderRef,
|
105
113
|
variant: "calendar.calendarContainer"
|
106
|
-
}), (0, _react2.jsx)(
|
114
|
+
}), (0, _react2.jsx)(_visuallyHidden.VisuallyHidden, {
|
115
|
+
"aria-live": "assertive"
|
116
|
+
}, (0, _react2.jsx)(_index.Text, null, title)), (0, _react2.jsx)(_index.Box, {
|
107
117
|
className: "header",
|
108
118
|
isRow: true,
|
109
119
|
variant: "calendar.calendarHeader",
|
110
120
|
verticalAlign: "middle"
|
111
121
|
}, (0, _react2.jsx)(_index.IconButton, {
|
122
|
+
ref: previousYearRef,
|
112
123
|
onPress: function onPress() {
|
113
124
|
return handleYearSelection(nav.PREVIOUS);
|
114
125
|
},
|
@@ -129,12 +140,7 @@ var Calendar = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
129
140
|
title: {
|
130
141
|
name: 'Chevron Left Icon'
|
131
142
|
}
|
132
|
-
})),
|
133
|
-
variant: "itemTitle",
|
134
|
-
role: "heading",
|
135
|
-
"aria-level": "3",
|
136
|
-
fontWeight: 3
|
137
|
-
}, title), (0, _react2.jsx)(_index.IconButton, (0, _extends2["default"])({}, nextButtonProps, {
|
143
|
+
})), renderTitle, (0, _react2.jsx)(_index.IconButton, (0, _extends2["default"])({}, nextButtonProps, {
|
138
144
|
"aria-label": "Next month navigation"
|
139
145
|
}), (0, _react2.jsx)(_index.Icon, {
|
140
146
|
icon: _ChevronRightIcon["default"],
|
@@ -143,6 +149,7 @@ var Calendar = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
143
149
|
name: 'Chevron Right Icon'
|
144
150
|
}
|
145
151
|
})), (0, _react2.jsx)(_index.IconButton, {
|
152
|
+
ref: nextYearRef,
|
146
153
|
onPress: function onPress() {
|
147
154
|
return handleYearSelection(nav.NEXT);
|
148
155
|
},
|
@@ -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
|
});
|
@@ -11,7 +11,7 @@ import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
|
11
11
|
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
12
12
|
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; }
|
13
13
|
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; }
|
14
|
-
import React, { forwardRef,
|
14
|
+
import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
15
15
|
import { createCalendar, parseDate } from '@internationalized/date';
|
16
16
|
import ChevronDoubleLeftIcon from '@pingux/mdi-react/ChevronDoubleLeftIcon';
|
17
17
|
import ChevronDoubleRightIcon from '@pingux/mdi-react/ChevronDoubleRightIcon';
|
@@ -53,51 +53,62 @@ var Calendar = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
53
53
|
prevButtonProps = _useCalendar.prevButtonProps,
|
54
54
|
nextButtonProps = _useCalendar.nextButtonProps,
|
55
55
|
title = _useCalendar.title;
|
56
|
-
|
57
|
-
/**
|
58
|
-
* Grabs the currently displayed date for yearly navigation.
|
59
|
-
*/
|
60
|
-
|
61
|
-
var _useState = useState(),
|
56
|
+
var _useState = useState(null),
|
62
57
|
_useState2 = _slicedToArray(_useState, 2),
|
63
|
-
|
64
|
-
|
65
|
-
var
|
66
|
-
|
67
|
-
}, [state.visibleRange.start]);
|
58
|
+
yearChangeDirection = _useState2[0],
|
59
|
+
setYearChangeDirection = _useState2[1];
|
60
|
+
var previousYearRef = useRef(null);
|
61
|
+
var nextYearRef = useRef(null);
|
68
62
|
var nav = {
|
69
63
|
NEXT: 'next',
|
70
64
|
PREVIOUS: 'previous'
|
71
65
|
};
|
72
66
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
67
|
+
// after updating visible year, reapplies focus to corresponding year buttons
|
68
|
+
useEffect(function () {
|
69
|
+
if (yearChangeDirection === nav.NEXT) {
|
70
|
+
nextYearRef.current.focus();
|
71
|
+
}
|
72
|
+
if (yearChangeDirection === nav.PREVIOUS) {
|
73
|
+
previousYearRef.current.focus();
|
74
|
+
}
|
75
|
+
setYearChangeDirection(null);
|
76
|
+
}, [nav.NEXT, nav.PREVIOUS, yearChangeDirection]);
|
77
77
|
|
78
|
-
|
79
|
-
|
78
|
+
// update visible year
|
79
|
+
var handleYearSelection = function handleYearSelection(navigation) {
|
80
80
|
if (navigation === nav.PREVIOUS) {
|
81
|
-
|
81
|
+
var previousYear = state.focusedDate.subtract({
|
82
82
|
years: 1
|
83
83
|
});
|
84
|
-
|
85
|
-
|
84
|
+
state.setFocusedDate(previousYear);
|
85
|
+
}
|
86
|
+
if (navigation === nav.NEXT) {
|
87
|
+
var nextYear = state.focusedDate.add({
|
86
88
|
years: 1
|
87
89
|
});
|
90
|
+
state.setFocusedDate(nextYear);
|
88
91
|
}
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
+
setYearChangeDirection(navigation);
|
93
|
+
};
|
94
|
+
var renderTitle = ___EmotionJSX(Text, {
|
95
|
+
variant: "itemTitle",
|
96
|
+
role: "heading",
|
97
|
+
"aria-level": "3",
|
98
|
+
fontWeight: 3
|
99
|
+
}, title);
|
92
100
|
return ___EmotionJSX(Box, _extends({}, calendarProps, {
|
93
101
|
ref: calenderRef,
|
94
102
|
variant: "calendar.calendarContainer"
|
95
|
-
}), ___EmotionJSX(
|
103
|
+
}), ___EmotionJSX(VisuallyHidden, {
|
104
|
+
"aria-live": "assertive"
|
105
|
+
}, ___EmotionJSX(Text, null, title)), ___EmotionJSX(Box, {
|
96
106
|
className: "header",
|
97
107
|
isRow: true,
|
98
108
|
variant: "calendar.calendarHeader",
|
99
109
|
verticalAlign: "middle"
|
100
110
|
}, ___EmotionJSX(IconButton, {
|
111
|
+
ref: previousYearRef,
|
101
112
|
onPress: function onPress() {
|
102
113
|
return handleYearSelection(nav.PREVIOUS);
|
103
114
|
},
|
@@ -118,12 +129,7 @@ var Calendar = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
118
129
|
title: {
|
119
130
|
name: 'Chevron Left Icon'
|
120
131
|
}
|
121
|
-
})),
|
122
|
-
variant: "itemTitle",
|
123
|
-
role: "heading",
|
124
|
-
"aria-level": "3",
|
125
|
-
fontWeight: 3
|
126
|
-
}, title), ___EmotionJSX(IconButton, _extends({}, nextButtonProps, {
|
132
|
+
})), renderTitle, ___EmotionJSX(IconButton, _extends({}, nextButtonProps, {
|
127
133
|
"aria-label": "Next month navigation"
|
128
134
|
}), ___EmotionJSX(Icon, {
|
129
135
|
icon: ChevronRightIcon,
|
@@ -132,6 +138,7 @@ var Calendar = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
132
138
|
name: 'Chevron Right Icon'
|
133
139
|
}
|
134
140
|
})), ___EmotionJSX(IconButton, {
|
141
|
+
ref: nextYearRef,
|
135
142
|
onPress: function onPress() {
|
136
143
|
return handleYearSelection(nav.NEXT);
|
137
144
|
},
|
@@ -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
|
});
|