@moda/om 15.10.1 → 15.11.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.
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ import 'focus-visible';
3
3
  export declare const tokens: {
4
4
  colors: {
5
5
  all: {
6
+ coal: string;
6
7
  ink: string;
7
8
  cement: string;
8
9
  fog: string;
@@ -60,6 +61,7 @@ export declare const tokens: {
60
61
  "dark-fuchsia": string;
61
62
  };
62
63
  greyscale: {
64
+ coal: string;
63
65
  ink: string;
64
66
  cement: string;
65
67
  fog: string;
package/dist/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as React$2 from 'react';
2
- import React__default, { useState, PureComponent, useRef, useEffect, Children, isValidElement, cloneElement, createContext, useContext, useCallback, useReducer, useMemo, forwardRef } from 'react';
2
+ import React__default, { useState, useEffect, PureComponent, useRef, Children, isValidElement, cloneElement, createContext, useContext, useCallback, useReducer, useMemo, forwardRef } from 'react';
3
3
  import { Link } from 'react-router-dom';
4
4
  import require$$1, { createPortal } from 'react-dom';
5
5
 
@@ -327,6 +327,7 @@ colors.colors = void 0; // THIS FILE IS AUTO-GENERATED. DO NOT EDIT.
327
327
 
328
328
  colors.colors = {
329
329
  "all": {
330
+ "coal": "rgb(0, 0, 0)",
330
331
  "ink": "rgb(25, 26, 27)",
331
332
  "cement": "rgb(101, 101, 102)",
332
333
  "fog": "rgb(151, 152, 153)",
@@ -384,6 +385,7 @@ colors.colors = {
384
385
  "dark-fuchsia": "rgb(180, 60, 160)"
385
386
  },
386
387
  "greyscale": {
388
+ "coal": "rgb(0, 0, 0)",
387
389
  "ink": "rgb(25, 26, 27)",
388
390
  "cement": "rgb(101, 101, 102)",
389
391
  "fog": "rgb(151, 152, 153)",
@@ -837,7 +839,7 @@ cs.get.hsl = function (string) {
837
839
  return null;
838
840
  }
839
841
 
840
- var hsl = /^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/;
842
+ var hsl = /^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?[\d\.]+)\s*)?\)$/;
841
843
  var match = string.match(hsl);
842
844
 
843
845
  if (match) {
@@ -938,12 +940,14 @@ var __assign$9 = commonjsGlobal && commonjsGlobal.__assign || function () {
938
940
  return __assign$9.apply(this, arguments);
939
941
  };
940
942
 
941
- var __spreadArray = commonjsGlobal && commonjsGlobal.__spreadArray || function (to, from) {
942
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) {
943
- to[j] = from[i];
943
+ var __spreadArray = commonjsGlobal && commonjsGlobal.__spreadArray || function (to, from, pack) {
944
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
945
+ if (ar || !(i in from)) {
946
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
947
+ ar[i] = from[i];
948
+ }
944
949
  }
945
-
946
- return to;
950
+ return to.concat(ar || Array.prototype.slice.call(from));
947
951
  };
948
952
 
949
953
  Object.defineProperty(helpers, "__esModule", {
@@ -979,7 +983,7 @@ var color = function color(name, alpha) {
979
983
  var _a;
980
984
 
981
985
  var color = colors_1.colors.all[name];
982
- 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;
986
+ 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;
983
987
  };
984
988
 
985
989
  helpers.color = color;
@@ -2957,21 +2961,32 @@ var FocusLock = /*#__PURE__*/React$2.forwardRef(function FocusLockUI(props, pare
2957
2961
  onDeactivationCallback(observed.current);
2958
2962
  }
2959
2963
  }, [onDeactivationCallback]);
2964
+ useEffect(function () {
2965
+ if (!disabled) {
2966
+ // cleanup return focus on trap deactivation
2967
+ // sideEffect/returnFocus should happen by this time
2968
+ originalFocusedElement.current = null;
2969
+ }
2970
+ }, []);
2960
2971
  var returnFocus = React$2.useCallback(function (allowDefer) {
2961
- var current = originalFocusedElement.current;
2972
+ var returnFocusTo = originalFocusedElement.current;
2962
2973
 
2963
- if (Boolean(shouldReturnFocus) && current && current.focus) {
2964
- var focusOptions = _typeof(shouldReturnFocus) === 'object' ? shouldReturnFocus : undefined;
2965
- originalFocusedElement.current = null;
2974
+ if (returnFocusTo && returnFocusTo.focus) {
2975
+ var howToReturnFocus = typeof shouldReturnFocus === 'function' ? shouldReturnFocus(returnFocusTo) : shouldReturnFocus;
2966
2976
 
2967
- if (allowDefer) {
2968
- // React might return focus after update
2969
- // it's safer to defer the action
2970
- Promise.resolve().then(function () {
2971
- return current.focus(focusOptions);
2972
- });
2973
- } else {
2974
- current.focus(focusOptions);
2977
+ if (Boolean(howToReturnFocus)) {
2978
+ var focusOptions = _typeof(howToReturnFocus) === 'object' ? howToReturnFocus : undefined;
2979
+ originalFocusedElement.current = null;
2980
+
2981
+ if (allowDefer) {
2982
+ // React might return focus after update
2983
+ // it's safer to defer the action
2984
+ Promise.resolve().then(function () {
2985
+ return returnFocusTo.focus(focusOptions);
2986
+ });
2987
+ } else {
2988
+ returnFocusTo.focus(focusOptions);
2989
+ }
2975
2990
  }
2976
2991
  }
2977
2992
  }, [shouldReturnFocus]); // MEDIUM CALLBACKS
@@ -3315,7 +3330,13 @@ var getAllAffectedNodes = function getAllAffectedNodes(node) {
3315
3330
  }, []);
3316
3331
  };
3317
3332
 
3318
- var isElementHidden = function isElementHidden(computedStyle) {
3333
+ var isElementHidden = function isElementHidden(node) {
3334
+ if (node.nodeType !== Node.ELEMENT_NODE) {
3335
+ return false;
3336
+ }
3337
+
3338
+ var computedStyle = window.getComputedStyle(node, null);
3339
+
3319
3340
  if (!computedStyle || !computedStyle.getPropertyValue) {
3320
3341
  return false;
3321
3342
  }
@@ -3324,7 +3345,7 @@ var isElementHidden = function isElementHidden(computedStyle) {
3324
3345
  };
3325
3346
 
3326
3347
  var isVisibleUncached = function isVisibleUncached(node, checkParent) {
3327
- 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);
3348
+ 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);
3328
3349
  };
3329
3350
 
3330
3351
  var isVisibleCached = function isVisibleCached(visibilityCache, node) {
@@ -3903,13 +3924,13 @@ var onWindowBlur = function onWindowBlur() {
3903
3924
  };
3904
3925
 
3905
3926
  var attachHandler = function attachHandler() {
3906
- document.addEventListener('focusin', onTrap, true);
3927
+ document.addEventListener('focusin', onTrap);
3907
3928
  document.addEventListener('focusout', onBlur);
3908
3929
  window.addEventListener('blur', onWindowBlur);
3909
3930
  };
3910
3931
 
3911
3932
  var detachHandler = function detachHandler() {
3912
- document.removeEventListener('focusin', onTrap, true);
3933
+ document.removeEventListener('focusin', onTrap);
3913
3934
  document.removeEventListener('focusout', onBlur);
3914
3935
  window.removeEventListener('blur', onWindowBlur);
3915
3936
  };
@@ -4150,6 +4171,11 @@ var locationCouldBeScrolled = function locationCouldBeScrolled(axis, node) {
4150
4171
  var current = node;
4151
4172
 
4152
4173
  do {
4174
+ // Skip over shadow root
4175
+ if (typeof ShadowRoot !== "undefined" && current instanceof ShadowRoot) {
4176
+ current = current.host;
4177
+ }
4178
+
4153
4179
  var isScrollable = elementCouldBeScrolled(axis, current);
4154
4180
 
4155
4181
  if (isScrollable) {
@@ -8574,30 +8600,30 @@ var useClickOutside = function useClickOutside(ref, onClickOutside) {
8574
8600
  });
8575
8601
  };
8576
8602
 
8577
- var Mode;
8603
+ var Mode$1;
8578
8604
 
8579
8605
  (function (Mode) {
8580
8606
  Mode[Mode["Resting"] = 0] = "Resting";
8581
8607
  Mode[Mode["Open"] = 1] = "Open";
8582
- })(Mode || (Mode = {}));
8608
+ })(Mode$1 || (Mode$1 = {}));
8583
8609
 
8584
8610
  var reducer = function reducer(state, action) {
8585
8611
  switch (action.type) {
8586
8612
  case 'OPEN':
8587
8613
  return _objectSpread2(_objectSpread2({}, state), {}, {
8588
- mode: Mode.Open
8614
+ mode: Mode$1.Open
8589
8615
  });
8590
8616
 
8591
8617
  case 'CLOSE':
8592
8618
  return _objectSpread2(_objectSpread2({}, state), {}, {
8593
- mode: Mode.Resting
8619
+ mode: Mode$1.Resting
8594
8620
  });
8595
8621
 
8596
8622
  case 'SELECT':
8597
8623
  return _objectSpread2(_objectSpread2({}, state), {}, {
8598
8624
  value: action.payload.value,
8599
8625
  focused: undefined,
8600
- mode: Mode.Resting
8626
+ mode: Mode$1.Resting
8601
8627
  });
8602
8628
 
8603
8629
  case 'FOCUS':
@@ -8616,7 +8642,7 @@ var useSelect = function useSelect(_ref) {
8616
8642
  var _useReducer = useReducer(reducer, {
8617
8643
  value: initialValue,
8618
8644
  focused: _typeof(initialValue) == 'object' ? initialValue === null || initialValue === void 0 ? void 0 : initialValue[0] : initialValue,
8619
- mode: Mode.Resting
8645
+ mode: Mode$1.Resting
8620
8646
  }),
8621
8647
  _useReducer2 = _slicedToArray(_useReducer, 2),
8622
8648
  state = _useReducer2[0],
@@ -8658,7 +8684,7 @@ var useSelect = function useSelect(_ref) {
8658
8684
  return {
8659
8685
  state: state,
8660
8686
  dispatch: dispatch,
8661
- Mode: Mode,
8687
+ Mode: Mode$1,
8662
8688
  selectRef: selectRef
8663
8689
  };
8664
8690
  };
@@ -11226,8 +11252,19 @@ var Paginator = function Paginator(_ref) {
11226
11252
  })));
11227
11253
  };
11228
11254
 
11229
- var _excluded$b = ["className", "children", "content", "open", "anchor", "zIndex"];
11255
+ var _excluded$b = ["className", "children", "content", "open", "anchor", "zIndex", "autoPreview", "smoothTransitioning"];
11230
11256
  var POPOVER_MOUSEOUT_DELAY_MS = 200;
11257
+ var Mode;
11258
+
11259
+ (function (Mode) {
11260
+ Mode["Opening"] = "opening";
11261
+ Mode["Open"] = "open";
11262
+ Mode["Closing"] = "closing";
11263
+ Mode["AutoOpening"] = "autoOpening";
11264
+ Mode["AutoOpen"] = "autoOpen";
11265
+ Mode["Closed"] = "closed";
11266
+ })(Mode || (Mode = {}));
11267
+
11231
11268
  var Popover = function Popover(_ref) {
11232
11269
  var className = _ref.className,
11233
11270
  children = _ref.children,
@@ -11237,37 +11274,93 @@ var Popover = function Popover(_ref) {
11237
11274
  _ref$anchor = _ref.anchor,
11238
11275
  anchor = _ref$anchor === void 0 ? 'topLeft' : _ref$anchor,
11239
11276
  zIndex = _ref.zIndex,
11277
+ _ref$autoPreview = _ref.autoPreview,
11278
+ autoPreview = _ref$autoPreview === void 0 ? false : _ref$autoPreview,
11279
+ _ref$smoothTransition = _ref.smoothTransitioning,
11280
+ smoothTransitioning = _ref$smoothTransition === void 0 ? false : _ref$smoothTransition,
11240
11281
  rest = _objectWithoutProperties(_ref, _excluded$b);
11241
11282
 
11242
- var _useState = useState(open),
11283
+ var _useState = useState(function () {
11284
+ if (open && smoothTransitioning) {
11285
+ return Mode.Opening;
11286
+ }
11287
+
11288
+ if (open && !smoothTransitioning) {
11289
+ return Mode.Open;
11290
+ }
11291
+
11292
+ if (autoPreview) {
11293
+ return Mode.AutoOpening;
11294
+ }
11295
+
11296
+ return Mode.Closed;
11297
+ }),
11243
11298
  _useState2 = _slicedToArray(_useState, 2),
11244
- isOpen = _useState2[0],
11245
- setOpen = _useState2[1];
11299
+ mode = _useState2[0],
11300
+ setMode = _useState2[1];
11246
11301
 
11247
11302
  var timeout = useRef(null);
11248
11303
  var handleMouseEnter = useCallback(function () {
11249
11304
  if (!open) {
11250
11305
  timeout.current && clearTimeout(timeout.current);
11251
- setOpen(true);
11306
+ setMode(smoothTransitioning ? Mode.Opening : Mode.Open);
11252
11307
  }
11253
- }, [open]);
11308
+ }, [open, smoothTransitioning]);
11254
11309
  var handleMouseLeave = useCallback(function () {
11255
- if (!open) {
11256
- timeout.current = setTimeout(function () {
11257
- return setOpen(false);
11258
- }, POPOVER_MOUSEOUT_DELAY_MS);
11259
- }
11260
- }, [open]);
11310
+ if (open) return;
11311
+ timeout.current = setTimeout(function () {
11312
+ return setMode(smoothTransitioning ? Mode.Closing : Mode.Closed);
11313
+ }, POPOVER_MOUSEOUT_DELAY_MS);
11314
+ }, [open, smoothTransitioning]);
11315
+ useEffect(function () {
11316
+ if (mode !== Mode.Closing) return;
11317
+ var closingTimeout = setTimeout(function () {
11318
+ return setMode(Mode.Closed);
11319
+ }, 750);
11320
+ return function () {
11321
+ return clearTimeout(closingTimeout);
11322
+ };
11323
+ }, [mode]);
11324
+ useEffect(function () {
11325
+ if (mode !== Mode.AutoOpening) return;
11326
+ var openingTimeout = setTimeout(function () {
11327
+ return setMode(Mode.AutoOpen);
11328
+ }, 1000);
11329
+ return function () {
11330
+ return clearTimeout(openingTimeout);
11331
+ };
11332
+ }, [mode]);
11333
+ useEffect(function () {
11334
+ if (mode !== Mode.Opening) return;
11335
+ var openingTimeout = setTimeout(function () {
11336
+ return setMode(Mode.Open);
11337
+ }, 750);
11338
+ return function () {
11339
+ return clearTimeout(openingTimeout);
11340
+ };
11341
+ }, [mode]);
11261
11342
  useEffect(function () {
11262
- return setOpen(open);
11263
- }, [open]);
11343
+ if (mode !== Mode.AutoOpen) return;
11344
+ var stayingTimeout = setTimeout(function () {
11345
+ return setMode(smoothTransitioning ? Mode.Closing : Mode.Closed);
11346
+ }, 5000);
11347
+ return function () {
11348
+ return clearTimeout(stayingTimeout);
11349
+ };
11350
+ }, [mode, smoothTransitioning]);
11351
+ var isOpen = mode === Mode.AutoOpen || mode === Mode.Opening || mode === Mode.Open || mode === Mode.Closing;
11264
11352
  return /*#__PURE__*/React__default.createElement("div", _extends$3({
11265
11353
  className: classNames("Popover Popover--anchor-".concat(anchor), className),
11266
11354
  onMouseEnter: handleMouseEnter,
11267
11355
  onMouseLeave: handleMouseLeave
11268
11356
  }, rest), /*#__PURE__*/React__default.createElement("span", {
11269
11357
  className: "Popover__trigger"
11270
- }, isOpen && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
11358
+ }, isOpen && /*#__PURE__*/React__default.createElement("div", {
11359
+ className: classNames('Popover__box', {
11360
+ 'Popover__box--opening': mode === Mode.Opening,
11361
+ 'Popover__box--closing': mode === Mode.Closing
11362
+ })
11363
+ }, /*#__PURE__*/React__default.createElement("div", {
11271
11364
  className: "Popover__caret",
11272
11365
  style: {
11273
11366
  zIndex: zIndex != null ? zIndex + 1 : undefined
@@ -11571,10 +11664,10 @@ var PasswordInput = /*#__PURE__*/forwardRef(function (_ref, ref) {
11571
11664
  return /*#__PURE__*/React__default.createElement("div", {
11572
11665
  className: "PasswordInput"
11573
11666
  }, /*#__PURE__*/React__default.createElement(Field, _extends$3({
11667
+ className: "PasswordInput__editor",
11668
+ ref: ref,
11574
11669
  type: passwordShown ? 'text' : 'password'
11575
- }, rest, {
11576
- ref: ref
11577
- })), /*#__PURE__*/React__default.createElement(Clickable, {
11670
+ }, rest)), /*#__PURE__*/React__default.createElement(Clickable, {
11578
11671
  className: "PasswordInput__password-action",
11579
11672
  onClick: togglePasswordVisiblity,
11580
11673
  type: "button"