New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

electron-react-titlebar

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electron-react-titlebar - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

index.d.ts

2

dist/main.js

@@ -1,2 +0,2 @@

(()=>{"use strict";var e={d:(n,r)=>{for(var i in r)e.o(r,i)&&!e.o(n,i)&&Object.defineProperty(n,i,{enumerable:!0,get:r[i]})},o:(e,n)=>Object.prototype.hasOwnProperty.call(e,n),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},n={};e.r(n),e.d(n,{initialize:()=>i});const r=require("electron");var i=function(){r.ipcMain.on("electron-react-titlebar/initialize",(function(e,n){var i=n?r.BrowserWindow.fromId(n):r.BrowserWindow.fromWebContents(e.sender);i&&(function(e,n){e.addListener("maximize",(function(){n.send("electron-react-titlebar/maximunize/change",!0,e.id)})),e.addListener("unmaximize",(function(){n.send("electron-react-titlebar/maximunize/change",!1,e.id)}))}(i,e.sender),e.sender.send("electron-react-titlebar/browser-window-id",i.id))})),r.ipcMain.on("electron-react-titlebar/maximumize/set",(function(e,n){var i=n?r.BrowserWindow.fromId(n):r.BrowserWindow.fromWebContents(e.sender);null!=i&&i.isMaximizable()&&(i.isMaximized()?i.unmaximize():i.maximize())})),r.ipcMain.on("electron-react-titlebar/minimumize/set",(function(e,n){var i=n?r.BrowserWindow.fromId(n):r.BrowserWindow.fromWebContents(e.sender);null==i||i.minimize()})),r.ipcMain.on("electron-react-titlebar/close",(function(e,n){var i=n?r.BrowserWindow.fromId(n):r.BrowserWindow.fromWebContents(e.sender);null==i||i.close()}))};module.exports=n})();
(()=>{"use strict";var e={d:(n,i)=>{for(var r in i)e.o(i,r)&&!e.o(n,r)&&Object.defineProperty(n,r,{enumerable:!0,get:i[r]})},o:(e,n)=>Object.prototype.hasOwnProperty.call(e,n),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},n={};e.r(n),e.d(n,{initialize:()=>r});const i=require("electron");var r=function(){i.ipcMain.handle("electron-react-titlebar/initialize",(function(e,n){var r=n?i.BrowserWindow.fromId(n):i.BrowserWindow.fromWebContents(e.sender);if(r)return function(e,n){e.addListener("maximize",(function(){n.send("electron-react-titlebar/maximunize/change",!0,e.id)})),e.addListener("unmaximize",(function(){n.send("electron-react-titlebar/maximunize/change",!1,e.id)}))}(r,e.sender),r.id})),i.ipcMain.on("electron-react-titlebar/maximumize/set",(function(e,n){var r=n?i.BrowserWindow.fromId(n):i.BrowserWindow.fromWebContents(e.sender);null!=r&&r.isMaximizable()&&(r.isMaximized()?r.unmaximize():r.maximize())})),i.ipcMain.on("electron-react-titlebar/minimumize/set",(function(e,n){var r=n?i.BrowserWindow.fromId(n):i.BrowserWindow.fromWebContents(e.sender);null==r||r.minimize()})),i.ipcMain.on("electron-react-titlebar/close",(function(e,n){var r=n?i.BrowserWindow.fromId(n):i.BrowserWindow.fromWebContents(e.sender);null==r||r.close()}))};module.exports=n})();
//# sourceMappingURL=main.js.map

@@ -1,2 +0,2 @@

