@moda/om 19.8.2 → 20.0.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.
Files changed (79) hide show
  1. package/README.md +1 -2
  2. package/dist/index.cjs.js +72 -26
  3. package/dist/index.cjs.js.map +1 -1
  4. package/dist/index.esm.js +72 -26
  5. package/dist/index.esm.js.map +1 -1
  6. package/dist/styles.css +1 -1
  7. package/index.scss +1 -0
  8. package/package.json +65 -62
  9. package/src/components/AspectRatioBox/AspectRatioBox.scss +1 -1
  10. package/src/components/Badge/Badge.scss +17 -17
  11. package/src/components/Breadcrumbs/Breadcrumb/Breadcrumb.scss +5 -5
  12. package/src/components/Breadcrumbs/Breadcrumbs.scss +2 -2
  13. package/src/components/Breakpoint/Breakpoint.scss +9 -7
  14. package/src/components/Button/Button.scss +45 -44
  15. package/src/components/Checkbox/Checkbox.scss +11 -11
  16. package/src/components/Checkbox/Checkbox.tsx +1 -1
  17. package/src/components/Clickable/Clickable.scss +3 -3
  18. package/src/components/ColorSwatch/ColorSwatch.scss +9 -9
  19. package/src/components/ColorSwatch/ColorSwatch.tsx +2 -2
  20. package/src/components/Constrain/Constrain.scss +9 -8
  21. package/src/components/Constrain/ExceedConstrain.scss +7 -7
  22. package/src/components/ControlLink/ControlLink.scss +6 -6
  23. package/src/components/DefinitionList/DefinitionList.scss +5 -5
  24. package/src/components/Dialog/Dialog.scss +4 -4
  25. package/src/components/Divider/Divider.scss +5 -5
  26. package/src/components/Expandable/Expandable.scss +17 -17
  27. package/src/components/Field/Field.scss +7 -7
  28. package/src/components/Label/Label.scss +4 -4
  29. package/src/components/Loading/Loading.scss +4 -4
  30. package/src/components/LoadingBalls/LoadingBalls.scss +2 -2
  31. package/src/components/LoadingShapes/LoadingShapes.scss +2 -2
  32. package/src/components/Modal/Modal.scss +1 -1
  33. package/src/components/ModalOverlay/ModalOverlay.scss +6 -6
  34. package/src/components/Overlay/Overlay.scss +4 -4
  35. package/src/components/Paginator/Paginator.scss +10 -10
  36. package/src/components/PasswordInput/PasswordInput.scss +4 -4
  37. package/src/components/Popover/Popover.scss +9 -9
  38. package/src/components/Popover/Popover.tsx +6 -2
  39. package/src/components/PromoBanner/PromoBanner.scss +9 -9
  40. package/src/components/RadioButton/RadioButton.scss +14 -14
  41. package/src/components/SearchInput/SearchInput.scss +4 -4
  42. package/src/components/Select/MultiSelect.scss +14 -14
  43. package/src/components/Select/MultiSelect.tsx +1 -1
  44. package/src/components/Select/Select.scss +25 -25
  45. package/src/components/Select/Select.tsx +1 -1
  46. package/src/components/Select/SelectOption.scss +7 -7
  47. package/src/components/Select/SelectOption.tsx +1 -1
  48. package/src/components/Select/SelectOptions.scss +8 -8
  49. package/src/components/Select/SelectOptions.tsx +2 -2
  50. package/src/components/Select/useSelect.ts +1 -1
  51. package/src/components/SelectableButton/SelectableButton.scss +13 -13
  52. package/src/components/SlidingPane/SlidingPane.scss +7 -7
  53. package/src/components/Stack/Stack.scss +6 -4
  54. package/src/components/Tabs/Tab.scss +6 -6
  55. package/src/components/Tabs/TabList.scss +3 -3
  56. package/src/components/Tabs/TabPanels.scss +2 -2
  57. package/src/components/Tag/Tag.scss +8 -8
  58. package/src/components/Text/Text.scss +4 -3
  59. package/src/components/TextInput/TextInput.scss +2 -2
  60. package/src/components/Textarea/Textarea.scss +3 -3
  61. package/src/components/Toast/Toast.scss +6 -6
  62. package/src/components/VerticalDivider/VerticalDivider.scss +3 -3
  63. package/src/index.scss +3 -3
  64. package/src/mixins/_mixins.scss +7 -7
  65. package/src/mixins/font-smoothing/_font-smoothing.scss +0 -2
  66. package/src/mixins/font-smoothing/font-smoothing.stories.scss +3 -3
  67. package/src/mixins/global-styles/_global-styles.scss +6 -5
  68. package/src/mixins/input-styles/_input-styles.scss +14 -12
  69. package/src/mixins/overflow-scroll/_overflow-scroll.scss +0 -2
  70. package/src/mixins/overflow-scroll/overflow-scroll.stories.scss +3 -3
  71. package/src/mixins/stack/_stack.scss +3 -3
  72. package/src/mixins/stack/stack.stories.scss +3 -3
  73. package/src/mixins/thin-underline/_thin-underline.scss +0 -2
  74. package/src/mixins/thin-underline/thin-underline.stories.scss +2 -2
  75. package/src/mixins/visually-hidden/_visually-hidden.scss +0 -2
  76. package/src/mixins/visually-hidden/visually-hidden.stories.scss +2 -2
  77. package/src/utilities/States/State.scss +4 -4
  78. package/src/utilities/States/States.scss +2 -2
  79. package/src/utilities/States/StatesProps.scss +8 -8
package/README.md CHANGED
@@ -70,7 +70,6 @@ Once you want to commit something, `git add` it then run the commitizen CLI. If
70
70
  When you're happy push to a feature branch and once the code is in `main`, semantic release will detect how to version it and automatically publish it to NPM.
71
71
 
72
72
  - **Netlify deploy config** is located here: https://app.netlify.com/sites/moda-om-storybook/configuration/deploys
73
-
74
73
  - **Netlify site overview**: https://app.netlify.com/sites/moda-om-storybook/overview
75
74
 
76
75
  (settings specified in netlify.toml override any corresponding settings in the Netlify UI)
@@ -103,7 +102,7 @@ Import and use the mixins/functions library:
103
102
  @import '~@moda/om';
104
103
 
105
104
  body {
106
- @include text(body1);
105
+ @include om.text(body1);
107
106
  padding: spacing(2, 4);
108
107
  }
109
108
  ```
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 || focusWasOutside(crossFrame) || !isFreeFocus() || !lastActiveFocus && autoFocus) {
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 (_ref) {
4432
- var node = _ref.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 (_ref2) {
4437
- var guard = _ref2.guard,
4438
- node = _ref2.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 (_ref3) {
4441
- var node = _ref3.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 (_ref5) {
4492
- var disabled = _ref5.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 (_ref6) {
4516
- var id = _ref6.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 && onChange(event);
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 && onClick(color, title);
7599
+ onClick === null || onClick === void 0 || onClick(color, title);
7559
7600
  }, [color, title, onClick]);
7560
7601
  var handleMouseEnter = React.useCallback(function (_event) {
7561
- onMouseEnter && onMouseEnter(color, title);
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 && onClick(option);
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
- ref.current && ref.current.focus();
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 && activeOption && onFocus(activeOption);
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 && dispatch({
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 && dispatch({
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 && onChange(values);
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 && clearTimeout(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
- open ? handleOpen() : handleClose();
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({