@onepercentio/one-ui 0.20.4 → 0.21.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/.babelrc +6 -0
- package/.prod.babelrc +8 -2
- package/dist/assets/styles/variables.scss +1 -0
- package/dist/components/AdaptiveButton/AdaptiveButton.js +2 -2
- package/dist/components/AdaptiveContainer/AdaptiveContainer.js +28 -26
- package/dist/components/AdaptiveContainer/AdaptiveContainer.module.scss +3 -1
- package/dist/components/AdaptiveDialog/AdaptiveDialog.js +9 -9
- package/dist/components/AdaptiveSidebar/AdaptiveSidebar.js +14 -14
- package/dist/components/AnchoredTooltip/AnchoredTooltip.js +30 -30
- package/dist/components/AnimatedEntrance/AnimatedEntrance.d.ts +1 -1
- package/dist/components/AnimatedEntrance/AnimatedEntrance.js +34 -45
- package/dist/components/AsyncWrapper/AsyncWrapper.js +2 -2
- package/dist/components/Avatar/Avatar.js +4 -4
- package/dist/components/BucketFill/BucketFill.js +9 -9
- package/dist/components/Button/Button.js +4 -4
- package/dist/components/Card/Card.js +1 -1
- package/dist/components/Chart/Chart.view.js +34 -34
- package/dist/components/CheckBox/CheckBox.js +3 -3
- package/dist/components/Collapsable/Collapsable.js +18 -18
- package/dist/components/Countdown/Countdown.js +16 -16
- package/dist/components/Divider/Divider.js +1 -1
- package/dist/components/EmailInput/EmailInput.d.ts +1 -1
- package/dist/components/EmailInput/EmailInput.js +4 -4
- package/dist/components/FadeIn/FadeIn.js +9 -9
- package/dist/components/FileInput/FileInput.js +6 -6
- package/dist/components/FileInput/View/BigFactory/BigFactory.js +1 -1
- package/dist/components/FileInput/View/Compact/Compact.js +6 -6
- package/dist/components/FlowController/FlowController.js +4 -4
- package/dist/components/Form/Form.js +17 -28
- package/dist/components/Freeze/Freeze.js +1 -1
- package/dist/components/HSForms/HSForms.js +9 -11
- package/dist/components/Header/Header.js +7 -7
- package/dist/components/HeaderCloseBtn/HeaderCloseBtn.js +1 -1
- package/dist/components/InfinityScroll/InfinityScroll.js +25 -25
- package/dist/components/Input/Input.js +13 -13
- package/dist/components/InstantCounter/InstantCounter.js +9 -9
- package/dist/components/LavaLamp/LavaLamp.data.js +25 -25
- package/dist/components/LavaLamp/LavaLamp.js +7 -7
- package/dist/components/LavaLamp/v2/LavaLamp.js +29 -45
- package/dist/components/LinkToId/LinkToId.js +7 -7
- package/dist/components/Loader/Loader.js +2 -2
- package/dist/components/LoaderDotsIndicator/LoaderDotsIndicator.js +6 -6
- package/dist/components/LoopableVideo/LoopableVideo.js +4 -4
- package/dist/components/MainGrid/MainGrid.js +2 -2
- package/dist/components/MutableHamburgerButton/MutableHamburgerButton.js +2 -2
- package/dist/components/Notification/Notification.js +1 -1
- package/dist/components/OrderableList/OrderableList.js +113 -138
- package/dist/components/PaginationIndicator/PaginationIndicator.js +50 -50
- package/dist/components/Parallax/Parallax.js +39 -39
- package/dist/components/Parallax/math/helpers.js +18 -19
- package/dist/components/PasswordInput/PasswordInput.d.ts +1 -1
- package/dist/components/PasswordInput/PasswordInput.js +10 -10
- package/dist/components/PingPongText/PingPongText.js +15 -15
- package/dist/components/PixelatedScan/PixelatedScan.js +19 -19
- package/dist/components/Portal/Portal.js +10 -10
- package/dist/components/ProgressBar/ProgressBar.js +6 -6
- package/dist/components/ProgressTexts/ProgressTexts.js +3 -3
- package/dist/components/Radio/Radio.js +3 -3
- package/dist/components/SectionContainer/SectionContainer.js +1 -1
- package/dist/components/Select/Select.js +13 -13
- package/dist/components/Select/Select.module.scss +8 -5
- package/dist/components/Skeleton/Skeleton.js +1 -1
- package/dist/components/Spacing/Spacing.js +1 -1
- package/dist/components/StaticScroller/StaticScroller.js +12 -12
- package/dist/components/Switch/Switch.js +2 -2
- package/dist/components/Table/Table.js +11 -11
- package/dist/components/Tabs/Tabs.d.ts +6 -1
- package/dist/components/Tabs/Tabs.js +28 -9
- package/dist/components/Tabs/Tabs.module.scss +20 -2
- package/dist/components/Text/Text.js +5 -5
- package/dist/components/Transition/MasksFactory/DiagonalReveal.js +5 -5
- package/dist/components/Transition/MasksFactory/DiagonalSquareToBalls.js +17 -17
- package/dist/components/Transition/MasksFactory/PhysicsSquares.js +13 -13
- package/dist/components/Transition/MasksFactory/SquareToBalls.js +9 -9
- package/dist/components/Transition/MasksFactory/utils.js +8 -8
- package/dist/components/Transition/Transition.js +49 -49
- package/dist/components/UncontrolledTransition/UncontrolledTransition.js +7 -7
- package/dist/components/WalletConnectionWrapper/WalletConnectionWrapper.js +44 -82
- package/dist/components/utilitary/ScrollAndFocusLock/ScrollAndFocusLock.js +6 -6
- package/dist/context/AsyncProcess.js +19 -42
- package/dist/context/CustomBrowserRouter.js +6 -6
- package/dist/context/OneUIProvider.js +15 -15
- package/dist/hooks/logs/useDependencyChangeDetection.js +2 -5
- package/dist/hooks/persistence/useLocalStorage.js +7 -7
- package/dist/hooks/shims/ObjectWatchShim.js +1 -15
- package/dist/hooks/ui/useAdaptiveImage.js +6 -6
- package/dist/hooks/ui/useBreakpoint.js +5 -5
- package/dist/hooks/ui/useCustomScrollbar.js +2 -2
- package/dist/hooks/ui/useMouseHover.js +4 -4
- package/dist/hooks/ui/usePaginationControls.js +34 -34
- package/dist/hooks/ui/useSnapToViewport.js +3 -3
- package/dist/hooks/ui/useTilt.js +38 -38
- package/dist/hooks/ui/useZoomable.js +20 -20
- package/dist/hooks/useAsyncControl.js +21 -38
- package/dist/hooks/useContainedRepositioning.js +22 -22
- package/dist/hooks/useCustomHistory.js +2 -2
- package/dist/hooks/useElementFit.js +6 -6
- package/dist/hooks/useFirestoreWatch.js +26 -39
- package/dist/hooks/useForm.js +8 -8
- package/dist/hooks/useFreeze.js +1 -1
- package/dist/hooks/useHero.d.ts +1 -0
- package/dist/hooks/useHero.js +132 -91
- package/dist/hooks/useHero.module.scss +7 -0
- package/dist/hooks/useIntersection.js +3 -3
- package/dist/hooks/useMergeRefs.js +3 -7
- package/dist/hooks/useObserve.js +5 -5
- package/dist/hooks/usePagination.js +39 -59
- package/dist/hooks/usePooledOperation.js +8 -22
- package/dist/hooks/usePooling.js +17 -33
- package/dist/hooks/useRebound.js +5 -5
- package/dist/hooks/useShortIntl.js +13 -13
- package/dist/hooks/utility/useEvents.js +5 -5
- package/dist/hooks/utility/useModule.js +3 -3
- package/dist/hooks/utility/useQuery.js +1 -1
- package/dist/models/DebugLogger.js +2 -2
- package/dist/models/GenericContract.js +1 -1
- package/dist/storybookUtils/index.js +1 -1
- package/dist/types.d.ts +11 -4
- package/dist/utility.d.js +3 -3
- package/dist/utils/blockchain.js +29 -102
- package/dist/utils/flatten.js +3 -3
- package/dist/utils/html.utils.js +1 -1
- package/package.json +2 -1
- package/src/types.ts +155 -41
|
@@ -11,22 +11,22 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
11
11
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
12
12
|
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."); }
|
|
13
13
|
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); }
|
|
14
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
15
|
-
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)
|
|
14
|
+
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; }
|
|
15
|
+
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; } }
|
|
16
16
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
17
17
|
/**
|
|
18
18
|
* . .. ... . .. ...
|
|
19
19
|
**/
|
|
20
20
|
function LoaderDotsIndicator(_ref) {
|
|
21
|
-
|
|
21
|
+
let _ref$dotsCount = _ref.dotsCount,
|
|
22
22
|
dotsCount = _ref$dotsCount === void 0 ? 3 : _ref$dotsCount;
|
|
23
|
-
|
|
23
|
+
const _useState = (0, _react.useState)("."),
|
|
24
24
|
_useState2 = _slicedToArray(_useState, 2),
|
|
25
25
|
text = _useState2[0],
|
|
26
26
|
setText = _useState2[1];
|
|
27
27
|
(0, _react.useEffect)(function () {
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
const fullText = new Array(dotsCount).fill(".").join("");
|
|
29
|
+
const intervalId = setInterval(function () {
|
|
30
30
|
setText(function (a) {
|
|
31
31
|
return a === fullText ? "." : a + ".";
|
|
32
32
|
});
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = LoopableVideo;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
|
|
8
|
+
const _excluded = ["videoSrc", "percentToBackTo"];
|
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
10
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
11
11
|
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; }
|
|
@@ -14,7 +14,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
14
14
|
* Plays a video and loops between the end and the timestamp you set
|
|
15
15
|
**/
|
|
16
16
|
function LoopableVideo(_ref) {
|
|
17
|
-
|
|
17
|
+
let videoSrc = _ref.videoSrc,
|
|
18
18
|
percentToBackTo = _ref.percentToBackTo,
|
|
19
19
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
20
20
|
if (process.env.NODE_ENV === "development") if (percentToBackTo < 0 || percentToBackTo > 1) throw new Error("percentToBackTo should be a value between 0-1");
|
|
@@ -22,8 +22,8 @@ function LoopableVideo(_ref) {
|
|
|
22
22
|
autoPlay: true,
|
|
23
23
|
muted: true,
|
|
24
24
|
onEnded: function onEnded(_ref2) {
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
let currentTarget = _ref2.currentTarget;
|
|
26
|
+
const el = currentTarget;
|
|
27
27
|
el.currentTime = el.duration * percentToBackTo;
|
|
28
28
|
el.play();
|
|
29
29
|
}
|
|
@@ -15,10 +15,10 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
15
15
|
* This layout provides 3 parts to compose screens
|
|
16
16
|
**/
|
|
17
17
|
function MainGrid(_ref, ref) {
|
|
18
|
-
|
|
18
|
+
let children = _ref.children,
|
|
19
19
|
leftContent = _ref.leftContent,
|
|
20
20
|
rightContent = _ref.rightContent;
|
|
21
|
-
|
|
21
|
+
const refs = [(0, _react.useRef)(null), (0, _react.useRef)(null), (0, _react.useRef)(null)];
|
|
22
22
|
(0, _react.useImperativeHandle)(ref, function () {
|
|
23
23
|
return {
|
|
24
24
|
setOrientation: function setOrientation(orientation) {
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = MutableHamburgerButton;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _MutableHamburgerButtonModule = _interopRequireDefault(require("./MutableHamburgerButton.module.scss"));
|
|
9
|
-
|
|
9
|
+
const _excluded = ["state", "size", "className"];
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
11
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
12
12
|
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; }
|
|
@@ -15,7 +15,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
15
15
|
* A hamburger button that mutates according to it's state
|
|
16
16
|
**/
|
|
17
17
|
function MutableHamburgerButton(_ref) {
|
|
18
|
-
|
|
18
|
+
let _ref$state = _ref.state,
|
|
19
19
|
state = _ref$state === void 0 ? "default" : _ref$state,
|
|
20
20
|
size = _ref.size,
|
|
21
21
|
_ref$className = _ref.className,
|
|
@@ -12,7 +12,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
12
12
|
* A layout for the notification card
|
|
13
13
|
**/
|
|
14
14
|
function Notification(_ref) {
|
|
15
|
-
|
|
15
|
+
let type = _ref.type,
|
|
16
16
|
children = _ref.children;
|
|
17
17
|
return /*#__PURE__*/_react.default.createElement(_Card.default, {
|
|
18
18
|
className: "".concat(_NotificationModule.default.container, " ").concat(_NotificationModule.default[type])
|
|
@@ -18,7 +18,7 @@ var _Transition = require("../Transition");
|
|
|
18
18
|
var _OrderableListModule = _interopRequireDefault(require("./OrderableList.module.scss"));
|
|
19
19
|
var _useEvents = _interopRequireDefault(require("../../hooks/utility/useEvents"));
|
|
20
20
|
var _ownEvent = _interopRequireDefault(require("../../utils/ownEvent"));
|
|
21
|
-
|
|
21
|
+
const _excluded = ["children", "className", "mode", "shrinkToOnOrder", "reorderingClassName", "cloneClassName"];
|
|
22
22
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
23
23
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
24
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -28,21 +28,20 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
28
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; }
|
|
29
29
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
30
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 _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
32
31
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
33
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."); }
|
|
34
|
-
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)
|
|
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; } }
|
|
35
34
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
36
35
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
37
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."); }
|
|
38
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); }
|
|
39
38
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
40
39
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
41
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
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; }
|
|
42
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; }
|
|
43
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; }
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
const OrderableListContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
44
|
+
let OrderableListReorderMode = /*#__PURE__*/function (OrderableListReorderMode) {
|
|
46
45
|
OrderableListReorderMode["VERTICAL"] = "v";
|
|
47
46
|
OrderableListReorderMode["TWO_DIMENSIONS"] = "hv";
|
|
48
47
|
return OrderableListReorderMode;
|
|
@@ -58,7 +57,7 @@ function cleanKeys(keys) {
|
|
|
58
57
|
* This component receives a list of keyed elements and orders it based of the order provided via the prop "keyOrder"
|
|
59
58
|
**/
|
|
60
59
|
function OrderableList(_ref) {
|
|
61
|
-
|
|
60
|
+
let children = _ref.children,
|
|
62
61
|
_ref$className = _ref.className,
|
|
63
62
|
className = _ref$className === void 0 ? "" : _ref$className,
|
|
64
63
|
_ref$mode = _ref.mode,
|
|
@@ -67,48 +66,48 @@ function OrderableList(_ref) {
|
|
|
67
66
|
reorderingClassName = _ref.reorderingClassName,
|
|
68
67
|
cloneClassName = _ref.cloneClassName,
|
|
69
68
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
70
|
-
|
|
69
|
+
const availableKeys = children.map(function (a) {
|
|
71
70
|
return a.key;
|
|
72
71
|
});
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
const availableKeysDep = availableKeys.join(",");
|
|
73
|
+
const initializeOrder = (0, _react.useCallback)(function () {
|
|
74
|
+
const missingOrderKeys = "keyOrder" in props && props.keyOrder ? availableKeys.filter(function (a) {
|
|
76
75
|
return !props.keyOrder.includes(a);
|
|
77
76
|
}) : [];
|
|
78
77
|
return ("keyOrder" in props && props.keyOrder ? [].concat(_toConsumableArray(props.keyOrder), _toConsumableArray(missingOrderKeys)) : undefined) || availableKeys;
|
|
79
78
|
}, [availableKeysDep, props.keyOrder]);
|
|
80
|
-
|
|
79
|
+
const _useRef = (0, _react.useRef)([]),
|
|
81
80
|
anchorsList = _useRef.current;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
81
|
+
const eventEmitter = (0, _useEvents.default)();
|
|
82
|
+
const currentClone = (0, _react.useRef)(null);
|
|
83
|
+
const currentWorkingKey = (0, _react.useRef)();
|
|
84
|
+
const rootRef = (0, _react.useRef)(null);
|
|
85
|
+
const _useState = (0, _react.useState)(initializeOrder),
|
|
87
86
|
_useState2 = _slicedToArray(_useState, 2),
|
|
88
87
|
_order = _useState2[0],
|
|
89
88
|
setOrder = _useState2[1];
|
|
90
89
|
(0, _react.useEffect)(function () {
|
|
91
90
|
return setOrder(initializeOrder());
|
|
92
91
|
}, [initializeOrder]);
|
|
93
|
-
|
|
92
|
+
const order = (0, _react.useMemo)(function () {
|
|
94
93
|
return ("currentOrder" in props ? props.currentOrder || _order : _order).filter(function (o) {
|
|
95
94
|
return o.includes(";") || availableKeys.includes(o);
|
|
96
95
|
});
|
|
97
96
|
}, [props.currentOrder, _order, availableKeysDep]);
|
|
98
|
-
|
|
97
|
+
const cleanOrder = (0, _react.useMemo)(function () {
|
|
99
98
|
return order.map(function (a) {
|
|
100
99
|
return a.split(";")[0];
|
|
101
100
|
});
|
|
102
101
|
}, [order]);
|
|
103
|
-
|
|
102
|
+
const orderId = (0, _react.useMemo)(function () {
|
|
104
103
|
return "key-" + cleanOrder.join("");
|
|
105
104
|
}, [cleanOrder]);
|
|
106
105
|
function rootEl() {
|
|
107
106
|
if (mode === OrderableListReorderMode.TWO_DIMENSIONS) return rootRef.current.lastElementChild.lastElementChild;
|
|
108
107
|
return rootRef.current;
|
|
109
108
|
}
|
|
110
|
-
|
|
111
|
-
|
|
109
|
+
const findParentElement = function findParentElement(target) {
|
|
110
|
+
let parent = target;
|
|
112
111
|
while (parent.parentElement !== rootEl()) {
|
|
113
112
|
if (parent.parentElement === null) break;
|
|
114
113
|
parent = parent.parentElement;
|
|
@@ -119,52 +118,52 @@ function OrderableList(_ref) {
|
|
|
119
118
|
(0, _react.useLayoutEffect)(function () {
|
|
120
119
|
if (shrinkToOnOrder) rootEl().style.setProperty("--shrink-to", "".concat(shrinkToOnOrder, "px"));
|
|
121
120
|
}, [shrinkToOnOrder]);
|
|
122
|
-
|
|
121
|
+
const calculateReordering = (0, _react.useMemo)(function () {
|
|
123
122
|
return (0, _throttle.default)(function (e, els, currentOrder) {
|
|
124
123
|
if (els.length > currentOrder.length || !currentWorkingKey.current) return;
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
124
|
+
const parent = findParentElement(e.target);
|
|
125
|
+
const indexOfKeyInCleanOrder = els.indexOf(parent);
|
|
126
|
+
const keyOfTheOverElement = currentOrder[indexOfKeyInCleanOrder];
|
|
127
|
+
const isDraggingOwnElement = currentWorkingKey.current === keyOfTheOverElement;
|
|
129
128
|
if (indexOfKeyInCleanOrder === -1 || keyOfTheOverElement === undefined) return;
|
|
130
129
|
if (!isDraggingOwnElement) {
|
|
131
|
-
|
|
130
|
+
const _ref2 = function () {
|
|
132
131
|
if (mode === OrderableListReorderMode.TWO_DIMENSIONS) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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;
|
|
138
137
|
return {
|
|
139
|
-
isAfter:
|
|
140
|
-
isBefore:
|
|
138
|
+
isAfter: isAfter,
|
|
139
|
+
isBefore: isBefore
|
|
141
140
|
};
|
|
142
141
|
} else {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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;
|
|
148
147
|
return {
|
|
149
|
-
isAfter:
|
|
150
|
-
isBefore:
|
|
148
|
+
isAfter: isAfter,
|
|
149
|
+
isBefore: isBefore
|
|
151
150
|
};
|
|
152
151
|
}
|
|
153
152
|
}(),
|
|
154
153
|
isAfter = _ref2.isAfter,
|
|
155
154
|
isBefore = _ref2.isBefore;
|
|
156
|
-
|
|
155
|
+
const checkIfCanMove = function checkIfCanMove(keyOfOverElement) {
|
|
157
156
|
return keyOfOverElement === undefined || keyOfOverElement !== currentWorkingKey.current;
|
|
158
157
|
};
|
|
159
|
-
|
|
160
|
-
|
|
158
|
+
const indexOfTheNewElement = indexOfKeyInCleanOrder + (isAfter ? 1 : -1);
|
|
159
|
+
const shouldTriggerReordering = (isAfter || isBefore) && checkIfCanMove(currentOrder[indexOfTheNewElement]);
|
|
161
160
|
if (shouldTriggerReordering) {
|
|
162
161
|
setOrder(function (p) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
162
|
+
const previousIndex = currentOrder.indexOf(currentWorkingKey.current);
|
|
163
|
+
const indexOfKeyInProvidedOrder = cleanKeys(p).indexOf(keyOfTheOverElement);
|
|
164
|
+
let indexOfTheNewElement = indexOfKeyInProvidedOrder + (isBefore ? -1 : 0);
|
|
166
165
|
if (previousIndex > indexOfTheNewElement) indexOfTheNewElement++;
|
|
167
|
-
|
|
166
|
+
const orderWithoutCurrent = p.filter(function (a) {
|
|
168
167
|
if (a.startsWith("".concat(currentWorkingKey.current, ";"))) return false;
|
|
169
168
|
return a !== currentWorkingKey.current;
|
|
170
169
|
});
|
|
@@ -177,27 +176,21 @@ function OrderableList(_ref) {
|
|
|
177
176
|
}, []);
|
|
178
177
|
(0, _react.useEffect)(function () {
|
|
179
178
|
function registerListeners() {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
179
|
+
const els = Array.from(rootEl().children);
|
|
180
|
+
const calculateReorderingCall = function calculateReorderingCall(e) {
|
|
181
|
+
const els = Array.from(rootEl().children);
|
|
183
182
|
calculateReordering(e, els, cleanOrder);
|
|
184
183
|
};
|
|
185
|
-
for (
|
|
186
|
-
var el = _els[_i2];
|
|
187
|
-
el.addEventListener("mousemove", calculateReorderingCall);
|
|
188
|
-
}
|
|
184
|
+
for (let el of els) el.addEventListener("mousemove", calculateReorderingCall);
|
|
189
185
|
return function () {
|
|
190
|
-
for (
|
|
191
|
-
var _el = _els2[_i3];
|
|
192
|
-
_el.removeEventListener("mousemove", calculateReorderingCall);
|
|
193
|
-
}
|
|
186
|
+
for (let el of els) el.removeEventListener("mousemove", calculateReorderingCall);
|
|
194
187
|
};
|
|
195
188
|
}
|
|
196
189
|
if (mode === OrderableListReorderMode.VERTICAL) {
|
|
197
190
|
return registerListeners();
|
|
198
191
|
} else {
|
|
199
|
-
|
|
200
|
-
|
|
192
|
+
let unsubscribe;
|
|
193
|
+
let timeout = setTimeout(function () {
|
|
201
194
|
unsubscribe = registerListeners();
|
|
202
195
|
}, 250);
|
|
203
196
|
return function () {
|
|
@@ -209,18 +202,18 @@ function OrderableList(_ref) {
|
|
|
209
202
|
(0, _react.useEffect)(function () {
|
|
210
203
|
if ("onChangeKeyOrder" in props) props.onChangeKeyOrder(cleanKeys(_order));
|
|
211
204
|
}, [_order]);
|
|
212
|
-
|
|
205
|
+
const cleanOrderRef = (0, _react.useRef)(cleanOrder);
|
|
213
206
|
(0, _react.useEffect)(function () {
|
|
214
207
|
cleanOrderRef.current = cleanOrder;
|
|
215
208
|
}, [cleanOrder]);
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
209
|
+
const onAnchorClick = (0, _react.useCallback)(function (_ref3) {
|
|
210
|
+
let anchor = _ref3.target;
|
|
211
|
+
let offset;
|
|
212
|
+
const orderableListItemForAnchor = findParentElement(anchor);
|
|
213
|
+
const box = orderableListItemForAnchor.getBoundingClientRect();
|
|
214
|
+
const els = Array.from(rootEl().children);
|
|
215
|
+
const elIndex = els.indexOf(orderableListItemForAnchor);
|
|
216
|
+
const clone = orderableListItemForAnchor.cloneNode(true);
|
|
224
217
|
currentClone.current = clone;
|
|
225
218
|
if (process.env.NODE_ENV === "development") clone.setAttribute("data-testid", "orderable-list-clone");
|
|
226
219
|
clone.setAttribute("data-orderableid", "orderable-list-clone");
|
|
@@ -236,23 +229,23 @@ function OrderableList(_ref) {
|
|
|
236
229
|
}, 0);
|
|
237
230
|
orderableListItemForAnchor.classList.add(_OrderableListModule.default.currentOrdering);
|
|
238
231
|
orderableListItemForAnchor.classList.remove(_OrderableListModule.default.visible);
|
|
239
|
-
|
|
240
|
-
|
|
232
|
+
const movementControl = function movementControl(e) {
|
|
233
|
+
const _ref4 = "touches" in e ? {
|
|
241
234
|
x: e.touches[0].pageX,
|
|
242
235
|
y: e.touches[0].pageY
|
|
243
236
|
} : e,
|
|
244
237
|
x1 = _ref4.x,
|
|
245
238
|
y1 = _ref4.y;
|
|
246
239
|
if (!offset) offset = [x1 - box.left, y1 - box.top];
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
offsetX =
|
|
250
|
-
offsetY =
|
|
240
|
+
const _offset = offset,
|
|
241
|
+
_offset2 = _slicedToArray(_offset, 2),
|
|
242
|
+
offsetX = _offset2[0],
|
|
243
|
+
offsetY = _offset2[1];
|
|
251
244
|
clone.style.top = "".concat(y1 - offsetY, "px");
|
|
252
245
|
clone.style.left = "".concat(x1 - offsetX, "px");
|
|
253
246
|
};
|
|
254
247
|
document.body.appendChild(clone);
|
|
255
|
-
|
|
248
|
+
const deleteClone = function deleteClone() {
|
|
256
249
|
window.removeEventListener("mousemove", movementControl);
|
|
257
250
|
window.removeEventListener("touchmove", movementControl);
|
|
258
251
|
window.removeEventListener("touchend", deleteClone);
|
|
@@ -261,7 +254,7 @@ function OrderableList(_ref) {
|
|
|
261
254
|
currentWorkingKey.current = undefined;
|
|
262
255
|
window.document.body.classList.remove(_OrderableListModule.default.unselectable);
|
|
263
256
|
{
|
|
264
|
-
|
|
257
|
+
let cleanUp = function cleanUp() {
|
|
265
258
|
if (shrinkToOnOrder) {
|
|
266
259
|
rootEl().style.removeProperty("padding-top");
|
|
267
260
|
rootEl().style.removeProperty("min-height");
|
|
@@ -269,38 +262,32 @@ function OrderableList(_ref) {
|
|
|
269
262
|
eventEmitter.dispatcher("order-stop");
|
|
270
263
|
rootEl().classList.remove(_OrderableListModule.default.ordering);
|
|
271
264
|
if (reorderingClassName) rootEl().classList.remove(reorderingClassName);
|
|
272
|
-
for (
|
|
273
|
-
var el = _els4[_i4];
|
|
274
|
-
el.classList.remove(_OrderableListModule.default.visible);
|
|
275
|
-
}
|
|
265
|
+
for (let el of els) el.classList.remove(_OrderableListModule.default.visible);
|
|
276
266
|
clone.remove();
|
|
277
267
|
currentClone.current = null;
|
|
278
|
-
for (
|
|
279
|
-
var _el2 = _arr2[_i5];
|
|
280
|
-
_el2.style.height = "";
|
|
281
|
-
}
|
|
268
|
+
for (let el of Array.from(elInvisible.children)) el.style.height = "";
|
|
282
269
|
};
|
|
283
|
-
|
|
284
|
-
|
|
270
|
+
const els = Array.from(rootEl().children);
|
|
271
|
+
const elInvisible = els.find(function (a) {
|
|
285
272
|
return !a.classList.contains(_OrderableListModule.default.visible) && a.style.maxHeight !== "0px";
|
|
286
273
|
});
|
|
287
274
|
if (shrinkToOnOrder) {
|
|
288
|
-
|
|
275
|
+
const child = elInvisible.lastElementChild;
|
|
289
276
|
child.style.maxHeight = "".concat(child.scrollHeight, "px");
|
|
290
277
|
child.classList.add(_OrderableListModule.default.transitionHeight);
|
|
291
|
-
|
|
278
|
+
const onEnd = (0, _ownEvent.default)(function () {
|
|
292
279
|
child.removeEventListener("transitionend", onEnd);
|
|
293
280
|
child.style.maxHeight = "initial";
|
|
294
281
|
child.classList.remove(_OrderableListModule.default.transitionHeight);
|
|
295
282
|
});
|
|
296
283
|
child.addEventListener("transitionend", onEnd);
|
|
297
284
|
}
|
|
298
|
-
|
|
299
|
-
if (clone.style.top.startsWith(Math.floor(
|
|
285
|
+
const box = elInvisible.getBoundingClientRect();
|
|
286
|
+
if (clone.style.top.startsWith(Math.floor(box.top).toString()) && clone.style.left.startsWith(Math.floor(box.left).toString())) {
|
|
300
287
|
cleanUp();
|
|
301
288
|
} else {
|
|
302
|
-
clone.style.top = "".concat(
|
|
303
|
-
clone.style.left = "".concat(
|
|
289
|
+
clone.style.top = "".concat(box.top, "px");
|
|
290
|
+
clone.style.left = "".concat(box.left, "px");
|
|
304
291
|
clone.style.transition = "top 500ms linear, left 500ms linear";
|
|
305
292
|
clone.addEventListener("transitionend", function () {
|
|
306
293
|
cleanUp();
|
|
@@ -308,26 +295,14 @@ function OrderableList(_ref) {
|
|
|
308
295
|
}
|
|
309
296
|
}
|
|
310
297
|
};
|
|
311
|
-
for (
|
|
312
|
-
var el = _els5[_i6];
|
|
298
|
+
for (let el of els) {
|
|
313
299
|
el.classList.add(_OrderableListModule.default.visible);
|
|
314
300
|
}
|
|
315
301
|
if (shrinkToOnOrder) {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
var _el3 = _step.value;
|
|
321
|
-
_el3.style.maxHeight = "".concat(_el3.scrollHeight, "px");
|
|
322
|
-
}
|
|
323
|
-
} catch (err) {
|
|
324
|
-
_iterator.e(err);
|
|
325
|
-
} finally {
|
|
326
|
-
_iterator.f();
|
|
327
|
-
}
|
|
328
|
-
var targetHeight = elIndex * shrinkToOnOrder;
|
|
329
|
-
var currentHeight = orderableListItemForAnchor.offsetTop - els[0].offsetTop;
|
|
330
|
-
var paddingTop = currentHeight - targetHeight;
|
|
302
|
+
for (let el of els) el.style.maxHeight = "".concat(el.scrollHeight, "px");
|
|
303
|
+
const targetHeight = elIndex * shrinkToOnOrder;
|
|
304
|
+
const currentHeight = orderableListItemForAnchor.offsetTop - els[0].offsetTop;
|
|
305
|
+
const paddingTop = currentHeight - targetHeight;
|
|
331
306
|
rootEl().style.paddingTop = "".concat(paddingTop, "px");
|
|
332
307
|
rootEl().style.minHeight = "".concat(rootEl().clientHeight, "px");
|
|
333
308
|
}
|
|
@@ -345,8 +320,8 @@ function OrderableList(_ref) {
|
|
|
345
320
|
}, []);
|
|
346
321
|
(0, _react.useLayoutEffect)(function () {
|
|
347
322
|
if (currentClone.current) {
|
|
348
|
-
|
|
349
|
-
|
|
323
|
+
const els = Array.from(rootEl().children);
|
|
324
|
+
const elInvisible = els.find(function (a) {
|
|
350
325
|
return !a.classList.contains(_OrderableListModule.default.visible) && a.style.maxHeight !== "0px";
|
|
351
326
|
});
|
|
352
327
|
elInvisible.children[0].style.height = "".concat(currentClone.current.clientHeight, "px");
|
|
@@ -355,10 +330,10 @@ function OrderableList(_ref) {
|
|
|
355
330
|
}, 150);
|
|
356
331
|
}
|
|
357
332
|
}, [cleanOrder]);
|
|
358
|
-
|
|
333
|
+
const toSpread = _objectSpread({}, props);
|
|
359
334
|
delete toSpread.keyOrder;
|
|
360
335
|
delete toSpread.onChangeKeyOrder;
|
|
361
|
-
|
|
336
|
+
const childrenToRender = _toConsumableArray(children).filter(function (a) {
|
|
362
337
|
return cleanOrder.includes(a.key);
|
|
363
338
|
}).sort(function (a, b) {
|
|
364
339
|
return cleanOrder.indexOf(a.key) - cleanOrder.indexOf(b.key);
|
|
@@ -369,7 +344,7 @@ function OrderableList(_ref) {
|
|
|
369
344
|
});
|
|
370
345
|
(0, _react.useLayoutEffect)(function () {
|
|
371
346
|
rootEl().addEventListener("touchstart", function (e) {
|
|
372
|
-
|
|
347
|
+
const relatedAnchor = anchorsList.find(function (anchor) {
|
|
373
348
|
return anchor.contains(e.target);
|
|
374
349
|
});
|
|
375
350
|
if (relatedAnchor) {
|
|
@@ -377,33 +352,33 @@ function OrderableList(_ref) {
|
|
|
377
352
|
onAnchorClick({
|
|
378
353
|
target: relatedAnchor
|
|
379
354
|
});
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
355
|
+
const moveCb = (0, _throttle.default)(function (e) {
|
|
356
|
+
const touch = e.touches[0];
|
|
357
|
+
const _ref5 = [touch.clientX, touch.clientY],
|
|
383
358
|
x = _ref5[0],
|
|
384
359
|
y = _ref5[1];
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
360
|
+
const els = Array.from(rootEl().children);
|
|
361
|
+
const currentElementIdx = els.findIndex(function (c, i) {
|
|
362
|
+
const rect = c === null || c === void 0 ? void 0 : c.getBoundingClientRect();
|
|
388
363
|
if (!rect) return false;
|
|
389
364
|
return rect.top < y && rect.top + rect.height > y;
|
|
390
365
|
});
|
|
391
366
|
if (currentElementIdx !== -1) {
|
|
392
|
-
|
|
393
|
-
|
|
367
|
+
const el = els[currentElementIdx];
|
|
368
|
+
const rect = el.getBoundingClientRect();
|
|
394
369
|
calculateReordering({
|
|
395
370
|
target: el,
|
|
396
371
|
offsetY: y - rect.top
|
|
397
372
|
}, els, cleanOrderRef.current);
|
|
398
373
|
}
|
|
399
374
|
}, 500);
|
|
400
|
-
|
|
401
|
-
|
|
375
|
+
const t = e.target;
|
|
376
|
+
const touchMoveCb = function touchMoveCb(e) {
|
|
402
377
|
e.stopPropagation();
|
|
403
378
|
window.dispatchEvent(new TouchEvent(e.type, e));
|
|
404
379
|
moveCb(e);
|
|
405
380
|
};
|
|
406
|
-
|
|
381
|
+
const removeCb = function removeCb(e) {
|
|
407
382
|
t.removeEventListener("touchmove", touchMoveCb);
|
|
408
383
|
t.removeEventListener("touchend", removeCb);
|
|
409
384
|
window.dispatchEvent(new TouchEvent(e.type, e));
|
|
@@ -413,7 +388,7 @@ function OrderableList(_ref) {
|
|
|
413
388
|
}
|
|
414
389
|
});
|
|
415
390
|
}, []);
|
|
416
|
-
|
|
391
|
+
const e = (0, _react.useMemo)(function () {
|
|
417
392
|
return {
|
|
418
393
|
bindAnchor: function bindAnchor(el) {
|
|
419
394
|
el.addEventListener("mousedown", onAnchorClick);
|
|
@@ -459,9 +434,9 @@ function OrderableList(_ref) {
|
|
|
459
434
|
})))));
|
|
460
435
|
}
|
|
461
436
|
function HeroWrapper(_ref6) {
|
|
462
|
-
|
|
437
|
+
let children = _ref6.children,
|
|
463
438
|
id = _ref6.id;
|
|
464
|
-
|
|
439
|
+
const _useHero = (0, _useHero2.default)(id, undefined, {
|
|
465
440
|
onHeroStart: function onHeroStart(_c, _o, t) {
|
|
466
441
|
t.querySelectorAll("img").forEach(function (img) {
|
|
467
442
|
return img.style.visibility = "hidden";
|
|
@@ -482,11 +457,11 @@ function HeroWrapper(_ref6) {
|
|
|
482
457
|
}, children);
|
|
483
458
|
}
|
|
484
459
|
function useOrderableListAnchor() {
|
|
485
|
-
|
|
486
|
-
|
|
460
|
+
const anchorRef = (0, _react.useRef)(null);
|
|
461
|
+
const ctx = (0, _react.useContext)(OrderableListContext);
|
|
487
462
|
(0, _react.useLayoutEffect)(function () {
|
|
488
463
|
if (!ctx) return;
|
|
489
|
-
|
|
464
|
+
const bindAnchor = ctx.bindAnchor,
|
|
490
465
|
unbindAnchor = ctx.unbindAnchor;
|
|
491
466
|
bindAnchor(anchorRef.current);
|
|
492
467
|
return function () {
|
|
@@ -498,12 +473,12 @@ function useOrderableListAnchor() {
|
|
|
498
473
|
};
|
|
499
474
|
}
|
|
500
475
|
function useOrderableEvents(events) {
|
|
501
|
-
|
|
476
|
+
const _useContext = (0, _react.useContext)(OrderableListContext),
|
|
502
477
|
on = _useContext.on;
|
|
503
478
|
(0, _react.useEffect)(function () {
|
|
504
|
-
|
|
505
|
-
for (
|
|
506
|
-
unsubscribers.push(on(
|
|
479
|
+
const unsubscribers = [];
|
|
480
|
+
for (let eventName in events) {
|
|
481
|
+
unsubscribers.push(on(eventName, events[eventName]));
|
|
507
482
|
}
|
|
508
483
|
return function () {
|
|
509
484
|
unsubscribers.forEach(function (u) {
|