@moda/om 15.10.0 → 15.11.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/CHANGELOG.md CHANGED
@@ -3,6 +3,34 @@
3
3
  All notable changes to this project will be documented in this file. See
4
4
  [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [15.11.0](https://github.com/ModaOperandi/om/compare/v15.10.3...v15.11.0) (2021-12-10)
7
+
8
+
9
+ ### Features
10
+
11
+ * **popover:** adds popover smooth animation ([#2256](https://github.com/ModaOperandi/om/issues/2256)) ([ad7562f](https://github.com/ModaOperandi/om/commit/ad7562f3256ba04b7b80a761c044ac17656f6588))
12
+
13
+ ## [15.10.3](https://github.com/ModaOperandi/om/compare/v15.10.2...v15.10.3) (2021-10-27)
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * upgrade deps ([4c65a4f](https://github.com/ModaOperandi/om/commit/4c65a4f56ae8ab3f716330c54095bef7149a23af))
19
+
20
+ ## [15.10.2](https://github.com/ModaOperandi/om/compare/v15.10.1...v15.10.2) (2021-10-26)
21
+
22
+
23
+ ### Bug Fixes
24
+
25
+ * **password-input:** adds padding to avoid overlapping hide/show badge ([#2113](https://github.com/ModaOperandi/om/issues/2113)) ([fc0319d](https://github.com/ModaOperandi/om/commit/fc0319d4045de13feb628bc9d70d7142670f2c8a))
26
+
27
+ ## [15.10.1](https://github.com/ModaOperandi/om/compare/v15.10.0...v15.10.1) (2021-10-19)
28
+
29
+
30
+ ### Bug Fixes
31
+
32
+ * nothing (just making sure that the release works) ([5947d02](https://github.com/ModaOperandi/om/commit/5947d028d7e46e059c5df114f1f7e65ae1b1a162))
33
+
6
34
  # [15.10.0](https://github.com/ModaOperandi/om/compare/v15.9.0...v15.10.0) (2021-10-12)
7
35
 
8
36
 
package/README.md CHANGED
@@ -101,3 +101,4 @@ body {
101
101
  padding: spacing(2, 4);
102
102
  }
103
103
  ```
104
+
@@ -6,6 +6,7 @@ export declare type PopoverProps = React.HTMLAttributes<HTMLDivElement> & {
6
6
  open?: boolean;
7
7
  anchor?: 'topLeft' | 'topCenter' | 'topRight' | 'bottomLeft' | 'bottomCenter' | 'bottomRight';
8
8
  zIndex?: number;
9
+ autoPreview?: boolean;
9
10
  };
10
11
  export declare const POPOVER_MOUSEOUT_DELAY_MS = 200;
11
12
  export declare const Popover: React.FC<PopoverProps>;
package/dist/index.cjs.js CHANGED
@@ -354,6 +354,7 @@ colors.colors = void 0; // THIS FILE IS AUTO-GENERATED. DO NOT EDIT.
354
354
 
355
355
  colors.colors = {
356
356
  "all": {
357
+ "coal": "rgb(0, 0, 0)",
357
358
  "ink": "rgb(25, 26, 27)",
358
359
  "cement": "rgb(101, 101, 102)",
359
360
  "fog": "rgb(151, 152, 153)",
@@ -411,6 +412,7 @@ colors.colors = {
411
412
  "dark-fuchsia": "rgb(180, 60, 160)"
412
413
  },
413
414
  "greyscale": {
415
+ "coal": "rgb(0, 0, 0)",
414
416
  "ink": "rgb(25, 26, 27)",
415
417
  "cement": "rgb(101, 101, 102)",
416
418
  "fog": "rgb(151, 152, 153)",
@@ -864,7 +866,7 @@ cs.get.hsl = function (string) {
864
866
  return null;
865
867
  }
866
868
 
867
- var hsl = /^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/;
869
+ var hsl = /^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?[\d\.]+)\s*)?\)$/;
868
870
  var match = string.match(hsl);
869
871
 
870
872
  if (match) {
@@ -965,12 +967,14 @@ var __assign$9 = commonjsGlobal && commonjsGlobal.__assign || function () {
965
967
  return __assign$9.apply(this, arguments);
966
968
  };
967
969
 
968
- var __spreadArray = commonjsGlobal && commonjsGlobal.__spreadArray || function (to, from) {
969
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) {
970
- to[j] = from[i];
970
+ var __spreadArray = commonjsGlobal && commonjsGlobal.__spreadArray || function (to, from, pack) {
971
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
972
+ if (ar || !(i in from)) {
973
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
974
+ ar[i] = from[i];
975
+ }
971
976
  }
972
-
973
- return to;
977
+ return to.concat(ar || Array.prototype.slice.call(from));
974
978
  };
975
979
 
976
980
  Object.defineProperty(helpers, "__esModule", {
@@ -1006,7 +1010,7 @@ var color = function color(name, alpha) {
1006
1010
  var _a;
1007
1011
 
1008
1012
  var color = colors_1.colors.all[name];
1009
- return alpha != null ? colorString.to.rgb(__spreadArray(__spreadArray([], ((_a = colorString.get.rgb(color)) === null || _a === void 0 ? void 0 : _a.slice(0, 3)) || []), [alpha])) : color;
1013
+ return alpha != null ? colorString.to.rgb(__spreadArray(__spreadArray([], ((_a = colorString.get.rgb(color)) === null || _a === void 0 ? void 0 : _a.slice(0, 3)) || [], true), [alpha], false)) : color;
1010
1014
  };
1011
1015
 
1012
1016
  helpers.color = color;
@@ -2984,21 +2988,32 @@ var FocusLock = /*#__PURE__*/React__namespace.forwardRef(function FocusLockUI(pr
2984
2988
  onDeactivationCallback(observed.current);
2985
2989
  }
2986
2990
  }, [onDeactivationCallback]);
2991
+ React$2.useEffect(function () {
2992
+ if (!disabled) {
2993
+ // cleanup return focus on trap deactivation
2994
+ // sideEffect/returnFocus should happen by this time
2995
+ originalFocusedElement.current = null;
2996
+ }
2997
+ }, []);
2987
2998
  var returnFocus = React__namespace.useCallback(function (allowDefer) {
2988
- var current = originalFocusedElement.current;
2999
+ var returnFocusTo = originalFocusedElement.current;
2989
3000
 
2990
- if (Boolean(shouldReturnFocus) && current && current.focus) {
2991
- var focusOptions = _typeof(shouldReturnFocus) === 'object' ? shouldReturnFocus : undefined;
2992
- originalFocusedElement.current = null;
3001
+ if (returnFocusTo && returnFocusTo.focus) {
3002
+ var howToReturnFocus = typeof shouldReturnFocus === 'function' ? shouldReturnFocus(returnFocusTo) : shouldReturnFocus;
2993
3003
 
2994
- if (allowDefer) {
2995
- // React might return focus after update
2996
- // it's safer to defer the action
2997
- Promise.resolve().then(function () {
2998
- return current.focus(focusOptions);
2999
- });
3000
- } else {
3001
- current.focus(focusOptions);
3004
+ if (Boolean(howToReturnFocus)) {
3005
+ var focusOptions = _typeof(howToReturnFocus) === 'object' ? howToReturnFocus : undefined;
3006
+ originalFocusedElement.current = null;
3007
+
3008
+ if (allowDefer) {
3009
+ // React might return focus after update
3010
+ // it's safer to defer the action
3011
+ Promise.resolve().then(function () {
3012
+ return returnFocusTo.focus(focusOptions);
3013
+ });
3014
+ } else {
3015
+ returnFocusTo.focus(focusOptions);
3016
+ }
3002
3017
  }
3003
3018
  }
3004
3019
  }, [shouldReturnFocus]); // MEDIUM CALLBACKS
@@ -3342,7 +3357,13 @@ var getAllAffectedNodes = function getAllAffectedNodes(node) {
3342
3357
  }, []);
3343
3358
  };
3344
3359
 
3345
- var isElementHidden = function isElementHidden(computedStyle) {
3360
+ var isElementHidden = function isElementHidden(node) {
3361
+ if (node.nodeType !== Node.ELEMENT_NODE) {
3362
+ return false;
3363
+ }
3364
+
3365
+ var computedStyle = window.getComputedStyle(node, null);
3366
+
3346
3367
  if (!computedStyle || !computedStyle.getPropertyValue) {
3347
3368
  return false;
3348
3369
  }
@@ -3351,7 +3372,7 @@ var isElementHidden = function isElementHidden(computedStyle) {
3351
3372
  };
3352
3373
 
3353
3374
  var isVisibleUncached = function isVisibleUncached(node, checkParent) {
3354
- return !node || node === document || node && node.nodeType === Node.DOCUMENT_NODE || !isElementHidden(window.getComputedStyle(node, null)) && checkParent(node.parentNode && node.parentNode.nodeType === Node.DOCUMENT_FRAGMENT_NODE ? node.parentNode.host : node.parentNode);
3375
+ return !node || node === document || node && node.nodeType === Node.DOCUMENT_NODE || !isElementHidden(node) && checkParent(node.parentNode && node.parentNode.nodeType === Node.DOCUMENT_FRAGMENT_NODE ? node.parentNode.host : node.parentNode);
3355
3376
  };
3356
3377
 
3357
3378
  var isVisibleCached = function isVisibleCached(visibilityCache, node) {
@@ -3930,13 +3951,13 @@ var onWindowBlur = function onWindowBlur() {
3930
3951
  };
3931
3952
 
3932
3953
  var attachHandler = function attachHandler() {
3933
- document.addEventListener('focusin', onTrap, true);
3954
+ document.addEventListener('focusin', onTrap);
3934
3955
  document.addEventListener('focusout', onBlur);
3935
3956
  window.addEventListener('blur', onWindowBlur);
3936
3957
  };
3937
3958
 
3938
3959
  var detachHandler = function detachHandler() {
3939
- document.removeEventListener('focusin', onTrap, true);
3960
+ document.removeEventListener('focusin', onTrap);
3940
3961
  document.removeEventListener('focusout', onBlur);
3941
3962
  window.removeEventListener('blur', onWindowBlur);
3942
3963
  };
@@ -4177,6 +4198,11 @@ var locationCouldBeScrolled = function locationCouldBeScrolled(axis, node) {
4177
4198
  var current = node;
4178
4199
 
4179
4200
  do {
4201
+ // Skip over shadow root
4202
+ if (typeof ShadowRoot !== "undefined" && current instanceof ShadowRoot) {
4203
+ current = current.host;
4204
+ }
4205
+
4180
4206
  var isScrollable = elementCouldBeScrolled(axis, current);
4181
4207
 
4182
4208
  if (isScrollable) {
@@ -8182,7 +8208,7 @@ var Exit20 = function Exit20(_a) {
8182
8208
  }, /*#__PURE__*/React__namespace.createElement("g", {
8183
8209
  id: "Exit_20_svg__Exit/20"
8184
8210
  }, /*#__PURE__*/React__namespace.createElement("path", {
8185
- id: "Exit_20_svg__Combined_Shape",
8211
+ id: "Exit_20_svg__Combined Shape",
8186
8212
  fillRule: "evenodd",
8187
8213
  clipRule: "evenodd",
8188
8214
  d: "M9.29293 10L2.64648 3.35356L3.35359 2.64645L10 9.2929L16.6465 2.64645L17.3536 3.35356L10.7071 10L17.3536 16.6465L16.6465 17.3536L10 10.7071L3.35359 17.3536L2.64648 16.6465L9.29293 10Z"
@@ -8601,30 +8627,30 @@ var useClickOutside = function useClickOutside(ref, onClickOutside) {
8601
8627
  });
8602
8628
  };
8603
8629
 
8604
- var Mode;
8630
+ var Mode$1;
8605
8631
 
8606
8632
  (function (Mode) {
8607
8633
  Mode[Mode["Resting"] = 0] = "Resting";
8608
8634
  Mode[Mode["Open"] = 1] = "Open";
8609
- })(Mode || (Mode = {}));
8635
+ })(Mode$1 || (Mode$1 = {}));
8610
8636
 
8611
8637
  var reducer = function reducer(state, action) {
8612
8638
  switch (action.type) {
8613
8639
  case 'OPEN':
8614
8640
  return _objectSpread2(_objectSpread2({}, state), {}, {
8615
- mode: Mode.Open
8641
+ mode: Mode$1.Open
8616
8642
  });
8617
8643
 
8618
8644
  case 'CLOSE':
8619
8645
  return _objectSpread2(_objectSpread2({}, state), {}, {
8620
- mode: Mode.Resting
8646
+ mode: Mode$1.Resting
8621
8647
  });
8622
8648
 
8623
8649
  case 'SELECT':
8624
8650
  return _objectSpread2(_objectSpread2({}, state), {}, {
8625
8651
  value: action.payload.value,
8626
8652
  focused: undefined,
8627
- mode: Mode.Resting
8653
+ mode: Mode$1.Resting
8628
8654
  });
8629
8655
 
8630
8656
  case 'FOCUS':
@@ -8643,7 +8669,7 @@ var useSelect = function useSelect(_ref) {
8643
8669
  var _useReducer = React$2.useReducer(reducer, {
8644
8670
  value: initialValue,
8645
8671
  focused: _typeof(initialValue) == 'object' ? initialValue === null || initialValue === void 0 ? void 0 : initialValue[0] : initialValue,
8646
- mode: Mode.Resting
8672
+ mode: Mode$1.Resting
8647
8673
  }),
8648
8674
  _useReducer2 = _slicedToArray(_useReducer, 2),
8649
8675
  state = _useReducer2[0],
@@ -8685,7 +8711,7 @@ var useSelect = function useSelect(_ref) {
8685
8711
  return {
8686
8712
  state: state,
8687
8713
  dispatch: dispatch,
8688
- Mode: Mode,
8714
+ Mode: Mode$1,
8689
8715
  selectRef: selectRef
8690
8716
  };
8691
8717
  };
@@ -11253,8 +11279,18 @@ var Paginator = function Paginator(_ref) {
11253
11279
  })));
11254
11280
  };
11255
11281
 
11256
- var _excluded$b = ["className", "children", "content", "open", "anchor", "zIndex"];
11282
+ var _excluded$b = ["className", "children", "content", "open", "anchor", "zIndex", "autoPreview"];
11257
11283
  var POPOVER_MOUSEOUT_DELAY_MS = 200;
11284
+ var Mode;
11285
+
11286
+ (function (Mode) {
11287
+ Mode["Open"] = "open";
11288
+ Mode["Closing"] = "closing";
11289
+ Mode["AutoOpening"] = "autoOpening";
11290
+ Mode["AutoOpen"] = "autoOpen";
11291
+ Mode["Closed"] = "closed";
11292
+ })(Mode || (Mode = {}));
11293
+
11258
11294
  var Popover = function Popover(_ref) {
11259
11295
  var className = _ref.className,
11260
11296
  children = _ref.children,
@@ -11264,37 +11300,78 @@ var Popover = function Popover(_ref) {
11264
11300
  _ref$anchor = _ref.anchor,
11265
11301
  anchor = _ref$anchor === void 0 ? 'topLeft' : _ref$anchor,
11266
11302
  zIndex = _ref.zIndex,
11303
+ _ref$autoPreview = _ref.autoPreview,
11304
+ autoPreview = _ref$autoPreview === void 0 ? false : _ref$autoPreview,
11267
11305
  rest = _objectWithoutProperties(_ref, _excluded$b);
11268
11306
 
11269
- var _useState = React$2.useState(open),
11307
+ var _useState = React$2.useState(function () {
11308
+ if (open) {
11309
+ return Mode.Open;
11310
+ }
11311
+
11312
+ if (autoPreview) {
11313
+ return Mode.AutoOpening;
11314
+ }
11315
+
11316
+ return Mode.Closed;
11317
+ }),
11270
11318
  _useState2 = _slicedToArray(_useState, 2),
11271
- isOpen = _useState2[0],
11272
- setOpen = _useState2[1];
11319
+ mode = _useState2[0],
11320
+ setMode = _useState2[1];
11273
11321
 
11274
11322
  var timeout = React$2.useRef(null);
11275
11323
  var handleMouseEnter = React$2.useCallback(function () {
11276
11324
  if (!open) {
11277
11325
  timeout.current && clearTimeout(timeout.current);
11278
- setOpen(true);
11326
+ setMode(Mode.Open);
11279
11327
  }
11280
11328
  }, [open]);
11281
11329
  var handleMouseLeave = React$2.useCallback(function () {
11282
11330
  if (!open) {
11283
11331
  timeout.current = setTimeout(function () {
11284
- return setOpen(false);
11332
+ return setMode(Mode.Closing);
11285
11333
  }, POPOVER_MOUSEOUT_DELAY_MS);
11286
11334
  }
11287
11335
  }, [open]);
11288
11336
  React$2.useEffect(function () {
11289
- return setOpen(open);
11290
- }, [open]);
11337
+ if (mode !== Mode.Closing) return;
11338
+ var closingTimeout = setTimeout(function () {
11339
+ return setMode(Mode.Closed);
11340
+ }, 750);
11341
+ return function () {
11342
+ return clearTimeout(closingTimeout);
11343
+ };
11344
+ }, [mode]);
11345
+ React$2.useEffect(function () {
11346
+ if (mode !== Mode.AutoOpening) return;
11347
+ var openingTimeout = setTimeout(function () {
11348
+ return setMode(Mode.AutoOpen);
11349
+ }, 1000);
11350
+ return function () {
11351
+ return clearTimeout(openingTimeout);
11352
+ };
11353
+ }, [mode]);
11354
+ React$2.useEffect(function () {
11355
+ if (mode !== Mode.AutoOpen) return;
11356
+ var stayingTimeout = setTimeout(function () {
11357
+ return setMode(Mode.Closing);
11358
+ }, 5000);
11359
+ return function () {
11360
+ return clearTimeout(stayingTimeout);
11361
+ };
11362
+ }, [mode]);
11363
+ var isOpen = mode === Mode.AutoOpen || mode === Mode.Open || mode === Mode.Closing;
11291
11364
  return /*#__PURE__*/React__default["default"].createElement("div", _extends$3({
11292
11365
  className: classNames("Popover Popover--anchor-".concat(anchor), className),
11293
11366
  onMouseEnter: handleMouseEnter,
11294
11367
  onMouseLeave: handleMouseLeave
11295
11368
  }, rest), /*#__PURE__*/React__default["default"].createElement("span", {
11296
11369
  className: "Popover__trigger"
11297
- }, isOpen && /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("div", {
11370
+ }, isOpen && /*#__PURE__*/React__default["default"].createElement("div", {
11371
+ className: classNames('Popover__box', {
11372
+ 'Popover__box--closing': mode === Mode.Closing
11373
+ })
11374
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
11298
11375
  className: "Popover__caret",
11299
11376
  style: {
11300
11377
  zIndex: zIndex != null ? zIndex + 1 : undefined
@@ -11598,10 +11675,10 @@ var PasswordInput = /*#__PURE__*/React$2.forwardRef(function (_ref, ref) {
11598
11675
  return /*#__PURE__*/React__default["default"].createElement("div", {
11599
11676
  className: "PasswordInput"
11600
11677
  }, /*#__PURE__*/React__default["default"].createElement(Field, _extends$3({
11678
+ className: "PasswordInput__editor",
11679
+ ref: ref,
11601
11680
  type: passwordShown ? 'text' : 'password'
11602
- }, rest, {
11603
- ref: ref
11604
- })), /*#__PURE__*/React__default["default"].createElement(Clickable, {
11681
+ }, rest)), /*#__PURE__*/React__default["default"].createElement(Clickable, {
11605
11682
  className: "PasswordInput__password-action",
11606
11683
  onClick: togglePasswordVisiblity,
11607
11684
  type: "button"