@vikadata/react-contexify
Advanced tools
Comparing version 5.0.0 to 5.0.1
@@ -780,3 +780,4 @@ 'use strict'; | ||
ref: nodeRef, | ||
role: "menu" | ||
role: "menu", | ||
id: id + '' | ||
}), cloneItems(children, { | ||
@@ -783,0 +784,0 @@ propsFromTrigger: propsFromTrigger, |
@@ -1,2 +0,2 @@ | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var n=require("react"),t=e(n),i=e(require("clsx"));function r(){return(r=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e}).apply(this,arguments)}function o(e,n){if(null==e)return{};var t,i,r={},o=Object.keys(e);for(i=0;i<o.length;i++)n.indexOf(t=o[i])>=0||(r[t]=e[t]);return r}var a=n.createContext({});function c(){return n.useContext(a)}var s=function(e){return t.createElement(a.Provider,{value:e.refTracker},e.children)};function l(){var e=new Map;return{on:function(n,t){var i;return e.has(n)?null==(i=e.get(n))||i.add(t):e.set(n,new Set([t])),this},off:function(n,t){return t?e.get(n).delete(t):e.delete(n),this},emit:function(n,t){if("production"!==process.env.NODE){var i=n;e.has(n)||0===i||console.error("It seems that the menu you are trying to display is not renderer or you have a menu id mismatch.","You used the menu id: "+n)}return e.has(n)&&e.get(n).forEach((function(e){e(t)})),this}}}var u=l();function f(){return n.useRef(new Map).current}var d={show:function(e){var n=e.id,t=e.event,i=e.props,r=e.position;t.preventDefault&&t.preventDefault(),u.emit(0).emit(n,{event:t.nativeEvent||t,props:i,position:r})},hideAll:function(){u.emit(0)}},v=function(){},m=function(e){var n,r=e.children,a=e.className,s=e.style,l=e.triggerEvent,u=e.data,f=e.propsFromTrigger,d=e.onClick,m=void 0===d?v:d,p=e.disabled,g=void 0!==p&&p,h=e.hidden,b=void 0!==h&&h,w=o(e,["children","className","style","triggerEvent","data","propsFromTrigger","onClick","disabled","hidden"]),x=c(),E={data:u,triggerEvent:l,props:f},_=y(g,E);if(y(b,E))return null;var k=i("react-contexify__item",a,((n={})["react-contexify__item--disabled"]=_,n));return t.createElement("div",Object.assign({},w,{className:k,style:s,onClick:function(e){E.event=e,_?e.stopPropagation():m(E)},onKeyDown:function(e){"Enter"===e.key&&(E.event=e,m(E))},ref:function(e){e&&!_&&x.set(e,{node:e,isSubmenu:!1})},tabIndex:-1,role:"menuitem","aria-disabled":_}),t.createElement("div",{className:"react-contexify__item__content"},r))},p=function(e){var a,l=e.arrow,u=void 0===l?"▶":l,d=e.children,v=e.disabled,m=void 0!==v&&v,p=e.hidden,g=void 0!==p&&p,h=e.label,w=e.className,x=e.triggerEvent,E=e.propsFromTrigger,_=e.style,k=o(e,["arrow","children","disabled","hidden","label","className","triggerEvent","propsFromTrigger","style"]),L=c(),T=f(),N=n.useRef(null),S=n.useState({left:"100%",top:0,bottom:"initial"}),R=S[0],A=S[1],C={triggerEvent:x,props:E},O=y(m,C),F=y(g,C);if(n.useEffect((function(){if(N.current){var e=window,n=e.innerWidth,t=e.innerHeight,i=N.current.getBoundingClientRect(),r={};i.right<n?(r.left="100%",r.right=void 0):(r.right="100%",r.left=void 0),i.bottom>t?(r.bottom=0,r.top="initial"):r.bottom="initial",A(r)}}),[]),F)return null;var j=i("react-contexify__item",w,((a={})["react-contexify__item--disabled"]=O,a)),D=r({},_,R);return t.createElement(s,{refTracker:T},t.createElement("div",Object.assign({},k,{className:j,ref:function(e){e&&!O&&L.set(e,{node:e,isSubmenu:!0,submenuRefTracker:T})},tabIndex:-1,role:"menuitem","aria-haspopup":!0,"aria-disabled":O}),t.createElement("div",{className:"react-contexify__item__content",onClick:function(e){e.stopPropagation()}},h,t.createElement("span",{className:"react-contexify__submenu-arrow"},u)),t.createElement("div",{className:"react-contexify react-contexify__submenu",ref:N,style:D},b(d,{propsFromTrigger:E,triggerEvent:x}))))};function g(e){return"function"==typeof e}function h(e){return"string"==typeof e}function b(e,t){return n.Children.map(n.Children.toArray(e).filter((function(e){return Boolean(e)})),(function(e){return n.isValidElement(e)?e.type!==m&&e.type!==p&&e.props.children?b(e.props.children,t):n.cloneElement(e,t):e}))}function y(e,n){return g(e)?e(n):e}function w(e,n){return g(n)?r({},e,n(e)):r({},e,n)}exports.Item=m,exports.Menu=function(e){var a,c,l,d=e.id,m=e.theme,p=e.style,g=e.className,y=e.children,x=e.animation,E=void 0===x?"scale":x,_=e.onHidden,k=void 0===_?v:_,L=e.onShown,T=void 0===L?v:L,N=o(e,["id","theme","style","className","children","animation","onHidden","onShown"]),S=n.useReducer(w,{x:0,y:0,visible:!1,triggerEvent:{},propsFromTrigger:null,willLeave:!1}),R=S[0],A=S[1],C=n.useRef(null),O=n.useRef(!1),F=(c=R.visible,l=n.useRef(),n.useEffect((function(){l.current=c}),[c]),l.current),j=f(),D=n.useState((function(){return function(){var e,n,t,i,r=new Map,o=!1;function a(){i[e].node.focus()}function c(){return-1!==e||(s(),!1)}function s(){e+1<i.length?e++:e+1===i.length&&(e=0),o&&l(),a()}function l(){if(c()&&!t){var s=r.get(n),l=s.isRoot,u=s.items,f=s.focusedIndex,d=s.parentNode;n.classList.remove("react-contexify__submenu--is-open"),i=u,n=d,l&&(t=!0,r.clear()),o||(e=f,a())}}return{init:function(n){i=n,e=-1,t=!0},moveDown:s,moveUp:function(){-1===e||0===e?e=i.length-1:e-1<i.length&&e--,o&&l(),a()},openSubmenu:function(){if(c()&&e>=0&&i[e].isSubmenu){var s=Array.from(i[e].submenuRefTracker.values()),l=i[e].node;return r.set(l,{isRoot:t,focusedIndex:e,parentNode:n||l,items:i}),l.classList.add("react-contexify__submenu--is-open"),n=l,s.length>0?(e=0,i=s):o=!0,t=!1,a(),!0}return!1},closeSubmenu:l}}()}))[0];function M(e){var n=e.event,t=e.props,i=e.position;n.stopPropagation();var r,o,a=i||(o={x:0,y:0},function(e){return"touchend"===e.type}(r=n)&&r.changedTouches&&r.changedTouches.length>0?(o.x=r.changedTouches[0].clientX,o.y=r.changedTouches[0].clientY):(o.x=r.clientX,o.y=r.clientY),(!o.x||o.x<0)&&(o.x=0),(!o.y||o.y<0)&&(o.y=0),o),c=a.x,s=a.y;setTimeout((function(){A({visible:!0,willLeave:!1,x:c,y:s,triggerEvent:n,propsFromTrigger:t})}),0)}function I(e){(void 0===e||2!==e.button&&!0!==e.ctrlKey||"contextmenu"===e.type)&&(function(e){return!(!e||!(h(e)||"exit"in e&&e.exit))}(E)?A((function(e){return{willLeave:e.visible}})):A((function(e){return{visible:!e.visible&&e.visible}})))}n.useEffect((function(){return O.current=!0,u.on(d,M).on(0,I),function(){u.off(d,M).off(0,I)}}),[d]),n.useEffect((function(){O.current&&R.visible!==F&&(R.visible?T():k())}),[R.visible,k,T]),n.useEffect((function(){R.visible?D.init(Array.from(j.values())):j.clear()}),[R.visible,D,j]),n.useEffect((function(){if(R.visible){var e=window,n=e.innerWidth,t=e.innerHeight,i=C.current,r=i.offsetWidth,o=i.offsetHeight,a=R.x,c=R.y;a+r>n&&(a-=a+r-n),c+o>t&&(c-=c+o-t),A({x:a,y:c})}}),[R.visible]),n.useEffect((function(){function e(e){switch(e.preventDefault(),e.key){case"Enter":D.openSubmenu()||I();break;case"Escape":I();break;case"ArrowUp":D.moveUp();break;case"ArrowDown":D.moveDown();break;case"ArrowRight":D.openSubmenu();break;case"ArrowLeft":D.closeSubmenu()}}return R.visible&&(window.addEventListener("resize",I),window.addEventListener("contextmenu",I),window.addEventListener("click",I),window.addEventListener("scroll",I),window.addEventListener("keydown",e),window.addEventListener("blur",I)),function(){window.removeEventListener("resize",I),window.removeEventListener("contextmenu",I),window.removeEventListener("click",I),window.removeEventListener("scroll",I),window.removeEventListener("keydown",e),window.removeEventListener("blur",I)}}),[R.visible,D]);var P,H,U=R.visible,W=R.triggerEvent,Y=R.propsFromTrigger,q=R.x,z=R.y,B=R.willLeave,K=i("react-contexify",g,((a={})["react-contexify__theme--"+m]=m,a),E?h(E)?i(((P={})["react-contexify__will-enter--"+E]=E&&U&&!B,P["react-contexify__will-leave--"+E+" react-contexify__will-leave--'disabled'"]=E&&U&&B,P)):"enter"in E&&"exit"in E?i(((H={})["react-contexify__will-enter--"+E.enter]=E.enter&&U&&!B,H["react-contexify__will-leave--"+E.exit+" react-contexify__will-leave--'disabled'"]=E.exit&&U&&B,H)):null:null),X=r({},p,{left:q,top:z,opacity:1});return t.createElement(s,{refTracker:j},U&&t.createElement("div",Object.assign({},N,{className:K,onAnimationEnd:function(){R.willLeave&&R.visible&&A({visible:!1,willLeave:!1})},style:X,ref:C,role:"menu"}),b(y,{propsFromTrigger:Y,triggerEvent:W})))},exports.Separator=function(){return t.createElement("div",{className:"react-contexify__separator"})},exports.Submenu=p,exports.animation={fade:"fade",flip:"flip",scale:"scale",slide:"slide"},exports.contextMenu=d,exports.theme={light:"light",dark:"dark"},exports.useContextMenu=function(e){return{show:function(n,t){d.show({id:(null==t?void 0:t.id)||(null==e?void 0:e.id),props:(null==t?void 0:t.props)||(null==e?void 0:e.props),event:n,position:null==t?void 0:t.position})},hideAll:function(){d.hideAll()}}}; | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var n=require("react"),t=e(n),i=e(require("clsx"));function r(){return(r=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e}).apply(this,arguments)}function o(e,n){if(null==e)return{};var t,i,r={},o=Object.keys(e);for(i=0;i<o.length;i++)n.indexOf(t=o[i])>=0||(r[t]=e[t]);return r}var a=n.createContext({});function c(){return n.useContext(a)}var s=function(e){return t.createElement(a.Provider,{value:e.refTracker},e.children)};function l(){var e=new Map;return{on:function(n,t){var i;return e.has(n)?null==(i=e.get(n))||i.add(t):e.set(n,new Set([t])),this},off:function(n,t){return t?e.get(n).delete(t):e.delete(n),this},emit:function(n,t){if("production"!==process.env.NODE){var i=n;e.has(n)||0===i||console.error("It seems that the menu you are trying to display is not renderer or you have a menu id mismatch.","You used the menu id: "+n)}return e.has(n)&&e.get(n).forEach((function(e){e(t)})),this}}}var u=l();function f(){return n.useRef(new Map).current}var d={show:function(e){var n=e.id,t=e.event,i=e.props,r=e.position;t.preventDefault&&t.preventDefault(),u.emit(0).emit(n,{event:t.nativeEvent||t,props:i,position:r})},hideAll:function(){u.emit(0)}},v=function(){},m=function(e){var n,r=e.children,a=e.className,s=e.style,l=e.triggerEvent,u=e.data,f=e.propsFromTrigger,d=e.onClick,m=void 0===d?v:d,p=e.disabled,g=void 0!==p&&p,h=e.hidden,b=void 0!==h&&h,w=o(e,["children","className","style","triggerEvent","data","propsFromTrigger","onClick","disabled","hidden"]),x=c(),E={data:u,triggerEvent:l,props:f},_=y(g,E);if(y(b,E))return null;var k=i("react-contexify__item",a,((n={})["react-contexify__item--disabled"]=_,n));return t.createElement("div",Object.assign({},w,{className:k,style:s,onClick:function(e){E.event=e,_?e.stopPropagation():m(E)},onKeyDown:function(e){"Enter"===e.key&&(E.event=e,m(E))},ref:function(e){e&&!_&&x.set(e,{node:e,isSubmenu:!1})},tabIndex:-1,role:"menuitem","aria-disabled":_}),t.createElement("div",{className:"react-contexify__item__content"},r))},p=function(e){var a,l=e.arrow,u=void 0===l?"▶":l,d=e.children,v=e.disabled,m=void 0!==v&&v,p=e.hidden,g=void 0!==p&&p,h=e.label,w=e.className,x=e.triggerEvent,E=e.propsFromTrigger,_=e.style,k=o(e,["arrow","children","disabled","hidden","label","className","triggerEvent","propsFromTrigger","style"]),L=c(),T=f(),N=n.useRef(null),S=n.useState({left:"100%",top:0,bottom:"initial"}),R=S[0],A=S[1],C={triggerEvent:x,props:E},O=y(m,C),F=y(g,C);if(n.useEffect((function(){if(N.current){var e=window,n=e.innerWidth,t=e.innerHeight,i=N.current.getBoundingClientRect(),r={};i.right<n?(r.left="100%",r.right=void 0):(r.right="100%",r.left=void 0),i.bottom>t?(r.bottom=0,r.top="initial"):r.bottom="initial",A(r)}}),[]),F)return null;var j=i("react-contexify__item",w,((a={})["react-contexify__item--disabled"]=O,a)),D=r({},_,R);return t.createElement(s,{refTracker:T},t.createElement("div",Object.assign({},k,{className:j,ref:function(e){e&&!O&&L.set(e,{node:e,isSubmenu:!0,submenuRefTracker:T})},tabIndex:-1,role:"menuitem","aria-haspopup":!0,"aria-disabled":O}),t.createElement("div",{className:"react-contexify__item__content",onClick:function(e){e.stopPropagation()}},h,t.createElement("span",{className:"react-contexify__submenu-arrow"},u)),t.createElement("div",{className:"react-contexify react-contexify__submenu",ref:N,style:D},b(d,{propsFromTrigger:E,triggerEvent:x}))))};function g(e){return"function"==typeof e}function h(e){return"string"==typeof e}function b(e,t){return n.Children.map(n.Children.toArray(e).filter((function(e){return Boolean(e)})),(function(e){return n.isValidElement(e)?e.type!==m&&e.type!==p&&e.props.children?b(e.props.children,t):n.cloneElement(e,t):e}))}function y(e,n){return g(e)?e(n):e}function w(e,n){return g(n)?r({},e,n(e)):r({},e,n)}exports.Item=m,exports.Menu=function(e){var a,c,l,d=e.id,m=e.theme,p=e.style,g=e.className,y=e.children,x=e.animation,E=void 0===x?"scale":x,_=e.onHidden,k=void 0===_?v:_,L=e.onShown,T=void 0===L?v:L,N=o(e,["id","theme","style","className","children","animation","onHidden","onShown"]),S=n.useReducer(w,{x:0,y:0,visible:!1,triggerEvent:{},propsFromTrigger:null,willLeave:!1}),R=S[0],A=S[1],C=n.useRef(null),O=n.useRef(!1),F=(c=R.visible,l=n.useRef(),n.useEffect((function(){l.current=c}),[c]),l.current),j=f(),D=n.useState((function(){return function(){var e,n,t,i,r=new Map,o=!1;function a(){i[e].node.focus()}function c(){return-1!==e||(s(),!1)}function s(){e+1<i.length?e++:e+1===i.length&&(e=0),o&&l(),a()}function l(){if(c()&&!t){var s=r.get(n),l=s.isRoot,u=s.items,f=s.focusedIndex,d=s.parentNode;n.classList.remove("react-contexify__submenu--is-open"),i=u,n=d,l&&(t=!0,r.clear()),o||(e=f,a())}}return{init:function(n){i=n,e=-1,t=!0},moveDown:s,moveUp:function(){-1===e||0===e?e=i.length-1:e-1<i.length&&e--,o&&l(),a()},openSubmenu:function(){if(c()&&e>=0&&i[e].isSubmenu){var s=Array.from(i[e].submenuRefTracker.values()),l=i[e].node;return r.set(l,{isRoot:t,focusedIndex:e,parentNode:n||l,items:i}),l.classList.add("react-contexify__submenu--is-open"),n=l,s.length>0?(e=0,i=s):o=!0,t=!1,a(),!0}return!1},closeSubmenu:l}}()}))[0];function M(e){var n=e.event,t=e.props,i=e.position;n.stopPropagation();var r,o,a=i||(o={x:0,y:0},function(e){return"touchend"===e.type}(r=n)&&r.changedTouches&&r.changedTouches.length>0?(o.x=r.changedTouches[0].clientX,o.y=r.changedTouches[0].clientY):(o.x=r.clientX,o.y=r.clientY),(!o.x||o.x<0)&&(o.x=0),(!o.y||o.y<0)&&(o.y=0),o),c=a.x,s=a.y;setTimeout((function(){A({visible:!0,willLeave:!1,x:c,y:s,triggerEvent:n,propsFromTrigger:t})}),0)}function I(e){(void 0===e||2!==e.button&&!0!==e.ctrlKey||"contextmenu"===e.type)&&(function(e){return!(!e||!(h(e)||"exit"in e&&e.exit))}(E)?A((function(e){return{willLeave:e.visible}})):A((function(e){return{visible:!e.visible&&e.visible}})))}n.useEffect((function(){return O.current=!0,u.on(d,M).on(0,I),function(){u.off(d,M).off(0,I)}}),[d]),n.useEffect((function(){O.current&&R.visible!==F&&(R.visible?T():k())}),[R.visible,k,T]),n.useEffect((function(){R.visible?D.init(Array.from(j.values())):j.clear()}),[R.visible,D,j]),n.useEffect((function(){if(R.visible){var e=window,n=e.innerWidth,t=e.innerHeight,i=C.current,r=i.offsetWidth,o=i.offsetHeight,a=R.x,c=R.y;a+r>n&&(a-=a+r-n),c+o>t&&(c-=c+o-t),A({x:a,y:c})}}),[R.visible]),n.useEffect((function(){function e(e){switch(e.preventDefault(),e.key){case"Enter":D.openSubmenu()||I();break;case"Escape":I();break;case"ArrowUp":D.moveUp();break;case"ArrowDown":D.moveDown();break;case"ArrowRight":D.openSubmenu();break;case"ArrowLeft":D.closeSubmenu()}}return R.visible&&(window.addEventListener("resize",I),window.addEventListener("contextmenu",I),window.addEventListener("click",I),window.addEventListener("scroll",I),window.addEventListener("keydown",e),window.addEventListener("blur",I)),function(){window.removeEventListener("resize",I),window.removeEventListener("contextmenu",I),window.removeEventListener("click",I),window.removeEventListener("scroll",I),window.removeEventListener("keydown",e),window.removeEventListener("blur",I)}}),[R.visible,D]);var P,H,U=R.visible,W=R.triggerEvent,Y=R.propsFromTrigger,q=R.x,z=R.y,B=R.willLeave,K=i("react-contexify",g,((a={})["react-contexify__theme--"+m]=m,a),E?h(E)?i(((P={})["react-contexify__will-enter--"+E]=E&&U&&!B,P["react-contexify__will-leave--"+E+" react-contexify__will-leave--'disabled'"]=E&&U&&B,P)):"enter"in E&&"exit"in E?i(((H={})["react-contexify__will-enter--"+E.enter]=E.enter&&U&&!B,H["react-contexify__will-leave--"+E.exit+" react-contexify__will-leave--'disabled'"]=E.exit&&U&&B,H)):null:null),X=r({},p,{left:q,top:z,opacity:1});return t.createElement(s,{refTracker:j},U&&t.createElement("div",Object.assign({},N,{className:K,onAnimationEnd:function(){R.willLeave&&R.visible&&A({visible:!1,willLeave:!1})},style:X,ref:C,role:"menu",id:d+""}),b(y,{propsFromTrigger:Y,triggerEvent:W})))},exports.Separator=function(){return t.createElement("div",{className:"react-contexify__separator"})},exports.Submenu=p,exports.animation={fade:"fade",flip:"flip",scale:"scale",slide:"slide"},exports.contextMenu=d,exports.theme={light:"light",dark:"dark"},exports.useContextMenu=function(e){return{show:function(n,t){d.show({id:(null==t?void 0:t.id)||(null==e?void 0:e.id),props:(null==t?void 0:t.props)||(null==e?void 0:e.props),event:n,position:null==t?void 0:t.position})},hideAll:function(){d.hideAll()}}}; | ||
//# sourceMappingURL=react-contexify.cjs.production.min.js.map |
@@ -781,3 +781,4 @@ import React, { useContext, createContext, useRef, useEffect, useState, Children, isValidElement, cloneElement, useReducer } from 'react'; | ||
ref: nodeRef, | ||
role: "menu" | ||
role: "menu", | ||
id: id + '' | ||
}), cloneItems(children, { | ||
@@ -784,0 +785,0 @@ propsFromTrigger: propsFromTrigger, |
{ | ||
"version": "5.0.0", | ||
"version": "5.0.1", | ||
"license": "MIT", | ||
@@ -4,0 +4,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
253555
3066
0