(()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{MenuBarProps:()=>o.MenuBarProps,MenuItemT:()=>n.MenuItemT,MenuListItemProps:()=>n.MenuListItemProps,MenuListProps:()=>a.MenuListProps,MenuT:()=>o.MenuT,TitleBar:()=>L,TitleBarProps:()=>i.TitleBarProps,WindowControlsProps:()=>r.WindowControlsProps});var r={};e.r(r),e.d(r,{h:()=>m});var n={};e.r(n),e.d(n,{M:()=>C});var a={};e.r(a),e.d(a,{q:()=>N});var o={};e.r(o),e.d(o,{j:()=>D});var i={};e.r(i),e.d(i,{T:()=>L});const l=require("react");var c=e.n(l);const u=require("electron");function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var m=function(e){var t,r,n=e.disableMaximize,a=e.disableMinimize,o=e.browserWindowId,i=(t=(0,l.useState)(!1),r=2,function(e){if(Array.isArray(e))return e}(t)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,a,o=[],i=!0,l=!1;try{for(r=r.call(e);!(i=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);i=!0);}catch(e){l=!0,a=e}finally{try{i||null==r.return||r.return()}finally{if(l)throw a}}return o}}(t,r)||function(e,t){if(e){if("string"==typeof e)return s(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?s(e,t):void 0}}(t,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),m=i[0],d=i[1],f=(0,l.useRef)(o);(0,l.useEffect)((function(){var e=function(e,t,r){r===f.current&&d(t)};return u.ipcRenderer.on("electron-react-titlebar/maximunize/change",e),u.ipcRenderer.once("electron-react-titlebar/browser-window-id",(function(e,t){f.current=t})),u.ipcRenderer.send("electron-react-titlebar/initialize",o),function(){u.ipcRenderer.removeListener("electron-react-titlebar/maximunize/change",e),u.ipcRenderer.send("electron-react-titlebar/deinitialize",o)}}),[o]);var b=(0,l.useCallback)((function(){u.ipcRenderer.send("electron-react-titlebar/maximumize/set",o)}),[o]),p=(0,l.useCallback)((function(){u.ipcRenderer.send("electron-react-titlebar/minimumize/set",o)}),[o]),y=(0,l.useCallback)((function(){u.ipcRenderer.send("electron-react-titlebar/close",o)}),[o]);return c().createElement("div",{className:"window-controls"},c().createElement("button",{"aria-label":"minimize",tabIndex:-1,className:"window-control window-minimize",disabled:a,onClick:p},c().createElement("svg",{"aria-hidden":"true",version:"1.1",width:"10",height:"10"},c().createElement("path",{d:"M 0,5 10,5 10,6 0,6 Z"}))),c().createElement("button",{"aria-label":"maximize",tabIndex:-1,className:"window-control window-maximize",disabled:n,onClick:b},c().createElement("svg",{"aria-hidden":"true",version:"1.1",width:"10",height:"10"},c().createElement("path",{d:m?"m 2,1e-5 0,2 -2,0 0,8 8,0 0,-2 2,0 0,-8 z m 1,1 6,0 0,6 -1,0 0,-5 -5,0 z m -2,2 6,0 0,6 -6,0 z":"M 0,0 0,10 10,10 10,0 Z M 1,1 9,1 9,9 1,9 Z"}))),c().createElement("button",{"aria-label":"close",tabIndex:-1,className:"window-control window-close",onClick:y},c().createElement("svg",{"aria-hidden":"true",version:"1.1",width:"10",height:"10"},c().createElement("path",{d:"M 0,0 0,0.7 4.3,5 0,9.3 0,10 0.7,10 5,5.7 9.3,10 10,10 10,9.3 5.7,5 10,0.7 10,0 9.3,0 5,4.3 0.7,0 Z"}))))};const d=require("classnames");var f=e.n(d);const b=require("lodash");function p(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function y(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?p(Object(r),!0).forEach((function(t){h(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):p(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function h(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function v(e){return function(e){if(Array.isArray(e))return g(e)}(e)||E(e)||w(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function w(e,t){if(e){if("string"==typeof e)return g(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?g(e,t):void 0}}function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function E(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function O(e,t,r){var n,a,o=function(e){if(Array.isArray(e))return e}(a=t)||E(a)||w(a)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),i=o[0],l=o.slice(1);if(void 0===i)return(0,b.isEqual)(e,r)?e:r;var c=O(n=i in e?e[i]:{},l,r);return c!==n?Array.isArray(e)?[].concat(v(e.slice(0,i)),[c],v(e.slice(i+1,e.length))):y(y({},e),{},h({},i,c)):e}const j=require("react-virtualized");function S(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function x(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?S(Object(r),!0).forEach((function(t){k(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):S(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function k(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function I(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var M=c().createElement("svg",{width:"1792",height:"1792",viewBox:"0 0 1792 1792",xmlns:"http://www.w3.org/2000/svg"},c().createElement("path",{d:"M1671 566q0 40-28 68l-724 724-136 136q-28 28-68 28t-68-28l-136-136-362-362q-28-28-28-68t28-68l136-136q28-28 68-28t68 28l294 295 656-657q28-28 68-28t68 28l136 136q28 28 28 68z"})),A=c().createElement("span",null),P=c().createElement("svg",{width:"1792",height:"1792",viewBox:"0 0 1792 1792",xmlns:"http://www.w3.org/2000/svg"},c().createElement("path",{d:"M896 352q-148 0-273 73t-198 198-73 273 73 273 198 198 273 73 273-73 198-198 73-273-73-273-198-198-273-73zm768 544q0 209-103 385.5t-279.5 279.5-385.5 103-385.5-103-279.5-279.5-103-385.5 103-385.5 279.5-279.5 385.5-103 385.5 103 279.5 279.5 103 385.5z"})),z=c().createElement("svg",{width:"1792",height:"1792",viewBox:"0 0 1792 1792",xmlns:"http://www.w3.org/2000/svg"},c().createElement("path",{d:"M1152 896q0 106-75 181t-181 75-181-75-75-181 75-181 181-75 181 75 75 181zm-256-544q-148 0-273 73t-198 198-73 273 73 273 198 198 273 73 273-73 198-198 73-273-73-273-198-198-273-73zm768 544q0 209-103 385.5t-279.5 279.5-385.5 103-385.5-103-279.5-279.5-103-385.5 103-385.5 279.5-279.5 385.5-103 385.5 103 279.5 279.5 103 385.5z"})),C=function(e){var t,r,n=e.mainIndex,a=e.subIndex,o=e.curItem,i=e.style,u=e.changeCheckState,s=(t=(0,l.useState)(!1),r=2,function(e){if(Array.isArray(e))return e}(t)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,a,o=[],i=!0,l=!1;try{for(r=r.call(e);!(i=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);i=!0);}catch(e){l=!0,a=e}finally{try{i||null==r.return||r.return()}finally{if(l)throw a}}return o}}(t,r)||function(e,t){if(e){if("string"==typeof e)return I(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?I(e,t):void 0}}(t,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),m=s[0],d=s[1],b=(0,l.useCallback)((function(e){if("separator"!==o.type&&!1!==o.enabled)if("checkbox"===o.type){e.persist();var t=x(x({},o),{},{checked:!o.checked});o.click(t,e),u(n,a,!o.checked)}else if("radio"===o.type){var r=x(x({},o),{},{checked:!0});o.click(r,e),o.checked||u(n,a,!0,!0)}else e.persist(),o.click(o,e);else e.stopPropagation()}),[]);if(0==o.visiable)return c().createElement("div",null);var p=f()("list-item",{selected:m&&"separator"!==o.type&&!1!==o.enabled}),y=f()("menu-item",{disabled:"separator"!==o.type&&!1===o.enabled}),h="separator"===o.type?c().createElement("hr",null):c().createElement("div",{className:y,onClick:b},c().createElement("div",{className:"status-icon"},"radio"===o.type?o.checked?z:P:o.checked&&"checkbox"===o.type?M:A),c().createElement("div",{className:"menu-label"},c().createElement("span",null,o.label)),o.accelerator&&c().createElement("div",{className:"accelerator"},o.accelerator));return c().createElement("div",{role:"menuitem",className:p,style:i,tabIndex:-1,onMouseOver:function(){return d(!0)},onMouseLeave:function(){return d(!1)}},h)},N=function(e){var t=e.rect,r=e.mainIndex,n=e.menulist,a=e.changeCheckState,o=(0,l.useCallback)((function(e){var t=e.index,r=n[t];return!1===r.visiable?0:"separator"===r.type?10:30}),[n]),i=(0,l.useCallback)((function(e){var t=e.key,o=e.rowIndex,i=e.style;return c().createElement(C,{key:t,curItem:n[o],style:i,changeCheckState:a,mainIndex:r,subIndex:o})}),[n,a,r]),u=n.map((function(e,t){return o({index:t})})).reduce((function(e,t){return e+t}),0);return c().createElement("div",{id:"foldout-container",style:{position:"absolute",top:t.bottom,left:0,width:"100%",height:"calc(100% - ".concat(t.bottom,"px)")}},c().createElement("div",{className:"overlay",tabIndex:-1}),c().createElement("div",{className:"foldout",style:{position:"absolute",marginLeft:t.left,maxWidth:"calc(100% - ".concat(t.left,"px)"),height:"100%",overflow:"hidden",top:0}},c().createElement("div",{id:"app-menu-foldout"},c().createElement("div",{className:"menu-pane",style:{height:u,maxHeight:"100%"}},c().createElement("div",{className:"list",role:"menu"},c().createElement(j.Grid,{cellRenderer:i,columnCount:1,rowCount:n.length,columnWidth:240,height:u,rowHeight:o,width:240})),c().createElement("div",{className:"menu-pane menu-endblock"})))))};function q(e){return function(e){if(Array.isArray(e))return B(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||R(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function T(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,a,o=[],i=!0,l=!1;try{for(r=r.call(e);!(i=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);i=!0);}catch(e){l=!0,a=e}finally{try{i||null==r.return||r.return()}finally{if(l)throw a}}return o}}(e,t)||R(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function R(e,t){if(e){if("string"==typeof e)return B(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?B(e,t):void 0}}function B(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var D=function(e){var t=e.menu,r=T((0,l.useState)(!1),2),n=r[0],a=r[1],o=T((0,l.useState)(0),2),i=o[0],u=o[1],s=T((0,l.useState)(t),2),m=s[0],d=s[1],b=(0,l.useRef)(!1),p=(0,l.useRef)({}),y=(0,l.useCallback)((function(e){n&&u(e)}),[n]),h=(0,l.useCallback)((function(e){b.current?b.current=!1:a(!(i===e&&n))}),[n,i]),v=(0,l.useCallback)((function(e){e!==i&&n&&(b.current=!0)}),[n,i]);(0,l.useEffect)((function(){d(t)}),[t]);var w=function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(n){for(var a=q(m),o=m[e].submenu.length,i=0;i<o;i++)"radio"===m[e].submenu[i].type&&(a=O(a,[e,"submenu",i,"checked"],i===t));d(a)}else d(O(m,[e,"submenu",t,"checked"],r))};return c().createElement("div",{id:"app-menu-bar",role:"menubar","aria-label":"Application menu"},m.map((function(e,t){var r;return c().createElement("div",{key:t,onMouseOver:function(){return y(t)},onClick:function(){return h(t)},onTouchStart:function(){return v(t)},onMouseMove:function(){return function(e){u(e)}(t)},ref:function(e){return e&&function(e,t){p.current[t]=e}(e,t)},className:f()("toolbar-dropdown",{open:n&&t===i,closed:!n||t!==i})},n&&t===i&&c().createElement(N,{rect:null===(r=p.current[t])||void 0===r?void 0:r.getBoundingClientRect(),menulist:e.submenu,changeCheckState:w,mainIndex:t}),c().createElement("div",{className:"toolbar-button"},c().createElement("button",{className:"button-component",type:"button",tabIndex:-1},c().createElement("div",{className:"menu-item"},c().createElement("div",{className:"menu-label"},c().createElement("span",{"aria-label":"View"},c().createElement("span",{"aria-hidden":"true"},e.label)))))))})))},L=function(e){var t=e.children,r=e.icon,n=e.menu,a=e.disableMinimize,o=e.disableMaximize,i=e.className,l=e.browserWindowId;return c().createElement("div",{id:"electron-app-title-bar",className:"electron-app-title-bar ".concat(i||"")},c().createElement("div",{className:"resize-handle resize-handle-top"}),c().createElement("div",{className:"resize-handle resize-handle-left"}),!!r&&c().createElement("img",{className:"icon",src:r}),!!n&&c().createElement(D,{menu:n}),t,c().createElement(m,{disableMinimize:a,disableMaximize:o,browserWindowId:l}))};module.exports=t})();
(()=>{"use strict";var e={n:t=>{var a=t&&t.__esModule?()=>t.default:()=>t;return e.d(a,{a}),a},d:(t,a)=>{for(var n in a)e.o(a,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:a[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{MenuBarProps:()=>l.MenuBarProps,MenuItemT:()=>n.MenuItemT,MenuListItemProps:()=>n.MenuListItemProps,MenuListProps:()=>r.MenuListProps,MenuT:()=>l.MenuT,TitleBar:()=>f,TitleBarProps:()=>i.TitleBarProps,WindowControlsProps:()=>a.WindowControlsProps});var a={};e.r(a),e.d(a,{h:()=>m});var n={};e.r(n),e.d(n,{M:()=>k});var r={};e.r(r),e.d(r,{q:()=>x});var l={};e.r(l),e.d(l,{j:()=>y});var i={};e.r(i),e.d(i,{T:()=>f});const c=require("react");var s=e.n(c);const o=require("electron"),m=({disableMaximize:e,disableMinimize:t,browserWindowId:a})=>{const[n,r]=(0,c.useState)(!1),l=(0,c.useRef)(a);(0,c.useEffect)((()=>{const e=(e,t,a)=>{a===l.current&&r(t)};return o.ipcRenderer.on("electron-react-titlebar/maximunize/change",e),(async()=>{l.current=await o.ipcRenderer.invoke("electron-react-titlebar/initialize",a)})().finally((()=>null)),()=>{o.ipcRenderer.removeListener("electron-react-titlebar/maximunize/change",e)}}),[a]);const i=(0,c.useCallback)((()=>{o.ipcRenderer.send("electron-react-titlebar/maximumize/set",a)}),[a]),m=(0,c.useCallback)((()=>{o.ipcRenderer.send("electron-react-titlebar/minimumize/set",a)}),[a]),d=(0,c.useCallback)((()=>{o.ipcRenderer.send("electron-react-titlebar/close",a)}),[a]);return s().createElement("div",{className:"window-controls"},s().createElement("button",{"aria-label":"minimize",tabIndex:-1,className:"window-control window-minimize",disabled:t,onClick:m},s().createElement("svg",{"aria-hidden":"true",version:"1.1",width:"10",height:"10"},s().createElement("path",{d:"M 0,5 10,5 10,6 0,6 Z"}))),s().createElement("button",{"aria-label":"maximize",tabIndex:-1,className:"window-control window-maximize",disabled:e,onClick:i},s().createElement("svg",{"aria-hidden":"true",version:"1.1",width:"10",height:"10"},s().createElement("path",{d:n?"m 2,1e-5 0,2 -2,0 0,8 8,0 0,-2 2,0 0,-8 z m 1,1 6,0 0,6 -1,0 0,-5 -5,0 z m -2,2 6,0 0,6 -6,0 z":"M 0,0 0,10 10,10 10,0 Z M 1,1 9,1 9,9 1,9 Z"}))),s().createElement("button",{"aria-label":"close",tabIndex:-1,className:"window-control window-close",onClick:d},s().createElement("svg",{"aria-hidden":"true",version:"1.1",width:"10",height:"10"},s().createElement("path",{d:"M 0,0 0,0.7 4.3,5 0,9.3 0,10 0.7,10 5,5.7 9.3,10 10,10 10,9.3 5.7,5 10,0.7 10,0 9.3,0 5,4.3 0.7,0 Z"}))))},d=require("classnames");var u=e.n(d);const b=require("lodash");function p(e,t,a){const[n,...r]=t;if(void 0===n)return(0,b.isEqual)(e,a)?e:a;let l;l=n in e?e[n]:{};const i=p(l,r,a);if(i!==l){let t;return t=Array.isArray(e)?[...e.slice(0,n),i,...e.slice(n+1,e.length)]:{...e,[n]:i},t}return e}const h=require("react-virtualized"),v=s().createElement("svg",{width:"1792",height:"1792",viewBox:"0 0 1792 1792",xmlns:"http://www.w3.org/2000/svg"},s().createElement("path",{d:"M1671 566q0 40-28 68l-724 724-136 136q-28 28-68 28t-68-28l-136-136-362-362q-28-28-28-68t28-68l136-136q28-28 68-28t68 28l294 295 656-657q28-28 68-28t68 28l136 136q28 28 28 68z"})),w=s().createElement("span",null),E=s().createElement("svg",{width:"1792",height:"1792",viewBox:"0 0 1792 1792",xmlns:"http://www.w3.org/2000/svg"},s().createElement("path",{d:"M896 352q-148 0-273 73t-198 198-73 273 73 273 198 198 273 73 273-73 198-198 73-273-73-273-198-198-273-73zm768 544q0 209-103 385.5t-279.5 279.5-385.5 103-385.5-103-279.5-279.5-103-385.5 103-385.5 279.5-279.5 385.5-103 385.5 103 279.5 279.5 103 385.5z"})),g=s().createElement("svg",{width:"1792",height:"1792",viewBox:"0 0 1792 1792",xmlns:"http://www.w3.org/2000/svg"},s().createElement("path",{d:"M1152 896q0 106-75 181t-181 75-181-75-75-181 75-181 181-75 181 75 75 181zm-256-544q-148 0-273 73t-198 198-73 273 73 273 198 198 273 73 273-73 198-198 73-273-73-273-198-198-273-73zm768 544q0 209-103 385.5t-279.5 279.5-385.5 103-385.5-103-279.5-279.5-103-385.5 103-385.5 279.5-279.5 385.5-103 385.5 103 279.5 279.5 103 385.5z"})),k=({mainIndex:e,subIndex:t,curItem:a,style:n,changeCheckState:r})=>{const[l,i]=(0,c.useState)(!1),o=(0,c.useCallback)((n=>{if("separator"!==a.type&&!1!==a.enabled)if("checkbox"===a.type){n.persist();const l={...a,checked:!a.checked};a.click(l,n),r(e,t,!a.checked)}else if("radio"===a.type){const l={...a,checked:!0};a.click(l,n),a.checked||r(e,t,!0,!0)}else n.persist(),a.click(a,n);else n.stopPropagation()}),[]);if(0==a.visiable)return s().createElement("div",null);const m=u()("list-item",{selected:l&&"separator"!==a.type&&!1!==a.enabled}),d=u()("menu-item",{disabled:"separator"!==a.type&&!1===a.enabled}),b="separator"===a.type?s().createElement("hr",null):s().createElement("div",{className:d,onClick:o},s().createElement("div",{className:"status-icon"},"radio"===a.type?a.checked?g:E:a.checked&&"checkbox"===a.type?v:w),s().createElement("div",{className:"menu-label"},s().createElement("span",null,a.label)),a.accelerator&&s().createElement("div",{className:"accelerator"},a.accelerator));return s().createElement("div",{role:"menuitem",className:m,style:n,tabIndex:-1,onMouseOver:()=>i(!0),onMouseLeave:()=>i(!1)},b)},x=({rect:e,mainIndex:t,menulist:a,changeCheckState:n})=>{const r=(0,c.useCallback)((({index:e})=>{const t=a[e];return!1===t.visiable?0:"separator"===t.type?10:30}),[a]),l=(0,c.useCallback)((({key:e,rowIndex:r,style:l})=>s().createElement(k,{key:e,curItem:a[r],style:l,changeCheckState:n,mainIndex:t,subIndex:r})),[a,n,t]),i=a.map(((e,t)=>r({index:t}))).reduce(((e,t)=>e+t),0);return s().createElement("div",{id:"foldout-container",style:{position:"absolute",top:e.bottom,left:0,width:"100%",height:`calc(100% - ${e.bottom}px)`}},s().createElement("div",{className:"overlay",tabIndex:-1}),s().createElement("div",{className:"foldout",style:{position:"absolute",marginLeft:e.left,maxWidth:`calc(100% - ${e.left}px)`,height:"100%",overflow:"hidden",top:0}},s().createElement("div",{id:"app-menu-foldout"},s().createElement("div",{className:"menu-pane",style:{height:i,maxHeight:"100%"}},s().createElement("div",{className:"list",role:"menu"},s().createElement(h.Grid,{cellRenderer:l,columnCount:1,rowCount:a.length,columnWidth:240,height:i,rowHeight:r,width:240})),s().createElement("div",{className:"menu-pane menu-endblock"})))))},y=({menu:e})=>{const[t,a]=(0,c.useState)(!1),[n,r]=(0,c.useState)(0),[l,i]=(0,c.useState)(e),o=(0,c.useRef)(!1),m=(0,c.useRef)({}),d=(0,c.useCallback)((e=>{t&&r(e)}),[t]),b=(0,c.useCallback)((e=>{o.current?o.current=!1:a(!(n===e&&t))}),[t,n]),h=(0,c.useCallback)((e=>{e!==n&&t&&(o.current=!0)}),[t,n]);(0,c.useEffect)((()=>{i(e)}),[e]);const v=(e,t,a,n=!1)=>{if(n){let a=[...l];const n=l[e].submenu.length;for(let r=0;r<n;r++)"radio"===l[e].submenu[r].type&&(a=p(a,[e,"submenu",r,"checked"],r===t));i(a)}else i(p(l,[e,"submenu",t,"checked"],a))};return s().createElement("div",{id:"app-menu-bar",role:"menubar","aria-label":"Application menu"},l.map(((e,a)=>{var l;return s().createElement("div",{key:a,onMouseOver:()=>d(a),onClick:()=>b(a),onTouchStart:()=>h(a),onMouseMove:()=>(e=>{r(e)})(a),ref:e=>e&&((e,t)=>{m.current[t]=e})(e,a),className:u()("toolbar-dropdown",{open:t&&a===n,closed:!t||a!==n})},t&&a===n&&s().createElement(x,{rect:null===(l=m.current[a])||void 0===l?void 0:l.getBoundingClientRect(),menulist:e.submenu,changeCheckState:v,mainIndex:a}),s().createElement("div",{className:"toolbar-button"},s().createElement("button",{className:"button-component",type:"button",tabIndex:-1},s().createElement("div",{className:"menu-item"},s().createElement("div",{className:"menu-label"},s().createElement("span",{"aria-label":"View"},s().createElement("span",{"aria-hidden":"true"},e.label)))))))})))},f=({children:e,icon:t,menu:a,disableMinimize:n,disableMaximize:r,className:l,browserWindowId:i})=>s().createElement("div",{id:"electron-app-title-bar",className:`electron-app-title-bar ${l||""}`},s().createElement("div",{className:"resize-handle resize-handle-top"}),s().createElement("div",{className:"resize-handle resize-handle-left"}),!!t&&s().createElement("img",{className:"icon",src:t}),!!a&&s().createElement(y,{menu:a}),e,s().createElement(m,{disableMinimize:n,disableMaximize:r,browserWindowId:i}));module.exports=t})();
//# sourceMappingURL=renderer.js.map

@@ -1,1 +0,1 @@

module.exports = {}
module.exports = require('./renderer')
{
"name": "electron-react-titlebar",
"version": "1.0.0",
"version": "1.1.0",
"description": "A github desktop style title bar component for electron.",
"main": "index.js",
"exports": {
".": "./index.js",
"./main": "./dist/main.js",
"./renderer": "./dist/renderer.js",
"./assets/style.css": "./assets/style.css"
"./assets/style.css": "./assets/style.css",
"./style": "./assets/style.css"
},

@@ -11,0 +13,0 @@ "scripts": {

@@ -29,2 +29,4 @@ # electron-react-titlebar

### Renderer process
#### If you are using webpack

@@ -80,6 +82,6 @@

Note: electron-react-titlebar is supporting a subset of [Electron's MenuItem](https://github.com/electron/electron/blob/master/docs/api/menu-item.md).
P
Supported options:
* `click` - supported, but the parameter only returns `item` and `event`
* `click` - supported, but the callback only have `item` and `event` parameter, and the `browserWindow` parameter is removed due to restriction since Electron@14
* `type` - `submenu` is not supported.

@@ -86,0 +88,0 @@ * `label` - supported

@@ -1,1 +0,1 @@

export { TitleBar, TitleBarProps, MenuItemT, MenuListItemProps, MenuListProps, MenuBarProps, MenuT, WindowControlsProps } from './dist/renderer/index'
export * from './dist/renderer/index'

@@ -13,8 +13,9 @@ import { ipcMain, BrowserWindow, WebContents } from 'electron'

export const initialize = (): void => {
ipcMain.on('electron-react-titlebar/initialize', (event, browserWindowId) => {
ipcMain.handle('electron-react-titlebar/initialize', (event, browserWindowId): number | undefined => {
const browserWindow = browserWindowId ? BrowserWindow.fromId(browserWindowId) : BrowserWindow.fromWebContents(event.sender)
if (browserWindow) {
setupEventListener(browserWindow, event.sender)
event.sender.send('electron-react-titlebar/browser-window-id', browserWindow.id)
return browserWindow.id
}
return undefined
})

@@ -21,0 +22,0 @@

@@ -27,3 +27,14 @@ const { resolve } = require('path');

options: {
presets: ['@babel/preset-env', '@babel/preset-typescript', '@babel/preset-react']
presets: [
[
'@babel/preset-env',
{
"targets": {
"electron": 12
}
}
],
'@babel/preset-typescript',
'@babel/preset-react'
]
}

@@ -30,0 +41,0 @@ },

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc