Socket
Socket
Sign inDemoInstall

terra-button

Package Overview
Dependencies
Maintainers
7
Versions
146
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

terra-button - npm Package Compare versions

Comparing version 3.69.0 to 3.70.0

5

CHANGELOG.md

@@ -5,2 +5,7 @@ # Changelog

## 3.70.0 - (November 2, 2023)
* Changed
* Added support to programmatically set selection state for Fusion-Button
## 3.69.0 - (October 23, 2023)

@@ -7,0 +12,0 @@

44

lib/Button.js

@@ -147,4 +147,3 @@ "use strict";

active: false,
focused: false,
isSelected: false
focused: false
};

@@ -172,3 +171,3 @@ _this.handleKeyDown = _this.handleKeyDown.bind(_assertThisInitialized(_this));

key: "handleClick",
value: function handleClick(event, isSelectable) {
value: function handleClick(event) {
// See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Button#Clicking_and_focus

@@ -183,7 +182,3 @@ // Button on Firefox, Safari and IE running on OS X does not receive focus when clicked.

if (this.props.onClick) {
if (isSelectable) {
this.props.onClick(event, this.state.isSelected);
} else {
this.props.onClick(event);
}
this.props.onClick(event);
}

@@ -193,3 +188,3 @@ }

key: "handleKeyDown",
value: function handleKeyDown(event, isSelectable) {
value: function handleKeyDown(event) {
// Add active state to FF browsers

@@ -214,9 +209,2 @@ if (event.nativeEvent.keyCode === KeyCode.KEY_SPACE) {

});
if (isSelectable) {
this.setState(function (prevState) {
return {
isSelected: !prevState.isSelected
};
});
}
}

@@ -261,13 +249,6 @@ if (this.props.onKeyDown) {

key: "handleMouseDown",
value: function handleMouseDown(event, isSelectable) {
value: function handleMouseDown(event) {
if (this.props.onMouseDown) {
this.props.onMouseDown(event);
}
if (isSelectable) {
this.setState(function (prevState) {
return {
isSelected: !prevState.isSelected
};
});
}

@@ -309,4 +290,5 @@ // See https://developer.mozilla.org/en-US/docs/Web/API/HTMLOrForeignElement/focus#Notes

// TODO: `isSelectable` prop is used for fusion pass through passivity and should be removed after Fusion Phase2 release.
var isSelectable = customProps.isSelectable;
// TODO: `isSelectable` and `isSelected` prop is used for fusion pass through passivity and should be removed after Fusion Phase2 release.
var isSelectable = customProps.isSelectable,
isSelected = customProps.isSelected;
var buttonClasses = (0, _classnames.default)(cx(['button', variant, {

@@ -323,3 +305,3 @@ 'is-disabled': isDisabled

}, {
'is-selected': isSelectable && this.state.isSelected && !isDisabled
'is-selected': isSelectable && isSelected && !isDisabled
}, theme.className]), customProps.className);

@@ -364,3 +346,3 @@ var buttonLabelClasses = cx([buttonLabelCx, {

if (isSelectable) {
customProps['aria-pressed'] = this.state.isSelected;
customProps['aria-pressed'] = isSelected;
}

@@ -380,3 +362,3 @@ var ComponentType = 'button';

onKeyDown: function onKeyDown(event) {
_this2.handleKeyDown(event, isSelectable);
_this2.handleKeyDown(event);
},

@@ -387,6 +369,6 @@ onKeyUp: this.handleKeyUp,

onClick: function onClick(event) {
_this2.handleClick(event, isSelectable);
_this2.handleClick(event);
},
onMouseDown: function onMouseDown(event) {
_this2.handleMouseDown(event, isSelectable);
_this2.handleMouseDown(event);
},

@@ -393,0 +375,0 @@ onFocus: this.handleFocus,

{
"name": "terra-button",
"main": "lib/Button.js",
"version": "3.69.0",
"version": "3.70.0",
"description": "The terra-button component provides users a way to trigger actions in the UI.",

@@ -47,3 +47,3 @@ "repository": {

},
"gitHead": "7eadd8eda62721d33cfc1300091110ddb9051817"
"gitHead": "37032241f543e8fa014c4865ca83ba2df0e2c30c"
}

@@ -121,3 +121,3 @@ import React from 'react';

super(props);
this.state = { active: false, focused: false, isSelected: false };
this.state = { active: false, focused: false };
this.handleKeyDown = this.handleKeyDown.bind(this);

@@ -148,3 +148,3 @@ this.handleKeyUp = this.handleKeyUp.bind(this);

handleClick(event, isSelectable) {
handleClick(event) {
// See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Button#Clicking_and_focus

@@ -160,11 +160,7 @@ // Button on Firefox, Safari and IE running on OS X does not receive focus when clicked.

if (this.props.onClick) {
if (isSelectable) {
this.props.onClick(event, this.state.isSelected);
} else {
this.props.onClick(event);
}
this.props.onClick(event);
}
}
handleKeyDown(event, isSelectable) {
handleKeyDown(event) {
// Add active state to FF browsers

@@ -185,5 +181,2 @@ if (event.nativeEvent.keyCode === KeyCode.KEY_SPACE) {

this.setState({ focused: true });
if (isSelectable) {
this.setState(prevState => ({ isSelected: !prevState.isSelected }));
}
}

@@ -222,9 +215,6 @@

handleMouseDown(event, isSelectable) {
handleMouseDown(event) {
if (this.props.onMouseDown) {
this.props.onMouseDown(event);
}
if (isSelectable) {
this.setState(prevState => ({ isSelected: !prevState.isSelected }));
}

@@ -264,4 +254,4 @@ // See https://developer.mozilla.org/en-US/docs/Web/API/HTMLOrForeignElement/focus#Notes

// TODO: `isSelectable` prop is used for fusion pass through passivity and should be removed after Fusion Phase2 release.
const { isSelectable } = customProps;
// TODO: `isSelectable` and `isSelected` prop is used for fusion pass through passivity and should be removed after Fusion Phase2 release.
const { isSelectable, isSelected } = customProps;

@@ -277,3 +267,3 @@ const buttonClasses = classNames(

{ 'is-focused': this.state.focused && !isDisabled },
{ 'is-selected': isSelectable && this.state.isSelected && !isDisabled },
{ 'is-selected': isSelectable && isSelected && !isDisabled },
theme.className,

@@ -327,3 +317,3 @@ ]),

if (isSelectable) {
customProps['aria-pressed'] = this.state.isSelected;
customProps['aria-pressed'] = isSelected;
}

@@ -346,8 +336,8 @@

aria-label={ariaLabel}
onKeyDown={(event) => { this.handleKeyDown(event, isSelectable); }}
onKeyDown={(event) => { this.handleKeyDown(event); }}
onKeyUp={this.handleKeyUp}
onBlur={this.handleOnBlur}
title={buttonTitle}
onClick={(event) => { this.handleClick(event, isSelectable); }}
onMouseDown={(event) => { this.handleMouseDown(event, isSelectable); }}
onClick={(event) => { this.handleClick(event); }}
onMouseDown={(event) => { this.handleMouseDown(event); }}
onFocus={this.handleFocus}

@@ -354,0 +344,0 @@ href={href}

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