@moda/om 21.1.1 → 21.2.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.
Files changed (32) hide show
  1. package/dist/index.cjs.js +46 -13
  2. package/dist/index.cjs.js.map +1 -1
  3. package/dist/index.esm.js +46 -13
  4. package/dist/index.esm.js.map +1 -1
  5. package/dist/src/components/Select/Select.d.ts +6 -0
  6. package/dist/src/components/Select/Select.stories.d.ts +1 -0
  7. package/dist/src/components/Select/SelectOptions.d.ts +2 -1
  8. package/dist/styles.css +1 -1
  9. package/package.json +42 -44
  10. package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +3 -3
  11. package/src/components/Breakpoint/Breakpoint.stories.tsx +1 -1
  12. package/src/components/Button/Button.stories.tsx +1 -1
  13. package/src/components/Button/Button.test.tsx +1 -1
  14. package/src/components/Checkbox/Checkbox.test.tsx +2 -2
  15. package/src/components/Clickable/Clickable.stories.tsx +1 -1
  16. package/src/components/ColorSwatch/ColorSwatch.stories.tsx +1 -1
  17. package/src/components/ControlLink/ControlLink.stories.tsx +1 -1
  18. package/src/components/Field/Field.stories.tsx +1 -1
  19. package/src/components/Modal/Modal.test.tsx +4 -4
  20. package/src/components/Paginator/Paginator.stories.tsx +1 -1
  21. package/src/components/SearchInput/SearchInput.stories.tsx +1 -1
  22. package/src/components/Select/Select.stories.tsx +34 -26
  23. package/src/components/Select/Select.test.tsx +2 -2
  24. package/src/components/Select/Select.tsx +5 -0
  25. package/src/components/Select/SelectOptions.scss +7 -0
  26. package/src/components/Select/SelectOptions.tsx +14 -1
  27. package/src/components/SelectableButton/SelectableButton.stories.tsx +1 -1
  28. package/src/components/Tag/Tag.stories.tsx +1 -1
  29. package/src/components/Tag/Tag.test.tsx +1 -1
  30. package/src/components/Toast/Toast.stories.tsx +1 -1
  31. package/src/components/Toast/Toast.test.tsx +1 -1
  32. package/src/hooks/useKeyboardListNavigation.spec.ts +4 -4
