Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@electron-lab/title-bar

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@electron-lab/title-bar - npm Package Compare versions

Comparing version 0.1.8 to 0.2.0

18

es/components/ActionButton.d.ts
import React, { ReactNode } from 'react';
export declare const ActionButton: {
Max: React.FC<React.HTMLAttributes<HTMLDivElement> & {
children?: React.ReactNode | ((isMax: boolean) => ReactNode);
children?: React.ReactNode | ((able: boolean, state: {
isMax: boolean;
}) => ReactNode);
followBrowserWindowOptions?: boolean;
hideButtonWhileDisable?: boolean;
}>;
Close: React.FC<React.HTMLAttributes<HTMLDivElement>>;
Min: React.FC<React.HTMLAttributes<HTMLDivElement>>;
Close: React.FC<React.HTMLAttributes<HTMLDivElement> & {
followBrowserWindowOptions?: boolean;
hideButtonWhileDisable?: boolean;
children?: React.ReactNode | ((able: boolean) => ReactNode);
}>;
Min: React.FC<React.HTMLAttributes<HTMLDivElement> & {
followBrowserWindowOptions?: boolean;
hideButtonWhileDisable?: boolean;
children?: React.ReactNode | ((able: boolean) => ReactNode);
}>;
};

64

es/components/ActionButton.js

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

var _excluded = ["children"],
_excluded2 = ["children"],
_excluded3 = ["children"];
var _excluded = ["children", "followBrowserWindowOptions", "hideButtonWhileDisable"],
_excluded2 = ["children", "followBrowserWindowOptions", "hideButtonWhileDisable"],
_excluded3 = ["children", "followBrowserWindowOptions", "hideButtonWhileDisable"];

@@ -34,4 +34,8 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }

var remote = window.require('@electron/remote');
var Max = function Max(_ref) {
var children = _ref.children,
followBrowserWindowOptions = _ref.followBrowserWindowOptions,
hideButtonWhileDisable = _ref.hideButtonWhileDisable,
rest = _objectWithoutProperties(_ref, _excluded);

@@ -49,13 +53,21 @@

}, []);
var _remote$getCurrentWin = remote.getCurrentWindow(),
isMaximizable = _remote$getCurrentWin.isMaximizable;
var maximizable = followBrowserWindowOptions ? isMaximizable() : true;
var shouldRenderMaxmizable = !(hideButtonWhileDisable && !maximizable);
var finalChildren = children;
if (typeof children === 'function') {
finalChildren = children(state === 'window/state/max');
finalChildren = children(maximizable, {
isMax: state === 'window/state/max'
});
}
return /*#__PURE__*/React.createElement("div", _objectSpread(_objectSpread({}, rest), {}, {
return /*#__PURE__*/React.createElement(React.Fragment, null, shouldRenderMaxmizable && /*#__PURE__*/React.createElement("div", _objectSpread(_objectSpread({}, rest), {}, {
onClick: function onClick() {
ipcRenderer.send(WINDOW_MAXIMIZE);
maximizable && ipcRenderer.send(WINDOW_MAXIMIZE);
}
}), finalChildren);
}), finalChildren));
};

@@ -65,9 +77,22 @@

var children = _ref2.children,
followBrowserWindowOptions = _ref2.followBrowserWindowOptions,
hideButtonWhileDisable = _ref2.hideButtonWhileDisable,
rest = _objectWithoutProperties(_ref2, _excluded2);
return /*#__PURE__*/React.createElement("div", _objectSpread(_objectSpread({}, rest), {}, {
var _remote$getCurrentWin2 = remote.getCurrentWindow(),
isMinimizable = _remote$getCurrentWin2.isMinimizable;
var minimizable = followBrowserWindowOptions ? isMinimizable() : true;
var shouldRenderMinimizable = !(hideButtonWhileDisable && !minimizable);
var finalChildren = children;
if (typeof children === 'function') {
finalChildren = children(minimizable);
}
return /*#__PURE__*/React.createElement(React.Fragment, null, shouldRenderMinimizable && /*#__PURE__*/React.createElement("div", _objectSpread(_objectSpread({}, rest), {}, {
onClick: function onClick() {
ipcRenderer.send(WINDOW_MINIMIZE);
minimizable && ipcRenderer.send(WINDOW_MINIMIZE);
}
}), children);
}), finalChildren));
};

@@ -77,9 +102,22 @@

