@ptcwebops/ptcw-design 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/icon-asset.cjs.entry.js +64 -0
- package/dist/cjs/{index-ac192914.js → index-0b899fc6.js} +158 -87
- package/dist/cjs/list-item.cjs.entry.js +2 -2
- package/dist/cjs/loader.cjs.js +3 -3
- package/dist/cjs/lottie-player.cjs.entry.js +2 -2
- package/dist/cjs/my-component.cjs.entry.js +3 -3
- package/dist/cjs/ptc-announcement.cjs.entry.js +35 -0
- package/dist/cjs/ptc-avatar.cjs.entry.js +2 -2
- package/dist/cjs/ptc-button_2.cjs.entry.js +97 -0
- package/dist/cjs/ptc-card.cjs.entry.js +2 -2
- package/dist/cjs/ptc-countdown.cjs.entry.js +2 -2
- package/dist/cjs/ptc-date.cjs.entry.js +2 -2
- package/dist/cjs/ptc-footer.cjs.entry.js +2 -2
- package/dist/cjs/ptc-form_3.cjs.entry.js +171 -0
- package/dist/cjs/ptc-img.cjs.entry.js +2 -2
- package/dist/cjs/ptc-link.cjs.entry.js +2 -2
- package/dist/cjs/ptc-list.cjs.entry.js +2 -2
- package/dist/cjs/ptc-lottie.cjs.entry.js +2 -2
- package/dist/cjs/ptc-nav-item.cjs.entry.js +2 -2
- package/dist/cjs/ptc-nav.cjs.entry.js +2 -2
- package/dist/cjs/ptc-overlay.cjs.entry.js +2 -2
- package/dist/cjs/ptc-para.cjs.entry.js +40 -0
- package/dist/cjs/ptc-picture.cjs.entry.js +2 -2
- package/dist/cjs/ptc-spacer.cjs.entry.js +2 -2
- package/dist/cjs/ptc-span.cjs.entry.js +2 -2
- package/dist/cjs/ptc-title.cjs.entry.js +3 -3
- package/dist/cjs/ptcw-design.cjs.js +3 -3
- package/dist/collection/collection-manifest.json +5 -2
- package/dist/collection/components/my-component/my-component.js +2 -3
- package/dist/collection/components/ptc-announcement/ptc-announcement.js +2 -2
- package/dist/collection/components/ptc-button/ptc-button.js +2 -2
- package/dist/collection/components/ptc-form/ptc-form.css +3 -0
- package/dist/collection/components/ptc-form/ptc-form.js +118 -0
- package/dist/collection/components/ptc-form/validation/FormValidation.full.min.js +1 -0
- package/dist/collection/components/ptc-form/validation/FormValidation.js +4234 -0
- package/dist/collection/components/ptc-input/ptc-input.css +47 -0
- package/dist/collection/components/ptc-input/ptc-input.js +133 -80
- package/dist/collection/components/ptc-select/ptc-select.css +22 -0
- package/dist/collection/components/ptc-select/ptc-select.js +105 -0
- package/dist/collection/components/ptc-title/ptc-title.js +1 -1
- package/dist/custom-elements/index.d.ts +19 -1
- package/dist/custom-elements/index.js +220 -50
- package/dist/esm/icon-asset.entry.js +60 -0
- package/dist/esm/{index-7a3883ee.js → index-eb8ce23d.js} +159 -88
- package/dist/esm/list-item.entry.js +2 -2
- package/dist/esm/loader.js +3 -3
- package/dist/esm/lottie-player.entry.js +2 -2
- package/dist/esm/my-component.entry.js +3 -3
- package/dist/esm/ptc-announcement.entry.js +31 -0
- package/dist/esm/ptc-avatar.entry.js +2 -2
- package/dist/esm/ptc-button_2.entry.js +92 -0
- package/dist/esm/ptc-card.entry.js +2 -2
- package/dist/esm/ptc-countdown.entry.js +2 -2
- package/dist/esm/ptc-date.entry.js +2 -2
- package/dist/esm/ptc-footer.entry.js +2 -2
- package/dist/esm/ptc-form_3.entry.js +165 -0
- package/dist/esm/ptc-img.entry.js +2 -2
- package/dist/esm/ptc-link.entry.js +2 -2
- package/dist/esm/ptc-list.entry.js +2 -2
- package/dist/esm/ptc-lottie.entry.js +2 -2
- package/dist/esm/ptc-nav-item.entry.js +2 -2
- package/dist/esm/ptc-nav.entry.js +2 -2
- package/dist/esm/ptc-overlay.entry.js +2 -2
- package/dist/esm/ptc-para.entry.js +36 -0
- package/dist/esm/ptc-picture.entry.js +2 -2
- package/dist/esm/ptc-spacer.entry.js +2 -2
- package/dist/esm/ptc-span.entry.js +2 -2
- package/dist/esm/ptc-title.entry.js +3 -3
- package/dist/esm/ptcw-design.js +3 -3
- package/dist/ptcw-design/p-01243ce4.entry.js +1 -0
- package/dist/ptcw-design/p-01f4bf71.entry.js +1 -0
- package/dist/ptcw-design/p-1b3b0193.entry.js +1 -0
- package/dist/ptcw-design/p-22fd400f.entry.js +1 -0
- package/dist/ptcw-design/p-23d07898.entry.js +1 -0
- package/dist/ptcw-design/p-2b59ce7a.entry.js +1 -0
- package/dist/ptcw-design/p-2ca3c085.js +1 -0
- package/dist/ptcw-design/p-389a5670.entry.js +1 -0
- package/dist/ptcw-design/p-3f42afb6.entry.js +1 -0
- package/dist/ptcw-design/p-51443fbb.entry.js +1 -0
- package/dist/ptcw-design/p-54794e45.entry.js +1 -0
- package/dist/ptcw-design/p-5ae43421.entry.js +1 -0
- package/dist/ptcw-design/p-63b55aba.entry.js +1 -0
- package/dist/ptcw-design/p-6b5c0d9d.entry.js +1 -0
- package/dist/ptcw-design/p-7076b32f.entry.js +1 -0
- package/dist/ptcw-design/{p-51a3e9e6.entry.js → p-75dc7328.entry.js} +1 -1
- package/dist/ptcw-design/p-945f5a15.entry.js +1 -0
- package/dist/ptcw-design/p-a86452af.entry.js +1 -0
- package/dist/ptcw-design/p-cf3d92e0.entry.js +1 -0
- package/dist/ptcw-design/p-d3f9852f.entry.js +1 -0
- package/dist/ptcw-design/p-d80b24c9.entry.js +1 -0
- package/dist/ptcw-design/p-e4b96b46.entry.js +1 -0
- package/dist/ptcw-design/p-eda0500f.entry.js +1 -0
- package/dist/ptcw-design/p-ef6acb81.entry.js +1 -0
- package/dist/ptcw-design/p-fd29d9dd.entry.js +1 -0
- package/dist/ptcw-design/ptcw-design.css +1 -1
- package/dist/ptcw-design/ptcw-design.esm.js +1 -1
- package/dist/ptcw-design/validation/FormValidation.full.min.js +1 -0
- package/dist/ptcw-design/validation/FormValidation.js +4234 -0
- package/dist/types/components/ptc-form/ptc-form.d.ts +11 -0
- package/dist/types/components/ptc-input/ptc-input.d.ts +19 -0
- package/dist/types/components/ptc-select/ptc-select.d.ts +9 -0
- package/dist/types/components.d.ts +63 -0
- package/dist/types/global.d.ts +1072 -0
- package/dist/types/stencil-public-runtime.d.ts +189 -186
- package/loader/index.d.ts +0 -1
- package/package.json +6 -2
- package/readme.md +1 -1
- package/dist/cjs/icon-asset_5.cjs.entry.js +0 -218
- package/dist/esm/icon-asset_5.entry.js +0 -210
- package/dist/ptcw-design/p-0c8df906.entry.js +0 -1
- package/dist/ptcw-design/p-186beb2c.entry.js +0 -1
- package/dist/ptcw-design/p-2d5f8cff.entry.js +0 -1
- package/dist/ptcw-design/p-50923c9a.js +0 -1
- package/dist/ptcw-design/p-62706e4e.entry.js +0 -1
- package/dist/ptcw-design/p-66ffa30c.entry.js +0 -1
- package/dist/ptcw-design/p-6b1a35e1.entry.js +0 -1
- package/dist/ptcw-design/p-73e2418e.entry.js +0 -1
- package/dist/ptcw-design/p-796b8287.entry.js +0 -1
- package/dist/ptcw-design/p-8edac972.entry.js +0 -1
- package/dist/ptcw-design/p-90402319.entry.js +0 -1
- package/dist/ptcw-design/p-919311d2.entry.js +0 -1
- package/dist/ptcw-design/p-ac449734.entry.js +0 -1
- package/dist/ptcw-design/p-d17b386a.entry.js +0 -1
- package/dist/ptcw-design/p-d44c44e6.entry.js +0 -1
- package/dist/ptcw-design/p-d6553853.entry.js +0 -1
- package/dist/ptcw-design/p-ef250898.entry.js +0 -1
- package/dist/ptcw-design/p-f694e46a.entry.js +0 -1
- package/dist/ptcw-design/p-f80152dc.entry.js +0 -1
- package/dist/ptcw-design/p-ff28ce2d.entry.js +0 -1
|
@@ -0,0 +1,4234 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FormValidation (https://formvalidation.io), v1.9.0 (cbf8fab)
|
|
3
|
+
* The best validation library for JavaScript
|
|
4
|
+
* (c) 2013 - 2021 Nguyen Huu Phuoc <me@phuoc.ng>
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
(function (global, factory) {
|
|
8
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
9
|
+
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
10
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.FormValidation = {}));
|
|
11
|
+
})(this, (function (exports) { 'use strict';
|
|
12
|
+
|
|
13
|
+
function t$i(t) {
|
|
14
|
+
var e = t.length;
|
|
15
|
+
var l = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]];
|
|
16
|
+
var n = 0;
|
|
17
|
+
var r = 0;
|
|
18
|
+
|
|
19
|
+
while (e--) {
|
|
20
|
+
r += l[n][parseInt(t.charAt(e), 10)];
|
|
21
|
+
n = 1 - n;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return r % 10 === 0 && r > 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function t$h(t) {
|
|
28
|
+
var e = t.length;
|
|
29
|
+
var n = 5;
|
|
30
|
+
|
|
31
|
+
for (var r = 0; r < e; r++) {
|
|
32
|
+
n = ((n || 10) * 2 % 11 + parseInt(t.charAt(r), 10)) % 10;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return n === 1;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function t$g(t) {
|
|
39
|
+
var e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
40
|
+
var n = t.length;
|
|
41
|
+
var o = e.length;
|
|
42
|
+
var l = Math.floor(o / 2);
|
|
43
|
+
|
|
44
|
+
for (var r = 0; r < n; r++) {
|
|
45
|
+
l = ((l || o) * 2 % (o + 1) + e.indexOf(t.charAt(r))) % o;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return l === 1;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function t$f(t) {
|
|
52
|
+
var e = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 0, 6, 7, 8, 9, 5], [2, 3, 4, 0, 1, 7, 8, 9, 5, 6], [3, 4, 0, 1, 2, 8, 9, 5, 6, 7], [4, 0, 1, 2, 3, 9, 5, 6, 7, 8], [5, 9, 8, 7, 6, 0, 4, 3, 2, 1], [6, 5, 9, 8, 7, 1, 0, 4, 3, 2], [7, 6, 5, 9, 8, 2, 1, 0, 4, 3], [8, 7, 6, 5, 9, 3, 2, 1, 0, 4], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]];
|
|
53
|
+
var n = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 5, 7, 6, 2, 8, 3, 0, 9, 4], [5, 8, 0, 3, 7, 9, 6, 1, 4, 2], [8, 9, 1, 6, 0, 4, 3, 5, 2, 7], [9, 4, 5, 3, 1, 2, 6, 8, 7, 0], [4, 2, 8, 6, 5, 7, 3, 9, 0, 1], [2, 7, 9, 3, 8, 0, 6, 4, 1, 5], [7, 0, 4, 6, 9, 1, 3, 2, 5, 8]];
|
|
54
|
+
var o = t.reverse();
|
|
55
|
+
var r = 0;
|
|
56
|
+
|
|
57
|
+
for (var _t = 0; _t < o.length; _t++) {
|
|
58
|
+
r = e[r][n[_t % 8][o[_t]]];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return r === 0;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
var index$3 = {
|
|
65
|
+
luhn: t$i,
|
|
66
|
+
mod11And10: t$h,
|
|
67
|
+
mod37And36: t$g,
|
|
68
|
+
verhoeff: t$f
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
function _classCallCheck(instance, Constructor) {
|
|
72
|
+
if (!(instance instanceof Constructor)) {
|
|
73
|
+
throw new TypeError("Cannot call a class as a function");
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function _defineProperties(target, props) {
|
|
78
|
+
for (var i = 0; i < props.length; i++) {
|
|
79
|
+
var descriptor = props[i];
|
|
80
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
81
|
+
descriptor.configurable = true;
|
|
82
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
83
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
88
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
89
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
90
|
+
return Constructor;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function _defineProperty(obj, key, value) {
|
|
94
|
+
if (key in obj) {
|
|
95
|
+
Object.defineProperty(obj, key, {
|
|
96
|
+
value: value,
|
|
97
|
+
enumerable: true,
|
|
98
|
+
configurable: true,
|
|
99
|
+
writable: true
|
|
100
|
+
});
|
|
101
|
+
} else {
|
|
102
|
+
obj[key] = value;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return obj;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function _inherits(subClass, superClass) {
|
|
109
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
110
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
114
|
+
constructor: {
|
|
115
|
+
value: subClass,
|
|
116
|
+
writable: true,
|
|
117
|
+
configurable: true
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function _getPrototypeOf(o) {
|
|
124
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
125
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
126
|
+
};
|
|
127
|
+
return _getPrototypeOf(o);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function _setPrototypeOf(o, p) {
|
|
131
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
132
|
+
o.__proto__ = p;
|
|
133
|
+
return o;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
return _setPrototypeOf(o, p);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function _isNativeReflectConstruct() {
|
|
140
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
141
|
+
if (Reflect.construct.sham) return false;
|
|
142
|
+
if (typeof Proxy === "function") return true;
|
|
143
|
+
|
|
144
|
+
try {
|
|
145
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
146
|
+
return true;
|
|
147
|
+
} catch (e) {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function _assertThisInitialized(self) {
|
|
153
|
+
if (self === void 0) {
|
|
154
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return self;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function _possibleConstructorReturn(self, call) {
|
|
161
|
+
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
162
|
+
return call;
|
|
163
|
+
} else if (call !== void 0) {
|
|
164
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return _assertThisInitialized(self);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function _createSuper(Derived) {
|
|
171
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
172
|
+
|
|
173
|
+
return function _createSuperInternal() {
|
|
174
|
+
var Super = _getPrototypeOf(Derived),
|
|
175
|
+
result;
|
|
176
|
+
|
|
177
|
+
if (hasNativeReflectConstruct) {
|
|
178
|
+
var NewTarget = _getPrototypeOf(this).constructor;
|
|
179
|
+
|
|
180
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
181
|
+
} else {
|
|
182
|
+
result = Super.apply(this, arguments);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return _possibleConstructorReturn(this, result);
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
190
|
+
if (!o) return;
|
|
191
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
192
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
193
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
194
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
195
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function _arrayLikeToArray(arr, len) {
|
|
199
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
200
|
+
|
|
201
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
202
|
+
|
|
203
|
+
return arr2;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
207
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
208
|
+
|
|
209
|
+
if (!it) {
|
|
210
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
211
|
+
if (it) o = it;
|
|
212
|
+
var i = 0;
|
|
213
|
+
|
|
214
|
+
var F = function () {};
|
|
215
|
+
|
|
216
|
+
return {
|
|
217
|
+
s: F,
|
|
218
|
+
n: function () {
|
|
219
|
+
if (i >= o.length) return {
|
|
220
|
+
done: true
|
|
221
|
+
};
|
|
222
|
+
return {
|
|
223
|
+
done: false,
|
|
224
|
+
value: o[i++]
|
|
225
|
+
};
|
|
226
|
+
},
|
|
227
|
+
e: function (e) {
|
|
228
|
+
throw e;
|
|
229
|
+
},
|
|
230
|
+
f: F
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
var normalCompletion = true,
|
|
238
|
+
didErr = false,
|
|
239
|
+
err;
|
|
240
|
+
return {
|
|
241
|
+
s: function () {
|
|
242
|
+
it = it.call(o);
|
|
243
|
+
},
|
|
244
|
+
n: function () {
|
|
245
|
+
var step = it.next();
|
|
246
|
+
normalCompletion = step.done;
|
|
247
|
+
return step;
|
|
248
|
+
},
|
|
249
|
+
e: function (e) {
|
|
250
|
+
didErr = true;
|
|
251
|
+
err = e;
|
|
252
|
+
},
|
|
253
|
+
f: function () {
|
|
254
|
+
try {
|
|
255
|
+
if (!normalCompletion && it.return != null) it.return();
|
|
256
|
+
} finally {
|
|
257
|
+
if (didErr) throw err;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function s$6() {
|
|
264
|
+
return {
|
|
265
|
+
fns: {},
|
|
266
|
+
clear: function clear() {
|
|
267
|
+
this.fns = {};
|
|
268
|
+
},
|
|
269
|
+
emit: function emit(s) {
|
|
270
|
+
for (var _len = arguments.length, f = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
271
|
+
f[_key - 1] = arguments[_key];
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
(this.fns[s] || []).map(function (s) {
|
|
275
|
+
return s.apply(s, f);
|
|
276
|
+
});
|
|
277
|
+
},
|
|
278
|
+
off: function off(s, f) {
|
|
279
|
+
if (this.fns[s]) {
|
|
280
|
+
var n = this.fns[s].indexOf(f);
|
|
281
|
+
|
|
282
|
+
if (n >= 0) {
|
|
283
|
+
this.fns[s].splice(n, 1);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
on: function on(s, f) {
|
|
288
|
+
(this.fns[s] = this.fns[s] || []).push(f);
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
function t$e() {
|
|
294
|
+
return {
|
|
295
|
+
filters: {},
|
|
296
|
+
add: function add(t, e) {
|
|
297
|
+
(this.filters[t] = this.filters[t] || []).push(e);
|
|
298
|
+
},
|
|
299
|
+
clear: function clear() {
|
|
300
|
+
this.filters = {};
|
|
301
|
+
},
|
|
302
|
+
execute: function execute(t, e, i) {
|
|
303
|
+
if (!this.filters[t] || !this.filters[t].length) {
|
|
304
|
+
return e;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
var s = e;
|
|
308
|
+
var r = this.filters[t];
|
|
309
|
+
var l = r.length;
|
|
310
|
+
|
|
311
|
+
for (var _t = 0; _t < l; _t++) {
|
|
312
|
+
s = r[_t].apply(s, i);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
return s;
|
|
316
|
+
},
|
|
317
|
+
remove: function remove(t, e) {
|
|
318
|
+
if (this.filters[t]) {
|
|
319
|
+
this.filters[t] = this.filters[t].filter(function (t) {
|
|
320
|
+
return t !== e;
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function e$a(e, t, r, n) {
|
|
328
|
+
var o = (r.getAttribute("type") || "").toLowerCase();
|
|
329
|
+
var c = r.tagName.toLowerCase();
|
|
330
|
+
|
|
331
|
+
if (c === "textarea") {
|
|
332
|
+
return r.value;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
if (c === "select") {
|
|
336
|
+
var _e = r;
|
|
337
|
+
var _t = _e.selectedIndex;
|
|
338
|
+
return _t >= 0 ? _e.options.item(_t).value : "";
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
if (c === "input") {
|
|
342
|
+
if ("radio" === o || "checkbox" === o) {
|
|
343
|
+
var _e2 = n.filter(function (e) {
|
|
344
|
+
return e.checked;
|
|
345
|
+
}).length;
|
|
346
|
+
return _e2 === 0 ? "" : _e2 + "";
|
|
347
|
+
} else {
|
|
348
|
+
return r.value;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
return "";
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
function r$2(r, e) {
|
|
356
|
+
var t = Array.isArray(e) ? e : [e];
|
|
357
|
+
var a = r;
|
|
358
|
+
t.forEach(function (r) {
|
|
359
|
+
a = a.replace("%s", r);
|
|
360
|
+
});
|
|
361
|
+
return a;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
function s$5() {
|
|
365
|
+
var s = function s(e) {
|
|
366
|
+
return parseFloat("".concat(e).replace(",", "."));
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
return {
|
|
370
|
+
validate: function validate(a) {
|
|
371
|
+
var t = a.value;
|
|
372
|
+
|
|
373
|
+
if (t === "") {
|
|
374
|
+
return {
|
|
375
|
+
valid: true
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
var n = Object.assign({}, {
|
|
380
|
+
inclusive: true,
|
|
381
|
+
message: ""
|
|
382
|
+
}, a.options);
|
|
383
|
+
var l = s(n.min);
|
|
384
|
+
var o = s(n.max);
|
|
385
|
+
return n.inclusive ? {
|
|
386
|
+
message: r$2(a.l10n ? n.message || a.l10n.between["default"] : n.message, ["".concat(l), "".concat(o)]),
|
|
387
|
+
valid: parseFloat(t) >= l && parseFloat(t) <= o
|
|
388
|
+
} : {
|
|
389
|
+
message: r$2(a.l10n ? n.message || a.l10n.between.notInclusive : n.message, ["".concat(l), "".concat(o)]),
|
|
390
|
+
valid: parseFloat(t) > l && parseFloat(t) < o
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
function t$d() {
|
|
397
|
+
return {
|
|
398
|
+
validate: function validate(t) {
|
|
399
|
+
return {
|
|
400
|
+
valid: true
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
function t$c(t, n) {
|
|
407
|
+
if ("function" === typeof t) {
|
|
408
|
+
return t.apply(this, n);
|
|
409
|
+
} else if ("string" === typeof t) {
|
|
410
|
+
var e = t;
|
|
411
|
+
|
|
412
|
+
if ("()" === e.substring(e.length - 2)) {
|
|
413
|
+
e = e.substring(0, e.length - 2);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
var i = e.split(".");
|
|
417
|
+
var o = i.pop();
|
|
418
|
+
var f = window;
|
|
419
|
+
|
|
420
|
+
var _iterator = _createForOfIteratorHelper(i),
|
|
421
|
+
_step;
|
|
422
|
+
|
|
423
|
+
try {
|
|
424
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
425
|
+
var _t = _step.value;
|
|
426
|
+
f = f[_t];
|
|
427
|
+
}
|
|
428
|
+
} catch (err) {
|
|
429
|
+
_iterator.e(err);
|
|
430
|
+
} finally {
|
|
431
|
+
_iterator.f();
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
return typeof f[o] === "undefined" ? null : f[o].apply(this, n);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
function o$3() {
|
|
439
|
+
return {
|
|
440
|
+
validate: function validate(o) {
|
|
441
|
+
var l = t$c(o.options.callback, [o]);
|
|
442
|
+
return "boolean" === typeof l ? {
|
|
443
|
+
valid: l
|
|
444
|
+
} : l;
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
function t$b() {
|
|
450
|
+
return {
|
|
451
|
+
validate: function validate(t) {
|
|
452
|
+
var o = "select" === t.element.tagName.toLowerCase() ? t.element.querySelectorAll("option:checked").length : t.elements.filter(function (e) {
|
|
453
|
+
return e.checked;
|
|
454
|
+
}).length;
|
|
455
|
+
var s = t.options.min ? "".concat(t.options.min) : "";
|
|
456
|
+
var n = t.options.max ? "".concat(t.options.max) : "";
|
|
457
|
+
var a = t.l10n ? t.options.message || t.l10n.choice["default"] : t.options.message;
|
|
458
|
+
var l = !(s && o < parseInt(s, 10) || n && o > parseInt(n, 10));
|
|
459
|
+
|
|
460
|
+
switch (true) {
|
|
461
|
+
case !!s && !!n:
|
|
462
|
+
a = r$2(t.l10n ? t.l10n.choice.between : t.options.message, [s, n]);
|
|
463
|
+
break;
|
|
464
|
+
|
|
465
|
+
case !!s:
|
|
466
|
+
a = r$2(t.l10n ? t.l10n.choice.more : t.options.message, s);
|
|
467
|
+
break;
|
|
468
|
+
|
|
469
|
+
case !!n:
|
|
470
|
+
a = r$2(t.l10n ? t.l10n.choice.less : t.options.message, n);
|
|
471
|
+
break;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
return {
|
|
475
|
+
message: a,
|
|
476
|
+
valid: l
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
var t$a = {
|
|
483
|
+
AMERICAN_EXPRESS: {
|
|
484
|
+
length: [15],
|
|
485
|
+
prefix: ["34", "37"]
|
|
486
|
+
},
|
|
487
|
+
DANKORT: {
|
|
488
|
+
length: [16],
|
|
489
|
+
prefix: ["5019"]
|
|
490
|
+
},
|
|
491
|
+
DINERS_CLUB: {
|
|
492
|
+
length: [14],
|
|
493
|
+
prefix: ["300", "301", "302", "303", "304", "305", "36"]
|
|
494
|
+
},
|
|
495
|
+
DINERS_CLUB_US: {
|
|
496
|
+
length: [16],
|
|
497
|
+
prefix: ["54", "55"]
|
|
498
|
+
},
|
|
499
|
+
DISCOVER: {
|
|
500
|
+
length: [16],
|
|
501
|
+
prefix: ["6011", "622126", "622127", "622128", "622129", "62213", "62214", "62215", "62216", "62217", "62218", "62219", "6222", "6223", "6224", "6225", "6226", "6227", "6228", "62290", "62291", "622920", "622921", "622922", "622923", "622924", "622925", "644", "645", "646", "647", "648", "649", "65"]
|
|
502
|
+
},
|
|
503
|
+
ELO: {
|
|
504
|
+
length: [16],
|
|
505
|
+
prefix: ["4011", "4312", "4389", "4514", "4573", "4576", "5041", "5066", "5067", "509", "6277", "6362", "6363", "650", "6516", "6550"]
|
|
506
|
+
},
|
|
507
|
+
FORBRUGSFORENINGEN: {
|
|
508
|
+
length: [16],
|
|
509
|
+
prefix: ["600722"]
|
|
510
|
+
},
|
|
511
|
+
JCB: {
|
|
512
|
+
length: [16],
|
|
513
|
+
prefix: ["3528", "3529", "353", "354", "355", "356", "357", "358"]
|
|
514
|
+
},
|
|
515
|
+
LASER: {
|
|
516
|
+
length: [16, 17, 18, 19],
|
|
517
|
+
prefix: ["6304", "6706", "6771", "6709"]
|
|
518
|
+
},
|
|
519
|
+
MAESTRO: {
|
|
520
|
+
length: [12, 13, 14, 15, 16, 17, 18, 19],
|
|
521
|
+
prefix: ["5018", "5020", "5038", "5868", "6304", "6759", "6761", "6762", "6763", "6764", "6765", "6766"]
|
|
522
|
+
},
|
|
523
|
+
MASTERCARD: {
|
|
524
|
+
length: [16],
|
|
525
|
+
prefix: ["51", "52", "53", "54", "55"]
|
|
526
|
+
},
|
|
527
|
+
SOLO: {
|
|
528
|
+
length: [16, 18, 19],
|
|
529
|
+
prefix: ["6334", "6767"]
|
|
530
|
+
},
|
|
531
|
+
UNIONPAY: {
|
|
532
|
+
length: [16, 17, 18, 19],
|
|
533
|
+
prefix: ["622126", "622127", "622128", "622129", "62213", "62214", "62215", "62216", "62217", "62218", "62219", "6222", "6223", "6224", "6225", "6226", "6227", "6228", "62290", "62291", "622920", "622921", "622922", "622923", "622924", "622925"]
|
|
534
|
+
},
|
|
535
|
+
VISA: {
|
|
536
|
+
length: [16],
|
|
537
|
+
prefix: ["4"]
|
|
538
|
+
},
|
|
539
|
+
VISA_ELECTRON: {
|
|
540
|
+
length: [16],
|
|
541
|
+
prefix: ["4026", "417500", "4405", "4508", "4844", "4913", "4917"]
|
|
542
|
+
}
|
|
543
|
+
};
|
|
544
|
+
function l$2() {
|
|
545
|
+
return {
|
|
546
|
+
validate: function validate(l) {
|
|
547
|
+
if (l.value === "") {
|
|
548
|
+
return {
|
|
549
|
+
meta: {
|
|
550
|
+
type: null
|
|
551
|
+
},
|
|
552
|
+
valid: true
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
if (/[^0-9-\s]+/.test(l.value)) {
|
|
557
|
+
return {
|
|
558
|
+
meta: {
|
|
559
|
+
type: null
|
|
560
|
+
},
|
|
561
|
+
valid: false
|
|
562
|
+
};
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
var r = l.value.replace(/\D/g, "");
|
|
566
|
+
|
|
567
|
+
if (!t$i(r)) {
|
|
568
|
+
return {
|
|
569
|
+
meta: {
|
|
570
|
+
type: null
|
|
571
|
+
},
|
|
572
|
+
valid: false
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
for (var _i = 0, _Object$keys = Object.keys(t$a); _i < _Object$keys.length; _i++) {
|
|
577
|
+
var _e = _Object$keys[_i];
|
|
578
|
+
|
|
579
|
+
for (var n in t$a[_e].prefix) {
|
|
580
|
+
if (l.value.substr(0, t$a[_e].prefix[n].length) === t$a[_e].prefix[n] && t$a[_e].length.indexOf(r.length) !== -1) {
|
|
581
|
+
return {
|
|
582
|
+
meta: {
|
|
583
|
+
type: _e
|
|
584
|
+
},
|
|
585
|
+
valid: true
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
return {
|
|
592
|
+
meta: {
|
|
593
|
+
type: null
|
|
594
|
+
},
|
|
595
|
+
valid: false
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
function t$9(t, e, n, r) {
|
|
602
|
+
if (isNaN(t) || isNaN(e) || isNaN(n)) {
|
|
603
|
+
return false;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
if (t < 1e3 || t > 9999 || e <= 0 || e > 12) {
|
|
607
|
+
return false;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
var s = [31, t % 400 === 0 || t % 100 !== 0 && t % 4 === 0 ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
611
|
+
|
|
612
|
+
if (n <= 0 || n > s[e - 1]) {
|
|
613
|
+
return false;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
if (r === true) {
|
|
617
|
+
var _r = new Date();
|
|
618
|
+
|
|
619
|
+
var _s = _r.getFullYear();
|
|
620
|
+
|
|
621
|
+
var a = _r.getMonth();
|
|
622
|
+
|
|
623
|
+
var u = _r.getDate();
|
|
624
|
+
|
|
625
|
+
return t < _s || t === _s && e - 1 < a || t === _s && e - 1 === a && n < u;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
return true;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
function n() {
|
|
632
|
+
var n = function n(t, e, _n) {
|
|
633
|
+
var s = e.indexOf("YYYY");
|
|
634
|
+
var a = e.indexOf("MM");
|
|
635
|
+
var l = e.indexOf("DD");
|
|
636
|
+
|
|
637
|
+
if (s === -1 || a === -1 || l === -1) {
|
|
638
|
+
return null;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
var o = t.split(" ");
|
|
642
|
+
var r = o[0].split(_n);
|
|
643
|
+
|
|
644
|
+
if (r.length < 3) {
|
|
645
|
+
return null;
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
var c = new Date(parseInt(r[s], 10), parseInt(r[a], 10) - 1, parseInt(r[l], 10));
|
|
649
|
+
|
|
650
|
+
if (o.length > 1) {
|
|
651
|
+
var _t = o[1].split(":");
|
|
652
|
+
|
|
653
|
+
c.setHours(_t.length > 0 ? parseInt(_t[0], 10) : 0);
|
|
654
|
+
c.setMinutes(_t.length > 1 ? parseInt(_t[1], 10) : 0);
|
|
655
|
+
c.setSeconds(_t.length > 2 ? parseInt(_t[2], 10) : 0);
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
return c;
|
|
659
|
+
};
|
|
660
|
+
|
|
661
|
+
var s = function s(t, e) {
|
|
662
|
+
var n = e.replace(/Y/g, "y").replace(/M/g, "m").replace(/D/g, "d").replace(/:m/g, ":M").replace(/:mm/g, ":MM").replace(/:S/, ":s").replace(/:SS/, ":ss");
|
|
663
|
+
var s = t.getDate();
|
|
664
|
+
var a = s < 10 ? "0".concat(s) : s;
|
|
665
|
+
var l = t.getMonth() + 1;
|
|
666
|
+
var o = l < 10 ? "0".concat(l) : l;
|
|
667
|
+
var r = "".concat(t.getFullYear()).substr(2);
|
|
668
|
+
var c = t.getFullYear();
|
|
669
|
+
var i = t.getHours() % 12 || 12;
|
|
670
|
+
var g = i < 10 ? "0".concat(i) : i;
|
|
671
|
+
var u = t.getHours();
|
|
672
|
+
var m = u < 10 ? "0".concat(u) : u;
|
|
673
|
+
var d = t.getMinutes();
|
|
674
|
+
var f = d < 10 ? "0".concat(d) : d;
|
|
675
|
+
var p = t.getSeconds();
|
|
676
|
+
var h = p < 10 ? "0".concat(p) : p;
|
|
677
|
+
var $ = {
|
|
678
|
+
H: "".concat(u),
|
|
679
|
+
HH: "".concat(m),
|
|
680
|
+
M: "".concat(d),
|
|
681
|
+
MM: "".concat(f),
|
|
682
|
+
d: "".concat(s),
|
|
683
|
+
dd: "".concat(a),
|
|
684
|
+
h: "".concat(i),
|
|
685
|
+
hh: "".concat(g),
|
|
686
|
+
m: "".concat(l),
|
|
687
|
+
mm: "".concat(o),
|
|
688
|
+
s: "".concat(p),
|
|
689
|
+
ss: "".concat(h),
|
|
690
|
+
yy: "".concat(r),
|
|
691
|
+
yyyy: "".concat(c)
|
|
692
|
+
};
|
|
693
|
+
return n.replace(/d{1,4}|m{1,4}|yy(?:yy)?|([HhMs])\1?|"[^"]*"|'[^']*'/g, function (t) {
|
|
694
|
+
return $[t] ? $[t] : t.slice(1, t.length - 1);
|
|
695
|
+
});
|
|
696
|
+
};
|
|
697
|
+
|
|
698
|
+
return {
|
|
699
|
+
validate: function validate(a) {
|
|
700
|
+
if (a.value === "") {
|
|
701
|
+
return {
|
|
702
|
+
meta: {
|
|
703
|
+
date: null
|
|
704
|
+
},
|
|
705
|
+
valid: true
|
|
706
|
+
};
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
var l = Object.assign({}, {
|
|
710
|
+
format: a.element && a.element.getAttribute("type") === "date" ? "YYYY-MM-DD" : "MM/DD/YYYY",
|
|
711
|
+
message: ""
|
|
712
|
+
}, a.options);
|
|
713
|
+
var o = a.l10n ? a.l10n.date["default"] : l.message;
|
|
714
|
+
var r = {
|
|
715
|
+
message: "".concat(o),
|
|
716
|
+
meta: {
|
|
717
|
+
date: null
|
|
718
|
+
},
|
|
719
|
+
valid: false
|
|
720
|
+
};
|
|
721
|
+
var c = l.format.split(" ");
|
|
722
|
+
var i = c.length > 1 ? c[1] : null;
|
|
723
|
+
var g = c.length > 2 ? c[2] : null;
|
|
724
|
+
var u = a.value.split(" ");
|
|
725
|
+
var m = u[0];
|
|
726
|
+
var d = u.length > 1 ? u[1] : null;
|
|
727
|
+
|
|
728
|
+
if (c.length !== u.length) {
|
|
729
|
+
return r;
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
var f = l.separator || (m.indexOf("/") !== -1 ? "/" : m.indexOf("-") !== -1 ? "-" : m.indexOf(".") !== -1 ? "." : "/");
|
|
733
|
+
|
|
734
|
+
if (f === null || m.indexOf(f) === -1) {
|
|
735
|
+
return r;
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
var p = m.split(f);
|
|
739
|
+
var h = c[0].split(f);
|
|
740
|
+
|
|
741
|
+
if (p.length !== h.length) {
|
|
742
|
+
return r;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
var $ = p[h.indexOf("YYYY")];
|
|
746
|
+
var M = p[h.indexOf("MM")];
|
|
747
|
+
var Y = p[h.indexOf("DD")];
|
|
748
|
+
|
|
749
|
+
if (!/^\d+$/.test($) || !/^\d+$/.test(M) || !/^\d+$/.test(Y) || $.length > 4 || M.length > 2 || Y.length > 2) {
|
|
750
|
+
return r;
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
var D = parseInt($, 10);
|
|
754
|
+
var x = parseInt(M, 10);
|
|
755
|
+
var y = parseInt(Y, 10);
|
|
756
|
+
|
|
757
|
+
if (!t$9(D, x, y)) {
|
|
758
|
+
return r;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
var I = new Date(D, x - 1, y);
|
|
762
|
+
|
|
763
|
+
if (i) {
|
|
764
|
+
var _t2 = d.split(":");
|
|
765
|
+
|
|
766
|
+
if (i.split(":").length !== _t2.length) {
|
|
767
|
+
return r;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
var _e = _t2.length > 0 ? _t2[0].length <= 2 && /^\d+$/.test(_t2[0]) ? parseInt(_t2[0], 10) : -1 : 0;
|
|
771
|
+
|
|
772
|
+
var _n2 = _t2.length > 1 ? _t2[1].length <= 2 && /^\d+$/.test(_t2[1]) ? parseInt(_t2[1], 10) : -1 : 0;
|
|
773
|
+
|
|
774
|
+
var _s = _t2.length > 2 ? _t2[2].length <= 2 && /^\d+$/.test(_t2[2]) ? parseInt(_t2[2], 10) : -1 : 0;
|
|
775
|
+
|
|
776
|
+
if (_e === -1 || _n2 === -1 || _s === -1) {
|
|
777
|
+
return r;
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
if (_s < 0 || _s > 60) {
|
|
781
|
+
return r;
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
if (_e < 0 || _e >= 24 || g && _e > 12) {
|
|
785
|
+
return r;
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
if (_n2 < 0 || _n2 > 59) {
|
|
789
|
+
return r;
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
I.setHours(_e);
|
|
793
|
+
I.setMinutes(_n2);
|
|
794
|
+
I.setSeconds(_s);
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
var O = typeof l.min === "function" ? l.min() : l.min;
|
|
798
|
+
var v = O instanceof Date ? O : O ? n(O, h, f) : I;
|
|
799
|
+
var H = typeof l.max === "function" ? l.max() : l.max;
|
|
800
|
+
var T = H instanceof Date ? H : H ? n(H, h, f) : I;
|
|
801
|
+
var S = O instanceof Date ? s(v, l.format) : O;
|
|
802
|
+
var b = H instanceof Date ? s(T, l.format) : H;
|
|
803
|
+
|
|
804
|
+
switch (true) {
|
|
805
|
+
case !!S && !b:
|
|
806
|
+
return {
|
|
807
|
+
message: r$2(a.l10n ? a.l10n.date.min : o, S),
|
|
808
|
+
meta: {
|
|
809
|
+
date: I
|
|
810
|
+
},
|
|
811
|
+
valid: I.getTime() >= v.getTime()
|
|
812
|
+
};
|
|
813
|
+
|
|
814
|
+
case !!b && !S:
|
|
815
|
+
return {
|
|
816
|
+
message: r$2(a.l10n ? a.l10n.date.max : o, b),
|
|
817
|
+
meta: {
|
|
818
|
+
date: I
|
|
819
|
+
},
|
|
820
|
+
valid: I.getTime() <= T.getTime()
|
|
821
|
+
};
|
|
822
|
+
|
|
823
|
+
case !!b && !!S:
|
|
824
|
+
return {
|
|
825
|
+
message: r$2(a.l10n ? a.l10n.date.range : o, [S, b]),
|
|
826
|
+
meta: {
|
|
827
|
+
date: I
|
|
828
|
+
},
|
|
829
|
+
valid: I.getTime() <= T.getTime() && I.getTime() >= v.getTime()
|
|
830
|
+
};
|
|
831
|
+
|
|
832
|
+
default:
|
|
833
|
+
return {
|
|
834
|
+
message: "".concat(o),
|
|
835
|
+
meta: {
|
|
836
|
+
date: I
|
|
837
|
+
},
|
|
838
|
+
valid: true
|
|
839
|
+
};
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
};
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
function o$2() {
|
|
846
|
+
return {
|
|
847
|
+
validate: function validate(o) {
|
|
848
|
+
var t = "function" === typeof o.options.compare ? o.options.compare.call(this) : o.options.compare;
|
|
849
|
+
return {
|
|
850
|
+
valid: t === "" || o.value !== t
|
|
851
|
+
};
|
|
852
|
+
}
|
|
853
|
+
};
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
function e$9() {
|
|
857
|
+
return {
|
|
858
|
+
validate: function validate(e) {
|
|
859
|
+
return {
|
|
860
|
+
valid: e.value === "" || /^\d+$/.test(e.value)
|
|
861
|
+
};
|
|
862
|
+
}
|
|
863
|
+
};
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
function t$8() {
|
|
867
|
+
var t = function t(_t3, e) {
|
|
868
|
+
var s = _t3.split(/"/);
|
|
869
|
+
|
|
870
|
+
var l = s.length;
|
|
871
|
+
var n = [];
|
|
872
|
+
var r = "";
|
|
873
|
+
|
|
874
|
+
for (var _t = 0; _t < l; _t++) {
|
|
875
|
+
if (_t % 2 === 0) {
|
|
876
|
+
var _l = s[_t].split(e);
|
|
877
|
+
|
|
878
|
+
var a = _l.length;
|
|
879
|
+
|
|
880
|
+
if (a === 1) {
|
|
881
|
+
r += _l[0];
|
|
882
|
+
} else {
|
|
883
|
+
n.push(r + _l[0]);
|
|
884
|
+
|
|
885
|
+
for (var _t2 = 1; _t2 < a - 1; _t2++) {
|
|
886
|
+
n.push(_l[_t2]);
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
r = _l[a - 1];
|
|
890
|
+
}
|
|
891
|
+
} else {
|
|
892
|
+
r += '"' + s[_t];
|
|
893
|
+
|
|
894
|
+
if (_t < l - 1) {
|
|
895
|
+
r += '"';
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
n.push(r);
|
|
901
|
+
return n;
|
|
902
|
+
};
|
|
903
|
+
|
|
904
|
+
return {
|
|
905
|
+
validate: function validate(e) {
|
|
906
|
+
if (e.value === "") {
|
|
907
|
+
return {
|
|
908
|
+
valid: true
|
|
909
|
+
};
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
var s = Object.assign({}, {
|
|
913
|
+
multiple: false,
|
|
914
|
+
separator: /[,;]/
|
|
915
|
+
}, e.options);
|
|
916
|
+
var l = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
|
|
917
|
+
var n = s.multiple === true || "".concat(s.multiple) === "true";
|
|
918
|
+
|
|
919
|
+
if (n) {
|
|
920
|
+
var _n = s.separator || /[,;]/;
|
|
921
|
+
|
|
922
|
+
var r = t(e.value, _n);
|
|
923
|
+
var a = r.length;
|
|
924
|
+
|
|
925
|
+
for (var _t4 = 0; _t4 < a; _t4++) {
|
|
926
|
+
if (!l.test(r[_t4])) {
|
|
927
|
+
return {
|
|
928
|
+
valid: false
|
|
929
|
+
};
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
return {
|
|
934
|
+
valid: true
|
|
935
|
+
};
|
|
936
|
+
} else {
|
|
937
|
+
return {
|
|
938
|
+
valid: l.test(e.value)
|
|
939
|
+
};
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
};
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
function e$8() {
|
|
946
|
+
return {
|
|
947
|
+
validate: function validate(e) {
|
|
948
|
+
if (e.value === "") {
|
|
949
|
+
return {
|
|
950
|
+
valid: true
|
|
951
|
+
};
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
var t;
|
|
955
|
+
var i = e.options.extension ? e.options.extension.toLowerCase().split(",") : null;
|
|
956
|
+
var s = e.options.type ? e.options.type.toLowerCase().split(",") : null;
|
|
957
|
+
var n = window["File"] && window["FileList"] && window["FileReader"];
|
|
958
|
+
|
|
959
|
+
if (n) {
|
|
960
|
+
var _n = e.element.files;
|
|
961
|
+
var o = _n.length;
|
|
962
|
+
var a = 0;
|
|
963
|
+
|
|
964
|
+
if (e.options.maxFiles && o > parseInt("".concat(e.options.maxFiles), 10)) {
|
|
965
|
+
return {
|
|
966
|
+
meta: {
|
|
967
|
+
error: "INVALID_MAX_FILES"
|
|
968
|
+
},
|
|
969
|
+
valid: false
|
|
970
|
+
};
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
if (e.options.minFiles && o < parseInt("".concat(e.options.minFiles), 10)) {
|
|
974
|
+
return {
|
|
975
|
+
meta: {
|
|
976
|
+
error: "INVALID_MIN_FILES"
|
|
977
|
+
},
|
|
978
|
+
valid: false
|
|
979
|
+
};
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
var r = {};
|
|
983
|
+
|
|
984
|
+
for (var l = 0; l < o; l++) {
|
|
985
|
+
a += _n[l].size;
|
|
986
|
+
t = _n[l].name.substr(_n[l].name.lastIndexOf(".") + 1);
|
|
987
|
+
r = {
|
|
988
|
+
ext: t,
|
|
989
|
+
file: _n[l],
|
|
990
|
+
size: _n[l].size,
|
|
991
|
+
type: _n[l].type
|
|
992
|
+
};
|
|
993
|
+
|
|
994
|
+
if (e.options.minSize && _n[l].size < parseInt("".concat(e.options.minSize), 10)) {
|
|
995
|
+
return {
|
|
996
|
+
meta: Object.assign({}, {
|
|
997
|
+
error: "INVALID_MIN_SIZE"
|
|
998
|
+
}, r),
|
|
999
|
+
valid: false
|
|
1000
|
+
};
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
if (e.options.maxSize && _n[l].size > parseInt("".concat(e.options.maxSize), 10)) {
|
|
1004
|
+
return {
|
|
1005
|
+
meta: Object.assign({}, {
|
|
1006
|
+
error: "INVALID_MAX_SIZE"
|
|
1007
|
+
}, r),
|
|
1008
|
+
valid: false
|
|
1009
|
+
};
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
if (i && i.indexOf(t.toLowerCase()) === -1) {
|
|
1013
|
+
return {
|
|
1014
|
+
meta: Object.assign({}, {
|
|
1015
|
+
error: "INVALID_EXTENSION"
|
|
1016
|
+
}, r),
|
|
1017
|
+
valid: false
|
|
1018
|
+
};
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
if (_n[l].type && s && s.indexOf(_n[l].type.toLowerCase()) === -1) {
|
|
1022
|
+
return {
|
|
1023
|
+
meta: Object.assign({}, {
|
|
1024
|
+
error: "INVALID_TYPE"
|
|
1025
|
+
}, r),
|
|
1026
|
+
valid: false
|
|
1027
|
+
};
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
if (e.options.maxTotalSize && a > parseInt("".concat(e.options.maxTotalSize), 10)) {
|
|
1032
|
+
return {
|
|
1033
|
+
meta: Object.assign({}, {
|
|
1034
|
+
error: "INVALID_MAX_TOTAL_SIZE",
|
|
1035
|
+
totalSize: a
|
|
1036
|
+
}, r),
|
|
1037
|
+
valid: false
|
|
1038
|
+
};
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
if (e.options.minTotalSize && a < parseInt("".concat(e.options.minTotalSize), 10)) {
|
|
1042
|
+
return {
|
|
1043
|
+
meta: Object.assign({}, {
|
|
1044
|
+
error: "INVALID_MIN_TOTAL_SIZE",
|
|
1045
|
+
totalSize: a
|
|
1046
|
+
}, r),
|
|
1047
|
+
valid: false
|
|
1048
|
+
};
|
|
1049
|
+
}
|
|
1050
|
+
} else {
|
|
1051
|
+
t = e.value.substr(e.value.lastIndexOf(".") + 1);
|
|
1052
|
+
|
|
1053
|
+
if (i && i.indexOf(t.toLowerCase()) === -1) {
|
|
1054
|
+
return {
|
|
1055
|
+
meta: {
|
|
1056
|
+
error: "INVALID_EXTENSION",
|
|
1057
|
+
ext: t
|
|
1058
|
+
},
|
|
1059
|
+
valid: false
|
|
1060
|
+
};
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
return {
|
|
1065
|
+
valid: true
|
|
1066
|
+
};
|
|
1067
|
+
}
|
|
1068
|
+
};
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
function a$4() {
|
|
1072
|
+
return {
|
|
1073
|
+
validate: function validate(a) {
|
|
1074
|
+
if (a.value === "") {
|
|
1075
|
+
return {
|
|
1076
|
+
valid: true
|
|
1077
|
+
};
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
var s = Object.assign({}, {
|
|
1081
|
+
inclusive: true,
|
|
1082
|
+
message: ""
|
|
1083
|
+
}, a.options);
|
|
1084
|
+
var t = parseFloat("".concat(s.min).replace(",", "."));
|
|
1085
|
+
return s.inclusive ? {
|
|
1086
|
+
message: r$2(a.l10n ? s.message || a.l10n.greaterThan["default"] : s.message, "".concat(t)),
|
|
1087
|
+
valid: parseFloat(a.value) >= t
|
|
1088
|
+
} : {
|
|
1089
|
+
message: r$2(a.l10n ? s.message || a.l10n.greaterThan.notInclusive : s.message, "".concat(t)),
|
|
1090
|
+
valid: parseFloat(a.value) > t
|
|
1091
|
+
};
|
|
1092
|
+
}
|
|
1093
|
+
};
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
function o$1() {
|
|
1097
|
+
return {
|
|
1098
|
+
validate: function validate(o) {
|
|
1099
|
+
var t = "function" === typeof o.options.compare ? o.options.compare.call(this) : o.options.compare;
|
|
1100
|
+
return {
|
|
1101
|
+
valid: t === "" || o.value === t
|
|
1102
|
+
};
|
|
1103
|
+
}
|
|
1104
|
+
};
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
function a$3() {
|
|
1108
|
+
return {
|
|
1109
|
+
validate: function validate(a) {
|
|
1110
|
+
if (a.value === "") {
|
|
1111
|
+
return {
|
|
1112
|
+
valid: true
|
|
1113
|
+
};
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
var e = Object.assign({}, {
|
|
1117
|
+
decimalSeparator: ".",
|
|
1118
|
+
thousandsSeparator: ""
|
|
1119
|
+
}, a.options);
|
|
1120
|
+
var t = e.decimalSeparator === "." ? "\\." : e.decimalSeparator;
|
|
1121
|
+
var r = e.thousandsSeparator === "." ? "\\." : e.thousandsSeparator;
|
|
1122
|
+
var o = new RegExp("^-?[0-9]{1,3}(".concat(r, "[0-9]{3})*(").concat(t, "[0-9]+)?$"));
|
|
1123
|
+
var n = new RegExp(r, "g");
|
|
1124
|
+
var s = "".concat(a.value);
|
|
1125
|
+
|
|
1126
|
+
if (!o.test(s)) {
|
|
1127
|
+
return {
|
|
1128
|
+
valid: false
|
|
1129
|
+
};
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
if (r) {
|
|
1133
|
+
s = s.replace(n, "");
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
if (t) {
|
|
1137
|
+
s = s.replace(t, ".");
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
var i = parseFloat(s);
|
|
1141
|
+
return {
|
|
1142
|
+
valid: !isNaN(i) && isFinite(i) && Math.floor(i) === i
|
|
1143
|
+
};
|
|
1144
|
+
}
|
|
1145
|
+
};
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
function d() {
|
|
1149
|
+
return {
|
|
1150
|
+
validate: function validate(d) {
|
|
1151
|
+
if (d.value === "") {
|
|
1152
|
+
return {
|
|
1153
|
+
valid: true
|
|
1154
|
+
};
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
var a = Object.assign({}, {
|
|
1158
|
+
ipv4: true,
|
|
1159
|
+
ipv6: true
|
|
1160
|
+
}, d.options);
|
|
1161
|
+
var e = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\/([0-9]|[1-2][0-9]|3[0-2]))?$/;
|
|
1162
|
+
var s = /^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*(\/(\d|\d\d|1[0-1]\d|12[0-8]))?$/;
|
|
1163
|
+
|
|
1164
|
+
switch (true) {
|
|
1165
|
+
case a.ipv4 && !a.ipv6:
|
|
1166
|
+
return {
|
|
1167
|
+
message: d.l10n ? a.message || d.l10n.ip.ipv4 : a.message,
|
|
1168
|
+
valid: e.test(d.value)
|
|
1169
|
+
};
|
|
1170
|
+
|
|
1171
|
+
case !a.ipv4 && a.ipv6:
|
|
1172
|
+
return {
|
|
1173
|
+
message: d.l10n ? a.message || d.l10n.ip.ipv6 : a.message,
|
|
1174
|
+
valid: s.test(d.value)
|
|
1175
|
+
};
|
|
1176
|
+
|
|
1177
|
+
case a.ipv4 && a.ipv6:
|
|
1178
|
+
default:
|
|
1179
|
+
return {
|
|
1180
|
+
message: d.l10n ? a.message || d.l10n.ip["default"] : a.message,
|
|
1181
|
+
valid: e.test(d.value) || s.test(d.value)
|
|
1182
|
+
};
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
};
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
function s$4() {
|
|
1189
|
+
return {
|
|
1190
|
+
validate: function validate(s) {
|
|
1191
|
+
if (s.value === "") {
|
|
1192
|
+
return {
|
|
1193
|
+
valid: true
|
|
1194
|
+
};
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
var a = Object.assign({}, {
|
|
1198
|
+
inclusive: true,
|
|
1199
|
+
message: ""
|
|
1200
|
+
}, s.options);
|
|
1201
|
+
var l = parseFloat("".concat(a.max).replace(",", "."));
|
|
1202
|
+
return a.inclusive ? {
|
|
1203
|
+
message: r$2(s.l10n ? a.message || s.l10n.lessThan["default"] : a.message, "".concat(l)),
|
|
1204
|
+
valid: parseFloat(s.value) <= l
|
|
1205
|
+
} : {
|
|
1206
|
+
message: r$2(s.l10n ? a.message || s.l10n.lessThan.notInclusive : a.message, "".concat(l)),
|
|
1207
|
+
valid: parseFloat(s.value) < l
|
|
1208
|
+
};
|
|
1209
|
+
}
|
|
1210
|
+
};
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
function t$7() {
|
|
1214
|
+
return {
|
|
1215
|
+
validate: function validate(t) {
|
|
1216
|
+
var n = !!t.options && !!t.options.trim;
|
|
1217
|
+
var o = t.value;
|
|
1218
|
+
return {
|
|
1219
|
+
valid: !n && o !== "" || n && o !== "" && o.trim() !== ""
|
|
1220
|
+
};
|
|
1221
|
+
}
|
|
1222
|
+
};
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
function a$2() {
|
|
1226
|
+
return {
|
|
1227
|
+
validate: function validate(a) {
|
|
1228
|
+
if (a.value === "") {
|
|
1229
|
+
return {
|
|
1230
|
+
valid: true
|
|
1231
|
+
};
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
var e = Object.assign({}, {
|
|
1235
|
+
decimalSeparator: ".",
|
|
1236
|
+
thousandsSeparator: ""
|
|
1237
|
+
}, a.options);
|
|
1238
|
+
var t = "".concat(a.value);
|
|
1239
|
+
|
|
1240
|
+
if (t.substr(0, 1) === e.decimalSeparator) {
|
|
1241
|
+
t = "0".concat(e.decimalSeparator).concat(t.substr(1));
|
|
1242
|
+
} else if (t.substr(0, 2) === "-".concat(e.decimalSeparator)) {
|
|
1243
|
+
t = "-0".concat(e.decimalSeparator).concat(t.substr(2));
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
var r = e.decimalSeparator === "." ? "\\." : e.decimalSeparator;
|
|
1247
|
+
var s = e.thousandsSeparator === "." ? "\\." : e.thousandsSeparator;
|
|
1248
|
+
var i = new RegExp("^-?[0-9]{1,3}(".concat(s, "[0-9]{3})*(").concat(r, "[0-9]+)?$"));
|
|
1249
|
+
var o = new RegExp(s, "g");
|
|
1250
|
+
|
|
1251
|
+
if (!i.test(t)) {
|
|
1252
|
+
return {
|
|
1253
|
+
valid: false
|
|
1254
|
+
};
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
if (s) {
|
|
1258
|
+
t = t.replace(o, "");
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
if (r) {
|
|
1262
|
+
t = t.replace(r, ".");
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
var l = parseFloat(t);
|
|
1266
|
+
return {
|
|
1267
|
+
valid: !isNaN(l) && isFinite(l)
|
|
1268
|
+
};
|
|
1269
|
+
}
|
|
1270
|
+
};
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
function r$1() {
|
|
1274
|
+
return {
|
|
1275
|
+
validate: function validate(r) {
|
|
1276
|
+
return t$c(r.options.promise, [r]);
|
|
1277
|
+
}
|
|
1278
|
+
};
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
function e$7() {
|
|
1282
|
+
return {
|
|
1283
|
+
validate: function validate(e) {
|
|
1284
|
+
if (e.value === "") {
|
|
1285
|
+
return {
|
|
1286
|
+
valid: true
|
|
1287
|
+
};
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
var t = e.options.regexp;
|
|
1291
|
+
|
|
1292
|
+
if (t instanceof RegExp) {
|
|
1293
|
+
return {
|
|
1294
|
+
valid: t.test(e.value)
|
|
1295
|
+
};
|
|
1296
|
+
} else {
|
|
1297
|
+
var n = t.toString();
|
|
1298
|
+
var o = e.options.flags ? new RegExp(n, e.options.flags) : new RegExp(n);
|
|
1299
|
+
return {
|
|
1300
|
+
valid: o.test(e.value)
|
|
1301
|
+
};
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
};
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
function e$6(e, t) {
|
|
1308
|
+
var n = function n(e) {
|
|
1309
|
+
return Object.keys(e).map(function (t) {
|
|
1310
|
+
return "".concat(encodeURIComponent(t), "=").concat(encodeURIComponent(e[t]));
|
|
1311
|
+
}).join("&");
|
|
1312
|
+
};
|
|
1313
|
+
|
|
1314
|
+
return new Promise(function (o, s) {
|
|
1315
|
+
var d = Object.assign({}, {
|
|
1316
|
+
crossDomain: false,
|
|
1317
|
+
headers: {},
|
|
1318
|
+
method: "GET",
|
|
1319
|
+
params: {}
|
|
1320
|
+
}, t);
|
|
1321
|
+
var a = Object.keys(d.params).map(function (e) {
|
|
1322
|
+
return "".concat(encodeURIComponent(e), "=").concat(encodeURIComponent(d.params[e]));
|
|
1323
|
+
}).join("&");
|
|
1324
|
+
var r = e.indexOf("?");
|
|
1325
|
+
var c = "GET" === d.method ? "".concat(e).concat(r ? "?" : "&").concat(a) : e;
|
|
1326
|
+
|
|
1327
|
+
if (d.crossDomain) {
|
|
1328
|
+
var _e = document.createElement("script");
|
|
1329
|
+
|
|
1330
|
+
var _t = "___fetch".concat(Date.now(), "___");
|
|
1331
|
+
|
|
1332
|
+
window[_t] = function (e) {
|
|
1333
|
+
delete window[_t];
|
|
1334
|
+
o(e);
|
|
1335
|
+
};
|
|
1336
|
+
|
|
1337
|
+
_e.src = "".concat(c).concat(r ? "&" : "?", "callback=").concat(_t);
|
|
1338
|
+
_e.async = true;
|
|
1339
|
+
|
|
1340
|
+
_e.addEventListener("load", function () {
|
|
1341
|
+
_e.parentNode.removeChild(_e);
|
|
1342
|
+
});
|
|
1343
|
+
|
|
1344
|
+
_e.addEventListener("error", function () {
|
|
1345
|
+
return s;
|
|
1346
|
+
});
|
|
1347
|
+
|
|
1348
|
+
document.head.appendChild(_e);
|
|
1349
|
+
} else {
|
|
1350
|
+
var _e2 = new XMLHttpRequest();
|
|
1351
|
+
|
|
1352
|
+
_e2.open(d.method, c);
|
|
1353
|
+
|
|
1354
|
+
_e2.setRequestHeader("X-Requested-With", "XMLHttpRequest");
|
|
1355
|
+
|
|
1356
|
+
if ("POST" === d.method) {
|
|
1357
|
+
_e2.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
Object.keys(d.headers).forEach(function (t) {
|
|
1361
|
+
return _e2.setRequestHeader(t, d.headers[t]);
|
|
1362
|
+
});
|
|
1363
|
+
|
|
1364
|
+
_e2.addEventListener("load", function () {
|
|
1365
|
+
o(JSON.parse(this.responseText));
|
|
1366
|
+
});
|
|
1367
|
+
|
|
1368
|
+
_e2.addEventListener("error", function () {
|
|
1369
|
+
return s;
|
|
1370
|
+
});
|
|
1371
|
+
|
|
1372
|
+
_e2.send(n(d.params));
|
|
1373
|
+
}
|
|
1374
|
+
});
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1377
|
+
function a$1() {
|
|
1378
|
+
var a = {
|
|
1379
|
+
crossDomain: false,
|
|
1380
|
+
data: {},
|
|
1381
|
+
headers: {},
|
|
1382
|
+
method: "GET",
|
|
1383
|
+
validKey: "valid"
|
|
1384
|
+
};
|
|
1385
|
+
return {
|
|
1386
|
+
validate: function validate(t) {
|
|
1387
|
+
if (t.value === "") {
|
|
1388
|
+
return Promise.resolve({
|
|
1389
|
+
valid: true
|
|
1390
|
+
});
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1393
|
+
var s = Object.assign({}, a, t.options);
|
|
1394
|
+
var r = s.data;
|
|
1395
|
+
|
|
1396
|
+
if ("function" === typeof s.data) {
|
|
1397
|
+
r = s.data.call(this, t);
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1400
|
+
if ("string" === typeof r) {
|
|
1401
|
+
r = JSON.parse(r);
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1404
|
+
r[s.name || t.field] = t.value;
|
|
1405
|
+
var o = "function" === typeof s.url ? s.url.call(this, t) : s.url;
|
|
1406
|
+
return e$6(o, {
|
|
1407
|
+
crossDomain: s.crossDomain,
|
|
1408
|
+
headers: s.headers,
|
|
1409
|
+
method: s.method,
|
|
1410
|
+
params: r
|
|
1411
|
+
}).then(function (e) {
|
|
1412
|
+
return Promise.resolve({
|
|
1413
|
+
message: e["message"],
|
|
1414
|
+
meta: e,
|
|
1415
|
+
valid: "".concat(e[s.validKey]) === "true"
|
|
1416
|
+
});
|
|
1417
|
+
})["catch"](function (e) {
|
|
1418
|
+
return Promise.reject({
|
|
1419
|
+
valid: false
|
|
1420
|
+
});
|
|
1421
|
+
});
|
|
1422
|
+
}
|
|
1423
|
+
};
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1426
|
+
function e$5() {
|
|
1427
|
+
return {
|
|
1428
|
+
validate: function validate(e) {
|
|
1429
|
+
if (e.value === "") {
|
|
1430
|
+
return {
|
|
1431
|
+
valid: true
|
|
1432
|
+
};
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
var a = Object.assign({}, {
|
|
1436
|
+
"case": "lower"
|
|
1437
|
+
}, e.options);
|
|
1438
|
+
var s = (a["case"] || "lower").toLowerCase();
|
|
1439
|
+
return {
|
|
1440
|
+
message: a.message || (e.l10n ? "upper" === s ? e.l10n.stringCase.upper : e.l10n.stringCase["default"] : a.message),
|
|
1441
|
+
valid: "upper" === s ? e.value === e.value.toUpperCase() : e.value === e.value.toLowerCase()
|
|
1442
|
+
};
|
|
1443
|
+
}
|
|
1444
|
+
};
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
function t$6() {
|
|
1448
|
+
var t = function t(e) {
|
|
1449
|
+
var t = e.length;
|
|
1450
|
+
|
|
1451
|
+
for (var s = e.length - 1; s >= 0; s--) {
|
|
1452
|
+
var n = e.charCodeAt(s);
|
|
1453
|
+
|
|
1454
|
+
if (n > 127 && n <= 2047) {
|
|
1455
|
+
t++;
|
|
1456
|
+
} else if (n > 2047 && n <= 65535) {
|
|
1457
|
+
t += 2;
|
|
1458
|
+
}
|
|
1459
|
+
|
|
1460
|
+
if (n >= 56320 && n <= 57343) {
|
|
1461
|
+
s--;
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1465
|
+
return "".concat(t);
|
|
1466
|
+
};
|
|
1467
|
+
|
|
1468
|
+
return {
|
|
1469
|
+
validate: function validate(s) {
|
|
1470
|
+
var n = Object.assign({}, {
|
|
1471
|
+
message: "",
|
|
1472
|
+
trim: false,
|
|
1473
|
+
utf8Bytes: false
|
|
1474
|
+
}, s.options);
|
|
1475
|
+
var a = n.trim === true || "".concat(n.trim) === "true" ? s.value.trim() : s.value;
|
|
1476
|
+
|
|
1477
|
+
if (a === "") {
|
|
1478
|
+
return {
|
|
1479
|
+
valid: true
|
|
1480
|
+
};
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1483
|
+
var r = n.min ? "".concat(n.min) : "";
|
|
1484
|
+
var l = n.max ? "".concat(n.max) : "";
|
|
1485
|
+
var i = n.utf8Bytes ? t(a) : a.length;
|
|
1486
|
+
var g = true;
|
|
1487
|
+
var m = s.l10n ? n.message || s.l10n.stringLength["default"] : n.message;
|
|
1488
|
+
|
|
1489
|
+
if (r && i < parseInt(r, 10) || l && i > parseInt(l, 10)) {
|
|
1490
|
+
g = false;
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
switch (true) {
|
|
1494
|
+
case !!r && !!l:
|
|
1495
|
+
m = r$2(s.l10n ? n.message || s.l10n.stringLength.between : n.message, [r, l]);
|
|
1496
|
+
break;
|
|
1497
|
+
|
|
1498
|
+
case !!r:
|
|
1499
|
+
m = r$2(s.l10n ? n.message || s.l10n.stringLength.more : n.message, "".concat(parseInt(r, 10)));
|
|
1500
|
+
break;
|
|
1501
|
+
|
|
1502
|
+
case !!l:
|
|
1503
|
+
m = r$2(s.l10n ? n.message || s.l10n.stringLength.less : n.message, "".concat(parseInt(l, 10)));
|
|
1504
|
+
break;
|
|
1505
|
+
}
|
|
1506
|
+
|
|
1507
|
+
return {
|
|
1508
|
+
message: m,
|
|
1509
|
+
valid: g
|
|
1510
|
+
};
|
|
1511
|
+
}
|
|
1512
|
+
};
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
function t$5() {
|
|
1516
|
+
var t = {
|
|
1517
|
+
allowEmptyProtocol: false,
|
|
1518
|
+
allowLocal: false,
|
|
1519
|
+
protocol: "http, https, ftp"
|
|
1520
|
+
};
|
|
1521
|
+
return {
|
|
1522
|
+
validate: function validate(o) {
|
|
1523
|
+
if (o.value === "") {
|
|
1524
|
+
return {
|
|
1525
|
+
valid: true
|
|
1526
|
+
};
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1529
|
+
var a = Object.assign({}, t, o.options);
|
|
1530
|
+
var l = a.allowLocal === true || "".concat(a.allowLocal) === "true";
|
|
1531
|
+
var f = a.allowEmptyProtocol === true || "".concat(a.allowEmptyProtocol) === "true";
|
|
1532
|
+
var u = a.protocol.split(",").join("|").replace(/\s/g, "");
|
|
1533
|
+
var e = new RegExp("^" + "(?:(?:" + u + ")://)" + (f ? "?" : "") + "(?:\\S+(?::\\S*)?@)?" + "(?:" + (l ? "" : "(?!(?:10|127)(?:\\.\\d{1,3}){3})" + "(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})" + "(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})") + "(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])" + "(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}" + "(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))" + "|" + "(?:(?:[a-z\\u00a1-\\uffff0-9]-?)*[a-z\\u00a1-\\uffff0-9]+)" + "(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-?)*[a-z\\u00a1-\\uffff0-9])*" + "(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))" + (l ? "?" : "") + ")" + "(?::\\d{2,5})?" + "(?:/[^\\s]*)?$", "i");
|
|
1534
|
+
return {
|
|
1535
|
+
valid: e.test(o.value)
|
|
1536
|
+
};
|
|
1537
|
+
}
|
|
1538
|
+
};
|
|
1539
|
+
}
|
|
1540
|
+
|
|
1541
|
+
var s$3 = {
|
|
1542
|
+
between: s$5,
|
|
1543
|
+
blank: t$d,
|
|
1544
|
+
callback: o$3,
|
|
1545
|
+
choice: t$b,
|
|
1546
|
+
creditCard: l$2,
|
|
1547
|
+
date: n,
|
|
1548
|
+
different: o$2,
|
|
1549
|
+
digits: e$9,
|
|
1550
|
+
emailAddress: t$8,
|
|
1551
|
+
file: e$8,
|
|
1552
|
+
greaterThan: a$4,
|
|
1553
|
+
identical: o$1,
|
|
1554
|
+
integer: a$3,
|
|
1555
|
+
ip: d,
|
|
1556
|
+
lessThan: s$4,
|
|
1557
|
+
notEmpty: t$7,
|
|
1558
|
+
numeric: a$2,
|
|
1559
|
+
promise: r$1,
|
|
1560
|
+
regexp: e$7,
|
|
1561
|
+
remote: a$1,
|
|
1562
|
+
stringCase: e$5,
|
|
1563
|
+
stringLength: t$6,
|
|
1564
|
+
uri: t$5
|
|
1565
|
+
};
|
|
1566
|
+
|
|
1567
|
+
var l$1 = /*#__PURE__*/function () {
|
|
1568
|
+
function l(i, s) {
|
|
1569
|
+
_classCallCheck(this, l);
|
|
1570
|
+
|
|
1571
|
+
this.elements = {};
|
|
1572
|
+
this.ee = s$6();
|
|
1573
|
+
this.filter = t$e();
|
|
1574
|
+
this.plugins = {};
|
|
1575
|
+
this.results = new Map();
|
|
1576
|
+
this.validators = {};
|
|
1577
|
+
this.form = i;
|
|
1578
|
+
this.fields = s;
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1581
|
+
_createClass(l, [{
|
|
1582
|
+
key: "on",
|
|
1583
|
+
value: function on(e, t) {
|
|
1584
|
+
this.ee.on(e, t);
|
|
1585
|
+
return this;
|
|
1586
|
+
}
|
|
1587
|
+
}, {
|
|
1588
|
+
key: "off",
|
|
1589
|
+
value: function off(e, t) {
|
|
1590
|
+
this.ee.off(e, t);
|
|
1591
|
+
return this;
|
|
1592
|
+
}
|
|
1593
|
+
}, {
|
|
1594
|
+
key: "emit",
|
|
1595
|
+
value: function emit(e) {
|
|
1596
|
+
var _this$ee;
|
|
1597
|
+
|
|
1598
|
+
for (var _len = arguments.length, t = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
1599
|
+
t[_key - 1] = arguments[_key];
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1602
|
+
(_this$ee = this.ee).emit.apply(_this$ee, [e].concat(t));
|
|
1603
|
+
|
|
1604
|
+
return this;
|
|
1605
|
+
}
|
|
1606
|
+
}, {
|
|
1607
|
+
key: "registerPlugin",
|
|
1608
|
+
value: function registerPlugin(e, t) {
|
|
1609
|
+
if (this.plugins[e]) {
|
|
1610
|
+
throw new Error("The plguin ".concat(e, " is registered"));
|
|
1611
|
+
}
|
|
1612
|
+
|
|
1613
|
+
t.setCore(this);
|
|
1614
|
+
t.install();
|
|
1615
|
+
this.plugins[e] = t;
|
|
1616
|
+
return this;
|
|
1617
|
+
}
|
|
1618
|
+
}, {
|
|
1619
|
+
key: "deregisterPlugin",
|
|
1620
|
+
value: function deregisterPlugin(e) {
|
|
1621
|
+
var t = this.plugins[e];
|
|
1622
|
+
|
|
1623
|
+
if (t) {
|
|
1624
|
+
t.uninstall();
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1627
|
+
delete this.plugins[e];
|
|
1628
|
+
return this;
|
|
1629
|
+
}
|
|
1630
|
+
}, {
|
|
1631
|
+
key: "registerValidator",
|
|
1632
|
+
value: function registerValidator(e, t) {
|
|
1633
|
+
if (this.validators[e]) {
|
|
1634
|
+
throw new Error("The validator ".concat(e, " is registered"));
|
|
1635
|
+
}
|
|
1636
|
+
|
|
1637
|
+
this.validators[e] = t;
|
|
1638
|
+
return this;
|
|
1639
|
+
}
|
|
1640
|
+
}, {
|
|
1641
|
+
key: "registerFilter",
|
|
1642
|
+
value: function registerFilter(e, t) {
|
|
1643
|
+
this.filter.add(e, t);
|
|
1644
|
+
return this;
|
|
1645
|
+
}
|
|
1646
|
+
}, {
|
|
1647
|
+
key: "deregisterFilter",
|
|
1648
|
+
value: function deregisterFilter(e, t) {
|
|
1649
|
+
this.filter.remove(e, t);
|
|
1650
|
+
return this;
|
|
1651
|
+
}
|
|
1652
|
+
}, {
|
|
1653
|
+
key: "executeFilter",
|
|
1654
|
+
value: function executeFilter(e, t, i) {
|
|
1655
|
+
return this.filter.execute(e, t, i);
|
|
1656
|
+
}
|
|
1657
|
+
}, {
|
|
1658
|
+
key: "addField",
|
|
1659
|
+
value: function addField(e, t) {
|
|
1660
|
+
var i = Object.assign({}, {
|
|
1661
|
+
selector: "",
|
|
1662
|
+
validators: {}
|
|
1663
|
+
}, t);
|
|
1664
|
+
this.fields[e] = this.fields[e] ? {
|
|
1665
|
+
selector: i.selector || this.fields[e].selector,
|
|
1666
|
+
validators: Object.assign({}, this.fields[e].validators, i.validators)
|
|
1667
|
+
} : i;
|
|
1668
|
+
this.elements[e] = this.queryElements(e);
|
|
1669
|
+
this.emit("core.field.added", {
|
|
1670
|
+
elements: this.elements[e],
|
|
1671
|
+
field: e,
|
|
1672
|
+
options: this.fields[e]
|
|
1673
|
+
});
|
|
1674
|
+
return this;
|
|
1675
|
+
}
|
|
1676
|
+
}, {
|
|
1677
|
+
key: "removeField",
|
|
1678
|
+
value: function removeField(e) {
|
|
1679
|
+
if (!this.fields[e]) {
|
|
1680
|
+
throw new Error("The field ".concat(e, " validators are not defined. Please ensure the field is added first"));
|
|
1681
|
+
}
|
|
1682
|
+
|
|
1683
|
+
var t = this.elements[e];
|
|
1684
|
+
var i = this.fields[e];
|
|
1685
|
+
delete this.elements[e];
|
|
1686
|
+
delete this.fields[e];
|
|
1687
|
+
this.emit("core.field.removed", {
|
|
1688
|
+
elements: t,
|
|
1689
|
+
field: e,
|
|
1690
|
+
options: i
|
|
1691
|
+
});
|
|
1692
|
+
return this;
|
|
1693
|
+
}
|
|
1694
|
+
}, {
|
|
1695
|
+
key: "validate",
|
|
1696
|
+
value: function validate() {
|
|
1697
|
+
var _this = this;
|
|
1698
|
+
|
|
1699
|
+
this.emit("core.form.validating", {
|
|
1700
|
+
formValidation: this
|
|
1701
|
+
});
|
|
1702
|
+
return this.filter.execute("validate-pre", Promise.resolve(), []).then(function () {
|
|
1703
|
+
return Promise.all(Object.keys(_this.fields).map(function (e) {
|
|
1704
|
+
return _this.validateField(e);
|
|
1705
|
+
})).then(function (e) {
|
|
1706
|
+
switch (true) {
|
|
1707
|
+
case e.indexOf("Invalid") !== -1:
|
|
1708
|
+
_this.emit("core.form.invalid", {
|
|
1709
|
+
formValidation: _this
|
|
1710
|
+
});
|
|
1711
|
+
|
|
1712
|
+
return Promise.resolve("Invalid");
|
|
1713
|
+
|
|
1714
|
+
case e.indexOf("NotValidated") !== -1:
|
|
1715
|
+
_this.emit("core.form.notvalidated", {
|
|
1716
|
+
formValidation: _this
|
|
1717
|
+
});
|
|
1718
|
+
|
|
1719
|
+
return Promise.resolve("NotValidated");
|
|
1720
|
+
|
|
1721
|
+
default:
|
|
1722
|
+
_this.emit("core.form.valid", {
|
|
1723
|
+
formValidation: _this
|
|
1724
|
+
});
|
|
1725
|
+
|
|
1726
|
+
return Promise.resolve("Valid");
|
|
1727
|
+
}
|
|
1728
|
+
});
|
|
1729
|
+
});
|
|
1730
|
+
}
|
|
1731
|
+
}, {
|
|
1732
|
+
key: "validateField",
|
|
1733
|
+
value: function validateField(e) {
|
|
1734
|
+
var _this2 = this;
|
|
1735
|
+
|
|
1736
|
+
var t = this.results.get(e);
|
|
1737
|
+
|
|
1738
|
+
if (t === "Valid" || t === "Invalid") {
|
|
1739
|
+
return Promise.resolve(t);
|
|
1740
|
+
}
|
|
1741
|
+
|
|
1742
|
+
this.emit("core.field.validating", e);
|
|
1743
|
+
var i = this.elements[e];
|
|
1744
|
+
|
|
1745
|
+
if (i.length === 0) {
|
|
1746
|
+
this.emit("core.field.valid", e);
|
|
1747
|
+
return Promise.resolve("Valid");
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
var s = i[0].getAttribute("type");
|
|
1751
|
+
|
|
1752
|
+
if ("radio" === s || "checkbox" === s || i.length === 1) {
|
|
1753
|
+
return this.validateElement(e, i[0]);
|
|
1754
|
+
} else {
|
|
1755
|
+
return Promise.all(i.map(function (t) {
|
|
1756
|
+
return _this2.validateElement(e, t);
|
|
1757
|
+
})).then(function (t) {
|
|
1758
|
+
switch (true) {
|
|
1759
|
+
case t.indexOf("Invalid") !== -1:
|
|
1760
|
+
_this2.emit("core.field.invalid", e);
|
|
1761
|
+
|
|
1762
|
+
_this2.results.set(e, "Invalid");
|
|
1763
|
+
|
|
1764
|
+
return Promise.resolve("Invalid");
|
|
1765
|
+
|
|
1766
|
+
case t.indexOf("NotValidated") !== -1:
|
|
1767
|
+
_this2.emit("core.field.notvalidated", e);
|
|
1768
|
+
|
|
1769
|
+
_this2.results["delete"](e);
|
|
1770
|
+
|
|
1771
|
+
return Promise.resolve("NotValidated");
|
|
1772
|
+
|
|
1773
|
+
default:
|
|
1774
|
+
_this2.emit("core.field.valid", e);
|
|
1775
|
+
|
|
1776
|
+
_this2.results.set(e, "Valid");
|
|
1777
|
+
|
|
1778
|
+
return Promise.resolve("Valid");
|
|
1779
|
+
}
|
|
1780
|
+
});
|
|
1781
|
+
}
|
|
1782
|
+
}
|
|
1783
|
+
}, {
|
|
1784
|
+
key: "validateElement",
|
|
1785
|
+
value: function validateElement(e, t) {
|
|
1786
|
+
var _this3 = this;
|
|
1787
|
+
|
|
1788
|
+
this.results["delete"](e);
|
|
1789
|
+
var i = this.elements[e];
|
|
1790
|
+
var s = this.filter.execute("element-ignored", false, [e, t, i]);
|
|
1791
|
+
|
|
1792
|
+
if (s) {
|
|
1793
|
+
this.emit("core.element.ignored", {
|
|
1794
|
+
element: t,
|
|
1795
|
+
elements: i,
|
|
1796
|
+
field: e
|
|
1797
|
+
});
|
|
1798
|
+
return Promise.resolve("Ignored");
|
|
1799
|
+
}
|
|
1800
|
+
|
|
1801
|
+
var _l = this.fields[e].validators;
|
|
1802
|
+
this.emit("core.element.validating", {
|
|
1803
|
+
element: t,
|
|
1804
|
+
elements: i,
|
|
1805
|
+
field: e
|
|
1806
|
+
});
|
|
1807
|
+
var r = Object.keys(_l).map(function (i) {
|
|
1808
|
+
return function () {
|
|
1809
|
+
return _this3.executeValidator(e, t, i, _l[i]);
|
|
1810
|
+
};
|
|
1811
|
+
});
|
|
1812
|
+
return this.waterfall(r).then(function (s) {
|
|
1813
|
+
var _l2 = s.indexOf("Invalid") === -1;
|
|
1814
|
+
|
|
1815
|
+
_this3.emit("core.element.validated", {
|
|
1816
|
+
element: t,
|
|
1817
|
+
elements: i,
|
|
1818
|
+
field: e,
|
|
1819
|
+
valid: _l2
|
|
1820
|
+
});
|
|
1821
|
+
|
|
1822
|
+
var r = t.getAttribute("type");
|
|
1823
|
+
|
|
1824
|
+
if ("radio" === r || "checkbox" === r || i.length === 1) {
|
|
1825
|
+
_this3.emit(_l2 ? "core.field.valid" : "core.field.invalid", e);
|
|
1826
|
+
}
|
|
1827
|
+
|
|
1828
|
+
return Promise.resolve(_l2 ? "Valid" : "Invalid");
|
|
1829
|
+
})["catch"](function (s) {
|
|
1830
|
+
_this3.emit("core.element.notvalidated", {
|
|
1831
|
+
element: t,
|
|
1832
|
+
elements: i,
|
|
1833
|
+
field: e
|
|
1834
|
+
});
|
|
1835
|
+
|
|
1836
|
+
return Promise.resolve(s);
|
|
1837
|
+
});
|
|
1838
|
+
}
|
|
1839
|
+
}, {
|
|
1840
|
+
key: "executeValidator",
|
|
1841
|
+
value: function executeValidator(e, t, i, s) {
|
|
1842
|
+
var _this4 = this;
|
|
1843
|
+
|
|
1844
|
+
var _l3 = this.elements[e];
|
|
1845
|
+
var r = this.filter.execute("validator-name", i, [i, e]);
|
|
1846
|
+
s.message = this.filter.execute("validator-message", s.message, [this.locale, e, r]);
|
|
1847
|
+
|
|
1848
|
+
if (!this.validators[r] || s.enabled === false) {
|
|
1849
|
+
this.emit("core.validator.validated", {
|
|
1850
|
+
element: t,
|
|
1851
|
+
elements: _l3,
|
|
1852
|
+
field: e,
|
|
1853
|
+
result: this.normalizeResult(e, r, {
|
|
1854
|
+
valid: true
|
|
1855
|
+
}),
|
|
1856
|
+
validator: r
|
|
1857
|
+
});
|
|
1858
|
+
return Promise.resolve("Valid");
|
|
1859
|
+
}
|
|
1860
|
+
|
|
1861
|
+
var a = this.validators[r];
|
|
1862
|
+
var d = this.getElementValue(e, t, r);
|
|
1863
|
+
var o = this.filter.execute("field-should-validate", true, [e, t, d, i]);
|
|
1864
|
+
|
|
1865
|
+
if (!o) {
|
|
1866
|
+
this.emit("core.validator.notvalidated", {
|
|
1867
|
+
element: t,
|
|
1868
|
+
elements: _l3,
|
|
1869
|
+
field: e,
|
|
1870
|
+
validator: i
|
|
1871
|
+
});
|
|
1872
|
+
return Promise.resolve("NotValidated");
|
|
1873
|
+
}
|
|
1874
|
+
|
|
1875
|
+
this.emit("core.validator.validating", {
|
|
1876
|
+
element: t,
|
|
1877
|
+
elements: _l3,
|
|
1878
|
+
field: e,
|
|
1879
|
+
validator: i
|
|
1880
|
+
});
|
|
1881
|
+
var n = a().validate({
|
|
1882
|
+
element: t,
|
|
1883
|
+
elements: _l3,
|
|
1884
|
+
field: e,
|
|
1885
|
+
l10n: this.localization,
|
|
1886
|
+
options: s,
|
|
1887
|
+
value: d
|
|
1888
|
+
});
|
|
1889
|
+
var h = "function" === typeof n["then"];
|
|
1890
|
+
|
|
1891
|
+
if (h) {
|
|
1892
|
+
return n.then(function (s) {
|
|
1893
|
+
var r = _this4.normalizeResult(e, i, s);
|
|
1894
|
+
|
|
1895
|
+
_this4.emit("core.validator.validated", {
|
|
1896
|
+
element: t,
|
|
1897
|
+
elements: _l3,
|
|
1898
|
+
field: e,
|
|
1899
|
+
result: r,
|
|
1900
|
+
validator: i
|
|
1901
|
+
});
|
|
1902
|
+
|
|
1903
|
+
return r.valid ? "Valid" : "Invalid";
|
|
1904
|
+
});
|
|
1905
|
+
} else {
|
|
1906
|
+
var _s = this.normalizeResult(e, i, n);
|
|
1907
|
+
|
|
1908
|
+
this.emit("core.validator.validated", {
|
|
1909
|
+
element: t,
|
|
1910
|
+
elements: _l3,
|
|
1911
|
+
field: e,
|
|
1912
|
+
result: _s,
|
|
1913
|
+
validator: i
|
|
1914
|
+
});
|
|
1915
|
+
return Promise.resolve(_s.valid ? "Valid" : "Invalid");
|
|
1916
|
+
}
|
|
1917
|
+
}
|
|
1918
|
+
}, {
|
|
1919
|
+
key: "getElementValue",
|
|
1920
|
+
value: function getElementValue(e, t, s) {
|
|
1921
|
+
var _l4 = e$a(this.form, e, t, this.elements[e]);
|
|
1922
|
+
|
|
1923
|
+
return this.filter.execute("field-value", _l4, [_l4, e, t, s]);
|
|
1924
|
+
}
|
|
1925
|
+
}, {
|
|
1926
|
+
key: "getElements",
|
|
1927
|
+
value: function getElements(e) {
|
|
1928
|
+
return this.elements[e];
|
|
1929
|
+
}
|
|
1930
|
+
}, {
|
|
1931
|
+
key: "getFields",
|
|
1932
|
+
value: function getFields() {
|
|
1933
|
+
return this.fields;
|
|
1934
|
+
}
|
|
1935
|
+
}, {
|
|
1936
|
+
key: "getFormElement",
|
|
1937
|
+
value: function getFormElement() {
|
|
1938
|
+
return this.form;
|
|
1939
|
+
}
|
|
1940
|
+
}, {
|
|
1941
|
+
key: "getLocale",
|
|
1942
|
+
value: function getLocale() {
|
|
1943
|
+
return this.locale;
|
|
1944
|
+
}
|
|
1945
|
+
}, {
|
|
1946
|
+
key: "getPlugin",
|
|
1947
|
+
value: function getPlugin(e) {
|
|
1948
|
+
return this.plugins[e];
|
|
1949
|
+
}
|
|
1950
|
+
}, {
|
|
1951
|
+
key: "updateFieldStatus",
|
|
1952
|
+
value: function updateFieldStatus(e, t, i) {
|
|
1953
|
+
var _this5 = this;
|
|
1954
|
+
|
|
1955
|
+
var s = this.elements[e];
|
|
1956
|
+
|
|
1957
|
+
var _l5 = s[0].getAttribute("type");
|
|
1958
|
+
|
|
1959
|
+
var r = "radio" === _l5 || "checkbox" === _l5 ? [s[0]] : s;
|
|
1960
|
+
r.forEach(function (s) {
|
|
1961
|
+
return _this5.updateElementStatus(e, s, t, i);
|
|
1962
|
+
});
|
|
1963
|
+
|
|
1964
|
+
if (!i) {
|
|
1965
|
+
switch (t) {
|
|
1966
|
+
case "NotValidated":
|
|
1967
|
+
this.emit("core.field.notvalidated", e);
|
|
1968
|
+
this.results["delete"](e);
|
|
1969
|
+
break;
|
|
1970
|
+
|
|
1971
|
+
case "Validating":
|
|
1972
|
+
this.emit("core.field.validating", e);
|
|
1973
|
+
this.results["delete"](e);
|
|
1974
|
+
break;
|
|
1975
|
+
|
|
1976
|
+
case "Valid":
|
|
1977
|
+
this.emit("core.field.valid", e);
|
|
1978
|
+
this.results.set(e, "Valid");
|
|
1979
|
+
break;
|
|
1980
|
+
|
|
1981
|
+
case "Invalid":
|
|
1982
|
+
this.emit("core.field.invalid", e);
|
|
1983
|
+
this.results.set(e, "Invalid");
|
|
1984
|
+
break;
|
|
1985
|
+
}
|
|
1986
|
+
}
|
|
1987
|
+
|
|
1988
|
+
return this;
|
|
1989
|
+
}
|
|
1990
|
+
}, {
|
|
1991
|
+
key: "updateElementStatus",
|
|
1992
|
+
value: function updateElementStatus(e, t, i, s) {
|
|
1993
|
+
var _this6 = this;
|
|
1994
|
+
|
|
1995
|
+
var _l6 = this.elements[e];
|
|
1996
|
+
var r = this.fields[e].validators;
|
|
1997
|
+
var a = s ? [s] : Object.keys(r);
|
|
1998
|
+
|
|
1999
|
+
switch (i) {
|
|
2000
|
+
case "NotValidated":
|
|
2001
|
+
a.forEach(function (i) {
|
|
2002
|
+
return _this6.emit("core.validator.notvalidated", {
|
|
2003
|
+
element: t,
|
|
2004
|
+
elements: _l6,
|
|
2005
|
+
field: e,
|
|
2006
|
+
validator: i
|
|
2007
|
+
});
|
|
2008
|
+
});
|
|
2009
|
+
this.emit("core.element.notvalidated", {
|
|
2010
|
+
element: t,
|
|
2011
|
+
elements: _l6,
|
|
2012
|
+
field: e
|
|
2013
|
+
});
|
|
2014
|
+
break;
|
|
2015
|
+
|
|
2016
|
+
case "Validating":
|
|
2017
|
+
a.forEach(function (i) {
|
|
2018
|
+
return _this6.emit("core.validator.validating", {
|
|
2019
|
+
element: t,
|
|
2020
|
+
elements: _l6,
|
|
2021
|
+
field: e,
|
|
2022
|
+
validator: i
|
|
2023
|
+
});
|
|
2024
|
+
});
|
|
2025
|
+
this.emit("core.element.validating", {
|
|
2026
|
+
element: t,
|
|
2027
|
+
elements: _l6,
|
|
2028
|
+
field: e
|
|
2029
|
+
});
|
|
2030
|
+
break;
|
|
2031
|
+
|
|
2032
|
+
case "Valid":
|
|
2033
|
+
a.forEach(function (i) {
|
|
2034
|
+
return _this6.emit("core.validator.validated", {
|
|
2035
|
+
element: t,
|
|
2036
|
+
elements: _l6,
|
|
2037
|
+
field: e,
|
|
2038
|
+
result: {
|
|
2039
|
+
message: r[i].message,
|
|
2040
|
+
valid: true
|
|
2041
|
+
},
|
|
2042
|
+
validator: i
|
|
2043
|
+
});
|
|
2044
|
+
});
|
|
2045
|
+
this.emit("core.element.validated", {
|
|
2046
|
+
element: t,
|
|
2047
|
+
elements: _l6,
|
|
2048
|
+
field: e,
|
|
2049
|
+
valid: true
|
|
2050
|
+
});
|
|
2051
|
+
break;
|
|
2052
|
+
|
|
2053
|
+
case "Invalid":
|
|
2054
|
+
a.forEach(function (i) {
|
|
2055
|
+
return _this6.emit("core.validator.validated", {
|
|
2056
|
+
element: t,
|
|
2057
|
+
elements: _l6,
|
|
2058
|
+
field: e,
|
|
2059
|
+
result: {
|
|
2060
|
+
message: r[i].message,
|
|
2061
|
+
valid: false
|
|
2062
|
+
},
|
|
2063
|
+
validator: i
|
|
2064
|
+
});
|
|
2065
|
+
});
|
|
2066
|
+
this.emit("core.element.validated", {
|
|
2067
|
+
element: t,
|
|
2068
|
+
elements: _l6,
|
|
2069
|
+
field: e,
|
|
2070
|
+
valid: false
|
|
2071
|
+
});
|
|
2072
|
+
break;
|
|
2073
|
+
}
|
|
2074
|
+
|
|
2075
|
+
return this;
|
|
2076
|
+
}
|
|
2077
|
+
}, {
|
|
2078
|
+
key: "resetForm",
|
|
2079
|
+
value: function resetForm(e) {
|
|
2080
|
+
var _this7 = this;
|
|
2081
|
+
|
|
2082
|
+
Object.keys(this.fields).forEach(function (t) {
|
|
2083
|
+
return _this7.resetField(t, e);
|
|
2084
|
+
});
|
|
2085
|
+
this.emit("core.form.reset", {
|
|
2086
|
+
formValidation: this,
|
|
2087
|
+
reset: e
|
|
2088
|
+
});
|
|
2089
|
+
return this;
|
|
2090
|
+
}
|
|
2091
|
+
}, {
|
|
2092
|
+
key: "resetField",
|
|
2093
|
+
value: function resetField(e, t) {
|
|
2094
|
+
if (t) {
|
|
2095
|
+
var _t = this.elements[e];
|
|
2096
|
+
|
|
2097
|
+
var _i = _t[0].getAttribute("type");
|
|
2098
|
+
|
|
2099
|
+
_t.forEach(function (e) {
|
|
2100
|
+
if ("radio" === _i || "checkbox" === _i) {
|
|
2101
|
+
e.removeAttribute("selected");
|
|
2102
|
+
e.removeAttribute("checked");
|
|
2103
|
+
e.checked = false;
|
|
2104
|
+
} else {
|
|
2105
|
+
e.setAttribute("value", "");
|
|
2106
|
+
|
|
2107
|
+
if (e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement) {
|
|
2108
|
+
e.value = "";
|
|
2109
|
+
}
|
|
2110
|
+
}
|
|
2111
|
+
});
|
|
2112
|
+
}
|
|
2113
|
+
|
|
2114
|
+
this.updateFieldStatus(e, "NotValidated");
|
|
2115
|
+
this.emit("core.field.reset", {
|
|
2116
|
+
field: e,
|
|
2117
|
+
reset: t
|
|
2118
|
+
});
|
|
2119
|
+
return this;
|
|
2120
|
+
}
|
|
2121
|
+
}, {
|
|
2122
|
+
key: "revalidateField",
|
|
2123
|
+
value: function revalidateField(e) {
|
|
2124
|
+
this.updateFieldStatus(e, "NotValidated");
|
|
2125
|
+
return this.validateField(e);
|
|
2126
|
+
}
|
|
2127
|
+
}, {
|
|
2128
|
+
key: "disableValidator",
|
|
2129
|
+
value: function disableValidator(e, t) {
|
|
2130
|
+
return this.toggleValidator(false, e, t);
|
|
2131
|
+
}
|
|
2132
|
+
}, {
|
|
2133
|
+
key: "enableValidator",
|
|
2134
|
+
value: function enableValidator(e, t) {
|
|
2135
|
+
return this.toggleValidator(true, e, t);
|
|
2136
|
+
}
|
|
2137
|
+
}, {
|
|
2138
|
+
key: "updateValidatorOption",
|
|
2139
|
+
value: function updateValidatorOption(e, t, i, s) {
|
|
2140
|
+
if (this.fields[e] && this.fields[e].validators && this.fields[e].validators[t]) {
|
|
2141
|
+
this.fields[e].validators[t][i] = s;
|
|
2142
|
+
}
|
|
2143
|
+
|
|
2144
|
+
return this;
|
|
2145
|
+
}
|
|
2146
|
+
}, {
|
|
2147
|
+
key: "setFieldOptions",
|
|
2148
|
+
value: function setFieldOptions(e, t) {
|
|
2149
|
+
this.fields[e] = t;
|
|
2150
|
+
return this;
|
|
2151
|
+
}
|
|
2152
|
+
}, {
|
|
2153
|
+
key: "destroy",
|
|
2154
|
+
value: function destroy() {
|
|
2155
|
+
var _this8 = this;
|
|
2156
|
+
|
|
2157
|
+
Object.keys(this.plugins).forEach(function (e) {
|
|
2158
|
+
return _this8.plugins[e].uninstall();
|
|
2159
|
+
});
|
|
2160
|
+
this.ee.clear();
|
|
2161
|
+
this.filter.clear();
|
|
2162
|
+
this.results.clear();
|
|
2163
|
+
this.plugins = {};
|
|
2164
|
+
return this;
|
|
2165
|
+
}
|
|
2166
|
+
}, {
|
|
2167
|
+
key: "setLocale",
|
|
2168
|
+
value: function setLocale(e, t) {
|
|
2169
|
+
this.locale = e;
|
|
2170
|
+
this.localization = t;
|
|
2171
|
+
return this;
|
|
2172
|
+
}
|
|
2173
|
+
}, {
|
|
2174
|
+
key: "waterfall",
|
|
2175
|
+
value: function waterfall(e) {
|
|
2176
|
+
return e.reduce(function (e, t) {
|
|
2177
|
+
return e.then(function (e) {
|
|
2178
|
+
return t().then(function (t) {
|
|
2179
|
+
e.push(t);
|
|
2180
|
+
return e;
|
|
2181
|
+
});
|
|
2182
|
+
});
|
|
2183
|
+
}, Promise.resolve([]));
|
|
2184
|
+
}
|
|
2185
|
+
}, {
|
|
2186
|
+
key: "queryElements",
|
|
2187
|
+
value: function queryElements(e) {
|
|
2188
|
+
var t = this.fields[e].selector ? "#" === this.fields[e].selector.charAt(0) ? "[id=\"".concat(this.fields[e].selector.substring(1), "\"]") : this.fields[e].selector : "[name=\"".concat(e, "\"]");
|
|
2189
|
+
return [].slice.call(this.form.querySelectorAll(t));
|
|
2190
|
+
}
|
|
2191
|
+
}, {
|
|
2192
|
+
key: "normalizeResult",
|
|
2193
|
+
value: function normalizeResult(e, t, i) {
|
|
2194
|
+
var s = this.fields[e].validators[t];
|
|
2195
|
+
return Object.assign({}, i, {
|
|
2196
|
+
message: i.message || (s ? s.message : "") || (this.localization && this.localization[t] && this.localization[t]["default"] ? this.localization[t]["default"] : "") || "The field ".concat(e, " is not valid")
|
|
2197
|
+
});
|
|
2198
|
+
}
|
|
2199
|
+
}, {
|
|
2200
|
+
key: "toggleValidator",
|
|
2201
|
+
value: function toggleValidator(e, t, i) {
|
|
2202
|
+
var _this9 = this;
|
|
2203
|
+
|
|
2204
|
+
var s = this.fields[t].validators;
|
|
2205
|
+
|
|
2206
|
+
if (i && s && s[i]) {
|
|
2207
|
+
this.fields[t].validators[i].enabled = e;
|
|
2208
|
+
} else if (!i) {
|
|
2209
|
+
Object.keys(s).forEach(function (i) {
|
|
2210
|
+
return _this9.fields[t].validators[i].enabled = e;
|
|
2211
|
+
});
|
|
2212
|
+
}
|
|
2213
|
+
|
|
2214
|
+
return this.updateFieldStatus(t, "NotValidated", i);
|
|
2215
|
+
}
|
|
2216
|
+
}]);
|
|
2217
|
+
|
|
2218
|
+
return l;
|
|
2219
|
+
}();
|
|
2220
|
+
|
|
2221
|
+
function r(e, t) {
|
|
2222
|
+
var i = Object.assign({}, {
|
|
2223
|
+
fields: {},
|
|
2224
|
+
locale: "en_US",
|
|
2225
|
+
plugins: {},
|
|
2226
|
+
init: function init(e) {}
|
|
2227
|
+
}, t);
|
|
2228
|
+
var r = new l$1(e, i.fields);
|
|
2229
|
+
r.setLocale(i.locale, i.localization);
|
|
2230
|
+
Object.keys(i.plugins).forEach(function (e) {
|
|
2231
|
+
return r.registerPlugin(e, i.plugins[e]);
|
|
2232
|
+
});
|
|
2233
|
+
Object.keys(s$3).forEach(function (e) {
|
|
2234
|
+
return r.registerValidator(e, s$3[e]);
|
|
2235
|
+
});
|
|
2236
|
+
i.init(r);
|
|
2237
|
+
Object.keys(i.fields).forEach(function (e) {
|
|
2238
|
+
return r.addField(e, i.fields[e]);
|
|
2239
|
+
});
|
|
2240
|
+
return r;
|
|
2241
|
+
}
|
|
2242
|
+
|
|
2243
|
+
var t$4 = /*#__PURE__*/function () {
|
|
2244
|
+
function t(_t) {
|
|
2245
|
+
_classCallCheck(this, t);
|
|
2246
|
+
|
|
2247
|
+
this.opts = _t;
|
|
2248
|
+
}
|
|
2249
|
+
|
|
2250
|
+
_createClass(t, [{
|
|
2251
|
+
key: "setCore",
|
|
2252
|
+
value: function setCore(_t2) {
|
|
2253
|
+
this.core = _t2;
|
|
2254
|
+
return this;
|
|
2255
|
+
}
|
|
2256
|
+
}, {
|
|
2257
|
+
key: "install",
|
|
2258
|
+
value: function install() {}
|
|
2259
|
+
}, {
|
|
2260
|
+
key: "uninstall",
|
|
2261
|
+
value: function uninstall() {}
|
|
2262
|
+
}]);
|
|
2263
|
+
|
|
2264
|
+
return t;
|
|
2265
|
+
}();
|
|
2266
|
+
|
|
2267
|
+
var index$2 = {
|
|
2268
|
+
getFieldValue: e$a
|
|
2269
|
+
};
|
|
2270
|
+
|
|
2271
|
+
var e$4 = /*#__PURE__*/function (_t) {
|
|
2272
|
+
_inherits(e, _t);
|
|
2273
|
+
|
|
2274
|
+
var _super = _createSuper(e);
|
|
2275
|
+
|
|
2276
|
+
function e(t) {
|
|
2277
|
+
var _this;
|
|
2278
|
+
|
|
2279
|
+
_classCallCheck(this, e);
|
|
2280
|
+
|
|
2281
|
+
_this = _super.call(this, t);
|
|
2282
|
+
_this.opts = t || {};
|
|
2283
|
+
_this.validatorNameFilter = _this.getValidatorName.bind(_assertThisInitialized(_this));
|
|
2284
|
+
return _this;
|
|
2285
|
+
}
|
|
2286
|
+
|
|
2287
|
+
_createClass(e, [{
|
|
2288
|
+
key: "install",
|
|
2289
|
+
value: function install() {
|
|
2290
|
+
this.core.registerFilter("validator-name", this.validatorNameFilter);
|
|
2291
|
+
}
|
|
2292
|
+
}, {
|
|
2293
|
+
key: "uninstall",
|
|
2294
|
+
value: function uninstall() {
|
|
2295
|
+
this.core.deregisterFilter("validator-name", this.validatorNameFilter);
|
|
2296
|
+
}
|
|
2297
|
+
}, {
|
|
2298
|
+
key: "getValidatorName",
|
|
2299
|
+
value: function getValidatorName(t, _e) {
|
|
2300
|
+
return this.opts[t] || t;
|
|
2301
|
+
}
|
|
2302
|
+
}]);
|
|
2303
|
+
|
|
2304
|
+
return e;
|
|
2305
|
+
}(t$4);
|
|
2306
|
+
|
|
2307
|
+
var i$3 = /*#__PURE__*/function (_e) {
|
|
2308
|
+
_inherits(i, _e);
|
|
2309
|
+
|
|
2310
|
+
var _super = _createSuper(i);
|
|
2311
|
+
|
|
2312
|
+
function i() {
|
|
2313
|
+
var _this;
|
|
2314
|
+
|
|
2315
|
+
_classCallCheck(this, i);
|
|
2316
|
+
|
|
2317
|
+
_this = _super.call(this, {});
|
|
2318
|
+
_this.elementValidatedHandler = _this.onElementValidated.bind(_assertThisInitialized(_this));
|
|
2319
|
+
_this.fieldValidHandler = _this.onFieldValid.bind(_assertThisInitialized(_this));
|
|
2320
|
+
_this.fieldInvalidHandler = _this.onFieldInvalid.bind(_assertThisInitialized(_this));
|
|
2321
|
+
_this.messageDisplayedHandler = _this.onMessageDisplayed.bind(_assertThisInitialized(_this));
|
|
2322
|
+
return _this;
|
|
2323
|
+
}
|
|
2324
|
+
|
|
2325
|
+
_createClass(i, [{
|
|
2326
|
+
key: "install",
|
|
2327
|
+
value: function install() {
|
|
2328
|
+
this.core.on("core.field.valid", this.fieldValidHandler).on("core.field.invalid", this.fieldInvalidHandler).on("core.element.validated", this.elementValidatedHandler).on("plugins.message.displayed", this.messageDisplayedHandler);
|
|
2329
|
+
}
|
|
2330
|
+
}, {
|
|
2331
|
+
key: "uninstall",
|
|
2332
|
+
value: function uninstall() {
|
|
2333
|
+
this.core.off("core.field.valid", this.fieldValidHandler).off("core.field.invalid", this.fieldInvalidHandler).off("core.element.validated", this.elementValidatedHandler).off("plugins.message.displayed", this.messageDisplayedHandler);
|
|
2334
|
+
}
|
|
2335
|
+
}, {
|
|
2336
|
+
key: "onElementValidated",
|
|
2337
|
+
value: function onElementValidated(e) {
|
|
2338
|
+
if (e.valid) {
|
|
2339
|
+
e.element.setAttribute("aria-invalid", "false");
|
|
2340
|
+
e.element.removeAttribute("aria-describedby");
|
|
2341
|
+
}
|
|
2342
|
+
}
|
|
2343
|
+
}, {
|
|
2344
|
+
key: "onFieldValid",
|
|
2345
|
+
value: function onFieldValid(e) {
|
|
2346
|
+
var _i = this.core.getElements(e);
|
|
2347
|
+
|
|
2348
|
+
if (_i) {
|
|
2349
|
+
_i.forEach(function (e) {
|
|
2350
|
+
e.setAttribute("aria-invalid", "false");
|
|
2351
|
+
e.removeAttribute("aria-describedby");
|
|
2352
|
+
});
|
|
2353
|
+
}
|
|
2354
|
+
}
|
|
2355
|
+
}, {
|
|
2356
|
+
key: "onFieldInvalid",
|
|
2357
|
+
value: function onFieldInvalid(e) {
|
|
2358
|
+
var _i2 = this.core.getElements(e);
|
|
2359
|
+
|
|
2360
|
+
if (_i2) {
|
|
2361
|
+
_i2.forEach(function (e) {
|
|
2362
|
+
return e.setAttribute("aria-invalid", "true");
|
|
2363
|
+
});
|
|
2364
|
+
}
|
|
2365
|
+
}
|
|
2366
|
+
}, {
|
|
2367
|
+
key: "onMessageDisplayed",
|
|
2368
|
+
value: function onMessageDisplayed(e) {
|
|
2369
|
+
e.messageElement.setAttribute("role", "alert");
|
|
2370
|
+
e.messageElement.setAttribute("aria-hidden", "false");
|
|
2371
|
+
|
|
2372
|
+
var _i3 = this.core.getElements(e.field);
|
|
2373
|
+
|
|
2374
|
+
var t = _i3.indexOf(e.element);
|
|
2375
|
+
|
|
2376
|
+
var l = "js-fv-".concat(e.field, "-").concat(t, "-").concat(Date.now(), "-message");
|
|
2377
|
+
e.messageElement.setAttribute("id", l);
|
|
2378
|
+
e.element.setAttribute("aria-describedby", l);
|
|
2379
|
+
var a = e.element.getAttribute("type");
|
|
2380
|
+
|
|
2381
|
+
if ("radio" === a || "checkbox" === a) {
|
|
2382
|
+
_i3.forEach(function (e) {
|
|
2383
|
+
return e.setAttribute("aria-describedby", l);
|
|
2384
|
+
});
|
|
2385
|
+
}
|
|
2386
|
+
}
|
|
2387
|
+
}]);
|
|
2388
|
+
|
|
2389
|
+
return i;
|
|
2390
|
+
}(t$4);
|
|
2391
|
+
|
|
2392
|
+
var t$3 = /*#__PURE__*/function (_e) {
|
|
2393
|
+
_inherits(t, _e);
|
|
2394
|
+
|
|
2395
|
+
var _super = _createSuper(t);
|
|
2396
|
+
|
|
2397
|
+
function t(e) {
|
|
2398
|
+
var _this;
|
|
2399
|
+
|
|
2400
|
+
_classCallCheck(this, t);
|
|
2401
|
+
|
|
2402
|
+
_this = _super.call(this, e);
|
|
2403
|
+
_this.addedFields = new Map();
|
|
2404
|
+
_this.opts = Object.assign({}, {
|
|
2405
|
+
html5Input: false,
|
|
2406
|
+
pluginPrefix: "data-fvp-",
|
|
2407
|
+
prefix: "data-fv-"
|
|
2408
|
+
}, e);
|
|
2409
|
+
_this.fieldAddedHandler = _this.onFieldAdded.bind(_assertThisInitialized(_this));
|
|
2410
|
+
_this.fieldRemovedHandler = _this.onFieldRemoved.bind(_assertThisInitialized(_this));
|
|
2411
|
+
return _this;
|
|
2412
|
+
}
|
|
2413
|
+
|
|
2414
|
+
_createClass(t, [{
|
|
2415
|
+
key: "install",
|
|
2416
|
+
value: function install() {
|
|
2417
|
+
var _this2 = this;
|
|
2418
|
+
|
|
2419
|
+
this.parsePlugins();
|
|
2420
|
+
var e = this.parseOptions();
|
|
2421
|
+
Object.keys(e).forEach(function (_t) {
|
|
2422
|
+
if (!_this2.addedFields.has(_t)) {
|
|
2423
|
+
_this2.addedFields.set(_t, true);
|
|
2424
|
+
}
|
|
2425
|
+
|
|
2426
|
+
_this2.core.addField(_t, e[_t]);
|
|
2427
|
+
});
|
|
2428
|
+
this.core.on("core.field.added", this.fieldAddedHandler).on("core.field.removed", this.fieldRemovedHandler);
|
|
2429
|
+
}
|
|
2430
|
+
}, {
|
|
2431
|
+
key: "uninstall",
|
|
2432
|
+
value: function uninstall() {
|
|
2433
|
+
this.addedFields.clear();
|
|
2434
|
+
this.core.off("core.field.added", this.fieldAddedHandler).off("core.field.removed", this.fieldRemovedHandler);
|
|
2435
|
+
}
|
|
2436
|
+
}, {
|
|
2437
|
+
key: "onFieldAdded",
|
|
2438
|
+
value: function onFieldAdded(e) {
|
|
2439
|
+
var _this3 = this;
|
|
2440
|
+
|
|
2441
|
+
var _t2 = e.elements;
|
|
2442
|
+
|
|
2443
|
+
if (!_t2 || _t2.length === 0 || this.addedFields.has(e.field)) {
|
|
2444
|
+
return;
|
|
2445
|
+
}
|
|
2446
|
+
|
|
2447
|
+
this.addedFields.set(e.field, true);
|
|
2448
|
+
|
|
2449
|
+
_t2.forEach(function (_t3) {
|
|
2450
|
+
var s = _this3.parseElement(_t3);
|
|
2451
|
+
|
|
2452
|
+
if (!_this3.isEmptyOption(s)) {
|
|
2453
|
+
var _t12 = {
|
|
2454
|
+
selector: e.options.selector,
|
|
2455
|
+
validators: Object.assign({}, e.options.validators || {}, s.validators)
|
|
2456
|
+
};
|
|
2457
|
+
|
|
2458
|
+
_this3.core.setFieldOptions(e.field, _t12);
|
|
2459
|
+
}
|
|
2460
|
+
});
|
|
2461
|
+
}
|
|
2462
|
+
}, {
|
|
2463
|
+
key: "onFieldRemoved",
|
|
2464
|
+
value: function onFieldRemoved(e) {
|
|
2465
|
+
if (e.field && this.addedFields.has(e.field)) {
|
|
2466
|
+
this.addedFields["delete"](e.field);
|
|
2467
|
+
}
|
|
2468
|
+
}
|
|
2469
|
+
}, {
|
|
2470
|
+
key: "parseOptions",
|
|
2471
|
+
value: function parseOptions() {
|
|
2472
|
+
var _this4 = this;
|
|
2473
|
+
|
|
2474
|
+
var e = this.opts.prefix;
|
|
2475
|
+
var _t5 = {};
|
|
2476
|
+
var s = this.core.getFields();
|
|
2477
|
+
var a = this.core.getFormElement();
|
|
2478
|
+
var i = [].slice.call(a.querySelectorAll("[name], [".concat(e, "field]")));
|
|
2479
|
+
i.forEach(function (s) {
|
|
2480
|
+
var a = _this4.parseElement(s);
|
|
2481
|
+
|
|
2482
|
+
if (!_this4.isEmptyOption(a)) {
|
|
2483
|
+
var _i = s.getAttribute("name") || s.getAttribute("".concat(e, "field"));
|
|
2484
|
+
|
|
2485
|
+
_t5[_i] = Object.assign({}, _t5[_i], a);
|
|
2486
|
+
}
|
|
2487
|
+
});
|
|
2488
|
+
Object.keys(_t5).forEach(function (e) {
|
|
2489
|
+
Object.keys(_t5[e].validators).forEach(function (a) {
|
|
2490
|
+
_t5[e].validators[a].enabled = _t5[e].validators[a].enabled || false;
|
|
2491
|
+
|
|
2492
|
+
if (s[e] && s[e].validators && s[e].validators[a]) {
|
|
2493
|
+
Object.assign(_t5[e].validators[a], s[e].validators[a]);
|
|
2494
|
+
}
|
|
2495
|
+
});
|
|
2496
|
+
});
|
|
2497
|
+
return Object.assign({}, s, _t5);
|
|
2498
|
+
}
|
|
2499
|
+
}, {
|
|
2500
|
+
key: "createPluginInstance",
|
|
2501
|
+
value: function createPluginInstance(e, _t6) {
|
|
2502
|
+
var s = e.split(".");
|
|
2503
|
+
var a = window || this;
|
|
2504
|
+
|
|
2505
|
+
for (var _e2 = 0, _t13 = s.length; _e2 < _t13; _e2++) {
|
|
2506
|
+
a = a[s[_e2]];
|
|
2507
|
+
}
|
|
2508
|
+
|
|
2509
|
+
if (typeof a !== "function") {
|
|
2510
|
+
throw new Error("the plugin ".concat(e, " doesn't exist"));
|
|
2511
|
+
}
|
|
2512
|
+
|
|
2513
|
+
return new a(_t6);
|
|
2514
|
+
}
|
|
2515
|
+
}, {
|
|
2516
|
+
key: "parsePlugins",
|
|
2517
|
+
value: function parsePlugins() {
|
|
2518
|
+
var _this5 = this;
|
|
2519
|
+
|
|
2520
|
+
var e = this.core.getFormElement();
|
|
2521
|
+
|
|
2522
|
+
var _t8 = new RegExp("^".concat(this.opts.pluginPrefix, "([a-z0-9-]+)(___)*([a-z0-9-]+)*$"));
|
|
2523
|
+
|
|
2524
|
+
var s = e.attributes.length;
|
|
2525
|
+
var a = {};
|
|
2526
|
+
|
|
2527
|
+
for (var i = 0; i < s; i++) {
|
|
2528
|
+
var _s = e.attributes[i].name;
|
|
2529
|
+
var n = e.attributes[i].value;
|
|
2530
|
+
|
|
2531
|
+
var r = _t8.exec(_s);
|
|
2532
|
+
|
|
2533
|
+
if (r && r.length === 4) {
|
|
2534
|
+
var _e3 = this.toCamelCase(r[1]);
|
|
2535
|
+
|
|
2536
|
+
a[_e3] = Object.assign({}, r[3] ? _defineProperty({}, this.toCamelCase(r[3]), n) : {
|
|
2537
|
+
enabled: "" === n || "true" === n
|
|
2538
|
+
}, a[_e3]);
|
|
2539
|
+
}
|
|
2540
|
+
}
|
|
2541
|
+
|
|
2542
|
+
Object.keys(a).forEach(function (e) {
|
|
2543
|
+
var _t9 = a[e];
|
|
2544
|
+
var s = _t9["enabled"];
|
|
2545
|
+
var i = _t9["class"];
|
|
2546
|
+
|
|
2547
|
+
if (s && i) {
|
|
2548
|
+
delete _t9["enabled"];
|
|
2549
|
+
delete _t9["clazz"];
|
|
2550
|
+
|
|
2551
|
+
var _s2 = _this5.createPluginInstance(i, _t9);
|
|
2552
|
+
|
|
2553
|
+
_this5.core.registerPlugin(e, _s2);
|
|
2554
|
+
}
|
|
2555
|
+
});
|
|
2556
|
+
}
|
|
2557
|
+
}, {
|
|
2558
|
+
key: "isEmptyOption",
|
|
2559
|
+
value: function isEmptyOption(e) {
|
|
2560
|
+
var _t10 = e.validators;
|
|
2561
|
+
return Object.keys(_t10).length === 0 && _t10.constructor === Object;
|
|
2562
|
+
}
|
|
2563
|
+
}, {
|
|
2564
|
+
key: "parseElement",
|
|
2565
|
+
value: function parseElement(e) {
|
|
2566
|
+
var _t11 = new RegExp("^".concat(this.opts.prefix, "([a-z0-9-]+)(___)*([a-z0-9-]+)*$"));
|
|
2567
|
+
|
|
2568
|
+
var s = e.attributes.length;
|
|
2569
|
+
var a = {};
|
|
2570
|
+
var i = e.getAttribute("type");
|
|
2571
|
+
|
|
2572
|
+
for (var n = 0; n < s; n++) {
|
|
2573
|
+
var _s3 = e.attributes[n].name;
|
|
2574
|
+
var r = e.attributes[n].value;
|
|
2575
|
+
|
|
2576
|
+
if (this.opts.html5Input) {
|
|
2577
|
+
switch (true) {
|
|
2578
|
+
case "minlength" === _s3:
|
|
2579
|
+
a["stringLength"] = Object.assign({}, {
|
|
2580
|
+
enabled: true,
|
|
2581
|
+
min: parseInt(r, 10)
|
|
2582
|
+
}, a["stringLength"]);
|
|
2583
|
+
break;
|
|
2584
|
+
|
|
2585
|
+
case "maxlength" === _s3:
|
|
2586
|
+
a["stringLength"] = Object.assign({}, {
|
|
2587
|
+
enabled: true,
|
|
2588
|
+
max: parseInt(r, 10)
|
|
2589
|
+
}, a["stringLength"]);
|
|
2590
|
+
break;
|
|
2591
|
+
|
|
2592
|
+
case "pattern" === _s3:
|
|
2593
|
+
a["regexp"] = Object.assign({}, {
|
|
2594
|
+
enabled: true,
|
|
2595
|
+
regexp: r
|
|
2596
|
+
}, a["regexp"]);
|
|
2597
|
+
break;
|
|
2598
|
+
|
|
2599
|
+
case "required" === _s3:
|
|
2600
|
+
a["notEmpty"] = Object.assign({}, {
|
|
2601
|
+
enabled: true
|
|
2602
|
+
}, a["notEmpty"]);
|
|
2603
|
+
break;
|
|
2604
|
+
|
|
2605
|
+
case "type" === _s3 && "color" === r:
|
|
2606
|
+
a["color"] = Object.assign({}, {
|
|
2607
|
+
enabled: true,
|
|
2608
|
+
type: "hex"
|
|
2609
|
+
}, a["color"]);
|
|
2610
|
+
break;
|
|
2611
|
+
|
|
2612
|
+
case "type" === _s3 && "email" === r:
|
|
2613
|
+
a["emailAddress"] = Object.assign({}, {
|
|
2614
|
+
enabled: true
|
|
2615
|
+
}, a["emailAddress"]);
|
|
2616
|
+
break;
|
|
2617
|
+
|
|
2618
|
+
case "type" === _s3 && "url" === r:
|
|
2619
|
+
a["uri"] = Object.assign({}, {
|
|
2620
|
+
enabled: true
|
|
2621
|
+
}, a["uri"]);
|
|
2622
|
+
break;
|
|
2623
|
+
|
|
2624
|
+
case "type" === _s3 && "range" === r:
|
|
2625
|
+
a["between"] = Object.assign({}, {
|
|
2626
|
+
enabled: true,
|
|
2627
|
+
max: parseFloat(e.getAttribute("max")),
|
|
2628
|
+
min: parseFloat(e.getAttribute("min"))
|
|
2629
|
+
}, a["between"]);
|
|
2630
|
+
break;
|
|
2631
|
+
|
|
2632
|
+
case "min" === _s3 && i !== "date" && i !== "range":
|
|
2633
|
+
a["greaterThan"] = Object.assign({}, {
|
|
2634
|
+
enabled: true,
|
|
2635
|
+
min: parseFloat(r)
|
|
2636
|
+
}, a["greaterThan"]);
|
|
2637
|
+
break;
|
|
2638
|
+
|
|
2639
|
+
case "max" === _s3 && i !== "date" && i !== "range":
|
|
2640
|
+
a["lessThan"] = Object.assign({}, {
|
|
2641
|
+
enabled: true,
|
|
2642
|
+
max: parseFloat(r)
|
|
2643
|
+
}, a["lessThan"]);
|
|
2644
|
+
break;
|
|
2645
|
+
}
|
|
2646
|
+
}
|
|
2647
|
+
|
|
2648
|
+
var l = _t11.exec(_s3);
|
|
2649
|
+
|
|
2650
|
+
if (l && l.length === 4) {
|
|
2651
|
+
var _e4 = this.toCamelCase(l[1]);
|
|
2652
|
+
|
|
2653
|
+
a[_e4] = Object.assign({}, l[3] ? _defineProperty({}, this.toCamelCase(l[3]), this.normalizeValue(r)) : {
|
|
2654
|
+
enabled: "" === r || "true" === r
|
|
2655
|
+
}, a[_e4]);
|
|
2656
|
+
}
|
|
2657
|
+
}
|
|
2658
|
+
|
|
2659
|
+
return {
|
|
2660
|
+
validators: a
|
|
2661
|
+
};
|
|
2662
|
+
}
|
|
2663
|
+
}, {
|
|
2664
|
+
key: "normalizeValue",
|
|
2665
|
+
value: function normalizeValue(e) {
|
|
2666
|
+
return e === "true" ? true : e === "false" ? false : e;
|
|
2667
|
+
}
|
|
2668
|
+
}, {
|
|
2669
|
+
key: "toUpperCase",
|
|
2670
|
+
value: function toUpperCase(e) {
|
|
2671
|
+
return e.charAt(1).toUpperCase();
|
|
2672
|
+
}
|
|
2673
|
+
}, {
|
|
2674
|
+
key: "toCamelCase",
|
|
2675
|
+
value: function toCamelCase(e) {
|
|
2676
|
+
return e.replace(/-./g, this.toUpperCase);
|
|
2677
|
+
}
|
|
2678
|
+
}]);
|
|
2679
|
+
|
|
2680
|
+
return t;
|
|
2681
|
+
}(t$4);
|
|
2682
|
+
|
|
2683
|
+
var o = /*#__PURE__*/function (_t) {
|
|
2684
|
+
_inherits(o, _t);
|
|
2685
|
+
|
|
2686
|
+
var _super = _createSuper(o);
|
|
2687
|
+
|
|
2688
|
+
function o() {
|
|
2689
|
+
var _this;
|
|
2690
|
+
|
|
2691
|
+
_classCallCheck(this, o);
|
|
2692
|
+
|
|
2693
|
+
_this = _super.call(this, {});
|
|
2694
|
+
_this.onValidHandler = _this.onFormValid.bind(_assertThisInitialized(_this));
|
|
2695
|
+
return _this;
|
|
2696
|
+
}
|
|
2697
|
+
|
|
2698
|
+
_createClass(o, [{
|
|
2699
|
+
key: "install",
|
|
2700
|
+
value: function install() {
|
|
2701
|
+
var t = this.core.getFormElement();
|
|
2702
|
+
|
|
2703
|
+
if (t.querySelectorAll('[type="submit"][name="submit"]').length) {
|
|
2704
|
+
throw new Error("Do not use `submit` for the name attribute of submit button");
|
|
2705
|
+
}
|
|
2706
|
+
|
|
2707
|
+
this.core.on("core.form.valid", this.onValidHandler);
|
|
2708
|
+
}
|
|
2709
|
+
}, {
|
|
2710
|
+
key: "uninstall",
|
|
2711
|
+
value: function uninstall() {
|
|
2712
|
+
this.core.off("core.form.valid", this.onValidHandler);
|
|
2713
|
+
}
|
|
2714
|
+
}, {
|
|
2715
|
+
key: "onFormValid",
|
|
2716
|
+
value: function onFormValid() {
|
|
2717
|
+
var t = this.core.getFormElement();
|
|
2718
|
+
|
|
2719
|
+
if (t instanceof HTMLFormElement) {
|
|
2720
|
+
t.submit();
|
|
2721
|
+
}
|
|
2722
|
+
}
|
|
2723
|
+
}]);
|
|
2724
|
+
|
|
2725
|
+
return o;
|
|
2726
|
+
}(t$4);
|
|
2727
|
+
|
|
2728
|
+
var e$3 = /*#__PURE__*/function (_t) {
|
|
2729
|
+
_inherits(e, _t);
|
|
2730
|
+
|
|
2731
|
+
var _super = _createSuper(e);
|
|
2732
|
+
|
|
2733
|
+
function e(t) {
|
|
2734
|
+
var _this;
|
|
2735
|
+
|
|
2736
|
+
_classCallCheck(this, e);
|
|
2737
|
+
|
|
2738
|
+
_this = _super.call(this, t);
|
|
2739
|
+
_this.opts = t || {};
|
|
2740
|
+
_this.triggerExecutedHandler = _this.onTriggerExecuted.bind(_assertThisInitialized(_this));
|
|
2741
|
+
return _this;
|
|
2742
|
+
}
|
|
2743
|
+
|
|
2744
|
+
_createClass(e, [{
|
|
2745
|
+
key: "install",
|
|
2746
|
+
value: function install() {
|
|
2747
|
+
this.core.on("plugins.trigger.executed", this.triggerExecutedHandler);
|
|
2748
|
+
}
|
|
2749
|
+
}, {
|
|
2750
|
+
key: "uninstall",
|
|
2751
|
+
value: function uninstall() {
|
|
2752
|
+
this.core.off("plugins.trigger.executed", this.triggerExecutedHandler);
|
|
2753
|
+
}
|
|
2754
|
+
}, {
|
|
2755
|
+
key: "onTriggerExecuted",
|
|
2756
|
+
value: function onTriggerExecuted(t) {
|
|
2757
|
+
if (this.opts[t.field]) {
|
|
2758
|
+
var _e3 = this.opts[t.field].split(" ");
|
|
2759
|
+
|
|
2760
|
+
var _iterator = _createForOfIteratorHelper(_e3),
|
|
2761
|
+
_step;
|
|
2762
|
+
|
|
2763
|
+
try {
|
|
2764
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
2765
|
+
var _t2 = _step.value;
|
|
2766
|
+
|
|
2767
|
+
var _e4 = _t2.trim();
|
|
2768
|
+
|
|
2769
|
+
if (this.opts[_e4]) {
|
|
2770
|
+
this.core.revalidateField(_e4);
|
|
2771
|
+
}
|
|
2772
|
+
}
|
|
2773
|
+
} catch (err) {
|
|
2774
|
+
_iterator.e(err);
|
|
2775
|
+
} finally {
|
|
2776
|
+
_iterator.f();
|
|
2777
|
+
}
|
|
2778
|
+
}
|
|
2779
|
+
}
|
|
2780
|
+
}]);
|
|
2781
|
+
|
|
2782
|
+
return e;
|
|
2783
|
+
}(t$4);
|
|
2784
|
+
|
|
2785
|
+
var e$2 = /*#__PURE__*/function (_t) {
|
|
2786
|
+
_inherits(e, _t);
|
|
2787
|
+
|
|
2788
|
+
var _super = _createSuper(e);
|
|
2789
|
+
|
|
2790
|
+
function e(t) {
|
|
2791
|
+
var _this;
|
|
2792
|
+
|
|
2793
|
+
_classCallCheck(this, e);
|
|
2794
|
+
|
|
2795
|
+
_this = _super.call(this, t);
|
|
2796
|
+
_this.opts = Object.assign({}, {
|
|
2797
|
+
excluded: e.defaultIgnore
|
|
2798
|
+
}, t);
|
|
2799
|
+
_this.ignoreValidationFilter = _this.ignoreValidation.bind(_assertThisInitialized(_this));
|
|
2800
|
+
return _this;
|
|
2801
|
+
}
|
|
2802
|
+
|
|
2803
|
+
_createClass(e, [{
|
|
2804
|
+
key: "install",
|
|
2805
|
+
value: function install() {
|
|
2806
|
+
this.core.registerFilter("element-ignored", this.ignoreValidationFilter);
|
|
2807
|
+
}
|
|
2808
|
+
}, {
|
|
2809
|
+
key: "uninstall",
|
|
2810
|
+
value: function uninstall() {
|
|
2811
|
+
this.core.deregisterFilter("element-ignored", this.ignoreValidationFilter);
|
|
2812
|
+
}
|
|
2813
|
+
}, {
|
|
2814
|
+
key: "ignoreValidation",
|
|
2815
|
+
value: function ignoreValidation(t, _e2, i) {
|
|
2816
|
+
return this.opts.excluded.apply(this, [t, _e2, i]);
|
|
2817
|
+
}
|
|
2818
|
+
}], [{
|
|
2819
|
+
key: "defaultIgnore",
|
|
2820
|
+
value: function defaultIgnore(t, _e, i) {
|
|
2821
|
+
var r = !!(_e.offsetWidth || _e.offsetHeight || _e.getClientRects().length);
|
|
2822
|
+
|
|
2823
|
+
var n = _e.getAttribute("disabled");
|
|
2824
|
+
|
|
2825
|
+
return n === "" || n === "disabled" || _e.getAttribute("type") === "hidden" || !r;
|
|
2826
|
+
}
|
|
2827
|
+
}]);
|
|
2828
|
+
|
|
2829
|
+
return e;
|
|
2830
|
+
}(t$4);
|
|
2831
|
+
|
|
2832
|
+
var t$2 = /*#__PURE__*/function (_e) {
|
|
2833
|
+
_inherits(t, _e);
|
|
2834
|
+
|
|
2835
|
+
var _super = _createSuper(t);
|
|
2836
|
+
|
|
2837
|
+
function t(e) {
|
|
2838
|
+
var _this;
|
|
2839
|
+
|
|
2840
|
+
_classCallCheck(this, t);
|
|
2841
|
+
|
|
2842
|
+
_this = _super.call(this, e);
|
|
2843
|
+
_this.statuses = new Map();
|
|
2844
|
+
_this.opts = Object.assign({}, {
|
|
2845
|
+
onStatusChanged: function onStatusChanged() {}
|
|
2846
|
+
}, e);
|
|
2847
|
+
_this.elementValidatingHandler = _this.onElementValidating.bind(_assertThisInitialized(_this));
|
|
2848
|
+
_this.elementValidatedHandler = _this.onElementValidated.bind(_assertThisInitialized(_this));
|
|
2849
|
+
_this.elementNotValidatedHandler = _this.onElementNotValidated.bind(_assertThisInitialized(_this));
|
|
2850
|
+
_this.elementIgnoredHandler = _this.onElementIgnored.bind(_assertThisInitialized(_this));
|
|
2851
|
+
_this.fieldAddedHandler = _this.onFieldAdded.bind(_assertThisInitialized(_this));
|
|
2852
|
+
_this.fieldRemovedHandler = _this.onFieldRemoved.bind(_assertThisInitialized(_this));
|
|
2853
|
+
return _this;
|
|
2854
|
+
}
|
|
2855
|
+
|
|
2856
|
+
_createClass(t, [{
|
|
2857
|
+
key: "install",
|
|
2858
|
+
value: function install() {
|
|
2859
|
+
this.core.on("core.element.validating", this.elementValidatingHandler).on("core.element.validated", this.elementValidatedHandler).on("core.element.notvalidated", this.elementNotValidatedHandler).on("core.element.ignored", this.elementIgnoredHandler).on("core.field.added", this.fieldAddedHandler).on("core.field.removed", this.fieldRemovedHandler);
|
|
2860
|
+
}
|
|
2861
|
+
}, {
|
|
2862
|
+
key: "uninstall",
|
|
2863
|
+
value: function uninstall() {
|
|
2864
|
+
this.statuses.clear();
|
|
2865
|
+
this.core.off("core.element.validating", this.elementValidatingHandler).off("core.element.validated", this.elementValidatedHandler).off("core.element.notvalidated", this.elementNotValidatedHandler).off("core.element.ignored", this.elementIgnoredHandler).off("core.field.added", this.fieldAddedHandler).off("core.field.removed", this.fieldRemovedHandler);
|
|
2866
|
+
}
|
|
2867
|
+
}, {
|
|
2868
|
+
key: "areFieldsValid",
|
|
2869
|
+
value: function areFieldsValid() {
|
|
2870
|
+
return Array.from(this.statuses.values()).every(function (e) {
|
|
2871
|
+
return e === "Valid" || e === "NotValidated" || e === "Ignored";
|
|
2872
|
+
});
|
|
2873
|
+
}
|
|
2874
|
+
}, {
|
|
2875
|
+
key: "getStatuses",
|
|
2876
|
+
value: function getStatuses() {
|
|
2877
|
+
return this.statuses;
|
|
2878
|
+
}
|
|
2879
|
+
}, {
|
|
2880
|
+
key: "onFieldAdded",
|
|
2881
|
+
value: function onFieldAdded(e) {
|
|
2882
|
+
this.statuses.set(e.field, "NotValidated");
|
|
2883
|
+
}
|
|
2884
|
+
}, {
|
|
2885
|
+
key: "onFieldRemoved",
|
|
2886
|
+
value: function onFieldRemoved(e) {
|
|
2887
|
+
if (this.statuses.has(e.field)) {
|
|
2888
|
+
this.statuses["delete"](e.field);
|
|
2889
|
+
}
|
|
2890
|
+
|
|
2891
|
+
this.opts.onStatusChanged(this.areFieldsValid());
|
|
2892
|
+
}
|
|
2893
|
+
}, {
|
|
2894
|
+
key: "onElementValidating",
|
|
2895
|
+
value: function onElementValidating(e) {
|
|
2896
|
+
this.statuses.set(e.field, "Validating");
|
|
2897
|
+
this.opts.onStatusChanged(false);
|
|
2898
|
+
}
|
|
2899
|
+
}, {
|
|
2900
|
+
key: "onElementValidated",
|
|
2901
|
+
value: function onElementValidated(e) {
|
|
2902
|
+
this.statuses.set(e.field, e.valid ? "Valid" : "Invalid");
|
|
2903
|
+
|
|
2904
|
+
if (e.valid) {
|
|
2905
|
+
this.opts.onStatusChanged(this.areFieldsValid());
|
|
2906
|
+
} else {
|
|
2907
|
+
this.opts.onStatusChanged(false);
|
|
2908
|
+
}
|
|
2909
|
+
}
|
|
2910
|
+
}, {
|
|
2911
|
+
key: "onElementNotValidated",
|
|
2912
|
+
value: function onElementNotValidated(e) {
|
|
2913
|
+
this.statuses.set(e.field, "NotValidated");
|
|
2914
|
+
this.opts.onStatusChanged(false);
|
|
2915
|
+
}
|
|
2916
|
+
}, {
|
|
2917
|
+
key: "onElementIgnored",
|
|
2918
|
+
value: function onElementIgnored(e) {
|
|
2919
|
+
this.statuses.set(e.field, "Ignored");
|
|
2920
|
+
this.opts.onStatusChanged(this.areFieldsValid());
|
|
2921
|
+
}
|
|
2922
|
+
}]);
|
|
2923
|
+
|
|
2924
|
+
return t;
|
|
2925
|
+
}(t$4);
|
|
2926
|
+
|
|
2927
|
+
function s$2(s, a) {
|
|
2928
|
+
a.split(" ").forEach(function (a) {
|
|
2929
|
+
if (s.classList) {
|
|
2930
|
+
s.classList.add(a);
|
|
2931
|
+
} else if (" ".concat(s.className, " ").indexOf(" ".concat(a, " "))) {
|
|
2932
|
+
s.className += " ".concat(a);
|
|
2933
|
+
}
|
|
2934
|
+
});
|
|
2935
|
+
}
|
|
2936
|
+
|
|
2937
|
+
function a(s, a) {
|
|
2938
|
+
a.split(" ").forEach(function (a) {
|
|
2939
|
+
s.classList ? s.classList.remove(a) : s.className = s.className.replace(a, "");
|
|
2940
|
+
});
|
|
2941
|
+
}
|
|
2942
|
+
|
|
2943
|
+
function c(c, e) {
|
|
2944
|
+
var t = [];
|
|
2945
|
+
var f = [];
|
|
2946
|
+
Object.keys(e).forEach(function (s) {
|
|
2947
|
+
if (s) {
|
|
2948
|
+
e[s] ? t.push(s) : f.push(s);
|
|
2949
|
+
}
|
|
2950
|
+
});
|
|
2951
|
+
f.forEach(function (s) {
|
|
2952
|
+
return a(c, s);
|
|
2953
|
+
});
|
|
2954
|
+
t.forEach(function (a) {
|
|
2955
|
+
return s$2(c, a);
|
|
2956
|
+
});
|
|
2957
|
+
}
|
|
2958
|
+
|
|
2959
|
+
function e$1(e, t) {
|
|
2960
|
+
var l = e.matches || e.webkitMatchesSelector || e["mozMatchesSelector"] || e["msMatchesSelector"];
|
|
2961
|
+
|
|
2962
|
+
if (l) {
|
|
2963
|
+
return l.call(e, t);
|
|
2964
|
+
}
|
|
2965
|
+
|
|
2966
|
+
var c = [].slice.call(e.parentElement.querySelectorAll(t));
|
|
2967
|
+
return c.indexOf(e) >= 0;
|
|
2968
|
+
}
|
|
2969
|
+
|
|
2970
|
+
function t$1(t, l) {
|
|
2971
|
+
var c = t;
|
|
2972
|
+
|
|
2973
|
+
while (c) {
|
|
2974
|
+
if (e$1(c, l)) {
|
|
2975
|
+
break;
|
|
2976
|
+
}
|
|
2977
|
+
|
|
2978
|
+
c = c.parentElement;
|
|
2979
|
+
}
|
|
2980
|
+
|
|
2981
|
+
return c;
|
|
2982
|
+
}
|
|
2983
|
+
|
|
2984
|
+
var s$1 = /*#__PURE__*/function (_e) {
|
|
2985
|
+
_inherits(s, _e);
|
|
2986
|
+
|
|
2987
|
+
var _super = _createSuper(s);
|
|
2988
|
+
|
|
2989
|
+
function s(e) {
|
|
2990
|
+
var _this;
|
|
2991
|
+
|
|
2992
|
+
_classCallCheck(this, s);
|
|
2993
|
+
|
|
2994
|
+
_this = _super.call(this, e);
|
|
2995
|
+
_this.messages = new Map();
|
|
2996
|
+
_this.defaultContainer = document.createElement("div");
|
|
2997
|
+
_this.opts = Object.assign({}, {
|
|
2998
|
+
container: function container(e, t) {
|
|
2999
|
+
return _this.defaultContainer;
|
|
3000
|
+
}
|
|
3001
|
+
}, e);
|
|
3002
|
+
_this.elementIgnoredHandler = _this.onElementIgnored.bind(_assertThisInitialized(_this));
|
|
3003
|
+
_this.fieldAddedHandler = _this.onFieldAdded.bind(_assertThisInitialized(_this));
|
|
3004
|
+
_this.fieldRemovedHandler = _this.onFieldRemoved.bind(_assertThisInitialized(_this));
|
|
3005
|
+
_this.validatorValidatedHandler = _this.onValidatorValidated.bind(_assertThisInitialized(_this));
|
|
3006
|
+
_this.validatorNotValidatedHandler = _this.onValidatorNotValidated.bind(_assertThisInitialized(_this));
|
|
3007
|
+
return _this;
|
|
3008
|
+
}
|
|
3009
|
+
|
|
3010
|
+
_createClass(s, [{
|
|
3011
|
+
key: "install",
|
|
3012
|
+
value: function install() {
|
|
3013
|
+
this.core.getFormElement().appendChild(this.defaultContainer);
|
|
3014
|
+
this.core.on("core.element.ignored", this.elementIgnoredHandler).on("core.field.added", this.fieldAddedHandler).on("core.field.removed", this.fieldRemovedHandler).on("core.validator.validated", this.validatorValidatedHandler).on("core.validator.notvalidated", this.validatorNotValidatedHandler);
|
|
3015
|
+
}
|
|
3016
|
+
}, {
|
|
3017
|
+
key: "uninstall",
|
|
3018
|
+
value: function uninstall() {
|
|
3019
|
+
this.core.getFormElement().removeChild(this.defaultContainer);
|
|
3020
|
+
this.messages.forEach(function (e) {
|
|
3021
|
+
return e.parentNode.removeChild(e);
|
|
3022
|
+
});
|
|
3023
|
+
this.messages.clear();
|
|
3024
|
+
this.core.off("core.element.ignored", this.elementIgnoredHandler).off("core.field.added", this.fieldAddedHandler).off("core.field.removed", this.fieldRemovedHandler).off("core.validator.validated", this.validatorValidatedHandler).off("core.validator.notvalidated", this.validatorNotValidatedHandler);
|
|
3025
|
+
}
|
|
3026
|
+
}, {
|
|
3027
|
+
key: "onFieldAdded",
|
|
3028
|
+
value: function onFieldAdded(e) {
|
|
3029
|
+
var _this2 = this;
|
|
3030
|
+
|
|
3031
|
+
var t = e.elements;
|
|
3032
|
+
|
|
3033
|
+
if (t) {
|
|
3034
|
+
t.forEach(function (e) {
|
|
3035
|
+
var t = _this2.messages.get(e);
|
|
3036
|
+
|
|
3037
|
+
if (t) {
|
|
3038
|
+
t.parentNode.removeChild(t);
|
|
3039
|
+
|
|
3040
|
+
_this2.messages["delete"](e);
|
|
3041
|
+
}
|
|
3042
|
+
});
|
|
3043
|
+
this.prepareFieldContainer(e.field, t);
|
|
3044
|
+
}
|
|
3045
|
+
}
|
|
3046
|
+
}, {
|
|
3047
|
+
key: "onFieldRemoved",
|
|
3048
|
+
value: function onFieldRemoved(e) {
|
|
3049
|
+
var _this3 = this;
|
|
3050
|
+
|
|
3051
|
+
if (!e.elements.length || !e.field) {
|
|
3052
|
+
return;
|
|
3053
|
+
}
|
|
3054
|
+
|
|
3055
|
+
var t = e.elements[0].getAttribute("type");
|
|
3056
|
+
|
|
3057
|
+
var _s2 = "radio" === t || "checkbox" === t ? [e.elements[0]] : e.elements;
|
|
3058
|
+
|
|
3059
|
+
_s2.forEach(function (e) {
|
|
3060
|
+
if (_this3.messages.has(e)) {
|
|
3061
|
+
var _t = _this3.messages.get(e);
|
|
3062
|
+
|
|
3063
|
+
_t.parentNode.removeChild(_t);
|
|
3064
|
+
|
|
3065
|
+
_this3.messages["delete"](e);
|
|
3066
|
+
}
|
|
3067
|
+
});
|
|
3068
|
+
}
|
|
3069
|
+
}, {
|
|
3070
|
+
key: "prepareFieldContainer",
|
|
3071
|
+
value: function prepareFieldContainer(e, t) {
|
|
3072
|
+
var _this4 = this;
|
|
3073
|
+
|
|
3074
|
+
if (t.length) {
|
|
3075
|
+
var _s12 = t[0].getAttribute("type");
|
|
3076
|
+
|
|
3077
|
+
if ("radio" === _s12 || "checkbox" === _s12) {
|
|
3078
|
+
this.prepareElementContainer(e, t[0], t);
|
|
3079
|
+
} else {
|
|
3080
|
+
t.forEach(function (_s4) {
|
|
3081
|
+
return _this4.prepareElementContainer(e, _s4, t);
|
|
3082
|
+
});
|
|
3083
|
+
}
|
|
3084
|
+
}
|
|
3085
|
+
}
|
|
3086
|
+
}, {
|
|
3087
|
+
key: "prepareElementContainer",
|
|
3088
|
+
value: function prepareElementContainer(e, _s5, i) {
|
|
3089
|
+
var a;
|
|
3090
|
+
|
|
3091
|
+
if ("string" === typeof this.opts.container) {
|
|
3092
|
+
var _e2 = "#" === this.opts.container.charAt(0) ? "[id=\"".concat(this.opts.container.substring(1), "\"]") : this.opts.container;
|
|
3093
|
+
|
|
3094
|
+
a = this.core.getFormElement().querySelector(_e2);
|
|
3095
|
+
} else {
|
|
3096
|
+
a = this.opts.container(e, _s5);
|
|
3097
|
+
}
|
|
3098
|
+
|
|
3099
|
+
var l = document.createElement("div");
|
|
3100
|
+
a.appendChild(l);
|
|
3101
|
+
c(l, {
|
|
3102
|
+
"fv-plugins-message-container": true
|
|
3103
|
+
});
|
|
3104
|
+
this.core.emit("plugins.message.placed", {
|
|
3105
|
+
element: _s5,
|
|
3106
|
+
elements: i,
|
|
3107
|
+
field: e,
|
|
3108
|
+
messageElement: l
|
|
3109
|
+
});
|
|
3110
|
+
this.messages.set(_s5, l);
|
|
3111
|
+
}
|
|
3112
|
+
}, {
|
|
3113
|
+
key: "getMessage",
|
|
3114
|
+
value: function getMessage(e) {
|
|
3115
|
+
return typeof e.message === "string" ? e.message : e.message[this.core.getLocale()];
|
|
3116
|
+
}
|
|
3117
|
+
}, {
|
|
3118
|
+
key: "onValidatorValidated",
|
|
3119
|
+
value: function onValidatorValidated(e) {
|
|
3120
|
+
var _s6 = e.elements;
|
|
3121
|
+
var i = e.element.getAttribute("type");
|
|
3122
|
+
var a = ("radio" === i || "checkbox" === i) && _s6.length > 0 ? _s6[0] : e.element;
|
|
3123
|
+
|
|
3124
|
+
if (this.messages.has(a)) {
|
|
3125
|
+
var _s13 = this.messages.get(a);
|
|
3126
|
+
|
|
3127
|
+
var _i = _s13.querySelector("[data-field=\"".concat(e.field, "\"][data-validator=\"").concat(e.validator, "\"]"));
|
|
3128
|
+
|
|
3129
|
+
if (!_i && !e.result.valid) {
|
|
3130
|
+
var _i2 = document.createElement("div");
|
|
3131
|
+
|
|
3132
|
+
_i2.innerHTML = this.getMessage(e.result);
|
|
3133
|
+
|
|
3134
|
+
_i2.setAttribute("data-field", e.field);
|
|
3135
|
+
|
|
3136
|
+
_i2.setAttribute("data-validator", e.validator);
|
|
3137
|
+
|
|
3138
|
+
if (this.opts.clazz) {
|
|
3139
|
+
c(_i2, _defineProperty({}, this.opts.clazz, true));
|
|
3140
|
+
}
|
|
3141
|
+
|
|
3142
|
+
_s13.appendChild(_i2);
|
|
3143
|
+
|
|
3144
|
+
this.core.emit("plugins.message.displayed", {
|
|
3145
|
+
element: e.element,
|
|
3146
|
+
field: e.field,
|
|
3147
|
+
message: e.result.message,
|
|
3148
|
+
messageElement: _i2,
|
|
3149
|
+
meta: e.result.meta,
|
|
3150
|
+
validator: e.validator
|
|
3151
|
+
});
|
|
3152
|
+
} else if (_i && !e.result.valid) {
|
|
3153
|
+
_i.innerHTML = this.getMessage(e.result);
|
|
3154
|
+
this.core.emit("plugins.message.displayed", {
|
|
3155
|
+
element: e.element,
|
|
3156
|
+
field: e.field,
|
|
3157
|
+
message: e.result.message,
|
|
3158
|
+
messageElement: _i,
|
|
3159
|
+
meta: e.result.meta,
|
|
3160
|
+
validator: e.validator
|
|
3161
|
+
});
|
|
3162
|
+
} else if (_i && e.result.valid) {
|
|
3163
|
+
_s13.removeChild(_i);
|
|
3164
|
+
}
|
|
3165
|
+
}
|
|
3166
|
+
}
|
|
3167
|
+
}, {
|
|
3168
|
+
key: "onValidatorNotValidated",
|
|
3169
|
+
value: function onValidatorNotValidated(e) {
|
|
3170
|
+
var t = e.elements;
|
|
3171
|
+
|
|
3172
|
+
var _s8 = e.element.getAttribute("type");
|
|
3173
|
+
|
|
3174
|
+
var i = "radio" === _s8 || "checkbox" === _s8 ? t[0] : e.element;
|
|
3175
|
+
|
|
3176
|
+
if (this.messages.has(i)) {
|
|
3177
|
+
var _t3 = this.messages.get(i);
|
|
3178
|
+
|
|
3179
|
+
var _s14 = _t3.querySelector("[data-field=\"".concat(e.field, "\"][data-validator=\"").concat(e.validator, "\"]"));
|
|
3180
|
+
|
|
3181
|
+
if (_s14) {
|
|
3182
|
+
_t3.removeChild(_s14);
|
|
3183
|
+
}
|
|
3184
|
+
}
|
|
3185
|
+
}
|
|
3186
|
+
}, {
|
|
3187
|
+
key: "onElementIgnored",
|
|
3188
|
+
value: function onElementIgnored(e) {
|
|
3189
|
+
var t = e.elements;
|
|
3190
|
+
|
|
3191
|
+
var _s10 = e.element.getAttribute("type");
|
|
3192
|
+
|
|
3193
|
+
var i = "radio" === _s10 || "checkbox" === _s10 ? t[0] : e.element;
|
|
3194
|
+
|
|
3195
|
+
if (this.messages.has(i)) {
|
|
3196
|
+
var _t4 = this.messages.get(i);
|
|
3197
|
+
|
|
3198
|
+
var _s15 = [].slice.call(_t4.querySelectorAll("[data-field=\"".concat(e.field, "\"]")));
|
|
3199
|
+
|
|
3200
|
+
_s15.forEach(function (e) {
|
|
3201
|
+
_t4.removeChild(e);
|
|
3202
|
+
});
|
|
3203
|
+
}
|
|
3204
|
+
}
|
|
3205
|
+
}], [{
|
|
3206
|
+
key: "getClosestContainer",
|
|
3207
|
+
value: function getClosestContainer(e, t, _s) {
|
|
3208
|
+
var i = e;
|
|
3209
|
+
|
|
3210
|
+
while (i) {
|
|
3211
|
+
if (i === t) {
|
|
3212
|
+
break;
|
|
3213
|
+
}
|
|
3214
|
+
|
|
3215
|
+
i = i.parentElement;
|
|
3216
|
+
|
|
3217
|
+
if (_s.test(i.className)) {
|
|
3218
|
+
break;
|
|
3219
|
+
}
|
|
3220
|
+
}
|
|
3221
|
+
|
|
3222
|
+
return i;
|
|
3223
|
+
}
|
|
3224
|
+
}]);
|
|
3225
|
+
|
|
3226
|
+
return s;
|
|
3227
|
+
}(t$4);
|
|
3228
|
+
|
|
3229
|
+
var l = /*#__PURE__*/function (_e) {
|
|
3230
|
+
_inherits(l, _e);
|
|
3231
|
+
|
|
3232
|
+
var _super = _createSuper(l);
|
|
3233
|
+
|
|
3234
|
+
function l(e) {
|
|
3235
|
+
var _this;
|
|
3236
|
+
|
|
3237
|
+
_classCallCheck(this, l);
|
|
3238
|
+
|
|
3239
|
+
_this = _super.call(this, e);
|
|
3240
|
+
_this.results = new Map();
|
|
3241
|
+
_this.containers = new Map();
|
|
3242
|
+
_this.opts = Object.assign({}, {
|
|
3243
|
+
defaultMessageContainer: true,
|
|
3244
|
+
eleInvalidClass: "",
|
|
3245
|
+
eleValidClass: "",
|
|
3246
|
+
rowClasses: "",
|
|
3247
|
+
rowValidatingClass: ""
|
|
3248
|
+
}, e);
|
|
3249
|
+
_this.elementIgnoredHandler = _this.onElementIgnored.bind(_assertThisInitialized(_this));
|
|
3250
|
+
_this.elementValidatingHandler = _this.onElementValidating.bind(_assertThisInitialized(_this));
|
|
3251
|
+
_this.elementValidatedHandler = _this.onElementValidated.bind(_assertThisInitialized(_this));
|
|
3252
|
+
_this.elementNotValidatedHandler = _this.onElementNotValidated.bind(_assertThisInitialized(_this));
|
|
3253
|
+
_this.iconPlacedHandler = _this.onIconPlaced.bind(_assertThisInitialized(_this));
|
|
3254
|
+
_this.fieldAddedHandler = _this.onFieldAdded.bind(_assertThisInitialized(_this));
|
|
3255
|
+
_this.fieldRemovedHandler = _this.onFieldRemoved.bind(_assertThisInitialized(_this));
|
|
3256
|
+
_this.messagePlacedHandler = _this.onMessagePlaced.bind(_assertThisInitialized(_this));
|
|
3257
|
+
return _this;
|
|
3258
|
+
}
|
|
3259
|
+
|
|
3260
|
+
_createClass(l, [{
|
|
3261
|
+
key: "install",
|
|
3262
|
+
value: function install() {
|
|
3263
|
+
var _t,
|
|
3264
|
+
_this2 = this;
|
|
3265
|
+
|
|
3266
|
+
c(this.core.getFormElement(), (_t = {}, _defineProperty(_t, this.opts.formClass, true), _defineProperty(_t, "fv-plugins-framework", true), _t));
|
|
3267
|
+
this.core.on("core.element.ignored", this.elementIgnoredHandler).on("core.element.validating", this.elementValidatingHandler).on("core.element.validated", this.elementValidatedHandler).on("core.element.notvalidated", this.elementNotValidatedHandler).on("plugins.icon.placed", this.iconPlacedHandler).on("core.field.added", this.fieldAddedHandler).on("core.field.removed", this.fieldRemovedHandler);
|
|
3268
|
+
|
|
3269
|
+
if (this.opts.defaultMessageContainer) {
|
|
3270
|
+
this.core.registerPlugin("___frameworkMessage", new s$1({
|
|
3271
|
+
clazz: this.opts.messageClass,
|
|
3272
|
+
container: function container(e, t) {
|
|
3273
|
+
var _l = "string" === typeof _this2.opts.rowSelector ? _this2.opts.rowSelector : _this2.opts.rowSelector(e, t);
|
|
3274
|
+
|
|
3275
|
+
var a = t$1(t, _l);
|
|
3276
|
+
return s$1.getClosestContainer(t, a, _this2.opts.rowPattern);
|
|
3277
|
+
}
|
|
3278
|
+
}));
|
|
3279
|
+
this.core.on("plugins.message.placed", this.messagePlacedHandler);
|
|
3280
|
+
}
|
|
3281
|
+
}
|
|
3282
|
+
}, {
|
|
3283
|
+
key: "uninstall",
|
|
3284
|
+
value: function uninstall() {
|
|
3285
|
+
var _t2;
|
|
3286
|
+
|
|
3287
|
+
this.results.clear();
|
|
3288
|
+
this.containers.clear();
|
|
3289
|
+
c(this.core.getFormElement(), (_t2 = {}, _defineProperty(_t2, this.opts.formClass, false), _defineProperty(_t2, "fv-plugins-framework", false), _t2));
|
|
3290
|
+
this.core.off("core.element.ignored", this.elementIgnoredHandler).off("core.element.validating", this.elementValidatingHandler).off("core.element.validated", this.elementValidatedHandler).off("core.element.notvalidated", this.elementNotValidatedHandler).off("plugins.icon.placed", this.iconPlacedHandler).off("core.field.added", this.fieldAddedHandler).off("core.field.removed", this.fieldRemovedHandler);
|
|
3291
|
+
|
|
3292
|
+
if (this.opts.defaultMessageContainer) {
|
|
3293
|
+
this.core.off("plugins.message.placed", this.messagePlacedHandler);
|
|
3294
|
+
}
|
|
3295
|
+
}
|
|
3296
|
+
}, {
|
|
3297
|
+
key: "onIconPlaced",
|
|
3298
|
+
value: function onIconPlaced(e) {}
|
|
3299
|
+
}, {
|
|
3300
|
+
key: "onMessagePlaced",
|
|
3301
|
+
value: function onMessagePlaced(e) {}
|
|
3302
|
+
}, {
|
|
3303
|
+
key: "onFieldAdded",
|
|
3304
|
+
value: function onFieldAdded(e) {
|
|
3305
|
+
var _this3 = this;
|
|
3306
|
+
|
|
3307
|
+
var s = e.elements;
|
|
3308
|
+
|
|
3309
|
+
if (s) {
|
|
3310
|
+
s.forEach(function (e) {
|
|
3311
|
+
var s = _this3.containers.get(e);
|
|
3312
|
+
|
|
3313
|
+
if (s) {
|
|
3314
|
+
var _t3;
|
|
3315
|
+
|
|
3316
|
+
c(s, (_t3 = {}, _defineProperty(_t3, _this3.opts.rowInvalidClass, false), _defineProperty(_t3, _this3.opts.rowValidatingClass, false), _defineProperty(_t3, _this3.opts.rowValidClass, false), _defineProperty(_t3, "fv-plugins-icon-container", false), _t3));
|
|
3317
|
+
|
|
3318
|
+
_this3.containers["delete"](e);
|
|
3319
|
+
}
|
|
3320
|
+
});
|
|
3321
|
+
this.prepareFieldContainer(e.field, s);
|
|
3322
|
+
}
|
|
3323
|
+
}
|
|
3324
|
+
}, {
|
|
3325
|
+
key: "onFieldRemoved",
|
|
3326
|
+
value: function onFieldRemoved(e) {
|
|
3327
|
+
var _this4 = this;
|
|
3328
|
+
|
|
3329
|
+
e.elements.forEach(function (e) {
|
|
3330
|
+
var s = _this4.containers.get(e);
|
|
3331
|
+
|
|
3332
|
+
if (s) {
|
|
3333
|
+
var _t4;
|
|
3334
|
+
|
|
3335
|
+
c(s, (_t4 = {}, _defineProperty(_t4, _this4.opts.rowInvalidClass, false), _defineProperty(_t4, _this4.opts.rowValidatingClass, false), _defineProperty(_t4, _this4.opts.rowValidClass, false), _t4));
|
|
3336
|
+
}
|
|
3337
|
+
});
|
|
3338
|
+
}
|
|
3339
|
+
}, {
|
|
3340
|
+
key: "prepareFieldContainer",
|
|
3341
|
+
value: function prepareFieldContainer(e, t) {
|
|
3342
|
+
var _this5 = this;
|
|
3343
|
+
|
|
3344
|
+
if (t.length) {
|
|
3345
|
+
var _s = t[0].getAttribute("type");
|
|
3346
|
+
|
|
3347
|
+
if ("radio" === _s || "checkbox" === _s) {
|
|
3348
|
+
this.prepareElementContainer(e, t[0]);
|
|
3349
|
+
} else {
|
|
3350
|
+
t.forEach(function (t) {
|
|
3351
|
+
return _this5.prepareElementContainer(e, t);
|
|
3352
|
+
});
|
|
3353
|
+
}
|
|
3354
|
+
}
|
|
3355
|
+
}
|
|
3356
|
+
}, {
|
|
3357
|
+
key: "prepareElementContainer",
|
|
3358
|
+
value: function prepareElementContainer(e, i) {
|
|
3359
|
+
var _l2 = "string" === typeof this.opts.rowSelector ? this.opts.rowSelector : this.opts.rowSelector(e, i);
|
|
3360
|
+
|
|
3361
|
+
var a = t$1(i, _l2);
|
|
3362
|
+
|
|
3363
|
+
if (a !== i) {
|
|
3364
|
+
var _t5;
|
|
3365
|
+
|
|
3366
|
+
c(a, (_t5 = {}, _defineProperty(_t5, this.opts.rowClasses, true), _defineProperty(_t5, "fv-plugins-icon-container", true), _t5));
|
|
3367
|
+
this.containers.set(i, a);
|
|
3368
|
+
}
|
|
3369
|
+
}
|
|
3370
|
+
}, {
|
|
3371
|
+
key: "onElementValidating",
|
|
3372
|
+
value: function onElementValidating(e) {
|
|
3373
|
+
var s = e.elements;
|
|
3374
|
+
var i = e.element.getAttribute("type");
|
|
3375
|
+
|
|
3376
|
+
var _l3 = "radio" === i || "checkbox" === i ? s[0] : e.element;
|
|
3377
|
+
|
|
3378
|
+
var a = this.containers.get(_l3);
|
|
3379
|
+
|
|
3380
|
+
if (a) {
|
|
3381
|
+
var _t6;
|
|
3382
|
+
|
|
3383
|
+
c(a, (_t6 = {}, _defineProperty(_t6, this.opts.rowInvalidClass, false), _defineProperty(_t6, this.opts.rowValidatingClass, true), _defineProperty(_t6, this.opts.rowValidClass, false), _t6));
|
|
3384
|
+
}
|
|
3385
|
+
}
|
|
3386
|
+
}, {
|
|
3387
|
+
key: "onElementNotValidated",
|
|
3388
|
+
value: function onElementNotValidated(e) {
|
|
3389
|
+
this.removeClasses(e.element, e.elements);
|
|
3390
|
+
}
|
|
3391
|
+
}, {
|
|
3392
|
+
key: "onElementIgnored",
|
|
3393
|
+
value: function onElementIgnored(e) {
|
|
3394
|
+
this.removeClasses(e.element, e.elements);
|
|
3395
|
+
}
|
|
3396
|
+
}, {
|
|
3397
|
+
key: "removeClasses",
|
|
3398
|
+
value: function removeClasses(e, s) {
|
|
3399
|
+
var _this6 = this;
|
|
3400
|
+
|
|
3401
|
+
var i = e.getAttribute("type");
|
|
3402
|
+
|
|
3403
|
+
var _l4 = "radio" === i || "checkbox" === i ? s[0] : e;
|
|
3404
|
+
|
|
3405
|
+
s.forEach(function (e) {
|
|
3406
|
+
var _t7;
|
|
3407
|
+
|
|
3408
|
+
c(e, (_t7 = {}, _defineProperty(_t7, _this6.opts.eleValidClass, false), _defineProperty(_t7, _this6.opts.eleInvalidClass, false), _t7));
|
|
3409
|
+
});
|
|
3410
|
+
var a = this.containers.get(_l4);
|
|
3411
|
+
|
|
3412
|
+
if (a) {
|
|
3413
|
+
var _t8;
|
|
3414
|
+
|
|
3415
|
+
c(a, (_t8 = {}, _defineProperty(_t8, this.opts.rowInvalidClass, false), _defineProperty(_t8, this.opts.rowValidatingClass, false), _defineProperty(_t8, this.opts.rowValidClass, false), _t8));
|
|
3416
|
+
}
|
|
3417
|
+
}
|
|
3418
|
+
}, {
|
|
3419
|
+
key: "onElementValidated",
|
|
3420
|
+
value: function onElementValidated(e) {
|
|
3421
|
+
var _this7 = this;
|
|
3422
|
+
|
|
3423
|
+
var s = e.elements;
|
|
3424
|
+
var i = e.element.getAttribute("type");
|
|
3425
|
+
|
|
3426
|
+
var _l5 = "radio" === i || "checkbox" === i ? s[0] : e.element;
|
|
3427
|
+
|
|
3428
|
+
s.forEach(function (s) {
|
|
3429
|
+
var _t9;
|
|
3430
|
+
|
|
3431
|
+
c(s, (_t9 = {}, _defineProperty(_t9, _this7.opts.eleValidClass, e.valid), _defineProperty(_t9, _this7.opts.eleInvalidClass, !e.valid), _t9));
|
|
3432
|
+
});
|
|
3433
|
+
var a = this.containers.get(_l5);
|
|
3434
|
+
|
|
3435
|
+
if (a) {
|
|
3436
|
+
if (!e.valid) {
|
|
3437
|
+
var _t10;
|
|
3438
|
+
|
|
3439
|
+
this.results.set(_l5, false);
|
|
3440
|
+
c(a, (_t10 = {}, _defineProperty(_t10, this.opts.rowInvalidClass, true), _defineProperty(_t10, this.opts.rowValidatingClass, false), _defineProperty(_t10, this.opts.rowValidClass, false), _t10));
|
|
3441
|
+
} else {
|
|
3442
|
+
this.results["delete"](_l5);
|
|
3443
|
+
var _e2 = true;
|
|
3444
|
+
this.containers.forEach(function (t, s) {
|
|
3445
|
+
if (t === a && _this7.results.get(s) === false) {
|
|
3446
|
+
_e2 = false;
|
|
3447
|
+
}
|
|
3448
|
+
});
|
|
3449
|
+
|
|
3450
|
+
if (_e2) {
|
|
3451
|
+
var _t11;
|
|
3452
|
+
|
|
3453
|
+
c(a, (_t11 = {}, _defineProperty(_t11, this.opts.rowInvalidClass, false), _defineProperty(_t11, this.opts.rowValidatingClass, false), _defineProperty(_t11, this.opts.rowValidClass, true), _t11));
|
|
3454
|
+
}
|
|
3455
|
+
}
|
|
3456
|
+
}
|
|
3457
|
+
}
|
|
3458
|
+
}]);
|
|
3459
|
+
|
|
3460
|
+
return l;
|
|
3461
|
+
}(t$4);
|
|
3462
|
+
|
|
3463
|
+
var i$2 = /*#__PURE__*/function (_e) {
|
|
3464
|
+
_inherits(i, _e);
|
|
3465
|
+
|
|
3466
|
+
var _super = _createSuper(i);
|
|
3467
|
+
|
|
3468
|
+
function i(e) {
|
|
3469
|
+
var _this;
|
|
3470
|
+
|
|
3471
|
+
_classCallCheck(this, i);
|
|
3472
|
+
|
|
3473
|
+
_this = _super.call(this, e);
|
|
3474
|
+
_this.icons = new Map();
|
|
3475
|
+
_this.opts = Object.assign({}, {
|
|
3476
|
+
invalid: "fv-plugins-icon--invalid",
|
|
3477
|
+
onPlaced: function onPlaced() {},
|
|
3478
|
+
onSet: function onSet() {},
|
|
3479
|
+
valid: "fv-plugins-icon--valid",
|
|
3480
|
+
validating: "fv-plugins-icon--validating"
|
|
3481
|
+
}, e);
|
|
3482
|
+
_this.elementValidatingHandler = _this.onElementValidating.bind(_assertThisInitialized(_this));
|
|
3483
|
+
_this.elementValidatedHandler = _this.onElementValidated.bind(_assertThisInitialized(_this));
|
|
3484
|
+
_this.elementNotValidatedHandler = _this.onElementNotValidated.bind(_assertThisInitialized(_this));
|
|
3485
|
+
_this.elementIgnoredHandler = _this.onElementIgnored.bind(_assertThisInitialized(_this));
|
|
3486
|
+
_this.fieldAddedHandler = _this.onFieldAdded.bind(_assertThisInitialized(_this));
|
|
3487
|
+
return _this;
|
|
3488
|
+
}
|
|
3489
|
+
|
|
3490
|
+
_createClass(i, [{
|
|
3491
|
+
key: "install",
|
|
3492
|
+
value: function install() {
|
|
3493
|
+
this.core.on("core.element.validating", this.elementValidatingHandler).on("core.element.validated", this.elementValidatedHandler).on("core.element.notvalidated", this.elementNotValidatedHandler).on("core.element.ignored", this.elementIgnoredHandler).on("core.field.added", this.fieldAddedHandler);
|
|
3494
|
+
}
|
|
3495
|
+
}, {
|
|
3496
|
+
key: "uninstall",
|
|
3497
|
+
value: function uninstall() {
|
|
3498
|
+
this.icons.forEach(function (e) {
|
|
3499
|
+
return e.parentNode.removeChild(e);
|
|
3500
|
+
});
|
|
3501
|
+
this.icons.clear();
|
|
3502
|
+
this.core.off("core.element.validating", this.elementValidatingHandler).off("core.element.validated", this.elementValidatedHandler).off("core.element.notvalidated", this.elementNotValidatedHandler).off("core.element.ignored", this.elementIgnoredHandler).off("core.field.added", this.fieldAddedHandler);
|
|
3503
|
+
}
|
|
3504
|
+
}, {
|
|
3505
|
+
key: "onFieldAdded",
|
|
3506
|
+
value: function onFieldAdded(e) {
|
|
3507
|
+
var _this2 = this;
|
|
3508
|
+
|
|
3509
|
+
var t = e.elements;
|
|
3510
|
+
|
|
3511
|
+
if (t) {
|
|
3512
|
+
t.forEach(function (e) {
|
|
3513
|
+
var t = _this2.icons.get(e);
|
|
3514
|
+
|
|
3515
|
+
if (t) {
|
|
3516
|
+
t.parentNode.removeChild(t);
|
|
3517
|
+
|
|
3518
|
+
_this2.icons["delete"](e);
|
|
3519
|
+
}
|
|
3520
|
+
});
|
|
3521
|
+
this.prepareFieldIcon(e.field, t);
|
|
3522
|
+
}
|
|
3523
|
+
}
|
|
3524
|
+
}, {
|
|
3525
|
+
key: "prepareFieldIcon",
|
|
3526
|
+
value: function prepareFieldIcon(e, t) {
|
|
3527
|
+
var _this3 = this;
|
|
3528
|
+
|
|
3529
|
+
if (t.length) {
|
|
3530
|
+
var _i8 = t[0].getAttribute("type");
|
|
3531
|
+
|
|
3532
|
+
if ("radio" === _i8 || "checkbox" === _i8) {
|
|
3533
|
+
this.prepareElementIcon(e, t[0]);
|
|
3534
|
+
} else {
|
|
3535
|
+
t.forEach(function (t) {
|
|
3536
|
+
return _this3.prepareElementIcon(e, t);
|
|
3537
|
+
});
|
|
3538
|
+
}
|
|
3539
|
+
}
|
|
3540
|
+
}
|
|
3541
|
+
}, {
|
|
3542
|
+
key: "prepareElementIcon",
|
|
3543
|
+
value: function prepareElementIcon(e, _i2) {
|
|
3544
|
+
var n = document.createElement("i");
|
|
3545
|
+
n.setAttribute("data-field", e);
|
|
3546
|
+
|
|
3547
|
+
_i2.parentNode.insertBefore(n, _i2.nextSibling);
|
|
3548
|
+
|
|
3549
|
+
c(n, {
|
|
3550
|
+
"fv-plugins-icon": true
|
|
3551
|
+
});
|
|
3552
|
+
var l = {
|
|
3553
|
+
classes: {
|
|
3554
|
+
invalid: this.opts.invalid,
|
|
3555
|
+
valid: this.opts.valid,
|
|
3556
|
+
validating: this.opts.validating
|
|
3557
|
+
},
|
|
3558
|
+
element: _i2,
|
|
3559
|
+
field: e,
|
|
3560
|
+
iconElement: n
|
|
3561
|
+
};
|
|
3562
|
+
this.core.emit("plugins.icon.placed", l);
|
|
3563
|
+
this.opts.onPlaced(l);
|
|
3564
|
+
this.icons.set(_i2, n);
|
|
3565
|
+
}
|
|
3566
|
+
}, {
|
|
3567
|
+
key: "onElementValidating",
|
|
3568
|
+
value: function onElementValidating(e) {
|
|
3569
|
+
var _this$setClasses;
|
|
3570
|
+
|
|
3571
|
+
var t = this.setClasses(e.field, e.element, e.elements, (_this$setClasses = {}, _defineProperty(_this$setClasses, this.opts.invalid, false), _defineProperty(_this$setClasses, this.opts.valid, false), _defineProperty(_this$setClasses, this.opts.validating, true), _this$setClasses));
|
|
3572
|
+
var _i3 = {
|
|
3573
|
+
element: e.element,
|
|
3574
|
+
field: e.field,
|
|
3575
|
+
iconElement: t,
|
|
3576
|
+
status: "Validating"
|
|
3577
|
+
};
|
|
3578
|
+
this.core.emit("plugins.icon.set", _i3);
|
|
3579
|
+
this.opts.onSet(_i3);
|
|
3580
|
+
}
|
|
3581
|
+
}, {
|
|
3582
|
+
key: "onElementValidated",
|
|
3583
|
+
value: function onElementValidated(e) {
|
|
3584
|
+
var _this$setClasses2;
|
|
3585
|
+
|
|
3586
|
+
var t = this.setClasses(e.field, e.element, e.elements, (_this$setClasses2 = {}, _defineProperty(_this$setClasses2, this.opts.invalid, !e.valid), _defineProperty(_this$setClasses2, this.opts.valid, e.valid), _defineProperty(_this$setClasses2, this.opts.validating, false), _this$setClasses2));
|
|
3587
|
+
var _i4 = {
|
|
3588
|
+
element: e.element,
|
|
3589
|
+
field: e.field,
|
|
3590
|
+
iconElement: t,
|
|
3591
|
+
status: e.valid ? "Valid" : "Invalid"
|
|
3592
|
+
};
|
|
3593
|
+
this.core.emit("plugins.icon.set", _i4);
|
|
3594
|
+
this.opts.onSet(_i4);
|
|
3595
|
+
}
|
|
3596
|
+
}, {
|
|
3597
|
+
key: "onElementNotValidated",
|
|
3598
|
+
value: function onElementNotValidated(e) {
|
|
3599
|
+
var _this$setClasses3;
|
|
3600
|
+
|
|
3601
|
+
var t = this.setClasses(e.field, e.element, e.elements, (_this$setClasses3 = {}, _defineProperty(_this$setClasses3, this.opts.invalid, false), _defineProperty(_this$setClasses3, this.opts.valid, false), _defineProperty(_this$setClasses3, this.opts.validating, false), _this$setClasses3));
|
|
3602
|
+
var _i5 = {
|
|
3603
|
+
element: e.element,
|
|
3604
|
+
field: e.field,
|
|
3605
|
+
iconElement: t,
|
|
3606
|
+
status: "NotValidated"
|
|
3607
|
+
};
|
|
3608
|
+
this.core.emit("plugins.icon.set", _i5);
|
|
3609
|
+
this.opts.onSet(_i5);
|
|
3610
|
+
}
|
|
3611
|
+
}, {
|
|
3612
|
+
key: "onElementIgnored",
|
|
3613
|
+
value: function onElementIgnored(e) {
|
|
3614
|
+
var _this$setClasses4;
|
|
3615
|
+
|
|
3616
|
+
var t = this.setClasses(e.field, e.element, e.elements, (_this$setClasses4 = {}, _defineProperty(_this$setClasses4, this.opts.invalid, false), _defineProperty(_this$setClasses4, this.opts.valid, false), _defineProperty(_this$setClasses4, this.opts.validating, false), _this$setClasses4));
|
|
3617
|
+
var _i6 = {
|
|
3618
|
+
element: e.element,
|
|
3619
|
+
field: e.field,
|
|
3620
|
+
iconElement: t,
|
|
3621
|
+
status: "Ignored"
|
|
3622
|
+
};
|
|
3623
|
+
this.core.emit("plugins.icon.set", _i6);
|
|
3624
|
+
this.opts.onSet(_i6);
|
|
3625
|
+
}
|
|
3626
|
+
}, {
|
|
3627
|
+
key: "setClasses",
|
|
3628
|
+
value: function setClasses(e, _i7, n, l) {
|
|
3629
|
+
var s = _i7.getAttribute("type");
|
|
3630
|
+
|
|
3631
|
+
var d = "radio" === s || "checkbox" === s ? n[0] : _i7;
|
|
3632
|
+
|
|
3633
|
+
if (this.icons.has(d)) {
|
|
3634
|
+
var _e2 = this.icons.get(d);
|
|
3635
|
+
|
|
3636
|
+
c(_e2, l);
|
|
3637
|
+
return _e2;
|
|
3638
|
+
} else {
|
|
3639
|
+
return null;
|
|
3640
|
+
}
|
|
3641
|
+
}
|
|
3642
|
+
}]);
|
|
3643
|
+
|
|
3644
|
+
return i;
|
|
3645
|
+
}(t$4);
|
|
3646
|
+
|
|
3647
|
+
var i$1 = /*#__PURE__*/function (_e) {
|
|
3648
|
+
_inherits(i, _e);
|
|
3649
|
+
|
|
3650
|
+
var _super = _createSuper(i);
|
|
3651
|
+
|
|
3652
|
+
function i(e) {
|
|
3653
|
+
var _this;
|
|
3654
|
+
|
|
3655
|
+
_classCallCheck(this, i);
|
|
3656
|
+
|
|
3657
|
+
_this = _super.call(this, e);
|
|
3658
|
+
_this.invalidFields = new Map();
|
|
3659
|
+
_this.opts = Object.assign({}, {
|
|
3660
|
+
enabled: true
|
|
3661
|
+
}, e);
|
|
3662
|
+
_this.validatorHandler = _this.onValidatorValidated.bind(_assertThisInitialized(_this));
|
|
3663
|
+
_this.shouldValidateFilter = _this.shouldValidate.bind(_assertThisInitialized(_this));
|
|
3664
|
+
_this.fieldAddedHandler = _this.onFieldAdded.bind(_assertThisInitialized(_this));
|
|
3665
|
+
_this.elementNotValidatedHandler = _this.onElementNotValidated.bind(_assertThisInitialized(_this));
|
|
3666
|
+
_this.elementValidatingHandler = _this.onElementValidating.bind(_assertThisInitialized(_this));
|
|
3667
|
+
return _this;
|
|
3668
|
+
}
|
|
3669
|
+
|
|
3670
|
+
_createClass(i, [{
|
|
3671
|
+
key: "install",
|
|
3672
|
+
value: function install() {
|
|
3673
|
+
this.core.on("core.validator.validated", this.validatorHandler).on("core.field.added", this.fieldAddedHandler).on("core.element.notvalidated", this.elementNotValidatedHandler).on("core.element.validating", this.elementValidatingHandler).registerFilter("field-should-validate", this.shouldValidateFilter);
|
|
3674
|
+
}
|
|
3675
|
+
}, {
|
|
3676
|
+
key: "uninstall",
|
|
3677
|
+
value: function uninstall() {
|
|
3678
|
+
this.invalidFields.clear();
|
|
3679
|
+
this.core.off("core.validator.validated", this.validatorHandler).off("core.field.added", this.fieldAddedHandler).off("core.element.notvalidated", this.elementNotValidatedHandler).off("core.element.validating", this.elementValidatingHandler).deregisterFilter("field-should-validate", this.shouldValidateFilter);
|
|
3680
|
+
}
|
|
3681
|
+
}, {
|
|
3682
|
+
key: "shouldValidate",
|
|
3683
|
+
value: function shouldValidate(e, _i, t, l) {
|
|
3684
|
+
var d = (this.opts.enabled === true || this.opts.enabled[e] === true) && this.invalidFields.has(_i) && !!this.invalidFields.get(_i).length && this.invalidFields.get(_i).indexOf(l) === -1;
|
|
3685
|
+
return !d;
|
|
3686
|
+
}
|
|
3687
|
+
}, {
|
|
3688
|
+
key: "onValidatorValidated",
|
|
3689
|
+
value: function onValidatorValidated(e) {
|
|
3690
|
+
var _i2 = this.invalidFields.has(e.element) ? this.invalidFields.get(e.element) : [];
|
|
3691
|
+
|
|
3692
|
+
var t = _i2.indexOf(e.validator);
|
|
3693
|
+
|
|
3694
|
+
if (e.result.valid && t >= 0) {
|
|
3695
|
+
_i2.splice(t, 1);
|
|
3696
|
+
} else if (!e.result.valid && t === -1) {
|
|
3697
|
+
_i2.push(e.validator);
|
|
3698
|
+
}
|
|
3699
|
+
|
|
3700
|
+
this.invalidFields.set(e.element, _i2);
|
|
3701
|
+
}
|
|
3702
|
+
}, {
|
|
3703
|
+
key: "onFieldAdded",
|
|
3704
|
+
value: function onFieldAdded(e) {
|
|
3705
|
+
if (e.elements) {
|
|
3706
|
+
this.clearInvalidFields(e.elements);
|
|
3707
|
+
}
|
|
3708
|
+
}
|
|
3709
|
+
}, {
|
|
3710
|
+
key: "onElementNotValidated",
|
|
3711
|
+
value: function onElementNotValidated(e) {
|
|
3712
|
+
this.clearInvalidFields(e.elements);
|
|
3713
|
+
}
|
|
3714
|
+
}, {
|
|
3715
|
+
key: "onElementValidating",
|
|
3716
|
+
value: function onElementValidating(e) {
|
|
3717
|
+
this.clearInvalidFields(e.elements);
|
|
3718
|
+
}
|
|
3719
|
+
}, {
|
|
3720
|
+
key: "clearInvalidFields",
|
|
3721
|
+
value: function clearInvalidFields(e) {
|
|
3722
|
+
var _this2 = this;
|
|
3723
|
+
|
|
3724
|
+
e.forEach(function (e) {
|
|
3725
|
+
return _this2.invalidFields["delete"](e);
|
|
3726
|
+
});
|
|
3727
|
+
}
|
|
3728
|
+
}]);
|
|
3729
|
+
|
|
3730
|
+
return i;
|
|
3731
|
+
}(t$4);
|
|
3732
|
+
|
|
3733
|
+
var e = /*#__PURE__*/function (_t) {
|
|
3734
|
+
_inherits(e, _t);
|
|
3735
|
+
|
|
3736
|
+
var _super = _createSuper(e);
|
|
3737
|
+
|
|
3738
|
+
function e(t) {
|
|
3739
|
+
var _this;
|
|
3740
|
+
|
|
3741
|
+
_classCallCheck(this, e);
|
|
3742
|
+
|
|
3743
|
+
_this = _super.call(this, t);
|
|
3744
|
+
_this.isFormValid = false;
|
|
3745
|
+
_this.opts = Object.assign({}, {
|
|
3746
|
+
aspNetButton: false,
|
|
3747
|
+
buttons: function buttons(t) {
|
|
3748
|
+
return [].slice.call(t.querySelectorAll('[type="submit"]:not([formnovalidate])'));
|
|
3749
|
+
}
|
|
3750
|
+
}, t);
|
|
3751
|
+
_this.submitHandler = _this.handleSubmitEvent.bind(_assertThisInitialized(_this));
|
|
3752
|
+
_this.buttonClickHandler = _this.handleClickEvent.bind(_assertThisInitialized(_this));
|
|
3753
|
+
return _this;
|
|
3754
|
+
}
|
|
3755
|
+
|
|
3756
|
+
_createClass(e, [{
|
|
3757
|
+
key: "install",
|
|
3758
|
+
value: function install() {
|
|
3759
|
+
var _this2 = this;
|
|
3760
|
+
|
|
3761
|
+
if (!(this.core.getFormElement() instanceof HTMLFormElement)) {
|
|
3762
|
+
return;
|
|
3763
|
+
}
|
|
3764
|
+
|
|
3765
|
+
var t = this.core.getFormElement();
|
|
3766
|
+
this.submitButtons = this.opts.buttons(t);
|
|
3767
|
+
t.setAttribute("novalidate", "novalidate");
|
|
3768
|
+
t.addEventListener("submit", this.submitHandler);
|
|
3769
|
+
this.hiddenClickedEle = document.createElement("input");
|
|
3770
|
+
this.hiddenClickedEle.setAttribute("type", "hidden");
|
|
3771
|
+
t.appendChild(this.hiddenClickedEle);
|
|
3772
|
+
this.submitButtons.forEach(function (t) {
|
|
3773
|
+
t.addEventListener("click", _this2.buttonClickHandler);
|
|
3774
|
+
});
|
|
3775
|
+
}
|
|
3776
|
+
}, {
|
|
3777
|
+
key: "uninstall",
|
|
3778
|
+
value: function uninstall() {
|
|
3779
|
+
var _this3 = this;
|
|
3780
|
+
|
|
3781
|
+
var t = this.core.getFormElement();
|
|
3782
|
+
|
|
3783
|
+
if (t instanceof HTMLFormElement) {
|
|
3784
|
+
t.removeEventListener("submit", this.submitHandler);
|
|
3785
|
+
}
|
|
3786
|
+
|
|
3787
|
+
this.submitButtons.forEach(function (t) {
|
|
3788
|
+
t.removeEventListener("click", _this3.buttonClickHandler);
|
|
3789
|
+
});
|
|
3790
|
+
this.hiddenClickedEle.parentElement.removeChild(this.hiddenClickedEle);
|
|
3791
|
+
}
|
|
3792
|
+
}, {
|
|
3793
|
+
key: "handleSubmitEvent",
|
|
3794
|
+
value: function handleSubmitEvent(t) {
|
|
3795
|
+
this.validateForm(t);
|
|
3796
|
+
}
|
|
3797
|
+
}, {
|
|
3798
|
+
key: "handleClickEvent",
|
|
3799
|
+
value: function handleClickEvent(t) {
|
|
3800
|
+
var _e = t.currentTarget;
|
|
3801
|
+
|
|
3802
|
+
if (_e instanceof HTMLElement) {
|
|
3803
|
+
if (this.opts.aspNetButton && this.isFormValid === true) ; else {
|
|
3804
|
+
var _e3 = this.core.getFormElement();
|
|
3805
|
+
|
|
3806
|
+
_e3.removeEventListener("submit", this.submitHandler);
|
|
3807
|
+
|
|
3808
|
+
this.clickedButton = t.target;
|
|
3809
|
+
var i = this.clickedButton.getAttribute("name");
|
|
3810
|
+
var s = this.clickedButton.getAttribute("value");
|
|
3811
|
+
|
|
3812
|
+
if (i && s) {
|
|
3813
|
+
this.hiddenClickedEle.setAttribute("name", i);
|
|
3814
|
+
this.hiddenClickedEle.setAttribute("value", s);
|
|
3815
|
+
}
|
|
3816
|
+
|
|
3817
|
+
this.validateForm(t);
|
|
3818
|
+
}
|
|
3819
|
+
}
|
|
3820
|
+
}
|
|
3821
|
+
}, {
|
|
3822
|
+
key: "validateForm",
|
|
3823
|
+
value: function validateForm(t) {
|
|
3824
|
+
var _this4 = this;
|
|
3825
|
+
|
|
3826
|
+
t.preventDefault();
|
|
3827
|
+
this.core.validate().then(function (t) {
|
|
3828
|
+
if (t === "Valid" && _this4.opts.aspNetButton && !_this4.isFormValid && _this4.clickedButton) {
|
|
3829
|
+
_this4.isFormValid = true;
|
|
3830
|
+
|
|
3831
|
+
_this4.clickedButton.removeEventListener("click", _this4.buttonClickHandler);
|
|
3832
|
+
|
|
3833
|
+
_this4.clickedButton.click();
|
|
3834
|
+
}
|
|
3835
|
+
});
|
|
3836
|
+
}
|
|
3837
|
+
}]);
|
|
3838
|
+
|
|
3839
|
+
return e;
|
|
3840
|
+
}(t$4);
|
|
3841
|
+
|
|
3842
|
+
var i = /*#__PURE__*/function (_t) {
|
|
3843
|
+
_inherits(i, _t);
|
|
3844
|
+
|
|
3845
|
+
var _super = _createSuper(i);
|
|
3846
|
+
|
|
3847
|
+
function i(t) {
|
|
3848
|
+
var _this;
|
|
3849
|
+
|
|
3850
|
+
_classCallCheck(this, i);
|
|
3851
|
+
|
|
3852
|
+
_this = _super.call(this, t);
|
|
3853
|
+
_this.messages = new Map();
|
|
3854
|
+
_this.opts = Object.assign({}, {
|
|
3855
|
+
placement: "top",
|
|
3856
|
+
trigger: "click"
|
|
3857
|
+
}, t);
|
|
3858
|
+
_this.iconPlacedHandler = _this.onIconPlaced.bind(_assertThisInitialized(_this));
|
|
3859
|
+
_this.validatorValidatedHandler = _this.onValidatorValidated.bind(_assertThisInitialized(_this));
|
|
3860
|
+
_this.elementValidatedHandler = _this.onElementValidated.bind(_assertThisInitialized(_this));
|
|
3861
|
+
_this.documentClickHandler = _this.onDocumentClicked.bind(_assertThisInitialized(_this));
|
|
3862
|
+
return _this;
|
|
3863
|
+
}
|
|
3864
|
+
|
|
3865
|
+
_createClass(i, [{
|
|
3866
|
+
key: "install",
|
|
3867
|
+
value: function install() {
|
|
3868
|
+
this.tip = document.createElement("div");
|
|
3869
|
+
c(this.tip, _defineProperty({
|
|
3870
|
+
"fv-plugins-tooltip": true
|
|
3871
|
+
}, "fv-plugins-tooltip--".concat(this.opts.placement), true));
|
|
3872
|
+
document.body.appendChild(this.tip);
|
|
3873
|
+
this.core.on("plugins.icon.placed", this.iconPlacedHandler).on("core.validator.validated", this.validatorValidatedHandler).on("core.element.validated", this.elementValidatedHandler);
|
|
3874
|
+
|
|
3875
|
+
if ("click" === this.opts.trigger) {
|
|
3876
|
+
document.addEventListener("click", this.documentClickHandler);
|
|
3877
|
+
}
|
|
3878
|
+
}
|
|
3879
|
+
}, {
|
|
3880
|
+
key: "uninstall",
|
|
3881
|
+
value: function uninstall() {
|
|
3882
|
+
this.messages.clear();
|
|
3883
|
+
document.body.removeChild(this.tip);
|
|
3884
|
+
this.core.off("plugins.icon.placed", this.iconPlacedHandler).off("core.validator.validated", this.validatorValidatedHandler).off("core.element.validated", this.elementValidatedHandler);
|
|
3885
|
+
|
|
3886
|
+
if ("click" === this.opts.trigger) {
|
|
3887
|
+
document.removeEventListener("click", this.documentClickHandler);
|
|
3888
|
+
}
|
|
3889
|
+
}
|
|
3890
|
+
}, {
|
|
3891
|
+
key: "onIconPlaced",
|
|
3892
|
+
value: function onIconPlaced(t) {
|
|
3893
|
+
var _this2 = this;
|
|
3894
|
+
|
|
3895
|
+
c(t.iconElement, {
|
|
3896
|
+
"fv-plugins-tooltip-icon": true
|
|
3897
|
+
});
|
|
3898
|
+
|
|
3899
|
+
switch (this.opts.trigger) {
|
|
3900
|
+
case "hover":
|
|
3901
|
+
t.iconElement.addEventListener("mouseenter", function (e) {
|
|
3902
|
+
return _this2.show(t.element, e);
|
|
3903
|
+
});
|
|
3904
|
+
t.iconElement.addEventListener("mouseleave", function (t) {
|
|
3905
|
+
return _this2.hide();
|
|
3906
|
+
});
|
|
3907
|
+
break;
|
|
3908
|
+
|
|
3909
|
+
case "click":
|
|
3910
|
+
default:
|
|
3911
|
+
t.iconElement.addEventListener("click", function (e) {
|
|
3912
|
+
return _this2.show(t.element, e);
|
|
3913
|
+
});
|
|
3914
|
+
break;
|
|
3915
|
+
}
|
|
3916
|
+
}
|
|
3917
|
+
}, {
|
|
3918
|
+
key: "onValidatorValidated",
|
|
3919
|
+
value: function onValidatorValidated(t) {
|
|
3920
|
+
if (!t.result.valid) {
|
|
3921
|
+
var _e2 = t.elements;
|
|
3922
|
+
|
|
3923
|
+
var _i4 = t.element.getAttribute("type");
|
|
3924
|
+
|
|
3925
|
+
var s = "radio" === _i4 || "checkbox" === _i4 ? _e2[0] : t.element;
|
|
3926
|
+
var o = typeof t.result.message === "string" ? t.result.message : t.result.message[this.core.getLocale()];
|
|
3927
|
+
this.messages.set(s, o);
|
|
3928
|
+
}
|
|
3929
|
+
}
|
|
3930
|
+
}, {
|
|
3931
|
+
key: "onElementValidated",
|
|
3932
|
+
value: function onElementValidated(t) {
|
|
3933
|
+
if (t.valid) {
|
|
3934
|
+
var _e3 = t.elements;
|
|
3935
|
+
|
|
3936
|
+
var _i5 = t.element.getAttribute("type");
|
|
3937
|
+
|
|
3938
|
+
var s = "radio" === _i5 || "checkbox" === _i5 ? _e3[0] : t.element;
|
|
3939
|
+
this.messages["delete"](s);
|
|
3940
|
+
}
|
|
3941
|
+
}
|
|
3942
|
+
}, {
|
|
3943
|
+
key: "onDocumentClicked",
|
|
3944
|
+
value: function onDocumentClicked(t) {
|
|
3945
|
+
this.hide();
|
|
3946
|
+
}
|
|
3947
|
+
}, {
|
|
3948
|
+
key: "show",
|
|
3949
|
+
value: function show(t, _i3) {
|
|
3950
|
+
_i3.preventDefault();
|
|
3951
|
+
|
|
3952
|
+
_i3.stopPropagation();
|
|
3953
|
+
|
|
3954
|
+
if (!this.messages.has(t)) {
|
|
3955
|
+
return;
|
|
3956
|
+
}
|
|
3957
|
+
|
|
3958
|
+
c(this.tip, {
|
|
3959
|
+
"fv-plugins-tooltip--hide": false
|
|
3960
|
+
});
|
|
3961
|
+
this.tip.innerHTML = "<div class=\"fv-plugins-tooltip__content\">".concat(this.messages.get(t), "</div>");
|
|
3962
|
+
var s = _i3.target;
|
|
3963
|
+
var o = s.getBoundingClientRect();
|
|
3964
|
+
|
|
3965
|
+
var _this$tip$getBounding = this.tip.getBoundingClientRect(),
|
|
3966
|
+
l = _this$tip$getBounding.height,
|
|
3967
|
+
n = _this$tip$getBounding.width;
|
|
3968
|
+
|
|
3969
|
+
var a = 0;
|
|
3970
|
+
var d = 0;
|
|
3971
|
+
|
|
3972
|
+
switch (this.opts.placement) {
|
|
3973
|
+
case "bottom":
|
|
3974
|
+
a = o.top + o.height;
|
|
3975
|
+
d = o.left + o.width / 2 - n / 2;
|
|
3976
|
+
break;
|
|
3977
|
+
|
|
3978
|
+
case "bottom-left":
|
|
3979
|
+
a = o.top + o.height;
|
|
3980
|
+
d = o.left;
|
|
3981
|
+
break;
|
|
3982
|
+
|
|
3983
|
+
case "bottom-right":
|
|
3984
|
+
a = o.top + o.height;
|
|
3985
|
+
d = o.left + o.width - n;
|
|
3986
|
+
break;
|
|
3987
|
+
|
|
3988
|
+
case "left":
|
|
3989
|
+
a = o.top + o.height / 2 - l / 2;
|
|
3990
|
+
d = o.left - n;
|
|
3991
|
+
break;
|
|
3992
|
+
|
|
3993
|
+
case "right":
|
|
3994
|
+
a = o.top + o.height / 2 - l / 2;
|
|
3995
|
+
d = o.left + o.width;
|
|
3996
|
+
break;
|
|
3997
|
+
|
|
3998
|
+
case "top-left":
|
|
3999
|
+
a = o.top - l;
|
|
4000
|
+
d = o.left;
|
|
4001
|
+
break;
|
|
4002
|
+
|
|
4003
|
+
case "top-right":
|
|
4004
|
+
a = o.top - l;
|
|
4005
|
+
d = o.left + o.width - n;
|
|
4006
|
+
break;
|
|
4007
|
+
|
|
4008
|
+
case "top":
|
|
4009
|
+
default:
|
|
4010
|
+
a = o.top - l;
|
|
4011
|
+
d = o.left + o.width / 2 - n / 2;
|
|
4012
|
+
break;
|
|
4013
|
+
}
|
|
4014
|
+
|
|
4015
|
+
var c$1 = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
|
|
4016
|
+
var r = window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0;
|
|
4017
|
+
a = a + c$1;
|
|
4018
|
+
d = d + r;
|
|
4019
|
+
this.tip.setAttribute("style", "top: ".concat(a, "px; left: ").concat(d, "px"));
|
|
4020
|
+
}
|
|
4021
|
+
}, {
|
|
4022
|
+
key: "hide",
|
|
4023
|
+
value: function hide() {
|
|
4024
|
+
c(this.tip, {
|
|
4025
|
+
"fv-plugins-tooltip--hide": true
|
|
4026
|
+
});
|
|
4027
|
+
}
|
|
4028
|
+
}]);
|
|
4029
|
+
|
|
4030
|
+
return i;
|
|
4031
|
+
}(t$4);
|
|
4032
|
+
|
|
4033
|
+
var t = /*#__PURE__*/function (_e) {
|
|
4034
|
+
_inherits(t, _e);
|
|
4035
|
+
|
|
4036
|
+
var _super = _createSuper(t);
|
|
4037
|
+
|
|
4038
|
+
function t(e) {
|
|
4039
|
+
var _this;
|
|
4040
|
+
|
|
4041
|
+
_classCallCheck(this, t);
|
|
4042
|
+
|
|
4043
|
+
_this = _super.call(this, e);
|
|
4044
|
+
_this.handlers = [];
|
|
4045
|
+
_this.timers = new Map();
|
|
4046
|
+
|
|
4047
|
+
var _t = document.createElement("div");
|
|
4048
|
+
|
|
4049
|
+
_this.defaultEvent = !("oninput" in _t) ? "keyup" : "input";
|
|
4050
|
+
_this.opts = Object.assign({}, {
|
|
4051
|
+
delay: 0,
|
|
4052
|
+
event: _this.defaultEvent,
|
|
4053
|
+
threshold: 0
|
|
4054
|
+
}, e);
|
|
4055
|
+
_this.fieldAddedHandler = _this.onFieldAdded.bind(_assertThisInitialized(_this));
|
|
4056
|
+
_this.fieldRemovedHandler = _this.onFieldRemoved.bind(_assertThisInitialized(_this));
|
|
4057
|
+
return _this;
|
|
4058
|
+
}
|
|
4059
|
+
|
|
4060
|
+
_createClass(t, [{
|
|
4061
|
+
key: "install",
|
|
4062
|
+
value: function install() {
|
|
4063
|
+
this.core.on("core.field.added", this.fieldAddedHandler).on("core.field.removed", this.fieldRemovedHandler);
|
|
4064
|
+
}
|
|
4065
|
+
}, {
|
|
4066
|
+
key: "uninstall",
|
|
4067
|
+
value: function uninstall() {
|
|
4068
|
+
this.handlers.forEach(function (e) {
|
|
4069
|
+
return e.element.removeEventListener(e.event, e.handler);
|
|
4070
|
+
});
|
|
4071
|
+
this.handlers = [];
|
|
4072
|
+
this.timers.forEach(function (e) {
|
|
4073
|
+
return window.clearTimeout(e);
|
|
4074
|
+
});
|
|
4075
|
+
this.timers.clear();
|
|
4076
|
+
this.core.off("core.field.added", this.fieldAddedHandler).off("core.field.removed", this.fieldRemovedHandler);
|
|
4077
|
+
}
|
|
4078
|
+
}, {
|
|
4079
|
+
key: "prepareHandler",
|
|
4080
|
+
value: function prepareHandler(e, _t2) {
|
|
4081
|
+
var _this2 = this;
|
|
4082
|
+
|
|
4083
|
+
_t2.forEach(function (_t3) {
|
|
4084
|
+
var i = [];
|
|
4085
|
+
|
|
4086
|
+
if (!!_this2.opts.event && _this2.opts.event[e] === false) {
|
|
4087
|
+
i = [];
|
|
4088
|
+
} else if (!!_this2.opts.event && !!_this2.opts.event[e]) {
|
|
4089
|
+
i = _this2.opts.event[e].split(" ");
|
|
4090
|
+
} else if ("string" === typeof _this2.opts.event && _this2.opts.event !== _this2.defaultEvent) {
|
|
4091
|
+
i = _this2.opts.event.split(" ");
|
|
4092
|
+
} else {
|
|
4093
|
+
var _e2 = _t3.getAttribute("type");
|
|
4094
|
+
|
|
4095
|
+
var s = _t3.tagName.toLowerCase();
|
|
4096
|
+
|
|
4097
|
+
var n = "radio" === _e2 || "checkbox" === _e2 || "file" === _e2 || "select" === s ? "change" : _this2.ieVersion >= 10 && _t3.getAttribute("placeholder") ? "keyup" : _this2.defaultEvent;
|
|
4098
|
+
i = [n];
|
|
4099
|
+
}
|
|
4100
|
+
|
|
4101
|
+
i.forEach(function (i) {
|
|
4102
|
+
var s = function s(i) {
|
|
4103
|
+
return _this2.handleEvent(i, e, _t3);
|
|
4104
|
+
};
|
|
4105
|
+
|
|
4106
|
+
_this2.handlers.push({
|
|
4107
|
+
element: _t3,
|
|
4108
|
+
event: i,
|
|
4109
|
+
field: e,
|
|
4110
|
+
handler: s
|
|
4111
|
+
});
|
|
4112
|
+
|
|
4113
|
+
_t3.addEventListener(i, s);
|
|
4114
|
+
});
|
|
4115
|
+
});
|
|
4116
|
+
}
|
|
4117
|
+
}, {
|
|
4118
|
+
key: "handleEvent",
|
|
4119
|
+
value: function handleEvent(e, _t4, i) {
|
|
4120
|
+
var _this3 = this;
|
|
4121
|
+
|
|
4122
|
+
if (this.exceedThreshold(_t4, i) && this.core.executeFilter("plugins-trigger-should-validate", true, [_t4, i])) {
|
|
4123
|
+
var s = function s() {
|
|
4124
|
+
return _this3.core.validateElement(_t4, i).then(function (s) {
|
|
4125
|
+
_this3.core.emit("plugins.trigger.executed", {
|
|
4126
|
+
element: i,
|
|
4127
|
+
event: e,
|
|
4128
|
+
field: _t4
|
|
4129
|
+
});
|
|
4130
|
+
});
|
|
4131
|
+
};
|
|
4132
|
+
|
|
4133
|
+
var n = this.opts.delay[_t4] || this.opts.delay;
|
|
4134
|
+
|
|
4135
|
+
if (n === 0) {
|
|
4136
|
+
s();
|
|
4137
|
+
} else {
|
|
4138
|
+
var _e3 = this.timers.get(i);
|
|
4139
|
+
|
|
4140
|
+
if (_e3) {
|
|
4141
|
+
window.clearTimeout(_e3);
|
|
4142
|
+
}
|
|
4143
|
+
|
|
4144
|
+
this.timers.set(i, window.setTimeout(s, n * 1e3));
|
|
4145
|
+
}
|
|
4146
|
+
}
|
|
4147
|
+
}
|
|
4148
|
+
}, {
|
|
4149
|
+
key: "onFieldAdded",
|
|
4150
|
+
value: function onFieldAdded(e) {
|
|
4151
|
+
this.handlers.filter(function (_t5) {
|
|
4152
|
+
return _t5.field === e.field;
|
|
4153
|
+
}).forEach(function (e) {
|
|
4154
|
+
return e.element.removeEventListener(e.event, e.handler);
|
|
4155
|
+
});
|
|
4156
|
+
this.prepareHandler(e.field, e.elements);
|
|
4157
|
+
}
|
|
4158
|
+
}, {
|
|
4159
|
+
key: "onFieldRemoved",
|
|
4160
|
+
value: function onFieldRemoved(e) {
|
|
4161
|
+
this.handlers.filter(function (_t6) {
|
|
4162
|
+
return _t6.field === e.field && e.elements.indexOf(_t6.element) >= 0;
|
|
4163
|
+
}).forEach(function (e) {
|
|
4164
|
+
return e.element.removeEventListener(e.event, e.handler);
|
|
4165
|
+
});
|
|
4166
|
+
}
|
|
4167
|
+
}, {
|
|
4168
|
+
key: "exceedThreshold",
|
|
4169
|
+
value: function exceedThreshold(e, _t7) {
|
|
4170
|
+
var i = this.opts.threshold[e] === 0 || this.opts.threshold === 0 ? false : this.opts.threshold[e] || this.opts.threshold;
|
|
4171
|
+
|
|
4172
|
+
if (!i) {
|
|
4173
|
+
return true;
|
|
4174
|
+
}
|
|
4175
|
+
|
|
4176
|
+
var s = _t7.getAttribute("type");
|
|
4177
|
+
|
|
4178
|
+
if (["button", "checkbox", "file", "hidden", "image", "radio", "reset", "submit"].indexOf(s) !== -1) {
|
|
4179
|
+
return true;
|
|
4180
|
+
}
|
|
4181
|
+
|
|
4182
|
+
var n = this.core.getElementValue(e, _t7);
|
|
4183
|
+
return n.length >= i;
|
|
4184
|
+
}
|
|
4185
|
+
}]);
|
|
4186
|
+
|
|
4187
|
+
return t;
|
|
4188
|
+
}(t$4);
|
|
4189
|
+
|
|
4190
|
+
var index$1 = {
|
|
4191
|
+
Alias: e$4,
|
|
4192
|
+
Aria: i$3,
|
|
4193
|
+
Declarative: t$3,
|
|
4194
|
+
DefaultSubmit: o,
|
|
4195
|
+
Dependency: e$3,
|
|
4196
|
+
Excluded: e$2,
|
|
4197
|
+
FieldStatus: t$2,
|
|
4198
|
+
Framework: l,
|
|
4199
|
+
Icon: i$2,
|
|
4200
|
+
Message: s$1,
|
|
4201
|
+
Sequence: i$1,
|
|
4202
|
+
SubmitButton: e,
|
|
4203
|
+
Tooltip: i,
|
|
4204
|
+
Trigger: t
|
|
4205
|
+
};
|
|
4206
|
+
|
|
4207
|
+
function s(s, t) {
|
|
4208
|
+
return s.classList ? s.classList.contains(t) : new RegExp("(^| )".concat(t, "( |$)"), "gi").test(s.className);
|
|
4209
|
+
}
|
|
4210
|
+
|
|
4211
|
+
var index = {
|
|
4212
|
+
call: t$c,
|
|
4213
|
+
classSet: c,
|
|
4214
|
+
closest: t$1,
|
|
4215
|
+
fetch: e$6,
|
|
4216
|
+
format: r$2,
|
|
4217
|
+
hasClass: s,
|
|
4218
|
+
isValidDate: t$9
|
|
4219
|
+
};
|
|
4220
|
+
|
|
4221
|
+
var p = {};
|
|
4222
|
+
|
|
4223
|
+
exports.Plugin = t$4;
|
|
4224
|
+
exports.algorithms = index$3;
|
|
4225
|
+
exports.filters = index$2;
|
|
4226
|
+
exports.formValidation = r;
|
|
4227
|
+
exports.locales = p;
|
|
4228
|
+
exports.plugins = index$1;
|
|
4229
|
+
exports.utils = index;
|
|
4230
|
+
exports.validators = s$3;
|
|
4231
|
+
|
|
4232
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4233
|
+
|
|
4234
|
+
}));
|