package/dist/index.esm.js CHANGED
@@ -12,7 +12,11 @@ function getAugmentedNamespace(n) {
12
12
  var f = n.default;
13
13
  if (typeof f == "function") {
14
14
  var a = function a () {
15
- if (this instanceof a) {
15
+ var isInstance = false;
16
+ try {
17
+ isInstance = this instanceof a;
18
+ } catch {}
19
+ if (isInstance) {
16
20
  return Reflect.construct(f, arguments, this.constructor);
17
21
  }
18
22
  return f.apply(this, arguments);
@@ -1677,13 +1681,14 @@ var RemoveScroll = /*#__PURE__*/React.forwardRef(function (props, parentRef) {
1677
1681
  enabled = props.enabled,
1678
1682
  shards = props.shards,
1679
1683
  sideCar = props.sideCar,
1684
+ noRelative = props.noRelative,
1680
1685
  noIsolation = props.noIsolation,
1681
1686
  inert = props.inert,
1682
1687
  allowPinchZoom = props.allowPinchZoom,
1683
1688
  _b = props.as,
1684
1689
  Container = _b === void 0 ? 'div' : _b,
1685
1690
  gapMode = props.gapMode,
1686
- rest = __rest$a(props, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noIsolation", "inert", "allowPinchZoom", "as", "gapMode"]);
1691
+ rest = __rest$a(props, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noRelative", "noIsolation", "inert", "allowPinchZoom", "as", "gapMode"]);
1687
1692
  var SideCar = sideCar;
1688
1693
  var containerRef = useMergeRefs([ref, parentRef]);
1689
1694
  var containerProps = __assign$a(__assign$a({}, rest), callbacks);
@@ -1691,6 +1696,7 @@ var RemoveScroll = /*#__PURE__*/React.forwardRef(function (props, parentRef) {
1691
1696
  sideCar: effectCar$1,
1692
1697
  removeScrollBar: removeScrollBar,
1693
1698
  shards: shards,
1699
+ noRelative: noRelative,
1694
1700
  noIsolation: noIsolation,
1695
1701
  inert: inert,
1696
1702
  setCallbacks: setCallbacks,
@@ -4765,6 +4771,9 @@ var handleScroll = function handleScroll(axis, endTarget, event, sourceDelta, no
4765
4771
  var availableScroll = 0;
4766
4772
  var availableScrollTop = 0;
4767
4773
  do {
4774
+ if (!target) {
4775
+ break;
4776
+ }
4768
4777
  var _a = getScrollVariables(axis, target),
4769
4778
  position = _a[0],
4770
4779
  scroll_1 = _a[1],
@@ -4776,11 +4785,10 @@ var handleScroll = function handleScroll(axis, endTarget, event, sourceDelta, no
4776
4785
  availableScrollTop += position;
4777
4786
  }
4778
4787
  }
4779
- if (target instanceof ShadowRoot) {
4780
- target = target.host;
4781
- } else {
4782
- target = target.parentNode;
4783
- }
4788
+ var parent_1 = target.parentNode;
4789
+ // we will "bubble" from ShadowDom in case we are, or just to the parent in normal case
4790
+ // this is the same logic used in focus-lock
4791
+ target = parent_1 && parent_1.nodeType === Node.DOCUMENT_FRAGMENT_NODE ? parent_1.host : parent_1;
4784
4792
  } while (
4785
4793
  // portaled content
4786
4794
  !targetInLock && target !== document.body ||
@@ -4955,6 +4963,7 @@ function RemoveScrollSideCar(props) {
4955
4963
  return /*#__PURE__*/React.createElement(React.Fragment, null, inert ? /*#__PURE__*/React.createElement(Style, {
4956
4964
  styles: generateStyle(id)
4957
4965
  }) : null, removeScrollBar ? /*#__PURE__*/React.createElement(RemoveScrollBar, {
4966
+ noRelative: props.noRelative,
4958
4967
  gapMode: props.gapMode
4959
4968
  }) : null);
4960
4969
  }
@@ -6319,6 +6328,23 @@ function _filter(fn, list) {
6319
6328
  return result;
6320
6329
  }
6321
6330
 
6331
+ function _filterMap(fn, map) {
6332
+ var result = new Map();
6333
+ var iterator = map.entries();
6334
+ var current = iterator.next();
6335
+ while (!current.done) {
6336
+ if (fn(current.value[1])) {
6337
+ result.set(current.value[0], current.value[1]);
6338
+ }
6339
+ current = iterator.next();
6340
+ }
6341
+ return result;
6342
+ }
6343
+
6344
+ function _isMap(x) {
6345
+ return Object.prototype.toString.call(x) === '[object Map]';
6346
+ }
6347
+
6322
6348
  function _isObject(x) {
6323
6349
  return Object.prototype.toString.call(x) === '[object Object]';
6324
6350
  }
@@ -6344,7 +6370,7 @@ function _xfilter(f) {
6344
6370
  /**
6345
6371
  * Takes a predicate and a `Filterable`, and returns a new filterable of the
6346
6372
  * same type containing the members of the given filterable which satisfy the
6347
- * given predicate. Filterable objects include plain objects or any object
6373
+ * given predicate. Filterable objects include plain objects, Maps, or any object
6348
6374
  * that has a filter method such as `Array`.
6349
6375
  *
6350
6376
  * Dispatches to the `filter` method of the second argument, if present.
@@ -6375,7 +6401,7 @@ var filter = /*#__PURE__*/_curry2(/*#__PURE__*/_dispatchable(['fantasy-land/filt
6375
6401
  acc[key] = filterable[key];
6376
6402
  }
6377
6403
  return acc;
6378
- }, {}, keys(filterable)) :
6404
+ }, {}, keys(filterable)) : _isMap(filterable) ? _filterMap(pred, filterable) :
6379
6405
  // else
6380
6406
  _filter(pred, filterable);
6381
6407
  }));
@@ -10537,7 +10563,7 @@ var SelectOption = function SelectOption(_ref) {
10537
10563
  }), label);
10538
10564
  };
10539
10565
 
10540
- var _excluded$k = ["idRef", "searchable", "autoFocus", "options", "selectedOption", "onSelect", "onFocus", "className", "dataTestId"];
10566
+ var _excluded$k = ["idRef", "searchable", "autoFocus", "options", "selectedOption", "onSelect", "onFocus", "className", "dataTestId", "extraOption"];
10541
10567
  var SelectOptions = function SelectOptions(_ref) {
10542
10568
  var idRef = _ref.idRef,
10543
10569
  searchable = _ref.searchable,
@@ -10549,6 +10575,7 @@ var SelectOptions = function SelectOptions(_ref) {
10549
10575
  onFocus = _ref.onFocus,
10550
10576
  className = _ref.className,
10551
10577
  dataTestId = _ref.dataTestId,
10578
+ extraOption = _ref.extraOption,
10552
10579
  rest = _objectWithoutProperties(_ref, _excluded$k);
10553
10580
  var _useState = useState(''),
10554
10581
  _useState2 = _slicedToArray(_useState, 2),
@@ -10608,7 +10635,11 @@ var SelectOptions = function SelectOptions(_ref) {
10608
10635
  selected: (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.value) === option.value,
10609
10636
  onClick: onSelect
10610
10637
  });
10611
- })), options.length === 0 && /*#__PURE__*/React__default.createElement(Text, {
10638
+ }), extraOption && /*#__PURE__*/React__default.createElement(ControlLink, {
10639
+ className: "SelectOptions__extra-option",
10640
+ disabled: extraOption.disabled,
10641
+ onClick: extraOption.callback
10642
+ }, extraOption.label)), options.length === 0 && /*#__PURE__*/React__default.createElement(Text, {
10612
10643
  className: "SelectOptions__none",
10613
10644
  color: "cement"
10614
10645
  }, "Nothing found"));
