@moda/om 19.8.1 → 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/dist/styles.css +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.scss +2 -3
- package/src/components/Select/Select.stories.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.cjs.js
CHANGED
|
@@ -1480,7 +1480,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
1480
1480
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
1481
1481
|
PERFORMANCE OF THIS SOFTWARE.
|
|
1482
1482
|
***************************************************************************** */
|
|
1483
|
-
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
1483
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
1484
1484
|
|
|
1485
1485
|
|
|
1486
1486
|
var __assign$a = function() {
|
|
@@ -3150,7 +3150,8 @@ var FocusLock = /*#__PURE__*/React__namespace.forwardRef(function FocusLockUI(pr
|
|
|
3150
3150
|
onActivation: onActivation,
|
|
3151
3151
|
onDeactivation: onDeactivation,
|
|
3152
3152
|
returnFocus: returnFocus,
|
|
3153
|
-
focusOptions: focusOptions
|
|
3153
|
+
focusOptions: focusOptions,
|
|
3154
|
+
noFocusGuards: noFocusGuards
|
|
3154
3155
|
}), /*#__PURE__*/React__namespace.createElement(Container, _extends({
|
|
3155
3156
|
ref: mergedRef
|
|
3156
3157
|
}, lockProps, {
|
|
@@ -4339,8 +4340,12 @@ var isFreeFocus = function isFreeFocus() {
|
|
|
4339
4340
|
};
|
|
4340
4341
|
var lastActiveTrap = null;
|
|
4341
4342
|
var lastActiveFocus = null;
|
|
4343
|
+
var tryRestoreFocus = function tryRestoreFocus() {
|
|
4344
|
+
return null;
|
|
4345
|
+
};
|
|
4342
4346
|
var lastPortaledElement = null;
|
|
4343
4347
|
var focusWasOutsideWindow = false;
|
|
4348
|
+
var windowFocused = false;
|
|
4344
4349
|
var defaultWhitelist = function defaultWhitelist() {
|
|
4345
4350
|
return true;
|
|
4346
4351
|
};
|
|
@@ -4392,6 +4397,14 @@ var withinHost = function withinHost(activeElement, workingArea) {
|
|
|
4392
4397
|
return checkInHost(activeElement, area, area);
|
|
4393
4398
|
});
|
|
4394
4399
|
};
|
|
4400
|
+
var getNodeFocusables = function getNodeFocusables(nodes) {
|
|
4401
|
+
return getFocusableNodes(nodes, new Map());
|
|
4402
|
+
};
|
|
4403
|
+
var isNotFocusable = function isNotFocusable(node) {
|
|
4404
|
+
return !getNodeFocusables([node.parentNode]).some(function (el) {
|
|
4405
|
+
return el.node === node;
|
|
4406
|
+
});
|
|
4407
|
+
};
|
|
4395
4408
|
var activateTrap = function activateTrap() {
|
|
4396
4409
|
var result = false;
|
|
4397
4410
|
if (lastActiveTrap) {
|
|
@@ -4401,13 +4414,34 @@ var activateTrap = function activateTrap() {
|
|
|
4401
4414
|
autoFocus = _lastActiveTrap.autoFocus,
|
|
4402
4415
|
shards = _lastActiveTrap.shards,
|
|
4403
4416
|
crossFrame = _lastActiveTrap.crossFrame,
|
|
4404
|
-
focusOptions = _lastActiveTrap.focusOptions
|
|
4417
|
+
focusOptions = _lastActiveTrap.focusOptions,
|
|
4418
|
+
noFocusGuards = _lastActiveTrap.noFocusGuards;
|
|
4405
4419
|
var workingNode = observed || lastPortaledElement && lastPortaledElement.portaledElement;
|
|
4420
|
+
if (focusOnBody() && lastActiveFocus) {
|
|
4421
|
+
if (!document.body.contains(lastActiveFocus) || isNotFocusable(lastActiveFocus)) {
|
|
4422
|
+
lastActiveFocus = null;
|
|
4423
|
+
var newTarget = tryRestoreFocus();
|
|
4424
|
+
if (newTarget) {
|
|
4425
|
+
newTarget.focus();
|
|
4426
|
+
}
|
|
4427
|
+
}
|
|
4428
|
+
}
|
|
4406
4429
|
var activeElement = document && document.activeElement;
|
|
4407
4430
|
if (workingNode) {
|
|
4408
4431
|
var workingArea = [workingNode].concat(shards.map(extractRef$2).filter(Boolean));
|
|
4432
|
+
var shouldForceRestoreFocus = function shouldForceRestoreFocus() {
|
|
4433
|
+
if (!focusWasOutside(crossFrame) || !noFocusGuards || !lastActiveFocus || windowFocused) {
|
|
4434
|
+
return false;
|
|
4435
|
+
}
|
|
4436
|
+
var nodes = getNodeFocusables(workingArea);
|
|
4437
|
+
var lastIndex = nodes.findIndex(function (_ref) {
|
|
4438
|
+
var node = _ref.node;
|
|
4439
|
+
return node === lastActiveFocus;
|
|
4440
|
+
});
|
|
4441
|
+
return lastIndex === 0 || lastIndex === nodes.length - 1;
|
|
4442
|
+
};
|
|
4409
4443
|
if (!activeElement || focusWhitelisted(activeElement)) {
|
|
4410
|
-
if (persistentFocus ||
|
|
4444
|
+
if (persistentFocus || shouldForceRestoreFocus() || !isFreeFocus() || !lastActiveFocus && autoFocus) {
|
|
4411
4445
|
if (workingNode && !(focusInside(workingArea) || activeElement && withinHost(activeElement, workingArea) || focusIsPortaledPair(activeElement))) {
|
|
4412
4446
|
if (document && !lastActiveFocus && activeElement && !autoFocus) {
|
|
4413
4447
|
if (activeElement.blur) {
|
|
@@ -4423,22 +4457,23 @@ var activateTrap = function activateTrap() {
|
|
|
4423
4457
|
}
|
|
4424
4458
|
focusWasOutsideWindow = false;
|
|
4425
4459
|
lastActiveFocus = document && document.activeElement;
|
|
4460
|
+
tryRestoreFocus = captureFocusRestore(lastActiveFocus);
|
|
4426
4461
|
}
|
|
4427
4462
|
}
|
|
4428
4463
|
if (document && activeElement !== document.activeElement && document.querySelector('[data-focus-auto-guard]')) {
|
|
4429
4464
|
var newActiveElement = document && document.activeElement;
|
|
4430
4465
|
var allNodes = expandFocusableNodes(workingArea);
|
|
4431
|
-
var focusedIndex = allNodes.map(function (
|
|
4432
|
-
var node =
|
|
4466
|
+
var focusedIndex = allNodes.map(function (_ref2) {
|
|
4467
|
+
var node = _ref2.node;
|
|
4433
4468
|
return node;
|
|
4434
4469
|
}).indexOf(newActiveElement);
|
|
4435
4470
|
if (focusedIndex > -1) {
|
|
4436
|
-
allNodes.filter(function (
|
|
4437
|
-
var guard =
|
|
4438
|
-
node =
|
|
4471
|
+
allNodes.filter(function (_ref3) {
|
|
4472
|
+
var guard = _ref3.guard,
|
|
4473
|
+
node = _ref3.node;
|
|
4439
4474
|
return guard && node.dataset.focusAutoGuard;
|
|
4440
|
-
}).forEach(function (
|
|
4441
|
-
var node =
|
|
4475
|
+
}).forEach(function (_ref4) {
|
|
4476
|
+
var node = _ref4.node;
|
|
4442
4477
|
return node.removeAttribute('tabIndex');
|
|
4443
4478
|
});
|
|
4444
4479
|
autoGuard(focusedIndex, allNodes.length, +1, allNodes);
|
|
@@ -4471,7 +4506,11 @@ var FocusWatcher = function FocusWatcher() {
|
|
|
4471
4506
|
process.env.NODE_ENV !== "production" ? {
|
|
4472
4507
|
children: PropTypes.node.isRequired
|
|
4473
4508
|
} : {};
|
|
4509
|
+
var onWindowFocus = function onWindowFocus() {
|
|
4510
|
+
windowFocused = true;
|
|
4511
|
+
};
|
|
4474
4512
|
var onWindowBlur = function onWindowBlur() {
|
|
4513
|
+
windowFocused = false;
|
|
4475
4514
|
focusWasOutsideWindow = 'just';
|
|
4476
4515
|
deferAction(function () {
|
|
4477
4516
|
focusWasOutsideWindow = 'meanwhile';
|
|
@@ -4480,16 +4519,18 @@ var onWindowBlur = function onWindowBlur() {
|
|
|
4480
4519
|
var attachHandler = function attachHandler() {
|
|
4481
4520
|
document.addEventListener('focusin', onTrap);
|
|
4482
4521
|
document.addEventListener('focusout', onBlur);
|
|
4522
|
+
window.addEventListener('focus', onWindowFocus);
|
|
4483
4523
|
window.addEventListener('blur', onWindowBlur);
|
|
4484
4524
|
};
|
|
4485
4525
|
var detachHandler = function detachHandler() {
|
|
4486
4526
|
document.removeEventListener('focusin', onTrap);
|
|
4487
4527
|
document.removeEventListener('focusout', onBlur);
|
|
4528
|
+
window.removeEventListener('focus', onWindowFocus);
|
|
4488
4529
|
window.removeEventListener('blur', onWindowBlur);
|
|
4489
4530
|
};
|
|
4490
4531
|
function reducePropsToState(propsList) {
|
|
4491
|
-
return propsList.filter(function (
|
|
4492
|
-
var disabled =
|
|
4532
|
+
return propsList.filter(function (_ref6) {
|
|
4533
|
+
var disabled = _ref6.disabled;
|
|
4493
4534
|
return !disabled;
|
|
4494
4535
|
});
|
|
4495
4536
|
}
|
|
@@ -4512,8 +4553,8 @@ function handleStateChangeOnClient(traps) {
|
|
|
4512
4553
|
lastActiveTrap = trap;
|
|
4513
4554
|
if (lastTrap && !sameTrap) {
|
|
4514
4555
|
lastTrap.onDeactivation();
|
|
4515
|
-
if (!traps.filter(function (
|
|
4516
|
-
var id =
|
|
4556
|
+
if (!traps.filter(function (_ref7) {
|
|
4557
|
+
var id = _ref7.id;
|
|
4517
4558
|
return id === lastTrap.id;
|
|
4518
4559
|
}).length) {
|
|
4519
4560
|
lastTrap.returnFocus(!trap);
|
|
@@ -7455,7 +7496,7 @@ var Checkbox = function Checkbox(_ref) {
|
|
|
7455
7496
|
}, [checked]);
|
|
7456
7497
|
var handleChange = React.useCallback(function (event) {
|
|
7457
7498
|
if (typeof checked === 'undefined') setIsChecked(event.currentTarget.checked);
|
|
7458
|
-
onChange
|
|
7499
|
+
onChange === null || onChange === void 0 || onChange(event);
|
|
7459
7500
|
}, [onChange, checked]);
|
|
7460
7501
|
return /*#__PURE__*/React.createElement("label", {
|
|
7461
7502
|
htmlFor: id,
|
|
@@ -7555,10 +7596,10 @@ var ColorSwatch = function ColorSwatch(_ref) {
|
|
|
7555
7596
|
title = _ref.title,
|
|
7556
7597
|
rest = _objectWithoutProperties(_ref, _excluded$u);
|
|
7557
7598
|
var handleClick = React.useCallback(function (_event) {
|
|
7558
|
-
onClick
|
|
7599
|
+
onClick === null || onClick === void 0 || onClick(color, title);
|
|
7559
7600
|
}, [color, title, onClick]);
|
|
7560
7601
|
var handleMouseEnter = React.useCallback(function (_event) {
|
|
7561
|
-
onMouseEnter
|
|
7602
|
+
onMouseEnter === null || onMouseEnter === void 0 || onMouseEnter(color, title);
|
|
7562
7603
|
}, [color, title, onMouseEnter]);
|
|
7563
7604
|
var backgroundColor = (_SKU_COLORS = SKU_COLORS[color]) !== null && _SKU_COLORS !== void 0 ? _SKU_COLORS : color;
|
|
7564
7605
|
var isWhite = !backgroundUrl && (!backgroundColor.startsWith('#') || backgroundColor.toLowerCase() === '#fff' || backgroundColor.toLowerCase() === '#ffffff');
|
|
@@ -10559,7 +10600,7 @@ var SelectOption = function SelectOption(_ref) {
|
|
|
10559
10600
|
var ref = React.useRef(null);
|
|
10560
10601
|
var handleClick = React.useCallback(function (event) {
|
|
10561
10602
|
event.preventDefault();
|
|
10562
|
-
!option.disabled
|
|
10603
|
+
if (!option.disabled) onClick(option);
|
|
10563
10604
|
}, [onClick, option]);
|
|
10564
10605
|
React.useEffect(function () {
|
|
10565
10606
|
if (active && ref.current) {
|
|
@@ -10621,11 +10662,12 @@ var SelectOptions = function SelectOptions(_ref) {
|
|
|
10621
10662
|
var ref = React.useRef(null);
|
|
10622
10663
|
React.useEffect(function () {
|
|
10623
10664
|
if (autoFocus) {
|
|
10624
|
-
|
|
10665
|
+
var _ref$current;
|
|
10666
|
+
(_ref$current = ref.current) === null || _ref$current === void 0 || _ref$current.focus();
|
|
10625
10667
|
}
|
|
10626
10668
|
}, [autoFocus]);
|
|
10627
10669
|
useUpdateEffect(function () {
|
|
10628
|
-
onFocus
|
|
10670
|
+
if (activeOption) onFocus === null || onFocus === void 0 || onFocus(activeOption);
|
|
10629
10671
|
}, [activeOption, onFocus]);
|
|
10630
10672
|
return /*#__PURE__*/React.createElement("div", {
|
|
10631
10673
|
className: classNames('SelectOptions', className)
|
|
@@ -10748,7 +10790,7 @@ var useSelect = function useSelect(_ref) {
|
|
|
10748
10790
|
};
|
|
10749
10791
|
}, [handleKeyDown]);
|
|
10750
10792
|
useUpdateEffect(function () {
|
|
10751
|
-
value
|
|
10793
|
+
if (value) dispatch({
|
|
10752
10794
|
type: 'SELECT',
|
|
10753
10795
|
payload: {
|
|
10754
10796
|
value: value
|
|
@@ -10821,7 +10863,7 @@ var Select = function Select(_ref) {
|
|
|
10821
10863
|
});
|
|
10822
10864
|
}, [Mode, dispatch, state]);
|
|
10823
10865
|
var handleAutofill = React.useCallback(function (value) {
|
|
10824
|
-
value
|
|
10866
|
+
if (value) dispatch({
|
|
10825
10867
|
type: 'SELECT',
|
|
10826
10868
|
payload: {
|
|
10827
10869
|
value: value
|
|
@@ -11011,7 +11053,7 @@ var MultiSelect = function MultiSelect(_ref) {
|
|
|
11011
11053
|
});
|
|
11012
11054
|
}, [Mode, dispatch, state]);
|
|
11013
11055
|
React.useEffect(function () {
|
|
11014
|
-
onChange
|
|
11056
|
+
onChange === null || onChange === void 0 || onChange(values);
|
|
11015
11057
|
}, [onChange, values]);
|
|
11016
11058
|
return /*#__PURE__*/React.createElement("div", _extends$1({
|
|
11017
11059
|
id: idRef ? "MultiSelect--".concat(idRef) : undefined,
|
|
@@ -11895,7 +11937,7 @@ var Popover = function Popover(_ref) {
|
|
|
11895
11937
|
}, [smoothTransitioning]);
|
|
11896
11938
|
var handleMouseEnter = React.useCallback(function () {
|
|
11897
11939
|
if (!open) {
|
|
11898
|
-
timeout.current
|
|
11940
|
+
if (timeout.current) clearTimeout(timeout.current);
|
|
11899
11941
|
handleOpen();
|
|
11900
11942
|
}
|
|
11901
11943
|
}, [handleOpen, open]);
|
|
@@ -11939,7 +11981,11 @@ var Popover = function Popover(_ref) {
|
|
|
11939
11981
|
}, [handleClose, mode, smoothTransitioning]);
|
|
11940
11982
|
React.useEffect(function () {
|
|
11941
11983
|
if (open === undefined) return;
|
|
11942
|
-
|
|
11984
|
+
if (open) {
|
|
11985
|
+
handleOpen();
|
|
11986
|
+
} else {
|
|
11987
|
+
handleClose();
|
|
11988
|
+
}
|
|
11943
11989
|
}, [handleClose, handleOpen, open]);
|
|
11944
11990
|
var isOpen = mode === Mode.AutoOpen || mode === Mode.Opening || mode === Mode.Open || mode === Mode.Closing;
|
|
11945
11991
|
return /*#__PURE__*/React.createElement("div", _extends$1({
|