1/** 2 * FormValidation (https://formvalidation.io) 3 * The best validation library for JavaScript 4 * (c) 2013 - 2023 Nguyen Huu Phuoc <[email protected]> 5 * 6 * @license https://formvalidation.io/license 7 * @package @form-validation/plugin-auto-focus 8 * @version 2.4.0 9 */ 10 11import{Plugin as t}from"../core/index.min.js";import{FieldStatus as o}from"../plugin-field-status/index.min.js";var n=function(t,o){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,o){t.__proto__=o}||function(t,o){for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(t[n]=o[n])},n(t,o)};var e=function(t){function e(o){var n=t.call(this,o)||this;return n.opts=Object.assign({},{onPrefocus:function(){}},o),n.invalidFormHandler=n.onFormInvalid.bind(n),n}return function(t,o){if("function"!=typeof o&&null!==o)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");function e(){this.constructor=t}n(t,o),t.prototype=null===o?Object.create(o):(e.prototype=o.prototype,new e)}(e,t),e.prototype.install=function(){this.core.on("core.form.invalid",this.invalidFormHandler).registerPlugin(e.FIELD_STATUS_PLUGIN,new o)},e.prototype.uninstall=function(){this.core.off("core.form.invalid",this.invalidFormHandler).deregisterPlugin(e.FIELD_STATUS_PLUGIN)},e.prototype.onEnabled=function(){this.core.enablePlugin(e.FIELD_STATUS_PLUGIN)},e.prototype.onDisabled=function(){this.core.disablePlugin(e.FIELD_STATUS_PLUGIN)},e.prototype.onFormInvalid=function(){if(this.isEnabled){var t=this.core.getPlugin(e.FIELD_STATUS_PLUGIN).getStatuses(),o=Object.keys(this.core.getFields()).filter((function(o){return"Invalid"===t.get(o)}));if(o.length>0){var n=o[0],i=this.core.getElements(n);if(i.length>0){var r=i[0],s={firstElement:r,field:n};this.core.emit("plugins.autofocus.prefocus",s),this.opts.onPrefocus(s),r.focus()}}}},e.FIELD_STATUS_PLUGIN="___autoFocusFieldStatus",e}(t);export{e as AutoFocus};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.