react-accessible-accordion
Advanced tools
Comparing version 3.1.1 to 3.2.0
@@ -6,2 +6,15 @@ # Changelog | ||
## [[v3.2.0]](https://github.com/springload/react-accessible-accordion/releases/tag/v3.2.0) | ||
### Added | ||
- Use `console.error` when provided with invalid HTML5 ids | ||
## [[v3.1.1]](https://github.com/springload/react-accessible-accordion/releases/tag/v3.1.1) | ||
### Fixed | ||
- Use `hidden` capabilities rather than something needing custom css | ||
everywhere. | ||
## [[v3.1.0]](https://github.com/springload/react-accessible-accordion/releases/tag/v3.1.0) | ||
@@ -8,0 +21,0 @@ |
@@ -480,6 +480,18 @@ import { createContext, createElement, PureComponent, Component, Fragment } from 'react'; | ||
counter = counter + 1; | ||
return current; | ||
return "raa-".concat(current); | ||
} | ||
function resetNextUuid() { | ||
counter = DEFAULT; | ||
} // HTML5 ids allow all unicode characters, except for ASCII whitespaces | ||
// https://infra.spec.whatwg.org/#ascii-whitespace | ||
var idRegex = /[\u0009\u000a\u000c\u000d\u0020]/g; | ||
function assertValidHtmlId(htmlId) { | ||
if (htmlId === '' || idRegex.test(htmlId)) { | ||
// tslint:disable-next-line | ||
console.error("uuid must be a valid HTML5 id but was given \"".concat(htmlId, "\", ASCII whitespaces are forbidden")); | ||
return false; | ||
} | ||
return true; | ||
} | ||
@@ -637,3 +649,9 @@ | ||
uuid = _this$props2$uuid === void 0 ? this.instanceUuid : _this$props2$uuid, | ||
dangerouslySetExpanded = _this$props2.dangerouslySetExpanded; | ||
dangerouslySetExpanded = _this$props2.dangerouslySetExpanded, | ||
rest = _objectWithoutProperties(_this$props2, ["uuid", "dangerouslySetExpanded"]); | ||
if (rest.id) { | ||
assertValidHtmlId(rest.id); | ||
} | ||
return createElement(ProviderWrapper, { | ||
@@ -796,2 +814,6 @@ uuid: uuid, | ||
if (rest.id) { | ||
assertValidHtmlId(rest.id); | ||
} | ||
return createElement("div", _extends({}, rest, { | ||
@@ -895,2 +917,7 @@ // tslint:disable-next-line react-a11y-event-has-role | ||
var headingAttributes = itemContext.headingAttributes; | ||
if (props.id) { | ||
assertValidHtmlId(props.id); | ||
} | ||
return createElement(AccordionItemHeading, _extends({}, props, headingAttributes)); | ||
@@ -926,2 +953,7 @@ }); | ||
var panelAttributes = _ref.panelAttributes; | ||
if (_this.props.id) { | ||
assertValidHtmlId(_this.props.id); | ||
} | ||
return createElement("div", _extends({ | ||
@@ -928,0 +960,0 @@ "data-accordion-component": "AccordionItemPanel" |
import * as React from 'react'; | ||
import { InjectedButtonAttributes, InjectedHeadingAttributes, InjectedPanelAttributes } from '../helpers/AccordionStore'; | ||
import { AccordionContext } from './AccordionContext'; | ||
export declare type UUID = string | number; | ||
export declare type UUID = string; | ||
declare type ProviderProps = { | ||
@@ -6,0 +6,0 @@ children?: React.ReactNode; |
@@ -1,2 +0,4 @@ | ||
export declare function nextUuid(): number; | ||
import { UUID } from '../components/ItemContext'; | ||
export declare function nextUuid(): UUID; | ||
export declare function resetNextUuid(): void; | ||
export declare function assertValidHtmlId(htmlId: string): boolean; |
@@ -484,6 +484,18 @@ (function (global, factory) { | ||
counter = counter + 1; | ||
return current; | ||
return "raa-".concat(current); | ||
} | ||
function resetNextUuid() { | ||
counter = DEFAULT; | ||
} // HTML5 ids allow all unicode characters, except for ASCII whitespaces | ||
// https://infra.spec.whatwg.org/#ascii-whitespace | ||
var idRegex = /[\u0009\u000a\u000c\u000d\u0020]/g; | ||
function assertValidHtmlId(htmlId) { | ||
if (htmlId === '' || idRegex.test(htmlId)) { | ||
// tslint:disable-next-line | ||
console.error("uuid must be a valid HTML5 id but was given \"".concat(htmlId, "\", ASCII whitespaces are forbidden")); | ||
return false; | ||
} | ||
return true; | ||
} | ||
@@ -641,3 +653,9 @@ | ||
uuid = _this$props2$uuid === void 0 ? this.instanceUuid : _this$props2$uuid, | ||
dangerouslySetExpanded = _this$props2.dangerouslySetExpanded; | ||
dangerouslySetExpanded = _this$props2.dangerouslySetExpanded, | ||
rest = _objectWithoutProperties(_this$props2, ["uuid", "dangerouslySetExpanded"]); | ||
if (rest.id) { | ||
assertValidHtmlId(rest.id); | ||
} | ||
return React.createElement(ProviderWrapper, { | ||
@@ -800,2 +818,6 @@ uuid: uuid, | ||
if (rest.id) { | ||
assertValidHtmlId(rest.id); | ||
} | ||
return React.createElement("div", _extends({}, rest, { | ||
@@ -899,2 +921,7 @@ // tslint:disable-next-line react-a11y-event-has-role | ||
var headingAttributes = itemContext.headingAttributes; | ||
if (props.id) { | ||
assertValidHtmlId(props.id); | ||
} | ||
return React.createElement(AccordionItemHeading, _extends({}, props, headingAttributes)); | ||
@@ -930,2 +957,7 @@ }); | ||
var panelAttributes = _ref.panelAttributes; | ||
if (_this.props.id) { | ||
assertValidHtmlId(_this.props.id); | ||
} | ||
return React.createElement("div", _extends({ | ||
@@ -932,0 +964,0 @@ "data-accordion-component": "AccordionItemPanel" |
{ | ||
"name": "react-accessible-accordion", | ||
"version": "3.1.1", | ||
"version": "3.2.0", | ||
"description": "Accessible Accordion component for React", | ||
@@ -5,0 +5,0 @@ "main": "dist/umd/index.js", |
105014
1916