@pingux/astro 2.0.3 → 2.0.4-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/EnvironmentBreadcrumb/EnvironmentBreadcrumb.stories.js +5 -4
- package/lib/cjs/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.test.js +12 -2
- package/lib/cjs/components/ListBox/Option.js +7 -3
- package/lib/cjs/components/ListItem/ListItem.styles.js +21 -7
- package/lib/cjs/components/MultivaluesField/MultivaluesField.stories.js +21 -11
- package/lib/cjs/components/TooltipTrigger/TooltipTrigger.stories.js +3 -1
- package/lib/cjs/hooks/index.js +7 -0
- package/lib/cjs/hooks/useOverlappingMenuHoverState/index.js +14 -0
- package/lib/cjs/hooks/useOverlappingMenuHoverState/useOverlappingMenuHoverState.js +61 -0
- package/lib/cjs/hooks/useOverlappingMenuHoverState/useOverlappingMenuHoverState.test.js +226 -0
- package/lib/cjs/recipes/LinkedListView.stories.js +189 -139
- package/lib/cjs/recipes/ListAndPanel.stories.js +21 -46
- package/lib/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.stories.js +5 -4
- package/lib/components/EnvironmentBreadcrumb/EnvironmentBreadcrumb.test.js +12 -2
- package/lib/components/ListBox/Option.js +7 -3
- package/lib/components/ListItem/ListItem.styles.js +21 -7
- package/lib/components/MultivaluesField/MultivaluesField.stories.js +21 -11
- package/lib/components/TooltipTrigger/TooltipTrigger.stories.js +3 -1
- package/lib/hooks/index.js +1 -0
- package/lib/hooks/useOverlappingMenuHoverState/index.js +1 -0
- package/lib/hooks/useOverlappingMenuHoverState/useOverlappingMenuHoverState.js +53 -0
- package/lib/hooks/useOverlappingMenuHoverState/useOverlappingMenuHoverState.test.js +219 -0
- package/lib/recipes/LinkedListView.stories.js +191 -141
- package/lib/recipes/ListAndPanel.stories.js +21 -46
- package/package.json +1 -1
- package/NOTICE.html +0 -12399
@@ -20,6 +20,7 @@ var _MoreVertIcon = _interopRequireDefault(require("mdi-react/MoreVertIcon"));
|
|
20
20
|
var _PencilIcon = _interopRequireDefault(require("mdi-react/PencilIcon"));
|
21
21
|
var _PlusIcon = _interopRequireDefault(require("mdi-react/PlusIcon"));
|
22
22
|
var _hooks = require("../hooks");
|
23
|
+
var _useOverlappingMenuHoverState = _interopRequireDefault(require("../hooks/useOverlappingMenuHoverState"));
|
23
24
|
var _index = require("../index");
|
24
25
|
var _react2 = require("@emotion/react");
|
25
26
|
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); }
|
@@ -188,46 +189,20 @@ var ListElement = function ListElement(_ref) {
|
|
188
189
|
var item = _ref.item,
|
189
190
|
isHoverable = _ref.isHoverable,
|
190
191
|
onClosePanel = _ref.onClosePanel;
|
191
|
-
var _useState = (0, _react.useState)(false),
|
192
|
-
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
193
|
-
isHovered = _useState2[0],
|
194
|
-
setIsHovered = _useState2[1];
|
195
|
-
var _useState3 = (0, _react.useState)({}),
|
196
|
-
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
197
|
-
mousePosition = _useState4[0],
|
198
|
-
setMousePosition = _useState4[1];
|
199
192
|
var listItemRef = (0, _react.useRef)();
|
200
|
-
var
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
if (hasMovedBackToRow) {
|
209
|
-
setIsHovered(true);
|
210
|
-
return;
|
211
|
-
}
|
212
|
-
setIsHovered(false);
|
213
|
-
};
|
214
|
-
var handleMouseMove = function handleMouseMove(e) {
|
215
|
-
setMousePosition({
|
216
|
-
currentPositionX: e.clientX,
|
217
|
-
currentPositionY: e.clientY
|
218
|
-
});
|
219
|
-
};
|
220
|
-
var handleHoveEnd = function handleHoveEnd() {
|
221
|
-
setIsHovered(false);
|
222
|
-
};
|
223
|
-
var handleHoveStart = function handleHoveStart() {
|
224
|
-
setIsHovered(true);
|
225
|
-
};
|
193
|
+
var _useOverlappingMenuHo = (0, _useOverlappingMenuHoverState["default"])({
|
194
|
+
listItemRef: listItemRef
|
195
|
+
}),
|
196
|
+
handleHoverEnd = _useOverlappingMenuHo.handleHoverEnd,
|
197
|
+
handleHoverStart = _useOverlappingMenuHo.handleHoverStart,
|
198
|
+
handleMenuHoverEnd = _useOverlappingMenuHo.handleMenuHoverEnd,
|
199
|
+
handleMouseMove = _useOverlappingMenuHo.handleMouseMove,
|
200
|
+
isHovered = _useOverlappingMenuHo.isHovered;
|
226
201
|
return (0, _react2.jsx)(_index.ListItem, {
|
227
202
|
isHovered: isHoverable && isHovered,
|
228
203
|
isRow: true,
|
229
|
-
onHoverEnd:
|
230
|
-
onHoverStart:
|
204
|
+
onHoverEnd: handleHoverEnd,
|
205
|
+
onHoverStart: handleHoverStart,
|
231
206
|
onMouseMove: handleMouseMove,
|
232
207
|
ref: listItemRef,
|
233
208
|
sx: sx.listElement.wrapper
|
@@ -259,9 +234,9 @@ var ListElement = function ListElement(_ref) {
|
|
259
234
|
icon: _MoreVertIcon["default"],
|
260
235
|
size: "md"
|
261
236
|
})), (0, _react2.jsx)(_index.Menu, {
|
262
|
-
onAction:
|
237
|
+
onAction: handleHoverEnd,
|
263
238
|
onHoverEnd: handleMenuHoverEnd,
|
264
|
-
onHoverStart:
|
239
|
+
onHoverStart: handleHoverStart
|
265
240
|
}, (0, _react2.jsx)(_reactStately.Item, {
|
266
241
|
key: "enable"
|
267
242
|
}, "Enable user"), (0, _react2.jsx)(_reactStately.Item, {
|
@@ -277,14 +252,14 @@ var ListElement = function ListElement(_ref) {
|
|
277
252
|
}))));
|
278
253
|
};
|
279
254
|
var Default = function Default() {
|
280
|
-
var
|
281
|
-
|
282
|
-
selectedItemId =
|
283
|
-
setSelectedItemId =
|
284
|
-
var
|
285
|
-
|
286
|
-
selectedKeys =
|
287
|
-
setSelectedKeys =
|
255
|
+
var _useState = (0, _react.useState)(),
|
256
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
257
|
+
selectedItemId = _useState2[0],
|
258
|
+
setSelectedItemId = _useState2[1];
|
259
|
+
var _useState3 = (0, _react.useState)(),
|
260
|
+
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
261
|
+
selectedKeys = _useState4[0],
|
262
|
+
setSelectedKeys = _useState4[1];
|
288
263
|
var _useOverlayPanelState = (0, _hooks.useOverlayPanelState)(),
|
289
264
|
panelState = _useOverlayPanelState.state,
|
290
265
|
onPanelClose = _useOverlayPanelState.onClose;
|
@@ -97,7 +97,7 @@ var environmentsWithSections = [{
|
|
97
97
|
name: 'Mine'
|
98
98
|
}]
|
99
99
|
}, {
|
100
|
-
name:
|
100
|
+
name: 'Other',
|
101
101
|
key: 'Other',
|
102
102
|
options: [{
|
103
103
|
name: 'Default'
|
@@ -184,10 +184,10 @@ export var WithSections = function WithSections() {
|
|
184
184
|
}
|
185
185
|
return _concatInstanceProperty(_context3 = [_objectSpread({}, envObj)]).call(_context3, prevEnvs);
|
186
186
|
};
|
187
|
-
var findEnvObj = function findEnvObj(envName) {
|
187
|
+
var findEnvObj = function findEnvObj(envName, envSectionName) {
|
188
188
|
var _context4;
|
189
189
|
return _findInstanceProperty(_context4 = _findInstanceProperty(environments).call(environments, function (section) {
|
190
|
-
return section.name ===
|
190
|
+
return section.name === envSectionName;
|
191
191
|
}).options).call(_context4, function (option) {
|
192
192
|
return option.name === envName;
|
193
193
|
});
|
@@ -195,10 +195,11 @@ export var WithSections = function WithSections() {
|
|
195
195
|
var handleEnvPress = function handleEnvPress(newEnv) {
|
196
196
|
var sectionPrefixIndex = _indexOfInstanceProperty(newEnv).call(newEnv, '-');
|
197
197
|
var envKey = newEnv.substr(sectionPrefixIndex + 1);
|
198
|
+
var envSectionName = newEnv.substr(0, sectionPrefixIndex);
|
198
199
|
var recentEnvironments = _findInstanceProperty(environments).call(environments, function (envSection) {
|
199
200
|
return envSection.name === 'Recent';
|
200
201
|
}).options;
|
201
|
-
var envObj = findEnvObj(envKey);
|
202
|
+
var envObj = findEnvObj(envKey, envSectionName);
|
202
203
|
var updatedRecentEnvironments = getUpdatedRecentEnvs(envObj, recentEnvironments);
|
203
204
|
setEnvironments(function (prevEnvs) {
|
204
205
|
return _mapInstanceProperty(prevEnvs).call(prevEnvs, function (section) {
|
@@ -16,9 +16,9 @@ import _typeof from "@babel/runtime-corejs3/helpers/esm/typeof";
|
|
16
16
|
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/esm/asyncToGenerator";
|
17
17
|
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
18
18
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
19
|
-
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 _context7; _forEachInstanceProperty(_context7 = ["next", "throw", "return"]).call(_context7, 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 _context8; 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(_context8 = this.tryEntries).call(_context8, 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; }
|
19
|
+
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; }
|
20
20
|
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; }
|
21
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var
|
21
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context6, _context7; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context6 = ownKeys(Object(source), !0)).call(_context6, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context7 = ownKeys(Object(source))).call(_context7, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
22
22
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
23
23
|
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
24
24
|
import React from 'react';
|
@@ -354,4 +354,14 @@ test('should hide section title if no search results within it', function () {
|
|
354
354
|
// 'Heading 1' should not be rendered, but 'Heading 2' should be
|
355
355
|
expect(screen.queryByText(itemsWithSections[0].name)).not.toBeInTheDocument();
|
356
356
|
expect(screen.queryByText(itemsWithSections[1].name)).toBeInTheDocument();
|
357
|
+
});
|
358
|
+
test('should reflect the selection change when env is clicked', function () {
|
359
|
+
var _context5;
|
360
|
+
var onSelectionChangeMock = jest.fn();
|
361
|
+
getSectionsComponent({
|
362
|
+
isDefaultOpen: true,
|
363
|
+
onSelectionChange: onSelectionChangeMock
|
364
|
+
});
|
365
|
+
userEvent.click(screen.getByText(itemsWithSections[1].options[1].name));
|
366
|
+
expect(onSelectionChangeMock).toHaveBeenNthCalledWith(1, _concatInstanceProperty(_context5 = "".concat(itemsWithSections[1].name, "-")).call(_context5, itemsWithSections[1].options[1].name));
|
357
367
|
});
|
@@ -29,7 +29,8 @@ var Option = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
29
29
|
others = _objectWithoutProperties(props, _excluded);
|
30
30
|
var key = item.key,
|
31
31
|
itemProps = item.props,
|
32
|
-
rendered = item.rendered
|
32
|
+
rendered = item.rendered,
|
33
|
+
ariaLabel = item['aria-label'];
|
33
34
|
var state = useContext(ListBoxContext);
|
34
35
|
var isSeparator = itemProps.isSeparator,
|
35
36
|
dataId = itemProps['data-id'];
|
@@ -76,7 +77,9 @@ var Option = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
76
77
|
"data-id": dataId,
|
77
78
|
className: classNames,
|
78
79
|
onPointerOver: setFocusOnHover
|
79
|
-
}, optionProps, others
|
80
|
+
}, optionProps, others, {
|
81
|
+
"aria-label": ariaLabel
|
82
|
+
}), isSelected && ___EmotionJSX(Icon, {
|
80
83
|
icon: CircleSmallIcon
|
81
84
|
}), rendered);
|
82
85
|
});
|
@@ -88,7 +91,8 @@ Option.propTypes = {
|
|
88
91
|
'data-id': PropTypes.string,
|
89
92
|
isSeparator: PropTypes.bool
|
90
93
|
}),
|
91
|
-
rendered: PropTypes.node
|
94
|
+
rendered: PropTypes.node,
|
95
|
+
'aria-label': PropTypes.string
|
92
96
|
}),
|
93
97
|
state: PropTypes.shape({
|
94
98
|
disabledKeys: isIterableProp,
|
@@ -1,4 +1,21 @@
|
|
1
|
-
|
1
|
+
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
2
|
+
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
3
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
4
|
+
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
5
|
+
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
6
|
+
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
7
|
+
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
8
|
+
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
9
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
10
|
+
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; }
|
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
|
+
var hover = {
|
13
|
+
bg: 'accent.99',
|
14
|
+
'&.is-hovered': {
|
15
|
+
bg: 'white'
|
16
|
+
}
|
17
|
+
};
|
18
|
+
var container = _objectSpread({
|
2
19
|
display: 'flex',
|
3
20
|
flex: '1 1 0px',
|
4
21
|
cursor: 'pointer',
|
@@ -8,14 +25,11 @@ var container = {
|
|
8
25
|
pt: 16,
|
9
26
|
pb: 16,
|
10
27
|
justifyContent: 'center',
|
11
|
-
bg: 'accent.99',
|
12
28
|
'&.is-selected': {
|
13
29
|
bg: 'white'
|
14
|
-
},
|
15
|
-
'&.is-hovered': {
|
16
|
-
bg: 'white'
|
17
30
|
}
|
18
|
-
};
|
31
|
+
}, hover);
|
19
32
|
export default {
|
20
|
-
container: container
|
33
|
+
container: container,
|
34
|
+
hover: hover
|
21
35
|
};
|
@@ -283,7 +283,8 @@ export var Default = function Default(args) {
|
|
283
283
|
}), function (item) {
|
284
284
|
return ___EmotionJSX(Item, {
|
285
285
|
key: item.key,
|
286
|
-
"data-id": item.name
|
286
|
+
"data-id": item.name,
|
287
|
+
"aria-label": item.name
|
287
288
|
}, item.name);
|
288
289
|
}));
|
289
290
|
};
|
@@ -308,7 +309,8 @@ export var Uncontrolled = function Uncontrolled(args) {
|
|
308
309
|
}), function (item) {
|
309
310
|
return ___EmotionJSX(Item, {
|
310
311
|
key: item.key,
|
311
|
-
"data-id": item.name
|
312
|
+
"data-id": item.name,
|
313
|
+
"aria-label": item.name
|
312
314
|
}, item.name);
|
313
315
|
}));
|
314
316
|
};
|
@@ -339,7 +341,8 @@ export var Controlled = function Controlled(args) {
|
|
339
341
|
}), function (item) {
|
340
342
|
return ___EmotionJSX(Item, {
|
341
343
|
key: item.key,
|
342
|
-
"data-id": item.name
|
344
|
+
"data-id": item.name,
|
345
|
+
"aria-label": item.name
|
343
346
|
}, item.name);
|
344
347
|
}));
|
345
348
|
};
|
@@ -364,7 +367,8 @@ export var Error = function Error(args) {
|
|
364
367
|
}), function (item) {
|
365
368
|
return ___EmotionJSX(Item, {
|
366
369
|
key: item.key,
|
367
|
-
"data-id": item.name
|
370
|
+
"data-id": item.name,
|
371
|
+
"aria-label": item.name
|
368
372
|
}, item.name);
|
369
373
|
}));
|
370
374
|
};
|
@@ -389,7 +393,8 @@ export var ReadOnlyField = function ReadOnlyField(args) {
|
|
389
393
|
}), function (item) {
|
390
394
|
return ___EmotionJSX(Item, {
|
391
395
|
key: item.key,
|
392
|
-
"data-id": item.name
|
396
|
+
"data-id": item.name,
|
397
|
+
"aria-label": item.name
|
393
398
|
}, item.name);
|
394
399
|
}));
|
395
400
|
};
|
@@ -414,7 +419,8 @@ export var ReadOnlyValues = function ReadOnlyValues(args) {
|
|
414
419
|
}), function (item) {
|
415
420
|
return ___EmotionJSX(Item, {
|
416
421
|
key: item.key,
|
417
|
-
"data-id": item.name
|
422
|
+
"data-id": item.name,
|
423
|
+
"aria-label": item.name
|
418
424
|
}, item.name);
|
419
425
|
}));
|
420
426
|
};
|
@@ -439,7 +445,8 @@ export var DisabledKeys = function DisabledKeys(args) {
|
|
439
445
|
}), function (item) {
|
440
446
|
return ___EmotionJSX(Item, {
|
441
447
|
key: item.key,
|
442
|
-
"data-id": item.name
|
448
|
+
"data-id": item.name,
|
449
|
+
"aria-label": item.name
|
443
450
|
}, item.name);
|
444
451
|
}));
|
445
452
|
};
|
@@ -464,7 +471,8 @@ export var CustomValues = function CustomValues(args) {
|
|
464
471
|
}), function (item) {
|
465
472
|
return ___EmotionJSX(Item, {
|
466
473
|
key: item.key,
|
467
|
-
"data-id": item.name
|
474
|
+
"data-id": item.name,
|
475
|
+
"aria-label": item.name
|
468
476
|
}, item.name);
|
469
477
|
}));
|
470
478
|
};
|
@@ -493,7 +501,8 @@ export var IconSlotsInBadge = function IconSlotsInBadge(args) {
|
|
493
501
|
}), function (item) {
|
494
502
|
return ___EmotionJSX(Item, {
|
495
503
|
key: item.key,
|
496
|
-
"data-id": item.name
|
504
|
+
"data-id": item.name,
|
505
|
+
"aria-label": item.name
|
497
506
|
}, item.name);
|
498
507
|
}));
|
499
508
|
};
|
@@ -515,7 +524,7 @@ export var CustomSize = function CustomSize(args) {
|
|
515
524
|
}, ___EmotionJSX(Box, {
|
516
525
|
width: 300
|
517
526
|
}, ___EmotionJSX(OverlayProvider
|
518
|
-
// note: spacing for demo purpose only so that the select list renders in the
|
527
|
+
// note: spacing for demo purpose only so that the select list renders in the right place
|
519
528
|
, {
|
520
529
|
style: setOverlayStyle(direction, isOpen, '25%', '25%', '75%')
|
521
530
|
}, ___EmotionJSX(MultivaluesField, _extends({
|
@@ -525,7 +534,8 @@ export var CustomSize = function CustomSize(args) {
|
|
525
534
|
}), function (item) {
|
526
535
|
return ___EmotionJSX(Item, {
|
527
536
|
key: item.key,
|
528
|
-
"data-id": item.name
|
537
|
+
"data-id": item.name,
|
538
|
+
"aria-label": item.name
|
529
539
|
}, item.name);
|
530
540
|
}))));
|
531
541
|
};
|
@@ -45,7 +45,9 @@ export var Disabled = function Disabled() {
|
|
45
45
|
return ___EmotionJSX(TooltipTrigger, {
|
46
46
|
delay: 0,
|
47
47
|
isDisabled: true
|
48
|
-
}, ___EmotionJSX(IconButton,
|
48
|
+
}, ___EmotionJSX(IconButton, {
|
49
|
+
"aria-label": "Earth Icon"
|
50
|
+
}, ___EmotionJSX(Icon, {
|
49
51
|
icon: Earth
|
50
52
|
})), ___EmotionJSX(Tooltip, null, "Hello World"));
|
51
53
|
};
|
package/lib/hooks/index.js
CHANGED
@@ -9,6 +9,7 @@ export { default as useField } from './useField';
|
|
9
9
|
export { default as useLabelHeight } from './useLabelHeight';
|
10
10
|
export { default as useModalState } from './useModalState';
|
11
11
|
export { default as useNavBarPress } from './useNavBarPress';
|
12
|
+
export { default as useOverlappingMenuHoverState } from './useOverlappingMenuHoverState';
|
12
13
|
export { default as useOverlayPanelState } from './useOverlayPanelState';
|
13
14
|
export { default as useProgressiveState } from './useProgressiveState';
|
14
15
|
export { default as usePropWarning } from './usePropWarning';
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './useOverlappingMenuHoverState';
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
2
|
+
import { useState } from 'react';
|
3
|
+
|
4
|
+
// Manages the hover state of a ListItem and an overlapping PopoverMenu together
|
5
|
+
var useOverlappingMenuHoverState = function useOverlappingMenuHoverState(_ref) {
|
6
|
+
var listItemRef = _ref.listItemRef;
|
7
|
+
var _useState = useState(false),
|
8
|
+
_useState2 = _slicedToArray(_useState, 2),
|
9
|
+
isHovered = _useState2[0],
|
10
|
+
setIsHovered = _useState2[1];
|
11
|
+
var _useState3 = useState({}),
|
12
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
13
|
+
mousePosition = _useState4[0],
|
14
|
+
setMousePosition = _useState4[1];
|
15
|
+
var handleMenuHoverEnd = function handleMenuHoverEnd() {
|
16
|
+
var currentPositionX = mousePosition.currentPositionX,
|
17
|
+
currentPositionY = mousePosition.currentPositionY;
|
18
|
+
var _listItemRef$current$ = listItemRef.current.getBoundingClientRect(),
|
19
|
+
height = _listItemRef$current$.height,
|
20
|
+
right = _listItemRef$current$.right,
|
21
|
+
top = _listItemRef$current$.top,
|
22
|
+
width = _listItemRef$current$.width;
|
23
|
+
|
24
|
+
// Uses the position of the mouse and list item dimensions from listItemRef
|
25
|
+
// to determine if mouse has moved back to ListItem
|
26
|
+
var hasMovedBackToRow = currentPositionY > top && currentPositionY < top + height && currentPositionX < right && currentPositionX > right - width;
|
27
|
+
if (hasMovedBackToRow) {
|
28
|
+
setIsHovered(true);
|
29
|
+
return;
|
30
|
+
}
|
31
|
+
setIsHovered(false);
|
32
|
+
};
|
33
|
+
var handleMouseMove = function handleMouseMove(e) {
|
34
|
+
setMousePosition({
|
35
|
+
currentPositionX: e.clientX,
|
36
|
+
currentPositionY: e.clientY
|
37
|
+
});
|
38
|
+
};
|
39
|
+
var handleHoverEnd = function handleHoverEnd() {
|
40
|
+
setIsHovered(false);
|
41
|
+
};
|
42
|
+
var handleHoverStart = function handleHoverStart() {
|
43
|
+
setIsHovered(true);
|
44
|
+
};
|
45
|
+
return {
|
46
|
+
handleHoverEnd: handleHoverEnd,
|
47
|
+
handleHoverStart: handleHoverStart,
|
48
|
+
handleMenuHoverEnd: handleMenuHoverEnd,
|
49
|
+
handleMouseMove: handleMouseMove,
|
50
|
+
isHovered: isHovered
|
51
|
+
};
|
52
|
+
};
|
53
|
+
export default useOverlappingMenuHoverState;
|