@uifabric/experiments
Version:
Experimental React components for building experiences for Microsoft 365.
35 lines • 1.66 kB
JavaScript
define(["require", "exports", "tslib", "react", "../../Foundation", "../../Foundation", "../../CollapsibleSection", "./Accordion.styles"], function (require, exports, tslib_1, React, Foundation_1, Foundation_2, CollapsibleSection_1, Accordion_styles_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var AccordionItemType = (Foundation_1.withSlots(CollapsibleSection_1.CollapsibleSection, null)).type;
var AccordionView = function (props) {
var collapseItems = props.collapseItems;
var children = React.Children.map(props.children, function (child, index) {
var defaultItemProps = {
defaultCollapsed: collapseItems,
};
if (child.type === AccordionItemType) {
return React.cloneElement(child, tslib_1.__assign(tslib_1.__assign({}, defaultItemProps), child.props));
}
return Foundation_1.withSlots(CollapsibleSection_1.CollapsibleSection, tslib_1.__assign({}, defaultItemProps),
" ",
child,
" ");
});
var Slots = Foundation_1.getSlots(props, {
root: 'div',
});
return Foundation_1.withSlots(Slots.root, null, children);
};
var AccordionStatics = {
Item: CollapsibleSection_1.CollapsibleSection,
defaultProps: {},
};
exports.Accordion = Foundation_2.createComponent(AccordionView, {
displayName: 'Accordion',
styles: Accordion_styles_1.styles,
statics: AccordionStatics,
});
exports.default = exports.Accordion;
});
//# sourceMappingURL=Accordion.js.map