@boobooking/dashboard-ui-components 0.16.1 → 0.16.3
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/README.md +32 -3
- package/dist/index.js +12 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -332,15 +332,44 @@ exportOrders() {
|
|
|
332
332
|
```
|
|
333
333
|
|
|
334
334
|
- Запрос — `GET` с cookie сессии (`credentials: 'same-origin'`).
|
|
335
|
-
- Promise отклоняется:
|
|
336
|
-
перенаправлении — обычно на страницу входа после истёкшей
|
|
337
|
-
|
|
335
|
+
- Promise отклоняется:
|
|
336
|
+
- при перенаправлении — обычно на страницу входа после истёкшей сессии:
|
|
337
|
+
у ошибки `redirectUrl` — адрес, куда в итоге привёл сервер, `status` —
|
|
338
|
+
`null`;
|
|
339
|
+
- при ответе не `2xx`: `status` — код ответа, `redirectUrl` — `null`;
|
|
340
|
+
- при сетевой ошибке — ошибкой `fetch`, без этих полей.
|
|
338
341
|
- Имя файла — из `Content-Disposition` (`filename*=UTF-8''…`, затем
|
|
339
342
|
`filename`), без него — последний сегмент пути адреса, без пути —
|
|
340
343
|
`download`.
|
|
341
344
|
- Таймаута нет; уход со страницы скачивание не прерывает. Файл до
|
|
342
345
|
сохранения целиком в памяти вкладки.
|
|
343
346
|
|
|
347
|
+
Ссылка при истёкшей сессии привела бы браузер на страницу входа. Чтобы
|
|
348
|
+
страница вела себя так же, она сама переходит по `redirectUrl`: пакет
|
|
349
|
+
не импортирует ни Inertia, ни роутер. В приложении на Inertia:
|
|
350
|
+
|
|
351
|
+
```js
|
|
352
|
+
import { router } from '@inertiajs/vue3'
|
|
353
|
+
|
|
354
|
+
exportOrders() {
|
|
355
|
+
this.exportFailure = "";
|
|
356
|
+
this.exportLoading = true;
|
|
357
|
+
|
|
358
|
+
downloadFile(this.exportUrl)
|
|
359
|
+
.catch((error) => {
|
|
360
|
+
if (error.redirectUrl) {
|
|
361
|
+
router.visit(error.redirectUrl);
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
this.exportFailure = "Попробуйте ещё раз";
|
|
366
|
+
})
|
|
367
|
+
.finally(() => {
|
|
368
|
+
this.exportLoading = false;
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
```
|
|
372
|
+
|
|
344
373
|
### ConfirmationModal
|
|
345
374
|
|
|
346
375
|
Модалка подтверждения действия: заголовок, текст, кнопка действия и кнопка
|
package/dist/index.js
CHANGED
|
@@ -269,8 +269,14 @@ function xe(e) {
|
|
|
269
269
|
}
|
|
270
270
|
async function Se(e) {
|
|
271
271
|
let t = await fetch(e, { credentials: "same-origin" });
|
|
272
|
-
if (t.redirected) throw Error(`downloadFile: сервер перенаправил запрос ${e}`)
|
|
273
|
-
|
|
272
|
+
if (t.redirected) throw Object.assign(/* @__PURE__ */ Error(`downloadFile: сервер перенаправил запрос ${e}`), {
|
|
273
|
+
redirectUrl: t.url,
|
|
274
|
+
status: null
|
|
275
|
+
});
|
|
276
|
+
if (!t.ok) throw Object.assign(/* @__PURE__ */ Error(`downloadFile: ответ ${t.status} на ${e}`), {
|
|
277
|
+
redirectUrl: null,
|
|
278
|
+
status: t.status
|
|
279
|
+
});
|
|
274
280
|
let n = be(t.headers.get("Content-Disposition")) ?? xe(e) ?? "download", r = URL.createObjectURL(await t.blob()), i = document.createElement("a");
|
|
275
281
|
i.href = r, i.download = n, i.style.display = "none", document.body.appendChild(i), i.click(), i.remove(), setTimeout(() => URL.revokeObjectURL(r), ye);
|
|
276
282
|
}
|
|
@@ -588,12 +594,12 @@ function Xe(e, t, n, r, o, c) {
|
|
|
588
594
|
onBlur: t[1] ||= (...e) => c.onBlur && c.onBlur(...e),
|
|
589
595
|
onKeydown: t[2] ||= te((...e) => c.commit && c.commit(...e), ["enter"]),
|
|
590
596
|
onPaste: t[3] ||= S((...e) => c.onPaste && c.onPaste(...e), ["prevent"])
|
|
591
|
-
}, null, 544), x(s(u, {
|
|
597
|
+
}, null, 544)]), x(s(u, {
|
|
592
598
|
size: "small",
|
|
593
599
|
onMousedown: t[4] ||= S(() => {}, ["prevent"]),
|
|
594
600
|
onClicked: c.clear,
|
|
595
601
|
class: "bb:absolute bb:right-0 bb:top-0 bb:pr-2 bb:h-full"
|
|
596
|
-
}, null, 8, ["onClicked"]), [[y, o.digits.length > 0]])])])])
|
|
602
|
+
}, null, 8, ["onClicked"]), [[y, o.digits.length > 0]])])])]);
|
|
597
603
|
}
|
|
598
604
|
var Ze = /*#__PURE__*/ A(Ge, [["render", Xe]]), Qe = {
|
|
599
605
|
components: {
|
|
@@ -656,11 +662,11 @@ function rt(e, t, n, r, o, c) {
|
|
|
656
662
|
o.search,
|
|
657
663
|
void 0,
|
|
658
664
|
{ trim: !0 }
|
|
659
|
-
]]), x(s(u, {
|
|
665
|
+
]])]), x(s(u, {
|
|
660
666
|
size: "small",
|
|
661
667
|
onClicked: c.clearInput,
|
|
662
668
|
class: "bb:absolute bb:right-0 bb:top-0 bb:pr-2 bb:h-full"
|
|
663
|
-
}, null, 8, ["onClicked"]), [[y, c.inputNeedsEraser]])])])])
|
|
669
|
+
}, null, 8, ["onClicked"]), [[y, c.inputNeedsEraser]])])])]);
|
|
664
670
|
}
|
|
665
671
|
var it = /*#__PURE__*/ A(Qe, [["render", rt]]), I = 4, L = 8;
|
|
666
672
|
function R(e) {
|