"use strict";var _interopRequireWildcard=require("@babel/runtime/helpers/interopRequireWildcard"),_interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.defaultProps=exports.propTypes=void 0;var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")),_possibleConstructorReturn2=_interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")),_getPrototypeOf2=_interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")),_createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass")),_inherits2=_interopRequireDefault(require("@babel/runtime/helpers/inherits")),_defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty")),_objectSpread2=_interopRequireDefault(require("@babel/runtime/helpers/objectSpread")),_react=_interopRequireWildcard(require("react")),_propTypes=_interopRequireDefault(require("prop-types")),_classnames=_interopRequireDefault(require("classnames")),_componentHelper=require("../../shared/component-helper"),renderProps={},propTypes={data:_propTypes.default.oneOfType([_propTypes.default.string,_propTypes.default.arrayOf(_propTypes.default.exact({title:_propTypes.default.string.isRequired,value:_propTypes.default.string.isRequired}))]).isRequired,info:_propTypes.default.string,class:_propTypes.default.string,className:_propTypes.default.string,children:_propTypes.default.oneOfType([_propTypes.default.string,_propTypes.default.node,_propTypes.default.func])};exports.propTypes=propTypes;var defaultProps=(0,_objectSpread2.default)({data:[],info:null,class:null,className:null,children:null},renderProps);exports.defaultProps=defaultProps;var DescriptionList=function(e){function l(e){var t;return(0,_classCallCheck2.default)(this,l),(t=(0,_possibleConstructorReturn2.default)(this,(0,_getPrototypeOf2.default)(l).call(this,e))).state={_listenForPropChanges:!0,_data:e.data||e.children,data:l.getData(e)},t}return(0,_inherits2.default)(l,e),(0,_createClass2.default)(l,null,[{key:"enableWebComponent",value:function(){(0,_componentHelper.registerElement)(l.tagName,l,defaultProps)}},{key:"getData",value:function(e){var t=[];return"string"==typeof(t=e.data?e.data:(0,_componentHelper.processChildren)(e))?"["===t[0]?JSON.parse(t):[]:t||[]}},{key:"getDerivedStateFromProps",value:function(e,t){return t._listenForPropChanges&&e.data&&t._data!==e.data&&(t._data=e.data,t.data=l.getData(e)),t._listenForPropChanges=!0,t}}]),(0,_createClass2.default)(l,[{key:"render",value:function(){var e=this.props,t=e.info,r=e.className,a=e.class,s=l.getData(this.props),p={className:(0,_classnames.default)("dnb-description-list",r,a)};return(0,_componentHelper.validateDOMAttributes)(this.props,p),_react.default.createElement("div",p,0<s.length&&_react.default.createElement("dl",{className:"dnb-description-list__dl typo-light"},s.map(function(e,t){var r=e.title,a=e.value;return _react.default.createElement(_react.Fragment,{key:"dl".concat(t)},_react.default.createElement("dt",{className:"dnb-description-list__dt"},r),_react.default.createElement("dd",{className:"dnb-description-list__dd"},a))})),t&&_react.default.createElement("p",{className:"dnb-description-list__info dnb-typo-book"},t))}}]),l}(_react.PureComponent);exports.default=DescriptionList,(0,_defineProperty2.default)(DescriptionList,"tagName","dnb-description-list"),(0,_defineProperty2.default)(DescriptionList,"defaultProps",defaultProps),DescriptionList.propTypes="production"!==process.env.NODE_ENV?propTypes:{};
//# sourceMappingURL=DescriptionList.js.map
