UNPKG

monday-ui-react-core

Version:

Official monday.com UI resources for application development in React.js

3 lines (2 loc) 1.64 kB
import{defineProperty as e,toConsumableArray as t}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{NavDirections as r}from"../../hooks/useFullKeyboardListeners.js";var n=function(t){var n=e(e(e(e({},r.RIGHT,new Map),r.LEFT,new Map),r.UP,new Map),r.DOWN,new Map);return t.forEach((function(e){!function(e,t){var n=t.topElement,o=t.bottomElement,a=t.leftElement,l=t.rightElement;function i(e,t){throw Error("Circular positioning detected: the ".concat(e," element is already positioned to the ").concat(t," of the ").concat(t," element. This probably means the layout isn't ordered correctly."))}n&&o&&(e[r.UP].get(n)===o&&i("BOTTOM","TOP"),e[r.DOWN].get(o)===n&&i("TOP","BOTTOM")),a&&l&&(e[r.LEFT].get(a)===l&&i("RIGHT","LEFT"),e[r.RIGHT].get(l)===a&&i("LEFT","RIGHT"))}(n,e);var t=e.topElement,o=e.bottomElement,a=e.leftElement,l=e.rightElement;t&&o&&(n[r.UP].set(o,t),n[r.DOWN].set(t,o)),a&&l&&(n[r.LEFT].set(l,a),n[r.RIGHT].set(a,l))})),n},o=function(e){switch(e){case r.LEFT:return r.RIGHT;case r.RIGHT:return r.LEFT;case r.UP:return r.DOWN;case r.DOWN:return r.UP;default:throw Error("Unexpected direction: ".concat(e))}},a=function e(n,o){var a=n[o],i=t(a)[0];return i?function(e,t){var r=!1,n=t;for(;!r;){var o=l(e,n);o?n=o:r=!0}return n}(a,i[0]):e(n,[r.LEFT,r.RIGHT].includes(o)?r.UP:r.LEFT)},l=function e(t,r){var n,o=t.get(r);return o?!o.current||o.current.disabled||"true"===(null===(n=o.current.dataset)||void 0===n?void 0:n.disabled)?e(t,o):o:null};export{n as getDirectionMaps,l as getNextElementToFocusInDirection,o as getOppositeDirection,a as getOutmostElementInDirection}; //# sourceMappingURL=helper.js.map