@formixru/b2b-ui 1.0.0 → 1.0.1

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 ADDED
@@ -0,0 +1,5 @@
1
+ ## v1.0.1
2
+
3
+ - Исправлены ошибки в работе блока .form
4
+
5
+ ## v1.0.0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formixru/b2b-ui",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -17,8 +17,8 @@ const initFormContent = ($b) => {
17
17
  };
18
18
 
19
19
  export const send = async ($b, url, method, data) => {
20
- url = new URL(url || $b.action, location.origin);
21
- method = method || $b.method;
20
+ url = new URL(url || $b.getAttribute('action'), location.origin);
21
+ method = method || $b.getAttribute('method');
22
22
  data = data || new FormData($b);
23
23
  const options = {
24
24
  method,
@@ -173,11 +173,11 @@ document.body.addEventListener('submit', (event) => {
173
173
  const { target } = event;
174
174
  const $b = target.closest('.form');
175
175
  if ($b) {
176
- const $submitButton = $b.querySelector('.form__submit-button[type="submit"]');
177
- if ($submitButton) {
178
- $submitButton.disabled = true;
179
- }
180
176
  if ($b.classList.contains('form_captcha') && window.smartCaptcha) {
177
+ const $submitButton = $b.querySelector('.form__submit-button[type="submit"]');
178
+ if ($submitButton) {
179
+ $submitButton.disabled = true;
180
+ }
181
181
  const $token = $b.querySelector('input[name="smart-token"]');
182
182
  if ($token && $token.value) {
183
183
  if ($b.classList.contains('form_ajax')) {
@@ -211,7 +211,7 @@ document.body.addEventListener('change', (event) => {
211
211
  if (target.classList.contains('form__trigger')) {
212
212
  $form.requestSubmit();
213
213
  } else if (target.dataset.request) {
214
- const { name, value } = target.dataset.request;
214
+ const { name, value } = JSON.parse(target.dataset.request);
215
215
  $form.insertAdjacentHTML('afterbegin', `<input type="hidden" name="${name}" value="${value}">`);
216
216
  $form.requestSubmit();
217
217
  } else if (target.closest('.form__option')) {