Merge branch 'master' of github.com:ONLYOFFICE/CommunityServer-AspNetCore
This commit is contained in:
commit
92a1a34445
1
.gitignore
vendored
1
.gitignore
vendored
@ -11,3 +11,4 @@
|
||||
*.log
|
||||
/packages/asc-web-components
|
||||
/products/ASC.People/Data/
|
||||
Data/
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { find, filter } from "lodash";
|
||||
import { find, filter, cloneDeep } from "lodash";
|
||||
import { EmployeeActivationStatus, EmployeeStatus } from "../../helpers/constants";
|
||||
|
||||
export function getSelectedUser(selection, userId) {
|
||||
@ -141,5 +141,5 @@ export function toEmployeeWrapper(profile) {
|
||||
contacts: []
|
||||
};
|
||||
|
||||
return { ...emptyData, ...profile };
|
||||
return cloneDeep({ ...emptyData, ...profile });
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "asc-web-components",
|
||||
"version": "1.0.65",
|
||||
"version": "1.0.66",
|
||||
"description": "Ascensio System SIA component library",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "dist/asc-web-components.js",
|
||||
|
@ -2,13 +2,14 @@ import React from "react";
|
||||
import PropTypes from "prop-types";
|
||||
import styled from 'styled-components';
|
||||
import { Icons } from '../icons';
|
||||
import isEqual from 'lodash/isEqual';
|
||||
|
||||
const StyledOuter = styled.div`
|
||||
width: ${props => props.size ? Math.abs(parseInt(props.size)) + "px" : "20px"};
|
||||
cursor: ${props => props.isDisabled || !props.isClickable ? 'default' : 'pointer'};
|
||||
line-height: 0;
|
||||
`;
|
||||
class IconButton extends React.Component{
|
||||
class IconButton extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
@ -25,8 +26,8 @@ class IconButton extends React.Component{
|
||||
}
|
||||
|
||||
|
||||
onMouseEnter(e){
|
||||
if(!this.props.isDisabled){
|
||||
onMouseEnter(e) {
|
||||
if (!this.props.isDisabled) {
|
||||
this.setState({
|
||||
currentIconName: this.props.iconHoverName ? this.props.iconHoverName : this.props.iconName,
|
||||
currentIconColor: this.props.hoverColor ? this.props.hoverColor : this.props.color
|
||||
@ -34,8 +35,8 @@ class IconButton extends React.Component{
|
||||
this.props.onMouseEnter && this.props.onMouseEnter(e);
|
||||
}
|
||||
}
|
||||
onMouseLeave(e){
|
||||
if(!this.props.isDisabled){
|
||||
onMouseLeave(e) {
|
||||
if (!this.props.isDisabled) {
|
||||
this.setState({
|
||||
currentIconName: this.props.iconName,
|
||||
currentIconColor: this.props.color
|
||||
@ -43,22 +44,22 @@ class IconButton extends React.Component{
|
||||
this.props.onMouseDown && this.props.onMouseDown(e);
|
||||
}
|
||||
}
|
||||
onMouseDown(e){
|
||||
if(!this.props.isDisabled){
|
||||
onMouseDown(e) {
|
||||
if (!this.props.isDisabled) {
|
||||
this.setState({
|
||||
currentIconName: this.props.iconClickName ? this.props.iconClickName : this.props.iconName,
|
||||
currentIconColor: this.props.clickColor ? this.props.clickColor : this.props.color
|
||||
currentIconColor: this.props.clickColor ? this.props.clickColor : this.props.color
|
||||
});
|
||||
this.props.onMouseDown && this.props.onMouseDown(e);
|
||||
}
|
||||
}
|
||||
onMouseUp(e){
|
||||
if(!this.props.isDisabled){
|
||||
onMouseUp(e) {
|
||||
if (!this.props.isDisabled) {
|
||||
switch (e.nativeEvent.which) {
|
||||
case 1: //Left click
|
||||
this.setState({
|
||||
currentIconName: this.props.iconHoverName ? this.props.iconHoverName : this.props.iconName,
|
||||
currentIconColor: this.props.iconHoverName ? this.props.iconHoverName : this.props.color
|
||||
currentIconColor: this.props.iconHoverName ? this.props.iconHoverName : this.props.color
|
||||
});
|
||||
this.props.onClick && this.props.onClick(e);
|
||||
this.props.onMouseUp && this.props.onMouseUp(e);
|
||||
@ -69,35 +70,24 @@ class IconButton extends React.Component{
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
shouldComponentUpdate(nextProps, nextState){
|
||||
if(!this.isNeedUpdate){
|
||||
for (let propsKey in this.props) {
|
||||
if(typeof this.props[propsKey] != "function" && typeof this.props[propsKey] != "object" && this.props[propsKey] != nextProps[propsKey]){
|
||||
this.isNeedUpdate = true;
|
||||
if(propsKey == "iconName"){
|
||||
this.setState({
|
||||
currentIconName: nextProps[propsKey]
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
shouldComponentUpdate(nextProps, nextState) {
|
||||
|
||||
if (!isEqual(this.props, nextProps)) {
|
||||
let newState = {
|
||||
currentIconName: this.state.currentIconName,
|
||||
currentIconColor: this.state.currentIconColor
|
||||
}
|
||||
for (let stateKey in this.state) {
|
||||
if(typeof this.state[stateKey] != "function" && typeof this.state[stateKey] != "object" && this.state[stateKey] != nextState[stateKey]){
|
||||
this.isNeedUpdate = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!this.isNeedUpdate) return false;
|
||||
else return true;
|
||||
if (this.props.iconName !== nextProps.iconName) newState.currentIconName = nextProps.iconName;
|
||||
if (this.props.color !== nextProps.color) newState.currentIconColor = nextProps.color;
|
||||
this.setState(newState);
|
||||
return true;
|
||||
}
|
||||
this.isNeedUpdate = false;
|
||||
return true;
|
||||
return !isEqual(this.state, nextState);
|
||||
}
|
||||
render(){
|
||||
render() {
|
||||
//console.log("IconButton render");
|
||||
return (
|
||||
<StyledOuter
|
||||
@ -111,7 +101,7 @@ class IconButton extends React.Component{
|
||||
|
||||
isClickable={typeof this.props.onClick === 'function'}
|
||||
>
|
||||
{React.createElement(Icons[this.state.currentIconName], {size: "scale", color: this.state.currentIconColor, isfill: this.props.isFill})}
|
||||
{React.createElement(Icons[this.state.currentIconName], { size: "scale", color: this.state.currentIconColor, isfill: this.props.isFill })}
|
||||
</StyledOuter>
|
||||
);
|
||||
}
|
||||
@ -127,7 +117,7 @@ IconButton.propTypes = {
|
||||
iconName: PropTypes.string.isRequired,
|
||||
iconHoverName: PropTypes.string,
|
||||
iconClickName: PropTypes.string,
|
||||
onClick:PropTypes.func
|
||||
onClick: PropTypes.func
|
||||
};
|
||||
|
||||
IconButton.defaultProps = {
|
||||
|
Loading…
Reference in New Issue
Block a user