@boobooking/dashboard-ui-components 0.25.1 → 0.26.0
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 +88 -25
- package/dist/index.js +15 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -175,6 +175,9 @@ playground, а не в исходном коде.
|
|
|
175
175
|
Поле ввода российского мобильного номера с маской `+7 (000) 000 00 00` и
|
|
176
176
|
дебаунсом перед отправкой.
|
|
177
177
|
|
|
178
|
+
Высота 4.5rem и серая рамка встроены в фильтр: класс `h-18 border border-gray-200`
|
|
179
|
+
ему не нужен. `class` и остальные атрибуты ложатся на корень фильтра.
|
|
180
|
+
|
|
178
181
|
<russian-mobile-filter v-model="phone" header="Телефон" @changed="reload" />
|
|
179
182
|
|
|
180
183
|
| Проп | Тип | По умолчанию | Описание |
|
|
@@ -200,6 +203,9 @@ playground, а не в исходном коде.
|
|
|
200
203
|
|
|
201
204
|
Текстовое поле поиска с ластиком очистки.
|
|
202
205
|
|
|
206
|
+
Высота 4.5rem и серая рамка встроены в фильтр: класс `h-18 border border-gray-200`
|
|
207
|
+
ему не нужен. `class` и остальные атрибуты ложатся на корень фильтра.
|
|
208
|
+
|
|
203
209
|
<search v-model="query" header="Поиск" @changed="reload" />
|
|
204
210
|
|
|
205
211
|
| Проп | Тип | По умолчанию | Описание |
|
|
@@ -1268,43 +1274,85 @@ exportOrders() {
|
|
|
1268
1274
|
}
|
|
1269
1275
|
```
|
|
1270
1276
|
|
|
1271
|
-
- Запрос — `GET` с cookie сессии (`credentials: 'same-origin'`)
|
|
1277
|
+
- Запрос — `GET` с cookie сессии (`credentials: 'same-origin'`) и
|
|
1278
|
+
заголовком `X-Requested-With: XMLHttpRequest`. Из-за него Laravel на
|
|
1279
|
+
истёкшую сессию отвечает `401`, а на невалидные параметры — `422`, а не
|
|
1280
|
+
перенаправлением.
|
|
1272
1281
|
- Promise отклоняется:
|
|
1273
|
-
- при
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1282
|
+
- при перенаправлении: у ошибки `redirectUrl` — адрес, куда в итоге привёл
|
|
1283
|
+
сервер, `status` — `null`, `sessionExpired` — `false`;
|
|
1284
|
+
- при ответе `401` — сессия истекла: `sessionExpired` — `true`, `status` —
|
|
1285
|
+
`401`, `redirectUrl` — `null`;
|
|
1286
|
+
- при другом ответе не `2xx`: `status` — код ответа, `redirectUrl` —
|
|
1287
|
+
`null`, `sessionExpired` — `false`;
|
|
1277
1288
|
- при сетевой ошибке — ошибкой `fetch`, без этих полей.
|
|
1289
|
+
- Адрес на другом origin из-за заголовка вызовет CORS-preflight: функция
|
|
1290
|
+
рассчитана на свой origin.
|
|
1278
1291
|
- Имя файла — из `Content-Disposition` (`filename*=UTF-8''…`, затем
|
|
1279
1292
|
`filename`), без него — последний сегмент пути адреса, без пути —
|
|
1280
1293
|
`download`.
|
|
1281
1294
|
- Таймаута нет; уход со страницы скачивание не прерывает. Файл до
|
|
1282
1295
|
сохранения целиком в памяти вкладки.
|
|
1283
1296
|
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1297
|
+
Истёкшая сессия приходит как `sessionExpired`: страница показывает своё
|
|
1298
|
+
уведомление, текст пишет она сама. `redirectUrl` — для прочих
|
|
1299
|
+
перенаправлений: ссылка привела бы браузер туда же, поэтому страница сама
|
|
1300
|
+
переходит по нему. Пакет не импортирует ни Inertia, ни роутер. В приложении
|
|
1301
|
+
на Inertia:
|
|
1287
1302
|
|
|
1288
|
-
```
|
|
1303
|
+
```vue
|
|
1304
|
+
<template>
|
|
1305
|
+
<action-pill icon="download" title="скачать xlsx" loading-text="формируется отчёт" :is-loading="exportLoading" @click="exportOrders" />
|
|
1306
|
+
<p v-if="exportFailure">{{ exportFailure }}</p>
|
|
1307
|
+
<notification-message v-model="sessionMessage" type="warning" />
|
|
1308
|
+
</template>
|
|
1309
|
+
|
|
1310
|
+
<script>
|
|
1289
1311
|
import { router } from '@inertiajs/vue3'
|
|
1312
|
+
import { ActionPill, downloadFile, NotificationMessage } from '@boobooking/dashboard-ui-components'
|
|
1290
1313
|
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
this.exportLoading = true;
|
|
1314
|
+
export default {
|
|
1315
|
+
components: { ActionPill, NotificationMessage },
|
|
1294
1316
|
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1317
|
+
props: {
|
|
1318
|
+
exportUrl: { type: String, required: true },
|
|
1319
|
+
},
|
|
1320
|
+
|
|
1321
|
+
data() {
|
|
1322
|
+
return {
|
|
1323
|
+
exportLoading: false,
|
|
1324
|
+
exportFailure: "",
|
|
1325
|
+
sessionMessage: "",
|
|
1326
|
+
};
|
|
1327
|
+
},
|
|
1328
|
+
|
|
1329
|
+
methods: {
|
|
1330
|
+
exportOrders() {
|
|
1331
|
+
this.exportFailure = "";
|
|
1332
|
+
this.sessionMessage = "";
|
|
1333
|
+
this.exportLoading = true;
|
|
1334
|
+
|
|
1335
|
+
downloadFile(this.exportUrl)
|
|
1336
|
+
.catch((error) => {
|
|
1337
|
+
if (error.sessionExpired) {
|
|
1338
|
+
this.sessionMessage = "Сессия закончилась. Обновите страницу.";
|
|
1339
|
+
return;
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1342
|
+
if (error.redirectUrl) {
|
|
1343
|
+
router.visit(error.redirectUrl);
|
|
1344
|
+
return;
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
this.exportFailure = "Попробуйте ещё раз";
|
|
1348
|
+
})
|
|
1349
|
+
.finally(() => {
|
|
1350
|
+
this.exportLoading = false;
|
|
1351
|
+
});
|
|
1352
|
+
},
|
|
1353
|
+
},
|
|
1354
|
+
};
|
|
1355
|
+
</script>
|
|
1308
1356
|
```
|
|
1309
1357
|
|
|
1310
1358
|
### ConfirmationModal
|
|
@@ -2162,6 +2210,21 @@ Tailwind, `@tailwindcss/forms` и типографикой, как у потре
|
|
|
2162
2210
|
Правила номера телефона в `RussianMobileFilter` — российские; язык текстов
|
|
2163
2211
|
задаётся, см. «Языки».
|
|
2164
2212
|
|
|
2213
|
+
## Обновление с 0.25
|
|
2214
|
+
|
|
2215
|
+
`downloadFile` шлёт заголовок `X-Requested-With: XMLHttpRequest`, поэтому
|
|
2216
|
+
Laravel отвечает на истёкшую сессию `401` (отказ с `sessionExpired: true`), а
|
|
2217
|
+
не перенаправлением на вход, а на невалидные параметры выгрузки — `422`, а не
|
|
2218
|
+
перенаправлением назад. Страницам, которые переходили по `redirectUrl`, нужна
|
|
2219
|
+
ветка `sessionExpired` (пример — в разделе `downloadFile`); невалидные
|
|
2220
|
+
параметры попадают в общую ветку отказа.
|
|
2221
|
+
|
|
2222
|
+
У `RussianMobileFilter` и `Search` высоту и рамку теперь рисует сам компонент:
|
|
2223
|
+
72px и серая рамка `gray-200`, как у остальных фильтров. Классы
|
|
2224
|
+
`h-18 border border-gray-200` на `RussianMobileFilter` больше не нужны.
|
|
2225
|
+
Странице, которой у `Search` нужна другая рамка или высота, достаточно задать
|
|
2226
|
+
их своими классами.
|
|
2227
|
+
|
|
2165
2228
|
## Обновление с 0.23
|
|
2166
2229
|
|
|
2167
2230
|
**Несовместимое изменение:** у каждого цвета теперь два вида, яркий `-solid`
|
package/dist/index.js
CHANGED
|
@@ -290,14 +290,24 @@ function we(e) {
|
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
292
|
async function Te(e) {
|
|
293
|
-
let t = await fetch(e, {
|
|
293
|
+
let t = await fetch(e, {
|
|
294
|
+
credentials: "same-origin",
|
|
295
|
+
headers: { "X-Requested-With": "XMLHttpRequest" }
|
|
296
|
+
});
|
|
294
297
|
if (t.redirected) throw Object.assign(/* @__PURE__ */ Error(`downloadFile: сервер перенаправил запрос ${e}`), {
|
|
295
298
|
redirectUrl: t.url,
|
|
296
|
-
status: null
|
|
299
|
+
status: null,
|
|
300
|
+
sessionExpired: !1
|
|
301
|
+
});
|
|
302
|
+
if (t.status === 401) throw Object.assign(/* @__PURE__ */ Error(`downloadFile: сессия истекла, ответ 401 на ${e}`), {
|
|
303
|
+
redirectUrl: null,
|
|
304
|
+
status: 401,
|
|
305
|
+
sessionExpired: !0
|
|
297
306
|
});
|
|
298
307
|
if (!t.ok) throw Object.assign(/* @__PURE__ */ Error(`downloadFile: ответ ${t.status} на ${e}`), {
|
|
299
308
|
redirectUrl: null,
|
|
300
|
-
status: t.status
|
|
309
|
+
status: t.status,
|
|
310
|
+
sessionExpired: !1
|
|
301
311
|
});
|
|
302
312
|
let n = Ce(t.headers.get("Content-Disposition")) ?? we(e) ?? "download", r = URL.createObjectURL(await t.blob()), i = document.createElement("a");
|
|
303
313
|
i.href = r, i.download = n, i.style.display = "none", document.body.appendChild(i), i.click(), i.remove(), setTimeout(() => URL.revokeObjectURL(r), Se);
|
|
@@ -652,7 +662,7 @@ var Je = 400, Ye = 3, Xe = {
|
|
|
652
662
|
clearTimeout(this.debounceTimer), this.digits !== this.lastCommitted && (this.lastCommitted = this.digits, this.$emit("changed"));
|
|
653
663
|
}
|
|
654
664
|
}
|
|
655
|
-
}, Ze = { class: "bb-dashboard-ui bb:flex bb:flex-none" }, Qe = { class: "bb:flex bb:w-full bb:flex-col bb:border bb:border-white bb:bg-white" }, $e = { class: "bb:relative bb:flex bb:h-full bb:w-full" }, et = { class: "bb:flex bb:w-full bb:h-full bb:items-center bb:justify-center" };
|
|
665
|
+
}, Ze = { class: "bb-dashboard-ui bb:flex bb:flex-none bb:h-18 bb:border bb:border-gray-200" }, Qe = { class: "bb:flex bb:w-full bb:flex-col bb:border bb:border-white bb:bg-white" }, $e = { class: "bb:relative bb:flex bb:h-full bb:w-full" }, et = { class: "bb:flex bb:w-full bb:h-full bb:items-center bb:justify-center" };
|
|
656
666
|
function tt(e, t, n, r, o, s) {
|
|
657
667
|
let l = g("element-header"), u = g("cross-button");
|
|
658
668
|
return p(), i("div", Ze, [a("div", Qe, [c(l, {
|
|
@@ -726,7 +736,7 @@ var nt = /*#__PURE__*/ j(Xe, [["render", tt]]), rt = {
|
|
|
726
736
|
this.$emit("update:modelValue", this.search), this.$emit("changed");
|
|
727
737
|
}
|
|
728
738
|
}
|
|
729
|
-
}, it = { class: "bb-dashboard-ui bb:flex bb:flex-none" }, at = { class: "bb:flex bb:w-full bb:flex-col bb:border bb:border-white bb:bg-white" }, ot = { class: "bb:relative bb:flex bb:h-full bb:w-full" }, st = { class: "bb:flex bb:w-full bb:h-full bb:items-center bb:justify-center" };
|
|
739
|
+
}, it = { class: "bb-dashboard-ui bb:flex bb:flex-none bb:h-18 bb:border bb:border-gray-200" }, at = { class: "bb:flex bb:w-full bb:flex-col bb:border bb:border-white bb:bg-white" }, ot = { class: "bb:relative bb:flex bb:h-full bb:w-full" }, st = { class: "bb:flex bb:w-full bb:h-full bb:items-center bb:justify-center" };
|
|
730
740
|
function ct(e, t, n, r, o, s) {
|
|
731
741
|
let l = g("element-header"), u = g("cross-button");
|
|
732
742
|
return p(), i("div", it, [a("div", at, [c(l, {
|