@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.cjs.js CHANGED
@@ -32,7 +32,11 @@ function getAugmentedNamespace(n) {
32
32
  var f = n.default;
33
33
  if (typeof f == "function") {
34
34
  var a = function a () {
35
- if (this instanceof a) {
35
+ var isInstance = false;
36
+ try {
37
+ isInstance = this instanceof a;
38
+ } catch {}
39
+ if (isInstance) {
36
40
  return Reflect.construct(f, arguments, this.constructor);
37
41
  }
38
42
  return f.apply(this, arguments);
@@ -1697,13 +1701,14 @@ var RemoveScroll = /*#__PURE__*/React__namespace.forwardRef(function (props, par
1697
1701
  enabled = props.enabled,
1698
1702
  shards = props.shards,
1699
1703
  sideCar = props.sideCar,
1704
+ noRelative = props.noRelative,
1700
1705
  noIsolation = props.noIsolation,
1701
1706
  inert = props.inert,
1702
1707
  allowPinchZoom = props.allowPinchZoom,
1703
1708
  _b = props.as,
1704
1709
  Container = _b === void 0 ? 'div' : _b,
1705
1710
  gapMode = props.gapMode,
1706
- rest = __rest$a(props, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noIsolation", "inert", "allowPinchZoom", "as", "gapMode"]);
1711
+ rest = __rest$a(props, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noRelative", "noIsolation", "inert", "allowPinchZoom", "as", "gapMode"]);
1707
1712
  var SideCar = sideCar;
1708
1713
  var containerRef = useMergeRefs([ref, parentRef]);
1709
1714
  var containerProps = __assign$a(__assign$a({}, rest), callbacks);
@@ -1711,6 +1716,7 @@ var RemoveScroll = /*#__PURE__*/React__namespace.forwardRef(function (props, par
1711
1716
  sideCar: effectCar$1,
1712
1717
  removeScrollBar: removeScrollBar,
1713
1718
  shards: shards,
1719
+ noRelative: noRelative,
1714
1720
  noIsolation: noIsolation,
1715
1721
  inert: inert,
1716
1722
  setCallbacks: setCallbacks,
@@ -4785,6 +4791,9 @@ var handleScroll = function handleScroll(axis, endTarget, event, sourceDelta, no
4785
4791
  var availableScroll = 0;
4786
4792
  var availableScrollTop = 0;
4787
4793
  do {
4794
+ if (!target) {
4795
+ break;
4796
+ }
4788
4797
  var _a = getScrollVariables(axis, target),
4789
4798
  position = _a[0],
4790
4799
  scroll_1 = _a[1],
@@ -4796,11 +4805,10 @@ var handleScroll = function handleScroll(axis, endTarget, event, sourceDelta, no
4796
4805
  availableScrollTop += position;
4797
4806
  }
4798
4807
  }
4799
- if (target instanceof ShadowRoot) {
4800
- target = target.host;
4801
- } else {
4802
- target = target.parentNode;
4803
- }
4808
+ var parent_1 = target.parentNode;
4809
+ // we will "bubble" from ShadowDom in case we are, or just to the parent in normal case
4810
+ // this is the same logic used in focus-lock
4811
+ target = parent_1 && parent_1.nodeType === Node.DOCUMENT_FRAGMENT_NODE ? parent_1.host : parent_1;
4804
4812
  } while (
4805
4813
  // portaled content
4806
4814
  !targetInLock && target !== document.body ||
@@ -4975,6 +4983,7 @@ function RemoveScrollSideCar(props) {
4975
4983
  return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, inert ? /*#__PURE__*/React__namespace.createElement(Style, {
4976
4984
  styles: generateStyle(id)
4977
4985
  }) : null, removeScrollBar ? /*#__PURE__*/React__namespace.createElement(RemoveScrollBar, {
4986
+ noRelative: props.noRelative,
4978
4987
  gapMode: props.gapMode
4979
4988
  }) : null);
4980
4989
  }
@@ -6339,6 +6348,23 @@ function _filter(fn, list) {
6339
6348
  return result;
6340
6349
  }
6341
6350
 
6351
+ function _filterMap(fn, map) {
6352
+ var result = new Map();
6353
+ var iterator = map.entries();
6354
+ var current = iterator.next();
6355
+ while (!current.done) {
6356
+ if (fn(current.value[1])) {
6357
+ result.set(current.value[0], current.value[1]);
6358
+ }
6359
+ current = iterator.next();
6360
+ }
6361
+ return result;
6362
+ }
6363
+
6364
+ function _isMap(x) {
6365
+ return Object.prototype.toString.call(x) === '[object Map]';
6366
+ }
6367
+
6342
6368
  function _isObject(x) {
6343
6369
  return Object.prototype.toString.call(x) === '[object Object]';
6344
6370
  }
@@ -6364,7 +6390,7 @@ function _xfilter(f) {
6364
6390
  /**
6365
6391
  * Takes a predicate and a `Filterable`, and returns a new filterable of the
6366
6392
  * same type containing the members of the given filterable which satisfy the
6367
- * given predicate. Filterable objects include plain objects or any object
6393
+ * given predicate. Filterable objects include plain objects, Maps, or any object
6368
6394
  * that has a filter method such as `Array`.
6369
6395
  *
6370
6396
  * Dispatches to the `filter` method of the second argument, if present.
@@ -6395,7 +6421,7 @@ var filter = /*#__PURE__*/_curry2(/*#__PURE__*/_dispatchable(['fantasy-land/filt
6395
6421
  acc[key] = filterable[key];
6396
6422
  }
6397
6423
  return acc;
6398
- }, {}, keys(filterable)) :
6424
+ }, {}, keys(filterable)) : _isMap(filterable) ? _filterMap(pred, filterable) :
6399
6425
  // else
6400
6426
  _filter(pred, filterable);
6401
6427
  }));
@@ -10557,7 +10583,7 @@ var SelectOption = function SelectOption(_ref) {
10557
10583
  }), label);
10558
10584
  };
10559
10585
 
10560
- var _excluded$k = ["idRef", "searchable", "autoFocus", "options", "selectedOption", "onSelect", "onFocus", "className", "dataTestId"];
10586
+ var _excluded$k = ["idRef", "searchable", "autoFocus", "options", "selectedOption", "onSelect", "onFocus", "className", "dataTestId", "extraOption"];
10561
10587
  var SelectOptions = function SelectOptions(_ref) {
10562
10588
  var idRef = _ref.idRef,
10563
10589
  searchable = _ref.searchable,
@@ -10569,6 +10595,7 @@ var SelectOptions = function SelectOptions(_ref) {
10569
10595
  onFocus = _ref.onFocus,
10570
10596
  className = _ref.className,
10571
10597
  dataTestId = _ref.dataTestId,
10598
+ extraOption = _ref.extraOption,
10572
10599
  rest = _objectWithoutProperties(_ref, _excluded$k);
10573
10600
  var _useState = React.useState(''),
10574
10601
  _useState2 = _slicedToArray(_useState, 2),
@@ -10628,7 +10655,11 @@ var SelectOptions = function SelectOptions(_ref) {
10628
10655
  selected: (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.value) === option.value,
10629
10656
  onClick: onSelect
10630
10657
  });
10631
- })), options.length === 0 && /*#__PURE__*/React.createElement(Text, {
10658
+ }), extraOption && /*#__PURE__*/React.createElement(ControlLink, {
10659
+ className: "SelectOptions__extra-option",
10660
+ disabled: extraOption.disabled,
10661
+ onClick: extraOption.callback
10662
+ }, extraOption.label)), options.length === 0 && /*#__PURE__*/React.createElement(Text, {
10632
10663
  className: "SelectOptions__none",
10633
10664
  color: "cement"
10634
10665
  }, "Nothing found"));
