@ndla/accordion
Advanced tools
Comparing version 0.3.3 to 0.3.4
@@ -47,3 +47,3 @@ function _typeof(obj) { 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); } | ||
_this.state = { | ||
panelsOpen: props.openIndexes | ||
openIndexes: props.openIndexes | ||
}; | ||
@@ -57,3 +57,3 @@ _this.togglePanel = _this.togglePanel.bind(_assertThisInitialized(_assertThisInitialized(_this))); | ||
value: function togglePanel(index) { | ||
var panelsOpen = this.state.panelsOpen; | ||
var openIndexes = this.state.openIndexes; | ||
var single = this.props.single; | ||
@@ -63,13 +63,13 @@ | ||
this.setState({ | ||
panelsOpen: panelsOpen.includes(index) ? [] : [index] | ||
openIndexes: openIndexes.includes(index) ? [] : [index] | ||
}); | ||
} else if (panelsOpen.includes(index)) { | ||
panelsOpen.splice(panelsOpen.indexOf(index), 1); | ||
} else if (openIndexes.includes(index)) { | ||
openIndexes.splice(openIndexes.indexOf(index), 1); | ||
this.setState({ | ||
panelsOpen: panelsOpen | ||
openIndexes: openIndexes | ||
}); | ||
} else { | ||
panelsOpen.push(index); | ||
openIndexes.push(index); | ||
this.setState({ | ||
panelsOpen: panelsOpen | ||
openIndexes: openIndexes | ||
}); | ||
@@ -81,5 +81,22 @@ } | ||
value: function render() { | ||
var _this2 = this; | ||
return this.props.children({ | ||
openIndexes: this.state.panelsOpen, | ||
handleItemClick: this.togglePanel | ||
openIndexes: this.state.openIndexes, | ||
handleItemClick: this.togglePanel, | ||
getBarProps: function getBarProps(panelId) { | ||
return { | ||
panelId: panelId, | ||
isOpen: _this2.state.openIndexes.includes(panelId), | ||
onClick: function onClick() { | ||
return _this2.togglePanel(panelId); | ||
} | ||
}; | ||
}, | ||
getPanelProps: function getPanelProps(panelId) { | ||
return { | ||
id: panelId, | ||
isOpen: _this2.state.openIndexes.includes(panelId) | ||
}; | ||
} | ||
}); | ||
@@ -86,0 +103,0 @@ } |
@@ -60,3 +60,3 @@ "use strict"; | ||
_this.state = { | ||
panelsOpen: props.openIndexes | ||
openIndexes: props.openIndexes | ||
}; | ||
@@ -70,3 +70,3 @@ _this.togglePanel = _this.togglePanel.bind(_assertThisInitialized(_assertThisInitialized(_this))); | ||
value: function togglePanel(index) { | ||
var panelsOpen = this.state.panelsOpen; | ||
var openIndexes = this.state.openIndexes; | ||
var single = this.props.single; | ||
@@ -76,13 +76,13 @@ | ||
this.setState({ | ||
panelsOpen: panelsOpen.includes(index) ? [] : [index] | ||
openIndexes: openIndexes.includes(index) ? [] : [index] | ||
}); | ||
} else if (panelsOpen.includes(index)) { | ||
panelsOpen.splice(panelsOpen.indexOf(index), 1); | ||
} else if (openIndexes.includes(index)) { | ||
openIndexes.splice(openIndexes.indexOf(index), 1); | ||
this.setState({ | ||
panelsOpen: panelsOpen | ||
openIndexes: openIndexes | ||
}); | ||
} else { | ||
panelsOpen.push(index); | ||
openIndexes.push(index); | ||
this.setState({ | ||
panelsOpen: panelsOpen | ||
openIndexes: openIndexes | ||
}); | ||
@@ -94,5 +94,22 @@ } | ||
value: function render() { | ||
var _this2 = this; | ||
return this.props.children({ | ||
openIndexes: this.state.panelsOpen, | ||
handleItemClick: this.togglePanel | ||
openIndexes: this.state.openIndexes, | ||
handleItemClick: this.togglePanel, | ||
getBarProps: function getBarProps(panelId) { | ||
return { | ||
panelId: panelId, | ||
isOpen: _this2.state.openIndexes.includes(panelId), | ||
onClick: function onClick() { | ||
return _this2.togglePanel(panelId); | ||
} | ||
}; | ||
}, | ||
getPanelProps: function getPanelProps(panelId) { | ||
return { | ||
id: panelId, | ||
isOpen: _this2.state.openIndexes.includes(panelId) | ||
}; | ||
} | ||
}); | ||
@@ -99,0 +116,0 @@ } |
{ | ||
"name": "@ndla/accordion", | ||
"version": "0.3.3", | ||
"version": "0.3.4", | ||
"description": "A simple accordion from NDLA", | ||
@@ -22,3 +22,3 @@ "license": "GPL-3.0", | ||
"dependencies": { | ||
"@ndla/core": "^0.4.3" | ||
"@ndla/core": "^0.4.4" | ||
}, | ||
@@ -34,3 +34,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "f51bccb73b427f3fa96fb6df8f2d450a13fab3f9" | ||
"gitHead": "e222847817aa2f92e26a22462614e5cd964a490e" | ||
} |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
59212
452
0
Updated@ndla/core@^0.4.4