@onepercentio/one-ui 0.19.5 → 0.19.7

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.
@@ -18,7 +18,11 @@ export declare enum AnchoredTooltipAlignment {
18
18
  CENTER = 1,
19
19
  RIGHT = 2
20
20
  }
21
- export declare function updateTooltipPosition(tooltipRef: HTMLDivElement, anchorRef: HTMLElement, limitToViewport?: boolean, alignment?: AnchoredTooltipAlignment): {
21
+ export declare enum AnchoredTooltipAnchor {
22
+ TOP = 0,
23
+ BOTTOM = 1
24
+ }
25
+ export declare function updateTooltipPosition(tooltipRef: HTMLDivElement, anchorRef: HTMLElement, limitToViewport?: boolean, alignment?: AnchoredTooltipAlignment, anchorTo?: AnchoredTooltipAnchor): {
22
26
  shouldAnchorToBottom: boolean;
23
27
  };
24
28
  declare const _default: React.ForwardRefExoticComponent<Props & React.RefAttributes<{
@@ -4,7 +4,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.default = exports.AnchoredTooltipAlignment = void 0;
7
+ exports.default = exports.AnchoredTooltipAnchor = exports.AnchoredTooltipAlignment = void 0;
8
8
  exports.updateTooltipPosition = updateTooltipPosition;
9
9
  var _react = _interopRequireWildcard(require("react"));
10
10
  var _OneUIProvider = require("../../context/OneUIProvider");
@@ -33,10 +33,17 @@ let AnchoredTooltipAlignment = /*#__PURE__*/function (AnchoredTooltipAlignment)
33
33
  return AnchoredTooltipAlignment;
34
34
  }({});
35
35
  exports.AnchoredTooltipAlignment = AnchoredTooltipAlignment;
36
+ let AnchoredTooltipAnchor = /*#__PURE__*/function (AnchoredTooltipAnchor) {
37
+ AnchoredTooltipAnchor[AnchoredTooltipAnchor["TOP"] = 0] = "TOP";
38
+ AnchoredTooltipAnchor[AnchoredTooltipAnchor["BOTTOM"] = 1] = "BOTTOM";
39
+ return AnchoredTooltipAnchor;
40
+ }({});
41
+ exports.AnchoredTooltipAnchor = AnchoredTooltipAnchor;
36
42
  function calculateTooltipFromAnchor(anchorRef, tooltipRef, containInViewport) {
37
43
  let alignTo = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : AnchoredTooltipAlignment.CENTER;
44
+ let anchorTo = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : AnchoredTooltipAnchor.TOP;
38
45
  const anchorPosition = getPositionOnViewport(anchorRef);
39
- const shouldAnchorToBottom = tooltipRef.clientHeight > anchorPosition.top;
46
+ const shouldAnchorToBottom = anchorTo === AnchoredTooltipAnchor.BOTTOM || tooltipRef.clientHeight > anchorPosition.top;
40
47
  let top = anchorPosition.top - tooltipRef.clientHeight;
41
48
 
42
49
  /**
@@ -85,7 +92,8 @@ function calculateTooltipFromAnchor(anchorRef, tooltipRef, containInViewport) {
85
92
  function updateTooltipPosition(tooltipRef, anchorRef) {
86
93
  let limitToViewport = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
87
94
  let alignment = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : AnchoredTooltipAlignment.CENTER;
88
- const _calculateTooltipFrom = calculateTooltipFromAnchor(anchorRef, tooltipRef, limitToViewport, alignment),
95
+ let anchorTo = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : AnchoredTooltipAnchor.TOP;
96
+ const _calculateTooltipFrom = calculateTooltipFromAnchor(anchorRef, tooltipRef, limitToViewport, alignment, anchorTo),
89
97
  top = _calculateTooltipFrom.top,
90
98
  left = _calculateTooltipFrom.left,
91
99
  shouldAnchorToBottom = _calculateTooltipFrom.shouldAnchorToBottom,
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { AnchoredTooltipAlignment } from "../AnchoredTooltip/AnchoredTooltip";
2
+ import { AnchoredTooltipAlignment, AnchoredTooltipAnchor } from "../AnchoredTooltip/AnchoredTooltip";
3
3
  declare class _CollapsableInterface {
4
4
  _id: string;
5
5
  constructor(id: string);
@@ -39,6 +39,7 @@ declare const _default: React.ForwardRefExoticComponent<(React.PropsWithChildren
39
39
  } | {
40
40
  mode: "float";
41
41
  alignTo: AnchoredTooltipAlignment;
42
+ anchorTo?: AnchoredTooltipAnchor | undefined;
42
43
  })> & Omit<React.HTMLAttributes<HTMLDivElement>, "title">) & React.RefAttributes<{
43
44
  redimension: () => void;
44
45
  }>>;
@@ -62,7 +62,7 @@ function Collapsable(_ref, ref) {
62
62
  el.parentElement.style.position = "relative";
63
63
  if (mode === "float") {
64
64
  el.style.minHeight = el.style.height;
65
- const _updateTooltipPositio = (0, _AnchoredTooltip.updateTooltipPosition)(el, toggleRef.current, true, "alignTo" in props ? props.alignTo : _AnchoredTooltip.AnchoredTooltipAlignment.CENTER),
65
+ const _updateTooltipPositio = (0, _AnchoredTooltip.updateTooltipPosition)(el, toggleRef.current, true, "alignTo" in props ? props.alignTo : _AnchoredTooltip.AnchoredTooltipAlignment.CENTER, "anchorTo" in props ? props.anchorTo : undefined),
66
66
  shouldAnchorToBottom = _updateTooltipPositio.shouldAnchorToBottom;
67
67
  el.style.minHeight = "";
68
68
  if (!shouldAnchorToBottom) {
@@ -10,6 +10,7 @@ exports.useOrderableEvents = useOrderableEvents;
10
10
  exports.useOrderableListAnchor = useOrderableListAnchor;
11
11
  var _throttle = _interopRequireDefault(require("lodash/throttle"));
12
12
  var _UncontrolledTransition = _interopRequireDefault(require("../UncontrolledTransition"));
13
+ var _TransitionModule = _interopRequireDefault(require("../Transition/Transition.module.scss"));
13
14
  var _react = _interopRequireWildcard(require("react"));
14
15
  var _useHero2 = _interopRequireDefault(require("../../hooks/useHero"));
15
16
  var _AnimatedEntrance = _interopRequireDefault(require("../AnimatedEntrance"));
@@ -27,16 +28,16 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
27
28
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
28
29
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
29
30
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
31
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
32
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
33
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
34
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
30
35
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
31
36
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
37
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
32
38
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
33
39
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
34
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
35
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
36
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
37
40
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
38
- function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
39
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
40
41
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
41
42
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
42
43
  const OrderableListContext = /*#__PURE__*/(0, _react.createContext)(null);
@@ -65,29 +66,34 @@ function OrderableList(_ref) {
65
66
  reorderingClassName = _ref.reorderingClassName,
66
67
  cloneClassName = _ref.cloneClassName,
67
68
  props = _objectWithoutProperties(_ref, _excluded);
69
+ const availableKeys = children.map(function (a) {
70
+ return a.key;
71
+ });
72
+ const availableKeysDep = availableKeys.join(",");
73
+ const initializeOrder = (0, _react.useCallback)(function () {
74
+ const missingOrderKeys = "keyOrder" in props && props.keyOrder ? availableKeys.filter(function (a) {
75
+ return !props.keyOrder.includes(a);
76
+ }) : [];
77
+ return ("keyOrder" in props && props.keyOrder ? [].concat(_toConsumableArray(props.keyOrder), _toConsumableArray(missingOrderKeys)) : undefined) || availableKeys;
78
+ }, [availableKeysDep, props.keyOrder]);
68
79
  const _useRef = (0, _react.useRef)([]),
69
80
  anchorsList = _useRef.current;
70
81
  const eventEmitter = (0, _useEvents.default)();
71
82
  const currentClone = (0, _react.useRef)(null);
72
83
  const currentWorkingKey = (0, _react.useRef)();
73
- const availableKeys = children.map(function (a) {
74
- return a.key;
75
- });
76
84
  const rootRef = (0, _react.useRef)(null);
77
- const _useState = (0, _react.useState)(function () {
78
- const missingOrderKeys = "keyOrder" in props && props.keyOrder ? availableKeys.filter(function (a) {
79
- return !props.keyOrder.includes(a);
80
- }) : [];
81
- return ("keyOrder" in props && props.keyOrder ? [].concat(_toConsumableArray(props.keyOrder), _toConsumableArray(missingOrderKeys)) : undefined) || availableKeys;
82
- }),
85
+ const _useState = (0, _react.useState)(initializeOrder),
83
86
  _useState2 = _slicedToArray(_useState, 2),
84
87
  _order = _useState2[0],
85
88
  setOrder = _useState2[1];
89
+ (0, _react.useEffect)(function () {
90
+ return setOrder(initializeOrder());
91
+ }, [initializeOrder]);
86
92
  const order = (0, _react.useMemo)(function () {
87
93
  return ("currentOrder" in props ? props.currentOrder || _order : _order).filter(function (o) {
88
94
  return o.includes(";") || availableKeys.includes(o);
89
95
  });
90
- }, [props.currentOrder, _order]);
96
+ }, [props.currentOrder, _order, availableKeysDep]);
91
97
  const cleanOrder = (0, _react.useMemo)(function () {
92
98
  return order.map(function (a) {
93
99
  return a.split(";")[0];
@@ -96,9 +102,13 @@ function OrderableList(_ref) {
96
102
  const orderId = (0, _react.useMemo)(function () {
97
103
  return "key-" + cleanOrder.join("");
98
104
  }, [cleanOrder]);
105
+ function rootEl() {
106
+ if (mode === OrderableListReorderMode.TWO_DIMENSIONS) return rootRef.current.lastElementChild.lastElementChild;
107
+ return rootRef.current;
108
+ }
99
109
  const findParentElement = function findParentElement(target) {
100
110
  let parent = target;
101
- while (parent.parentElement !== rootRef.current) {
111
+ while (parent.parentElement !== rootEl()) {
102
112
  if (parent.parentElement === null) break;
103
113
  parent = parent.parentElement;
104
114
  }
@@ -106,7 +116,7 @@ function OrderableList(_ref) {
106
116
  return parent;
107
117
  };
108
118
  (0, _react.useLayoutEffect)(function () {
109
- if (shrinkToOnOrder) rootRef.current.style.setProperty("--shrink-to", "".concat(shrinkToOnOrder, "px"));
119
+ if (shrinkToOnOrder) rootEl().style.setProperty("--shrink-to", "".concat(shrinkToOnOrder, "px"));
110
120
  }, [shrinkToOnOrder]);
111
121
  const calculateReordering = (0, _react.useMemo)(function () {
112
122
  return (0, _throttle.default)(function (e, els, currentOrder) {
@@ -117,11 +127,31 @@ function OrderableList(_ref) {
117
127
  const isDraggingOwnElement = currentWorkingKey.current === keyOfTheOverElement;
118
128
  if (indexOfKeyInCleanOrder === -1 || keyOfTheOverElement === undefined) return;
119
129
  if (!isDraggingOwnElement) {
120
- const distanceFromTop = e.offsetY;
121
- const heightOfEl = parent.clientHeight;
122
- const offset = heightOfEl * 0.25;
123
- const isAfter = distanceFromTop > heightOfEl - offset;
124
- const isBefore = distanceFromTop < offset;
130
+ const _ref2 = function () {
131
+ if (mode === OrderableListReorderMode.TWO_DIMENSIONS) {
132
+ const distanceFromLeft = e.offsetX;
133
+ const widthOfEl = parent.clientWidth;
134
+ const offset = widthOfEl * 0.25;
135
+ const isAfter = distanceFromLeft > widthOfEl - offset;
136
+ const isBefore = distanceFromLeft < offset;
137
+ return {
138
+ isAfter: isAfter,
139
+ isBefore: isBefore
140
+ };
141
+ } else {
142
+ const distanceFromTop = e.offsetY;
143
+ const heightOfEl = parent.clientHeight;
144
+ const offset = heightOfEl * 0.25;
145
+ const isAfter = distanceFromTop > heightOfEl - offset;
146
+ const isBefore = distanceFromTop < offset;
147
+ return {
148
+ isAfter: isAfter,
149
+ isBefore: isBefore
150
+ };
151
+ }
152
+ }(),
153
+ isAfter = _ref2.isAfter,
154
+ isBefore = _ref2.isBefore;
125
155
  const checkIfCanMove = function checkIfCanMove(keyOfOverElement) {
126
156
  return keyOfOverElement === undefined || keyOfOverElement !== currentWorkingKey.current;
127
157
  };
@@ -145,15 +175,29 @@ function OrderableList(_ref) {
145
175
  }, 1000 / 60);
146
176
  }, []);
147
177
  (0, _react.useEffect)(function () {
148
- const els = Array.from(rootRef.current.children);
149
- const calculateReorderingCall = function calculateReorderingCall(e) {
150
- const els = Array.from(rootRef.current.children);
151
- calculateReordering(e, els, cleanOrder);
152
- };
153
- for (let el of els) el.addEventListener("mousemove", calculateReorderingCall);
154
- return function () {
155
- for (let el of els) el.removeEventListener("mousemove", calculateReorderingCall);
156
- };
178
+ function registerListeners() {
179
+ const els = Array.from(rootEl().children);
180
+ const calculateReorderingCall = function calculateReorderingCall(e) {
181
+ const els = Array.from(rootEl().children);
182
+ calculateReordering(e, els, cleanOrder);
183
+ };
184
+ for (let el of els) el.addEventListener("mousemove", calculateReorderingCall);
185
+ return function () {
186
+ for (let el of els) el.removeEventListener("mousemove", calculateReorderingCall);
187
+ };
188
+ }
189
+ if (mode === OrderableListReorderMode.VERTICAL) {
190
+ return registerListeners();
191
+ } else {
192
+ let unsubscribe;
193
+ let timeout = setTimeout(function () {
194
+ unsubscribe = registerListeners();
195
+ }, 250);
196
+ return function () {
197
+ clearTimeout(timeout);
198
+ if (unsubscribe) unsubscribe();
199
+ };
200
+ }
157
201
  }, [cleanOrder]);
158
202
  (0, _react.useEffect)(function () {
159
203
  if ("onChangeKeyOrder" in props) props.onChangeKeyOrder(cleanKeys(_order));
@@ -162,12 +206,12 @@ function OrderableList(_ref) {
162
206
  (0, _react.useEffect)(function () {
163
207
  cleanOrderRef.current = cleanOrder;
164
208
  }, [cleanOrder]);
165
- const onAnchorClick = (0, _react.useCallback)(function (_ref2) {
166
- let anchor = _ref2.target;
209
+ const onAnchorClick = (0, _react.useCallback)(function (_ref3) {
210
+ let anchor = _ref3.target;
167
211
  let offset;
168
212
  const orderableListItemForAnchor = findParentElement(anchor);
169
213
  const box = orderableListItemForAnchor.getBoundingClientRect();
170
- const els = Array.from(rootRef.current.children);
214
+ const els = Array.from(rootEl().children);
171
215
  const elIndex = els.indexOf(orderableListItemForAnchor);
172
216
  const clone = orderableListItemForAnchor.cloneNode(true);
173
217
  currentClone.current = clone;
@@ -186,12 +230,12 @@ function OrderableList(_ref) {
186
230
  orderableListItemForAnchor.classList.add(_OrderableListModule.default.currentOrdering);
187
231
  orderableListItemForAnchor.classList.remove(_OrderableListModule.default.visible);
188
232
  const movementControl = function movementControl(e) {
189
- const _ref3 = "touches" in e ? {
233
+ const _ref4 = "touches" in e ? {
190
234
  x: e.touches[0].pageX,
191
235
  y: e.touches[0].pageY
192
236
  } : e,
193
- x1 = _ref3.x,
194
- y1 = _ref3.y;
237
+ x1 = _ref4.x,
238
+ y1 = _ref4.y;
195
239
  if (!offset) offset = [x1 - box.left, y1 - box.top];
196
240
  const _offset = offset,
197
241
  _offset2 = _slicedToArray(_offset, 2),
@@ -212,18 +256,18 @@ function OrderableList(_ref) {
212
256
  {
213
257
  let cleanUp = function cleanUp() {
214
258
  if (shrinkToOnOrder) {
215
- rootRef.current.style.removeProperty("padding-top");
216
- rootRef.current.style.removeProperty("min-height");
259
+ rootEl().style.removeProperty("padding-top");
260
+ rootEl().style.removeProperty("min-height");
217
261
  }
218
262
  eventEmitter.dispatcher("order-stop");
219
- rootRef.current.classList.remove(_OrderableListModule.default.ordering);
220
- if (reorderingClassName) rootRef.current.classList.remove(reorderingClassName);
263
+ rootEl().classList.remove(_OrderableListModule.default.ordering);
264
+ if (reorderingClassName) rootEl().classList.remove(reorderingClassName);
221
265
  for (let el of els) el.classList.remove(_OrderableListModule.default.visible);
222
266
  clone.remove();
223
267
  currentClone.current = null;
224
268
  for (let el of Array.from(elInvisible.children)) el.style.height = "";
225
269
  };
226
- const els = Array.from(rootRef.current.children);
270
+ const els = Array.from(rootEl().children);
227
271
  const elInvisible = els.find(function (a) {
228
272
  return !a.classList.contains(_OrderableListModule.default.visible) && a.style.maxHeight !== "0px";
229
273
  });
@@ -259,13 +303,13 @@ function OrderableList(_ref) {
259
303
  const targetHeight = elIndex * shrinkToOnOrder;
260
304
  const currentHeight = orderableListItemForAnchor.offsetTop - els[0].offsetTop;
261
305
  const paddingTop = currentHeight - targetHeight;
262
- rootRef.current.style.paddingTop = "".concat(paddingTop, "px");
263
- rootRef.current.style.minHeight = "".concat(rootRef.current.clientHeight, "px");
306
+ rootEl().style.paddingTop = "".concat(paddingTop, "px");
307
+ rootEl().style.minHeight = "".concat(rootEl().clientHeight, "px");
264
308
  }
265
309
  orderableListItemForAnchor.style.visibility = "hidden";
266
310
  orderableListItemForAnchor.classList.remove(_OrderableListModule.default.visible);
267
- rootRef.current.classList.add(_OrderableListModule.default.ordering);
268
- if (reorderingClassName) rootRef.current.classList.add(reorderingClassName);
311
+ rootEl().classList.add(_OrderableListModule.default.ordering);
312
+ if (reorderingClassName) rootEl().classList.add(reorderingClassName);
269
313
  currentWorkingKey.current = cleanOrderRef.current[elIndex];
270
314
  eventEmitter.dispatcher("order-start");
271
315
  window.document.body.classList.add(_OrderableListModule.default.unselectable);
@@ -276,7 +320,7 @@ function OrderableList(_ref) {
276
320
  }, []);
277
321
  (0, _react.useLayoutEffect)(function () {
278
322
  if (currentClone.current) {
279
- const els = Array.from(rootRef.current.children);
323
+ const els = Array.from(rootEl().children);
280
324
  const elInvisible = els.find(function (a) {
281
325
  return !a.classList.contains(_OrderableListModule.default.visible) && a.style.maxHeight !== "0px";
282
326
  });
@@ -299,7 +343,7 @@ function OrderableList(_ref) {
299
343
  });
300
344
  });
301
345
  (0, _react.useLayoutEffect)(function () {
302
- rootRef.current.addEventListener("touchstart", function (e) {
346
+ rootEl().addEventListener("touchstart", function (e) {
303
347
  const relatedAnchor = anchorsList.find(function (anchor) {
304
348
  return anchor.contains(e.target);
305
349
  });
@@ -309,7 +353,7 @@ function OrderableList(_ref) {
309
353
  target: relatedAnchor
310
354
  });
311
355
  const moveCb = (0, _throttle.default)(function () {
312
- const els = Array.from(rootRef.current.children);
356
+ const els = Array.from(rootEl().children);
313
357
  const currentElementIdx = els.findIndex(function (c) {
314
358
  const rect = c === null || c === void 0 ? void 0 : c.getBoundingClientRect();
315
359
  if (!rect) return false;
@@ -360,7 +404,17 @@ function OrderableList(_ref) {
360
404
  className: "".concat(_OrderableListModule.default.root, " ").concat(className, " ").concat(shrinkToOnOrder ? _OrderableListModule.default.shrinkable : "")
361
405
  }, toSpread), mode === OrderableListReorderMode.VERTICAL ? /*#__PURE__*/_react.default.createElement(_AnimatedEntrance.default, null, childrenToRender) : /*#__PURE__*/_react.default.createElement(_UncontrolledTransition.default, {
362
406
  className: _OrderableListModule.default.transition,
363
- transitionType: _Transition.TransitionAnimationTypes.FADE,
407
+ transitionType: _Transition.TransitionAnimationTypes.CUSTOM,
408
+ config: {
409
+ backward: {
410
+ elementEntering: "",
411
+ elementExiting: ""
412
+ },
413
+ forward: {
414
+ elementEntering: _OrderableListModule.default.stubEntering,
415
+ elementExiting: _TransitionModule.default.fadeOut
416
+ }
417
+ },
364
418
  contentClassName: "".concat(className)
365
419
  }, /*#__PURE__*/_react.default.createElement(_react.Fragment, {
366
420
  key: orderId
@@ -375,15 +429,18 @@ function OrderableList(_ref) {
375
429
  }, a);
376
430
  })))));
377
431
  }
378
- function HeroWrapper(_ref5) {
379
- let children = _ref5.children,
380
- id = _ref5.id;
432
+ function HeroWrapper(_ref6) {
433
+ let children = _ref6.children,
434
+ id = _ref6.id;
381
435
  const _useHero = (0, _useHero2.default)(id, undefined, {
382
436
  onHeroStart: function onHeroStart(_c, _o, t) {
383
437
  t.querySelectorAll("img").forEach(function (img) {
384
438
  return img.style.visibility = "hidden";
385
439
  });
386
440
  },
441
+ onHeroCloned: function onHeroCloned() {
442
+ // if (!clone.classList.contains(Styles.visible)) clone.style.opacity = "0";
443
+ },
387
444
  onHeroEnd: function onHeroEnd() {
388
445
  if (heroRef.current) heroRef.current.querySelectorAll("img").forEach(function (img) {
389
446
  return img.style.visibility = "";
@@ -64,14 +64,35 @@ $fast: var(--orderable-list--speed);
64
64
  .transition {
65
65
  width: 100%;
66
66
  align-items: flex-start !important;
67
+ overflow: visible !important;
67
68
  > * {
68
69
  flex-direction: row !important;
69
70
  flex-wrap: wrap;
70
- &:first-child {
71
- visibility: hidden;
72
- }
71
+ // &:first-child {
72
+ // visibility: hidden;
73
+ // }
73
74
  &:last-child {
74
75
  visibility: visible;
75
76
  }
76
77
  }
77
78
  }
79
+
80
+ div.stub {
81
+ animation-name: stub;
82
+ position: absolute;
83
+ pointer-events: none;
84
+ opacity: 0 !important;
85
+ }
86
+
87
+ div.stubEntering {
88
+ animation-name: stub;
89
+ z-index: -1;
90
+ }
91
+ @keyframes stub {
92
+ 0% {
93
+ opacity: 1;
94
+ }
95
+ 100% {
96
+ opacity: 1;
97
+ }
98
+ }
@@ -103,7 +103,8 @@ function Select(_ref) {
103
103
  className: "".concat(otherProps.disabled ? "disabled" : "", " ").concat(rootClassName),
104
104
  contentClassName: "".concat(_SelectModule.default.optionsContainer, " ").concat(dropdownClassNames.dropdown),
105
105
  alignTo: alignTo,
106
- ref: collapsableRef
106
+ ref: collapsableRef,
107
+ anchorTo: _AnchoredTooltip.AnchoredTooltipAnchor.BOTTOM
107
108
  }, /*#__PURE__*/_react.default.createElement("div", {
108
109
  className: _SelectModule.default.items,
109
110
  onClick: function onClick(e) {
@@ -26,6 +26,8 @@ export default function useHero(id: string, options?: Partial<{
26
26
  * Usefull for triggering secondary animations
27
27
  */
28
28
  onHeroEnd?: () => void;
29
+ /** Do somethign with the clone before it goes to the html */
30
+ onHeroCloned?: (clone: HTMLDivElement) => void;
29
31
  /**
30
32
  * Do something when the hero starts the transition
31
33
  * Here it's usefull to switch classNames with the target.
@@ -93,6 +93,7 @@ function useHero(id) {
93
93
  }
94
94
  const oldClone = document.querySelector("[".concat(dataProperty, "-clone=\"").concat(ID(id), "\"]"));
95
95
  const clone = oldClone || otherElement.cloneNode(true);
96
+ if (events.onHeroCloned && !oldClone) events.onHeroCloned(clone);
96
97
 
97
98
  // Clean up thos properties that can cause confusion since it's a clone
98
99
  clone.style.visibility = "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onepercentio/one-ui",
3
- "version": "0.19.5",
3
+ "version": "0.19.7",
4
4
  "description": "A set of reusable components created through the development of Onepercent projects",
5
5
  "repository": "git@github.com:onepercentio/one-ui.git",
6
6
  "author": "Murilo Oliveira de Araujo <murilo.araujo@onepercent.io>",
@@ -79,6 +79,7 @@
79
79
  "kill-port": "^2.0.0",
80
80
  "lodash": "^4.17.21",
81
81
  "prerender-loader": "^1.3.0",
82
+ "react-dev-utils": "^12.0.1",
82
83
  "sharp": "^0.30.3",
83
84
  "webpack": "^5"
84
85
  },