@@ -10737,7 +10768,7 @@ var useSelect = function useSelect(_ref) {
10737
10768
  };
10738
10769
  };
10739
10770
 
10740
- var _excluded$j = ["allowAutoFill", "autoSelect", "className", "defaultValue", "disabled", "dropDirection", "error", "idRef", "label", "name", "onChange", "options", "placeholder", "searchable", "shiftIconLeftwards", "value", "dataTestId", "colorSwatch"];
10771
+ var _excluded$j = ["allowAutoFill", "autoSelect", "className", "defaultValue", "disabled", "dropDirection", "error", "idRef", "label", "name", "onChange", "options", "placeholder", "searchable", "shiftIconLeftwards", "value", "dataTestId", "colorSwatch", "extraOption"];
10741
10772
  var Select = function Select(_ref) {
10742
10773
  var _ref2;
10743
10774
  var _ref$allowAutoFill = _ref.allowAutoFill,
@@ -10763,6 +10794,7 @@ var Select = function Select(_ref) {
10763
10794
  value = _ref.value,
10764
10795
  dataTestId = _ref.dataTestId,
10765
10796
  colorSwatch = _ref.colorSwatch,
10797
+ extraOption = _ref.extraOption,
10766
10798
  rest = _objectWithoutProperties(_ref, _excluded$j);
10767
10799
  var _useSelect = useSelect({
10768
10800
  value: value,
@@ -10859,7 +10891,8 @@ var Select = function Select(_ref) {
10859
10891
  options: options,
10860
10892
  onSelect: handleSelect,
10861
10893
  onFocus: handleFocus,
10862
- selectedOption: selected
10894
+ selectedOption: selected,
10895
+ extraOption: extraOption
10863
10896
  })), allowAutoFill && /*#__PURE__*/React.createElement("input", {
10864
10897
  className: "Select__hidden-field",
10865
10898
  name: name,