1 |
- import{s as g,al as H,y as F,aG as G,aH as k,aB as M,cS as z,f as v,z as A,a1 as D}from"./index-DT8qTvyx.js";var B=function(l){g(e,l);function e(o){var r=l.call(this,o)||this;return r.toDispose=[],r.handleFocus=r.handleFocus.bind(r),r.handleBlur=r.handleBlur.bind(r),r.validateHook=r.validateHook.bind(r),r.state={isFocused:!1},r}return e.prototype.componentDidMount=function(){var o=this.props,r=o.addHook,t=o.name;t&&r&&this.toDispose.push(r(this.validateHook,"validate"))},e.prototype.componentDidUpdate=function(o){var r;H(["errorCode","delimiter"],o==null?void 0:o.validationConfig,(r=this.props)===null||r===void 0?void 0:r.validationConfig)&&this.validateHook()},e.prototype.componentWillUnmount=function(){this.toDispose.forEach(function(o){return o()}),this.toDispose=[]},e.prototype.getValidationConfig=function(){var o=this.props.validationConfig;return{errorMode:(o==null?void 0:o.errorMode)!=="partial"?"full":"partial",delimiter:o!=null&&o.delimiter&&typeof o.delimiter=="string"?o.delimiter:"; "}},e.prototype.validateHook=function(){var o,r=this.props,t=r.formStore,n=r.formItem,d=r.name,f=this.getValidationConfig().delimiter;if(d){var i=(o=t==null?void 0:t.inputGroupItems)===null||o===void 0?void 0:o[d];if(Array.isArray(i)){var m=i.map(function(s,c){if(s.errors.length<=0)return"";var h=s.label?"(".concat(c+1,")").concat(s.label):"(".concat(c+1,")");return"".concat(h,": ").concat(s.errors.join(f))}).filter(Boolean);n&&n.setError(m)}}},e.prototype.handleFocus=function(){this.setState({isFocused:!0})},e.prototype.handleBlur=function(){this.setState({isFocused:!1})},e.prototype.renderControl=function(o,r,t){var n=this.props,d=n.render,f=n.onChange;if(!o)return null;var i=o;return d("".concat(r),i,F({onChange:f},t))},e.prototype.validate=function(){var o=this.props.formItem,r=[];return o==null||o.subFormItems.forEach(function(t){t.errors.length&&r.push.apply(r,G([],k(t.errors),!1))}),r.length?r:""},e.prototype.render=function(){var o=this,r=this.props,t=r.body,n=r.controls,d=r.className;r.style,r.mode;var f=r.horizontal;r.formMode;var i=r.formHorizontal,m=r.data,s=r.classnames,c=r.static,h=r.disabled,b=r.mobileUI,C=this.getValidationConfig().errorMode,u=Array.isArray(n)?n:t;Array.isArray(u)||(u=[]),u=u.filter(function(a){if(a&&(a.hidden||a.visible===!1))return!1;var p=M(a||{},m);return!(p.hidden||p.visible===!1)});var I=f||(i?z(i,u.length):void 0);return v.createElement("div",{className:s("InputGroup","InputGroup-validation--".concat(C),d,{"is-focused":this.state.isFocused},{"is-mobile":b})},u.map(function(a,p){var _=~["icon","plain","tpl","button","submit","reset"].indexOf(a&&a.type),y=o.renderControl(a,p,{formHorizontal:I,formMode:"normal",inputOnly:!0,inputGroupControl:{name:o.props.name,path:o.props.$path,schema:o.props.$schema},key:p,static:c,disabled:h,onFocus:o.handleFocus,onBlur:o.handleBlur});return _?v.createElement("span",{key:p,className:s(a.addOnclassName,~["button","submit","reset"].indexOf(a&&a.type)?"InputGroup-btn":"InputGroup-addOn")},y):y}))},e.defaultProps={validationConfig:{errorMode:"full",delimiter:"; "}},e}(v.Component),E=function(l){g(e,l);function e(){return l!==null&&l.apply(this,arguments)||this}return e=A([D({type:"input-group",strictMode:!1})],e),e}(B);export{B as InputGroup,E as default};
|