@moda/om 19.8.2 → 19.9.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 +72 -26
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +72 -26
- package/dist/index.esm.js.map +1 -1
- package/package.json +63 -61
- package/src/components/Checkbox/Checkbox.tsx +1 -1
- package/src/components/ColorSwatch/ColorSwatch.tsx +2 -2
- package/src/components/Popover/Popover.tsx +6 -2
- package/src/components/Select/MultiSelect.tsx +1 -1
- package/src/components/Select/Select.tsx +1 -1
- package/src/components/Select/SelectOption.tsx +1 -1
- package/src/components/Select/SelectOptions.tsx +2 -2
- package/src/components/Select/useSelect.ts +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1460,7 +1460,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
1460
1460
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
1461
1461
|
PERFORMANCE OF THIS SOFTWARE.
|
|
1462
1462
|
***************************************************************************** */
|
|
1463
|
-
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
1463
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
1464
1464
|
|
|
1465
1465
|
|
|
1466
1466
|
var __assign$a = function() {
|
|
@@ -3130,7 +3130,8 @@ var FocusLock = /*#__PURE__*/React.forwardRef(function FocusLockUI(props, parent
|
|
|
3130
3130
|
onActivation: onActivation,
|
|
3131
3131
|
onDeactivation: onDeactivation,
|
|
3132
3132
|
returnFocus: returnFocus,
|
|
3133
|
-
focusOptions: focusOptions
|
|
3133
|
+
focusOptions: focusOptions,
|
|
3134
|
+
noFocusGuards: noFocusGuards
|
|
3134
3135
|
}), /*#__PURE__*/React.createElement(Container, _extends({
|
|
3135
3136
|
ref: mergedRef
|
|
3136
3137
|
}, lockProps, {
|
|
@@ -4319,8 +4320,12 @@ var isFreeFocus = function isFreeFocus() {
|
|
|
4319
4320
|
};
|
|
4320
4321
|
var lastActiveTrap = null;
|
|
4321
4322
|
var lastActiveFocus = null;
|
|
4323
|
+
var tryRestoreFocus = function tryRestoreFocus() {
|
|
4324
|
+
return null;
|
|
4325
|
+
};
|
|
4322
4326
|
var lastPortaledElement = null;
|
|
4323
4327
|
var focusWasOutsideWindow = false;
|
|
4328
|
+
var windowFocused = false;
|
|
4324
4329
|
var defaultWhitelist = function defaultWhitelist() {
|
|
4325
4330
|
return true;
|
|
4326
4331
|
};
|
|
@@ -4372,6 +4377,14 @@ var withinHost = function withinHost(activeElement, workingArea) {
|
|
|
4372
4377
|
return checkInHost(activeElement, area, area);
|
|
4373
4378
|
});
|
|
4374
4379
|
};
|
|
4380
|
+
var getNodeFocusables = function getNodeFocusables(nodes) {
|
|
4381
|
+
return getFocusableNodes(nodes, new Map());
|
|
4382
|
+
};
|
|
4383
|
+
var isNotFocusable = function isNotFocusable(node) {
|
|
4384
|
+
return !getNodeFocusables([node.parentNode]).some(function (el) {
|
|
4385
|
+
return el.node === node;
|
|
4386
|
+
});
|
|
4387
|
+
};
|
|
4375
4388
|
var activateTrap = function activateTrap() {
|
|
4376
4389
|
var result = false;
|
|
4377
4390
|
if (lastActiveTrap) {
|
|
@@ -4381,13 +4394,34 @@ var activateTrap = function activateTrap() {
|
|
|
4381
4394
|
autoFocus = _lastActiveTrap.autoFocus,
|
|
4382
4395
|
shards = _lastActiveTrap.shards,
|
|
4383
4396
|
crossFrame = _lastActiveTrap.crossFrame,
|
|
4384
|
-
focusOptions = _lastActiveTrap.focusOptions
|
|
4397
|
+
focusOptions = _lastActiveTrap.focusOptions,
|
|
4398
|
+
noFocusGuards = _lastActiveTrap.noFocusGuards;
|
|
4385
4399
|
var workingNode = observed || lastPortaledElement && lastPortaledElement.portaledElement;
|
|
4400
|
+
if (focusOnBody() && lastActiveFocus) {
|
|
4401
|
+
if (!document.body.contains(lastActiveFocus) || isNotFocusable(lastActiveFocus)) {
|
|
4402
|
+
lastActiveFocus = null;
|
|
4403
|
+
var newTarget = tryRestoreFocus();
|
|
4404
|
+
if (newTarget) {
|
|
4405
|
+
newTarget.focus();
|
|
4406
|
+
}
|
|
4407
|
+
}
|
|
4408
|
+
}
|
|
4386
4409
|
var activeElement = document && document.activeElement;
|
|
4387
4410
|
if (workingNode) {
|
|
4388
4411
|
var workingArea = [workingNode].concat(shards.map(extractRef$2).filter(Boolean));
|
|
4412
|
+
var shouldForceRestoreFocus = function shouldForceRestoreFocus() {
|
|
4413
|
+
if (!focusWasOutside(crossFrame) || !noFocusGuards || !lastActiveFocus || windowFocused) {
|
|
4414
|
+
return false;
|
|
4415
|
+
}
|
|
4416
|
+
var nodes = getNodeFocusables(workingArea);
|
|
4417
|
+
var lastIndex = nodes.findIndex(function (_ref) {
|
|
4418
|
+
var node = _ref.node;
|
|
4419
|
+
return node === lastActiveFocus;
|
|
4420
|
+
});
|
|
4421
|
+
return lastIndex === 0 || lastIndex === nodes.length - 1;
|
|
4422
|
+
};
|
|
4389
4423
|
if (!activeElement || focusWhitelisted(activeElement)) {
|
|
4390
|
-
if (persistentFocus ||
|
|
4424
|
+
if (persistentFocus || shouldForceRestoreFocus() || !isFreeFocus() || !lastActiveFocus && autoFocus) {
|
|
4391
4425
|
if (workingNode && !(focusInside(workingArea) || activeElement && withinHost(activeElement, workingArea) || focusIsPortaledPair(activeElement))) {
|
|
4392
4426
|
if (document && !lastActiveFocus && activeElement && !autoFocus) {
|
|
4393
4427
|
if (activeElement.blur) {
|
|
@@ -4403,22 +4437,23 @@ var activateTrap = function activateTrap() {
|
|
|
4403
4437
|
}
|
|
4404
4438
|
focusWasOutsideWindow = false;
|
|
4405
4439
|
lastActiveFocus = document && document.activeElement;
|
|
4440
|
+
tryRestoreFocus = captureFocusRestore(lastActiveFocus);
|
|
4406
4441
|
}
|
|
4407
4442
|
}
|
|
4408
4443
|
if (document && activeElement !== document.activeElement && document.querySelector('[data-focus-auto-guard]')) {
|
|
4409
4444
|
var newActiveElement = document && document.activeElement;
|
|
4410
4445
|
var allNodes = expandFocusableNodes(workingArea);
|
|
4411
|
-
var focusedIndex = allNodes.map(function (
|
|
4412
|
-
var node =
|
|
4446
|
+
var focusedIndex = allNodes.map(function (_ref2) {
|
|
4447
|
+
var node = _ref2.node;
|
|
4413
4448
|
return node;
|
|
4414
4449
|
}).indexOf(newActiveElement);
|
|
4415
4450
|
if (focusedIndex > -1) {
|
|
4416
|
-
allNodes.filter(function (
|
|
4417
|
-
var guard =
|
|
4418
|
-
node =
|
|
4451
|
+
allNodes.filter(function (_ref3) {
|
|
4452
|
+
var guard = _ref3.guard,
|
|
4453
|
+
node = _ref3.node;
|
|
4419
4454
|
return guard && node.dataset.focusAutoGuard;
|
|
4420
|
-
}).forEach(function (
|
|
4421
|
-
var node =
|
|
4455
|
+
}).forEach(function (_ref4) {
|
|
4456
|
+
var node = _ref4.node;
|
|
4422
4457
|
return node.removeAttribute('tabIndex');
|
|
4423
4458
|
});
|
|
4424
4459
|
autoGuard(focusedIndex, allNodes.length, +1, allNodes);
|
|
@@ -4451,7 +4486,11 @@ var FocusWatcher = function FocusWatcher() {
|
|
|
4451
4486
|
process.env.NODE_ENV !== "production" ? {
|
|
4452
4487
|
children: PropTypes.node.isRequired
|
|
4453
4488
|
} : {};
|
|
4489
|
+
var onWindowFocus = function onWindowFocus() {
|
|
4490
|
+
windowFocused = true;
|
|
4491
|
+
};
|
|
4454
4492
|
var onWindowBlur = function onWindowBlur() {
|
|
4493
|
+
windowFocused = false;
|
|
4455
4494
|
focusWasOutsideWindow = 'just';
|
|
4456
4495
|
deferAction(function () {
|
|
4457
4496
|
focusWasOutsideWindow = 'meanwhile';
|
|
@@ -4460,16 +4499,18 @@ var onWindowBlur = function onWindowBlur() {
|
|
|
4460
4499
|
var attachHandler = function attachHandler() {
|
|
4461
4500
|
document.addEventListener('focusin', onTrap);
|
|
4462
4501
|
document.addEventListener('focusout', onBlur);
|
|
4502
|
+
window.addEventListener('focus', onWindowFocus);
|
|
4463
4503
|
window.addEventListener('blur', onWindowBlur);
|
|
4464
4504
|
};
|
|
4465
4505
|
var detachHandler = function detachHandler() {
|
|
4466
4506
|
document.removeEventListener('focusin', onTrap);
|
|
4467
4507
|
document.removeEventListener('focusout', onBlur);
|
|
4508
|
+
window.removeEventListener('focus', onWindowFocus);
|
|
4468
4509
|
window.removeEventListener('blur', onWindowBlur);
|
|
4469
4510
|
};
|
|
4470
4511
|
function reducePropsToState(propsList) {
|
|
4471
|
-
return propsList.filter(function (
|
|
4472
|
-
var disabled =
|
|
4512
|
+
return propsList.filter(function (_ref6) {
|
|
4513
|
+
var disabled = _ref6.disabled;
|
|
4473
4514
|
return !disabled;
|
|
4474
4515
|
});
|
|
4475
4516
|
}
|
|
@@ -4492,8 +4533,8 @@ function handleStateChangeOnClient(traps) {
|
|
|
4492
4533
|
lastActiveTrap = trap;
|
|
4493
4534
|
if (lastTrap && !sameTrap) {
|
|
4494
4535
|
lastTrap.onDeactivation();
|
|
4495
|
-
if (!traps.filter(function (
|
|
4496
|
-
var id =
|
|
4536
|
+
if (!traps.filter(function (_ref7) {
|
|
4537
|
+
var id = _ref7.id;
|
|
4497
4538
|
return id === lastTrap.id;
|
|
4498
4539
|
}).length) {
|
|
4499
4540
|
lastTrap.returnFocus(!trap);
|
|
@@ -7435,7 +7476,7 @@ var Checkbox = function Checkbox(_ref) {
|
|
|
7435
7476
|
}, [checked]);
|
|
7436
7477
|
var handleChange = useCallback(function (event) {
|
|
7437
7478
|
if (typeof checked === 'undefined') setIsChecked(event.currentTarget.checked);
|
|
7438
|
-
onChange
|
|
7479
|
+
onChange === null || onChange === void 0 || onChange(event);
|
|
7439
7480
|
}, [onChange, checked]);
|
|
7440
7481
|
return /*#__PURE__*/React__default.createElement("label", {
|
|
7441
7482
|
htmlFor: id,
|
|
@@ -7535,10 +7576,10 @@ var ColorSwatch = function ColorSwatch(_ref) {
|
|
|
7535
7576
|
title = _ref.title,
|
|
7536
7577
|
rest = _objectWithoutProperties(_ref, _excluded$u);
|
|
7537
7578
|
var handleClick = useCallback(function (_event) {
|
|
7538
|
-
onClick
|
|
7579
|
+
onClick === null || onClick === void 0 || onClick(color, title);
|
|
7539
7580
|
}, [color, title, onClick]);
|
|
7540
7581
|
var handleMouseEnter = useCallback(function (_event) {
|
|
7541
|
-
onMouseEnter
|
|
7582
|
+
onMouseEnter === null || onMouseEnter === void 0 || onMouseEnter(color, title);
|
|
7542
7583
|
}, [color, title, onMouseEnter]);
|
|
7543
7584
|
var backgroundColor = (_SKU_COLORS = SKU_COLORS[color]) !== null && _SKU_COLORS !== void 0 ? _SKU_COLORS : color;
|
|
7544
7585
|
var isWhite = !backgroundUrl && (!backgroundColor.startsWith('#') || backgroundColor.toLowerCase() === '#fff' || backgroundColor.toLowerCase() === '#ffffff');
|
|
@@ -10539,7 +10580,7 @@ var SelectOption = function SelectOption(_ref) {
|
|
|
10539
10580
|
var ref = useRef(null);
|
|
10540
10581
|
var handleClick = useCallback(function (event) {
|
|
10541
10582
|
event.preventDefault();
|
|
10542
|
-
!option.disabled
|
|
10583
|
+
if (!option.disabled) onClick(option);
|
|
10543
10584
|
}, [onClick, option]);
|
|
10544
10585
|
useEffect(function () {
|
|
10545
10586
|
if (active && ref.current) {
|
|
@@ -10601,11 +10642,12 @@ var SelectOptions = function SelectOptions(_ref) {
|
|
|
10601
10642
|
var ref = useRef(null);
|
|
10602
10643
|
useEffect(function () {
|
|
10603
10644
|
if (autoFocus) {
|
|
10604
|
-
|
|
10645
|
+
var _ref$current;
|
|
10646
|
+
(_ref$current = ref.current) === null || _ref$current === void 0 || _ref$current.focus();
|
|
10605
10647
|
}
|
|
10606
10648
|
}, [autoFocus]);
|
|
10607
10649
|
useUpdateEffect(function () {
|
|
10608
|
-
onFocus
|
|
10650
|
+
if (activeOption) onFocus === null || onFocus === void 0 || onFocus(activeOption);
|
|
10609
10651
|
}, [activeOption, onFocus]);
|
|
10610
10652
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
10611
10653
|
className: classNames('SelectOptions', className)
|
|
@@ -10728,7 +10770,7 @@ var useSelect = function useSelect(_ref) {
|
|
|
10728
10770
|
};
|
|
10729
10771
|
}, [handleKeyDown]);
|
|
10730
10772
|
useUpdateEffect(function () {
|
|
10731
|
-
value
|
|
10773
|
+
if (value) dispatch({
|
|
10732
10774
|
type: 'SELECT',
|
|
10733
10775
|
payload: {
|
|
10734
10776
|
value: value
|
|
@@ -10801,7 +10843,7 @@ var Select = function Select(_ref) {
|
|
|
10801
10843
|
});
|
|
10802
10844
|
}, [Mode, dispatch, state]);
|
|
10803
10845
|
var handleAutofill = useCallback(function (value) {
|
|
10804
|
-
value
|
|
10846
|
+
if (value) dispatch({
|
|
10805
10847
|
type: 'SELECT',
|
|
10806
10848
|
payload: {
|
|
10807
10849
|
value: value
|
|
@@ -10991,7 +11033,7 @@ var MultiSelect = function MultiSelect(_ref) {
|
|
|
10991
11033
|
});
|
|
10992
11034
|
}, [Mode, dispatch, state]);
|
|
10993
11035
|
useEffect(function () {
|
|
10994
|
-
onChange
|
|
11036
|
+
onChange === null || onChange === void 0 || onChange(values);
|
|
10995
11037
|
}, [onChange, values]);
|
|
10996
11038
|
return /*#__PURE__*/React__default.createElement("div", _extends$1({
|
|
10997
11039
|
id: idRef ? "MultiSelect--".concat(idRef) : undefined,
|
|
@@ -11875,7 +11917,7 @@ var Popover = function Popover(_ref) {
|
|
|
11875
11917
|
}, [smoothTransitioning]);
|
|
11876
11918
|
var handleMouseEnter = useCallback(function () {
|
|
11877
11919
|
if (!open) {
|
|
11878
|
-
timeout.current
|
|
11920
|
+
if (timeout.current) clearTimeout(timeout.current);
|
|
11879
11921
|
handleOpen();
|
|
11880
11922
|
}
|
|
11881
11923
|
}, [handleOpen, open]);
|
|
@@ -11919,7 +11961,11 @@ var Popover = function Popover(_ref) {
|
|
|
11919
11961
|
}, [handleClose, mode, smoothTransitioning]);
|
|
11920
11962
|
useEffect(function () {
|
|
11921
11963
|
if (open === undefined) return;
|
|
11922
|
-
|
|
11964
|
+
if (open) {
|
|
11965
|
+
handleOpen();
|
|
11966
|
+
} else {
|
|
11967
|
+
handleClose();
|
|
11968
|
+
}
|
|
11923
11969
|
}, [handleClose, handleOpen, open]);
|
|
11924
11970
|
var isOpen = mode === Mode.AutoOpen || mode === Mode.Opening || mode === Mode.Open || mode === Mode.Closing;
|
|
11925
11971
|
return /*#__PURE__*/React__default.createElement("div", _extends$1({
|