@mackin.com/styleguide 11.0.8 → 11.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +4 -0
- package/index.esm.js +10 -4
- package/index.js +10 -4
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -16,6 +16,10 @@ interface AccordionProps {
|
|
|
16
16
|
wrapperClassName?: string;
|
|
17
17
|
/** Applied to the expand/collapse header button. */
|
|
18
18
|
headerButtonClassName?: string;
|
|
19
|
+
/** Applied to the wrapping element that contains the expanded content wrapper. Look for a class with `AccordionContent` in it's name in debug tools. */
|
|
20
|
+
contentWrapperClassName?: string;
|
|
21
|
+
/** Applied to the wrapping element that contains `children`. Look for a class with `AccordionExpandedContent` in it's name in debug tools. */
|
|
22
|
+
expandedContentWrapperClassName?: string;
|
|
19
23
|
/** If true, padding will not be added to the expanded content */
|
|
20
24
|
noPad?: boolean;
|
|
21
25
|
/** The initial state of the Accordion. Defaults to 'false'.
|
package/index.esm.js
CHANGED
|
@@ -514,7 +514,7 @@ const Accordion = (props) => {
|
|
|
514
514
|
visibility: 'hidden',
|
|
515
515
|
});
|
|
516
516
|
const expandedContentWrapperStyles = !props.noPad ? css({
|
|
517
|
-
label: '
|
|
517
|
+
label: 'AccordionExpandedContent',
|
|
518
518
|
padding: '0 1rem 1rem 1rem'
|
|
519
519
|
}) : undefined;
|
|
520
520
|
function forceBrowserReflow() {
|
|
@@ -523,9 +523,11 @@ const Accordion = (props) => {
|
|
|
523
523
|
(_a = content.current) === null || _a === void 0 ? void 0 : _a.offsetHeight;
|
|
524
524
|
}
|
|
525
525
|
React.useEffect(() => {
|
|
526
|
+
var _a;
|
|
526
527
|
const currentContent = content.current;
|
|
527
528
|
if (currentContent) {
|
|
528
529
|
if (open) {
|
|
530
|
+
(_a = document.getElementById(expandedPanelId)) === null || _a === void 0 ? void 0 : _a.removeAttribute('hidden');
|
|
529
531
|
currentContent.style.visibility = 'visible';
|
|
530
532
|
currentContent.style.height = '0px';
|
|
531
533
|
forceBrowserReflow();
|
|
@@ -556,8 +558,10 @@ const Accordion = (props) => {
|
|
|
556
558
|
}
|
|
557
559
|
else {
|
|
558
560
|
setTimeout(() => {
|
|
561
|
+
var _a;
|
|
559
562
|
// undo the style so the root class takes back over ('hidden')
|
|
560
563
|
currentContent.style.visibility = '';
|
|
564
|
+
(_a = document.getElementById(expandedPanelId)) === null || _a === void 0 ? void 0 : _a.setAttribute('hidden', 'true');
|
|
561
565
|
}, expandTimeMs + 1);
|
|
562
566
|
}
|
|
563
567
|
}
|
|
@@ -590,7 +594,6 @@ const Accordion = (props) => {
|
|
|
590
594
|
width: ((_c = props.block) !== null && _c !== void 0 ? _c : true) ? '100%' : 'auto'
|
|
591
595
|
}, props.headerButtonClassName)), onClick: e => {
|
|
592
596
|
e.stopPropagation();
|
|
593
|
-
console.warn('click');
|
|
594
597
|
if (props.onChange) {
|
|
595
598
|
props.onChange(!open);
|
|
596
599
|
}
|
|
@@ -599,9 +602,12 @@ const Accordion = (props) => {
|
|
|
599
602
|
}
|
|
600
603
|
}, rightIcon: !props.disabled ? React.createElement(Icon, { id: open ? 'collapse' : 'expand' }) : undefined },
|
|
601
604
|
React.createElement("span", null, props.header))),
|
|
602
|
-
React.createElement("div", { ref: content, className: contentStyles },
|
|
603
|
-
React.createElement("div", { className: expandedContentWrapperStyles, id: expandedPanelId,
|
|
605
|
+
React.createElement("div", { ref: content, className: cx([contentStyles, props.contentWrapperClassName]) },
|
|
606
|
+
React.createElement("div", { className: cx([expandedContentWrapperStyles, props.expandedContentWrapperClassName]), id: expandedPanelId, role: "region", "aria-labelledby": buttonId }, props.children))));
|
|
604
607
|
};
|
|
608
|
+
//TB: FEAT Just have an AccordionGroup component that takes props. If you just want one Accordion, pass on item in the array.
|
|
609
|
+
// allows us to manage state the same way rather than having internal and external states we may need to sync up
|
|
610
|
+
// AccordionDef = { label:string, getContent: () => JSX.Element }
|
|
605
611
|
const useAccordionState = (count, openIndex) => {
|
|
606
612
|
const [panels, setShowPanel] = React.useState(new Array(count).fill(false).map((b, i) => {
|
|
607
613
|
return i === openIndex;
|
package/index.js
CHANGED
|
@@ -532,7 +532,7 @@ const Accordion = (props) => {
|
|
|
532
532
|
visibility: 'hidden',
|
|
533
533
|
});
|
|
534
534
|
const expandedContentWrapperStyles = !props.noPad ? css.css({
|
|
535
|
-
label: '
|
|
535
|
+
label: 'AccordionExpandedContent',
|
|
536
536
|
padding: '0 1rem 1rem 1rem'
|
|
537
537
|
}) : undefined;
|
|
538
538
|
function forceBrowserReflow() {
|
|
@@ -541,9 +541,11 @@ const Accordion = (props) => {
|
|
|
541
541
|
(_a = content.current) === null || _a === void 0 ? void 0 : _a.offsetHeight;
|
|
542
542
|
}
|
|
543
543
|
React__namespace.useEffect(() => {
|
|
544
|
+
var _a;
|
|
544
545
|
const currentContent = content.current;
|
|
545
546
|
if (currentContent) {
|
|
546
547
|
if (open) {
|
|
548
|
+
(_a = document.getElementById(expandedPanelId)) === null || _a === void 0 ? void 0 : _a.removeAttribute('hidden');
|
|
547
549
|
currentContent.style.visibility = 'visible';
|
|
548
550
|
currentContent.style.height = '0px';
|
|
549
551
|
forceBrowserReflow();
|
|
@@ -574,8 +576,10 @@ const Accordion = (props) => {
|
|
|
574
576
|
}
|
|
575
577
|
else {
|
|
576
578
|
setTimeout(() => {
|
|
579
|
+
var _a;
|
|
577
580
|
// undo the style so the root class takes back over ('hidden')
|
|
578
581
|
currentContent.style.visibility = '';
|
|
582
|
+
(_a = document.getElementById(expandedPanelId)) === null || _a === void 0 ? void 0 : _a.setAttribute('hidden', 'true');
|
|
579
583
|
}, expandTimeMs + 1);
|
|
580
584
|
}
|
|
581
585
|
}
|
|
@@ -608,7 +612,6 @@ const Accordion = (props) => {
|
|
|
608
612
|
width: ((_c = props.block) !== null && _c !== void 0 ? _c : true) ? '100%' : 'auto'
|
|
609
613
|
}, props.headerButtonClassName)), onClick: e => {
|
|
610
614
|
e.stopPropagation();
|
|
611
|
-
console.warn('click');
|
|
612
615
|
if (props.onChange) {
|
|
613
616
|
props.onChange(!open);
|
|
614
617
|
}
|
|
@@ -617,9 +620,12 @@ const Accordion = (props) => {
|
|
|
617
620
|
}
|
|
618
621
|
}, rightIcon: !props.disabled ? React__namespace.createElement(Icon, { id: open ? 'collapse' : 'expand' }) : undefined },
|
|
619
622
|
React__namespace.createElement("span", null, props.header))),
|
|
620
|
-
React__namespace.createElement("div", { ref: content, className: contentStyles },
|
|
621
|
-
React__namespace.createElement("div", { className: expandedContentWrapperStyles, id: expandedPanelId,
|
|
623
|
+
React__namespace.createElement("div", { ref: content, className: css.cx([contentStyles, props.contentWrapperClassName]) },
|
|
624
|
+
React__namespace.createElement("div", { className: css.cx([expandedContentWrapperStyles, props.expandedContentWrapperClassName]), id: expandedPanelId, role: "region", "aria-labelledby": buttonId }, props.children))));
|
|
622
625
|
};
|
|
626
|
+
//TB: FEAT Just have an AccordionGroup component that takes props. If you just want one Accordion, pass on item in the array.
|
|
627
|
+
// allows us to manage state the same way rather than having internal and external states we may need to sync up
|
|
628
|
+
// AccordionDef = { label:string, getContent: () => JSX.Element }
|
|
623
629
|
const useAccordionState = (count, openIndex) => {
|
|
624
630
|
const [panels, setShowPanel] = React__namespace.useState(new Array(count).fill(false).map((b, i) => {
|
|
625
631
|
return i === openIndex;
|