"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 _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")),_classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")),_createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass")),_possibleConstructorReturn2=_interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")),_getPrototypeOf2=_interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")),_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"),_IconPrimary=_interopRequireDefault(require("../icon-primary/IconPrimary")),renderProps={render_content:null},propTypes={title:_propTypes.default.string,text:_propTypes.default.string,icon:_propTypes.default.oneOfType([_propTypes.default.string,_propTypes.default.func,_propTypes.default.node]),icon_size:_propTypes.default.string,status:_propTypes.default.oneOf(["error","info"]),hidden:_propTypes.default.oneOfType([_propTypes.default.string,_propTypes.default.bool]),text_id:_propTypes.default.string,class:_propTypes.default.string,animation:_propTypes.default.string,className:_propTypes.default.string,children:_propTypes.default.oneOfType([_propTypes.default.string,_propTypes.default.func,_propTypes.default.node]),render_content:_propTypes.default.func};exports.propTypes=propTypes;var defaultProps=(0,_objectSpread2.default)({title:null,text:null,icon:"exclamation",icon_size:"medium",status:"error",hidden:!1,text_id:null,class:null,animation:null,className:null,children:null},renderProps);exports.defaultProps=defaultProps;var FormStatus=function(e){function h(){return(0,_classCallCheck2.default)(this,h),(0,_possibleConstructorReturn2.default)(this,(0,_getPrototypeOf2.default)(h).apply(this,arguments))}return(0,_inherits2.default)(h,e),(0,_createClass2.default)(h,[{key:"correctStatus",value:function(e){switch(e){case"information":e="info"}return e}},{key:"render",value:function(){var e=this.props,t=e.title,r=e.status,n=e.hidden,a=e.className,s=e.animation,o=e.class,i=e.text_id,p=(e.text,e.icon),l=e.icon_size,u=(e.children,(0,_objectWithoutProperties2.default)(e,["title","status","hidden","className","animation","class","text_id","text","icon","icon_size","children"])),c=this.correctStatus(r),d=h.getIcon({status:c,icon:p,icon_size:l}),f=h.getContent(this.props),_="string"==typeof f&&0<f.length,m=(0,_objectSpread2.default)({hidden:n,className:(0,_classnames.default)("dnb-form-status","dnb-form-status--".concat(c),s?"dnb-form-status--".concat(s):null,_?"dnb-form-status--has-content":null,a,o),title:t},u),y={className:"dnb-form-status--text",id:i};return n?m["aria-hidden"]=n:_&&(m["aria-live"]="assertive"),(0,_componentHelper.validateDOMAttributes)(this.props,m),(0,_componentHelper.validateDOMAttributes)(null,y),_react.default.createElement("span",m,_react.default.createElement("span",{className:"dnb-form-status__shell"},d,_react.default.createElement("span",y,f)))}}],[{key:"enableWebComponent",value:function(){(0,_componentHelper.registerElement)(h.tagName,h,defaultProps)}},{key:"getContent",value:function(e){return e.text?e.text:("function"==typeof e.render_content&&e.render_content(e),(0,_componentHelper.processChildren)(e))}},{key:"getIcon",value:function(e){var t=e.status,r=e.icon,n=e.icon_size;if("string"==typeof r){var a=r;switch(t){case"info":case"information":a="information";break;case"error":default:a="exclamation"}r=_react.default.createElement(_IconPrimary.default,{"aria-hidden":!0,icon:a,size:n})}return r}}]),h}(_react.PureComponent);exports.default=FormStatus,(0,_defineProperty2.default)(FormStatus,"tagName","dnb-form-status"),(0,_defineProperty2.default)(FormStatus,"defaultProps",defaultProps),FormStatus.propTypes="production"!==process.env.NODE_ENV?propTypes:{};
//# sourceMappingURL=FormStatus.js.map
