@useinsider/guido 3.18.2-beta.3718ee1 → 3.18.2-beta.3d66140

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.
@@ -1,7 +1,7 @@
1
1
  import { getCsrfToken as O } from "../utils/genericUtil.js";
2
- import { ref as m, computed as T } from "vue";
3
- const X = (b = {}) => {
4
- const p = m(!1), a = m(null), u = m(null), g = T(() => p.value), y = T(() => a.value !== null), v = {
2
+ import { ref as m, computed as w } from "vue";
3
+ const k = (g = {}) => {
4
+ const h = m(!1), n = m(null), u = m(null), b = w(() => h.value), y = w(() => n.value !== null), v = {
5
5
  baseURL: "",
6
6
  timeout: 1e4,
7
7
  retry: 0,
@@ -10,79 +10,90 @@ const X = (b = {}) => {
10
10
  "Content-Type": "application/json",
11
11
  "X-CSRF-TOKEN": O(),
12
12
  Accept: "application/json",
13
+ // The panel backend only answers 401/419 to ajax requests; without this a guest
14
+ // fetch gets a 302 to the login page and never sees an auth status.
13
15
  "X-Requested-With": "XMLHttpRequest"
14
16
  },
15
- ...b
16
- }, w = (e, s) => {
17
+ ...g
18
+ }, x = (e, r) => {
17
19
  if (e.startsWith("http://") || e.startsWith("https://"))
18
20
  return e;
19
- const t = s || v.baseURL || "";
21
+ const t = r || v.baseURL || "";
20
22
  return t.endsWith("/") && e.startsWith("/") ? `${t}${e.slice(1)}` : t.endsWith("/") || e.startsWith("/") ? `${t}${e}` : `${t}/${e}`;
21
- }, P = (e) => new Promise((s, t) => {
23
+ }, P = (e) => new Promise((r, t) => {
22
24
  setTimeout(() => {
23
25
  t(new Error("Request timeout"));
24
26
  }, e);
25
- }), x = (e) => new Promise((s) => {
26
- setTimeout(s, e);
27
- }), i = async (e, s, t, L = {}) => {
28
- a.value = null, p.value = !0, u.value = new AbortController();
29
- const n = { ...v, ...L }, D = w(s, n.baseURL), c = {
27
+ }), C = (e) => new Promise((r) => {
28
+ setTimeout(r, e);
29
+ }), i = async (e, r, t, W = {}) => {
30
+ n.value = null, h.value = !0, u.value = new AbortController();
31
+ const a = { ...v, ...W }, E = x(r, a.baseURL), c = {
30
32
  method: e,
31
- headers: { ...n.headers },
33
+ headers: { ...a.headers },
32
34
  signal: u.value.signal,
33
- ...n
35
+ ...a
34
36
  };
35
37
  t && ["POST", "PUT", "PATCH"].includes(e) && (t instanceof FormData ? (delete c.headers["Content-Type"], c.body = t) : c.body = JSON.stringify(t));
36
- const E = async (h = 0) => {
38
+ const T = async (p = 0) => {
39
+ if (window.isSessionExpired)
40
+ throw n.value = { message: "Session expired" }, new Error("Session expired");
37
41
  try {
38
- const o = [fetch(D, c)];
39
- n.timeout && o.push(P(n.timeout));
40
- const r = await Promise.race(o);
41
- if (!r.ok) {
42
- const H = `HTTP Error: ${r.status} ${r.statusText}`, d = new Error(H);
43
- throw d.status = r.status, d.statusText = r.statusText, d.response = r, d;
42
+ const o = [fetch(E, c)];
43
+ a.timeout && o.push(P(a.timeout));
44
+ const s = await Promise.race(o);
45
+ if (!s.ok) {
46
+ const D = `HTTP Error: ${s.status} ${s.statusText}`, f = new Error(D);
47
+ throw f.status = s.status, f.statusText = s.statusText, f.response = s, [401, 403, 419].includes(s.status) && Promise.resolve().then(() => s.clone().text().catch(() => "")).then((H) => window.dispatchEvent(new CustomEvent("insider:http-auth-error", {
48
+ detail: {
49
+ status: s.status,
50
+ body: H,
51
+ url: new URL(E, window.location.href).href
52
+ }
53
+ }))).catch(() => {
54
+ }), f;
44
55
  }
45
- let f;
46
- const l = r.headers.get("content-type");
47
- return l != null && l.includes("application/json") ? f = await r.json() : l != null && l.includes("text/") ? f = await r.text() : f = await r.blob(), {
48
- data: f,
49
- status: r.status,
50
- statusText: r.statusText,
51
- headers: r.headers
56
+ let d;
57
+ const l = s.headers.get("content-type");
58
+ return l != null && l.includes("application/json") ? d = await s.json() : l != null && l.includes("text/") ? d = await s.text() : d = await s.blob(), {
59
+ data: d,
60
+ status: s.status,
61
+ statusText: s.statusText,
62
+ headers: s.headers
52
63
  };
53
64
  } catch (o) {
54
- const r = o instanceof Error && o.name === "AbortError";
55
- if (h < (n.retry || 0) && !r)
56
- return await x(n.retryDelay || 1e3), E(h + 1);
57
- throw o instanceof Error ? o.name === "AbortError" ? a.value = { message: "Request was cancelled" } : a.value = { message: o.message } : a.value = o, o;
65
+ const s = o instanceof Error && o.name === "AbortError";
66
+ if (p < (a.retry || 0) && !s)
67
+ return await C(a.retryDelay || 1e3), T(p + 1);
68
+ throw o instanceof Error ? o.name === "AbortError" ? n.value = { message: "Request was cancelled" } : n.value = { message: o.message } : n.value = o, o;
58
69
  }
59
70
  };
60
71
  try {
61
- return await E();
72
+ return await T();
62
73
  } finally {
63
- p.value = !1, u.value = null;
74
+ h.value = !1, u.value = null;
64
75
  }
65
- }, C = (e, s) => i("GET", e, void 0, s), R = (e, s, t) => i("POST", e, s, t), $ = (e, s, t) => i("PUT", e, s, t), q = (e, s, t) => i("PATCH", e, s, t), A = (e, s) => i("DELETE", e, void 0, s), U = (e) => {
76
+ }, R = (e, r) => i("GET", e, void 0, r), U = (e, r, t) => i("POST", e, r, t), $ = (e, r, t) => i("PUT", e, r, t), q = (e, r, t) => i("PATCH", e, r, t), A = (e, r) => i("DELETE", e, void 0, r), L = (e) => {
66
77
  u.value && u.value.abort(e);
67
- }, W = () => {
68
- a.value = null;
78
+ }, S = () => {
79
+ n.value = null;
69
80
  };
70
81
  return {
71
82
  // State
72
- loading: g,
73
- error: T(() => a.value),
83
+ loading: b,
84
+ error: w(() => n.value),
74
85
  hasError: y,
75
86
  // Methods
76
87
  request: i,
77
- get: C,
78
- post: R,
88
+ get: R,
89
+ post: U,
79
90
  put: $,
80
91
  patch: q,
81
92
  delete: A,
82
- cancel: U,
83
- clearError: W
93
+ cancel: L,
94
+ clearError: S
84
95
  };
85
96
  };
86
97
  export {
87
- X as useHttp
98
+ k as useHttp
88
99
  };
@@ -67,7 +67,7 @@ class se extends ut {
67
67
  (d, c) => `
68
68
  <div data-reorder-icon-key="${P}${c}" style="display: none;">
69
69
  <${_.BUTTON}
70
- class="guido-drag-handle-btn flat-inline flat-white"
70
+ class="drag-handle-btn flat-inline flat-white"
71
71
  ${O.BUTTON.name}="${P}${c}"
72
72
  >
73
73
  <${_.ICON}
@@ -328,7 +328,7 @@ class se extends ut {
328
328
  _createBuiltInItemHtml(t, e) {
329
329
  return `
330
330
  <div class="orderable-item" draggable="true" data-key="${t.key}">
331
- <span class="guido-drag-handle" data-reorder-icon-slot="${e}"></span>
331
+ <span class="drag-handle" data-reorder-icon-slot="${e}"></span>
332
332
  <span class="item-label">${this.api.translate(t.label)}</span>
333
333
  <div class="item-action" data-action-for="${t.key}"></div>
334
334
  </div>
@@ -353,7 +353,7 @@ class se extends ut {
353
353
  <div class="orderable-item price-group-item" draggable="true"
354
354
  data-key="${C}" data-group="prices">
355
355
  <div class="price-group-header">
356
- <span class="guido-drag-handle" data-reorder-icon-slot="${t}"></span>
356
+ <span class="drag-handle" data-reorder-icon-slot="${t}"></span>
357
357
  <span class="item-label">${this.api.translate("Product Prices")}</span>
358
358
  <div class="item-action" data-action-for="${C}"></div>
359
359
  </div>
@@ -365,7 +365,7 @@ class se extends ut {
365
365
  return `
366
366
  <div class="orderable-item" draggable="true"
367
367
  data-key="${t}" data-custom-index="${e}">
368
- <span class="guido-drag-handle" data-reorder-icon-slot="${r}"></span>
368
+ <span class="drag-handle" data-reorder-icon-slot="${r}"></span>
369
369
  <div class="custom-attr-select-wrap"
370
370
  data-custom-select-slot="${e}"></div>
371
371
  <div class="item-action"
@@ -134,10 +134,7 @@ ue-orderable.orderable-disabled .droppable-icon {
134
134
  border-top: 2px solid var(--guido-color-primary-500, #0A2ECC);
135
135
  }
136
136
 
137
- /* Namespaced: Stripo ships a global \`.drag-handle { position: absolute }\` for its
138
- floating popups, which knocked this handle out of flow (SD-151734). */
139
- .guido-drag-handle {
140
- cursor: move;
137
+ .drag-handle {
141
138
  user-select: none;
142
139
  display: flex;
143
140
  align-items: center;
@@ -147,13 +144,13 @@ ue-orderable.orderable-disabled .droppable-icon {
147
144
  flex-shrink: 0;
148
145
  }
149
146
 
150
- .guido-drag-handle .guido-drag-handle-btn .button {
147
+ .drag-handle .drag-handle-btn .button {
151
148
  padding: 0;
152
149
  min-width: auto;
153
150
  cursor: move;
154
151
  }
155
152
 
156
- .guido-drag-handle .guido-drag-handle-btn .button .icon-button {
153
+ .drag-handle .drag-handle-btn .button .icon-button {
157
154
  color: var(--guido-color-gray-600);
158
155
  }
159
156
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.18.2-beta.3718ee1",
3
+ "version": "3.18.2-beta.3d66140",
4
4
  "description": "Guido is a Vue + TypeScript wrapper for Email Plugin. Easily embed the email editor in your Vue applications.",
5
5
  "main": "./dist/guido.umd.cjs",
6
6
  "module": "./dist/library.js",
@@ -77,7 +77,7 @@
77
77
  "@typescript-eslint/parser": "7.18.0",
78
78
  "@useinsider/eslint-config": "1.5.3",
79
79
  "@vitejs/plugin-vue2": "2.3.1",
80
- "@vitest/coverage-v8": "2.1.9",
80
+ "@vitest/coverage-v8": "4.1.11",
81
81
  "eslint": "8.57.1",
82
82
  "eslint-config-airbnb-base": "15.0.0",
83
83
  "eslint-config-airbnb-typescript": "18.0.0",
@@ -90,17 +90,17 @@
90
90
  "happy-dom": "15.11.7",
91
91
  "husky": "9.1.7",
92
92
  "msw": "2.10.3",
93
- "nyc": "17.1.0",
93
+ "nyc": "18.0.0",
94
94
  "sass": "1.69.7",
95
95
  "typescript": "5.5.4",
96
96
  "typescript-eslint": "8.26.0",
97
97
  "vite-plugin-dts": "4.5.4",
98
98
  "vite-plugin-istanbul": "7.0.0",
99
- "vitest": "2.1.9",
99
+ "vitest": "4.1.11",
100
100
  "vue-tsc": "2.2.10"
101
101
  },
102
102
  "overrides": {
103
- "axios": "1.8.2",
103
+ "axios": "1.20.0",
104
104
  "flatted": "3.4.2",
105
105
  "micromatch": "4.0.8",
106
106
  "path-to-regexp": "6.3.0"