react-accessible-accordion
Advanced tools
Comparing version 3.3.3 to 3.3.4
@@ -6,15 +6,2 @@ # Changelog | ||
## [[v3.3.2]](https://github.com/springload/react-accessible-accordion/releases/tag/v3.4.0) | ||
### Changed | ||
- Bug fix release. See | ||
https://github.com/springload/react-accessible-accordion/issues/284 | ||
## [[v3.3.1]](https://github.com/springload/react-accessible-accordion/releases/tag/v3.4.0) | ||
### Changed | ||
- ESLint and related fixes. | ||
## [[v3.3.0]](https://github.com/springload/react-accessible-accordion/releases/tag/v3.3.0) | ||
@@ -21,0 +8,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { createElement, PureComponent, createContext, Component, Fragment } from 'react'; | ||
import { createElement, PureComponent, createContext, useState, Fragment } from 'react'; | ||
@@ -207,2 +207,6 @@ function _classCallCheck(instance, Constructor) { | ||
function _slicedToArray(arr, i) { | ||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); | ||
} | ||
function _toConsumableArray(arr) { | ||
@@ -216,2 +220,6 @@ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); | ||
function _arrayWithHoles(arr) { | ||
if (Array.isArray(arr)) return arr; | ||
} | ||
function _iterableToArray(iter) { | ||
@@ -221,2 +229,29 @@ if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); | ||
function _iterableToArrayLimit(arr, i) { | ||
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; | ||
var _arr = []; | ||
var _n = true; | ||
var _d = false; | ||
var _e = undefined; | ||
try { | ||
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { | ||
_arr.push(_s.value); | ||
if (i && _arr.length === i) break; | ||
} | ||
} catch (err) { | ||
_d = true; | ||
_e = err; | ||
} finally { | ||
try { | ||
if (!_n && _i["return"] != null) _i["return"](); | ||
} finally { | ||
if (_d) throw _e; | ||
} | ||
} | ||
return _arr; | ||
} | ||
function _unsupportedIterableToArray(o, minLen) { | ||
@@ -243,2 +278,6 @@ if (!o) return; | ||
function _nonIterableRest() { | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
var AccordionStore = function AccordionStore(_ref) { | ||
@@ -522,57 +561,34 @@ var _this = this; | ||
var Provider$1 = /*#__PURE__*/function (_React$Component) { | ||
_inherits(Provider, _React$Component); | ||
var Provider$1 = function Provider(_ref) { | ||
var children = _ref.children, | ||
uuid = _ref.uuid, | ||
accordionContext = _ref.accordionContext, | ||
dangerouslySetExpanded = _ref.dangerouslySetExpanded; | ||
var _super = _createSuper(Provider); | ||
var toggleExpanded = function toggleExpanded() { | ||
accordionContext.toggleExpanded(uuid); | ||
}; | ||
function Provider() { | ||
var _this; | ||
var renderChildren = function renderChildren(accordionContext) { | ||
var expanded = dangerouslySetExpanded !== null && dangerouslySetExpanded !== void 0 ? dangerouslySetExpanded : accordionContext.isItemExpanded(uuid); | ||
var disabled = accordionContext.isItemDisabled(uuid); | ||
var panelAttributes = accordionContext.getPanelAttributes(uuid, dangerouslySetExpanded); | ||
var headingAttributes = accordionContext.getHeadingAttributes(uuid); | ||
var buttonAttributes = accordionContext.getButtonAttributes(uuid, dangerouslySetExpanded); | ||
return /*#__PURE__*/createElement(Context$1.Provider, { | ||
value: { | ||
uuid: uuid, | ||
expanded: expanded, | ||
disabled: disabled, | ||
toggleExpanded: toggleExpanded, | ||
panelAttributes: panelAttributes, | ||
headingAttributes: headingAttributes, | ||
buttonAttributes: buttonAttributes | ||
} | ||
}, children); | ||
}; | ||
_classCallCheck(this, Provider); | ||
return /*#__PURE__*/createElement(Consumer, null, renderChildren); | ||
}; | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this = _super.call.apply(_super, [this].concat(args)); | ||
_defineProperty(_assertThisInitialized(_this), "toggleExpanded", function () { | ||
_this.props.accordionContext.toggleExpanded(_this.props.uuid); | ||
}); | ||
_defineProperty(_assertThisInitialized(_this), "renderChildren", function (accordionContext) { | ||
var _this$props = _this.props, | ||
uuid = _this$props.uuid, | ||
dangerouslySetExpanded = _this$props.dangerouslySetExpanded; | ||
var expanded = dangerouslySetExpanded !== null && dangerouslySetExpanded !== void 0 ? dangerouslySetExpanded : accordionContext.isItemExpanded(uuid); | ||
var disabled = accordionContext.isItemDisabled(uuid); | ||
var panelAttributes = accordionContext.getPanelAttributes(uuid, dangerouslySetExpanded); | ||
var headingAttributes = accordionContext.getHeadingAttributes(uuid); | ||
var buttonAttributes = accordionContext.getButtonAttributes(uuid, dangerouslySetExpanded); | ||
return /*#__PURE__*/createElement(Context$1.Provider, { | ||
value: { | ||
uuid: uuid, | ||
expanded: expanded, | ||
disabled: disabled, | ||
toggleExpanded: _this.toggleExpanded, | ||
panelAttributes: panelAttributes, | ||
headingAttributes: headingAttributes, | ||
buttonAttributes: buttonAttributes | ||
} | ||
}, _this.props.children); | ||
}); | ||
return _this; | ||
} | ||
_createClass(Provider, [{ | ||
key: "render", | ||
value: function render() { | ||
return /*#__PURE__*/createElement(Consumer, null, this.renderChildren); | ||
} | ||
}]); | ||
return Provider; | ||
}(Component); | ||
var ProviderWrapper = function ProviderWrapper(props) { | ||
@@ -585,105 +601,49 @@ return /*#__PURE__*/createElement(Consumer, null, function (accordionContext) { | ||
}; | ||
var Consumer$1 = /*#__PURE__*/function (_React$PureComponent) { | ||
_inherits(Consumer, _React$PureComponent); | ||
var Consumer$1 = function Consumer(_ref2) { | ||
var children = _ref2.children; | ||
var _super2 = _createSuper(Consumer); | ||
var renderChildren = function renderChildren(container) { | ||
return container ? children(container) : null; | ||
}; | ||
function Consumer() { | ||
var _this2; | ||
_classCallCheck(this, Consumer); | ||
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
} | ||
_this2 = _super2.call.apply(_super2, [this].concat(args)); | ||
_defineProperty(_assertThisInitialized(_this2), "renderChildren", function (container) { | ||
return container ? _this2.props.children(container) : null; | ||
}); | ||
return _this2; | ||
} | ||
_createClass(Consumer, [{ | ||
key: "render", | ||
value: function render() { | ||
return /*#__PURE__*/createElement(Context$1.Consumer, null, this.renderChildren); | ||
} | ||
}]); | ||
return Consumer; | ||
}(PureComponent); | ||
var defaultProps = { | ||
className: 'accordion__item' | ||
return /*#__PURE__*/createElement(Context$1.Consumer, null, renderChildren); | ||
}; | ||
var AccordionItem = /*#__PURE__*/function (_React$Component) { | ||
_inherits(AccordionItem, _React$Component); | ||
var AccordionItem = function AccordionItem(_ref) { | ||
var customUuid = _ref.uuid, | ||
dangerouslySetExpanded = _ref.dangerouslySetExpanded, | ||
_ref$className = _ref.className, | ||
className = _ref$className === void 0 ? 'accordion__item' : _ref$className, | ||
activeClassName = _ref.activeClassName, | ||
rest = _objectWithoutProperties(_ref, ["uuid", "dangerouslySetExpanded", "className", "activeClassName"]); | ||
var _super = _createSuper(AccordionItem); | ||
var _useState = useState(nextUuid()), | ||
_useState2 = _slicedToArray(_useState, 1), | ||
instanceUuid = _useState2[0]; | ||
function AccordionItem() { | ||
var _this; | ||
var uuid = customUuid || instanceUuid; | ||
_classCallCheck(this, AccordionItem); | ||
var renderChildren = function renderChildren(itemContext) { | ||
var expanded = itemContext.expanded; | ||
var cx = expanded && activeClassName ? activeClassName : className; | ||
return /*#__PURE__*/createElement("div", _extends({ | ||
"data-accordion-component": "AccordionItem", | ||
className: cx | ||
}, rest)); | ||
}; | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
assertValidHtmlId(uuid); | ||
_this = _super.call.apply(_super, [this].concat(args)); | ||
_defineProperty(_assertThisInitialized(_this), "instanceUuid", nextUuid()); | ||
_defineProperty(_assertThisInitialized(_this), "renderChildren", function (itemContext) { | ||
var _this$props = _this.props, | ||
uuid = _this$props.uuid, | ||
className = _this$props.className, | ||
activeClassName = _this$props.activeClassName, | ||
dangerouslySetExpanded = _this$props.dangerouslySetExpanded, | ||
rest = _objectWithoutProperties(_this$props, ["uuid", "className", "activeClassName", "dangerouslySetExpanded"]); | ||
var expanded = itemContext.expanded; | ||
var cx = expanded && activeClassName ? activeClassName : className; | ||
return /*#__PURE__*/createElement("div", _extends({ | ||
"data-accordion-component": "AccordionItem", | ||
className: cx | ||
}, rest)); | ||
}); | ||
return _this; | ||
if (rest.id) { | ||
assertValidHtmlId(rest.id); | ||
} | ||
_createClass(AccordionItem, [{ | ||
key: "render", | ||
value: function render() { | ||
var _this$props2 = this.props, | ||
_this$props2$uuid = _this$props2.uuid, | ||
uuid = _this$props2$uuid === void 0 ? this.instanceUuid : _this$props2$uuid, | ||
dangerouslySetExpanded = _this$props2.dangerouslySetExpanded, | ||
rest = _objectWithoutProperties(_this$props2, ["uuid", "dangerouslySetExpanded"]); | ||
return /*#__PURE__*/createElement(ProviderWrapper, { | ||
uuid: uuid, | ||
dangerouslySetExpanded: dangerouslySetExpanded | ||
}, /*#__PURE__*/createElement(Consumer$1, null, renderChildren)); | ||
}; | ||
assertValidHtmlId(uuid); | ||
AccordionItem.displayName = DisplayName$1.AccordionItem; | ||
if (rest.id) { | ||
assertValidHtmlId(rest.id); | ||
} | ||
return /*#__PURE__*/createElement(ProviderWrapper, { | ||
uuid: uuid, | ||
dangerouslySetExpanded: dangerouslySetExpanded | ||
}, /*#__PURE__*/createElement(Consumer$1, null, this.renderChildren)); | ||
} | ||
}]); | ||
return AccordionItem; | ||
}(Component); | ||
_defineProperty(AccordionItem, "defaultProps", defaultProps); | ||
_defineProperty(AccordionItem, "displayName", DisplayName$1.AccordionItem); | ||
function getClosestAccordion(el) { | ||
@@ -738,10 +698,11 @@ return el && (el.matches('[data-accordion-component="Accordion"]') ? el : getClosestAccordion(el.parentElement)); | ||
var keycodes = { | ||
DOWN: '40', | ||
END: '35', | ||
ENTER: '13', | ||
HOME: '36', | ||
LEFT: '37', | ||
RIGHT: '39', | ||
SPACE: '32', | ||
UP: '38' | ||
END: 'End', | ||
ENTER: 'Enter', | ||
HOME: 'Home', | ||
SPACE: ' ', | ||
SPACE_DEPRECATED: 'Spacebar', | ||
UP: 'ArrowUp', | ||
DOWN: 'ArrowDown', | ||
LEFT: 'ArrowLeft', | ||
RIGHT: 'ArrowRight' | ||
}; | ||
@@ -756,5 +717,5 @@ | ||
var handleKeyPress = function handleKeyPress(evt) { | ||
var keyCode = evt.which.toString(); | ||
var keyCode = evt.key; | ||
if (keyCode === keycodes.ENTER || keyCode === keycodes.SPACE) { | ||
if (keyCode === keycodes.ENTER || keyCode === keycodes.SPACE || keyCode === keycodes.SPACE_DEPRECATED) { | ||
evt.preventDefault(); | ||
@@ -830,3 +791,3 @@ toggleExpanded(); | ||
var defaultProps$1 = { | ||
var defaultProps = { | ||
className: 'accordion__heading', | ||
@@ -896,3 +857,3 @@ 'aria-level': 3 | ||
_defineProperty(AccordionItemHeading, "defaultProps", defaultProps$1); | ||
_defineProperty(AccordionItemHeading, "defaultProps", defaultProps); | ||
@@ -899,0 +860,0 @@ var AccordionItemHeadingWrapper = function AccordionItemHeadingWrapper(props) { |
@@ -1,5 +0,5 @@ | ||
import * as React from 'react'; | ||
/// <reference types="react" /> | ||
import DisplayName from '../helpers/DisplayName'; | ||
import { DivAttributes } from '../helpers/types'; | ||
import { ItemContext, UUID } from './ItemContext'; | ||
import { UUID } from './ItemContext'; | ||
declare type Props = DivAttributes & { | ||
@@ -10,12 +10,6 @@ uuid?: UUID; | ||
}; | ||
declare const defaultProps: { | ||
className: string; | ||
declare const AccordionItem: { | ||
({ uuid: customUuid, dangerouslySetExpanded, className, activeClassName, ...rest }: Props): JSX.Element; | ||
displayName: DisplayName; | ||
}; | ||
export default class AccordionItem extends React.Component<Props> { | ||
static defaultProps: typeof defaultProps; | ||
static displayName: DisplayName.AccordionItem; | ||
instanceUuid: UUID; | ||
renderChildren: (itemContext: ItemContext) => JSX.Element; | ||
render(): JSX.Element; | ||
} | ||
export {}; | ||
export default AccordionItem; |
@@ -26,5 +26,2 @@ import * as React from 'react'; | ||
}; | ||
export declare class Consumer extends React.PureComponent<ConsumerProps> { | ||
renderChildren: (container: ItemContext | null) => React.ReactNode; | ||
render(): JSX.Element; | ||
} | ||
export declare const Consumer: ({ children }: ConsumerProps) => JSX.Element; |
declare const keycodes: { | ||
DOWN: string; | ||
END: string; | ||
ENTER: string; | ||
HOME: string; | ||
SPACE: string; | ||
SPACE_DEPRECATED: string; | ||
UP: string; | ||
DOWN: string; | ||
LEFT: string; | ||
RIGHT: string; | ||
SPACE: string; | ||
UP: string; | ||
}; | ||
export default keycodes; |
@@ -211,2 +211,6 @@ (function (global, factory) { | ||
function _slicedToArray(arr, i) { | ||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); | ||
} | ||
function _toConsumableArray(arr) { | ||
@@ -220,2 +224,6 @@ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); | ||
function _arrayWithHoles(arr) { | ||
if (Array.isArray(arr)) return arr; | ||
} | ||
function _iterableToArray(iter) { | ||
@@ -225,2 +233,29 @@ if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); | ||
function _iterableToArrayLimit(arr, i) { | ||
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; | ||
var _arr = []; | ||
var _n = true; | ||
var _d = false; | ||
var _e = undefined; | ||
try { | ||
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { | ||
_arr.push(_s.value); | ||
if (i && _arr.length === i) break; | ||
} | ||
} catch (err) { | ||
_d = true; | ||
_e = err; | ||
} finally { | ||
try { | ||
if (!_n && _i["return"] != null) _i["return"](); | ||
} finally { | ||
if (_d) throw _e; | ||
} | ||
} | ||
return _arr; | ||
} | ||
function _unsupportedIterableToArray(o, minLen) { | ||
@@ -247,2 +282,6 @@ if (!o) return; | ||
function _nonIterableRest() { | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
var AccordionStore = function AccordionStore(_ref) { | ||
@@ -526,57 +565,34 @@ var _this = this; | ||
var Provider$1 = /*#__PURE__*/function (_React$Component) { | ||
_inherits(Provider, _React$Component); | ||
var Provider$1 = function Provider(_ref) { | ||
var children = _ref.children, | ||
uuid = _ref.uuid, | ||
accordionContext = _ref.accordionContext, | ||
dangerouslySetExpanded = _ref.dangerouslySetExpanded; | ||
var _super = _createSuper(Provider); | ||
var toggleExpanded = function toggleExpanded() { | ||
accordionContext.toggleExpanded(uuid); | ||
}; | ||
function Provider() { | ||
var _this; | ||
var renderChildren = function renderChildren(accordionContext) { | ||
var expanded = dangerouslySetExpanded !== null && dangerouslySetExpanded !== void 0 ? dangerouslySetExpanded : accordionContext.isItemExpanded(uuid); | ||
var disabled = accordionContext.isItemDisabled(uuid); | ||
var panelAttributes = accordionContext.getPanelAttributes(uuid, dangerouslySetExpanded); | ||
var headingAttributes = accordionContext.getHeadingAttributes(uuid); | ||
var buttonAttributes = accordionContext.getButtonAttributes(uuid, dangerouslySetExpanded); | ||
return /*#__PURE__*/React.createElement(Context$1.Provider, { | ||
value: { | ||
uuid: uuid, | ||
expanded: expanded, | ||
disabled: disabled, | ||
toggleExpanded: toggleExpanded, | ||
panelAttributes: panelAttributes, | ||
headingAttributes: headingAttributes, | ||
buttonAttributes: buttonAttributes | ||
} | ||
}, children); | ||
}; | ||
_classCallCheck(this, Provider); | ||
return /*#__PURE__*/React.createElement(Consumer, null, renderChildren); | ||
}; | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this = _super.call.apply(_super, [this].concat(args)); | ||
_defineProperty(_assertThisInitialized(_this), "toggleExpanded", function () { | ||
_this.props.accordionContext.toggleExpanded(_this.props.uuid); | ||
}); | ||
_defineProperty(_assertThisInitialized(_this), "renderChildren", function (accordionContext) { | ||
var _this$props = _this.props, | ||
uuid = _this$props.uuid, | ||
dangerouslySetExpanded = _this$props.dangerouslySetExpanded; | ||
var expanded = dangerouslySetExpanded !== null && dangerouslySetExpanded !== void 0 ? dangerouslySetExpanded : accordionContext.isItemExpanded(uuid); | ||
var disabled = accordionContext.isItemDisabled(uuid); | ||
var panelAttributes = accordionContext.getPanelAttributes(uuid, dangerouslySetExpanded); | ||
var headingAttributes = accordionContext.getHeadingAttributes(uuid); | ||
var buttonAttributes = accordionContext.getButtonAttributes(uuid, dangerouslySetExpanded); | ||
return /*#__PURE__*/React.createElement(Context$1.Provider, { | ||
value: { | ||
uuid: uuid, | ||
expanded: expanded, | ||
disabled: disabled, | ||
toggleExpanded: _this.toggleExpanded, | ||
panelAttributes: panelAttributes, | ||
headingAttributes: headingAttributes, | ||
buttonAttributes: buttonAttributes | ||
} | ||
}, _this.props.children); | ||
}); | ||
return _this; | ||
} | ||
_createClass(Provider, [{ | ||
key: "render", | ||
value: function render() { | ||
return /*#__PURE__*/React.createElement(Consumer, null, this.renderChildren); | ||
} | ||
}]); | ||
return Provider; | ||
}(React.Component); | ||
var ProviderWrapper = function ProviderWrapper(props) { | ||
@@ -589,105 +605,49 @@ return /*#__PURE__*/React.createElement(Consumer, null, function (accordionContext) { | ||
}; | ||
var Consumer$1 = /*#__PURE__*/function (_React$PureComponent) { | ||
_inherits(Consumer, _React$PureComponent); | ||
var Consumer$1 = function Consumer(_ref2) { | ||
var children = _ref2.children; | ||
var _super2 = _createSuper(Consumer); | ||
var renderChildren = function renderChildren(container) { | ||
return container ? children(container) : null; | ||
}; | ||
function Consumer() { | ||
var _this2; | ||
_classCallCheck(this, Consumer); | ||
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
} | ||
_this2 = _super2.call.apply(_super2, [this].concat(args)); | ||
_defineProperty(_assertThisInitialized(_this2), "renderChildren", function (container) { | ||
return container ? _this2.props.children(container) : null; | ||
}); | ||
return _this2; | ||
} | ||
_createClass(Consumer, [{ | ||
key: "render", | ||
value: function render() { | ||
return /*#__PURE__*/React.createElement(Context$1.Consumer, null, this.renderChildren); | ||
} | ||
}]); | ||
return Consumer; | ||
}(React.PureComponent); | ||
var defaultProps = { | ||
className: 'accordion__item' | ||
return /*#__PURE__*/React.createElement(Context$1.Consumer, null, renderChildren); | ||
}; | ||
var AccordionItem = /*#__PURE__*/function (_React$Component) { | ||
_inherits(AccordionItem, _React$Component); | ||
var AccordionItem = function AccordionItem(_ref) { | ||
var customUuid = _ref.uuid, | ||
dangerouslySetExpanded = _ref.dangerouslySetExpanded, | ||
_ref$className = _ref.className, | ||
className = _ref$className === void 0 ? 'accordion__item' : _ref$className, | ||
activeClassName = _ref.activeClassName, | ||
rest = _objectWithoutProperties(_ref, ["uuid", "dangerouslySetExpanded", "className", "activeClassName"]); | ||
var _super = _createSuper(AccordionItem); | ||
var _useState = React.useState(nextUuid()), | ||
_useState2 = _slicedToArray(_useState, 1), | ||
instanceUuid = _useState2[0]; | ||
function AccordionItem() { | ||
var _this; | ||
var uuid = customUuid || instanceUuid; | ||
_classCallCheck(this, AccordionItem); | ||
var renderChildren = function renderChildren(itemContext) { | ||
var expanded = itemContext.expanded; | ||
var cx = expanded && activeClassName ? activeClassName : className; | ||
return /*#__PURE__*/React.createElement("div", _extends({ | ||
"data-accordion-component": "AccordionItem", | ||
className: cx | ||
}, rest)); | ||
}; | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
assertValidHtmlId(uuid); | ||
_this = _super.call.apply(_super, [this].concat(args)); | ||
_defineProperty(_assertThisInitialized(_this), "instanceUuid", nextUuid()); | ||
_defineProperty(_assertThisInitialized(_this), "renderChildren", function (itemContext) { | ||
var _this$props = _this.props, | ||
uuid = _this$props.uuid, | ||
className = _this$props.className, | ||
activeClassName = _this$props.activeClassName, | ||
dangerouslySetExpanded = _this$props.dangerouslySetExpanded, | ||
rest = _objectWithoutProperties(_this$props, ["uuid", "className", "activeClassName", "dangerouslySetExpanded"]); | ||
var expanded = itemContext.expanded; | ||
var cx = expanded && activeClassName ? activeClassName : className; | ||
return /*#__PURE__*/React.createElement("div", _extends({ | ||
"data-accordion-component": "AccordionItem", | ||
className: cx | ||
}, rest)); | ||
}); | ||
return _this; | ||
if (rest.id) { | ||
assertValidHtmlId(rest.id); | ||
} | ||
_createClass(AccordionItem, [{ | ||
key: "render", | ||
value: function render() { | ||
var _this$props2 = this.props, | ||
_this$props2$uuid = _this$props2.uuid, | ||
uuid = _this$props2$uuid === void 0 ? this.instanceUuid : _this$props2$uuid, | ||
dangerouslySetExpanded = _this$props2.dangerouslySetExpanded, | ||
rest = _objectWithoutProperties(_this$props2, ["uuid", "dangerouslySetExpanded"]); | ||
return /*#__PURE__*/React.createElement(ProviderWrapper, { | ||
uuid: uuid, | ||
dangerouslySetExpanded: dangerouslySetExpanded | ||
}, /*#__PURE__*/React.createElement(Consumer$1, null, renderChildren)); | ||
}; | ||
assertValidHtmlId(uuid); | ||
AccordionItem.displayName = DisplayName$1.AccordionItem; | ||
if (rest.id) { | ||
assertValidHtmlId(rest.id); | ||
} | ||
return /*#__PURE__*/React.createElement(ProviderWrapper, { | ||
uuid: uuid, | ||
dangerouslySetExpanded: dangerouslySetExpanded | ||
}, /*#__PURE__*/React.createElement(Consumer$1, null, this.renderChildren)); | ||
} | ||
}]); | ||
return AccordionItem; | ||
}(React.Component); | ||
_defineProperty(AccordionItem, "defaultProps", defaultProps); | ||
_defineProperty(AccordionItem, "displayName", DisplayName$1.AccordionItem); | ||
function getClosestAccordion(el) { | ||
@@ -742,10 +702,11 @@ return el && (el.matches('[data-accordion-component="Accordion"]') ? el : getClosestAccordion(el.parentElement)); | ||
var keycodes = { | ||
DOWN: '40', | ||
END: '35', | ||
ENTER: '13', | ||
HOME: '36', | ||
LEFT: '37', | ||
RIGHT: '39', | ||
SPACE: '32', | ||
UP: '38' | ||
END: 'End', | ||
ENTER: 'Enter', | ||
HOME: 'Home', | ||
SPACE: ' ', | ||
SPACE_DEPRECATED: 'Spacebar', | ||
UP: 'ArrowUp', | ||
DOWN: 'ArrowDown', | ||
LEFT: 'ArrowLeft', | ||
RIGHT: 'ArrowRight' | ||
}; | ||
@@ -760,5 +721,5 @@ | ||
var handleKeyPress = function handleKeyPress(evt) { | ||
var keyCode = evt.which.toString(); | ||
var keyCode = evt.key; | ||
if (keyCode === keycodes.ENTER || keyCode === keycodes.SPACE) { | ||
if (keyCode === keycodes.ENTER || keyCode === keycodes.SPACE || keyCode === keycodes.SPACE_DEPRECATED) { | ||
evt.preventDefault(); | ||
@@ -834,3 +795,3 @@ toggleExpanded(); | ||
var defaultProps$1 = { | ||
var defaultProps = { | ||
className: 'accordion__heading', | ||
@@ -900,3 +861,3 @@ 'aria-level': 3 | ||
_defineProperty(AccordionItemHeading, "defaultProps", defaultProps$1); | ||
_defineProperty(AccordionItemHeading, "defaultProps", defaultProps); | ||
@@ -903,0 +864,0 @@ var AccordionItemHeadingWrapper = function AccordionItemHeadingWrapper(props) { |
{ | ||
"name": "react-accessible-accordion", | ||
"version": "3.3.3", | ||
"version": "3.3.4", | ||
"description": "Accessible Accordion component for React", | ||
@@ -118,4 +118,4 @@ "main": "dist/umd/index.js", | ||
"puppeteer": "2.0.0", | ||
"react": "16.3.2", | ||
"react-dom": "16.3.3", | ||
"react": "16.8.0", | ||
"react-dom": "16.8.0", | ||
"react-syntax-highlighter": "^12.2.1", | ||
@@ -137,4 +137,4 @@ "react-test-renderer": "^16.8.6", | ||
"peerDependencies": { | ||
"react": "^16.3.2", | ||
"react-dom": "^16.3.3" | ||
"react": "^16.3.2 || ^17.0.0", | ||
"react-dom": "^16.3.3 || ^17.0.0" | ||
}, | ||
@@ -141,0 +141,0 @@ "husky": { |
@@ -124,3 +124,3 @@ [react-accessible-accordion](https://springload.github.io/react-accessible-accordion/) | ||
#### dangerouslySetExpanding: `boolean` [*optional*] | ||
#### dangerouslySetExpanded: `boolean` [*optional*] | ||
@@ -226,9 +226,4 @@ Enables external control of the expansion. | ||
require (other) complex markup in order to be considered 'accessible'. | ||
This also includes disclosure widgets. | ||
If you believe that you have a valid use-case for 'disabled' items, or items | ||
which require manual 'expanded' state-management, then please | ||
[let us know](https://github.com/springload/react-accessible-accordion/issues/new) - | ||
we're always open for critical (but polite) feedback. Otherwise, we don't plan | ||
on implementing this functionality in the near future. | ||
### How do I disable an item? | ||
@@ -238,8 +233,2 @@ | ||
### How do I manually control the expanded state of an item? | ||
See "Which design patterns does this component NOT aim to solve?". You may use | ||
the 'preExpanded' prop to set the initial expanded state, but it may not be | ||
controlled manually thereafter. | ||
## Browser Support | ||
@@ -246,0 +235,0 @@ |
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
98366
1740
244