@frollo/frollo-web-ui 0.0.22 → 0.1.2
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/cjs/index.js +635 -421
- package/esm/{add-to-unscopables-c6a09beb.js → add-to-unscopables-81c17489.js} +139 -99
- package/esm/{es.array.includes-1b7043c3.js → es.array.includes-debcb50f.js} +9 -3
- package/esm/{es.function.name-f416c9da.js → es.function.name-e746680f.js} +1 -1
- package/esm/{function-name-982253be.js → function-name-f0c1223e.js} +52 -61
- package/esm/{fw-button-0826e6fc.js → fw-button-ab906734.js} +12 -4
- package/esm/fw-button.js +4 -4
- package/esm/fw-card.js +6 -3
- package/esm/fw-checkbox.js +13 -8
- package/esm/fw-form.js +1 -1
- package/esm/fw-input.js +21 -11
- package/esm/fw-modal.js +7 -475
- package/esm/fw-navigation-menu.js +80 -24
- package/esm/fw-tabs.js +4 -3
- package/esm/{index-9de6159f.js → index-5ee56f7d.js} +24 -75
- package/esm/index-963039a3.js +475 -0
- package/esm/index.js +128 -40
- package/esm/to-string-139f1ee8.js +52 -0
- package/esm/{vee-validate.esm-028c6424.js → vee-validate.esm-b64acab1.js} +62 -9
- package/frollo-web-ui.esm.js +669 -421
- package/index.d.ts +28 -11
- package/package.json +20 -17
- package/tailwind.config.js +8 -8
- package/types/components/fw-button/fw-button.vue.d.ts +1 -0
- package/types/components/fw-card/fw-card.vue.d.ts +1 -0
- package/types/components/fw-checkbox/fw-checkbox.vue.d.ts +5 -4
- package/types/components/fw-checkbox/index.types.d.ts +1 -1
- package/types/components/fw-input/fw-input.vue.d.ts +17 -4
- package/types/components/fw-input/index.types.d.ts +1 -1
- package/types/components/fw-navigation-menu/fw-navigation-menu.vue.d.ts +3 -0
- package/types/index.esm.d.ts +1 -1
- package/types/services/modal.d.ts +1 -1
package/esm/index.js
CHANGED
|
@@ -1,18 +1,27 @@
|
|
|
1
|
-
import { f as fails$1, d as documentCreateElement$1, g as global$
|
|
2
|
-
import { _ as _export,
|
|
3
|
-
import { a as arrayIteration,
|
|
1
|
+
import { f as fails$1, d as documentCreateElement$1, g as global$4, a as descriptors, b as functionUncurryThis, c as functionBindNative, i as isCallable$1, e as engineUserAgent } from './function-name-f0c1223e.js';
|
|
2
|
+
import { _ as _export, d as defineBuiltIn$1, c as createNonEnumerableProperty$1, o as objectKeys$1, t as toIndexedObject$1, a as objectPropertyIsEnumerable } from './add-to-unscopables-81c17489.js';
|
|
3
|
+
import { a as arrayIteration, s as script$5, b as script$6 } from './index-5ee56f7d.js';
|
|
4
|
+
export { b as FwTab, s as FwTabs } from './index-5ee56f7d.js';
|
|
5
|
+
import { t as toStringTagSupport, c as classof$1 } from './to-string-139f1ee8.js';
|
|
4
6
|
import './fw-form.js';
|
|
5
7
|
import { FwInput as script } from './fw-input.js';
|
|
8
|
+
export { FwInput } from './fw-input.js';
|
|
6
9
|
import { FwCheckbox as script$1 } from './fw-checkbox.js';
|
|
10
|
+
export { FwCheckbox } from './fw-checkbox.js';
|
|
7
11
|
import { FwCard as script$2 } from './fw-card.js';
|
|
12
|
+
export { FwCard } from './fw-card.js';
|
|
8
13
|
import './fw-button.js';
|
|
9
14
|
import { FwNavigationMenu as script$4 } from './fw-navigation-menu.js';
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
import './
|
|
15
|
+
export { FwNavigationMenu } from './fw-navigation-menu.js';
|
|
16
|
+
import { s as script$7, u as uniqueId } from './index-963039a3.js';
|
|
17
|
+
export { s as FwModal } from './index-963039a3.js';
|
|
18
|
+
import { F as Form } from './vee-validate.esm-b64acab1.js';
|
|
19
|
+
export { F as FwForm } from './vee-validate.esm-b64acab1.js';
|
|
20
|
+
import { s as script$3 } from './fw-button-ab906734.js';
|
|
21
|
+
export { s as FwButton } from './fw-button-ab906734.js';
|
|
22
|
+
import { createApp } from 'vue';
|
|
23
|
+
import './es.array.includes-debcb50f.js';
|
|
24
|
+
import './es.function.name-e746680f.js';
|
|
16
25
|
import './style-inject.es-1f59c1d0.js';
|
|
17
26
|
|
|
18
27
|
function _arrayWithHoles(arr) {
|
|
@@ -99,17 +108,17 @@ var STRICT_METHOD = arrayMethodIsStrict('forEach');
|
|
|
99
108
|
// https://tc39.es/ecma262/#sec-array.prototype.foreach
|
|
100
109
|
var arrayForEach = !STRICT_METHOD ? function forEach(callbackfn /* , thisArg */) {
|
|
101
110
|
return $forEach(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
|
|
102
|
-
// eslint-disable-next-line es/no-array-prototype-foreach -- safe
|
|
111
|
+
// eslint-disable-next-line es-x/no-array-prototype-foreach -- safe
|
|
103
112
|
} : [].forEach;
|
|
104
113
|
|
|
105
114
|
'use strict';
|
|
106
|
-
var $$
|
|
115
|
+
var $$3 = _export;
|
|
107
116
|
var forEach$1 = arrayForEach;
|
|
108
117
|
|
|
109
118
|
// `Array.prototype.forEach` method
|
|
110
119
|
// https://tc39.es/ecma262/#sec-array.prototype.foreach
|
|
111
|
-
// eslint-disable-next-line es/no-array-prototype-foreach -- safe
|
|
112
|
-
$$
|
|
120
|
+
// eslint-disable-next-line es-x/no-array-prototype-foreach -- safe
|
|
121
|
+
$$3({ target: 'Array', proto: true, forced: [].forEach != forEach$1 }, {
|
|
113
122
|
forEach: forEach$1
|
|
114
123
|
});
|
|
115
124
|
|
|
@@ -126,13 +135,13 @@ var objectToString = TO_STRING_TAG_SUPPORT$1 ? {}.toString : function toString()
|
|
|
126
135
|
};
|
|
127
136
|
|
|
128
137
|
var TO_STRING_TAG_SUPPORT = toStringTagSupport;
|
|
129
|
-
var
|
|
138
|
+
var defineBuiltIn = defineBuiltIn$1;
|
|
130
139
|
var toString = objectToString;
|
|
131
140
|
|
|
132
141
|
// `Object.prototype.toString` method
|
|
133
142
|
// https://tc39.es/ecma262/#sec-object.prototype.tostring
|
|
134
143
|
if (!TO_STRING_TAG_SUPPORT) {
|
|
135
|
-
|
|
144
|
+
defineBuiltIn(Object.prototype, 'toString', toString, { unsafe: true });
|
|
136
145
|
}
|
|
137
146
|
|
|
138
147
|
var web_domCollections_forEach = {};
|
|
@@ -181,7 +190,7 @@ var DOMTokenListPrototype$1 = classList && classList.constructor && classList.co
|
|
|
181
190
|
|
|
182
191
|
var domTokenListPrototype = DOMTokenListPrototype$1 === Object.prototype ? undefined : DOMTokenListPrototype$1;
|
|
183
192
|
|
|
184
|
-
var global = global$
|
|
193
|
+
var global$3 = global$4;
|
|
185
194
|
var DOMIterables = domIterables;
|
|
186
195
|
var DOMTokenListPrototype = domTokenListPrototype;
|
|
187
196
|
var forEach = arrayForEach;
|
|
@@ -198,7 +207,7 @@ var handlePrototype = function (CollectionPrototype) {
|
|
|
198
207
|
|
|
199
208
|
for (var COLLECTION_NAME in DOMIterables) {
|
|
200
209
|
if (DOMIterables[COLLECTION_NAME]) {
|
|
201
|
-
handlePrototype(global[COLLECTION_NAME] && global[COLLECTION_NAME].prototype);
|
|
210
|
+
handlePrototype(global$3[COLLECTION_NAME] && global$3[COLLECTION_NAME].prototype);
|
|
202
211
|
}
|
|
203
212
|
}
|
|
204
213
|
|
|
@@ -207,13 +216,13 @@ handlePrototype(DOMTokenListPrototype);
|
|
|
207
216
|
var es_object_entries = {};
|
|
208
217
|
|
|
209
218
|
var DESCRIPTORS = descriptors;
|
|
210
|
-
var uncurryThis = functionUncurryThis;
|
|
219
|
+
var uncurryThis$1 = functionUncurryThis;
|
|
211
220
|
var objectKeys = objectKeys$1;
|
|
212
221
|
var toIndexedObject = toIndexedObject$1;
|
|
213
222
|
var $propertyIsEnumerable = objectPropertyIsEnumerable.f;
|
|
214
223
|
|
|
215
|
-
var propertyIsEnumerable = uncurryThis($propertyIsEnumerable);
|
|
216
|
-
var push = uncurryThis([].push);
|
|
224
|
+
var propertyIsEnumerable = uncurryThis$1($propertyIsEnumerable);
|
|
225
|
+
var push = uncurryThis$1([].push);
|
|
217
226
|
|
|
218
227
|
// `Object.{ entries, values }` methods implementation
|
|
219
228
|
var createMethod = function (TO_ENTRIES) {
|
|
@@ -243,12 +252,12 @@ var objectToArray = {
|
|
|
243
252
|
values: createMethod(false)
|
|
244
253
|
};
|
|
245
254
|
|
|
246
|
-
var
|
|
255
|
+
var $$2 = _export;
|
|
247
256
|
var $entries = objectToArray.entries;
|
|
248
257
|
|
|
249
258
|
// `Object.entries` method
|
|
250
259
|
// https://tc39.es/ecma262/#sec-object.entries
|
|
251
|
-
|
|
260
|
+
$$2({ target: 'Object', stat: true }, {
|
|
252
261
|
entries: function entries(O) {
|
|
253
262
|
return $entries(O);
|
|
254
263
|
}
|
|
@@ -310,36 +319,115 @@ function _objectSpread2(target) {
|
|
|
310
319
|
return target;
|
|
311
320
|
}
|
|
312
321
|
|
|
313
|
-
var
|
|
314
|
-
|
|
322
|
+
var web_timers = {};
|
|
323
|
+
|
|
324
|
+
var web_setInterval = {};
|
|
325
|
+
|
|
326
|
+
var NATIVE_BIND = functionBindNative;
|
|
327
|
+
|
|
328
|
+
var FunctionPrototype = Function.prototype;
|
|
329
|
+
var apply$1 = FunctionPrototype.apply;
|
|
330
|
+
var call = FunctionPrototype.call;
|
|
331
|
+
|
|
332
|
+
// eslint-disable-next-line es-x/no-reflect -- safe
|
|
333
|
+
var functionApply = typeof Reflect == 'object' && Reflect.apply || (NATIVE_BIND ? call.bind(apply$1) : function () {
|
|
334
|
+
return call.apply(apply$1, arguments);
|
|
335
|
+
});
|
|
315
336
|
|
|
337
|
+
var uncurryThis = functionUncurryThis;
|
|
338
|
+
|
|
339
|
+
var arraySlice$1 = uncurryThis([].slice);
|
|
340
|
+
|
|
341
|
+
var $TypeError = TypeError;
|
|
342
|
+
|
|
343
|
+
var validateArgumentsLength$1 = function (passed, required) {
|
|
344
|
+
if (passed < required) throw $TypeError('Not enough arguments');
|
|
345
|
+
return passed;
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
var global$2 = global$4;
|
|
349
|
+
var apply = functionApply;
|
|
350
|
+
var isCallable = isCallable$1;
|
|
351
|
+
var userAgent = engineUserAgent;
|
|
352
|
+
var arraySlice = arraySlice$1;
|
|
353
|
+
var validateArgumentsLength = validateArgumentsLength$1;
|
|
354
|
+
|
|
355
|
+
var MSIE = /MSIE .\./.test(userAgent); // <- dirty ie9- check
|
|
356
|
+
var Function$1 = global$2.Function;
|
|
357
|
+
|
|
358
|
+
var wrap = function (scheduler) {
|
|
359
|
+
return MSIE ? function (handler, timeout /* , ...arguments */) {
|
|
360
|
+
var boundArgs = validateArgumentsLength(arguments.length, 1) > 2;
|
|
361
|
+
var fn = isCallable(handler) ? handler : Function$1(handler);
|
|
362
|
+
var args = boundArgs ? arraySlice(arguments, 2) : undefined;
|
|
363
|
+
return scheduler(boundArgs ? function () {
|
|
364
|
+
apply(fn, this, args);
|
|
365
|
+
} : fn, timeout);
|
|
366
|
+
} : scheduler;
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
// ie9- setTimeout & setInterval additional parameters fix
|
|
370
|
+
// https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#timers
|
|
371
|
+
var schedulersFix = {
|
|
372
|
+
// `setTimeout` method
|
|
373
|
+
// https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-settimeout
|
|
374
|
+
setTimeout: wrap(global$2.setTimeout),
|
|
375
|
+
// `setInterval` method
|
|
376
|
+
// https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-setinterval
|
|
377
|
+
setInterval: wrap(global$2.setInterval)
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
var $$1 = _export;
|
|
381
|
+
var global$1 = global$4;
|
|
382
|
+
var setInterval = schedulersFix.setInterval;
|
|
383
|
+
|
|
384
|
+
// ie9- setInterval additional parameters fix
|
|
385
|
+
// https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-setinterval
|
|
386
|
+
$$1({ global: true, bind: true, forced: global$1.setInterval !== setInterval }, {
|
|
387
|
+
setInterval: setInterval
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
var web_setTimeout = {};
|
|
391
|
+
|
|
392
|
+
var $ = _export;
|
|
393
|
+
var global = global$4;
|
|
394
|
+
var setTimeout$1 = schedulersFix.setTimeout;
|
|
395
|
+
|
|
396
|
+
// ie9- setTimeout additional parameters fix
|
|
397
|
+
// https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-settimeout
|
|
398
|
+
$({ global: true, bind: true, forced: global.setTimeout !== setTimeout$1 }, {
|
|
399
|
+
setTimeout: setTimeout$1
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
var modalService = function modalService(options, element) {
|
|
316
403
|
var elementToMount = document.createElement('div');
|
|
317
|
-
|
|
318
|
-
var appContext = (_getCurrentInstance = getCurrentInstance()) === null || _getCurrentInstance === void 0 ? void 0 : _getCurrentInstance.appContext;
|
|
404
|
+
elementToMount.id = uniqueId('fw-modal-app-');
|
|
319
405
|
var elAppend = element || document.body;
|
|
406
|
+
var modalVNode = undefined;
|
|
320
407
|
|
|
321
408
|
var open = function open() {
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
}));
|
|
325
|
-
modalVNode.appContext = appContext ? appContext : null;
|
|
326
|
-
render(modalVNode, elementToMount);
|
|
409
|
+
var _modalVNode;
|
|
410
|
+
|
|
411
|
+
modalVNode = createApp(script$7, _objectSpread2({}, options));
|
|
327
412
|
elAppend.appendChild(elementToMount);
|
|
413
|
+
(_modalVNode = modalVNode) === null || _modalVNode === void 0 ? void 0 : _modalVNode.mount(elementToMount);
|
|
328
414
|
};
|
|
329
415
|
|
|
330
416
|
var close = function close() {
|
|
331
|
-
render(null, elementToMount);
|
|
332
|
-
|
|
333
417
|
if (elementToMount) {
|
|
334
|
-
|
|
335
|
-
|
|
418
|
+
var _elementToMount$query;
|
|
419
|
+
|
|
420
|
+
(_elementToMount$query = elementToMount.querySelector('.fw-modal')) === null || _elementToMount$query === void 0 ? void 0 : _elementToMount$query.classList.add('modalFadeIn-leave-active');
|
|
421
|
+
setTimeout(function () {
|
|
422
|
+
var _modalVNode2;
|
|
336
423
|
|
|
337
|
-
|
|
424
|
+
(_modalVNode2 = modalVNode) === null || _modalVNode2 === void 0 ? void 0 : _modalVNode2.unmount();
|
|
425
|
+
modalVNode = undefined;
|
|
426
|
+
elementToMount.remove();
|
|
427
|
+
}, 400);
|
|
428
|
+
}
|
|
338
429
|
};
|
|
339
430
|
|
|
340
|
-
onUnmounted(function () {
|
|
341
|
-
close();
|
|
342
|
-
});
|
|
343
431
|
return {
|
|
344
432
|
open: open,
|
|
345
433
|
close: close
|
|
@@ -356,4 +444,4 @@ var install = function install(app) {
|
|
|
356
444
|
});
|
|
357
445
|
};
|
|
358
446
|
|
|
359
|
-
export {
|
|
447
|
+
export { install as default, modalService };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { w as wellKnownSymbol$2, i as isCallable$1 } from './function-name-f0c1223e.js';
|
|
2
|
+
import { b as classofRaw$1 } from './add-to-unscopables-81c17489.js';
|
|
3
|
+
|
|
4
|
+
var wellKnownSymbol$1 = wellKnownSymbol$2;
|
|
5
|
+
|
|
6
|
+
var TO_STRING_TAG$1 = wellKnownSymbol$1('toStringTag');
|
|
7
|
+
var test = {};
|
|
8
|
+
|
|
9
|
+
test[TO_STRING_TAG$1] = 'z';
|
|
10
|
+
|
|
11
|
+
var toStringTagSupport = String(test) === '[object z]';
|
|
12
|
+
|
|
13
|
+
var TO_STRING_TAG_SUPPORT = toStringTagSupport;
|
|
14
|
+
var isCallable = isCallable$1;
|
|
15
|
+
var classofRaw = classofRaw$1;
|
|
16
|
+
var wellKnownSymbol = wellKnownSymbol$2;
|
|
17
|
+
|
|
18
|
+
var TO_STRING_TAG = wellKnownSymbol('toStringTag');
|
|
19
|
+
var $Object = Object;
|
|
20
|
+
|
|
21
|
+
// ES3 wrong here
|
|
22
|
+
var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';
|
|
23
|
+
|
|
24
|
+
// fallback for IE11 Script Access Denied error
|
|
25
|
+
var tryGet = function (it, key) {
|
|
26
|
+
try {
|
|
27
|
+
return it[key];
|
|
28
|
+
} catch (error) { /* empty */ }
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// getting tag from ES6+ `Object.prototype.toString`
|
|
32
|
+
var classof$1 = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) {
|
|
33
|
+
var O, tag, result;
|
|
34
|
+
return it === undefined ? 'Undefined' : it === null ? 'Null'
|
|
35
|
+
// @@toStringTag case
|
|
36
|
+
: typeof (tag = tryGet(O = $Object(it), TO_STRING_TAG)) == 'string' ? tag
|
|
37
|
+
// builtinTag case
|
|
38
|
+
: CORRECT_ARGUMENTS ? classofRaw(O)
|
|
39
|
+
// ES3 arguments fallback
|
|
40
|
+
: (result = classofRaw(O)) == 'Object' && isCallable(O.callee) ? 'Arguments' : result;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
var classof = classof$1;
|
|
44
|
+
|
|
45
|
+
var $String = String;
|
|
46
|
+
|
|
47
|
+
var toString = function (argument) {
|
|
48
|
+
if (classof(argument) === 'Symbol') throw TypeError('Cannot convert a Symbol value to a string');
|
|
49
|
+
return $String(argument);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export { toString as a, classof$1 as c, toStringTagSupport as t };
|
|
@@ -16,6 +16,30 @@ const isProxyAvailable = typeof Proxy === 'function';
|
|
|
16
16
|
const HOOK_SETUP = 'devtools-plugin:setup';
|
|
17
17
|
const HOOK_PLUGIN_SETTINGS_SET = 'plugin:settings:set';
|
|
18
18
|
|
|
19
|
+
let supported;
|
|
20
|
+
let perf;
|
|
21
|
+
function isPerformanceSupported() {
|
|
22
|
+
var _a;
|
|
23
|
+
if (supported !== undefined) {
|
|
24
|
+
return supported;
|
|
25
|
+
}
|
|
26
|
+
if (typeof window !== 'undefined' && window.performance) {
|
|
27
|
+
supported = true;
|
|
28
|
+
perf = window.performance;
|
|
29
|
+
}
|
|
30
|
+
else if (typeof global !== 'undefined' && ((_a = global.perf_hooks) === null || _a === void 0 ? void 0 : _a.performance)) {
|
|
31
|
+
supported = true;
|
|
32
|
+
perf = global.perf_hooks.performance;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
supported = false;
|
|
36
|
+
}
|
|
37
|
+
return supported;
|
|
38
|
+
}
|
|
39
|
+
function now() {
|
|
40
|
+
return isPerformanceSupported() ? perf.now() : Date.now();
|
|
41
|
+
}
|
|
42
|
+
|
|
19
43
|
class ApiProxy {
|
|
20
44
|
constructor(plugin, hook) {
|
|
21
45
|
this.target = null;
|
|
@@ -53,6 +77,9 @@ class ApiProxy {
|
|
|
53
77
|
}
|
|
54
78
|
currentSettings = value;
|
|
55
79
|
},
|
|
80
|
+
now() {
|
|
81
|
+
return now();
|
|
82
|
+
},
|
|
56
83
|
};
|
|
57
84
|
if (hook) {
|
|
58
85
|
hook.on(HOOK_PLUGIN_SETTINGS_SET, (pluginId, value) => {
|
|
@@ -141,7 +168,7 @@ function setupDevtoolsPlugin(pluginDescriptor, setupFn) {
|
|
|
141
168
|
}
|
|
142
169
|
|
|
143
170
|
/**
|
|
144
|
-
* vee-validate v4.5.
|
|
171
|
+
* vee-validate v4.5.11
|
|
145
172
|
* (c) 2022 Abdelrahman Awad
|
|
146
173
|
* @license MIT
|
|
147
174
|
*/
|
|
@@ -643,18 +670,34 @@ async function _validate(field, value) {
|
|
|
643
670
|
if (isYupValidator(field.rules)) {
|
|
644
671
|
return validateFieldWithYup(value, field.rules, { bails: field.bails });
|
|
645
672
|
}
|
|
646
|
-
// if a generic function
|
|
647
|
-
if (isCallable(field.rules)) {
|
|
673
|
+
// if a generic function or chain of generic functions
|
|
674
|
+
if (isCallable(field.rules) || Array.isArray(field.rules)) {
|
|
648
675
|
const ctx = {
|
|
649
676
|
field: field.name,
|
|
650
677
|
form: field.formData,
|
|
651
678
|
value: value,
|
|
652
679
|
};
|
|
653
|
-
|
|
654
|
-
const
|
|
655
|
-
const
|
|
680
|
+
// Normalize the pipeline
|
|
681
|
+
const pipeline = Array.isArray(field.rules) ? field.rules : [field.rules];
|
|
682
|
+
const length = pipeline.length;
|
|
683
|
+
const errors = [];
|
|
684
|
+
for (let i = 0; i < length; i++) {
|
|
685
|
+
const rule = pipeline[i];
|
|
686
|
+
const result = await rule(value, ctx);
|
|
687
|
+
const isValid = typeof result !== 'string' && result;
|
|
688
|
+
if (isValid) {
|
|
689
|
+
continue;
|
|
690
|
+
}
|
|
691
|
+
const message = typeof result === 'string' ? result : _generateFieldError(ctx);
|
|
692
|
+
errors.push(message);
|
|
693
|
+
if (field.bails) {
|
|
694
|
+
return {
|
|
695
|
+
errors,
|
|
696
|
+
};
|
|
697
|
+
}
|
|
698
|
+
}
|
|
656
699
|
return {
|
|
657
|
-
errors
|
|
700
|
+
errors,
|
|
658
701
|
};
|
|
659
702
|
}
|
|
660
703
|
const normalizedContext = Object.assign(Object.assign({}, field), { rules: normalizeRules(field.rules) });
|
|
@@ -1439,6 +1482,8 @@ function useField(name, rules, opts) {
|
|
|
1439
1482
|
function _useField(name, rules, opts) {
|
|
1440
1483
|
const { initialValue: modelValue, validateOnMount, bails, type, checkedValue, label, validateOnValueUpdate, uncheckedValue, standalone, } = normalizeOptions(unref(name), opts);
|
|
1441
1484
|
const form = !standalone ? injectWithSelf(FormContextKey) : undefined;
|
|
1485
|
+
// a flag indicating if the field is about to be removed/unmounted.
|
|
1486
|
+
let markedForRemoval = false;
|
|
1442
1487
|
const { id, value, initialValue, meta, setState, errors, errorMessage } = useFieldState(name, {
|
|
1443
1488
|
modelValue,
|
|
1444
1489
|
standalone,
|
|
@@ -1455,7 +1500,7 @@ function _useField(name, rules, opts) {
|
|
|
1455
1500
|
if (schema && !isYupValidator(schema)) {
|
|
1456
1501
|
rulesValue = extractRuleFromSchema(schema, unref(name)) || rulesValue;
|
|
1457
1502
|
}
|
|
1458
|
-
if (isYupValidator(rulesValue) || isCallable(rulesValue)) {
|
|
1503
|
+
if (isYupValidator(rulesValue) || isCallable(rulesValue) || Array.isArray(rulesValue)) {
|
|
1459
1504
|
return rulesValue;
|
|
1460
1505
|
}
|
|
1461
1506
|
return normalizeRules(rulesValue);
|
|
@@ -1475,12 +1520,19 @@ function _useField(name, rules, opts) {
|
|
|
1475
1520
|
meta.pending = true;
|
|
1476
1521
|
meta.validated = true;
|
|
1477
1522
|
const result = await validateCurrentValue('validated-only');
|
|
1523
|
+
if (markedForRemoval) {
|
|
1524
|
+
result.valid = true;
|
|
1525
|
+
result.errors = [];
|
|
1526
|
+
}
|
|
1478
1527
|
setState({ errors: result.errors });
|
|
1479
1528
|
meta.pending = false;
|
|
1480
1529
|
return result;
|
|
1481
1530
|
}
|
|
1482
1531
|
async function validateValidStateOnly() {
|
|
1483
1532
|
const result = await validateCurrentValue('silent');
|
|
1533
|
+
if (markedForRemoval) {
|
|
1534
|
+
result.valid = true;
|
|
1535
|
+
}
|
|
1484
1536
|
meta.valid = result.valid;
|
|
1485
1537
|
return result;
|
|
1486
1538
|
}
|
|
@@ -1595,13 +1647,14 @@ function _useField(name, rules, opts) {
|
|
|
1595
1647
|
// associate the field with the given form
|
|
1596
1648
|
form.register(field);
|
|
1597
1649
|
onBeforeUnmount(() => {
|
|
1650
|
+
markedForRemoval = true;
|
|
1598
1651
|
form.unregister(field);
|
|
1599
1652
|
});
|
|
1600
1653
|
// extract cross-field dependencies in a computed prop
|
|
1601
1654
|
const dependencies = computed(() => {
|
|
1602
1655
|
const rulesVal = normalizedRules.value;
|
|
1603
1656
|
// is falsy, a function schema or a yup schema
|
|
1604
|
-
if (!rulesVal || isCallable(rulesVal) || isYupValidator(rulesVal)) {
|
|
1657
|
+
if (!rulesVal || isCallable(rulesVal) || isYupValidator(rulesVal) || Array.isArray(rulesVal)) {
|
|
1605
1658
|
return {};
|
|
1606
1659
|
}
|
|
1607
1660
|
return Object.keys(rulesVal).reduce((acc, rule) => {
|