vgapp 0.7.2 → 0.7.4

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.
@@ -31,6 +31,8 @@ const NAME_KEY = 'vg.fs';
31
31
  /**
32
32
  * Constants Events
33
33
  */
34
+ const CLASS_NAME_ALERT = 'vg-form-sender-alert';
35
+
34
36
  const EVENT_KEY_SUCCESS = 'vg.fs.success';
35
37
  const EVENT_KEY_ERROR = 'vg.fs.error';
36
38
  const EVENT_KEY_BEFORE = 'vg.fs.before';
@@ -297,7 +299,7 @@ class VGFormSender extends BaseModule {
297
299
  }
298
300
  } else {
299
301
  if ('errors' in response && normalizeData(response.errors)) {
300
- status = normalizeData(response.errors) ? 'error' : 'success';
302
+ status = normalizeData(response.errors) ? 'danger' : 'success';
301
303
  }
302
304
  }
303
305
  }
@@ -388,7 +390,9 @@ class VGFormSender extends BaseModule {
388
390
  }
389
391
 
390
392
  setDataRelationStatus($element, status, data, type) {
391
- let $alert = Selectors.find('.vg-alert-' + status, $element);
393
+ if (status === 'error') status = 'danger';
394
+
395
+ let $alert = Selectors.find('.'+ CLASS_NAME_ALERT +'-' + status, $element);
392
396
 
393
397
  if (isObject(data)) {
394
398
  if (status === 'error') {
@@ -435,11 +439,11 @@ class VGFormSender extends BaseModule {
435
439
  code = ' ' + data.text + ' (' + data.code + ')';
436
440
  }
437
441
 
438
- if (!title) txt += '<h4 class="vg-alert-content--title">' + code + '</h4>';
439
- else txt += '<h4 class="vg-alert-content--title">' + title + '</h4>';
442
+ if (!title) txt += '<h4 class="'+ CLASS_NAME_ALERT +'-content--title">' + code + '</h4>';
443
+ else txt += '<h4 class="'+ CLASS_NAME_ALERT +'-content--title">' + title + '</h4>';
440
444
 
441
445
  if ('message' in response) {
442
- txt += '<div class="vg-alert-content--message">' + response.message + '</div>'
446
+ txt += '<div class="'+ CLASS_NAME_ALERT +'-content--message">' + response.message + '</div>'
443
447
  }
444
448
 
445
449
  if ('errors' in response && this._params.alert.errors) {
@@ -469,13 +473,13 @@ class VGFormSender extends BaseModule {
469
473
 
470
474
  if (!$alert) {
471
475
  $alert = document.createElement('div');
472
- $alert.classList.add('vg-alert', 'vg-alert-' + status, 'vg-alert-' + type);
476
+ $alert.classList.add(CLASS_NAME_ALERT, CLASS_NAME_ALERT + '-' + status, CLASS_NAME_ALERT + '-' + type);
473
477
 
474
478
  let content = document.createElement('div');
475
- content.classList.add('vg-alert-content');
479
+ content.classList.add(CLASS_NAME_ALERT + '-content');
476
480
 
477
481
  let icon = document.createElement('div');
478
- icon.classList.add('vg-alert-content--icon');
482
+ icon.classList.add(CLASS_NAME_ALERT + '-content--icon');
479
483
 
480
484
  let i = document.createElement('i');
481
485
  i.innerHTML = getSVG(status);
@@ -484,13 +488,13 @@ class VGFormSender extends BaseModule {
484
488
  content.append(icon);
485
489
 
486
490
  let text = document.createElement('div');
487
- text.classList.add('vg-alert-content--text');
491
+ text.classList.add(CLASS_NAME_ALERT + '-content--text');
488
492
  text.innerHTML = data.view;
489
493
 
490
494
  content.append(text);
491
495
  $alert.append(content);
492
496
  } else {
493
- let text = Selectors.find('.vg-alert-content--text', $alert);
497
+ let text = Selectors.find('.'+ CLASS_NAME_ALERT +'-content--text', $alert);
494
498
  text.innerHTML = data.view;
495
499
  }
496
500
 
@@ -1,3 +1,3 @@
1
1
  $form-sender-map: (
2
2
  'eye-color': $color
3
- );
3
+ );
@@ -6,10 +6,10 @@
6
6
  *--------------------------------------------------------------------------
7
7
  **/
8
8
 
9
- @import "../../../utils/scss/functions";
10
- @import "../../../utils/scss/mixin";
11
- @import "../../../utils/scss/variables";
12
- @import "variables";
9
+ @import '../../../utils/scss/functions';
10
+ @import '../../../utils/scss/mixin';
11
+ @import '../../../utils/scss/variables';
12
+ @import 'variables';
13
13
 
14
14
  .vg-form-sender {
15
15
  @include mix-vars('form-sender', $form-sender-map);
@@ -45,4 +45,53 @@
45
45
  right: 34px;
46
46
  }
47
47
  }
48
+ }
49
+
50
+ .vg-form-sender-alert {
51
+ @include mix-alert-color-mode($class: vg-form-sender-alert);
52
+
53
+ background-color: var(--vg-form-sender-alert-background-color);
54
+ border: 1px solid var(--vg-form-sender-alert-border-color) ;
55
+ border-radius: var(--vg-border-radius);
56
+
57
+ &.vg-form-sender-alert-modal {
58
+ height: 260px;
59
+ display: flex;
60
+ align-items: center;
61
+ justify-content: center;
62
+
63
+ .vg-form-sender-alert-content {
64
+ display: flex;
65
+ flex-direction: column;
66
+ align-items: center;
67
+ gap: 1.5rem;
68
+ }
69
+
70
+ .vg-form-sender-alert-content--text {
71
+ text-align: center;
72
+ }
73
+ }
74
+
75
+ &.vg-form-sender-alert-collapse {
76
+ margin-bottom: 2rem;
77
+ padding: 2rem;
78
+
79
+ .vg-form-sender-alert-content {
80
+ display: flex;
81
+ gap: 2rem;
82
+ }
83
+ }
84
+ }
85
+
86
+ .vg-form-sender-alert-content--icon {
87
+ svg {
88
+ path {
89
+ fill: var(--vg-form-sender-alert-icon);
90
+ }
91
+ }
92
+ }
93
+
94
+ .vg-form-sender-alert-content--text {
95
+ font-size: 1.25rem;
96
+ color: var(--vg-form-sender-alert-color);
48
97
  }
@@ -70,12 +70,12 @@ class VGLoadMore extends BaseModule{
70
70
  buttonParams = normalizeData(el.dataset.button);
71
71
 
72
72
  if (!isObject(buttonParams)) {
73
- console.log('Дата атрибут data-button должен быть в формате json и передавать объект');
73
+ console.error('Дата атрибут data-button должен быть в формате json и передавать объект');
74
74
  return;
75
75
  }
76
76
 
77
77
  if (limit < offset) {
78
- console.log('Параметр offset должен быть меньше или равен параметру limit');
78
+ console.error('Параметр offset должен быть меньше или равен параметру limit');
79
79
  return;
80
80
  }
81
81
 
@@ -51,6 +51,7 @@ class VGModal extends BaseModule {
51
51
  fields: [],
52
52
  hash: false,
53
53
  centered: false,
54
+ dismiss: true,
54
55
  ajax: {
55
56
  route: '',
56
57
  target: '',
@@ -106,8 +107,11 @@ class VGModal extends BaseModule {
106
107
  if (typeof id !== "string") return;
107
108
 
108
109
  let _element = document.createElement('div');
109
- _element.classList.add('vg-modal', 'fade');
110
- _element.id = id;let dialog = document.createElement('div');
110
+ _element.classList.add('vg-modal');
111
+ _element.classList.add('fade');
112
+ _element.id = id;
113
+
114
+ let dialog = document.createElement('div');
111
115
  dialog.classList.add('vg-modal-dialog');
112
116
 
113
117
  if ('centered' in params && params.centered) {
@@ -117,14 +121,16 @@ class VGModal extends BaseModule {
117
121
  let content = document.createElement('div');
118
122
  content.classList.add('vg-modal-content');
119
123
 
120
- let btnClose = document.createElement('button');
121
- Manipulator.set(btnClose, 'type', 'button');
122
- Manipulator.set(btnClose, 'data-vg-dismiss', 'modal');
123
- Manipulator.set(btnClose, 'data-vg-target', '#' + id);
124
- Manipulator.set(btnClose, 'aria-label', 'close');
125
- btnClose.classList.add('vg-btn-close');
124
+ if ('dismiss' in params && params.dismiss) {
125
+ let btnClose = document.createElement('button');
126
+ Manipulator.set(btnClose, 'type', 'button');
127
+ Manipulator.set(btnClose, 'data-vg-dismiss', 'modal');
128
+ Manipulator.set(btnClose, 'data-vg-target', '#' + id);
129
+ Manipulator.set(btnClose, 'aria-label', 'close');
130
+ btnClose.classList.add('vg-btn-close');
126
131
 
127
- content.append(btnClose);
132
+ content.append(btnClose);
133
+ }
128
134
 
129
135
  let body = document.createElement('div');
130
136
  body.classList.add('vg-modal-body');
@@ -136,6 +142,9 @@ class VGModal extends BaseModule {
136
142
  document.body.append(_element);
137
143
 
138
144
  const modal = VGModal.getOrCreateInstance(_element, params);
145
+ if ('animation' in params) {
146
+ modal._animation(_element, VGModal.NAME_KEY, params.animation);
147
+ }
139
148
 
140
149
  execute(callback, [modal]);
141
150
 
@@ -167,7 +167,7 @@ class VGRollup extends BaseModule {
167
167
  element.classList.add(_this.classes.ellipsis);
168
168
  element.style.webkitLineClamp = line;
169
169
  } else {
170
- console.log("Переменная [data-line] или параметр[line] не должны быть пустыми");
170
+ console.error("Переменная [data-line] или параметр[line] не должны быть пустыми");
171
171
  }
172
172
  }
173
173
  }
@@ -313,7 +313,7 @@ class VGSelect extends BaseModule {
313
313
  });
314
314
 
315
315
  observer.observe(select, {
316
- attributeFilter: ['disabled', 'required', 'style', 'hidden'],
316
+ attributeFilter: ['disabled', 'required', 'style', 'hidden', 'value', 'selected'],
317
317
  childList: true,
318
318
  subtree: true,
319
319
  characterDataOldValue: true,
@@ -51,7 +51,6 @@ class VGSpy extends BaseModule {
51
51
  parentScrollTop: 0
52
52
  }
53
53
  this._params = this._configAfterMerge(this._params);
54
- console.log(this._params)
55
54
 
56
55
  this.refresh();
57
56
  }
@@ -30,6 +30,8 @@ class Animation {
30
30
 
31
31
  this._element.classList.add(this.classes.duration);
32
32
 
33
+ if (this._element.classList.contains('fade')) this._element.classList.remove('fade');
34
+
33
35
  this._triggers();
34
36
  }
35
37
 
@@ -37,6 +39,8 @@ class Animation {
37
39
  EventHandler.on(this._element, this._name_key + '.show', () => {
38
40
  this._element.classList.remove(this._params.out);
39
41
  this._element.classList.add(this._params.in);
42
+ });
43
+ EventHandler.on(this._element, this._name_key + '.shown', () => {
40
44
  this._element.classList.add(this.classes.animated);
41
45
  });
42
46
 
@@ -46,8 +50,11 @@ class Animation {
46
50
  });
47
51
 
48
52
  EventHandler.on(this._element, this._name_key + '.hidden', () => {
49
- this._element.classList.remove(this._params.out);
50
- this._element.classList.remove(this.classes.animated);
53
+ [... this._element.classList].forEach((cl) => {
54
+ if (cl.indexOf('animate__') !== -1) {
55
+ this._element.classList.remove(cl);
56
+ }
57
+ })
51
58
  });
52
59
  }
53
60
  }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Animation Loader
3
+ */
4
+ @keyframes vgLoader {
5
+ 0% {
6
+ transform: rotate(0deg);
7
+ }
8
+ 100% {
9
+ transform: rotate(360deg);
10
+ }
11
+ }
@@ -1,6 +1,7 @@
1
1
  @import "../../utils/scss/functions";
2
- @import "../../utils/scss/mixin";
3
2
  @import "../../utils/scss/variables";
3
+ @import "../../utils/scss/mixin";
4
+ @import "../../utils/scss/animation";
4
5
 
5
6
  .vg-backdrop {
6
7
  @include mix-vars('backdrop', $backdrop-map);
@@ -60,6 +61,7 @@
60
61
  width: 7em;
61
62
  height: 7em;
62
63
  }
64
+
63
65
  .vg-loader {
64
66
  @include mix-vars('loader', $loader-map);
65
67
  margin: var(--vg-loader-margin);
@@ -72,144 +74,4 @@
72
74
  border-left: var(--vg-loader-border-width) var(--vg-loader-border-style) var(--vg-loader-color);
73
75
  transform: var(--vg-loader-transform);
74
76
  animation: var(--vg-loader-animation);
75
- }
76
-
77
- /**
78
- * UI before Animation
79
- */
80
- .ui-success {
81
- &-circle {
82
- stroke-dasharray: 260.75219024795285px, 260.75219024795285px;
83
- stroke-dashoffset: 270.75219024795285px;
84
- transform: rotate(0);
85
- transform-origin: center center;
86
- stroke-linecap: round;
87
- animation: ani-success-circle 1s ease-in both;
88
- }
89
- &-path {
90
- stroke-dasharray: 60px 64px;
91
- stroke-dashoffset: 62px;
92
- stroke-linecap: round;
93
- animation: ani-success-path 0.4s 1s ease-in both;
94
- }
95
- }
96
-
97
- .ui-error {
98
- &-circle {
99
- stroke-dasharray: 260.75219024795285px, 260.75219024795285px;
100
- stroke-dashoffset: 260.75219024795285px;
101
- animation: ani-error-circle 1.2s linear;
102
- }
103
- &-line1 {
104
- stroke-dasharray: 54px 55px;
105
- stroke-dashoffset: 55px;
106
- stroke-linecap: round;
107
- animation: ani-error-line 0.15s 1.2s linear both;
108
- }
109
- &-line2 {
110
- stroke-dasharray: 54px 55px;
111
- stroke-dashoffset: 55px;
112
- stroke-linecap: round;
113
- animation: ani-error-line 0.2s 0.9s linear both;
114
- }
115
- }
116
-
117
- .ui-waiting {
118
- &-circle {
119
- stroke-dasharray: 260.75219024795285px, 260.75219024795285px;
120
- stroke-dashoffset: 260.75219024795285px;
121
- animation: ani-waiting-circle 1.2s linear;
122
- }
123
- &-line1 {
124
- stroke-dasharray: 280.75219024795285px, 200.75219024795285px;
125
- stroke-dashoffset: 280.75219024795285px;
126
- animation: ani-waiting-line 0.8s 0.3s linear both;
127
- transform: rotate(0);
128
- transform-origin: center center;
129
- }
130
- &-line2 {
131
- stroke-dasharray: 54px 55px;
132
- stroke-dashoffset: 55px;
133
- animation: ani-waiting-line2 0.85s .6s ease-in both;
134
- transform: rotate(0) scale(0.9);
135
- transform-origin: center center;
136
- }
137
- }
138
-
139
- /**
140
- * Animation Loader
141
- */
142
- @keyframes vgLoader {
143
- 0% {
144
- transform: rotate(0deg);
145
- }
146
- 100% {
147
- transform: rotate(360deg);
148
- }
149
- }
150
-
151
- // success animation
152
- @keyframes ani-success-circle {
153
- to {
154
- stroke-dashoffset: 782.2565707438586px;
155
- }
156
- }
157
-
158
- @keyframes ani-success-path {
159
- 0% {
160
- stroke-dashoffset: 62px;
161
- }
162
- 65% {
163
- stroke-dashoffset: -5px;
164
- }
165
- 84% {
166
- stroke-dashoffset: 4px;
167
- }
168
- 100% {
169
- stroke-dashoffset: -2px;
170
- }
171
- }
172
-
173
- // error animation
174
- @keyframes ani-error-line {
175
- to {
176
- stroke-dashoffset: 0;
177
- }
178
- }
179
-
180
- @keyframes ani-error-circle {
181
- 0% {
182
- stroke-dasharray: 0, 260.75219024795285px;
183
- stroke-dashoffset: 0;
184
- }
185
- 35% {
186
- stroke-dasharray: 120px, 120px;
187
- stroke-dashoffset: -120px;
188
- }
189
- 70% {
190
- stroke-dasharray: 0, 260.75219024795285px;
191
- stroke-dashoffset: -260.75219024795285px;
192
- }
193
- 100% {
194
- stroke-dasharray: 260.75219024795285px, 0;
195
- stroke-dashoffset: -260.75219024795285px;
196
- }
197
- }
198
-
199
- // waiting animation
200
- @keyframes ani-waiting-circle {
201
- to {
202
- stroke-dashoffset: 782.2565707438586px;
203
- }
204
- }
205
- @keyframes ani-waiting-line {
206
- to {
207
- stroke-dashoffset: 0;
208
- }
209
- }
210
- @keyframes ani-waiting-line2 {
211
- to {
212
- stroke-dashoffset: 0;
213
- transform: rotate(360deg) scale(1);
214
- }
215
77
  }
@@ -19,4 +19,22 @@
19
19
 
20
20
  @function tint-color($color, $weight) {
21
21
  @return mix(white, $color, $weight);
22
+ }
23
+
24
+ @function get-alert-color($type) {
25
+ @if $type == success {
26
+ @return $success-map;
27
+ }
28
+
29
+ @if $type == danger {
30
+ @return $danger-map;
31
+ }
32
+
33
+ @if $type == warning {
34
+ @return $warning-map;
35
+ }
36
+
37
+ @if $type == info {
38
+ @return $info-map;
39
+ }
22
40
  }
@@ -8,4 +8,16 @@
8
8
  --vg-#{$module}-#{$key}: #{$value}
9
9
  }
10
10
  }
11
+ }
12
+
13
+ @mixin mix-alert-color-mode($class) {
14
+ $colors: ['success', 'info', 'warning', 'danger'];
15
+
16
+ @each $value in $colors {
17
+ &.#{$class}-#{$value} {
18
+ @each $property, $val in get-alert-color($value) {
19
+ --#{$class}-#{$property}: #{$val};
20
+ }
21
+ }
22
+ }
11
23
  }
@@ -4,6 +4,7 @@ $bg-color-active: #c7dcf6 !default;
4
4
 
5
5
  // -- Colors
6
6
  $color: #000000 !default;
7
+ $color-emphasis: #3c3c3c !default;
7
8
  $color-active: #0065ff !default;
8
9
  $color-disabled: rgba(#000000, .5) !default;
9
10
 
@@ -53,25 +54,25 @@ $loader-map: (
53
54
  );
54
55
 
55
56
  // Colors Status
56
- $danger: #dc3545 !default;
57
- $danger-border: tint-color($danger, 60%) !default;
58
- $danger-text: shade-color($danger, 60%) !default;
59
- $danger-bg: tint-color($danger, 80%) !default;
57
+ $danger: #FF2A2C !default;
58
+ $danger-border: #FFCCC7 !default;
59
+ $danger-text: #DF0306 !default;
60
+ $danger-bg: #FFF2F0 !default;
60
61
 
61
- $success: #198754;
62
- $success-border: tint-color($success, 60%) !default;
63
- $success-text: shade-color($success, 60%) !default;
64
- $success-bg: tint-color($success, 80%) !default;
62
+ $success: #4FD90B;
63
+ $success-border: #BAF98A !default;
64
+ $success-text: #40BE02 !default;
65
+ $success-bg: #F6FFED !default;
65
66
 
66
67
  $warning: #FFC107;
67
- $warning-border: tint-color($warning, 60%) !default;
68
- $warning-text: shade-color($warning, 60%) !default;
69
- $warning-bg: tint-color($warning, 80%) !default;
68
+ $warning-border: #FFDE79 !default;
69
+ $warning-text: #FFC107 !default;
70
+ $warning-bg: #FFF6DA !default;
70
71
 
71
- $info: #0DCAF0;
72
- $info-border: tint-color($info, 60%) !default;
73
- $info-text: shade-color($info, 60%) !default;
74
- $info-bg: tint-color($info, 80%) !default;
72
+ $info: #1F8BFF;
73
+ $info-border: #F0FAFF !default;
74
+ $info-text: #0471E5 !default;
75
+ $info-bg: #ADDDFF !default;
75
76
 
76
77
  $dark: #232323;
77
78
  $dark-border: shade-color($dark, 60%) !default;
@@ -79,24 +80,28 @@ $dark-text: tint-color($dark, 60%) !default;
79
80
  $dark-bg: shade-color($dark, 80%) !default;
80
81
 
81
82
  $success-map: (
83
+ icon: $success,
82
84
  color: $success-text,
83
85
  border-color: $success-border,
84
86
  background-color: $success-bg
85
87
  );
86
88
 
87
89
  $danger-map: (
90
+ icon: $danger,
88
91
  color: $danger-text,
89
92
  border-color: $danger-border,
90
93
  background-color: $danger-bg
91
94
  );
92
95
 
93
96
  $warning-map: (
97
+ icon: $warning,
94
98
  color: $warning-text,
95
99
  border-color: $warning-border,
96
100
  background-color: $warning-bg
97
101
  );
98
102
 
99
103
  $info-map: (
104
+ icon: $info,
100
105
  color: $info-text,
101
106
  border-color: $info-border,
102
107
  background-color: $info-bg