vgapp 0.2.8 → 0.3.0
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/CHANGELOG.md +5 -0
- package/app/modules/vgformsender/js/hideshowpass.js +97 -0
- package/app/modules/vgformsender/js/vgformsender.js +24 -4
- package/app/modules/vgformsender/scss/_variables.scss +3 -0
- package/app/modules/vgformsender/scss/vgformsender.scss +22 -0
- package/app/utils/js/components/templater.js +58 -0
- package/app/utils/js/dom/selectors.js +4 -0
- package/build/vgapp.css +19 -5096
- package/build/vgapp.css.map +1 -1
- package/build/vgapp.js +3 -4982
- package/build/vgapp.js.LICENSE.txt +1 -1
- package/build/vgapp.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import BaseModule from "../../base-module";
|
|
2
|
+
import EventHandler from "../../../utils/js/dom/event";
|
|
3
|
+
import Selectors from "../../../utils/js/dom/selectors";
|
|
4
|
+
import {isDisabled, mergeDeepObject} from "../../../utils/js/functions";
|
|
5
|
+
import Templater from "../../../utils/js/components/templater";
|
|
6
|
+
import {Manipulator} from "../../../utils/js/dom/manipulator";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Constants
|
|
10
|
+
*/
|
|
11
|
+
const NAME = 'hideshowpass';
|
|
12
|
+
const NAME_KEY = 'vg.hideshowpass';
|
|
13
|
+
const SELECTOR_DATA_TOGGLE= '[data-vg-toggle="vgpass"]';
|
|
14
|
+
|
|
15
|
+
const CLASS_NAME_SHOW = 'show';
|
|
16
|
+
|
|
17
|
+
const EVENT_KEY_CLICK_DATA_API = `click.${NAME_KEY}.data.api`;
|
|
18
|
+
|
|
19
|
+
class VGHideShowPass extends BaseModule{
|
|
20
|
+
constructor(el, params = {}) {
|
|
21
|
+
super(el, params);
|
|
22
|
+
|
|
23
|
+
this._params = this._getParams(el, mergeDeepObject({
|
|
24
|
+
|
|
25
|
+
}, params))
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
static get NAME() {
|
|
29
|
+
return NAME;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
static get NAME_KEY() {
|
|
33
|
+
return NAME_KEY
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
toggle(relatedTarget) {
|
|
37
|
+
return !this._isShown() ? this.show(relatedTarget) : this.hide(relatedTarget);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
show(relatedTarget) {
|
|
41
|
+
if (relatedTarget) this._params = this._getParams(relatedTarget, this._params);
|
|
42
|
+
|
|
43
|
+
this._element.classList.add(CLASS_NAME_SHOW);
|
|
44
|
+
relatedTarget.remove();
|
|
45
|
+
this.build(true);
|
|
46
|
+
Manipulator.set(this._element, 'type', 'text');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
hide(relatedTarget) {
|
|
50
|
+
this._element.classList.remove(CLASS_NAME_SHOW);
|
|
51
|
+
relatedTarget.remove();
|
|
52
|
+
this.build(false);
|
|
53
|
+
Manipulator.set(this._element, 'type', 'password');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
_isShown() {
|
|
57
|
+
return this._element.classList.contains(CLASS_NAME_SHOW);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
static init(el, params) {
|
|
61
|
+
let instance = VGHideShowPass.getOrCreateInstance(el, params);
|
|
62
|
+
instance.build(false);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
build(isShow = false) {
|
|
66
|
+
if (!isShow) {
|
|
67
|
+
this._params.template = 'pass-close';
|
|
68
|
+
} else {
|
|
69
|
+
this._params.template = 'pass-open';
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
new Templater(this._element, this._params).render();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Data API implementation
|
|
78
|
+
*/
|
|
79
|
+
EventHandler.on(document, EVENT_KEY_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
|
|
80
|
+
const target = Selectors.prev(this);
|
|
81
|
+
if (!target) return;
|
|
82
|
+
|
|
83
|
+
if (['A', 'AREA'].includes(this.tagName)) {
|
|
84
|
+
event.preventDefault()
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (isDisabled(this)) {
|
|
88
|
+
return
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
this.setAttribute('aria-expanded', true);
|
|
92
|
+
|
|
93
|
+
const instance = VGHideShowPass.getOrCreateInstance(target)
|
|
94
|
+
instance.toggle(this);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
export default VGHideShowPass
|
|
@@ -2,11 +2,11 @@ import BaseModule from "../../base-module";
|
|
|
2
2
|
import {Manipulator} from "../../../utils/js/dom/manipulator";
|
|
3
3
|
import EventHandler from "../../../utils/js/dom/event";
|
|
4
4
|
import VGModal from "../../vgmodal/js/vgmodal";
|
|
5
|
-
import {isObject, makeRandomString, mergeDeepObject, normalizeData} from "../../../utils/js/functions";
|
|
5
|
+
import {execute, isObject, makeRandomString, mergeDeepObject, noop, normalizeData} from "../../../utils/js/functions";
|
|
6
6
|
import Selectors from "../../../utils/js/dom/selectors";
|
|
7
7
|
import VGCollapse from "../../vgcollapse/js/vgcollapse";
|
|
8
8
|
import {getSVG} from "../../module-fn";
|
|
9
|
-
import
|
|
9
|
+
import VGHideShowPass from "./hideshowpass";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Constants
|
|
@@ -33,6 +33,12 @@ class VGFormSender extends BaseModule {
|
|
|
33
33
|
submit: false,
|
|
34
34
|
fields: [],
|
|
35
35
|
timeout: 50,
|
|
36
|
+
pass: {
|
|
37
|
+
enabled: true,
|
|
38
|
+
template: 'pass-open',
|
|
39
|
+
classes: ['vg-form-sender--hide-show-pass'],
|
|
40
|
+
insert: 'afterend'
|
|
41
|
+
},
|
|
36
42
|
alert: {
|
|
37
43
|
enabled: true,
|
|
38
44
|
type: 'modal'
|
|
@@ -47,7 +53,11 @@ class VGFormSender extends BaseModule {
|
|
|
47
53
|
alertCollapse: 'vg-form-sender-collapse',
|
|
48
54
|
alertModal: 'vg-form-sender-modal',
|
|
49
55
|
validation: 'needs-validation',
|
|
50
|
-
wasValidate: 'was-validated'
|
|
56
|
+
wasValidate: 'was-validated',
|
|
57
|
+
content: 'vg-form-sender--content'
|
|
58
|
+
},
|
|
59
|
+
callback: {
|
|
60
|
+
afterInit: noop
|
|
51
61
|
}
|
|
52
62
|
}, params));
|
|
53
63
|
|
|
@@ -71,12 +81,22 @@ class VGFormSender extends BaseModule {
|
|
|
71
81
|
build() {
|
|
72
82
|
this._element.classList.add(this._params.classes.general);
|
|
73
83
|
|
|
84
|
+
[... Selectors.findAll('input, textarea, select', this._element)].forEach((el) => {
|
|
85
|
+
el.parentElement.classList.add(this._params.classes.content)
|
|
86
|
+
});
|
|
87
|
+
|
|
74
88
|
if (this._params.validate) {
|
|
75
89
|
Manipulator.set(this._element, 'novalidate', '');
|
|
76
90
|
this._element.classList.add(this._params.classes.validation);
|
|
77
91
|
}
|
|
78
92
|
|
|
79
|
-
|
|
93
|
+
if (this._params.pass.enabled) {
|
|
94
|
+
[... Selectors.findAll('input[type="password"]', this._element)].forEach((el) => {
|
|
95
|
+
VGHideShowPass.init(el, this._params.pass);
|
|
96
|
+
})
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
execute(this._params.callback.afterInit, [this._element, this]);
|
|
80
100
|
|
|
81
101
|
return this
|
|
82
102
|
}
|
|
@@ -9,11 +9,33 @@
|
|
|
9
9
|
@import "../../../utils/scss/functions";
|
|
10
10
|
@import "../../../utils/scss/mixin";
|
|
11
11
|
@import "../../../utils/scss/variables";
|
|
12
|
+
@import "variables";
|
|
12
13
|
|
|
13
14
|
.vg-form-sender {
|
|
15
|
+
@include mix-vars('form-sender', $form-sender-map);
|
|
16
|
+
|
|
14
17
|
&-modal {
|
|
15
18
|
.vg-modal-content {
|
|
16
19
|
padding: 0;
|
|
17
20
|
}
|
|
18
21
|
}
|
|
22
|
+
|
|
23
|
+
&--content {
|
|
24
|
+
position: relative;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&--hide-show-pass {
|
|
28
|
+
position: absolute;
|
|
29
|
+
top: 15px;
|
|
30
|
+
right: 15px;
|
|
31
|
+
width: 22px;
|
|
32
|
+
height: 22px;
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
|
|
35
|
+
svg {
|
|
36
|
+
path {
|
|
37
|
+
fill: var(--vg-form-sender-eye-color);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
19
41
|
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import {execute, mergeDeepObject} from "../functions";
|
|
2
|
+
|
|
3
|
+
const TEMPLATES = [
|
|
4
|
+
{type: 'collapse', template: ''},
|
|
5
|
+
{type: 'modal', template: '<div class="vg-modal"></div>'},
|
|
6
|
+
{type: 'pass-open', template: '<span data-vg-toggle="vgpass" class="[[classes]]" title="Показать / Скрыть" data-bs-toggle="tooltip"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path d="M288 80c-65.2 0-118.8 29.6-159.9 67.7C89.6 183.5 63 226 49.4 256c13.6 30 40.2 72.5 78.6 108.3C169.2 402.4 222.8 432 288 432s118.8-29.6 159.9-67.7C486.4 328.5 513 286 526.6 256c-13.6-30-40.2-72.5-78.6-108.3C406.8 109.6 353.2 80 288 80zM95.4 112.6C142.5 68.8 207.2 32 288 32s145.5 36.8 192.6 80.6c46.8 43.5 78.1 95.4 93 131.1c3.3 7.9 3.3 16.7 0 24.6c-14.9 35.7-46.2 87.7-93 131.1C433.5 443.2 368.8 480 288 480s-145.5-36.8-192.6-80.6C48.6 356 17.3 304 2.5 268.3c-3.3-7.9-3.3-16.7 0-24.6C17.3 208 48.6 156 95.4 112.6zM288 336c44.2 0 80-35.8 80-80s-35.8-80-80-80c-.7 0-1.3 0-2 0c1.3 5.1 2 10.5 2 16c0 35.3-28.7 64-64 64c-5.5 0-10.9-.7-16-2c0 .7 0 1.3 0 2c0 44.2 35.8 80 80 80zm0-208a128 128 0 1 1 0 256 128 128 0 1 1 0-256z"/></svg></span>'},
|
|
7
|
+
{type: 'pass-close', template: '<span data-vg-toggle="vgpass" class="[[classes]]" title="Показать / Скрыть" data-bs-toggle="tooltip"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7L525.6 386.7c39.6-40.6 66.4-86.1 79.9-118.4c3.3-7.9 3.3-16.7 0-24.6c-14.9-35.7-46.2-87.7-93-131.1C465.5 68.8 400.8 32 320 32c-68.2 0-125 26.3-169.3 60.8L38.8 5.1zm151 118.3C226 97.7 269.5 80 320 80c65.2 0 118.8 29.6 159.9 67.7C518.4 183.5 545 226 558.6 256c-12.6 28-36.6 66.8-70.9 100.9l-53.8-42.2c9.1-17.6 14.2-37.5 14.2-58.7c0-70.7-57.3-128-128-128c-32.2 0-61.7 11.9-84.2 31.5l-46.1-36.1zM394.9 284.2l-81.5-63.9c4.2-8.5 6.6-18.2 6.6-28.3c0-5.5-.7-10.9-2-16c.7 0 1.3 0 2 0c44.2 0 80 35.8 80 80c0 9.9-1.8 19.4-5.1 28.2zm9.4 130.3C378.8 425.4 350.7 432 320 432c-65.2 0-118.8-29.6-159.9-67.7C121.6 328.5 95 286 81.4 256c8.3-18.4 21.5-41.5 39.4-64.8L83.1 161.5C60.3 191.2 44 220.8 34.5 243.7c-3.3 7.9-3.3 16.7 0 24.6c14.9 35.7 46.2 87.7 93 131.1C174.5 443.2 239.2 480 320 480c47.8 0 89.9-12.9 126.2-32.5l-41.9-33zM192 256c0 70.7 57.3 128 128 128c13.3 0 26.1-2 38.2-5.8L302 334c-23.5-5.4-43.1-21.2-53.7-42.3l-56.1-44.2c-.2 2.8-.3 5.6-.3 8.5z"/></svg></span>'},
|
|
8
|
+
]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Templater {
|
|
12
|
+
constructor(el, params = {}) {
|
|
13
|
+
if (!el) {
|
|
14
|
+
throw new Error('Element is required');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
this._element = el;
|
|
18
|
+
this._params = mergeDeepObject({
|
|
19
|
+
insert: 'afterend',
|
|
20
|
+
classes: []
|
|
21
|
+
}, params);
|
|
22
|
+
|
|
23
|
+
this.templateBuild = null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
render(content, callback) {
|
|
27
|
+
let tmpl = this.toHTML(content, callback);
|
|
28
|
+
|
|
29
|
+
switch (this._params.insert) {
|
|
30
|
+
case 'afterend':
|
|
31
|
+
this._element.insertAdjacentHTML('afterend', tmpl);
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
toHTML(content = '' | null, callback) {
|
|
37
|
+
let tmpl = '';
|
|
38
|
+
|
|
39
|
+
for (const tmplElement of TEMPLATES) {
|
|
40
|
+
if (tmplElement.type === this._params.template) {
|
|
41
|
+
tmpl = tmplElement.template;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (!tmpl) return;
|
|
46
|
+
|
|
47
|
+
tmpl = tmpl.replace('[[classes]]', this._params.classes.join(' '));
|
|
48
|
+
execute(callback, [this._element, this._params, tmpl]);
|
|
49
|
+
|
|
50
|
+
return tmpl;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
setContent() {
|
|
54
|
+
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export default Templater;
|