@drumee/ui-toolkit 0.0.17 → 0.0.19

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/index.js CHANGED
@@ -1,31 +1,7 @@
1
1
 
2
- let loaded = 0;
3
- function start() {
4
- if (loaded) return;
5
- Kind.registerAddons({
6
- 'dtk_otp': import('./widgets/otp'),
7
- 'dtk_dialog': import('./widgets/dialog'),
8
- 'dtk_pwsetter': import('./widgets/pwsetter'),
9
- })
10
- loaded = 1;
11
- }
12
-
13
-
14
2
  /**
15
3
  *
16
4
  */
17
- export function loadWidgets() {
18
- if (document.readyState == 'complete') {
19
- start()
20
- } else {
21
- if (location.hash) {
22
- document.addEventListener('drumee:plugins:ready', start);
23
- } else {
24
- document.addEventListener('drumee:router:ready', start);
25
- }
26
- }
5
+ export function loadSeeds() {
6
+ Kind.registerAddons(require('./seeds'))
27
7
  }
28
-
29
- export * from './utils/index';
30
- export * from './utils/validator';
31
- export * from './utils/contextmenu';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drumee/ui-toolkit",
3
- "version": "0.0.17",
3
+ "version": "0.0.19",
4
4
  "description": "",
5
5
  "main": "./index.js",
6
6
  "repository": {
package/seeds.js ADDED
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ 'dtk_otp': import('./widgets/otp'),
3
+ 'dtk_dialog': import('./widgets/dialog'),
4
+ 'dtk_pwsetter': import('./widgets/pwsetter'),
5
+ }
@@ -0,0 +1,13 @@
1
+ const { arcLength } = require("@drumee/ui-essentials")
2
+ module.exports = function(ui){
3
+ let html;
4
+ const id = ui._id;
5
+ const val = arcLength(ui.mget(_a.percent));
6
+ return html = `
7
+ <svg id="${id}-main" viewBox="0 0 200 200" class="${ui.fig.family}__progress outer">
8
+ <circle id="${id}-bg" class="${ui.fig.family}__progress bg" cx="100" cy="95" r="68" stroke-dashoffset="0" stroke-dasharray="502.4"></circle>
9
+ <circle id="${id}-fg" class="${ui.fig.family}__progress fg" cx="95" cy="90" r="72" stroke-dashoffset="${val}" stroke-dasharray="502.4" transform="rotate(270, 100, 90)"></circle>
10
+ <circle class="${ui.fig.family}__progress inner" cx="100" cy="95" r="66" stroke-dashoffset="0" fill="#FFFFFF"></circle>
11
+ </svg>
12
+ `;
13
+ };
@@ -1,60 +0,0 @@
1
- export const STATE = {
2
- 1: 1,
3
- on: 1,
4
- in: 1,
5
- yes: 1,
6
- true: 1,
7
- sms: 1,
8
- email: 1,
9
- 0: 0,
10
- off: 0,
11
- out: 0,
12
- no: 0,
13
- fasle: 0,
14
- undefined: 0,
15
- null: 0,
16
- };
17
-
18
- export const RADIO = {
19
- 1: "on",
20
- on: "on",
21
- in: "on",
22
- yes: "on",
23
- true: "on",
24
- 0: "off",
25
- off: "off",
26
- out: "off",
27
- no: "off",
28
- fasle: "off",
29
- undefined: "off",
30
- null: "off",
31
- };
32
-
33
- export const BOOLEAN = {
34
- 1: true,
35
- on: true,
36
- in: true,
37
- yes: true,
38
- true: true,
39
- 0: false,
40
- off: false,
41
- out: false,
42
- no: false,
43
- fasle: false,
44
- undefined: false,
45
- null: false,
46
- };
47
-
48
- export const LOG_LEVEL = {
49
- info: 2,
50
- debug: 3,
51
- verbose: 4,
52
- gossip: 5
53
- }
54
-
55
- export const LOG_NAME = {
56
- info: 'info',
57
- debug: 'debug',
58
- verbose: 'verbose',
59
- gossip: 'gossip'
60
- }
@@ -1,27 +0,0 @@
1
-
2
- export function buildContextmenu(p, trigger, e) {
3
- let kids;
4
- if (_.isFunction(p.contextmenuSkeleton)) {
5
- kids = p.contextmenuSkeleton(p, trigger, e);
6
- } else if (_.isArray(p.contextmenuSkeleton)) {
7
- kids = p.contextmenuSkeleton;
8
- } else if (_.isObject(p.contextmenuSkeleton)) {
9
- kids = [p.contextmenuSkeleton];
10
- }
11
- if (_.isString(kids) || _.isEmpty(kids)) {
12
- return Skeletons.Box.Y({ volatility: 1, style: { display: _a.none } });
13
- } else if (!_.isArray(kids)) {
14
- kids = [kids];
15
- }
16
- return Skeletons.Box.Y({
17
- volatility: 4,
18
- className: `drumee-contextmenu ${p.fig.family}`,
19
- kids,
20
- uiHandler: [p],
21
- style: {
22
- left: e.pageX,
23
- top: e.pageY,
24
- zIndex: 100000
25
- }
26
- })
27
- }
package/utils/index.js DELETED
@@ -1,715 +0,0 @@
1
- const Filesize = require("filesize");
2
-
3
- let VERBOSITY = parseInt(localStorage.logLevel) || 0;
4
- const { LOG_LEVEL, BOOLEAN, STATE, RADIO } = require("./constants")
5
-
6
-
7
-
8
- /**
9
- *
10
- * @param {*} name
11
- * @returns
12
- */
13
- export function log(name) {
14
- if (!name) return VERBOSITY;
15
- return VERBOSITY >= LOG_LEVEL[name];
16
- };
17
-
18
-
19
-
20
- /**
21
- *
22
- * @param {*} c
23
- * @returns
24
- */
25
- export function clarityToAlpha(c) {
26
- let a = (100 - c) / 100;
27
- if (a > 1) {
28
- a = 1;
29
- }
30
- if (a < 0) {
31
- a = 0;
32
- }
33
- return a;
34
- }
35
-
36
- /**
37
- *
38
- * @returns
39
- */
40
- export function colon() {
41
- switch (Visitor.language()) {
42
- case "fr":
43
- return " :";
44
- default:
45
- return ":";
46
- }
47
- }
48
-
49
-
50
- /**
51
- *
52
- * @param {*} name
53
- * @param {*} s
54
- * @param {*} l
55
- * @returns
56
- */
57
- export function colorFromName(name, s, l) {
58
- if (s == null) {
59
- s = 40;
60
- }
61
- if (l == null) {
62
- l = 60;
63
- }
64
- let hash = 0;
65
- let i = 0;
66
- while (i < name.length) {
67
- hash = name.charCodeAt(i) + (hash << 5) - hash;
68
- i++;
69
- }
70
- const h = hash % 360;
71
- const r = `hsl(${h}, ${s}%, ${l}%)`;
72
- return r;
73
- }
74
-
75
- /**
76
- *
77
- * @param {*} format
78
- * @returns
79
- */
80
- export function today(format) {
81
- const f = format || Visitor.dateformat();
82
- return Dayjs().format(f);
83
- }
84
-
85
-
86
-
87
- /**
88
- *
89
- * @param {*} val
90
- * @param {*} opt
91
- * @returns
92
- */
93
- export function filesize(val, opt) {
94
- if (val == null || val == undefined) val = 0;
95
- return Filesize(val, { locale: Visitor.language(), ...opt });
96
- }
97
-
98
-
99
-
100
- /**
101
- *
102
- * @param {*} text
103
- */
104
- export async function copyToClipboard(text) {
105
- // Try using modern Clipboard API first
106
- if (navigator.clipboard && navigator.clipboard.writeText) {
107
- try {
108
- // await navigator.clipboard.writeText(data);
109
- // return true;
110
- const blob = new Blob([text], { type: 'text/plain' });
111
- // Create a ClipboardItem with the Blob
112
- const clipboardItem = new ClipboardItem({ [blob.type]: blob });
113
- // Write the item to the clipboard
114
- await navigator.clipboard.write([clipboardItem]);
115
- return true;
116
- } catch (err) {
117
- console.error('Clipboard API failed:', err);
118
- // Fall back to execCommand method
119
- }
120
- }
121
-
122
- // Fallback for older browsers
123
- const el = document.createElement("textarea");
124
- el.value = text;
125
- el.setAttribute("readonly", "");
126
- el.style.position = "absolute";
127
- el.style.left = "-9999px";
128
- document.body.appendChild(el);
129
-
130
- el.select();
131
- const success = document.execCommand("copy");
132
- document.body.removeChild(el);
133
-
134
- return success;
135
- }
136
- /**
137
- *
138
- * @param {*} val
139
- * @returns
140
- */
141
- export function toOnOff(val) {
142
- if (val) {
143
- return _a.on;
144
- }
145
- return _a.off;
146
- }
147
-
148
-
149
-
150
- /**
151
- *
152
- *
153
- * @param {*} str
154
- * @returns
155
- */
156
- export function isHTML(str) {
157
- const a = document.createElement("div");
158
- a.innerHTML = str;
159
- for (let c of Array.from(a.childNodes)) {
160
- if (c.nodeType === 1) {
161
- return true;
162
- }
163
- }
164
- return false;
165
- }
166
-
167
-
168
- /**
169
- *
170
- * @param {*} sec
171
- * @returns
172
- */
173
- export function timestamp(sec) {
174
- if (sec == null) {
175
- sec = 0;
176
- }
177
- const ts = new Date().getTime();
178
- if (sec) {
179
- return Math.round(ts / 1000);
180
- }
181
- return ts;
182
- }
183
-
184
-
185
- /**
186
- *
187
- * @param {*} format
188
- * @returns
189
- */
190
- export function timeNow(format) {
191
- if (format == null) {
192
- format = "YY-MM-DD-hh-mm";
193
- }
194
- const d = new Date();
195
- return Dayjs(d.getTime()).format(format);
196
- }
197
-
198
- /**
199
- *
200
- * @param {*} time
201
- * @param {*} format
202
- * @returns
203
- */
204
- export function dayOfTime(time, format) {
205
- if (format == null) {
206
- format = "DD/MM/YYYY";
207
- }
208
- return Dayjs(time, "X").format(format);
209
- }
210
-
211
- /**
212
- *
213
- * @param {*} url
214
- * @returns
215
- */
216
- export function loadJS(url) {
217
- const a = new Promise(function (resolve, reject) {
218
- const xhr = new XMLHttpRequest();
219
- xhr.open("GET", url, true);
220
- xhr.onload = function (e) {
221
- const el = document.createElement(_a.script);
222
- el.setAttribute(_a.text, "text/javascript");
223
- el.type = "text/javascript";
224
- el.setAttribute("charset", "utf-8");
225
- el.setAttribute("async", "");
226
- el.innerHTML = xhr.responseText;
227
- document.head.appendChild(el);
228
- resolve(xhr);
229
- };
230
-
231
- xhr.onerror = function (e) {
232
- reject(xhr);
233
- };
234
-
235
- xhr.send();
236
- return xhr;
237
- });
238
- return a;
239
- }
240
-
241
- /**
242
- *
243
- * @param {*} v
244
- * @returns
245
- */
246
- export function toggleState(v) {
247
- if (STATE[v] != null) {
248
- return STATE[v];
249
- }
250
- if (v) {
251
- return 1;
252
- }
253
- return 0;
254
- }
255
-
256
- /**
257
- *
258
- * @param {*} v
259
- * @returns
260
- */
261
- export function radioState(v) {
262
- if (RADIO[v] != null) {
263
- return RADIO[v];
264
- }
265
- return 0;
266
- }
267
-
268
- /**
269
- *
270
- * @param {*} v
271
- * @returns
272
- */
273
- export function toBoolean(v) {
274
- if (BOOLEAN[v] != null) {
275
- return BOOLEAN[v];
276
- }
277
- return false;
278
- }
279
-
280
-
281
- /**
282
- *
283
- * @param {*} x
284
- * @returns
285
- */
286
- export function isNumeric(x) {
287
- if (_.isNumber(x)) {
288
- return true;
289
- }
290
- if (_.isString(x)) {
291
- if (x.match(/^[0-9]+(\.)*[0-9]\%$/)) {
292
- return false;
293
- }
294
- return x.match(/[0-9]\.*[0-9]*/) || x.match(/([0-9]\.*[0-9]*)px/i);
295
- }
296
- return false;
297
- }
298
-
299
- /**
300
- *
301
- * @param {*} outer
302
- * @param {*} inner
303
- * @returns
304
- */
305
- export function fitBoxes(outer, inner) {
306
- let hi, wi;
307
- outer.height = parseInt(outer.height);
308
- outer.width = parseInt(outer.width);
309
- inner.height = parseInt(inner.height) || outer.height;
310
- inner.width = parseInt(inner.width) || outer.width;
311
- const innerRatio = inner.width / inner.height;
312
- const outerRatio = outer.width / outer.height;
313
- if (outerRatio > innerRatio) {
314
- wi = (inner.width * outer.height) / inner.height;
315
- hi = outer.height;
316
- } else {
317
- wi = outer.width;
318
- hi = (inner.height * outer.width) / inner.width;
319
- }
320
- const scaled = outerRatio / innerRatio;
321
- const _box = {
322
- width: wi,
323
- height: hi,
324
- scaled,
325
- };
326
- return _box;
327
- }
328
-
329
- /**
330
- *
331
- * @param {*} string
332
- * @returns
333
- */
334
- export function capFirst(string) {
335
- return string.charAt(0).toUpperCase() + string.slice(1);
336
- }
337
-
338
- /**
339
- *
340
- * @param {*} sortByFunction
341
- * @returns
342
- */
343
- export function reverseSortBy(sortByFunction) {
344
- return function (left, right) {
345
- var l = sortByFunction(left);
346
- var r = sortByFunction(right);
347
-
348
- if (l === void 0) return -1;
349
- if (r === void 0) return 1;
350
-
351
- return l < r ? 1 : l > r ? -1 : 0;
352
- };
353
- }
354
-
355
- /**
356
- *
357
- * @param {*} name
358
- * @returns
359
- */
360
- export function modelComparator(name) {
361
- return function modelComparator(model) {
362
- let v = model.get(name);
363
- if (v.toLowerCase) {
364
- return v.toLowerCase();
365
- }
366
- return v;
367
- }
368
- }
369
-
370
- /**
371
- *
372
- * @param {*} size
373
- * @returns
374
- */
375
- export function toPercent(size) {
376
- size = size * 100;
377
- return `${Math.round(size)}%`;
378
- }
379
-
380
-
381
-
382
-
383
- /**
384
- *
385
- * @param {*} val
386
- * @returns
387
- */
388
- export function arcLength(val) {
389
- const c = Math.PI * (80 * 2);
390
-
391
- if (val < 0) {
392
- val = 0;
393
- }
394
- if (val > 100) {
395
- val = 100;
396
- }
397
-
398
- const pct = ((100 - val) / 100) * c;
399
- return `${pct}`;
400
- }
401
-
402
- /**
403
- *
404
- * @param {*} msg
405
- */
406
- export function openUserMailAgent(msg) {
407
- let subject = msg.subject || msg.title || "";
408
- let body = msg.body || msg.message || "";
409
- subject = encodeURIComponent(subject);
410
- body = encodeURIComponent(body);
411
- var mailToLink = `?subject=${subject}&body=${body}`;
412
- if (msg.recipients) {
413
- if (_.isString(msg.recipients)) {
414
- mailToLink = `mailto:${msg.recipients}${mailToLink}`;
415
- } else if (_.isArray(msg.recipients)) {
416
- let r = msg.recipients.join(";");
417
- mailToLink = `mailto:${r}${mailToLink}`;
418
- }
419
- } else {
420
- mailToLink = `mailto:${mailToLink}`;
421
- }
422
- const a = document.createElement(_K.tag.a);
423
- a.hidden = "";
424
- a.setAttribute(_a.href, mailToLink);
425
- a.setAttribute(_a.target, "_blank");
426
- a.style.position = _a.absolute;
427
- a.style.opacity = 0;
428
- a.style.width = "10px";
429
- a.style.height = "10px";
430
- var clickHandler = () => {
431
- const f = () => {
432
- a.removeEventListener(_e.click, clickHandler);
433
- a.remove();
434
- };
435
- setTimeout(f, 300);
436
- };
437
- console.log("AAA:427", a)
438
- window.CLIKK = a;
439
- a.addEventListener(_e.click, clickHandler, false);
440
- setTimeout(() => {
441
- a.click();
442
- }, 300);
443
- }
444
-
445
-
446
- /**
447
- *
448
- * @param {*} link
449
- * @returns
450
- */
451
- export function openLink(link) {
452
- if (window.open(link, "_blank") == null) {
453
- return alert(LOCALE.WINDOW_BLOCKED);
454
- }
455
- }
456
-
457
- /**
458
- *
459
- * @param {*} len
460
- * @param {*} sep
461
- * @returns
462
- */
463
- export function randomString(len, sep) {
464
- if (len == null) {
465
- len = 1;
466
- }
467
- if (sep == null) {
468
- sep = "";
469
- }
470
- const a = new Uint32Array(len);
471
- const b = window.crypto.getRandomValues(a);
472
- const c = [];
473
- b.forEach((e) => c.push(e.toString(16)));
474
- return c.join(sep);
475
- }
476
-
477
- /**
478
- *
479
- * @param {*} e
480
- * @returns
481
- */
482
- export function dataTransfer(e) {
483
- let item;
484
- let res = { folders: [], files: [] };
485
- switch (e.type) {
486
- case _e.drop:
487
- var dt = e.originalEvent.dataTransfer;
488
- if (dt == null) {
489
- return res;
490
- }
491
- var items = dt.items || dt.files || [];
492
-
493
- var folders = [];
494
- var entries = [];
495
- var files = [];
496
-
497
- for (item of Array.from(items)) {
498
- if (_.isFunction(item.getAsEntry)) {
499
- entries.push(item.getAsEntry());
500
- } else if (_.isFunction(item.webkitGetAsEntry)) {
501
- entries.push(item.webkitGetAsEntry());
502
- }
503
- }
504
-
505
- for (let entry of Array.from(entries)) {
506
- if (entry && entry.isDirectory) {
507
- folders.push(entry);
508
- } else if (entry && entry.isFile) {
509
- files.push(entry);
510
- }
511
- }
512
- res = { folders, files };
513
- break;
514
- case _e.change:
515
- items = e.target.items || [];
516
- files = e.target.files || [];
517
- folders = [];
518
- for (item of Array.from(items)) {
519
- if (_.isFunction(item.getAsEntry)) {
520
- folders.push(item.getAsEntry());
521
- } else if (_.isFunction(item.webkitGetAsEntry)) {
522
- folders.push(item.webkitGetAsEntry());
523
- }
524
- }
525
- res = { folders, files };
526
- break;
527
- default:
528
- console.warn("Got wrong type", e);
529
- }
530
- return res;
531
- }
532
-
533
- /**
534
- *
535
- * @param {*} fonts
536
- * @param {*} id
537
- * @returns
538
- */
539
- export function appendFontFace(fonts, id) {
540
- if (!_.isArray(fonts)) {
541
- return;
542
- }
543
- const { main_domain } = bootstrap();
544
- id = id || Host.get(_a.id);
545
- id = `--font-face-${id}`;
546
- let el = document.getElementById(id);
547
- if (el != null) {
548
- document.head.removeChild(el);
549
- }
550
- el = document.createElement(_a.style);
551
- el.setAttribute(_a.id, id);
552
- el.setAttribute(_a.type, "text/css");
553
- el.setAttribute("rel", _a.stylesheet);
554
- el.setAttribute(_a.media, _a.screen);
555
- const list = [];
556
- const { protocol } = bootstrap()
557
- for (let f of Array.from(fonts)) {
558
- var l1, url;
559
- if (_.isEmpty(f.local1)) {
560
- l1 = f.name;
561
- } else {
562
- l1 = f.local1;
563
- }
564
- url = `${protocol}://${main_domain}${f.url}`
565
- const src = `local('${l1}'), local('${f.local2}'), url(${url}) format('${f.format}')`;
566
- const fn = f.name || f.family;
567
- const str = `@font-face {\n \
568
- font-family:'${fn}';\n \
569
- font-style: ${f.style};\n \
570
- font-weight: ${f.weight};\n \
571
- src: ${src};\n \
572
- }\n`;
573
- list.push(str);
574
- }
575
- el.appendChild(document.createTextNode(list.join(" ")));
576
- return document.head.appendChild(el);
577
- }
578
-
579
-
580
- /**
581
- *
582
- * @param {*} url
583
- * @returns
584
- */
585
- export function appendLink(url) {
586
- return new Promise((resolve, reject) => {
587
- const id = this._ensureEl(url, "link");
588
- // id = opt.id
589
- if (id == null || id === undefined) {
590
- this.debug("Injecting undefined link", url);
591
- return reject();
592
- }
593
- const el = document.createElement(_a.link);
594
- el.setAttribute("id", id);
595
- el.setAttribute("rel", _a.stylesheet);
596
- el.setAttribute("href", url);
597
- el.setAttribute("media", "screen");
598
- const xhr = new XMLHttpRequest();
599
- xhr.allowCORS(xhr, url);
600
- xhr.open("GET", url, true);
601
- xhr.send();
602
- return (xhr.onloadend = function (e) {
603
- document.head.appendChild(el);
604
- resolve(e);
605
- });
606
- });
607
- }
608
-
609
-
610
- /**
611
- *
612
- * @param {*} url
613
- * @returns
614
- */
615
- export function createQrcode(opt) {
616
- const p = 50;
617
- const { id, text = "", maxWidth = window.innerWidth - p, maxHeight = window.innerHeight - p } = opt;
618
- let count = 0;
619
- return new Promise((resolve, reject) => {
620
- let i = setInterval(async () => {
621
- count++;
622
- const canvas = document.getElementById(id);
623
- if (canvas) {
624
- clearInterval(i);
625
- let { toDataURL } = require("qrcode");
626
- let src = await toDataURL(text);
627
- if (canvas.width > maxWidth) {
628
- canvas.width = maxWidth;
629
- }
630
- if (canvas.height > maxHeight) {
631
- canvas.height = maxHeight;
632
- }
633
- canvas.src = src;
634
- resolve(canvas)
635
- } else {
636
- if (count > 100) {
637
- console.warn(`Failed to find provided element id=${id}`);
638
- reject({ error: `Element not found` })
639
- }
640
- }
641
- }, 300);
642
- });
643
- }
644
-
645
- export function createSafeObject(initial = {}) {
646
- const data = { ...initial };
647
-
648
- const handler = {
649
- get(target, prop) {
650
- // Handle method calls
651
- if (methods.hasOwnProperty(prop)) {
652
- return methods[prop].bind(proxy);
653
- }
654
-
655
- // Handle property access
656
- if (prop in data) {
657
- return data[prop];
658
- }
659
-
660
- // Return key as string for missing properties
661
- return String(prop);
662
- },
663
-
664
- set(target, prop, value) {
665
- // Don't allow overriding methods
666
- if (prop in methods) {
667
- console.warn(`Cannot override method "${prop}"`);
668
- return false;
669
- }
670
- data[prop] = value;
671
- return true;
672
- }
673
- };
674
-
675
- // Built-in methods
676
- const methods = {
677
- set(key, value) {
678
- data[key] = value;
679
- return this;
680
- },
681
-
682
- get(key) {
683
- return key in data ? data[key] : String(key);
684
- },
685
-
686
- extend(newProps) {
687
- Object.assign(data, newProps);
688
- return this;
689
- },
690
-
691
- delete(key) {
692
- delete data[key];
693
- return this;
694
- },
695
-
696
- has(key) {
697
- return key in data;
698
- },
699
-
700
- keys() {
701
- return Object.keys(data);
702
- },
703
-
704
- values() {
705
- return Object.values(data);
706
- },
707
-
708
- toObject() {
709
- return { ...data };
710
- }
711
- };
712
-
713
- const proxy = new Proxy({}, handler);
714
- return proxy;
715
- }
@@ -1,56 +0,0 @@
1
- const identRegExp = /^([a-zA-Z0-9_\-])([a-zA-Z0-9_\.\-])([a-zA-Z0-9_\.\-])*$/;
2
- const hostRegExp = /^[a-zA-Z0-9_\-]+$/;
3
- const nameRegExp = /^([a-zA-Z0-9_\.\-\'\ xC0-\xFF])+$/;
4
-
5
- const validator = {
6
- require(v) {
7
- if (v.trim() === '') {
8
- return false;
9
- }
10
- return true;
11
- },
12
-
13
- email(v) {
14
- if (v.trim() !== '') {
15
- return v.isEmail();
16
- }
17
- return true;
18
- },
19
-
20
- phone(v) {
21
- if (v.trim() !== '') {
22
- return v.isPhoneNumber();
23
- }
24
- return true;
25
- },
26
-
27
- emailOrIdent(v) {
28
- if (v.trim() !== '') {
29
- return v.isEmail() || identRegExp.test(v);
30
- }
31
- return true;
32
- },
33
-
34
- ident(v) {
35
- if (v.trim() !== '') {
36
- return identRegExp.test(v);
37
- }
38
- return true;
39
- },
40
-
41
- host(v) {
42
- if (v.trim() !== '') {
43
- return hostRegExp.test(v);
44
- }
45
- return true;
46
- },
47
-
48
- name(v) {
49
- if (v.trim() !== '') {
50
- return nameRegExp.test(v);
51
- }
52
- return true;
53
- }
54
- };
55
-
56
- module.exports = validator;