diff --git a/CHANGELOG.md b/CHANGELOG.md index aac8bf5..4ca4612 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,10 @@ # Changelog -## main / unreleased +## 17.0.0 / unreleased +* [FEATURE] Drop Internet Explorer and other older browsers support * [ENHANCEMENT] Test against Ruby 3.3 -* [ENHANCEMENT] Update QUnit to 2.21.0 +* [ENHANCEMENT] Update QUnit to 2.23.0 ## 16.0.0 / 2023-09-02 diff --git a/dist/simple-form.bootstrap4.esm.js b/dist/simple-form.bootstrap4.esm.js index 4a904d9..d3d0a6d 100644 --- a/dist/simple-form.bootstrap4.esm.js +++ b/dist/simple-form.bootstrap4.esm.js @@ -1,66 +1,39 @@ /*! - * Client Side Validations Simple Form JS (Default) - v0.4.0 (https://github.com/DavyJonesLocker/client_side_validations-simple_form) + * Client Side Validations Simple Form JS (Default) - v0.5.0 (https://github.com/DavyJonesLocker/client_side_validations-simple_form) * Copyright (c) 2024 Geremia Taglialatela, Brian Cardarella * Licensed under MIT (https://opensource.org/licenses/mit-license.php) */ import ClientSideValidations from '@client-side-validations/client-side-validations'; -function _arrayLikeToArray(r, a) { - (null == a || a > r.length) && (a = r.length); - for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; - return n; -} -function _arrayWithoutHoles(r) { - if (Array.isArray(r)) return _arrayLikeToArray(r); -} -function _iterableToArray(r) { - if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); -} -function _nonIterableSpread() { - throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); -} -function _toConsumableArray(r) { - return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); -} -function _unsupportedIterableToArray(r, a) { - if (r) { - if ("string" == typeof r) return _arrayLikeToArray(r, a); - var t = {}.toString.call(r).slice(8, -1); - return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; - } -} - -var addClass = function addClass(element, customClass) { +const addClass = (element, customClass) => { if (customClass) { - var _element$classList; - (_element$classList = element.classList).add.apply(_element$classList, _toConsumableArray(customClass.split(' '))); + element.classList.add(...customClass.split(' ')); } }; -var removeClass = function removeClass(element, customClass) { +const removeClass = (element, customClass) => { if (customClass) { - var _element$classList2; - (_element$classList2 = element.classList).remove.apply(_element$classList2, _toConsumableArray(customClass.split(' '))); + element.classList.remove(...customClass.split(' ')); } }; ClientSideValidations.formBuilders['SimpleForm::FormBuilder'] = { - add: function add($element, settings, message) { + add: function ($element, settings, message) { this.wrapper(settings.wrapper).add.call(this, $element[0], settings, message); }, - remove: function remove($element, settings) { + remove: function ($element, settings) { this.wrapper(settings.wrapper).remove.call(this, $element[0], settings); }, - wrapper: function wrapper(name) { + wrapper: function (name) { return this.wrappers[name] || this.wrappers.default; }, wrappers: { default: { - add: function add(element, settings, message) { - var wrapperElement = element.parentElement; - var errorElement = wrapperElement.querySelector("".concat(settings.error_tag, ".invalid-feedback")); + add(element, settings, message) { + const wrapperElement = element.parentElement; + let errorElement = wrapperElement.querySelector("".concat(settings.error_tag, ".invalid-feedback")); if (!errorElement) { - var formTextElement = wrapperElement.querySelector('.form-text'); + const formTextElement = wrapperElement.querySelector('.form-text'); errorElement = document.createElement(settings.error_tag); addClass(errorElement, 'invalid-feedback'); errorElement.textContent = message; @@ -74,9 +47,9 @@ ClientSideValidations.formBuilders['SimpleForm::FormBuilder'] = { addClass(element, 'is-invalid'); errorElement.textContent = message; }, - remove: function remove(element, settings) { - var wrapperElement = element.parentElement; - var errorElement = wrapperElement.querySelector("".concat(settings.error_tag, ".invalid-feedback")); + remove(element, settings) { + const wrapperElement = element.parentElement; + const errorElement = wrapperElement.querySelector("".concat(settings.error_tag, ".invalid-feedback")); removeClass(wrapperElement, settings.wrapper_error_class); removeClass(element, 'is-invalid'); if (errorElement) { diff --git a/dist/simple-form.bootstrap4.js b/dist/simple-form.bootstrap4.js index ba9349a..9c14313 100644 --- a/dist/simple-form.bootstrap4.js +++ b/dist/simple-form.bootstrap4.js @@ -1,5 +1,5 @@ /*! - * Client Side Validations Simple Form JS (Bootstrap 4+) - v0.4.0 (https://github.com/DavyJonesLocker/client_side_validations-simple_form) + * Client Side Validations Simple Form JS (Bootstrap 4+) - v0.5.0 (https://github.com/DavyJonesLocker/client_side_validations-simple_form) * Copyright (c) 2024 Geremia Taglialatela, Brian Cardarella * Licensed under MIT (https://opensource.org/licenses/mit-license.php) */ @@ -10,61 +10,34 @@ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ClientSideValidations)); })(this, (function (ClientSideValidations) { 'use strict'; - function _arrayLikeToArray(r, a) { - (null == a || a > r.length) && (a = r.length); - for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; - return n; - } - function _arrayWithoutHoles(r) { - if (Array.isArray(r)) return _arrayLikeToArray(r); - } - function _iterableToArray(r) { - if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); - } - function _nonIterableSpread() { - throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); - } - function _toConsumableArray(r) { - return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); - } - function _unsupportedIterableToArray(r, a) { - if (r) { - if ("string" == typeof r) return _arrayLikeToArray(r, a); - var t = {}.toString.call(r).slice(8, -1); - return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; - } - } - - var addClass = function addClass(element, customClass) { + const addClass = (element, customClass) => { if (customClass) { - var _element$classList; - (_element$classList = element.classList).add.apply(_element$classList, _toConsumableArray(customClass.split(' '))); + element.classList.add(...customClass.split(' ')); } }; - var removeClass = function removeClass(element, customClass) { + const removeClass = (element, customClass) => { if (customClass) { - var _element$classList2; - (_element$classList2 = element.classList).remove.apply(_element$classList2, _toConsumableArray(customClass.split(' '))); + element.classList.remove(...customClass.split(' ')); } }; ClientSideValidations.formBuilders['SimpleForm::FormBuilder'] = { - add: function add($element, settings, message) { + add: function ($element, settings, message) { this.wrapper(settings.wrapper).add.call(this, $element[0], settings, message); }, - remove: function remove($element, settings) { + remove: function ($element, settings) { this.wrapper(settings.wrapper).remove.call(this, $element[0], settings); }, - wrapper: function wrapper(name) { + wrapper: function (name) { return this.wrappers[name] || this.wrappers.default; }, wrappers: { default: { - add: function add(element, settings, message) { - var wrapperElement = element.parentElement; - var errorElement = wrapperElement.querySelector("".concat(settings.error_tag, ".invalid-feedback")); + add(element, settings, message) { + const wrapperElement = element.parentElement; + let errorElement = wrapperElement.querySelector("".concat(settings.error_tag, ".invalid-feedback")); if (!errorElement) { - var formTextElement = wrapperElement.querySelector('.form-text'); + const formTextElement = wrapperElement.querySelector('.form-text'); errorElement = document.createElement(settings.error_tag); addClass(errorElement, 'invalid-feedback'); errorElement.textContent = message; @@ -78,9 +51,9 @@ addClass(element, 'is-invalid'); errorElement.textContent = message; }, - remove: function remove(element, settings) { - var wrapperElement = element.parentElement; - var errorElement = wrapperElement.querySelector("".concat(settings.error_tag, ".invalid-feedback")); + remove(element, settings) { + const wrapperElement = element.parentElement; + const errorElement = wrapperElement.querySelector("".concat(settings.error_tag, ".invalid-feedback")); removeClass(wrapperElement, settings.wrapper_error_class); removeClass(element, 'is-invalid'); if (errorElement) { diff --git a/dist/simple-form.esm.js b/dist/simple-form.esm.js index d2eaf4d..21a0e50 100644 --- a/dist/simple-form.esm.js +++ b/dist/simple-form.esm.js @@ -1,64 +1,37 @@ /*! - * Client Side Validations Simple Form JS (Default) - v0.4.0 (https://github.com/DavyJonesLocker/client_side_validations-simple_form) + * Client Side Validations Simple Form JS (Default) - v0.5.0 (https://github.com/DavyJonesLocker/client_side_validations-simple_form) * Copyright (c) 2024 Geremia Taglialatela, Brian Cardarella * Licensed under MIT (https://opensource.org/licenses/mit-license.php) */ import ClientSideValidations from '@client-side-validations/client-side-validations'; -function _arrayLikeToArray(r, a) { - (null == a || a > r.length) && (a = r.length); - for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; - return n; -} -function _arrayWithoutHoles(r) { - if (Array.isArray(r)) return _arrayLikeToArray(r); -} -function _iterableToArray(r) { - if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); -} -function _nonIterableSpread() { - throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); -} -function _toConsumableArray(r) { - return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); -} -function _unsupportedIterableToArray(r, a) { - if (r) { - if ("string" == typeof r) return _arrayLikeToArray(r, a); - var t = {}.toString.call(r).slice(8, -1); - return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; - } -} - -var addClass = function addClass(element, customClass) { +const addClass = (element, customClass) => { if (customClass) { - var _element$classList; - (_element$classList = element.classList).add.apply(_element$classList, _toConsumableArray(customClass.split(' '))); + element.classList.add(...customClass.split(' ')); } }; -var removeClass = function removeClass(element, customClass) { +const removeClass = (element, customClass) => { if (customClass) { - var _element$classList2; - (_element$classList2 = element.classList).remove.apply(_element$classList2, _toConsumableArray(customClass.split(' '))); + element.classList.remove(...customClass.split(' ')); } }; ClientSideValidations.formBuilders['SimpleForm::FormBuilder'] = { - add: function add($element, settings, message) { + add: function ($element, settings, message) { this.wrapper(settings.wrapper).add.call(this, $element[0], settings, message); }, - remove: function remove($element, settings) { + remove: function ($element, settings) { this.wrapper(settings.wrapper).remove.call(this, $element[0], settings); }, - wrapper: function wrapper(name) { + wrapper: function (name) { return this.wrappers[name] || this.wrappers.default; }, wrappers: { default: { - add: function add(element, settings, message) { - var wrapperElement = element.closest("".concat(settings.wrapper_tag, ".").concat(settings.wrapper_class.replace(/ /g, '.'))); - var errorElement = wrapperElement.querySelector("".concat(settings.error_tag, ".").concat(settings.error_class.replace(/ /g, '.'))); + add(element, settings, message) { + const wrapperElement = element.closest("".concat(settings.wrapper_tag, ".").concat(settings.wrapper_class.replace(/ /g, '.'))); + let errorElement = wrapperElement.querySelector("".concat(settings.error_tag, ".").concat(settings.error_class.replace(/ /g, '.'))); if (!errorElement) { errorElement = document.createElement(settings.error_tag); addClass(errorElement, settings.error_class); @@ -68,9 +41,9 @@ ClientSideValidations.formBuilders['SimpleForm::FormBuilder'] = { addClass(wrapperElement, settings.wrapper_error_class); errorElement.textContent = message; }, - remove: function remove(element, settings) { - var wrapperElement = element.closest("".concat(settings.wrapper_tag, ".").concat(settings.wrapper_class.replace(/ /g, '.'))); - var errorElement = wrapperElement.querySelector("".concat(settings.error_tag, ".").concat(settings.error_class.replace(/ /g, '.'))); + remove(element, settings) { + const wrapperElement = element.closest("".concat(settings.wrapper_tag, ".").concat(settings.wrapper_class.replace(/ /g, '.'))); + const errorElement = wrapperElement.querySelector("".concat(settings.error_tag, ".").concat(settings.error_class.replace(/ /g, '.'))); removeClass(wrapperElement, settings.wrapper_error_class); if (errorElement) { errorElement.remove(); diff --git a/dist/simple-form.js b/dist/simple-form.js index a845d79..1591ad4 100644 --- a/dist/simple-form.js +++ b/dist/simple-form.js @@ -1,5 +1,5 @@ /*! - * Client Side Validations Simple Form JS (Default) - v0.4.0 (https://github.com/DavyJonesLocker/client_side_validations-simple_form) + * Client Side Validations Simple Form JS (Default) - v0.5.0 (https://github.com/DavyJonesLocker/client_side_validations-simple_form) * Copyright (c) 2024 Geremia Taglialatela, Brian Cardarella * Licensed under MIT (https://opensource.org/licenses/mit-license.php) */ @@ -10,59 +10,32 @@ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ClientSideValidations)); })(this, (function (ClientSideValidations) { 'use strict'; - function _arrayLikeToArray(r, a) { - (null == a || a > r.length) && (a = r.length); - for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; - return n; - } - function _arrayWithoutHoles(r) { - if (Array.isArray(r)) return _arrayLikeToArray(r); - } - function _iterableToArray(r) { - if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); - } - function _nonIterableSpread() { - throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); - } - function _toConsumableArray(r) { - return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); - } - function _unsupportedIterableToArray(r, a) { - if (r) { - if ("string" == typeof r) return _arrayLikeToArray(r, a); - var t = {}.toString.call(r).slice(8, -1); - return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; - } - } - - var addClass = function addClass(element, customClass) { + const addClass = (element, customClass) => { if (customClass) { - var _element$classList; - (_element$classList = element.classList).add.apply(_element$classList, _toConsumableArray(customClass.split(' '))); + element.classList.add(...customClass.split(' ')); } }; - var removeClass = function removeClass(element, customClass) { + const removeClass = (element, customClass) => { if (customClass) { - var _element$classList2; - (_element$classList2 = element.classList).remove.apply(_element$classList2, _toConsumableArray(customClass.split(' '))); + element.classList.remove(...customClass.split(' ')); } }; ClientSideValidations.formBuilders['SimpleForm::FormBuilder'] = { - add: function add($element, settings, message) { + add: function ($element, settings, message) { this.wrapper(settings.wrapper).add.call(this, $element[0], settings, message); }, - remove: function remove($element, settings) { + remove: function ($element, settings) { this.wrapper(settings.wrapper).remove.call(this, $element[0], settings); }, - wrapper: function wrapper(name) { + wrapper: function (name) { return this.wrappers[name] || this.wrappers.default; }, wrappers: { default: { - add: function add(element, settings, message) { - var wrapperElement = element.closest("".concat(settings.wrapper_tag, ".").concat(settings.wrapper_class.replace(/ /g, '.'))); - var errorElement = wrapperElement.querySelector("".concat(settings.error_tag, ".").concat(settings.error_class.replace(/ /g, '.'))); + add(element, settings, message) { + const wrapperElement = element.closest("".concat(settings.wrapper_tag, ".").concat(settings.wrapper_class.replace(/ /g, '.'))); + let errorElement = wrapperElement.querySelector("".concat(settings.error_tag, ".").concat(settings.error_class.replace(/ /g, '.'))); if (!errorElement) { errorElement = document.createElement(settings.error_tag); addClass(errorElement, settings.error_class); @@ -72,9 +45,9 @@ addClass(wrapperElement, settings.wrapper_error_class); errorElement.textContent = message; }, - remove: function remove(element, settings) { - var wrapperElement = element.closest("".concat(settings.wrapper_tag, ".").concat(settings.wrapper_class.replace(/ /g, '.'))); - var errorElement = wrapperElement.querySelector("".concat(settings.error_tag, ".").concat(settings.error_class.replace(/ /g, '.'))); + remove(element, settings) { + const wrapperElement = element.closest("".concat(settings.wrapper_tag, ".").concat(settings.wrapper_class.replace(/ /g, '.'))); + const errorElement = wrapperElement.querySelector("".concat(settings.error_tag, ".").concat(settings.error_class.replace(/ /g, '.'))); removeClass(wrapperElement, settings.wrapper_error_class); if (errorElement) { errorElement.remove(); diff --git a/eslint.config.mjs b/eslint.config.mjs index 2bd9b28..0a0c508 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -1,13 +1,15 @@ import neostandard from 'neostandard' +import compat from 'eslint-plugin-compat' export default [ { ignores: [ - 'coverage/**/*.js', - 'dist/**/*.js', - 'test/**/*.js', - 'vendor/**/*.js', + 'coverage/*', + 'dist/*', + 'test/*', + 'vendor/*', ] }, + compat.configs['flat/recommended'], ...neostandard() ] diff --git a/lib/client_side_validations/simple_form/version.rb b/lib/client_side_validations/simple_form/version.rb index 914d764..dd3a8c9 100644 --- a/lib/client_side_validations/simple_form/version.rb +++ b/lib/client_side_validations/simple_form/version.rb @@ -2,6 +2,6 @@ module ClientSideValidations module SimpleForm - VERSION = '16.1.0' + VERSION = '17.0.0' end end diff --git a/package.json b/package.json index 7da9286..178c90b 100644 --- a/package.json +++ b/package.json @@ -29,9 +29,10 @@ "@rollup/plugin-node-resolve": "^16.0.0", "chrome-launcher": "^1.1.2", "eslint": "^9.17.0", + "eslint-plugin-compat": "^6.0.2", "neostandard": "^0.12.0", - "puppeteer-core": "^23.10.4", - "rollup": "^4.28.1", + "puppeteer-core": "^23.11.1", + "rollup": "^4.29.1", "rollup-plugin-copy": "^3.5.0" }, "peerDependencies": { @@ -45,17 +46,14 @@ }, "packageManager": "pnpm@^9.12.1", "browserslist": [ - ">= 1%", - "last 1 major version", + ">= 0.5%", + "last 2 major versions", "not dead", - "Chrome >= 45", - "Firefox >= 38", - "Edge >= 12", - "Explorer >= 10", - "iOS >= 9", - "Safari >= 9", - "Android >= 4.4", - "Opera >= 30" + "Chrome >= 60", + "Firefox >= 60", + "Firefox ESR", + "iOS >= 12", + "Safari >= 12" ], "files": [ "dist", @@ -69,7 +67,7 @@ "/vendor/" ] }, - "version": "0.4.0", + "version": "0.5.0", "directories": { "lib": "lib", "test": "test" diff --git a/test/javascript/server.rb b/test/javascript/server.rb index 6a09df6..7937e0c 100644 --- a/test/javascript/server.rb +++ b/test/javascript/server.rb @@ -34,7 +34,7 @@ def call(env) use AssetPath, urls: ['/vendor/assets/javascripts'], root: rails_validations_path.full_gem_path DEFAULT_JQUERY_VERSION = '3.7.1.slim' -QUNIT_VERSION = '2.22.0' +QUNIT_VERSION = '2.23.0' helpers do def jquery_version diff --git a/vendor/assets/javascripts/rails.validations.simple_form.bootstrap4.js b/vendor/assets/javascripts/rails.validations.simple_form.bootstrap4.js index ba9349a..9c14313 100644 --- a/vendor/assets/javascripts/rails.validations.simple_form.bootstrap4.js +++ b/vendor/assets/javascripts/rails.validations.simple_form.bootstrap4.js @@ -1,5 +1,5 @@ /*! - * Client Side Validations Simple Form JS (Bootstrap 4+) - v0.4.0 (https://github.com/DavyJonesLocker/client_side_validations-simple_form) + * Client Side Validations Simple Form JS (Bootstrap 4+) - v0.5.0 (https://github.com/DavyJonesLocker/client_side_validations-simple_form) * Copyright (c) 2024 Geremia Taglialatela, Brian Cardarella * Licensed under MIT (https://opensource.org/licenses/mit-license.php) */ @@ -10,61 +10,34 @@ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ClientSideValidations)); })(this, (function (ClientSideValidations) { 'use strict'; - function _arrayLikeToArray(r, a) { - (null == a || a > r.length) && (a = r.length); - for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; - return n; - } - function _arrayWithoutHoles(r) { - if (Array.isArray(r)) return _arrayLikeToArray(r); - } - function _iterableToArray(r) { - if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); - } - function _nonIterableSpread() { - throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); - } - function _toConsumableArray(r) { - return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); - } - function _unsupportedIterableToArray(r, a) { - if (r) { - if ("string" == typeof r) return _arrayLikeToArray(r, a); - var t = {}.toString.call(r).slice(8, -1); - return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; - } - } - - var addClass = function addClass(element, customClass) { + const addClass = (element, customClass) => { if (customClass) { - var _element$classList; - (_element$classList = element.classList).add.apply(_element$classList, _toConsumableArray(customClass.split(' '))); + element.classList.add(...customClass.split(' ')); } }; - var removeClass = function removeClass(element, customClass) { + const removeClass = (element, customClass) => { if (customClass) { - var _element$classList2; - (_element$classList2 = element.classList).remove.apply(_element$classList2, _toConsumableArray(customClass.split(' '))); + element.classList.remove(...customClass.split(' ')); } }; ClientSideValidations.formBuilders['SimpleForm::FormBuilder'] = { - add: function add($element, settings, message) { + add: function ($element, settings, message) { this.wrapper(settings.wrapper).add.call(this, $element[0], settings, message); }, - remove: function remove($element, settings) { + remove: function ($element, settings) { this.wrapper(settings.wrapper).remove.call(this, $element[0], settings); }, - wrapper: function wrapper(name) { + wrapper: function (name) { return this.wrappers[name] || this.wrappers.default; }, wrappers: { default: { - add: function add(element, settings, message) { - var wrapperElement = element.parentElement; - var errorElement = wrapperElement.querySelector("".concat(settings.error_tag, ".invalid-feedback")); + add(element, settings, message) { + const wrapperElement = element.parentElement; + let errorElement = wrapperElement.querySelector("".concat(settings.error_tag, ".invalid-feedback")); if (!errorElement) { - var formTextElement = wrapperElement.querySelector('.form-text'); + const formTextElement = wrapperElement.querySelector('.form-text'); errorElement = document.createElement(settings.error_tag); addClass(errorElement, 'invalid-feedback'); errorElement.textContent = message; @@ -78,9 +51,9 @@ addClass(element, 'is-invalid'); errorElement.textContent = message; }, - remove: function remove(element, settings) { - var wrapperElement = element.parentElement; - var errorElement = wrapperElement.querySelector("".concat(settings.error_tag, ".invalid-feedback")); + remove(element, settings) { + const wrapperElement = element.parentElement; + const errorElement = wrapperElement.querySelector("".concat(settings.error_tag, ".invalid-feedback")); removeClass(wrapperElement, settings.wrapper_error_class); removeClass(element, 'is-invalid'); if (errorElement) { diff --git a/vendor/assets/javascripts/rails.validations.simple_form.js b/vendor/assets/javascripts/rails.validations.simple_form.js index a845d79..1591ad4 100644 --- a/vendor/assets/javascripts/rails.validations.simple_form.js +++ b/vendor/assets/javascripts/rails.validations.simple_form.js @@ -1,5 +1,5 @@ /*! - * Client Side Validations Simple Form JS (Default) - v0.4.0 (https://github.com/DavyJonesLocker/client_side_validations-simple_form) + * Client Side Validations Simple Form JS (Default) - v0.5.0 (https://github.com/DavyJonesLocker/client_side_validations-simple_form) * Copyright (c) 2024 Geremia Taglialatela, Brian Cardarella * Licensed under MIT (https://opensource.org/licenses/mit-license.php) */ @@ -10,59 +10,32 @@ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ClientSideValidations)); })(this, (function (ClientSideValidations) { 'use strict'; - function _arrayLikeToArray(r, a) { - (null == a || a > r.length) && (a = r.length); - for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; - return n; - } - function _arrayWithoutHoles(r) { - if (Array.isArray(r)) return _arrayLikeToArray(r); - } - function _iterableToArray(r) { - if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); - } - function _nonIterableSpread() { - throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); - } - function _toConsumableArray(r) { - return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); - } - function _unsupportedIterableToArray(r, a) { - if (r) { - if ("string" == typeof r) return _arrayLikeToArray(r, a); - var t = {}.toString.call(r).slice(8, -1); - return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; - } - } - - var addClass = function addClass(element, customClass) { + const addClass = (element, customClass) => { if (customClass) { - var _element$classList; - (_element$classList = element.classList).add.apply(_element$classList, _toConsumableArray(customClass.split(' '))); + element.classList.add(...customClass.split(' ')); } }; - var removeClass = function removeClass(element, customClass) { + const removeClass = (element, customClass) => { if (customClass) { - var _element$classList2; - (_element$classList2 = element.classList).remove.apply(_element$classList2, _toConsumableArray(customClass.split(' '))); + element.classList.remove(...customClass.split(' ')); } }; ClientSideValidations.formBuilders['SimpleForm::FormBuilder'] = { - add: function add($element, settings, message) { + add: function ($element, settings, message) { this.wrapper(settings.wrapper).add.call(this, $element[0], settings, message); }, - remove: function remove($element, settings) { + remove: function ($element, settings) { this.wrapper(settings.wrapper).remove.call(this, $element[0], settings); }, - wrapper: function wrapper(name) { + wrapper: function (name) { return this.wrappers[name] || this.wrappers.default; }, wrappers: { default: { - add: function add(element, settings, message) { - var wrapperElement = element.closest("".concat(settings.wrapper_tag, ".").concat(settings.wrapper_class.replace(/ /g, '.'))); - var errorElement = wrapperElement.querySelector("".concat(settings.error_tag, ".").concat(settings.error_class.replace(/ /g, '.'))); + add(element, settings, message) { + const wrapperElement = element.closest("".concat(settings.wrapper_tag, ".").concat(settings.wrapper_class.replace(/ /g, '.'))); + let errorElement = wrapperElement.querySelector("".concat(settings.error_tag, ".").concat(settings.error_class.replace(/ /g, '.'))); if (!errorElement) { errorElement = document.createElement(settings.error_tag); addClass(errorElement, settings.error_class); @@ -72,9 +45,9 @@ addClass(wrapperElement, settings.wrapper_error_class); errorElement.textContent = message; }, - remove: function remove(element, settings) { - var wrapperElement = element.closest("".concat(settings.wrapper_tag, ".").concat(settings.wrapper_class.replace(/ /g, '.'))); - var errorElement = wrapperElement.querySelector("".concat(settings.error_tag, ".").concat(settings.error_class.replace(/ /g, '.'))); + remove(element, settings) { + const wrapperElement = element.closest("".concat(settings.wrapper_tag, ".").concat(settings.wrapper_class.replace(/ /g, '.'))); + const errorElement = wrapperElement.querySelector("".concat(settings.error_tag, ".").concat(settings.error_class.replace(/ /g, '.'))); removeClass(wrapperElement, settings.wrapper_error_class); if (errorElement) { errorElement.remove();