react-autowhatever
Advanced tools
Comparing version 0.1.2 to 0.2.0
@@ -24,20 +24,2 @@ import theme from '../theme.less'; | ||
const items = [{ | ||
text: 'Apple' | ||
}, { | ||
text: 'Banana' | ||
}, { | ||
text: 'Cherry' | ||
}, { | ||
text: 'Grapefruit' | ||
}, { | ||
text: 'Lemon' | ||
}]; | ||
function renderItem(item) { | ||
return ( | ||
<span>{item.text}</span> | ||
); | ||
} | ||
class Example extends Component { | ||
@@ -56,5 +38,3 @@ static propTypes = { | ||
<Autowhatever id={exampleId} | ||
isOpen={false} | ||
items={items} | ||
renderItem={renderItem} | ||
items={[]} | ||
inputProps={inputProps} | ||
@@ -61,0 +41,0 @@ theme={theme} /> |
@@ -55,3 +55,2 @@ import theme from '../theme.less'; | ||
<Autowhatever id={exampleId} | ||
isOpen={true} | ||
items={items} | ||
@@ -58,0 +57,0 @@ renderItem={renderItem} |
@@ -55,3 +55,2 @@ import theme from '../theme.less'; | ||
<Autowhatever id={exampleId} | ||
isOpen={true} | ||
items={items} | ||
@@ -58,0 +57,0 @@ renderItem={renderItem} |
@@ -77,3 +77,2 @@ import theme from '../theme.less'; | ||
isMultiSection={true} | ||
isOpen={true} | ||
items={items} | ||
@@ -80,0 +79,0 @@ shouldRenderSection={shouldRenderSection} |
@@ -77,3 +77,2 @@ import theme from '../theme.less'; | ||
isMultiSection={true} | ||
isOpen={true} | ||
items={items} | ||
@@ -80,0 +79,0 @@ shouldRenderSection={shouldRenderSection} |
@@ -133,3 +133,2 @@ 'use strict'; | ||
var isMultiSection = _props4.isMultiSection; | ||
var isOpen = _props4.isOpen; | ||
var items = _props4.items; | ||
@@ -139,2 +138,3 @@ var focusedSectionIndex = _props4.focusedSectionIndex; | ||
var isOpen = items.length > 0; | ||
var ariaActivedescendant = this.getItemId(focusedSectionIndex, focusedItemIndex); | ||
@@ -166,5 +166,4 @@ var theme = (0, _reactThemeable2['default'])(this.props.theme); | ||
isMultiSection: _react.PropTypes.bool, // Indicates whether a multi section list of items should be rendered. | ||
isOpen: _react.PropTypes.bool.isRequired, // Indicates whether `items` should be rendered, or not. | ||
items: _react.PropTypes.array.isRequired, // Array of items or sections to render. | ||
renderItem: _react.PropTypes.func.isRequired, // This function renders a single item. | ||
renderItem: _react.PropTypes.func, // This function renders a single item. | ||
shouldRenderSection: _react.PropTypes.func, // This function gets a section and returns whether it should be rendered, or not. | ||
@@ -187,2 +186,5 @@ renderSectionTitle: _react.PropTypes.func, // This function gets a section and renders its title. | ||
}, | ||
renderItem: function renderItem() { | ||
throw new Error('`renderItem` must be provided'); | ||
}, | ||
renderSectionTitle: function renderSectionTitle() { | ||
@@ -189,0 +191,0 @@ throw new Error('`renderSectionTitle` must be provided'); |
{ | ||
"name": "react-autowhatever", | ||
"version": "0.1.2", | ||
"version": "0.2.0", | ||
"description": "Accessible rendering layer for Autosuggest and Autocomplete components", | ||
@@ -5,0 +5,0 @@ "main": "dist/Autowhatever.js", |
@@ -8,5 +8,4 @@ import React, { Component, PropTypes } from 'react'; | ||
isMultiSection: PropTypes.bool, // Indicates whether a multi section list of items should be rendered. | ||
isOpen: PropTypes.bool.isRequired, // Indicates whether `items` should be rendered, or not. | ||
items: PropTypes.array.isRequired, // Array of items or sections to render. | ||
renderItem: PropTypes.func.isRequired, // This function renders a single item. | ||
renderItem: PropTypes.func, // This function renders a single item. | ||
shouldRenderSection: PropTypes.func, // This function gets a section and returns whether it should be rendered, or not. | ||
@@ -25,2 +24,5 @@ renderSectionTitle: PropTypes.func, // This function gets a section and renders its title. | ||
shouldRenderSection: () => true, | ||
renderItem: () => { | ||
throw new Error('`renderItem` must be provided'); | ||
}, | ||
renderSectionTitle: () => { | ||
@@ -121,4 +123,4 @@ throw new Error('`renderSectionTitle` must be provided'); | ||
render() { | ||
const { id, isMultiSection, isOpen, items, | ||
focusedSectionIndex, focusedItemIndex } = this.props; | ||
const { id, isMultiSection, items, focusedSectionIndex, focusedItemIndex } = this.props; | ||
const isOpen = (items.length > 0); | ||
const ariaActivedescendant = this.getItemId(focusedSectionIndex, focusedItemIndex); | ||
@@ -125,0 +127,0 @@ const theme = themeable(this.props.theme); |
36871
865