var children = _ref3.children,
followBrowserWindowOptions = _ref3.followBrowserWindowOptions,
hideButtonWhileDisable = _ref3.hideButtonWhileDisable,
rest = _objectWithoutProperties(_ref3, _excluded3);
return /*#__PURE__*/React.createElement("div", _objectSpread(_objectSpread({}, rest), {}, {
var _remote$getCurrentWin3 = remote.getCurrentWindow(),
isClosable = _remote$getCurrentWin3.isClosable;
var closable = followBrowserWindowOptions ? isClosable() : true;
var shouldRenderClosable = !(hideButtonWhileDisable && !closable);
var finalChildren = children;
if (typeof children === 'function') {
finalChildren = children(closable);
}
return /*#__PURE__*/React.createElement(React.Fragment, null, shouldRenderClosable && /*#__PURE__*/React.createElement("div", _objectSpread(_objectSpread({}, rest), {}, {
onClick: function onClick() {
ipcRenderer.send(WINDOW_CLOSE);
closable && ipcRenderer.send(WINDOW_CLOSE);
}
}), children);
}), finalChildren));
};

@@ -86,0 +124,0 @@

import { ipcMain } from 'electron';
import { WINDOW_CLOSE, WINDOW_MAXIMIZE, WINDOW_MINIMIZE, WINDOW_STATE, WINDOW_STATE_MAX, WINDOW_STATE_NORMAL } from './constants';
import * as remoteMain from '@electron/remote/main';
remoteMain.initialize();
export var initWindowListener = function initWindowListener(mainWindow) {
remoteMain.enable(mainWindow.webContents);
ipcMain.on(WINDOW_CLOSE, function () {

@@ -5,0 +8,0 @@ mainWindow.close();

@@ -7,4 +7,7 @@ import React, { CSSProperties } from 'react';

dark?: boolean;
followBrowserWindowOptions?: boolean;
hideButtonWhileDisable?: boolean;
extra?: React.ReactNode;
};
declare const TitleBar: React.FC<TitleBarProps>;
export default TitleBar;

@@ -30,3 +30,5 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }

dark = _ref.dark,
children = _ref.children;
children = _ref.children,
followBrowserWindowOptions = _ref.followBrowserWindowOptions,
hideButtonWhileDisable = _ref.hideButtonWhileDisable;

@@ -54,19 +56,38 @@ var _useState = useState(title || document.title),

}, dynamicTitle), /*#__PURE__*/React.createElement("div", {
style: {
position: 'relative',
zIndex: 10
}
className: cx(getClassName('flex-provider'))
}, /*#__PURE__*/React.createElement("div", {
className: cx(getClassName('children'))
}, children), platform === 'win32' && /*#__PURE__*/React.createElement("div", {
className: cx(getClassName('actions'))
}, /*#__PURE__*/React.createElement(ActionButton.Min, {
className: cx(getClassName('action'))
}, /*#__PURE__*/React.createElement(IconMinimize, null)), /*#__PURE__*/React.createElement(ActionButton.Max, {
className: cx(getClassName('action'))
}, function (isMax) {
return isMax ? restoreIcon : /*#__PURE__*/React.createElement(IconMaximize, null);
followBrowserWindowOptions: followBrowserWindowOptions,
hideButtonWhileDisable: hideButtonWhileDisable
}, function (able) {
return /*#__PURE__*/React.createElement("div", {
className: cx(getClassName('action'), {
disabled: !able
})
}, /*#__PURE__*/React.createElement(IconMinimize, null));
}), /*#__PURE__*/React.createElement(ActionButton.Max, {
followBrowserWindowOptions: followBrowserWindowOptions,
hideButtonWhileDisable: hideButtonWhileDisable
}, function (able, _ref2) {
var isMax = _ref2.isMax;
return /*#__PURE__*/React.createElement("div", {
className: cx(getClassName('action'), {
disabled: !able
})
}, isMax ? restoreIcon : /*#__PURE__*/React.createElement(IconMaximize, null));
}), /*#__PURE__*/React.createElement(ActionButton.Close, {
className: cx(getClassName('action'), getClassName('close'))
}, /*#__PURE__*/React.createElement(IconClose, null))));
followBrowserWindowOptions: followBrowserWindowOptions,
hideButtonWhileDisable: hideButtonWhileDisable
}, function (able) {
return /*#__PURE__*/React.createElement("div", {
className: cx(getClassName('action'), getClassName('close'), {
disabled: !able
})
}, /*#__PURE__*/React.createElement(IconClose, null));
}))));
};
export default TitleBar;
import React, { ReactNode } from 'react';
export declare const ActionButton: {
Max: React.FC<React.HTMLAttributes<HTMLDivElement> & {
children?: React.ReactNode | ((isMax: boolean) => ReactNode);
children?: React.ReactNode | ((able: boolean, state: {
isMax: boolean;
}) => ReactNode);
followBrowserWindowOptions?: boolean;
hideButtonWhileDisable?: boolean;
}>;
Close: React.FC<React.HTMLAttributes<HTMLDivElement>>;
Min: React.FC<React.HTMLAttributes<HTMLDivElement>>;
Close: React.FC<React.HTMLAttributes<HTMLDivElement> & {
followBrowserWindowOptions?: boolean;
hideButtonWhileDisable?: boolean;
children?: React.ReactNode | ((able: boolean) => ReactNode);
}>;
Min: React.FC<React.HTMLAttributes<HTMLDivElement> & {
followBrowserWindowOptions?: boolean;
hideButtonWhileDisable?: boolean;
children?: React.ReactNode | ((able: boolean) => ReactNode);
}>;
};

