@kongkiat/react-context-menu
Version:
Context Menu for React
21 lines (20 loc) • 32.9 kB
JavaScript
import{jsx as e,jsxs as n}from"react/jsx-runtime";import t,{useRef as r,useState as o,useCallback as i,useEffect as a}from"react";import s from"react-dom";!function(e,n){void 0===n&&(n={});var t=n.insertAt;if(e&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===t&&r.firstChild?r.insertBefore(o,r.firstChild):r.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}(':root {\n --bg-default-color: rgb(255, 255, 255);\n --bg-default-color-hover: rgb(229, 231, 233);\n --text-default-color: rgb(107, 114, 128);\n --border-default-color: rgb(178, 186, 187);\n}\n\n:root.dark {\n --bg-default-color: rgb(24, 24, 24);\n --bg-default-color-hover: rgb(39, 39, 42);\n --text-default-color: rgb(229, 231, 235);\n --border-default-color: rgb(72, 72, 72);\n}\n\n.contextmenu {\n position: fixed;\n left: 0;\n top: calc(100% + 10px);\n z-index: 9999;\n}\n.contextmenu__item {\n display: block;\n cursor: pointer;\n user-select: none;\n transition: 0.2s;\n position: relative;\n}\n.contextmenu__item--disabled {\n opacity: 0.5;\n cursor: no-drop;\n}\n.contextmenu .submenu {\n position: relative;\n}\n.contextmenu .submenu__item {\n position: absolute;\n top: 0;\n left: 100%;\n opacity: 0;\n visibility: hidden;\n}\n.contextmenu .submenu > .contextmenu__item:after {\n content: "";\n width: 0;\n height: 0;\n position: absolute;\n top: 50%;\n transform: translateY(-50%);\n right: 0px;\n transition: 0.2s;\n}\n\n.fade-enter {\n opacity: 0;\n}\n\n.fade-enter-active {\n opacity: 1;\n transition: opacity 200ms;\n}\n\n.fade-exit {\n opacity: 1;\n}\n\n.fade-exit-active {\n opacity: 0;\n transition: opacity 200ms;\n}\n\n.zoom-enter {\n opacity: 0;\n transform: scale(0.8);\n transform-origin: top left;\n}\n\n.zoom-enter-active {\n opacity: 1;\n transform: scale(1);\n transition: opacity 200ms, transform 200ms;\n transform-origin: top left;\n}\n\n.zoom-exit {\n opacity: 1;\n transform: scale(1);\n transform-origin: top left;\n}\n\n.zoom-exit-active {\n opacity: 0;\n transform: scale(0.8);\n transition: opacity 200ms, transform 200ms;\n transform-origin: top left;\n}\n\n.toTopLeft-enter {\n opacity: 0;\n transform: translate(10px, 10px);\n}\n\n.toTopLeft-enter-active {\n opacity: 1;\n transform: translate(0px, 0px);\n transition: opacity 200ms, transform 200ms;\n}\n\n.toTopLeft-exit {\n opacity: 1;\n transform: translate(0px, 0px);\n}\n\n.toTopLeft-exit-active {\n opacity: 0;\n transform: translate(10px, 10px);\n transition: opacity 200ms, transform 200ms;\n}\n\n.rightToLeft-enter {\n opacity: 0;\n transform: translateX(10px);\n}\n\n.rightToLeft-enter-active {\n opacity: 1;\n transform: translateX(0px);\n transition: opacity 200ms, transform 200ms;\n}\n\n.rightToLeft-exit {\n opacity: 1;\n transform: translateX(0px);\n}\n\n.rightToLeft-exit-active {\n opacity: 0;\n transform: translateX(10px);\n transition: opacity 200ms, transform 200ms;\n}\n\n.pop-enter {\n opacity: 0;\n transform: scale(0.8);\n}\n\n.pop-enter-active {\n opacity: 1;\n transform: scale(1);\n transition: opacity 200ms, transform 200ms;\n}\n\n.pop-exit {\n opacity: 1;\n transform: scale(1);\n}\n\n.pop-exit-active {\n opacity: 0;\n transform: scale(0.8);\n transition: opacity 200ms, transform 200ms;\n}');var c=function(){return c=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var o in n=arguments[t])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e},c.apply(this,arguments)};function u(e,n,t){if(t||2===arguments.length)for(var r,o=0,i=n.length;o<i;o++)!r&&o in n||(r||(r=Array.prototype.slice.call(n,0,o)),r[o]=n[o]);return e.concat(r||Array.prototype.slice.call(n))}function l(e,n){return e(n={exports:{}},n.exports),n.exports}"function"==typeof SuppressedError&&SuppressedError;var p=l((function(e){
/*!
Copyright (c) 2018 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
*/
!function(){var n={}.hasOwnProperty;function t(){for(var e="",n=0;n<arguments.length;n++){var t=arguments[n];t&&(e=o(e,r(t)))}return e}function r(e){if("string"==typeof e||"number"==typeof e)return e;if("object"!=typeof e)return"";if(Array.isArray(e))return t.apply(null,e);if(e.toString!==Object.prototype.toString&&!e.toString.toString().includes("[native code]"))return e.toString();var r="";for(var i in e)n.call(e,i)&&e[i]&&(r=o(r,i));return r}function o(e,n){return n?e?e+" "+n:e+n:e}e.exports?(t.default=t,e.exports=t):window.classNames=t}()}));function f(){return f=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)({}).hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},f.apply(null,arguments)}function d(e,n){if(null==e)return{};var t={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(n.indexOf(r)>=0)continue;t[r]=e[r]}return t}function m(e,n){return m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,n){return e.__proto__=n,e},m(e,n)}function y(e,n){e.prototype=Object.create(n.prototype),e.prototype.constructor=e,m(e,n)
/** @license React v16.13.1
* react-is.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/}var v="function"==typeof Symbol&&Symbol.for,h=v?Symbol.for("react.element"):60103,b=v?Symbol.for("react.portal"):60106,E=v?Symbol.for("react.fragment"):60107,g=v?Symbol.for("react.strict_mode"):60108,x=v?Symbol.for("react.profiler"):60114,O=v?Symbol.for("react.provider"):60109,S=v?Symbol.for("react.context"):60110,w=v?Symbol.for("react.async_mode"):60111,C=v?Symbol.for("react.concurrent_mode"):60111,N=v?Symbol.for("react.forward_ref"):60112,T=v?Symbol.for("react.suspense"):60113,j=v?Symbol.for("react.suspense_list"):60120,P=v?Symbol.for("react.memo"):60115,_=v?Symbol.for("react.lazy"):60116,R=v?Symbol.for("react.block"):60121,k=v?Symbol.for("react.fundamental"):60117,$=v?Symbol.for("react.responder"):60118,M=v?Symbol.for("react.scope"):60119;function D(e){if("object"==typeof e&&null!==e){var n=e.$$typeof;switch(n){case h:switch(e=e.type){case w:case C:case E:case x:case g:case T:return e;default:switch(e=e&&e.$$typeof){case S:case N:case _:case P:case O:return e;default:return n}}case b:return n}}}function L(e){return D(e)===C}var A={AsyncMode:w,ConcurrentMode:C,ContextConsumer:S,ContextProvider:O,Element:h,ForwardRef:N,Fragment:E,Lazy:_,Memo:P,Portal:b,Profiler:x,StrictMode:g,Suspense:T,isAsyncMode:function(e){return L(e)||D(e)===w},isConcurrentMode:L,isContextConsumer:function(e){return D(e)===S},isContextProvider:function(e){return D(e)===O},isElement:function(e){return"object"==typeof e&&null!==e&&e.$$typeof===h},isForwardRef:function(e){return D(e)===N},isFragment:function(e){return D(e)===E},isLazy:function(e){return D(e)===_},isMemo:function(e){return D(e)===P},isPortal:function(e){return D(e)===b},isProfiler:function(e){return D(e)===x},isStrictMode:function(e){return D(e)===g},isSuspense:function(e){return D(e)===T},isValidElementType:function(e){return"string"==typeof e||"function"==typeof e||e===E||e===C||e===x||e===g||e===T||e===j||"object"==typeof e&&null!==e&&(e.$$typeof===_||e.$$typeof===P||e.$$typeof===O||e.$$typeof===S||e.$$typeof===N||e.$$typeof===k||e.$$typeof===$||e.$$typeof===M||e.$$typeof===R)},typeOf:D},I=l((function(e,n){"production"!==process.env.NODE_ENV&&function(){var e="function"==typeof Symbol&&Symbol.for,t=e?Symbol.for("react.element"):60103,r=e?Symbol.for("react.portal"):60106,o=e?Symbol.for("react.fragment"):60107,i=e?Symbol.for("react.strict_mode"):60108,a=e?Symbol.for("react.profiler"):60114,s=e?Symbol.for("react.provider"):60109,c=e?Symbol.for("react.context"):60110,u=e?Symbol.for("react.async_mode"):60111,l=e?Symbol.for("react.concurrent_mode"):60111,p=e?Symbol.for("react.forward_ref"):60112,f=e?Symbol.for("react.suspense"):60113,d=e?Symbol.for("react.suspense_list"):60120,m=e?Symbol.for("react.memo"):60115,y=e?Symbol.for("react.lazy"):60116,v=e?Symbol.for("react.block"):60121,h=e?Symbol.for("react.fundamental"):60117,b=e?Symbol.for("react.responder"):60118,E=e?Symbol.for("react.scope"):60119;function g(e){if("object"==typeof e&&null!==e){var n=e.$$typeof;switch(n){case t:var d=e.type;switch(d){case u:case l:case o:case a:case i:case f:return d;default:var v=d&&d.$$typeof;switch(v){case c:case p:case y:case m:case s:return v;default:return n}}case r:return n}}}var x=u,O=l,S=c,w=s,C=t,N=p,T=o,j=y,P=m,_=r,R=a,k=i,$=f,M=!1;function D(e){return g(e)===l}n.AsyncMode=x,n.ConcurrentMode=O,n.ContextConsumer=S,n.ContextProvider=w,n.Element=C,n.ForwardRef=N,n.Fragment=T,n.Lazy=j,n.Memo=P,n.Portal=_,n.Profiler=R,n.StrictMode=k,n.Suspense=$,n.isAsyncMode=function(e){return M||(M=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),D(e)||g(e)===u},n.isConcurrentMode=D,n.isContextConsumer=function(e){return g(e)===c},n.isContextProvider=function(e){return g(e)===s},n.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},n.isForwardRef=function(e){return g(e)===p},n.isFragment=function(e){return g(e)===o},n.isLazy=function(e){return g(e)===y},n.isMemo=function(e){return g(e)===m},n.isPortal=function(e){return g(e)===r},n.isProfiler=function(e){return g(e)===a},n.isStrictMode=function(e){return g(e)===i},n.isSuspense=function(e){return g(e)===f},n.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===o||e===l||e===a||e===i||e===f||e===d||"object"==typeof e&&null!==e&&(e.$$typeof===y||e.$$typeof===m||e.$$typeof===s||e.$$typeof===c||e.$$typeof===p||e.$$typeof===h||e.$$typeof===b||e.$$typeof===E||e.$$typeof===v)},n.typeOf=g}()}));I.AsyncMode,I.ConcurrentMode,I.ContextConsumer,I.ContextProvider,I.Element,I.ForwardRef,I.Fragment,I.Lazy,I.Memo,I.Portal,I.Profiler,I.StrictMode,I.Suspense,I.isAsyncMode,I.isConcurrentMode,I.isContextConsumer,I.isContextProvider,I.isElement,I.isForwardRef,I.isFragment,I.isLazy,I.isMemo,I.isPortal,I.isProfiler,I.isStrictMode,I.isSuspense,I.isValidElementType,I.typeOf;var V=l((function(e){"production"===process.env.NODE_ENV?e.exports=A:e.exports=I})),z=Object.getOwnPropertySymbols,F=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable;
/*
object-assign
(c) Sindre Sorhus
@license MIT
*/var W=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var n={},t=0;t<10;t++)n["_"+String.fromCharCode(t)]=t;var r=Object.getOwnPropertyNames(n).map((function(e){return n[e]}));if("0123456789"!==r.join(""))return!1;var o={};return"abcdefghijklmnopqrst".split("").forEach((function(e){o[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},o)).join("")}catch(e){return!1}}()?Object.assign:function(e,n){for(var t,r,o=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),i=1;i<arguments.length;i++){for(var a in t=Object(arguments[i]))F.call(t,a)&&(o[a]=t[a]);if(z){r=z(t);for(var s=0;s<r.length;s++)q.call(t,r[s])&&(o[r[s]]=t[r[s]])}}return o},U="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",X=Function.call.bind(Object.prototype.hasOwnProperty),Y=function(){};if("production"!==process.env.NODE_ENV){var H=U,B={},J=X;Y=function(e){var n="Warning: "+e;"undefined"!=typeof console&&console.error(n);try{throw new Error(n)}catch(e){}}}function G(e,n,t,r,o){if("production"!==process.env.NODE_ENV)for(var i in e)if(J(e,i)){var a;try{if("function"!=typeof e[i]){var s=Error((r||"React class")+": "+t+" type `"+i+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[i]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw s.name="Invariant Violation",s}a=e[i](n,i,r,t,null,H)}catch(e){a=e}if(!a||a instanceof Error||Y((r||"React class")+": type specification of "+t+" `"+i+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof a+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),a instanceof Error&&!(a.message in B)){B[a.message]=!0;var c=o?o():"";Y("Failed "+t+" type: "+a.message+(null!=c?c:""))}}}G.resetWarningCache=function(){"production"!==process.env.NODE_ENV&&(B={})};var Q=G,K=function(){};function Z(){return null}"production"!==process.env.NODE_ENV&&(K=function(e){var n="Warning: "+e;"undefined"!=typeof console&&console.error(n);try{throw new Error(n)}catch(e){}});var ee=function(e,n){var t="function"==typeof Symbol&&Symbol.iterator,r="@@iterator";var o="<<anonymous>>",i={array:u("array"),bigint:u("bigint"),bool:u("boolean"),func:u("function"),number:u("number"),object:u("object"),string:u("string"),symbol:u("symbol"),any:c(Z),arrayOf:function(e){return c((function(n,t,r,o,i){if("function"!=typeof e)return new s("Property `"+i+"` of component `"+r+"` has invalid PropType notation inside arrayOf.");var a=n[t];if(!Array.isArray(a))return new s("Invalid "+o+" `"+i+"` of type `"+f(a)+"` supplied to `"+r+"`, expected an array.");for(var c=0;c<a.length;c++){var u=e(a,c,r,o,i+"["+c+"]",U);if(u instanceof Error)return u}return null}))},element:c((function(n,t,r,o,i){var a=n[t];return e(a)?null:new s("Invalid "+o+" `"+i+"` of type `"+f(a)+"` supplied to `"+r+"`, expected a single ReactElement.")})),elementType:c((function(e,n,t,r,o){var i=e[n];return V.isValidElementType(i)?null:new s("Invalid "+r+" `"+o+"` of type `"+f(i)+"` supplied to `"+t+"`, expected a single ReactElement type.")})),instanceOf:function(e){return c((function(n,t,r,i,a){if(!(n[t]instanceof e)){var c=e.name||o;return new s("Invalid "+i+" `"+a+"` of type `"+(((u=n[t]).constructor&&u.constructor.name?u.constructor.name:o)+"` supplied to `")+r+"`, expected instance of `"+c+"`.")}var u;return null}))},node:c((function(e,n,t,r,o){return p(e[n])?null:new s("Invalid "+r+" `"+o+"` supplied to `"+t+"`, expected a ReactNode.")})),objectOf:function(e){return c((function(n,t,r,o,i){if("function"!=typeof e)return new s("Property `"+i+"` of component `"+r+"` has invalid PropType notation inside objectOf.");var a=n[t],c=f(a);if("object"!==c)return new s("Invalid "+o+" `"+i+"` of type `"+c+"` supplied to `"+r+"`, expected an object.");for(var u in a)if(X(a,u)){var l=e(a,u,r,o,i+"."+u,U);if(l instanceof Error)return l}return null}))},oneOf:function(e){if(!Array.isArray(e))return"production"!==process.env.NODE_ENV&&K(arguments.length>1?"Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).":"Invalid argument supplied to oneOf, expected an array."),Z;return c((function(n,t,r,o,i){for(var c=n[t],u=0;u<e.length;u++)if(a(c,e[u]))return null;var l=JSON.stringify(e,(function(e,n){return"symbol"===d(n)?String(n):n}));return new s("Invalid "+o+" `"+i+"` of value `"+String(c)+"` supplied to `"+r+"`, expected one of "+l+".")}))},oneOfType:function(e){if(!Array.isArray(e))return"production"!==process.env.NODE_ENV&&K("Invalid argument supplied to oneOfType, expected an instance of array."),Z;for(var n=0;n<e.length;n++){var t=e[n];if("function"!=typeof t)return K("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+m(t)+" at index "+n+"."),Z}return c((function(n,t,r,o,i){for(var a=[],c=0;c<e.length;c++){var u=(0,e[c])(n,t,r,o,i,U);if(null==u)return null;u.data&&X(u.data,"expectedType")&&a.push(u.data.expectedType)}return new s("Invalid "+o+" `"+i+"` supplied to `"+r+"`"+(a.length>0?", expected one of type ["+a.join(", ")+"]":"")+".")}))},shape:function(e){return c((function(n,t,r,o,i){var a=n[t],c=f(a);if("object"!==c)return new s("Invalid "+o+" `"+i+"` of type `"+c+"` supplied to `"+r+"`, expected `object`.");for(var u in e){var p=e[u];if("function"!=typeof p)return l(r,o,i,u,d(p));var m=p(a,u,r,o,i+"."+u,U);if(m)return m}return null}))},exact:function(e){return c((function(n,t,r,o,i){var a=n[t],c=f(a);if("object"!==c)return new s("Invalid "+o+" `"+i+"` of type `"+c+"` supplied to `"+r+"`, expected `object`.");var u=W({},n[t],e);for(var p in u){var m=e[p];if(X(e,p)&&"function"!=typeof m)return l(r,o,i,p,d(m));if(!m)return new s("Invalid "+o+" `"+i+"` key `"+p+"` supplied to `"+r+"`.\nBad object: "+JSON.stringify(n[t],null," ")+"\nValid keys: "+JSON.stringify(Object.keys(e),null," "));var y=m(a,p,r,o,i+"."+p,U);if(y)return y}return null}))}};function a(e,n){return e===n?0!==e||1/e==1/n:e!=e&&n!=n}function s(e,n){this.message=e,this.data=n&&"object"==typeof n?n:{},this.stack=""}function c(e){if("production"!==process.env.NODE_ENV)var t={},r=0;function i(i,a,c,u,l,p,f){if(u=u||o,p=p||c,f!==U){if(n){var d=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw d.name="Invariant Violation",d}if("production"!==process.env.NODE_ENV&&"undefined"!=typeof console){var m=u+":"+c;!t[m]&&r<3&&(K("You are manually calling a React.PropTypes validation function for the `"+p+"` prop on `"+u+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),t[m]=!0,r++)}}return null==a[c]?i?null===a[c]?new s("The "+l+" `"+p+"` is marked as required in `"+u+"`, but its value is `null`."):new s("The "+l+" `"+p+"` is marked as required in `"+u+"`, but its value is `undefined`."):null:e(a,c,u,l,p)}var a=i.bind(null,!1);return a.isRequired=i.bind(null,!0),a}function u(e){return c((function(n,t,r,o,i,a){var c=n[t];return f(c)!==e?new s("Invalid "+o+" `"+i+"` of type `"+d(c)+"` supplied to `"+r+"`, expected `"+e+"`.",{expectedType:e}):null}))}function l(e,n,t,r,o){return new s((e||"React class")+": "+n+" type `"+t+"."+r+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+o+"`.")}function p(n){switch(typeof n){case"number":case"string":case"undefined":return!0;case"boolean":return!n;case"object":if(Array.isArray(n))return n.every(p);if(null===n||e(n))return!0;var o=function(e){var n=e&&(t&&e[t]||e[r]);if("function"==typeof n)return n}(n);if(!o)return!1;var i,a=o.call(n);if(o!==n.entries){for(;!(i=a.next()).done;)if(!p(i.value))return!1}else for(;!(i=a.next()).done;){var s=i.value;if(s&&!p(s[1]))return!1}return!0;default:return!1}}function f(e){var n=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":function(e,n){return"symbol"===e||!!n&&("Symbol"===n["@@toStringTag"]||"function"==typeof Symbol&&n instanceof Symbol)}(n,e)?"symbol":n}function d(e){if(null==e)return""+e;var n=f(e);if("object"===n){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return n}function m(e){var n=d(e);switch(n){case"array":case"object":return"an "+n;case"boolean":case"date":case"regexp":return"a "+n;default:return n}}return s.prototype=Error.prototype,i.checkPropTypes=Q,i.resetWarningCache=Q.resetWarningCache,i.PropTypes=i,i};function ne(){}function te(){}te.resetWarningCache=ne;var re=l((function(e){if("production"!==process.env.NODE_ENV){var n=V;e.exports=ee(n.isElement,!0)}else e.exports=function(){function e(e,n,t,r,o,i){if(i!==U){var a=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw a.name="Invariant Violation",a}}function n(){return e}e.isRequired=e;var t={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:n,element:e,elementType:e,instanceOf:n,node:e,objectOf:n,oneOf:n,oneOfType:n,shape:n,exact:n,checkPropTypes:te,resetWarningCache:ne};return t.PropTypes=t,t}()}));function oe(e,n){return e.replace(new RegExp("(^|\\s)"+n+"(?:\\s|$)","g"),"$1").replace(/\s+/g," ").replace(/^\s*|\s*$/g,"")}var ie=!1,ae="production"!==process.env.NODE_ENV?re.oneOfType([re.number,re.shape({enter:re.number,exit:re.number,appear:re.number}).isRequired]):null,se="production"!==process.env.NODE_ENV?re.oneOfType([re.string,re.shape({enter:re.string,exit:re.string,active:re.string}),re.shape({enter:re.string,enterDone:re.string,enterActive:re.string,exit:re.string,exitDone:re.string,exitActive:re.string})]):null,ce=t.createContext(null),ue=function(e){return e.scrollTop},le="unmounted",pe="exited",fe="entering",de="entered",me="exiting",ye=function(e){function n(n,t){var r;r=e.call(this,n,t)||this;var o,i=t&&!t.isMounting?n.enter:n.appear;return r.appearStatus=null,n.in?i?(o=pe,r.appearStatus=fe):o=de:o=n.unmountOnExit||n.mountOnEnter?le:pe,r.state={status:o},r.nextCallback=null,r}y(n,e),n.getDerivedStateFromProps=function(e,n){return e.in&&n.status===le?{status:pe}:null};var r=n.prototype;return r.componentDidMount=function(){this.updateStatus(!0,this.appearStatus)},r.componentDidUpdate=function(e){var n=null;if(e!==this.props){var t=this.state.status;this.props.in?t!==fe&&t!==de&&(n=fe):t!==fe&&t!==de||(n=me)}this.updateStatus(!1,n)},r.componentWillUnmount=function(){this.cancelNextCallback()},r.getTimeouts=function(){var e,n,t,r=this.props.timeout;return e=n=t=r,null!=r&&"number"!=typeof r&&(e=r.exit,n=r.enter,t=void 0!==r.appear?r.appear:n),{exit:e,enter:n,appear:t}},r.updateStatus=function(e,n){if(void 0===e&&(e=!1),null!==n)if(this.cancelNextCallback(),n===fe){if(this.props.unmountOnExit||this.props.mountOnEnter){var t=this.props.nodeRef?this.props.nodeRef.current:s.findDOMNode(this);t&&ue(t)}this.performEnter(e)}else this.performExit();else this.props.unmountOnExit&&this.state.status===pe&&this.setState({status:le})},r.performEnter=function(e){var n=this,t=this.props.enter,r=this.context?this.context.isMounting:e,o=this.props.nodeRef?[r]:[s.findDOMNode(this),r],i=o[0],a=o[1],c=this.getTimeouts(),u=r?c.appear:c.enter;!e&&!t||ie?this.safeSetState({status:de},(function(){n.props.onEntered(i)})):(this.props.onEnter(i,a),this.safeSetState({status:fe},(function(){n.props.onEntering(i,a),n.onTransitionEnd(u,(function(){n.safeSetState({status:de},(function(){n.props.onEntered(i,a)}))}))})))},r.performExit=function(){var e=this,n=this.props.exit,t=this.getTimeouts(),r=this.props.nodeRef?void 0:s.findDOMNode(this);n&&!ie?(this.props.onExit(r),this.safeSetState({status:me},(function(){e.props.onExiting(r),e.onTransitionEnd(t.exit,(function(){e.safeSetState({status:pe},(function(){e.props.onExited(r)}))}))}))):this.safeSetState({status:pe},(function(){e.props.onExited(r)}))},r.cancelNextCallback=function(){null!==this.nextCallback&&(this.nextCallback.cancel(),this.nextCallback=null)},r.safeSetState=function(e,n){n=this.setNextCallback(n),this.setState(e,n)},r.setNextCallback=function(e){var n=this,t=!0;return this.nextCallback=function(r){t&&(t=!1,n.nextCallback=null,e(r))},this.nextCallback.cancel=function(){t=!1},this.nextCallback},r.onTransitionEnd=function(e,n){this.setNextCallback(n);var t=this.props.nodeRef?this.props.nodeRef.current:s.findDOMNode(this),r=null==e&&!this.props.addEndListener;if(t&&!r){if(this.props.addEndListener){var o=this.props.nodeRef?[this.nextCallback]:[t,this.nextCallback],i=o[0],a=o[1];this.props.addEndListener(i,a)}null!=e&&setTimeout(this.nextCallback,e)}else setTimeout(this.nextCallback,0)},r.render=function(){var e=this.state.status;if(e===le)return null;var n=this.props,r=n.children;n.in,n.mountOnEnter,n.unmountOnExit,n.appear,n.enter,n.exit,n.timeout,n.addEndListener,n.onEnter,n.onEntering,n.onEntered,n.onExit,n.onExiting,n.onExited,n.nodeRef;var o=d(n,["children","in","mountOnEnter","unmountOnExit","appear","enter","exit","timeout","addEndListener","onEnter","onEntering","onEntered","onExit","onExiting","onExited","nodeRef"]);return t.createElement(ce.Provider,{value:null},"function"==typeof r?r(e,o):t.cloneElement(t.Children.only(r),o))},n}(t.Component);function ve(){}ye.contextType=ce,ye.propTypes="production"!==process.env.NODE_ENV?{nodeRef:re.shape({current:"undefined"==typeof Element?re.any:function(e,n,t,r,o,i){var a=e[n];return re.instanceOf(a&&"ownerDocument"in a?a.ownerDocument.defaultView.Element:Element)(e,n,t,r,o,i)}}),children:re.oneOfType([re.func.isRequired,re.element.isRequired]).isRequired,in:re.bool,mountOnEnter:re.bool,unmountOnExit:re.bool,appear:re.bool,enter:re.bool,exit:re.bool,timeout:function(e){var n=ae;e.addEndListener||(n=n.isRequired);for(var t=arguments.length,r=new Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];return n.apply(void 0,[e].concat(r))},addEndListener:re.func,onEnter:re.func,onEntering:re.func,onEntered:re.func,onExit:re.func,onExiting:re.func,onExited:re.func}:{},ye.defaultProps={in:!1,mountOnEnter:!1,unmountOnExit:!1,appear:!1,enter:!0,exit:!0,onEnter:ve,onEntering:ve,onEntered:ve,onExit:ve,onExiting:ve,onExited:ve},ye.UNMOUNTED=le,ye.EXITED=pe,ye.ENTERING=fe,ye.ENTERED=de,ye.EXITING=me;var he=ye,be=function(e,n){return e&&n&&n.split(" ").forEach((function(n){return r=n,void((t=e).classList?t.classList.add(r):function(e,n){return e.classList?!!n&&e.classList.contains(n):-1!==(" "+(e.className.baseVal||e.className)+" ").indexOf(" "+n+" ")}(t,r)||("string"==typeof t.className?t.className=t.className+" "+r:t.setAttribute("class",(t.className&&t.className.baseVal||"")+" "+r)));var t,r}))},Ee=function(e,n){return e&&n&&n.split(" ").forEach((function(n){return r=n,void((t=e).classList?t.classList.remove(r):"string"==typeof t.className?t.className=oe(t.className,r):t.setAttribute("class",oe(t.className&&t.className.baseVal||"",r)));var t,r}))},ge=function(e){function n(){for(var n,t=arguments.length,r=new Array(t),o=0;o<t;o++)r[o]=arguments[o];return(n=e.call.apply(e,[this].concat(r))||this).appliedClasses={appear:{},enter:{},exit:{}},n.onEnter=function(e,t){var r=n.resolveArguments(e,t),o=r[0],i=r[1];n.removeClasses(o,"exit"),n.addClass(o,i?"appear":"enter","base"),n.props.onEnter&&n.props.onEnter(e,t)},n.onEntering=function(e,t){var r=n.resolveArguments(e,t),o=r[0],i=r[1]?"appear":"enter";n.addClass(o,i,"active"),n.props.onEntering&&n.props.onEntering(e,t)},n.onEntered=function(e,t){var r=n.resolveArguments(e,t),o=r[0],i=r[1]?"appear":"enter";n.removeClasses(o,i),n.addClass(o,i,"done"),n.props.onEntered&&n.props.onEntered(e,t)},n.onExit=function(e){var t=n.resolveArguments(e)[0];n.removeClasses(t,"appear"),n.removeClasses(t,"enter"),n.addClass(t,"exit","base"),n.props.onExit&&n.props.onExit(e)},n.onExiting=function(e){var t=n.resolveArguments(e)[0];n.addClass(t,"exit","active"),n.props.onExiting&&n.props.onExiting(e)},n.onExited=function(e){var t=n.resolveArguments(e)[0];n.removeClasses(t,"exit"),n.addClass(t,"exit","done"),n.props.onExited&&n.props.onExited(e)},n.resolveArguments=function(e,t){return n.props.nodeRef?[n.props.nodeRef.current,e]:[e,t]},n.getClassNames=function(e){var t=n.props.classNames,r="string"==typeof t,o=r?""+(r&&t?t+"-":"")+e:t[e];return{baseClassName:o,activeClassName:r?o+"-active":t[e+"Active"],doneClassName:r?o+"-done":t[e+"Done"]}},n}y(n,e);var r=n.prototype;return r.addClass=function(e,n,t){var r=this.getClassNames(n)[t+"ClassName"],o=this.getClassNames("enter").doneClassName;"appear"===n&&"done"===t&&o&&(r+=" "+o),"active"===t&&e&&ue(e),r&&(this.appliedClasses[n][t]=r,be(e,r))},r.removeClasses=function(e,n){var t=this.appliedClasses[n],r=t.base,o=t.active,i=t.done;this.appliedClasses[n]={},r&&Ee(e,r),o&&Ee(e,o),i&&Ee(e,i)},r.render=function(){var e=this.props;e.classNames;var n=d(e,["classNames"]);return t.createElement(he,f({},n,{onEnter:this.onEnter,onEntered:this.onEntered,onEntering:this.onEntering,onExit:this.onExit,onExiting:this.onExiting,onExited:this.onExited}))},n}(t.Component);ge.defaultProps={classNames:""},ge.propTypes="production"!==process.env.NODE_ENV?f({},he.propTypes,{classNames:se,onEnter:re.func,onEntering:re.func,onEntered:re.func,onExit:re.func,onExiting:re.func,onExited:re.func}):{};var xe=function(n){var t=n.children,o=n.isVisible,i=n.timeout,a=n.className,s=r(null);return e(ge,{nodeRef:s,in:o,timeout:i,classNames:a,unmountOnExit:!0,children:t})},Oe=function(e,n){var t,r;return function(){for(var o=[],i=0;i<arguments.length;i++)o[i]=arguments[i];var a=this;r?(clearTimeout(t),t=setTimeout((function(){Date.now()-r>=n&&(e.apply(a,o),r=Date.now())}),n-(Date.now()-r))):(e.apply(a,o),r=Date.now())}},Se={},we={},Ce=function(e,n,t){var r="_".concat(Math.random().toString(36).substr(2,9));return Se[r]={id:e,showMenu:n,hideMenu:t},e},Ne=function(e){we.id!==e&&"ID_NOT_REQUIRED"!==e||(we.hideMenu&&we.hideMenu(),we={})},Te=function(n){var u=n.children,l=n.id,f=n.appendTo,d=n.hideOnLeave,m=n.preventHideOnResize,y=n.preventHideOnScroll,v=n.attributes,h=n.className,b=n.animation,E=n.onMouseLeave,g=n.onHide,x=n.onShow,O=r(null),S=o(!1),w=S[0],C=S[1],N=o(null),T=N[0],j=N[1],P=function(e){var n=e.position;C(!0),j(n)},_=function(){C(!1),g&&g(T)},R=i((function(e){e.preventDefault(),E&&E(e),d&&Ne(l)}),[d,l,E]),k=function(e){O.current&&!O.current.contains(e.target)&&Ne(l)},$=function(e){var n=e.target;do{if(n.classList&&n.classList.contains("menu-trigger"))return;n=n.parentElement}while(n);Ne(l)},M=Oe((function(){Ne(l)}),200),D=Oe((function(){Ne(l)}),200);a((function(){return Ce(l,P,_),document.addEventListener("mousedown",k),document.addEventListener("contextmenu",$),y||window.addEventListener("scroll",M),m||window.addEventListener("resize",D),function(){document.removeEventListener("mousedown",k),document.removeEventListener("contextmenu",$),window.removeEventListener("scroll",M),window.removeEventListener("resize",D)}}),[l,y,m,M,D]),a((function(){if(w&&T&&O.current){var e=T.clientY,n=T.clientX,t=window.innerHeight,r=window.innerWidth,o=O.current,i=o.offsetHeight,a=o.offsetWidth,s=e,c=n;t<e+i&&(s=e-i),r<n+a&&(c=n-a),O.current.style.top="".concat(s+2,"px"),O.current.style.left="".concat(c+2,"px"),x&&x(T)}}),[w,T,x]);var L=t.Children.map(u,(function(e){return t.isValidElement(e)?t.cloneElement(e,{id:l}):e})),A=function(){return e("div",c({className:p("contextmenu",h),ref:O,onMouseLeave:R},v,{children:L}))},I=function(){return s.createPortal(e(A,{}),document.querySelector(f))};return"complete"===document.readyState&&f?b?e(xe,{isVisible:w,timeout:200,className:b,children:e(I,{})}):e(I,{}):b?e(xe,{isVisible:w,timeout:200,className:b,children:e(A,{})}):e(A,{})},je=function(n){var t=n.children,o=n.onClick,a=n.disabled,s=void 0!==a&&a,u=n.preventClose,l=void 0!==u&&u,f=n.className,d=function(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.indexOf(r)<0&&(t[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)n.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(t[r[o]]=e[r[o]])}return t}(n,["children","onClick","disabled","preventClose","className"]),m=r(null),y=i((function(e){s||(o&&o(e),l||Ne("ID_NOT_REQUIRED"))}),[s,o,l]);return e("div",c({className:p("contextmenu__item",{"contextmenu__item--disabled":s},f),onClick:y,ref:m},d,{children:t}))};je.Submenu=function(t){var a=t.children,s=t.element,l=t.attributes,f=t.className,d=void 0===f?"":f,m=o(null),y=m[0],v=m[1],h=r(null),b=r(null),E=i((function(){if(b.current&&h.current){var e=window.innerHeight,n=window.innerWidth,t=b.current.getBoundingClientRect(),r=t.left,o=t.top,i=t.width,a=t.height,s=h.current.getBoundingClientRect(),u=s.width,l={opacity:1,visibility:"visible"};o+s.height+a>e&&(l=c(c({},l),{top:"inherit",bottom:"0"})),r+u+i>n&&(l=c(c({},l),{left:"inherit",right:"100%"})),v(l)}}),[]),g=i((function(){v({opacity:0,visibility:"hidden"})}),[]);return n("div",c({className:p.apply(void 0,u(["submenu"],d.split(" "),!1)),onMouseOver:E,onMouseOut:g,ref:b},l,{children:[e(je,{children:s}),e("div",{className:"submenu__item",ref:h,style:null!=y?y:void 0,children:a})]}))};var Pe=function(n){var t=n.as,o=void 0===t?"div":t,a=n.children,s=n.id,u=n.disableWhileShiftPressed,l=n.attributes,f=n.disable,d=n.className,m=n.onClick,y=r(null),v=i((function(e){if(!f)if(u&&e.nativeEvent.shiftKey)Ne(s);else{e.preventDefault(),e.stopPropagation();var n=e.nativeEvent,t=n.clientX;!function(e){we.hideMenu&&we.hideMenu(),Object.keys(Se).forEach((function(n){Se[n].id&&Se[n].id===e.id&&(Se[n].showMenu(e),we=Se[n])}))}({position:{clientY:n.clientY,clientX:t},id:s})}}),[s,f,u]);return e(o,c({className:p("menu-trigger",d),ref:y},l,{onClick:function(e){return m&&m(e)},onContextMenu:function(e){return v(e)},children:a}))};export{Te as ContextMenu,je as ContextMenuItem,Pe as ContextMenuTrigger};