@pingux/astro 2.13.0-alpha.3 → 2.13.0-alpha.5

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.
@@ -1,19 +1,37 @@
1
+ import _Symbol from "@babel/runtime-corejs3/core-js-stable/symbol";
2
+ import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
3
+ import _Object$create from "@babel/runtime-corejs3/core-js-stable/object/create";
4
+ import _Object$getPrototypeOf from "@babel/runtime-corejs3/core-js-stable/object/get-prototype-of";
5
+ import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
6
+ import _Object$setPrototypeOf from "@babel/runtime-corejs3/core-js-stable/object/set-prototype-of";
7
+ import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
8
+ import _reverseInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/reverse";
9
+ import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
10
+ import _typeof from "@babel/runtime-corejs3/helpers/esm/typeof";
11
+ import _asyncToGenerator from "@babel/runtime-corejs3/helpers/esm/asyncToGenerator";
1
12
  import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
13
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof _Symbol ? _Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return _Object$defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = _Object$create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = _Object$getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = _Object$create(IteratorPrototype); function defineIteratorMethods(prototype) { var _context8; _forEachInstanceProperty(_context8 = ["next", "throw", "return"]).call(_context8, function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], _forEachInstanceProperty(tryLocsList).call(tryLocsList, pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return _Object$setPrototypeOf ? _Object$setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = _Object$create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = _Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return _reverseInstanceProperty(keys).call(keys), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { var _context9; if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, _forEachInstanceProperty(_context9 = this.tryEntries).call(_context9, resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+_sliceInstanceProperty(name).call(name, 1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
2
14
  import React from 'react';
3
15
  import userEvent from '@testing-library/user-event';
16
+ import { HelpHint, Link } from '../../index';
4
17
  import axeTest from '../../utils/testUtils/testAxe';
5
- import { fireEvent, render, screen } from '../../utils/testUtils/testWrapper';
6
- import HelpHint from './HelpHint';
18
+ import { fireEvent, render, screen, waitFor } from '../../utils/testUtils/testWrapper';
7
19
  import { jsx as ___EmotionJSX } from "@emotion/react";
8
20
  var testId = 'help-hint__button';
9
- var tooltipValue = 'Some text';
21
+ var popoverValue = 'Some text';
10
22
  var defaultProps = {
11
- children: tooltipValue
23
+ children: popoverValue
12
24
  };
13
25
  var getComponent = function getComponent() {
14
26
  var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
15
27
  return render(___EmotionJSX(HelpHint, _extends({}, defaultProps, props)));
16
28
  };
29
+ var getComponentWithLink = function getComponentWithLink() {
30
+ var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
31
+ return render(___EmotionJSX(HelpHint, _extends({}, defaultProps, props), ___EmotionJSX(Link, {
32
+ href: "https://uilibrary.ping-eng.com/"
33
+ }, "Learn More")));
34
+ };
17
35
 
18
36
  // Need to be added to each test file to test accessibility using axe.
19
37
  axeTest(getComponent);
@@ -22,35 +40,124 @@ test('renders HelpHint component', function () {
22
40
  var helpHintButton = screen.getByTestId(testId);
23
41
  expect(helpHintButton).toBeInTheDocument();
24
42
  });
25
- test('shows tooltip on hover', function () {
26
- getComponent();
27
- var helpHintButton = screen.getByTestId(testId);
28
- expect(screen.queryByText(tooltipValue)).not.toBeInTheDocument();
29
- fireEvent.mouseMove(helpHintButton);
30
- fireEvent.mouseEnter(helpHintButton);
31
- var tooltip = screen.getByRole('tooltip');
32
- var tooltipId = tooltip.getAttribute('id');
33
- expect(tooltip).toBeInTheDocument();
34
- expect(helpHintButton).toHaveAttribute('aria-describedby', tooltipId);
35
- });
36
- test('shows tooltip on focus', function () {
37
- getComponent();
38
- var helpHintButton = screen.getByTestId(testId);
39
- expect(screen.queryByText(tooltipValue)).not.toBeInTheDocument();
40
- userEvent.tab();
41
- expect(helpHintButton).toHaveFocus();
42
- var tooltip = screen.getByRole('tooltip');
43
- var tooltipId = tooltip.getAttribute('id');
44
- expect(tooltip).toBeInTheDocument();
45
- expect(helpHintButton).toHaveAttribute('aria-describedby', tooltipId);
46
- });
47
- test('applies tooltipProps', function () {
43
+ test('shows popover when trigger is hovered', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
44
+ var helpHintButton, popover;
45
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
46
+ while (1) {
47
+ switch (_context.prev = _context.next) {
48
+ case 0:
49
+ getComponent();
50
+ helpHintButton = screen.getByTestId(testId);
51
+ expect(screen.queryByText(popoverValue)).not.toBeInTheDocument();
52
+ fireEvent.mouseMove(helpHintButton);
53
+ fireEvent.mouseEnter(helpHintButton);
54
+ popover = screen.getByRole('presentation');
55
+ expect(popover).toBeInTheDocument();
56
+ case 7:
57
+ case "end":
58
+ return _context.stop();
59
+ }
60
+ }
61
+ }, _callee);
62
+ })));
63
+ test('keeps the popover open if the popover is hovered', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
64
+ var helpHintButton, popover;
65
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
66
+ while (1) {
67
+ switch (_context2.prev = _context2.next) {
68
+ case 0:
69
+ getComponent();
70
+ helpHintButton = screen.getByTestId(testId);
71
+ expect(screen.queryByText(popoverValue)).not.toBeInTheDocument();
72
+ fireEvent.mouseMove(helpHintButton);
73
+ fireEvent.mouseEnter(helpHintButton);
74
+ popover = screen.getByRole('presentation');
75
+ fireEvent.mouseMove(popover);
76
+ fireEvent.mouseEnter(popover);
77
+ expect(popover).toBeInTheDocument();
78
+ _context2.next = 11;
79
+ return waitFor(function () {
80
+ expect(screen.queryByRole('presentation')).toBeInTheDocument();
81
+ }, {
82
+ timeout: 2000
83
+ });
84
+ case 11:
85
+ case "end":
86
+ return _context2.stop();
87
+ }
88
+ }
89
+ }, _callee2);
90
+ })));
91
+ test('popover without focusable children should open onPress and disappear in 1000ms', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
92
+ var helpHintButton;
93
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
94
+ while (1) {
95
+ switch (_context3.prev = _context3.next) {
96
+ case 0:
97
+ getComponent();
98
+ helpHintButton = screen.getByTestId(testId);
99
+ userEvent.tab();
100
+ expect(helpHintButton).toHaveFocus();
101
+ userEvent.type(helpHintButton, '{enter}', {
102
+ skipClick: true
103
+ });
104
+ _context3.next = 7;
105
+ return waitFor(function () {
106
+ expect(screen.queryByRole('presentation')).toBeInTheDocument();
107
+ }, {
108
+ timeout: 500
109
+ });
110
+ case 7:
111
+ _context3.next = 9;
112
+ return waitFor(function () {
113
+ expect(screen.queryByRole('presentation')).not.toBeInTheDocument();
114
+ }, {
115
+ timeout: 1100
116
+ });
117
+ case 9:
118
+ case "end":
119
+ return _context3.stop();
120
+ }
121
+ }
122
+ }, _callee3);
123
+ })));
124
+ test('popover with focusable children should open onPress and focus the first focusable child', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
125
+ var helpHintButton, link;
126
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
127
+ while (1) {
128
+ switch (_context4.prev = _context4.next) {
129
+ case 0:
130
+ getComponentWithLink();
131
+ helpHintButton = screen.getByTestId(testId);
132
+ userEvent.tab();
133
+ expect(helpHintButton).toHaveFocus();
134
+ userEvent.type(helpHintButton, '{enter}', {
135
+ skipClick: true
136
+ });
137
+ _context4.next = 7;
138
+ return waitFor(function () {
139
+ expect(screen.queryByRole('presentation')).toBeInTheDocument();
140
+ }, {
141
+ timeout: 3000
142
+ });
143
+ case 7:
144
+ link = screen.queryByRole('link');
145
+ expect(link).toBeInTheDocument();
146
+ expect(link).toHaveFocus();
147
+ case 10:
148
+ case "end":
149
+ return _context4.stop();
150
+ }
151
+ }
152
+ }, _callee4);
153
+ })));
154
+ test('applies popoverProps', function () {
48
155
  getComponent({
49
- tooltipProps: {
156
+ popoverProps: {
50
157
  isOpen: true
51
158
  }
52
159
  });
53
- expect(screen.getByText(tooltipValue)).toBeInTheDocument();
160
+ expect(screen.getByText(popoverValue)).toBeInTheDocument();
54
161
  });
55
162
  test('applies iconButtonProps', function () {
56
163
  var newLabel = 'New label';
@@ -60,4 +167,80 @@ test('applies iconButtonProps', function () {
60
167
  }
61
168
  });
62
169
  expect(screen.getByLabelText(newLabel)).toBeInTheDocument();
63
- });
170
+ });
171
+ test('popover stays open until closeDelay after mouse leaves trigger', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
172
+ var closeDelay, helpHintButton;
173
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
174
+ while (1) {
175
+ switch (_context5.prev = _context5.next) {
176
+ case 0:
177
+ closeDelay = 10;
178
+ getComponent({
179
+ closeDelay: closeDelay
180
+ });
181
+ helpHintButton = screen.getByTestId(testId);
182
+ fireEvent.mouseEnter(helpHintButton);
183
+ fireEvent.mouseLeave(helpHintButton);
184
+ _context5.next = 7;
185
+ return waitFor(function () {
186
+ expect(screen.queryByRole('presentation')).toBeInTheDocument();
187
+ }, {
188
+ timeout: closeDelay - 1
189
+ });
190
+ case 7:
191
+ case "end":
192
+ return _context5.stop();
193
+ }
194
+ }
195
+ }, _callee5);
196
+ })));
197
+ test('popover closes after closeDelay when mouse leaves trigger', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
198
+ var closeDelay, helpHintButton;
199
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
200
+ while (1) {
201
+ switch (_context6.prev = _context6.next) {
202
+ case 0:
203
+ closeDelay = 10;
204
+ getComponent({
205
+ closeDelay: closeDelay
206
+ });
207
+ helpHintButton = screen.getByTestId(testId);
208
+ fireEvent.mouseEnter(helpHintButton);
209
+ fireEvent.mouseLeave(helpHintButton);
210
+ _context6.next = 7;
211
+ return waitFor(function () {
212
+ expect(screen.queryByRole('presentation')).not.toBeInTheDocument();
213
+ }, {
214
+ timeout: closeDelay + 1
215
+ });
216
+ case 7:
217
+ case "end":
218
+ return _context6.stop();
219
+ }
220
+ }
221
+ }, _callee6);
222
+ })));
223
+ test('popover automatically closes in 1000ms after mouse leaves trigger', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
224
+ var oneSecond, helpHintButton;
225
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
226
+ while (1) {
227
+ switch (_context7.prev = _context7.next) {
228
+ case 0:
229
+ oneSecond = 1000;
230
+ getComponent();
231
+ helpHintButton = screen.getByTestId(testId);
232
+ fireEvent.mouseEnter(helpHintButton);
233
+ fireEvent.mouseLeave(helpHintButton);
234
+ _context7.next = 7;
235
+ return waitFor(function () {
236
+ expect(screen.queryByRole('presentation')).not.toBeInTheDocument();
237
+ }, {
238
+ timeout: oneSecond + 1
239
+ });
240
+ case 7:
241
+ case "end":
242
+ return _context7.stop();
243
+ }
244
+ }
245
+ }, _callee7);
246
+ })));
@@ -35,7 +35,17 @@ var web = _objectSpread(_objectSpread({}, app), {}, {
35
35
  },
36
36
  '&.is-focused': _objectSpread({}, focusWithCroppedOutline)
37
37
  });
