Comparing version 0.3.68 to 0.3.69
@@ -10,3 +10,5 @@ // # fields component | ||
var React = require('react'); | ||
var R = React.DOM; | ||
var _ = require('../../undash'); | ||
var cx = require('classnames'); | ||
@@ -55,13 +57,11 @@ module.exports = React.createClass({ | ||
var help = !isGroup ? null : config.createElement('help', { | ||
config: config, field: field | ||
}); | ||
var legend = !isGroup ? null : React.createElement( | ||
return config.createElement('field', { | ||
config: config, field: field, plain: isGroup || this.props.plain | ||
}, R.fieldset({ className: cx(classes) }, isGroup ? React.createElement( | ||
'legend', | ||
null, | ||
config.fieldLabel(field) | ||
); | ||
var content = fields.map(function (childField, i) { | ||
) : null, isGroup ? config.createElement('help', { | ||
config: config, field: field | ||
}) : null, fields.map(function (childField, i) { | ||
var key = childField.key || i; | ||
@@ -73,13 +73,5 @@ return config.createFieldElement({ | ||
}); | ||
}.bind(this)); | ||
return config.createElement('field', { | ||
config: config, field: field, plain: isGroup || this.props.plain | ||
}, config.createElement('fieldset', { | ||
config: config, | ||
field: field, | ||
classes: classes | ||
}, help, legend, content)); | ||
}.bind(this)))); | ||
} | ||
}); |
@@ -48,2 +48,11 @@ // # Choices component | ||
var getInitiallyOpenSections = function getInitiallyOpenSections() { | ||
var choices = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; | ||
return choices.filter(function (choice) { | ||
return choice.sectionKey && choice.initialState === 'open'; | ||
}).map(function (choice) { | ||
return choice.sectionKey; | ||
}); | ||
}; | ||
module.exports = React.createClass({ | ||
@@ -53,7 +62,28 @@ | ||
mixins: [require('../../mixins/helper'), | ||
//plugin.require('mixin.resize'), | ||
//plugin.require('mixin.scroll'), | ||
require('../../mixins/click-outside'), ScrollLock], | ||
mixins: [require('../../mixins/helper'), require('../../mixins/click-outside'), ScrollLock], | ||
// return new set of open sections, when user clicks on section header with sectionKey | ||
getNextOpenSections: function getNextOpenSections(sectionKey) { | ||
var canOpenMultipleSections = this.props.canOpenMultipleSections; | ||
var openSections = this.state.openSections; | ||
if (openSections.indexOf(sectionKey) === -1) { | ||
// currently closed, so open it: | ||
if (canOpenMultipleSections) { | ||
// open this section, leave others alone: | ||
return openSections.concat([sectionKey]); | ||
} else { | ||
// open this section, close all others: | ||
return [sectionKey]; | ||
} | ||
} else { | ||
// currently open, so close it (ie remove it from the list of open sections): | ||
return openSections.filter(function (key) { | ||
return sectionKey !== key; | ||
}); | ||
} | ||
}, | ||
getInitialState: function getInitialState() { | ||
@@ -64,3 +94,4 @@ return { | ||
searchString: '', | ||
hoverValue: null | ||
hoverValue: null, | ||
openSections: getInitiallyOpenSections(this.props.choices) | ||
}; | ||
@@ -105,3 +136,3 @@ }, | ||
this.setState({ | ||
openSection: null, | ||
openSections: getInitiallyOpenSections(this.props.choices), | ||
searchString: '' | ||
@@ -114,3 +145,3 @@ }); | ||
this.setState({ | ||
openSection: null, | ||
openSections: getInitiallyOpenSections(this.props.choices), | ||
searchString: choice.keepSearchString ? this.state.searchString : '' | ||
@@ -123,3 +154,3 @@ }); | ||
this.setState({ | ||
openSection: null, | ||
openSections: getInitiallyOpenSections(this.props.choices), | ||
searchString: '' | ||
@@ -194,3 +225,4 @@ }); | ||
var nextState = { | ||
open: nextProps.open | ||
open: nextProps.open, | ||
openSections: getInitiallyOpenSections(nextProps.choices) | ||
}; | ||
@@ -217,8 +249,5 @@ | ||
onHeaderClick: function onHeaderClick(choice) { | ||
console.log('on header click', choice); | ||
if (this.state.openSection === choice.sectionKey) { | ||
this.setState({ openSection: null }); | ||
} else { | ||
this.setState({ openSection: choice.sectionKey }, this.adjustSize); | ||
} | ||
this.setState({ | ||
openSections: this.getNextOpenSections(choice.sectionKey) | ||
}, this.adjustSize); | ||
}, | ||
@@ -270,3 +299,3 @@ | ||
var openSection = this.state.openSection; | ||
var openSections = this.state.openSections; | ||
var alwaysExanded = !props.isAccordionAlwaysCollapsable && this.hasOneSection() || this.state.searchString; | ||
@@ -280,3 +309,3 @@ var visibleChoices = []; | ||
isInSection = true; | ||
isInOpenSection = choice.sectionKey === openSection; | ||
isInOpenSection = openSections.indexOf(choice.sectionKey) !== -1; | ||
} else if (_.isNull(choice.sectionKey)) { | ||
@@ -484,3 +513,7 @@ isInSection = false; | ||
} else if (choice.sectionKey) { | ||
choiceElement = R.a({ href: 'JavaScript' + ':', onClick: this.onHeaderClick.bind(this, choice) }, config.createElement('choice-section-header', { choice: choice, isOpen: this.state.openSection === choice.sectionKey, isDisabled: hasDisabledSections })); | ||
choiceElement = R.a({ href: 'JavaScript' + ':', onClick: this.onHeaderClick.bind(this, choice) }, config.createElement('choice-section-header', { | ||
choice: choice, | ||
isOpen: this.state.openSections.indexOf(choice.sectionKey) !== -1, | ||
isDisabled: hasDisabledSections | ||
})); | ||
choiceValue = 'section:' + choice.sectionKey; | ||
@@ -487,0 +520,0 @@ } else { |
@@ -72,4 +72,2 @@ // # default-config | ||
createElement_Fieldset: React.createFactory(require('./components/helpers/fieldset')), | ||
createElement_Label: React.createFactory(require('./components/helpers/label')), | ||
@@ -269,3 +267,4 @@ | ||
// Create an element given a name, props, and children. | ||
createElement: function createElement(name, props) { | ||
createElement: function createElement(name, props, children) { | ||
if (!props.config) { | ||
@@ -277,8 +276,4 @@ props = _.extend({}, props, { config: config }); | ||
for (var _len = arguments.length, children = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { | ||
children[_key - 2] = arguments[_key]; | ||
} | ||
if (config['createElement_' + name]) { | ||
return config['createElement_' + name].apply(config, [props].concat(children)); | ||
return config['createElement_' + name](props, children); | ||
} | ||
@@ -288,3 +283,3 @@ | ||
if (config.hasElementFactory('Unknown')) { | ||
return config.createElement.apply(config, ['Unknown', props].concat(children)); | ||
return config.createElement('Unknown', props, children); | ||
} | ||
@@ -517,4 +512,4 @@ } | ||
cssTransitionWrapper: function cssTransitionWrapper() { | ||
for (var _len2 = arguments.length, children = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
children[_key2] = arguments[_key2]; | ||
for (var _len = arguments.length, children = Array(_len), _key = 0; _key < _len; _key++) { | ||
children[_key] = arguments[_key]; | ||
} | ||
@@ -521,0 +516,0 @@ |
@@ -40,3 +40,3 @@ // # bootstrap plugin | ||
return { | ||
createElement: function createElement(name, props) { | ||
createElement: function createElement(name, props, children) { | ||
@@ -56,9 +56,5 @@ name = config.elementName(name); | ||
for (var _len = arguments.length, children = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { | ||
children[_key - 2] = arguments[_key]; | ||
} | ||
return _createElement.apply(undefined, [name, props].concat(children)); | ||
return _createElement(name, props, children); | ||
} | ||
}; | ||
}; |
@@ -31,3 +31,3 @@ // # element-classes plugin | ||
// Wrap the createElement method. | ||
createElement: function createElement(name, props) { | ||
createElement: function createElement(name, props, children) { | ||
@@ -40,9 +40,5 @@ name = config.elementName(name); | ||
for (var _len = arguments.length, children = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { | ||
children[_key - 2] = arguments[_key]; | ||
} | ||
return _createElement.apply(undefined, [name, props].concat(children)); | ||
return _createElement(name, props, children); | ||
} | ||
}; | ||
}; |
{ | ||
"name": "formatic", | ||
"version": "0.3.68", | ||
"version": "0.3.69", | ||
"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
209290
78
5905