vgapp 1.4.4 → 1.4.5

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.
@@ -12,7 +12,8 @@ const NAME = 'hideshowpass';
12
12
  const NAME_KEY = 'vg.hideshowpass';
13
13
  const SELECTOR_DATA_TOGGLE= '[data-vg-toggle="pass"]';
14
14
 
15
- const CLASS_NAME_SHOW = 'show';
15
+ const CLASS_NAME_SHOW = 'show';
16
+ const CLASS_NAME_FOCUS_OFFSET = 'vg-form-sender--content-pass-focus-offset';
16
17
 
17
18
  const EVENT_KEY_CLICK_DATA_API = `click.${NAME_KEY}.data.api`;
18
19
 
@@ -67,6 +68,10 @@ class VGHideShowPass extends BaseModule{
67
68
  const HTML = Html('string');
68
69
  if (this._element.parentElement && this._params.parentClass) {
69
70
  this._element.parentElement.classList.add(this._params.parentClass);
71
+ this._element.parentElement.classList.toggle(
72
+ CLASS_NAME_FOCUS_OFFSET,
73
+ this._params.focus === true
74
+ );
70
75
  }
71
76
 
72
77
  if (!isShow) {
@@ -127,10 +127,10 @@ class VGFormSender extends BaseModule {
127
127
  validate: false,
128
128
  submit: false,
129
129
  fields: [],
130
- timeout: 50,
131
- pass: {
132
- enabled: true,
133
- template: 'pass-open',
130
+ timeout: 50,
131
+ pass: {
132
+ focus: false,
133
+ template: 'pass-open',
134
134
  classes: ['vg-form-sender--hide-show-pass'],
135
135
  insert: 'afterend'
136
136
  },
@@ -270,11 +270,9 @@ class VGFormSender extends BaseModule {
270
270
  this._element.classList.add(this._params.classes.validation);
271
271
  }
272
272
 
273
- if (this._params.pass.enabled) {
274
- [... Selectors.findAll('input[type="password"]', this._element)].forEach((el) => {
275
- VGHideShowPass.init(el, this._params.pass);
276
- })
277
- }
273
+ [... Selectors.findAll('input[type="password"]', this._element)].forEach((el) => {
274
+ VGHideShowPass.init(el, this._params.pass);
275
+ })
278
276
 
279
277
  execute(this._params.callback.afterInit, [this._element, this]);
280
278
 
@@ -78,7 +78,7 @@ VGFormSender.init(document.getElementById('contactForm'), {
78
78
  | `response.enabled` | `boolean` | `false` | Нативная обработка ответа (без AJAX) |
79
79
  | `submit` | `boolean` | `false` | Отправлять нативно (без AJAX) |
80
80
  | `fields` | `Array` | `[]` | Доп. данные для отправки |
81
- | `pass.enabled` | `boolean` | `true` | Показывать иконку глаза у паролей |
81
+ | `pass.focus` | `boolean` | `false` | Увеличивать правый отступ поля и сдвигать иконку глаза при фокусе |
82
82
  | `alert.enabled` | `boolean` | `true` | Показывать уведомления |
83
83
  | `alert.type` | `'modal' \| 'collapse'` | `'modal'` | Тип уведомления |
84
84
  | `alert.errors` | `boolean` | `true` | Показывать детали ошибок |
@@ -22,7 +22,7 @@
22
22
  &--content {
23
23
  position: relative;
24
24
 
25
- &-pass {
25
+ &-pass-focus-offset {
26
26
  &:focus-within {
27
27
  input {
28
28
  padding-right: 5rem;
@@ -56,7 +56,7 @@
56
56
  right: 34px;
57
57
  }
58
58
 
59
- .vg-form-sender--content-pass {
59
+ .vg-form-sender--content-pass-focus-offset {
60
60
  &:focus-within {
61
61
  input {
62
62
  padding-right: 6.25rem;
@@ -23,7 +23,6 @@ const SELECTOR_DATA_TOGGLE_CLEAR = '[data-vg-toggle="lawcookie-clear"]';
23
23
  const EVENT_KEY_CLICK_DATA_API = `click.${NAME_KEY}.data.api`;
24
24
 
25
25
  class VGLawCookie extends BaseModule {
26
- // Убрано статическое sParams — избыточно и небезопасно
27
26
 
28
27
  constructor(element, params = {}) {
29
28
  super(element, params);
@@ -147,13 +146,15 @@ class VGLawCookie extends BaseModule {
147
146
  }
148
147
 
149
148
  /**
150
- * Полный сброс согласия
151
- */
152
- static reset() {
153
- Cookies.remove(VGLawCookie.getDefaultParams().cookie.name);
154
- localStorage.clear();
155
- location.reload();
156
- }
149
+ * Сбрасывает согласие, не затрагивая остальные данные хранилища
150
+ */
151
+ static reset() {
152
+ const { name } = VGLawCookie.getDefaultParams().cookie;
153
+
154
+ Cookies.remove(name);
155
+ localStorage.removeItem(name);
156
+ location.reload();
157
+ }
157
158
 
158
159
  /**
159
160
  * Возвращает дефолтные параметры (для доступа без инстанса)
@@ -164,11 +165,13 @@ class VGLawCookie extends BaseModule {
164
165
  }, {});
165
166
  }
166
167
 
167
- dispose() {
168
- Cookies.remove(VGLawCookie.getDefaultParams().cookie.name);
169
- localStorage.clear();
170
- super.dispose();
171
- }
168
+ dispose() {
169
+ const { name } = this._params.cookie;
170
+
171
+ Cookies.remove(name);
172
+ localStorage.removeItem(name);
173
+ super.dispose();
174
+ }
172
175
 
173
176
  /**
174
177
  * Инициализация модуля
@@ -213,7 +216,7 @@ EventHandler.on(document, EVENT_KEY_CLICK_DATA_API, SELECTOR_DATA_TOGGLE_CLEAR,
213
216
 
214
217
  const instance = VGLawCookie.getOrCreateInstance(element);
215
218
  instance.dispose();
216
- VGLawCookie.reset(); // Полный сброс
217
- });
219
+ VGLawCookie.reset(); // Сброс согласия
220
+ });
218
221
 
219
- export default VGLawCookie;
222
+ export default VGLawCookie;