@formixru/b2b-ui 1.0.4 → 1.0.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## v1.0.5
2
+
3
+ - Доработки по коду и документации
4
+ - Функция __FORMIX__DIALOG__INIT_JSON переименована в __FORMIX__DIALOG__INTERCEPT_DATA
5
+ - Обновлена требуемая версия @advdominion/tooltip
6
+ - Доработки по работе по .tabs
7
+
1
8
  ## v1.0.4
2
9
 
3
10
  - Добавлены новые переменные для .slider-nav
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formixru/b2b-ui",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -28,7 +28,7 @@
28
28
  "@advdominion/is": "^1.0.1",
29
29
  "@advdominion/lightningcss-loader": "^1.0.0",
30
30
  "@advdominion/pluralize": "^1.0.1",
31
- "@advdominion/tooltip": "^1.0.0",
31
+ "@advdominion/tooltip": "^3.0.0",
32
32
  "@eslint/eslintrc": "^3.2.0",
33
33
  "@eslint/js": "^9.18.0",
34
34
  "@floating-ui/dom": "^1.6.13",
@@ -125,7 +125,7 @@ export const get = async (id, url) => {
125
125
  try {
126
126
  data = JSON.parse(data);
127
127
  if (is(data.redirect, 'String')) {
128
- if (data.redirect.length > 0) {
128
+ if (data.redirect) {
129
129
  location.assign(data.redirect);
130
130
  clearLoaderTimeout();
131
131
  } else {
@@ -133,9 +133,9 @@ export const get = async (id, url) => {
133
133
  }
134
134
  } else {
135
135
  try {
136
- await window.__FORMIX__DIALOG__INIT_JSON();
136
+ await window.__FORMIX__DIALOG__INTERCEPT_DATA(data);
137
137
  } catch {
138
- console.warn('Функция __FORMIX__DIALOG__INIT_JSON не установлена');
138
+ console.warn('Функция __FORMIX__DIALOG__INTERCEPT_DATA не установлена');
139
139
  }
140
140
  data = data.content || '';
141
141
  }
@@ -44,49 +44,7 @@ export const send = async ($b, url, method, data) => {
44
44
  console.warn('Ошибка при попытке преобразования ответа в JSON.');
45
45
  return {};
46
46
  });
47
- if (data.success) {
48
- $b.dispatchEvent(new CustomEvent('form-success', { bubbles: true }));
49
- }
50
- if (data.dialog) {
51
- const $dialog = document.querySelector(data.dialog.id);
52
- $dialog.querySelector('.dialog__container').innerHTML = data.dialog.content;
53
- showDialog($dialog);
54
- }
55
- if (data.reloadOnHideDialog) {
56
- $b.closest('.dialog').addEventListener('dialog-hide', () => {
57
- location.reload();
58
- });
59
- }
60
- if (data.hideDialog) {
61
- hideDialog($b.closest('.dialog'));
62
- }
63
- try {
64
- await window.__FORMIX__FORM__INTERCEPT_DATA(data);
65
- } catch {
66
- console.warn('Функция __FORMIX__FORM__INTERCEPT_DATA не установлена');
67
- }
68
- if (data.content) {
69
- hideLoader();
70
- const $dialog = $b.closest('.dialog');
71
- if ($dialog) {
72
- $dialog.querySelector('.dialog__container').innerHTML = data.content;
73
- initDialogContent($dialog);
74
- setTimeout(() => {
75
- scrollToError($dialog);
76
- });
77
- } else {
78
- const $parent = $b.parentElement;
79
- $b.outerHTML = data.content;
80
- const $form = $parent.querySelector('.form');
81
- if ($form) {
82
- init($form);
83
- initFormContent($form);
84
- setTimeout(() => {
85
- scrollToError($form);
86
- });
87
- }
88
- }
89
- } else if (is(data.redirect, 'String')) {
47
+ if (is(data.redirect, 'String')) {
90
48
  if (data.redirect) {
91
49
  location.assign(data.redirect);
92
50
  if (data.redirect.startsWith('tg:')) {
@@ -98,7 +56,51 @@ export const send = async ($b, url, method, data) => {
98
56
  location.reload();
99
57
  }
100
58
  } else {
101
- hideLoader();
59
+ if (!(data.reloadOnHideDialog && data.hideDialog)) {
60
+ hideLoader();
61
+ }
62
+ try {
63
+ await window.__FORMIX__FORM__INTERCEPT_DATA(data);
64
+ } catch {
65
+ console.warn('Функция __FORMIX__FORM__INTERCEPT_DATA не установлена');
66
+ }
67
+ if (data.success) {
68
+ $b.dispatchEvent(new CustomEvent('form-success', { bubbles: true }));
69
+ }
70
+ if (data.dialog) {
71
+ const $dialog = document.querySelector(data.dialog.id);
72
+ $dialog.querySelector('.dialog__container').innerHTML = data.dialog.content;
73
+ showDialog($dialog);
74
+ }
75
+ if (data.reloadOnHideDialog) {
76
+ $b.closest('.dialog').addEventListener('dialog-hide', () => {
77
+ location.reload();
78
+ });
79
+ }
80
+ if (data.hideDialog) {
81
+ hideDialog($b.closest('.dialog'));
82
+ }
83
+ if (data.content) {
84
+ const $dialog = $b.closest('.dialog');
85
+ if ($dialog) {
86
+ $dialog.querySelector('.dialog__container').innerHTML = data.content;
87
+ initDialogContent($dialog);
88
+ setTimeout(() => {
89
+ scrollToError($dialog);
90
+ });
91
+ } else {
92
+ const $parent = $b.parentElement;
93
+ $b.outerHTML = data.content;
94
+ const $form = $parent.querySelector('.form');
95
+ if ($form) {
96
+ init($form);
97
+ initFormContent($form);
98
+ setTimeout(() => {
99
+ scrollToError($form);
100
+ });
101
+ }
102
+ }
103
+ }
102
104
  }
103
105
  } catch (error) {
104
106
  if (error.status === 401) {
@@ -88,10 +88,9 @@ export const get = async (id, url, showLoaderDelay) => {
88
88
  if (data.length > 0) {
89
89
  const $b = document.querySelector(id);
90
90
  $b.innerHTML = data;
91
- show($b).then(() => {
92
- hideLoader();
93
- initSidebarContent($b);
94
- });
91
+ await show($b)
92
+ hideLoader();
93
+ initSidebarContent($b);
95
94
  } else {
96
95
  hideLoader();
97
96
  }
@@ -10,7 +10,7 @@ const setLeftWidth = async ($line, $el) => {
10
10
  const $label = $el.querySelector('.tabs__label');
11
11
  const styles = {
12
12
  width: $label.getBoundingClientRect().width,
13
- left: $label.offsetLeft,
13
+ left: $el.offsetLeft + $label.offsetLeft,
14
14
  };
15
15
  await $line.animate([{ transform: `translateX(${styles.left}px)`, width: `${styles.width}px` }], {
16
16
  duration: cssVar('--duration-effect-s'),