Comparing version 0.3.67 to 0.3.68
@@ -9,4 +9,2 @@ // # object component | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var React = require('react'); | ||
@@ -43,4 +41,2 @@ var update = require('react-addons-update'); | ||
orderedAssocList: function orderedAssocList(props) { | ||
var _this = this; | ||
var config = this.props.config; | ||
@@ -51,31 +47,25 @@ var newAssocList = config.objectToAssocList(props.field.value); | ||
if (this.keyOrder) { | ||
var _ret = function () { | ||
var keyToItem = newAssocList.reduce(function (obj, item) { | ||
obj[item.key] = item; | ||
return obj; | ||
}, {}); | ||
var keyOrderSet = _this.keyOrder.reduce(function (obj, key) { | ||
obj[key] = true; | ||
return obj; | ||
}, {}); | ||
// Make a list in order of old keys. | ||
var orderedAssocList = _this.keyOrder.reduce(function (list, key) { | ||
if (key in keyToItem) { | ||
list.push(keyToItem[key]); | ||
} | ||
return list; | ||
}, []); | ||
// Add any new keys at the end. | ||
newAssocList.reduce(function (list, item) { | ||
if (!(item.key in keyOrderSet)) { | ||
list.push(item); | ||
} | ||
return list; | ||
}, orderedAssocList); | ||
return { | ||
v: orderedAssocList | ||
}; | ||
}(); | ||
if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v; | ||
var keyToItem = newAssocList.reduce(function (obj, item) { | ||
obj[item.key] = item; | ||
return obj; | ||
}, {}); | ||
var keyOrderSet = this.keyOrder.reduce(function (obj, key) { | ||
obj[key] = true; | ||
return obj; | ||
}, {}); | ||
// Make a list in order of old keys. | ||
var orderedAssocList = this.keyOrder.reduce(function (list, key) { | ||
if (key in keyToItem) { | ||
list.push(keyToItem[key]); | ||
} | ||
return list; | ||
}, []); | ||
// Add any new keys at the end. | ||
newAssocList.reduce(function (list, item) { | ||
if (!(item.key in keyOrderSet)) { | ||
list.push(item); | ||
} | ||
return list; | ||
}, orderedAssocList); | ||
return orderedAssocList; | ||
} | ||
@@ -82,0 +72,0 @@ return newAssocList; |
@@ -53,5 +53,5 @@ // # select component | ||
}, config.createElement('pretty-select-value', { | ||
choices: this.state.choices, isAccordion: field.isAccordion, field: field, onChange: this.onChange, onAction: this.onBubbleAction | ||
choices: this.state.choices, isAccordion: field.isAccordion, isAccordionAlwaysCollapsable: field.isAccordionAlwaysCollapsable, field: field, onChange: this.onChange, onAction: this.onBubbleAction | ||
})); | ||
} | ||
}); |
@@ -132,18 +132,16 @@ // # Choices component | ||
if (!this.isListening) { | ||
(function () { | ||
var listenToFrame = function listenToFrame() { | ||
requestAnimationFrameThrottled(3, function () { | ||
if (_this.isListening) { | ||
// Make sure we don't adjust again before rendering. | ||
_this.adjustSize(function () { | ||
if (_this.isListening) { | ||
listenToFrame(); | ||
} | ||
}); | ||
} | ||
}); | ||
}; | ||
_this.isListening = true; | ||
listenToFrame(); | ||
})(); | ||
var listenToFrame = function listenToFrame() { | ||
requestAnimationFrameThrottled(3, function () { | ||
if (_this.isListening) { | ||
// Make sure we don't adjust again before rendering. | ||
_this.adjustSize(function () { | ||
if (_this.isListening) { | ||
listenToFrame(); | ||
} | ||
}); | ||
} | ||
}); | ||
}; | ||
this.isListening = true; | ||
listenToFrame(); | ||
} | ||
@@ -213,2 +211,3 @@ } else { | ||
onHeaderClick: function onHeaderClick(choice) { | ||
console.log('on header click', choice); | ||
if (this.state.openSection === choice.sectionKey) { | ||
@@ -266,3 +265,3 @@ this.setState({ openSection: null }); | ||
var openSection = this.state.openSection; | ||
var alwaysExanded = this.hasOneSection() || this.state.searchString; | ||
var alwaysExanded = !props.isAccordionAlwaysCollapsable && this.hasOneSection() || this.state.searchString; | ||
var visibleChoices = []; | ||
@@ -364,72 +363,70 @@ var isInOpenSection; | ||
if (direction !== 0 || event.keyCode === keyCodes.ENTER) { | ||
(function () { | ||
var visibleChoices = _this4.visibleChoices(); | ||
var hoverValue = _this4.state.hoverValue; | ||
var visibleChoices = this.visibleChoices(); | ||
var hoverValue = this.state.hoverValue; | ||
event.preventDefault(); | ||
event.stopPropagation(); | ||
event.preventDefault(); | ||
event.stopPropagation(); | ||
if (direction !== 0) { | ||
if (visibleChoices) { | ||
var hoverIndex = -1; | ||
if (hoverValue === 'search') { | ||
hoverIndex = -1; | ||
} else { | ||
_.find(visibleChoices, function (choice, i) { | ||
if (hoverValue === _this4.choiceValue(choice)) { | ||
hoverIndex = i; | ||
return true; | ||
} | ||
}); | ||
} | ||
var nextHoverIndex = hoverIndex + direction; | ||
if (nextHoverIndex < 0) { | ||
nextHoverIndex = 0; | ||
if (_this4.refs.container) { | ||
var containerNode = ReactDOM.findDOMNode(_this4.refs.container); | ||
containerNode.scrollTop = 0; | ||
if (direction !== 0) { | ||
if (visibleChoices) { | ||
var hoverIndex = -1; | ||
if (hoverValue === 'search') { | ||
hoverIndex = -1; | ||
} else { | ||
_.find(visibleChoices, function (choice, i) { | ||
if (hoverValue === _this4.choiceValue(choice)) { | ||
hoverIndex = i; | ||
return true; | ||
} | ||
} else if (nextHoverIndex + 1 > visibleChoices.length) { | ||
nextHoverIndex = visibleChoices.length - 1; | ||
}); | ||
} | ||
var nextHoverIndex = hoverIndex + direction; | ||
if (nextHoverIndex < 0) { | ||
nextHoverIndex = 0; | ||
if (this.refs.container) { | ||
var containerNode = ReactDOM.findDOMNode(this.refs.container); | ||
containerNode.scrollTop = 0; | ||
} | ||
var nextHoverComponent = _this4.refs['choice-' + nextHoverIndex]; | ||
if (nextHoverComponent && _this4.refs.container) { | ||
var node = ReactDOM.findDOMNode(nextHoverComponent); | ||
var _containerNode = ReactDOM.findDOMNode(_this4.refs.container); | ||
scrollIntoContainerView(node, _containerNode); | ||
} else if (nextHoverIndex + 1 > visibleChoices.length) { | ||
nextHoverIndex = visibleChoices.length - 1; | ||
} | ||
var nextHoverComponent = this.refs['choice-' + nextHoverIndex]; | ||
if (nextHoverComponent && this.refs.container) { | ||
var node = ReactDOM.findDOMNode(nextHoverComponent); | ||
var _containerNode = ReactDOM.findDOMNode(this.refs.container); | ||
scrollIntoContainerView(node, _containerNode); | ||
} | ||
var nextHoverValue = nextHoverIndex > -1 ? this.choiceValue(visibleChoices[nextHoverIndex]) : 'search'; | ||
if (nextHoverValue === 'search') { | ||
if (this.refs.search) { | ||
this.refs.search.focus(); | ||
} | ||
var nextHoverValue = nextHoverIndex > -1 ? _this4.choiceValue(visibleChoices[nextHoverIndex]) : 'search'; | ||
if (nextHoverValue === 'search') { | ||
if (_this4.refs.search) { | ||
_this4.refs.search.focus(); | ||
} | ||
} | ||
_this4.setState({ | ||
hoverValue: nextHoverValue | ||
}); | ||
} | ||
this.setState({ | ||
hoverValue: nextHoverValue | ||
}); | ||
} | ||
} | ||
if (event.keyCode === keyCodes.ENTER) { | ||
var selectedChoice = _.find(visibleChoices, function (choice) { | ||
return _this4.choiceValue(choice) === hoverValue; | ||
}); | ||
if (selectedChoice) { | ||
if (_this4.props.onFocusSelect) { | ||
_this4.props.onFocusSelect(); | ||
} | ||
if (hoverValue.indexOf('value:') === 0) { | ||
_this4.onSelect(selectedChoice, event); | ||
} else if (selectedChoice.action) { | ||
_this4.onChoiceAction(selectedChoice); | ||
} else if (selectedChoice.sectionKey) { | ||
_this4.onHeaderClick(selectedChoice); | ||
} else { | ||
_this4.onClose(); | ||
} | ||
if (event.keyCode === keyCodes.ENTER) { | ||
var selectedChoice = _.find(visibleChoices, function (choice) { | ||
return _this4.choiceValue(choice) === hoverValue; | ||
}); | ||
if (selectedChoice) { | ||
if (this.props.onFocusSelect) { | ||
this.props.onFocusSelect(); | ||
} | ||
if (hoverValue.indexOf('value:') === 0) { | ||
this.onSelect(selectedChoice, event); | ||
} else if (selectedChoice.action) { | ||
this.onChoiceAction(selectedChoice); | ||
} else if (selectedChoice.sectionKey) { | ||
this.onHeaderClick(selectedChoice); | ||
} else { | ||
this.onClose(); | ||
} | ||
} | ||
})(); | ||
} | ||
} | ||
@@ -436,0 +433,0 @@ }, |
@@ -136,2 +136,3 @@ // # pretty-select-value component | ||
isAccordion: field.isAccordion, | ||
isAccordionAlwaysCollapsable: field.isAccordionAlwaysCollapsable, | ||
hoverIndex: this.state.hoverIndex, | ||
@@ -138,0 +139,0 @@ onFocusSelect: this.onFocus |
{ | ||
"name": "formatic", | ||
"version": "0.3.67", | ||
"version": "0.3.68", | ||
"description": "Automatic, pluggable form generation", | ||
@@ -5,0 +5,0 @@ "main": "./build/lib/formatic", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
209551
5909