38
+ var popover = _objectSpread(_objectSpread({}, app), {}, {
39
+ color: 'white',
40
+ fontSize: 'sm',
41
+ fontWeight: 1,
42
+ textDecoration: 'underline',
43
+ '&.is-hovered': {
44
+ cursor: 'pointer'
45
+ }
46
+ });
38
47
  export default {
39
48
  app: app,
49
+ popover: popover,
40
50
  web: web
41
51
  };
@@ -11,7 +11,7 @@ function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (
11
11
  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; }
12
12
  import { baseBadge } from '../Badge/Badge.styles';
13
13
  import { text } from '../Button/Buttons.styles';
14
- var container = {
14
+ export var container = {
15
15
  maxWidth: '11.3em',
16
16
  maxHeight: '15em',
17
17
  overflow: 'hidden',
@@ -87,6 +87,8 @@ TooltipTrigger.propTypes = {
87
87
  /** The additional offset applied along the cross axis
88
88
  * between the element and its anchor element. */
89
89
  crossOffset: PropTypes.number,
90
+ /** Amount of time before the tooltip disappears */
91
+ closeDelay: PropTypes.number,
90
92
  /** Amount of time before the tooltip shows */
91
93
  delay: PropTypes.number,
92
94
  /** Where the popover menu opens relative to its trigger. */
@@ -10,6 +10,8 @@ This component is typically used as a design fallback for contextual information
10
10
  This component should provide useful, supplementary information or clarification regarding the element it points to.
11
11
  It shouldn’t contain essential content, error or feedback messages, or action items.
12
12
 
13
+ Tooltips cannot contain interactive content (links, buttons) according to the [ARIA Authoring Practices Guide](https://www.w3.org/WAI/ARIA/apg/patterns/tooltip/).
14
+
13
15
  ### Required Components
14
16
 
15
17
  This component requires the [Button](./?path=/docs/components-button--default) and Tooltip components.
@@ -1,9 +1,21 @@
1
+ import _Symbol from "@babel/runtime-corejs3/core-js-stable/symbol";
2
+ import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
3
+ import _Object$create from "@babel/runtime-corejs3/core-js-stable/object/create";
4
+ import _Object$getPrototypeOf from "@babel/runtime-corejs3/core-js-stable/object/get-prototype-of";
5
+ import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
6
+ import _Object$setPrototypeOf from "@babel/runtime-corejs3/core-js-stable/object/set-prototype-of";
7
+ import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
8
+ import _reverseInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/reverse";
9
+ import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
10
+ import _typeof from "@babel/runtime-corejs3/helpers/esm/typeof";
11
+ import _asyncToGenerator from "@babel/runtime-corejs3/helpers/esm/asyncToGenerator";
12
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof _Symbol ? _Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return _Object$defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = _Object$create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = _Object$getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = _Object$create(IteratorPrototype); function defineIteratorMethods(prototype) { var _context2; _forEachInstanceProperty(_context2 = ["next", "throw", "return"]).call(_context2, function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], _forEachInstanceProperty(tryLocsList).call(tryLocsList, pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return _Object$setPrototypeOf ? _Object$setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = _Object$create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = _Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return _reverseInstanceProperty(keys).call(keys), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { var _context3; if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, _forEachInstanceProperty(_context3 = this.tryEntries).call(_context3, resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+_sliceInstanceProperty(name).call(name, 1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
1
13
  import React from 'react';
2
14
  import userEvent from '@testing-library/user-event';
3
15
  import { Button, Tooltip, TooltipTrigger } from '../../index';
4
16
  import theme from '../../styles/theme';
5
17
  import axeTest from '../../utils/testUtils/testAxe';
6
- import { fireEvent, render, screen } from '../../utils/testUtils/testWrapper';
18
+ import { fireEvent, render, screen, waitFor } from '../../utils/testUtils/testWrapper';
7
19
  import { jsx as ___EmotionJSX } from "@emotion/react";
8
20
  var getComponent = function getComponent() {
9
21
  var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -78,4 +90,38 @@ test('passing in width applies the correct width to the container', function ()
78
90
  });
79
91
  var arrow = screen.getByTestId('popover-container');
80
92
  expect(arrow).toHaveStyle('width: 100px');
81
- });
93
+ });
94
+ test('tooltip closes after closeDelay when mouse leaves trigger', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
95
+ var closeDelay, button;
96
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
97
+ while (1) {
98
+ switch (_context.prev = _context.next) {
99
+ case 0:
100
+ closeDelay = 5000;
101
+ getComponent({
102
+ closeDelay: closeDelay
103
+ });
104
+ button = screen.getByRole('button');
105
+ fireEvent.mouseEnter(button);
106
+ expect(screen.queryByRole('tooltip')).toBeInTheDocument();
107
+ fireEvent.mouseLeave(button);
108
+ _context.next = 8;
109
+ return waitFor(function () {
110
+ expect(screen.queryByRole('tooltip')).toBeInTheDocument();
111
+ }, {
112
+ timeout: closeDelay / 2 + 100
113
+ });
114
+ case 8:
115
+ _context.next = 10;
116
+ return waitFor(function () {
117
+ expect(screen.queryByRole('tooltip')).not.toBeInTheDocument();
118
+ }, {
119
+ timeout: closeDelay + 100
120
+ });
121
+ case 10:
122
+ case "end":
123
+ return _context.stop();
124
+ }
125
+ }
126
+ }, _callee);
127
+ })));
@@ -31,7 +31,8 @@ export var FIGMA_LINKS = {
31
31
  "default": 'https://www.figma.com/file/bpbEw54gTTcdIiZs4PKK1p/Astro-Specs?type=design&node-id=218-1442&t=8Wwd3tIBh3GEjCJB-0'
32
32
  },
