|
1 | 1 | /*! |
2 | | - * Client Side Validations Simple Form JS (Default) - v0.4.0 (https://github.com/DavyJonesLocker/client_side_validations-simple_form) |
| 2 | + * Client Side Validations Simple Form JS (Default) - v0.5.0 (https://github.com/DavyJonesLocker/client_side_validations-simple_form) |
3 | 3 | * Copyright (c) 2024 Geremia Taglialatela, Brian Cardarella |
4 | 4 | * Licensed under MIT (https://opensource.org/licenses/mit-license.php) |
5 | 5 | */ |
|
10 | 10 | (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ClientSideValidations)); |
11 | 11 | })(this, (function (ClientSideValidations) { 'use strict'; |
12 | 12 |
|
13 | | - function _arrayLikeToArray(r, a) { |
14 | | - (null == a || a > r.length) && (a = r.length); |
15 | | - for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; |
16 | | - return n; |
17 | | - } |
18 | | - function _arrayWithoutHoles(r) { |
19 | | - if (Array.isArray(r)) return _arrayLikeToArray(r); |
20 | | - } |
21 | | - function _iterableToArray(r) { |
22 | | - if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); |
23 | | - } |
24 | | - function _nonIterableSpread() { |
25 | | - throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); |
26 | | - } |
27 | | - function _toConsumableArray(r) { |
28 | | - return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); |
29 | | - } |
30 | | - function _unsupportedIterableToArray(r, a) { |
31 | | - if (r) { |
32 | | - if ("string" == typeof r) return _arrayLikeToArray(r, a); |
33 | | - var t = {}.toString.call(r).slice(8, -1); |
34 | | - 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; |
35 | | - } |
36 | | - } |
37 | | - |
38 | | - var addClass = function addClass(element, customClass) { |
| 13 | + const addClass = (element, customClass) => { |
39 | 14 | if (customClass) { |
40 | | - var _element$classList; |
41 | | - (_element$classList = element.classList).add.apply(_element$classList, _toConsumableArray(customClass.split(' '))); |
| 15 | + element.classList.add(...customClass.split(' ')); |
42 | 16 | } |
43 | 17 | }; |
44 | | - var removeClass = function removeClass(element, customClass) { |
| 18 | + const removeClass = (element, customClass) => { |
45 | 19 | if (customClass) { |
46 | | - var _element$classList2; |
47 | | - (_element$classList2 = element.classList).remove.apply(_element$classList2, _toConsumableArray(customClass.split(' '))); |
| 20 | + element.classList.remove(...customClass.split(' ')); |
48 | 21 | } |
49 | 22 | }; |
50 | 23 |
|
51 | 24 | ClientSideValidations.formBuilders['SimpleForm::FormBuilder'] = { |
52 | | - add: function add($element, settings, message) { |
| 25 | + add: function ($element, settings, message) { |
53 | 26 | this.wrapper(settings.wrapper).add.call(this, $element[0], settings, message); |
54 | 27 | }, |
55 | | - remove: function remove($element, settings) { |
| 28 | + remove: function ($element, settings) { |
56 | 29 | this.wrapper(settings.wrapper).remove.call(this, $element[0], settings); |
57 | 30 | }, |
58 | | - wrapper: function wrapper(name) { |
| 31 | + wrapper: function (name) { |
59 | 32 | return this.wrappers[name] || this.wrappers.default; |
60 | 33 | }, |
61 | 34 | wrappers: { |
62 | 35 | default: { |
63 | | - add: function add(element, settings, message) { |
64 | | - var wrapperElement = element.closest("".concat(settings.wrapper_tag, ".").concat(settings.wrapper_class.replace(/ /g, '.'))); |
65 | | - var errorElement = wrapperElement.querySelector("".concat(settings.error_tag, ".").concat(settings.error_class.replace(/ /g, '.'))); |
| 36 | + add(element, settings, message) { |
| 37 | + const wrapperElement = element.closest("".concat(settings.wrapper_tag, ".").concat(settings.wrapper_class.replace(/ /g, '.'))); |
| 38 | + let errorElement = wrapperElement.querySelector("".concat(settings.error_tag, ".").concat(settings.error_class.replace(/ /g, '.'))); |
66 | 39 | if (!errorElement) { |
67 | 40 | errorElement = document.createElement(settings.error_tag); |
68 | 41 | addClass(errorElement, settings.error_class); |
|
72 | 45 | addClass(wrapperElement, settings.wrapper_error_class); |
73 | 46 | errorElement.textContent = message; |
74 | 47 | }, |
75 | | - remove: function remove(element, settings) { |
76 | | - var wrapperElement = element.closest("".concat(settings.wrapper_tag, ".").concat(settings.wrapper_class.replace(/ /g, '.'))); |
77 | | - var errorElement = wrapperElement.querySelector("".concat(settings.error_tag, ".").concat(settings.error_class.replace(/ /g, '.'))); |
| 48 | + remove(element, settings) { |
| 49 | + const wrapperElement = element.closest("".concat(settings.wrapper_tag, ".").concat(settings.wrapper_class.replace(/ /g, '.'))); |
| 50 | + const errorElement = wrapperElement.querySelector("".concat(settings.error_tag, ".").concat(settings.error_class.replace(/ /g, '.'))); |
78 | 51 | removeClass(wrapperElement, settings.wrapper_error_class); |
79 | 52 | if (errorElement) { |
80 | 53 | errorElement.remove(); |
|
0 commit comments