gutenblock-controls
Advanced tools
Comparing version 0.3.4 to 0.3.5
@@ -54,37 +54,26 @@ 'use strict'; | ||
key: 'update', | ||
value: function update(name, value, tabId, parentChange, customUpdate) { | ||
value: function update(name, value, tabId, onChange) { | ||
var _props = this.props, | ||
attribute = _props.attribute, | ||
attributes = _props.attributes, | ||
setAttributes = _props.setAttributes; | ||
attributes = _props.attributes; | ||
//if nested repeats, pass state up to top most one | ||
if (parentChange) { | ||
var currentAttributes = attributes[attribute] || []; | ||
var currentAttributes = attributes[attribute] || []; | ||
var foundAttribute = currentAttributes.find(function (attr, index) { | ||
return index === tabId; | ||
}); | ||
var newAttributes = void 0; | ||
if (!foundAttribute) newAttributes = [].concat(_toConsumableArray(currentAttributes), [_defineProperty({}, name, value)]);else newAttributes = currentAttributes.map(function (attr, index) { | ||
return index === tabId ? Object.assign({}, attr, _defineProperty({}, name, value)) : attr; | ||
}); | ||
var foundAttribute = currentAttributes.find(function (attr, index) { | ||
return index === tabId; | ||
}); | ||
var newAttributes = void 0; | ||
if (!foundAttribute) newAttributes = [].concat(_toConsumableArray(currentAttributes), [_defineProperty({}, name, value)]);else newAttributes = currentAttributes.map(function (attr, index) { | ||
return index === tabId ? Object.assign({}, attr, _defineProperty({}, name, value)) : attr; | ||
}); | ||
return parentChange(attribute, newAttributes); | ||
} | ||
var topLevel = [].concat(_toConsumableArray(attributes[attribute])); | ||
topLevel[tabId] = Object.assign({}, topLevel[tabId], _defineProperty({}, name, value)); | ||
setAttributes(_defineProperty({}, attribute, topLevel)); | ||
return onChange(attribute, newAttributes); | ||
} | ||
}, { | ||
key: 'delete', | ||
value: function _delete(childAttributes, childAttribute, tabId, onDelete, customDelete) { | ||
value: function _delete(childAttributes, childAttribute, tabId, onChange) { | ||
var _props2 = this.props, | ||
attribute = _props2.attribute, | ||
attributes = _props2.attributes, | ||
setAttributes = _props2.setAttributes; | ||
attributes = _props2.attributes; | ||
@@ -104,5 +93,3 @@ | ||
if (onDelete) return onDelete(newAttributes, attribute); | ||
setAttributes(_defineProperty({}, attribute, newAttributes)); | ||
return onChange(attribute, newAttributes); | ||
} | ||
@@ -119,4 +106,3 @@ }, { | ||
attributes = _props3.attributes, | ||
_onChange = _props3.onChange, | ||
_onDelete = _props3.onDelete; | ||
_onChange = _props3.onChange; | ||
@@ -131,6 +117,6 @@ | ||
onChange: function onChange(name, value) { | ||
return _this2.update(name, value, index, _onChange, child.onUpdate); | ||
return _this2.update(name, value, index, _onChange); | ||
}, | ||
onDelete: function onDelete(childAttributes, childAttribute) { | ||
return _this2.delete(childAttributes, childAttribute, index, _onDelete, child.onDelete); | ||
return _this2.delete(childAttributes, childAttribute, index, _onChange); | ||
}, | ||
@@ -137,0 +123,0 @@ style: { |
{ | ||
"name": "gutenblock-controls", | ||
"version": "0.3.4", | ||
"version": "0.3.5", | ||
"description": "Useful inspector controls for gutenberg", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
25542
625