@@ -14,5 +14,5 @@ "use strict";

var _excluded = ["children"],
_excluded2 = ["children"],
_excluded3 = ["children"];
var _excluded = ["children", "followBrowserWindowOptions", "hideButtonWhileDisable"],
_excluded2 = ["children", "followBrowserWindowOptions", "hideButtonWhileDisable"],
_excluded3 = ["children", "followBrowserWindowOptions", "hideButtonWhileDisable"];

@@ -48,4 +48,8 @@ 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); }

var remote = window.require('@electron/remote');
var Max = function Max(_ref) {
var children = _ref.children,
followBrowserWindowOptions = _ref.followBrowserWindowOptions,
hideButtonWhileDisable = _ref.hideButtonWhileDisable,
rest = _objectWithoutProperties(_ref, _excluded);

@@ -63,13 +67,21 @@

}, []);
var _remote$getCurrentWin = remote.getCurrentWindow(),
isMaximizable = _remote$getCurrentWin.isMaximizable;
var maximizable = followBrowserWindowOptions ? isMaximizable() : true;
var shouldRenderMaxmizable = !(hideButtonWhileDisable && !maximizable);
var finalChildren = children;
if (typeof children === 'function') {
finalChildren = children(state === 'window/state/max');
finalChildren = children(maximizable, {
isMax: state === 'window/state/max'
});
}
return /*#__PURE__*/_react.default.createElement("div", _objectSpread(_objectSpread({}, rest), {}, {
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, shouldRenderMaxmizable && /*#__PURE__*/_react.default.createElement("div", _objectSpread(_objectSpread({}, rest), {}, {
onClick: function onClick() {
ipcRenderer.send(_constants.WINDOW_MAXIMIZE);
maximizable && ipcRenderer.send(_constants.WINDOW_MAXIMIZE);
}
}), finalChildren);
}), finalChildren));
};

@@ -79,9 +91,22 @@

var children = _ref2.children,
followBrowserWindowOptions = _ref2.followBrowserWindowOptions,
hideButtonWhileDisable = _ref2.hideButtonWhileDisable,
rest = _objectWithoutProperties(_ref2, _excluded2);
return /*#__PURE__*/_react.default.createElement("div", _objectSpread(_objectSpread({}, rest), {}, {
var _remote$getCurrentWin2 = remote.getCurrentWindow(),
isMinimizable = _remote$getCurrentWin2.isMinimizable;
var minimizable = followBrowserWindowOptions ? isMinimizable() : true;
var shouldRenderMinimizable = !(hideButtonWhileDisable && !minimizable);
var finalChildren = children;
if (typeof children === 'function') {
finalChildren = children(minimizable);
}
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, shouldRenderMinimizable && /*#__PURE__*/_react.default.createElement("div", _objectSpread(_objectSpread({}, rest), {}, {
onClick: function onClick() {
ipcRenderer.send(_constants.WINDOW_MINIMIZE);
minimizable && ipcRenderer.send(_constants.WINDOW_MINIMIZE);
}
}), children);
}), finalChildren));
};

@@ -91,9 +116,22 @@

var children = _ref3.children,
followBrowserWindowOptions = _ref3.followBrowserWindowOptions,
hideButtonWhileDisable = _ref3.hideButtonWhileDisable,
rest = _objectWithoutProperties(_ref3, _excluded3);
return /*#__PURE__*/_react.default.createElement("div", _objectSpread(_objectSpread({}, rest), {}, {
var _remote$getCurrentWin3 = remote.getCurrentWindow(),
isClosable = _remote$getCurrentWin3.isClosable;
var closable = followBrowserWindowOptions ? isClosable() : true;
var shouldRenderClosable = !(hideButtonWhileDisable && !closable);
var finalChildren = children;
if (typeof children === 'function') {
finalChildren = children(closable);
}
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, shouldRenderClosable && /*#__PURE__*/_react.default.createElement("div", _objectSpread(_objectSpread({}, rest), {}, {
onClick: function onClick() {
ipcRenderer.send(_constants.WINDOW_CLOSE);
closable && ipcRenderer.send(_constants.WINDOW_CLOSE);
}
}), children);
}), finalChildren));
};

@@ -100,0 +138,0 @@

