Socket
Socket
Sign inDemoInstall

rc-tabs

Package Overview
Dependencies
Maintainers
7
Versions
226
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rc-tabs - npm Package Compare versions

Comparing version 12.7.1 to 12.8.0

22

es/TabNavList/OperationNode.js

@@ -10,2 +10,3 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";

import AddButton from "./AddButton";
import { getRemovable } from "../util";
function OperationNode(_ref, ref) {

@@ -65,10 +66,15 @@ var prefixCls = _ref.prefixCls,

}, tabs.map(function (tab) {
var removable = editable && tab.closable !== false && !tab.disabled;
var closable = tab.closable,
disabled = tab.disabled,
closeIcon = tab.closeIcon,
key = tab.key,
label = tab.label;
var removable = getRemovable(closable, closeIcon, editable, disabled);
return /*#__PURE__*/React.createElement(MenuItem, {
key: tab.key,
id: "".concat(popupId, "-").concat(tab.key),
key: key,
id: "".concat(popupId, "-").concat(key),
role: "option",
"aria-controls": id && "".concat(id, "-panel-").concat(tab.key),
disabled: tab.disabled
}, /*#__PURE__*/React.createElement("span", null, tab.label), removable && /*#__PURE__*/React.createElement("button", {
"aria-controls": id && "".concat(id, "-panel-").concat(key),
disabled: disabled
}, /*#__PURE__*/React.createElement("span", null, label), removable && /*#__PURE__*/React.createElement("button", {
type: "button",

@@ -80,5 +86,5 @@ "aria-label": removeAriaLabel || 'remove',

e.stopPropagation();
onRemoveTab(e, tab.key);
onRemoveTab(e, key);
}
}, tab.closeIcon || editable.removeIcon || '×'));
}, closeIcon || editable.removeIcon || '×'));
}));

@@ -85,0 +91,0 @@ function selectOffset(offset) {

@@ -5,3 +5,3 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";

import * as React from 'react';
import { genDataNodeKey } from "../util";
import { genDataNodeKey, getRemovable } from "../util";
function TabNode(_ref) {

@@ -25,3 +25,3 @@ var _classNames;

var tabPrefix = "".concat(prefixCls, "-tab");
var removable = editable && closable !== false && !disabled;
var removable = getRemovable(closable, closeIcon, editable, disabled);
function onInternalClick(e) {

@@ -28,0 +28,0 @@ if (disabled) {

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

import React from 'react';
import type React from 'react';
import type { ReactNode } from 'react';
import type { EditableConfig } from './interface';
/**

@@ -8,1 +10,2 @@ * We trade Map as deps which may change with same value but different ref object.

export declare function genDataNodeKey(key: React.Key): string;
export declare function getRemovable(closable?: boolean, closeIcon?: ReactNode, editable?: EditableConfig, disabled?: boolean): boolean;

@@ -20,2 +20,14 @@ /**

return String(key).replace(/"/g, RC_TABS_DOUBLE_QUOTE);
}
export function getRemovable(closable, closeIcon, editable, disabled) {
if (
// Only editable tabs can be removed
!editable ||
// Tabs cannot be removed when disabled
disabled ||
// If closable is not explicitly set to true, the remove button should be hidden when closeIcon is null or false
closable !== true && (closeIcon === false || closeIcon === null)) {
return false;
}
return true;
}

@@ -17,2 +17,3 @@ "use strict";

var _AddButton = _interopRequireDefault(require("./AddButton"));
var _util = require("../util");
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); }

@@ -74,10 +75,15 @@ 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; }

}, tabs.map(function (tab) {
var removable = editable && tab.closable !== false && !tab.disabled;
var closable = tab.closable,
disabled = tab.disabled,
closeIcon = tab.closeIcon,
key = tab.key,
label = tab.label;
var removable = (0, _util.getRemovable)(closable, closeIcon, editable, disabled);
return /*#__PURE__*/React.createElement(_rcMenu.MenuItem, {
key: tab.key,
id: "".concat(popupId, "-").concat(tab.key),
key: key,
id: "".concat(popupId, "-").concat(key),
role: "option",
"aria-controls": id && "".concat(id, "-panel-").concat(tab.key),
disabled: tab.disabled
}, /*#__PURE__*/React.createElement("span", null, tab.label), removable && /*#__PURE__*/React.createElement("button", {
"aria-controls": id && "".concat(id, "-panel-").concat(key),
disabled: disabled
}, /*#__PURE__*/React.createElement("span", null, label), removable && /*#__PURE__*/React.createElement("button", {
type: "button",

@@ -89,5 +95,5 @@ "aria-label": removeAriaLabel || 'remove',

e.stopPropagation();
onRemoveTab(e, tab.key);
onRemoveTab(e, key);
}
}, tab.closeIcon || editable.removeIcon || '×'));
}, closeIcon || editable.removeIcon || '×'));
}));

@@ -94,0 +100,0 @@ function selectOffset(offset) {

@@ -34,3 +34,3 @@ "use strict";

var tabPrefix = "".concat(prefixCls, "-tab");
var removable = editable && closable !== false && !disabled;
var removable = (0, _util.getRemovable)(closable, closeIcon, editable, disabled);
function onInternalClick(e) {

@@ -37,0 +37,0 @@ if (disabled) {

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

import React from 'react';
import type React from 'react';
import type { ReactNode } from 'react';
import type { EditableConfig } from './interface';
/**

@@ -8,1 +10,2 @@ * We trade Map as deps which may change with same value but different ref object.

export declare function genDataNodeKey(key: React.Key): string;
export declare function getRemovable(closable?: boolean, closeIcon?: ReactNode, editable?: EditableConfig, disabled?: boolean): boolean;

@@ -7,2 +7,3 @@ "use strict";

exports.genDataNodeKey = genDataNodeKey;
exports.getRemovable = getRemovable;
exports.stringify = stringify;

@@ -28,2 +29,14 @@ /**

return String(key).replace(/"/g, RC_TABS_DOUBLE_QUOTE);
}
function getRemovable(closable, closeIcon, editable, disabled) {
if (
// Only editable tabs can be removed
!editable ||
// Tabs cannot be removed when disabled
disabled ||
// If closable is not explicitly set to true, the remove button should be hidden when closeIcon is null or false
closable !== true && (closeIcon === false || closeIcon === null)) {
return false;
}
return true;
}
{
"name": "rc-tabs",
"version": "12.7.1",
"version": "12.8.0",
"description": "tabs ui component for react",

@@ -5,0 +5,0 @@ "engines": {

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