@mikezimm/npmfunctions
Version:
Functions used in my SPFx webparts
99 lines • 4.97 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var React = __importStar(require("react"));
var Icon_1 = require("office-ui-fabric-react/lib/Icon");
require('./AccordionStyles.css');
var Accordion = /** @class */ (function (_super) {
__extends(Accordion, _super);
function Accordion(props) {
var _this = _super.call(this, props) || this;
_this.state = {
showAccordion: _this.props.showAccordion !== undefined ? _this.props.showAccordion : false,
};
return _this;
}
Accordion.prototype.componentDidMount = function () {
};
Accordion.prototype.componentDidUpdate = function (prevProps) {
var refresh = false;
if (prevProps.showAccordion !== this.props.showAccordion) {
refresh = true;
}
if (refresh === true) {
}
};
Accordion.prototype.render = function () {
var defaultIcon = this.props.defaultIcon;
var showAccordion = this.state.showAccordion;
var accordionClassName = '';
switch (this.props.animation) {
case 'CenterExpand':
accordionClassName = showAccordion === true ? 'show-fps-accordion-2' : 'hide-fps-accordion-2';
break;
case 'TopDown':
accordionClassName = showAccordion === true ? 'show-fps-accordion-1' : 'hide-fps-accordion-1';
break;
default:
accordionClassName = showAccordion === true ? 'show-fps-accordion-1' : 'hide-fps-accordion-1';
}
var ExpandIconName = defaultIcon ? defaultIcon : 'ChevronDownSmall';
var AccordionIcon = React.createElement(Icon_1.Icon, { style: { paddingLeft: '20px' }, iconName: showAccordion === true ? 'ChevronUpSmall' : ExpandIconName });
var TitleClassNames = ['fps-accordion-title-flex', typeof this.props.title === 'string' ? 'fps-accordion-title' : null].join(' ');
var contentStylesWhenVisible = this.props.contentStyles ? this.props.contentStyles : { height: '100px' };
var contentStyles = showAccordion === true ? contentStylesWhenVisible : undefined;
var AccordionComponent = React.createElement("div", { style: this.props.componentStyles },
React.createElement("div", { className: TitleClassNames, style: this.props.titleStyles, onClick: this._toggleAccordion.bind(this) },
this.props.title,
" ",
AccordionIcon),
React.createElement("div", { className: ['fps-accordion', accordionClassName].join(' '), style: contentStyles }, this.props.content));
return (AccordionComponent);
};
Accordion.prototype._toggleAccordion = function () {
var showAccordion = this.state.showAccordion === true ? false : true;
this.setState({ showAccordion: showAccordion });
if (this.props.toggleCallback)
this.props.toggleCallback(showAccordion);
};
return Accordion;
}(React.Component));
exports.default = Accordion;
//# sourceMappingURL=Accordion.js.map