11/*!
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)
33 * Copyright (c) 2024 Geremia Taglialatela, Brian Cardarella
44 * Licensed under MIT (https://opensource.org/licenses/mit-license.php)
55 */
66
77import ClientSideValidations from '@client-side-validations/client-side-validations' ;
88
9- function _arrayLikeToArray ( r , a ) {
10- ( null == a || a > r . length ) && ( a = r . length ) ;
11- for ( var e = 0 , n = Array ( a ) ; e < a ; e ++ ) n [ e ] = r [ e ] ;
12- return n ;
13- }
14- function _arrayWithoutHoles ( r ) {
15- if ( Array . isArray ( r ) ) return _arrayLikeToArray ( r ) ;
16- }
17- function _iterableToArray ( r ) {
18- if ( "undefined" != typeof Symbol && null != r [ Symbol . iterator ] || null != r [ "@@iterator" ] ) return Array . from ( r ) ;
19- }
20- function _nonIterableSpread ( ) {
21- throw new TypeError ( "Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method." ) ;
22- }
23- function _toConsumableArray ( r ) {
24- return _arrayWithoutHoles ( r ) || _iterableToArray ( r ) || _unsupportedIterableToArray ( r ) || _nonIterableSpread ( ) ;
25- }
26- function _unsupportedIterableToArray ( r , a ) {
27- if ( r ) {
28- if ( "string" == typeof r ) return _arrayLikeToArray ( r , a ) ;
29- var t = { } . toString . call ( r ) . slice ( 8 , - 1 ) ;
30- return "Object" === t && r . constructor && ( t = r . constructor . name ) , "Map" === t || "Set" === t ? Array . from ( r ) : "Arguments" === t || / ^ (?: U i | I ) n t (?: 8 | 1 6 | 3 2 ) (?: C l a m p e d ) ? A r r a y $ / . test ( t ) ? _arrayLikeToArray ( r , a ) : void 0 ;
31- }
32- }
33-
34- var addClass = function addClass ( element , customClass ) {
9+ const addClass = ( element , customClass ) => {
3510 if ( customClass ) {
36- var _element$classList ;
37- ( _element$classList = element . classList ) . add . apply ( _element$classList , _toConsumableArray ( customClass . split ( ' ' ) ) ) ;
11+ element . classList . add ( ...customClass . split ( ' ' ) ) ;
3812 }
3913} ;
40- var removeClass = function removeClass ( element , customClass ) {
14+ const removeClass = ( element , customClass ) => {
4115 if ( customClass ) {
42- var _element$classList2 ;
43- ( _element$classList2 = element . classList ) . remove . apply ( _element$classList2 , _toConsumableArray ( customClass . split ( ' ' ) ) ) ;
16+ element . classList . remove ( ...customClass . split ( ' ' ) ) ;
4417 }
4518} ;
4619
4720ClientSideValidations . formBuilders [ 'SimpleForm::FormBuilder' ] = {
48- add : function add ( $element , settings , message ) {
21+ add : function ( $element , settings , message ) {
4922 this . wrapper ( settings . wrapper ) . add . call ( this , $element [ 0 ] , settings , message ) ;
5023 } ,
51- remove : function remove ( $element , settings ) {
24+ remove : function ( $element , settings ) {
5225 this . wrapper ( settings . wrapper ) . remove . call ( this , $element [ 0 ] , settings ) ;
5326 } ,
54- wrapper : function wrapper ( name ) {
27+ wrapper : function ( name ) {
5528 return this . wrappers [ name ] || this . wrappers . default ;
5629 } ,
5730 wrappers : {
5831 default : {
59- add : function add ( element , settings , message ) {
60- var wrapperElement = element . closest ( "" . concat ( settings . wrapper_tag , "." ) . concat ( settings . wrapper_class . replace ( / / g, '.' ) ) ) ;
61- var errorElement = wrapperElement . querySelector ( "" . concat ( settings . error_tag , "." ) . concat ( settings . error_class . replace ( / / g, '.' ) ) ) ;
32+ add ( element , settings , message ) {
33+ const wrapperElement = element . closest ( "" . concat ( settings . wrapper_tag , "." ) . concat ( settings . wrapper_class . replace ( / / g, '.' ) ) ) ;
34+ let errorElement = wrapperElement . querySelector ( "" . concat ( settings . error_tag , "." ) . concat ( settings . error_class . replace ( / / g, '.' ) ) ) ;
6235 if ( ! errorElement ) {
6336 errorElement = document . createElement ( settings . error_tag ) ;
6437 addClass ( errorElement , settings . error_class ) ;
@@ -68,9 +41,9 @@ ClientSideValidations.formBuilders['SimpleForm::FormBuilder'] = {
6841 addClass ( wrapperElement , settings . wrapper_error_class ) ;
6942 errorElement . textContent = message ;
7043 } ,
71- remove : function remove ( element , settings ) {
72- var wrapperElement = element . closest ( "" . concat ( settings . wrapper_tag , "." ) . concat ( settings . wrapper_class . replace ( / / g, '.' ) ) ) ;
73- var errorElement = wrapperElement . querySelector ( "" . concat ( settings . error_tag , "." ) . concat ( settings . error_class . replace ( / / g, '.' ) ) ) ;
44+ remove ( element , settings ) {
45+ const wrapperElement = element . closest ( "" . concat ( settings . wrapper_tag , "." ) . concat ( settings . wrapper_class . replace ( / / g, '.' ) ) ) ;
46+ const errorElement = wrapperElement . querySelector ( "" . concat ( settings . error_tag , "." ) . concat ( settings . error_class . replace ( / / g, '.' ) ) ) ;
7447 removeClass ( wrapperElement , settings . wrapper_error_class ) ;
7548 if ( errorElement ) {
7649 errorElement . remove ( ) ;
0 commit comments