33
33
  helpHint: {
34
- "default": 'https://www.figma.com/file/Oa6VYtJcUJzEJuuRp0p4ls/Astro?type=design&node-id=0%3A4534&t=We3h7LaaFJQnxdSy-1'
34
+ "default": 'https://www.figma.com/file/Oa6VYtJcUJzEJuuRp0p4ls/Astro?type=design&node-id=0%3A4534&t=We3h7LaaFJQnxdSy-1',
35
+ withLink: 'https://www.figma.com/file/bpbEw54gTTcdIiZs4PKK1p/Astro-Specs?type=design&node-id=28958%3A40081&mode=design&t=WmSYPx1hR8kxFiXf-1'
35
36
  },
36
37
  icon: {
37
38
  "default": 'https://www.figma.com/file/bpbEw54gTTcdIiZs4PKK1p/Astro-Specs?type=design&node-id=24360%3A49754&t=3b86het2R9G2Zyo2-1'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pingux/astro",
3
- "version": "2.13.0-alpha.3",
3
+ "version": "2.13.0-alpha.5",
4
4
  "description": "React component library for Ping Identity's design system",
5
5
  "repository": {
6
6
  "type": "git",
@@ -100,7 +100,7 @@
100
100
  "react-calendar": "^3.4.0",
101
101
  "react-color": "^2.19.3",
102
102
  "react-dropzone": "^11.4.2",
103
- "react-stately": "~3.17.0",
103
+ "react-stately": "^3.20.0",
104
104
  "recharts": "^2.1.4",
105
105
  "regenerator-runtime": "^0.13.7",
106
106
  "styled-system": "^5.1.5",