@moda/om 21.6.11 → 21.7.0
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/dist/index.cjs.js +54 -3
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +54 -3
- package/dist/index.esm.js.map +1 -1
- package/dist/src/components/Popover/Popover.d.ts +16 -0
- package/dist/src/components/Popover/Popover.stories.d.ts +53 -0
- package/dist/src/components/SlidingPane/SlidingPane.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/Popover/Popover.stories.tsx +189 -1
- package/src/components/Popover/Popover.tsx +75 -1
- package/src/components/SlidingPane/SlidingPane.tsx +8 -1
package/dist/index.esm.js
CHANGED
|
@@ -12331,7 +12331,7 @@ var PasswordInput = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
12331
12331
|
});
|
|
12332
12332
|
PasswordInput.displayName = 'PasswordInput';
|
|
12333
12333
|
|
|
12334
|
-
var _excluded$9 = ["className", "children", "content", "open", "anchor", "zIndex", "autoPreview", "smoothTransitioning"];
|
|
12334
|
+
var _excluded$9 = ["className", "children", "content", "open", "anchor", "zIndex", "autoPreview", "smoothTransitioning", "role", "aria-label", "aria-labelledby", "popoverId", "openOnFocus", "closeOnEscape", "onClose", "autoFocus"];
|
|
12335
12335
|
var POPOVER_MOUSEOUT_DELAY_MS = 200;
|
|
12336
12336
|
var THREE_QUARTER_SECOND_DELAY = 750;
|
|
12337
12337
|
var ONE_SECOND_DELAY = 1000;
|
|
@@ -12357,6 +12357,17 @@ var Popover = function Popover(_ref) {
|
|
|
12357
12357
|
autoPreview = _ref$autoPreview === void 0 ? false : _ref$autoPreview,
|
|
12358
12358
|
_ref$smoothTransition = _ref.smoothTransitioning,
|
|
12359
12359
|
smoothTransitioning = _ref$smoothTransition === void 0 ? false : _ref$smoothTransition,
|
|
12360
|
+
role = _ref.role,
|
|
12361
|
+
ariaLabel = _ref['aria-label'],
|
|
12362
|
+
ariaLabelledby = _ref['aria-labelledby'],
|
|
12363
|
+
popoverId = _ref.popoverId,
|
|
12364
|
+
_ref$openOnFocus = _ref.openOnFocus,
|
|
12365
|
+
openOnFocus = _ref$openOnFocus === void 0 ? false : _ref$openOnFocus,
|
|
12366
|
+
_ref$closeOnEscape = _ref.closeOnEscape,
|
|
12367
|
+
closeOnEscape = _ref$closeOnEscape === void 0 ? true : _ref$closeOnEscape,
|
|
12368
|
+
onClose = _ref.onClose,
|
|
12369
|
+
_ref$autoFocus = _ref.autoFocus,
|
|
12370
|
+
autoFocus = _ref$autoFocus === void 0 ? false : _ref$autoFocus,
|
|
12360
12371
|
rest = _objectWithoutProperties(_ref, _excluded$9);
|
|
12361
12372
|
var _useState = useState(function () {
|
|
12362
12373
|
if (open && smoothTransitioning) {
|
|
@@ -12374,6 +12385,7 @@ var Popover = function Popover(_ref) {
|
|
|
12374
12385
|
mode = _useState2[0],
|
|
12375
12386
|
setMode = _useState2[1];
|
|
12376
12387
|
var timeout = useRef(null);
|
|
12388
|
+
var contentRef = useRef(null);
|
|
12377
12389
|
var handleOpen = useCallback(function () {
|
|
12378
12390
|
if (smoothTransitioning) setMode(Mode.Opening);
|
|
12379
12391
|
if (!smoothTransitioning) setMode(Mode.Open);
|
|
@@ -12392,6 +12404,27 @@ var Popover = function Popover(_ref) {
|
|
|
12392
12404
|
if (open) return;
|
|
12393
12405
|
timeout.current = setTimeout(handleClose, POPOVER_MOUSEOUT_DELAY_MS);
|
|
12394
12406
|
}, [handleClose, open]);
|
|
12407
|
+
var handleKeyDown = useCallback(function (event) {
|
|
12408
|
+
if (closeOnEscape && event.key === 'Escape') {
|
|
12409
|
+
onClose === null || onClose === void 0 || onClose();
|
|
12410
|
+
handleClose();
|
|
12411
|
+
event.preventDefault();
|
|
12412
|
+
}
|
|
12413
|
+
}, [closeOnEscape, onClose, handleClose]);
|
|
12414
|
+
var handleFocus = useCallback(function () {
|
|
12415
|
+
if (openOnFocus && open === undefined) {
|
|
12416
|
+
if (timeout.current) clearTimeout(timeout.current);
|
|
12417
|
+
handleOpen();
|
|
12418
|
+
}
|
|
12419
|
+
}, [openOnFocus, open, handleOpen]);
|
|
12420
|
+
var handleBlur = useCallback(function (event) {
|
|
12421
|
+
if (openOnFocus && open === undefined) {
|
|
12422
|
+
// Only close if focus moved outside the popover entirely
|
|
12423
|
+
if (!event.currentTarget.contains(event.relatedTarget)) {
|
|
12424
|
+
timeout.current = setTimeout(handleClose, POPOVER_MOUSEOUT_DELAY_MS);
|
|
12425
|
+
}
|
|
12426
|
+
}
|
|
12427
|
+
}, [openOnFocus, open, handleClose]);
|
|
12395
12428
|
useEffect(function () {
|
|
12396
12429
|
if (mode !== Mode.Closing) return;
|
|
12397
12430
|
var closingTimeout = setTimeout(function () {
|
|
@@ -12435,10 +12468,18 @@ var Popover = function Popover(_ref) {
|
|
|
12435
12468
|
}
|
|
12436
12469
|
}, [handleClose, handleOpen, open]);
|
|
12437
12470
|
var isOpen = mode === Mode.AutoOpen || mode === Mode.Opening || mode === Mode.Open || mode === Mode.Closing;
|
|
12471
|
+
useEffect(function () {
|
|
12472
|
+
if (autoFocus && isOpen && contentRef.current) {
|
|
12473
|
+
contentRef.current.focus();
|
|
12474
|
+
}
|
|
12475
|
+
}, [autoFocus, isOpen]);
|
|
12438
12476
|
return /*#__PURE__*/React__default.createElement("div", _extends$1({
|
|
12439
12477
|
className: classNames("Popover Popover--anchor-".concat(anchor), className),
|
|
12440
12478
|
onMouseEnter: handleMouseEnter,
|
|
12441
|
-
onMouseLeave: handleMouseLeave
|
|
12479
|
+
onMouseLeave: handleMouseLeave,
|
|
12480
|
+
onKeyDown: handleKeyDown,
|
|
12481
|
+
onFocus: handleFocus,
|
|
12482
|
+
onBlur: handleBlur
|
|
12442
12483
|
}, rest), /*#__PURE__*/React__default.createElement("span", {
|
|
12443
12484
|
className: "Popover__trigger"
|
|
12444
12485
|
}, isOpen && /*#__PURE__*/React__default.createElement("div", {
|
|
@@ -12448,10 +12489,17 @@ var Popover = function Popover(_ref) {
|
|
|
12448
12489
|
})
|
|
12449
12490
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
12450
12491
|
className: "Popover__caret",
|
|
12492
|
+
"aria-hidden": "true",
|
|
12451
12493
|
style: {
|
|
12452
12494
|
zIndex: zIndex != null ? zIndex + 1 : undefined
|
|
12453
12495
|
}
|
|
12454
12496
|
}), /*#__PURE__*/React__default.createElement("div", {
|
|
12497
|
+
ref: contentRef,
|
|
12498
|
+
id: popoverId,
|
|
12499
|
+
role: role,
|
|
12500
|
+
"aria-label": ariaLabel,
|
|
12501
|
+
"aria-labelledby": ariaLabelledby,
|
|
12502
|
+
tabIndex: autoFocus ? -1 : undefined,
|
|
12455
12503
|
className: "Popover__content",
|
|
12456
12504
|
style: {
|
|
12457
12505
|
zIndex: zIndex
|
|
@@ -12529,13 +12577,15 @@ var SelectableButton = function SelectableButton(_ref) {
|
|
|
12529
12577
|
}, rest), /*#__PURE__*/React__default.createElement("span", null, children));
|
|
12530
12578
|
};
|
|
12531
12579
|
|
|
12532
|
-
var _excluded$5 = ["className", "title", "visible", "children", "onClose"];
|
|
12580
|
+
var _excluded$5 = ["className", "title", "visible", "children", "onClose", "autoFocus"];
|
|
12533
12581
|
var SlidingPane = function SlidingPane(_ref) {
|
|
12534
12582
|
var className = _ref.className,
|
|
12535
12583
|
title = _ref.title,
|
|
12536
12584
|
visible = _ref.visible,
|
|
12537
12585
|
children = _ref.children,
|
|
12538
12586
|
onClose = _ref.onClose,
|
|
12587
|
+
_ref$autoFocus = _ref.autoFocus,
|
|
12588
|
+
autoFocus = _ref$autoFocus === void 0 ? true : _ref$autoFocus,
|
|
12539
12589
|
rest = _objectWithoutProperties(_ref, _excluded$5);
|
|
12540
12590
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
|
|
12541
12591
|
className: classNames('SlidingPane__overlay', {
|
|
@@ -12544,6 +12594,7 @@ var SlidingPane = function SlidingPane(_ref) {
|
|
|
12544
12594
|
onClick: onClose
|
|
12545
12595
|
}), /*#__PURE__*/React__default.createElement(FocusOn, {
|
|
12546
12596
|
enabled: visible,
|
|
12597
|
+
autoFocus: autoFocus,
|
|
12547
12598
|
onClickOutside: onClose,
|
|
12548
12599
|
onEscapeKey: onClose
|
|
12549
12600
|
}, /*#__PURE__*/React__default.createElement("div", _extends$1({
|