"use strict";
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
Object.defineProperty(exports, "__esModule", {

@@ -12,3 +14,13 @@ value: true

var remoteMain = _interopRequireWildcard(require("@electron/remote/main"));
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); }
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; }
remoteMain.initialize();
var initWindowListener = function initWindowListener(mainWindow) {
remoteMain.enable(mainWindow.webContents);
_electron.ipcMain.on(_constants.WINDOW_CLOSE, function () {

@@ -15,0 +27,0 @@ mainWindow.close();

@@ -7,4 +7,7 @@ import React, { CSSProperties } from 'react';

dark?: boolean;
followBrowserWindowOptions?: boolean;
hideButtonWhileDisable?: boolean;
extra?: React.ReactNode;
};
declare const TitleBar: React.FC<TitleBarProps>;
export default TitleBar;

@@ -50,3 +50,5 @@ "use strict";

dark = _ref.dark,
children = _ref.children;
children = _ref.children,
followBrowserWindowOptions = _ref.followBrowserWindowOptions,
hideButtonWhileDisable = _ref.hideButtonWhileDisable;

@@ -74,17 +76,36 @@ var _useState = (0, _react.useState)(title || document.title),

}, dynamicTitle), /*#__PURE__*/_react.default.createElement("div", {
style: {
position: 'relative',
zIndex: 10
}
className: (0, _classnames.default)(getClassName('flex-provider'))
}, /*#__PURE__*/_react.default.createElement("div", {
className: (0, _classnames.default)(getClassName('children'))
}, children), platform === 'win32' && /*#__PURE__*/_react.default.createElement("div", {
className: (0, _classnames.default)(getClassName('actions'))
}, /*#__PURE__*/_react.default.createElement(_ActionButton.ActionButton.Min, {
className: (0, _classnames.default)(getClassName('action'))
}, /*#__PURE__*/_react.default.createElement(_Icon.IconMinimize, null)), /*#__PURE__*/_react.default.createElement(_ActionButton.ActionButton.Max, {
className: (0, _classnames.default)(getClassName('action'))
}, function (isMax) {
return isMax ? restoreIcon : /*#__PURE__*/_react.default.createElement(_Icon.IconMaximize, null);
followBrowserWindowOptions: followBrowserWindowOptions,
hideButtonWhileDisable: hideButtonWhileDisable
}, function (able) {
return /*#__PURE__*/_react.default.createElement("div", {
className: (0, _classnames.default)(getClassName('action'), {
disabled: !able
})
}, /*#__PURE__*/_react.default.createElement(_Icon.IconMinimize, null));
}), /*#__PURE__*/_react.default.createElement(_ActionButton.ActionButton.Max, {
followBrowserWindowOptions: followBrowserWindowOptions,
hideButtonWhileDisable: hideButtonWhileDisable
}, function (able, _ref2) {
var isMax = _ref2.isMax;
return /*#__PURE__*/_react.default.createElement("div", {
className: (0, _classnames.default)(getClassName('action'), {
disabled: !able
})
}, isMax ? restoreIcon : /*#__PURE__*/_react.default.createElement(_Icon.IconMaximize, null));
}), /*#__PURE__*/_react.default.createElement(_ActionButton.ActionButton.Close, {
className: (0, _classnames.default)(getClassName('action'), getClassName('close'))
}, /*#__PURE__*/_react.default.createElement(_Icon.IconClose, null))));
followBrowserWindowOptions: followBrowserWindowOptions,
hideButtonWhileDisable: hideButtonWhileDisable
}, function (able) {
return /*#__PURE__*/_react.default.createElement("div", {
className: (0, _classnames.default)(getClassName('action'), getClassName('close'), {
disabled: !able
})
}, /*#__PURE__*/_react.default.createElement(_Icon.IconClose, null));
}))));
};

@@ -91,0 +112,0 @@

{
"name": "@electron-lab/title-bar",
"version": "0.1.8",
"version": "0.2.0",
"main": "lib/index.js",

@@ -9,2 +9,3 @@ "module": "es/index.js",

"dependencies": {
"@electron/remote": "^2.0.1",
"classnames": "^2.3.1"

@@ -24,3 +25,3 @@ },

],
"gitHead": "55a5bf7e75b41c1c50c3277dd37faab3553ab8de",
"gitHead": "4cce2a40ac4266d581687a70e5418829e447b308",
"devDependencies": {

@@ -27,0 +28,0 @@ "jest": "^27.1.0"

@@ -11,4 +11,9 @@ import type { BrowserWindow } from 'electron';

} from './constants';
import * as remoteMain from '@electron/remote/main';
export const initWindowListener = (mainWindow: BrowserWindow):void => {
remoteMain.initialize();
export const initWindowListener = (mainWindow: BrowserWindow): void => {
remoteMain.enable(mainWindow.webContents);
ipcMain.on(WINDOW_CLOSE, () => {

@@ -15,0 +20,0 @@ mainWindow.close();

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

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