@pacem/pacem-scaffolding 1.0.0-abel
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/LICENSE +191 -0
- package/NOTICE +4 -0
- package/dist/browser/pacem-scaffolding.js +10430 -0
- package/dist/browser/pacem-scaffolding.js.map +1 -0
- package/dist/browser/pacem-scaffolding.min.js +2 -0
- package/dist/browser/pacem-scaffolding.min.js.map +1 -0
- package/dist/bundle/pacem-scaffolding.min.mjs +380 -0
- package/dist/bundle/pacem-scaffolding.mjs +10046 -0
- package/dist/bundle/pacem-scaffolding.mjs.map +7 -0
- package/dist/esm/calendar-picker.js +478 -0
- package/dist/esm/char-counter.js +43 -0
- package/dist/esm/checkbox-list.js +75 -0
- package/dist/esm/checkbox.js +112 -0
- package/dist/esm/childform.js +237 -0
- package/dist/esm/contenteditable.js +326 -0
- package/dist/esm/datetime-picker.js +310 -0
- package/dist/esm/form.js +630 -0
- package/dist/esm/formfield.js +1065 -0
- package/dist/esm/geolocate.js +197 -0
- package/dist/esm/hierarchy.js +509 -0
- package/dist/esm/index-components-scaffolding.js +39 -0
- package/dist/esm/index-components.js +1 -0
- package/dist/esm/index-iife.js +3 -0
- package/dist/esm/index-root.js +2 -0
- package/dist/esm/index-scaffolding.js +3 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/input-chars.js +185 -0
- package/dist/esm/input-color.js +80 -0
- package/dist/esm/input-email.js +32 -0
- package/dist/esm/input-file.js +691 -0
- package/dist/esm/input-hidden.js +25 -0
- package/dist/esm/input-image.js +391 -0
- package/dist/esm/input-number.js +58 -0
- package/dist/esm/input-password.js +71 -0
- package/dist/esm/input-search.js +27 -0
- package/dist/esm/input-tel.js +31 -0
- package/dist/esm/input-text.js +36 -0
- package/dist/esm/input-url.js +32 -0
- package/dist/esm/input.js +215 -0
- package/dist/esm/l10n.js +66 -0
- package/dist/esm/latlng.js +178 -0
- package/dist/esm/namevalue-list.js +139 -0
- package/dist/esm/property-picker.js +84 -0
- package/dist/esm/radio-list.js +70 -0
- package/dist/esm/radio.js +79 -0
- package/dist/esm/select.js +126 -0
- package/dist/esm/slider.js +284 -0
- package/dist/esm/snapshot.js +325 -0
- package/dist/esm/suggest.js +545 -0
- package/dist/esm/tags.js +174 -0
- package/dist/esm/textarea-markdown.js +75 -0
- package/dist/esm/textarea.js +51 -0
- package/dist/esm/types-components.js +611 -0
- package/dist/esm/types.js +8 -0
- package/dist/esm/validators.js +409 -0
- package/package.json +38 -0
- package/typings/index.d.ts +2283 -0
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Watch, P, PCSS, CustomElement, ViewChild, Utils, PropertyConverters, Defaults, DeferPromise } from '@pacem/pacem-core';
|
|
8
|
+
import { PacemFormRelevantElement } from './form';
|
|
9
|
+
// TODO: add warning state
|
|
10
|
+
export class PacemBaseValidatorElement extends PacemFormRelevantElement {
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
|
+
}
|
|
14
|
+
viewActivatedCallback() {
|
|
15
|
+
super.viewActivatedCallback();
|
|
16
|
+
Utils.addClass(this, PCSS + '-validator');
|
|
17
|
+
}
|
|
18
|
+
propertyChangedCallback(name, old, val, first) {
|
|
19
|
+
super.propertyChangedCallback(name, old, val, first);
|
|
20
|
+
let form = this.form;
|
|
21
|
+
switch (name) {
|
|
22
|
+
case 'watch':
|
|
23
|
+
old && form && form.unregisterValidator(val, this);
|
|
24
|
+
form && form.registerValidator(val, this);
|
|
25
|
+
break;
|
|
26
|
+
case 'invalid':
|
|
27
|
+
break;
|
|
28
|
+
case 'form':
|
|
29
|
+
let n = this.watch;
|
|
30
|
+
if (!Utils.isNullOrEmpty(n)) {
|
|
31
|
+
if (old != null)
|
|
32
|
+
old.unregisterValidator(n, this);
|
|
33
|
+
if (val != null)
|
|
34
|
+
val.registerValidator(n, this);
|
|
35
|
+
}
|
|
36
|
+
break;
|
|
37
|
+
case 'disabled':
|
|
38
|
+
this.triggerFormFieldValidation();
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
#easer;
|
|
43
|
+
triggerFormFieldValidation() {
|
|
44
|
+
const form = this.form, watch = this.watch;
|
|
45
|
+
if (!Utils.isNull(form) && !Utils.isNullOrEmpty(watch)) {
|
|
46
|
+
cancelAnimationFrame(this.#easer);
|
|
47
|
+
this.#easer = requestAnimationFrame(() => {
|
|
48
|
+
form.validate(watch);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
validate(val) {
|
|
53
|
+
if (this.disabled) {
|
|
54
|
+
return Utils.fromResult(true);
|
|
55
|
+
}
|
|
56
|
+
return this.evaluate(val);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
__decorate([
|
|
60
|
+
Watch({ converter: PropertyConverters.Boolean })
|
|
61
|
+
], PacemBaseValidatorElement.prototype, "invalid", void 0);
|
|
62
|
+
__decorate([
|
|
63
|
+
Watch({ converter: PropertyConverters.String })
|
|
64
|
+
], PacemBaseValidatorElement.prototype, "errorMessage", void 0);
|
|
65
|
+
__decorate([
|
|
66
|
+
Watch({ emit: false, reflectBack: true, converter: PropertyConverters.String })
|
|
67
|
+
], PacemBaseValidatorElement.prototype, "watch", void 0);
|
|
68
|
+
export const BASIC_VALIDATOR_TEMPLATE = `<${P}-span part="error-message" hide="{{ !:host.invalid }}" text="{{ :host.errorMessage }}"></${P}-span>`;
|
|
69
|
+
// #region TEXTUAL
|
|
70
|
+
function isValueEmpty(val) {
|
|
71
|
+
return Utils.isNullOrEmpty(val);
|
|
72
|
+
}
|
|
73
|
+
let PacemRequiredValidatorElement = class PacemRequiredValidatorElement extends PacemBaseValidatorElement {
|
|
74
|
+
evaluate(val) {
|
|
75
|
+
let retval = !isValueEmpty(val);
|
|
76
|
+
return Utils.fromResult(retval);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
PacemRequiredValidatorElement = __decorate([
|
|
80
|
+
CustomElement({ tagName: P + '-required-validator', template: BASIC_VALIDATOR_TEMPLATE, shadow: Defaults.USE_SHADOW_ROOT })
|
|
81
|
+
], PacemRequiredValidatorElement);
|
|
82
|
+
export { PacemRequiredValidatorElement };
|
|
83
|
+
let PacemRegexValidatorElement = class PacemRegexValidatorElement extends PacemBaseValidatorElement {
|
|
84
|
+
propertyChangedCallback(name, old, val, first) {
|
|
85
|
+
super.propertyChangedCallback(name, old, val, first);
|
|
86
|
+
if (!first && name === 'pattern') {
|
|
87
|
+
this.triggerFormFieldValidation();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
evaluate(val) {
|
|
91
|
+
let retval = true, pattern = this.pattern;
|
|
92
|
+
if (!isValueEmpty(val)) {
|
|
93
|
+
retval = new RegExp(pattern).test(val);
|
|
94
|
+
}
|
|
95
|
+
return Utils.fromResult(retval);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
__decorate([
|
|
99
|
+
Watch({ emit: false, converter: PropertyConverters.String })
|
|
100
|
+
], PacemRegexValidatorElement.prototype, "pattern", void 0);
|
|
101
|
+
PacemRegexValidatorElement = __decorate([
|
|
102
|
+
CustomElement({ tagName: P + '-regex-validator', template: BASIC_VALIDATOR_TEMPLATE, shadow: Defaults.USE_SHADOW_ROOT })
|
|
103
|
+
], PacemRegexValidatorElement);
|
|
104
|
+
export { PacemRegexValidatorElement };
|
|
105
|
+
let PacemLengthValidatorElement = class PacemLengthValidatorElement extends PacemBaseValidatorElement {
|
|
106
|
+
propertyChangedCallback(name, old, val, first) {
|
|
107
|
+
super.propertyChangedCallback(name, old, val, first);
|
|
108
|
+
if (!first &&
|
|
109
|
+
(name === 'min' || name === 'max')) {
|
|
110
|
+
this.triggerFormFieldValidation();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
evaluate(val) {
|
|
114
|
+
let retval = true;
|
|
115
|
+
if (!isValueEmpty(val)) {
|
|
116
|
+
if (this.min >= 0)
|
|
117
|
+
retval = retval && (val || '').toString().length >= this.min;
|
|
118
|
+
if (this.max >= 0)
|
|
119
|
+
retval = retval && (val || '').toString().length <= this.max;
|
|
120
|
+
}
|
|
121
|
+
return Utils.fromResult(retval);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
__decorate([
|
|
125
|
+
Watch({ emit: false, converter: PropertyConverters.Number })
|
|
126
|
+
], PacemLengthValidatorElement.prototype, "min", void 0);
|
|
127
|
+
__decorate([
|
|
128
|
+
Watch({ emit: false, converter: PropertyConverters.Number })
|
|
129
|
+
], PacemLengthValidatorElement.prototype, "max", void 0);
|
|
130
|
+
PacemLengthValidatorElement = __decorate([
|
|
131
|
+
CustomElement({ tagName: P + '-length-validator', template: BASIC_VALIDATOR_TEMPLATE, shadow: Defaults.USE_SHADOW_ROOT })
|
|
132
|
+
], PacemLengthValidatorElement);
|
|
133
|
+
export { PacemLengthValidatorElement };
|
|
134
|
+
// #endregion
|
|
135
|
+
// #region NUMERIC/ORDINAL
|
|
136
|
+
let PacemRangeValidatorElement = class PacemRangeValidatorElement extends PacemBaseValidatorElement {
|
|
137
|
+
propertyChangedCallback(name, old, val, first) {
|
|
138
|
+
super.propertyChangedCallback(name, old, val, first);
|
|
139
|
+
if (!first &&
|
|
140
|
+
(name === 'min' || name === 'max')) {
|
|
141
|
+
this.triggerFormFieldValidation();
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
evaluate(val) {
|
|
145
|
+
let retval = true;
|
|
146
|
+
if (!isValueEmpty(val)) {
|
|
147
|
+
let date = val;
|
|
148
|
+
if (val instanceof Date || (typeof val !== 'number' && (date = Utils.parseDate(val)) instanceof Date && isFinite(date.valueOf()))) {
|
|
149
|
+
if (this.min != null)
|
|
150
|
+
retval = retval && date.valueOf() >= Utils.parseDate(this.min).valueOf();
|
|
151
|
+
if (this.max != null)
|
|
152
|
+
retval = retval && date.valueOf() <= Utils.parseDate(this.max).valueOf();
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
if (this.min != null)
|
|
156
|
+
retval = retval && val >= this.min;
|
|
157
|
+
if (this.max != null)
|
|
158
|
+
retval = retval && val <= this.max;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return Utils.fromResult(retval);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
__decorate([
|
|
165
|
+
Watch({ emit: false, converter: PropertyConverters.Number })
|
|
166
|
+
], PacemRangeValidatorElement.prototype, "min", void 0);
|
|
167
|
+
__decorate([
|
|
168
|
+
Watch({ emit: false, converter: PropertyConverters.Number })
|
|
169
|
+
], PacemRangeValidatorElement.prototype, "max", void 0);
|
|
170
|
+
PacemRangeValidatorElement = __decorate([
|
|
171
|
+
CustomElement({ tagName: P + '-range-validator', template: BASIC_VALIDATOR_TEMPLATE, shadow: Defaults.USE_SHADOW_ROOT })
|
|
172
|
+
], PacemRangeValidatorElement);
|
|
173
|
+
export { PacemRangeValidatorElement };
|
|
174
|
+
// #endregion
|
|
175
|
+
// #region COMPLEX
|
|
176
|
+
let PacemCompareValidatorElement = class PacemCompareValidatorElement extends PacemBaseValidatorElement {
|
|
177
|
+
propertyChangedCallback(name, old, val, first) {
|
|
178
|
+
super.propertyChangedCallback(name, old, val, first);
|
|
179
|
+
if (!first &&
|
|
180
|
+
(name === 'operator' || name === 'to')) {
|
|
181
|
+
this.triggerFormFieldValidation();
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
_prepareValuesForComparison(val, other) {
|
|
185
|
+
// gotta manage the case when a stringified datetime is compared with an actual date object.
|
|
186
|
+
if (Utils.Dates.isDate(val) || Utils.Dates.isDate(other)) {
|
|
187
|
+
return [Utils.parseDate(val), Utils.parseDate(other)];
|
|
188
|
+
}
|
|
189
|
+
return [val, other];
|
|
190
|
+
}
|
|
191
|
+
evaluate(val) {
|
|
192
|
+
let retval = true, other = this.to;
|
|
193
|
+
if (!isValueEmpty(val) && !isValueEmpty(other)) {
|
|
194
|
+
const arranged = this._prepareValuesForComparison(val, other);
|
|
195
|
+
val = arranged[0], other = arranged[1];
|
|
196
|
+
switch (this.operator) {
|
|
197
|
+
case 'lessOrEqual':
|
|
198
|
+
retval = val <= other;
|
|
199
|
+
break;
|
|
200
|
+
case 'less':
|
|
201
|
+
retval = val < other;
|
|
202
|
+
break;
|
|
203
|
+
case 'greaterOrEqual':
|
|
204
|
+
retval = val >= other;
|
|
205
|
+
break;
|
|
206
|
+
case 'greater':
|
|
207
|
+
retval = val > other;
|
|
208
|
+
break;
|
|
209
|
+
case 'notEqual':
|
|
210
|
+
retval = val !== other;
|
|
211
|
+
break;
|
|
212
|
+
default:
|
|
213
|
+
retval = val === other;
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return Utils.fromResult(retval);
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
__decorate([
|
|
221
|
+
Watch({ emit: false, converter: PropertyConverters.String })
|
|
222
|
+
], PacemCompareValidatorElement.prototype, "operator", void 0);
|
|
223
|
+
__decorate([
|
|
224
|
+
Watch({ emit: false, reflectBack: true })
|
|
225
|
+
], PacemCompareValidatorElement.prototype, "to", void 0);
|
|
226
|
+
PacemCompareValidatorElement = __decorate([
|
|
227
|
+
CustomElement({ tagName: P + '-compare-validator', template: BASIC_VALIDATOR_TEMPLATE, shadow: Defaults.USE_SHADOW_ROOT })
|
|
228
|
+
], PacemCompareValidatorElement);
|
|
229
|
+
export { PacemCompareValidatorElement };
|
|
230
|
+
// #endregion
|
|
231
|
+
let PacemBinaryValidatorElement = class PacemBinaryValidatorElement extends PacemBaseValidatorElement {
|
|
232
|
+
propertyChangedCallback(name, old, val, first) {
|
|
233
|
+
super.propertyChangedCallback(name, old, val, first);
|
|
234
|
+
if (!first &&
|
|
235
|
+
(name === 'pattern' || name === 'maxSize')) {
|
|
236
|
+
this.triggerFormFieldValidation();
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
evaluate(val) {
|
|
240
|
+
let retval = true, pattern = this.pattern, maxSize = this.maxSize;
|
|
241
|
+
if (!isValueEmpty(val)) {
|
|
242
|
+
// file name
|
|
243
|
+
if (!Utils.isNullOrEmpty(pattern)) {
|
|
244
|
+
let filename = typeof val === 'string' ? val : val.name;
|
|
245
|
+
retval = new RegExp(pattern, 'i').test(filename);
|
|
246
|
+
}
|
|
247
|
+
// max size
|
|
248
|
+
if (!Utils.isNull(maxSize) && typeof val === 'object' && val.size > 0) {
|
|
249
|
+
retval = retval && val.size <= maxSize;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return Utils.fromResult(retval);
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
__decorate([
|
|
256
|
+
Watch({ emit: false, converter: PropertyConverters.String })
|
|
257
|
+
], PacemBinaryValidatorElement.prototype, "pattern", void 0);
|
|
258
|
+
__decorate([
|
|
259
|
+
Watch({ emit: false, converter: PropertyConverters.String })
|
|
260
|
+
], PacemBinaryValidatorElement.prototype, "maxSize", void 0);
|
|
261
|
+
PacemBinaryValidatorElement = __decorate([
|
|
262
|
+
CustomElement({ tagName: P + '-binary-validator', template: BASIC_VALIDATOR_TEMPLATE, shadow: Defaults.USE_SHADOW_ROOT })
|
|
263
|
+
], PacemBinaryValidatorElement);
|
|
264
|
+
export { PacemBinaryValidatorElement };
|
|
265
|
+
let PacemAsyncValidatorElement = class PacemAsyncValidatorElement extends PacemBaseValidatorElement {
|
|
266
|
+
constructor() {
|
|
267
|
+
super(...arguments);
|
|
268
|
+
this._deferredToken = null;
|
|
269
|
+
}
|
|
270
|
+
_evaluateResult() {
|
|
271
|
+
const fetcher = this._fetcher;
|
|
272
|
+
const result = fetcher.result;
|
|
273
|
+
switch (result) {
|
|
274
|
+
case 'true':
|
|
275
|
+
return true;
|
|
276
|
+
break;
|
|
277
|
+
case 'false':
|
|
278
|
+
return false;
|
|
279
|
+
break;
|
|
280
|
+
default: // expect json
|
|
281
|
+
try {
|
|
282
|
+
let json = JSON.parse(result);
|
|
283
|
+
let res = Utils.getApiResult(json);
|
|
284
|
+
return (res || false);
|
|
285
|
+
}
|
|
286
|
+
catch (_) {
|
|
287
|
+
return false;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
_fetch(val) {
|
|
292
|
+
const deferred = this._deferredToken;
|
|
293
|
+
const fetcher = this._fetcher;
|
|
294
|
+
var params = this.parameters || {};
|
|
295
|
+
params[this.watch] = val;
|
|
296
|
+
const request = {
|
|
297
|
+
parameters: params,
|
|
298
|
+
url: this.url,
|
|
299
|
+
as: 'text',
|
|
300
|
+
method: this.method
|
|
301
|
+
};
|
|
302
|
+
const serializedRequest = Utils.jsonSortStringify(request);
|
|
303
|
+
// check changed:
|
|
304
|
+
// assume idempotent with last request.
|
|
305
|
+
const lastRequest = this.#lastRequest;
|
|
306
|
+
let returnLastResult = false;
|
|
307
|
+
if (!Utils.isNullOrEmpty(lastRequest)) {
|
|
308
|
+
returnLastResult = (serializedRequest === lastRequest);
|
|
309
|
+
}
|
|
310
|
+
if (returnLastResult) {
|
|
311
|
+
const result = this._evaluateResult();
|
|
312
|
+
deferred.resolve(result);
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
Utils.extend(fetcher, request);
|
|
316
|
+
// debounce
|
|
317
|
+
clearTimeout(this._debouncer);
|
|
318
|
+
this._debouncer = setTimeout(() => {
|
|
319
|
+
fetcher.fetch().then(_ => {
|
|
320
|
+
const result = this._evaluateResult();
|
|
321
|
+
deferred.resolve(result);
|
|
322
|
+
// memoize last successful request
|
|
323
|
+
this.#lastRequest = serializedRequest;
|
|
324
|
+
}, _ => {
|
|
325
|
+
deferred.resolve(false);
|
|
326
|
+
});
|
|
327
|
+
}, 1000);
|
|
328
|
+
}
|
|
329
|
+
return deferred.promise;
|
|
330
|
+
}
|
|
331
|
+
#lastRequest;
|
|
332
|
+
evaluate(val) {
|
|
333
|
+
if (Utils.isNullOrEmpty(val)) {
|
|
334
|
+
return Utils.fromResult(true);
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
this._deferredToken = this._deferredToken = DeferPromise.defer();
|
|
338
|
+
return this._fetch(val).then(r => {
|
|
339
|
+
this._deferredToken = null;
|
|
340
|
+
return r;
|
|
341
|
+
}, _ => {
|
|
342
|
+
this._deferredToken = null;
|
|
343
|
+
return false;
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
propertyChangedCallback(name, old, val, first) {
|
|
348
|
+
super.propertyChangedCallback(name, old, val, first);
|
|
349
|
+
if (!first) {
|
|
350
|
+
switch (name) {
|
|
351
|
+
case 'parameters':
|
|
352
|
+
case 'url':
|
|
353
|
+
case 'method':
|
|
354
|
+
case 'fetchCredentials':
|
|
355
|
+
case 'fetchHeaders':
|
|
356
|
+
this.triggerFormFieldValidation();
|
|
357
|
+
break;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
__decorate([
|
|
363
|
+
Watch({ emit: false, converter: PropertyConverters.Json })
|
|
364
|
+
], PacemAsyncValidatorElement.prototype, "parameters", void 0);
|
|
365
|
+
__decorate([
|
|
366
|
+
Watch({ emit: false, converter: PropertyConverters.Json })
|
|
367
|
+
], PacemAsyncValidatorElement.prototype, "fetchCredentials", void 0);
|
|
368
|
+
__decorate([
|
|
369
|
+
Watch({ emit: false, converter: PropertyConverters.Json })
|
|
370
|
+
], PacemAsyncValidatorElement.prototype, "fetchHeaders", void 0);
|
|
371
|
+
__decorate([
|
|
372
|
+
Watch({ emit: false, converter: PropertyConverters.String })
|
|
373
|
+
], PacemAsyncValidatorElement.prototype, "url", void 0);
|
|
374
|
+
__decorate([
|
|
375
|
+
Watch({ emit: false, converter: PropertyConverters.String })
|
|
376
|
+
], PacemAsyncValidatorElement.prototype, "method", void 0);
|
|
377
|
+
__decorate([
|
|
378
|
+
ViewChild(P + '-fetch')
|
|
379
|
+
], PacemAsyncValidatorElement.prototype, "_fetcher", void 0);
|
|
380
|
+
PacemAsyncValidatorElement = __decorate([
|
|
381
|
+
CustomElement({
|
|
382
|
+
tagName: P + '-async-validator',
|
|
383
|
+
template: BASIC_VALIDATOR_TEMPLATE + `<${P}-fetch autofetch="false" throttle="true" credentials="{{ :host.fetchCredentials }}" headers="{{ :host.fetchHeaders }}"></${P}-fetch>`, shadow: Defaults.USE_SHADOW_ROOT
|
|
384
|
+
})
|
|
385
|
+
], PacemAsyncValidatorElement);
|
|
386
|
+
export { PacemAsyncValidatorElement };
|
|
387
|
+
let PacemCustomValidatorElement = class PacemCustomValidatorElement extends PacemBaseValidatorElement {
|
|
388
|
+
propertyChangedCallback(name, old, val, first) {
|
|
389
|
+
super.propertyChangedCallback(name, old, val, first);
|
|
390
|
+
if (!first &&
|
|
391
|
+
(name === 'isValid')) {
|
|
392
|
+
this.triggerFormFieldValidation();
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
evaluate(val) {
|
|
396
|
+
let retval = true;
|
|
397
|
+
if (!isValueEmpty(val)) {
|
|
398
|
+
retval = !!this.isValid;
|
|
399
|
+
}
|
|
400
|
+
return Utils.fromResult(retval);
|
|
401
|
+
}
|
|
402
|
+
};
|
|
403
|
+
__decorate([
|
|
404
|
+
Watch({ emit: false, converter: PropertyConverters.Boolean })
|
|
405
|
+
], PacemCustomValidatorElement.prototype, "isValid", void 0);
|
|
406
|
+
PacemCustomValidatorElement = __decorate([
|
|
407
|
+
CustomElement({ tagName: P + '-custom-validator', template: BASIC_VALIDATOR_TEMPLATE, shadow: Defaults.USE_SHADOW_ROOT })
|
|
408
|
+
], PacemCustomValidatorElement);
|
|
409
|
+
export { PacemCustomValidatorElement };
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pacem/pacem-scaffolding",
|
|
3
|
+
"files": [
|
|
4
|
+
"dist/browser/*.*",
|
|
5
|
+
"dist/bundle/*.*",
|
|
6
|
+
"dist/esm/*.*",
|
|
7
|
+
"typings/*.*",
|
|
8
|
+
"README.md",
|
|
9
|
+
"LICENSE",
|
|
10
|
+
"NOTICE",
|
|
11
|
+
"package.json"
|
|
12
|
+
],
|
|
13
|
+
"type": "module",
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@pacem/pacem-foundation": "*",
|
|
16
|
+
"@pacem/pacem-core": "*"
|
|
17
|
+
},
|
|
18
|
+
"main": "./dist/esm/index.js",
|
|
19
|
+
"module": "./dist/esm/index.js",
|
|
20
|
+
"typings": "./typings/index.d.ts",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"import": "./dist/esm/index.js",
|
|
24
|
+
"types": "./typings/index.d.ts"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"version": "1.0.0-abel",
|
|
28
|
+
"author": {
|
|
29
|
+
"name": "Pacem",
|
|
30
|
+
"url": "https://pacem.it"
|
|
31
|
+
},
|
|
32
|
+
"license": "Apache-2.0",
|
|
33
|
+
"homepage": "https://js.pacem.it",
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "git+https://github.com/pacem-it/pacem.git"
|
|
37
|
+
}
|
|
38
|
+
}
|