@@ -10717,7 +10748,7 @@ var useSelect = function useSelect(_ref) {
10717
10748
  };
10718
10749
  };
10719
10750
 
10720
- var _excluded$j = ["allowAutoFill", "autoSelect", "className", "defaultValue", "disabled", "dropDirection", "error", "idRef", "label", "name", "onChange", "options", "placeholder", "searchable", "shiftIconLeftwards", "value", "dataTestId", "colorSwatch"];
10751
+ var _excluded$j = ["allowAutoFill", "autoSelect", "className", "defaultValue", "disabled", "dropDirection", "error", "idRef", "label", "name", "onChange", "options", "placeholder", "searchable", "shiftIconLeftwards", "value", "dataTestId", "colorSwatch", "extraOption"];
10721
10752
  var Select = function Select(_ref) {
10722
10753
  var _ref2;
10723
10754
  var _ref$allowAutoFill = _ref.allowAutoFill,
@@ -10743,6 +10774,7 @@ var Select = function Select(_ref) {
10743
10774
  value = _ref.value,
10744
10775
  dataTestId = _ref.dataTestId,
10745
10776
  colorSwatch = _ref.colorSwatch,
10777
+ extraOption = _ref.extraOption,
10746
10778
  rest = _objectWithoutProperties(_ref, _excluded$j);
10747
10779
  var _useSelect = useSelect({
10748
10780
  value: value,
@@ -10839,7 +10871,8 @@ var Select = function Select(_ref) {
10839
10871
  options: options,
10840
10872
  onSelect: handleSelect,
10841
10873
  onFocus: handleFocus,
10842
- selectedOption: selected
10874
+ selectedOption: selected,
10875
+ extraOption: extraOption
10843
10876
  })), allowAutoFill && /*#__PURE__*/React__default.createElement("input", {
10844
10877
  className: "Select__hidden-field",
10845
10878
  name: name,