"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"),_Context=_interopRequireDefault(require("../../shared/Context")),renderProps={render_content:null},propTypes={for_id:_propTypes.default.string,title:_propTypes.default.string,text:_propTypes.default.string,id:_propTypes.default.string,class:_propTypes.default.string,disabled:_propTypes.default.oneOfType([_propTypes.default.string,_propTypes.default.bool]),direction:_propTypes.default.oneOf(["vertical","horizontal"]),vertical:_propTypes.default.oneOfType([_propTypes.default.string,_propTypes.default.bool]),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)({for_id:null,title:null,text:null,id:null,class:null,disabled:null,direction:null,vertical:null,className:null,children:null},renderProps);exports.defaultProps=defaultProps;var FormLabel=function(e){function f(){return(0,_classCallCheck2.default)(this,f),(0,_possibleConstructorReturn2.default)(this,(0,_getPrototypeOf2.default)(f).apply(this,arguments))}return(0,_inherits2.default)(f,e),(0,_createClass2.default)(f,[{key:"render",value:function(){var e=this.context.formRow?(0,_componentHelper.extendPropsWithContext)(this.props,this.context.formRow):this.props,r=e.for_id,t=e.title,l=e.className,o=e.id,p=e.disabled,n=e.direction,i=e.vertical,a=e.class,s=(e.text,(0,_objectWithoutProperties2.default)(e,["for_id","title","className","id","disabled","direction","vertical","class","text"])),u=f.getContent(this.props),d=(0,_objectSpread2.default)({className:(0,_classnames.default)("dnb-form-label",((0,_componentHelper.isTrue)(i)||n)&&"dnb-form-label--".concat((0,_componentHelper.isTrue)(i)?"vertical":n),l,a),htmlFor:r,id:o,title:t,disabled:(0,_componentHelper.isTrue)(p)},s);return(0,_componentHelper.validateDOMAttributes)(this.props,d),_react.default.createElement("label",d,u)}}],[{key:"enableWebComponent",value:function(){(0,_componentHelper.registerElement)(f.tagName,f,defaultProps)}},{key:"getContent",value:function(e){return e.text?e.text:("function"==typeof e.render_content&&e.render_content(e),(0,_componentHelper.processChildren)(e))}}]),f}(_react.PureComponent);exports.default=FormLabel,(0,_defineProperty2.default)(FormLabel,"tagName","dnb-form-label"),(0,_defineProperty2.default)(FormLabel,"defaultProps",defaultProps),(0,_defineProperty2.default)(FormLabel,"contextType",_Context.default),FormLabel.propTypes="production"!==process.env.NODE_ENV?propTypes:{};
//# sourceMappingURL=FormLabel.js.map
