@mackin.com/styleguide 11.0.9 → 11.0.11
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 +13 -4
- package/index.js +13 -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
|
}
|
|
@@ -598,9 +602,12 @@ const Accordion = (props) => {
|
|
|
598
602
|
}
|
|
599
603
|
}, rightIcon: !props.disabled ? React.createElement(Icon, { id: open ? 'collapse' : 'expand' }) : undefined },
|
|
600
604
|
React.createElement("span", null, props.header))),
|
|
601
|
-
React.createElement("div", { ref: content, className: contentStyles },
|
|
602
|
-
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))));
|
|
603
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 }
|
|
604
611
|
const useAccordionState = (count, openIndex) => {
|
|
605
612
|
const [panels, setShowPanel] = React.useState(new Array(count).fill(false).map((b, i) => {
|
|
606
613
|
return i === openIndex;
|
|
@@ -1216,7 +1223,9 @@ const Autocomplete = (p) => {
|
|
|
1216
1223
|
}), p.listClassName) },
|
|
1217
1224
|
displayOptions.map((v, listItemIndex) => {
|
|
1218
1225
|
const selected = selectedResultIndex === listItemIndex;
|
|
1219
|
-
return (React.createElement(ListItem, { key: v, variant: "full", className: cx(listItemStyles, selected ? listItemFocusStyles : undefined, p.listItemClassName), role: "option", id: getOptionId(p.id, listItemIndex), "aria-selected": selected
|
|
1226
|
+
return (React.createElement(ListItem, { key: v, variant: "full", className: cx(listItemStyles, selected ? listItemFocusStyles : undefined, p.listItemClassName), role: "option", id: getOptionId(p.id, listItemIndex), "aria-selected": selected, onClick: () => {
|
|
1227
|
+
onPickValue(v, true);
|
|
1228
|
+
} },
|
|
1220
1229
|
React.createElement(Text, { tag: "div", ellipsis: true, align: "left", className: listItemTextStyles }, v)));
|
|
1221
1230
|
}),
|
|
1222
1231
|
!p.allowScroll && displayOptions.length < p.options.length && (React.createElement(ListItem, { className: p.listItemClassName },
|
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
|
}
|
|
@@ -616,9 +620,12 @@ const Accordion = (props) => {
|
|
|
616
620
|
}
|
|
617
621
|
}, rightIcon: !props.disabled ? React__namespace.createElement(Icon, { id: open ? 'collapse' : 'expand' }) : undefined },
|
|
618
622
|
React__namespace.createElement("span", null, props.header))),
|
|
619
|
-
React__namespace.createElement("div", { ref: content, className: contentStyles },
|
|
620
|
-
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))));
|
|
621
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 }
|
|
622
629
|
const useAccordionState = (count, openIndex) => {
|
|
623
630
|
const [panels, setShowPanel] = React__namespace.useState(new Array(count).fill(false).map((b, i) => {
|
|
624
631
|
return i === openIndex;
|
|
@@ -1234,7 +1241,9 @@ const Autocomplete = (p) => {
|
|
|
1234
1241
|
}), p.listClassName) },
|
|
1235
1242
|
displayOptions.map((v, listItemIndex) => {
|
|
1236
1243
|
const selected = selectedResultIndex === listItemIndex;
|
|
1237
|
-
return (React__namespace.createElement(ListItem, { key: v, variant: "full", className: css.cx(listItemStyles, selected ? listItemFocusStyles : undefined, p.listItemClassName), role: "option", id: getOptionId(p.id, listItemIndex), "aria-selected": selected
|
|
1244
|
+
return (React__namespace.createElement(ListItem, { key: v, variant: "full", className: css.cx(listItemStyles, selected ? listItemFocusStyles : undefined, p.listItemClassName), role: "option", id: getOptionId(p.id, listItemIndex), "aria-selected": selected, onClick: () => {
|
|
1245
|
+
onPickValue(v, true);
|
|
1246
|
+
} },
|
|
1238
1247
|
React__namespace.createElement(Text, { tag: "div", ellipsis: true, align: "left", className: listItemTextStyles }, v)));
|
|
1239
1248
|
}),
|
|
1240
1249
|
!p.allowScroll && displayOptions.length < p.options.length && (React__namespace.createElement(ListItem, { className: p.listItemClassName },
|