"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 _extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends")),_objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")),_classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")),_possibleConstructorReturn2=_interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")),_getPrototypeOf2=_interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")),_assertThisInitialized2=_interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized")),_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"),_Context=_interopRequireDefault(require("../../shared/Context")),renderProps={render_content:null},propTypes={id:_propTypes.default.string,element:_propTypes.default.string,no_form:_propTypes.default.oneOfType([_propTypes.default.string,_propTypes.default.bool]),prevent_submit:_propTypes.default.oneOfType([_propTypes.default.string,_propTypes.default.bool]),size:_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]),disabled:_propTypes.default.oneOfType([_propTypes.default.string,_propTypes.default.bool]),class:_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)({id:null,element:"form",no_form:!1,prevent_submit:!1,size:null,direction:"horizontal",vertical:null,disabled:null,class:null,className:null,children:null},renderProps);exports.defaultProps=defaultProps;var FormSet=function(e){function _(e){var t;return(0,_classCallCheck2.default)(this,_),t=(0,_possibleConstructorReturn2.default)(this,(0,_getPrototypeOf2.default)(_).call(this,e)),(0,_defineProperty2.default)((0,_assertThisInitialized2.default)(t),"onSubmitHandler",function(e){var r=t.props.prevent_submit;(0,_componentHelper.isTrue)(r)&&e.preventDefault(),(0,_componentHelper.dispatchCustomElementEvent)((0,_assertThisInitialized2.default)(t),"on_submit",{event:e})}),t._id=e.id||"dnb-form-set-".concat(Math.round(999*Math.random())),t}return(0,_inherits2.default)(_,e),(0,_createClass2.default)(_,null,[{key:"enableWebComponent",value:function(){(0,_componentHelper.registerElement)(_.tagName,_,defaultProps)}},{key:"getContent",value:function(e){return"function"==typeof e.render_content&&e.render_content(e),(0,_componentHelper.processChildren)(e)}}]),(0,_createClass2.default)(_,[{key:"render",value:function(){var e=this.props,r=e.element,t=e.size,p=e.direction,o=e.vertical,n=e.no_form,l=(e.prevent_submit,e.disabled),i=(e.id,e.className),s=e.class,a=(0,_objectWithoutProperties2.default)(e,["element","size","direction","vertical","no_form","prevent_submit","disabled","id","className","class"]),u=_.getContent(this.props),d=(0,_objectSpread2.default)({className:(0,_classnames.default)("dnb-form-set",i,s)},a);(0,_componentHelper.isTrue)(n)||(d.onSubmit=this.onSubmitHandler),(0,_componentHelper.validateDOMAttributes)(this.props,d);var f=(0,_componentHelper.extend)(this.context,{formRow:{size:t,direction:p,vertical:o,disabled:l}});return _react.default.createElement(_Context.default.Provider,{value:f},_react.default.createElement(Element,(0,_extends2.default)({is:(0,_componentHelper.isTrue)(n)?"div":r},d),u))}}]),_}(_react.PureComponent);exports.default=FormSet,(0,_defineProperty2.default)(FormSet,"tagName","dnb-form-set"),(0,_defineProperty2.default)(FormSet,"defaultProps",defaultProps),(0,_defineProperty2.default)(FormSet,"contextType",_Context.default),FormSet.propTypes="production"!==process.env.NODE_ENV?propTypes:{};var Element=function(e){var r=e.is,t=e.children,p=(0,_objectWithoutProperties2.default)(e,["is","children"]);return _react.default.createElement(r,p,t)};Element.propTypes="production"!==process.env.NODE_ENV?{is:_propTypes.default.string.isRequired,children:_propTypes.default.node.isRequired}:{};
//# sourceMappingURL=FormSet.js.map
