@dismissible/react-client 0.0.1-canary.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/dist/dismissible-client.es.js +771 -0
- package/dist/dismissible-client.umd.js +22 -0
- package/dist/mockServiceWorker.js +344 -0
- package/dist/style.css +1 -0
- package/package.json +80 -0
|
@@ -0,0 +1,771 @@
|
|
|
1
|
+
import ce, { useState as Q, useCallback as Z, useEffect as ue } from "react";
|
|
2
|
+
var K = { exports: {} }, D = {};
|
|
3
|
+
/**
|
|
4
|
+
* @license React
|
|
5
|
+
* react-jsx-runtime.production.js
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the MIT license found in the
|
|
10
|
+
* LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/
|
|
12
|
+
var ee;
|
|
13
|
+
function fe() {
|
|
14
|
+
if (ee) return D;
|
|
15
|
+
ee = 1;
|
|
16
|
+
var r = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
|
|
17
|
+
function t(i, o, s) {
|
|
18
|
+
var u = null;
|
|
19
|
+
if (s !== void 0 && (u = "" + s), o.key !== void 0 && (u = "" + o.key), "key" in o) {
|
|
20
|
+
s = {};
|
|
21
|
+
for (var f in o)
|
|
22
|
+
f !== "key" && (s[f] = o[f]);
|
|
23
|
+
} else s = o;
|
|
24
|
+
return o = s.ref, {
|
|
25
|
+
$$typeof: r,
|
|
26
|
+
type: i,
|
|
27
|
+
key: u,
|
|
28
|
+
ref: o !== void 0 ? o : null,
|
|
29
|
+
props: s
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return D.Fragment = n, D.jsx = t, D.jsxs = t, D;
|
|
33
|
+
}
|
|
34
|
+
var F = {};
|
|
35
|
+
/**
|
|
36
|
+
* @license React
|
|
37
|
+
* react-jsx-runtime.development.js
|
|
38
|
+
*
|
|
39
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
40
|
+
*
|
|
41
|
+
* This source code is licensed under the MIT license found in the
|
|
42
|
+
* LICENSE file in the root directory of this source tree.
|
|
43
|
+
*/
|
|
44
|
+
var re;
|
|
45
|
+
function de() {
|
|
46
|
+
return re || (re = 1, process.env.NODE_ENV !== "production" && function() {
|
|
47
|
+
function r(e) {
|
|
48
|
+
if (e == null) return null;
|
|
49
|
+
if (typeof e == "function")
|
|
50
|
+
return e.$$typeof === J ? null : e.displayName || e.name || null;
|
|
51
|
+
if (typeof e == "string") return e;
|
|
52
|
+
switch (e) {
|
|
53
|
+
case Y:
|
|
54
|
+
return "Fragment";
|
|
55
|
+
case S:
|
|
56
|
+
return "Profiler";
|
|
57
|
+
case W:
|
|
58
|
+
return "StrictMode";
|
|
59
|
+
case H:
|
|
60
|
+
return "Suspense";
|
|
61
|
+
case $:
|
|
62
|
+
return "SuspenseList";
|
|
63
|
+
case q:
|
|
64
|
+
return "Activity";
|
|
65
|
+
}
|
|
66
|
+
if (typeof e == "object")
|
|
67
|
+
switch (typeof e.tag == "number" && console.error(
|
|
68
|
+
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
69
|
+
), e.$$typeof) {
|
|
70
|
+
case L:
|
|
71
|
+
return "Portal";
|
|
72
|
+
case O:
|
|
73
|
+
return (e.displayName || "Context") + ".Provider";
|
|
74
|
+
case I:
|
|
75
|
+
return (e._context.displayName || "Context") + ".Consumer";
|
|
76
|
+
case M:
|
|
77
|
+
var l = e.render;
|
|
78
|
+
return e = e.displayName, e || (e = l.displayName || l.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
79
|
+
case U:
|
|
80
|
+
return l = e.displayName || null, l !== null ? l : r(e.type) || "Memo";
|
|
81
|
+
case k:
|
|
82
|
+
l = e._payload, e = e._init;
|
|
83
|
+
try {
|
|
84
|
+
return r(e(l));
|
|
85
|
+
} catch {
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
function n(e) {
|
|
91
|
+
return "" + e;
|
|
92
|
+
}
|
|
93
|
+
function t(e) {
|
|
94
|
+
try {
|
|
95
|
+
n(e);
|
|
96
|
+
var l = !1;
|
|
97
|
+
} catch {
|
|
98
|
+
l = !0;
|
|
99
|
+
}
|
|
100
|
+
if (l) {
|
|
101
|
+
l = console;
|
|
102
|
+
var d = l.error, h = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
103
|
+
return d.call(
|
|
104
|
+
l,
|
|
105
|
+
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
106
|
+
h
|
|
107
|
+
), n(e);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function i(e) {
|
|
111
|
+
if (e === Y) return "<>";
|
|
112
|
+
if (typeof e == "object" && e !== null && e.$$typeof === k)
|
|
113
|
+
return "<...>";
|
|
114
|
+
try {
|
|
115
|
+
var l = r(e);
|
|
116
|
+
return l ? "<" + l + ">" : "<...>";
|
|
117
|
+
} catch {
|
|
118
|
+
return "<...>";
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function o() {
|
|
122
|
+
var e = z.A;
|
|
123
|
+
return e === null ? null : e.getOwner();
|
|
124
|
+
}
|
|
125
|
+
function s() {
|
|
126
|
+
return Error("react-stack-top-frame");
|
|
127
|
+
}
|
|
128
|
+
function u(e) {
|
|
129
|
+
if (_.call(e, "key")) {
|
|
130
|
+
var l = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
131
|
+
if (l && l.isReactWarning) return !1;
|
|
132
|
+
}
|
|
133
|
+
return e.key !== void 0;
|
|
134
|
+
}
|
|
135
|
+
function f(e, l) {
|
|
136
|
+
function d() {
|
|
137
|
+
m || (m = !0, console.error(
|
|
138
|
+
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
139
|
+
l
|
|
140
|
+
));
|
|
141
|
+
}
|
|
142
|
+
d.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
143
|
+
get: d,
|
|
144
|
+
configurable: !0
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
function j() {
|
|
148
|
+
var e = r(this.type);
|
|
149
|
+
return C[e] || (C[e] = !0, console.error(
|
|
150
|
+
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
151
|
+
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
152
|
+
}
|
|
153
|
+
function p(e, l, d, h, x, T, V, B) {
|
|
154
|
+
return d = T.ref, e = {
|
|
155
|
+
$$typeof: w,
|
|
156
|
+
type: e,
|
|
157
|
+
key: l,
|
|
158
|
+
props: T,
|
|
159
|
+
_owner: x
|
|
160
|
+
}, (d !== void 0 ? d : null) !== null ? Object.defineProperty(e, "ref", {
|
|
161
|
+
enumerable: !1,
|
|
162
|
+
get: j
|
|
163
|
+
}) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
164
|
+
configurable: !1,
|
|
165
|
+
enumerable: !1,
|
|
166
|
+
writable: !0,
|
|
167
|
+
value: 0
|
|
168
|
+
}), Object.defineProperty(e, "_debugInfo", {
|
|
169
|
+
configurable: !1,
|
|
170
|
+
enumerable: !1,
|
|
171
|
+
writable: !0,
|
|
172
|
+
value: null
|
|
173
|
+
}), Object.defineProperty(e, "_debugStack", {
|
|
174
|
+
configurable: !1,
|
|
175
|
+
enumerable: !1,
|
|
176
|
+
writable: !0,
|
|
177
|
+
value: V
|
|
178
|
+
}), Object.defineProperty(e, "_debugTask", {
|
|
179
|
+
configurable: !1,
|
|
180
|
+
enumerable: !1,
|
|
181
|
+
writable: !0,
|
|
182
|
+
value: B
|
|
183
|
+
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
184
|
+
}
|
|
185
|
+
function E(e, l, d, h, x, T, V, B) {
|
|
186
|
+
var R = l.children;
|
|
187
|
+
if (R !== void 0)
|
|
188
|
+
if (h)
|
|
189
|
+
if (P(R)) {
|
|
190
|
+
for (h = 0; h < R.length; h++)
|
|
191
|
+
a(R[h]);
|
|
192
|
+
Object.freeze && Object.freeze(R);
|
|
193
|
+
} else
|
|
194
|
+
console.error(
|
|
195
|
+
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
196
|
+
);
|
|
197
|
+
else a(R);
|
|
198
|
+
if (_.call(l, "key")) {
|
|
199
|
+
R = r(e);
|
|
200
|
+
var N = Object.keys(l).filter(function(le) {
|
|
201
|
+
return le !== "key";
|
|
202
|
+
});
|
|
203
|
+
h = 0 < N.length ? "{key: someKey, " + N.join(": ..., ") + ": ...}" : "{key: someKey}", g[R + h] || (N = 0 < N.length ? "{" + N.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
204
|
+
`A props object containing a "key" prop is being spread into JSX:
|
|
205
|
+
let props = %s;
|
|
206
|
+
<%s {...props} />
|
|
207
|
+
React keys must be passed directly to JSX without using spread:
|
|
208
|
+
let props = %s;
|
|
209
|
+
<%s key={someKey} {...props} />`,
|
|
210
|
+
h,
|
|
211
|
+
R,
|
|
212
|
+
N,
|
|
213
|
+
R
|
|
214
|
+
), g[R + h] = !0);
|
|
215
|
+
}
|
|
216
|
+
if (R = null, d !== void 0 && (t(d), R = "" + d), u(l) && (t(l.key), R = "" + l.key), "key" in l) {
|
|
217
|
+
d = {};
|
|
218
|
+
for (var X in l)
|
|
219
|
+
X !== "key" && (d[X] = l[X]);
|
|
220
|
+
} else d = l;
|
|
221
|
+
return R && f(
|
|
222
|
+
d,
|
|
223
|
+
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
224
|
+
), p(
|
|
225
|
+
e,
|
|
226
|
+
R,
|
|
227
|
+
T,
|
|
228
|
+
x,
|
|
229
|
+
o(),
|
|
230
|
+
d,
|
|
231
|
+
V,
|
|
232
|
+
B
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
function a(e) {
|
|
236
|
+
typeof e == "object" && e !== null && e.$$typeof === w && e._store && (e._store.validated = 1);
|
|
237
|
+
}
|
|
238
|
+
var c = ce, w = Symbol.for("react.transitional.element"), L = Symbol.for("react.portal"), Y = Symbol.for("react.fragment"), W = Symbol.for("react.strict_mode"), S = Symbol.for("react.profiler"), I = Symbol.for("react.consumer"), O = Symbol.for("react.context"), M = Symbol.for("react.forward_ref"), H = Symbol.for("react.suspense"), $ = Symbol.for("react.suspense_list"), U = Symbol.for("react.memo"), k = Symbol.for("react.lazy"), q = Symbol.for("react.activity"), J = Symbol.for("react.client.reference"), z = c.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, _ = Object.prototype.hasOwnProperty, P = Array.isArray, v = console.createTask ? console.createTask : function() {
|
|
239
|
+
return null;
|
|
240
|
+
};
|
|
241
|
+
c = {
|
|
242
|
+
"react-stack-bottom-frame": function(e) {
|
|
243
|
+
return e();
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
var m, C = {}, y = c["react-stack-bottom-frame"].bind(
|
|
247
|
+
c,
|
|
248
|
+
s
|
|
249
|
+
)(), b = v(i(s)), g = {};
|
|
250
|
+
F.Fragment = Y, F.jsx = function(e, l, d, h, x) {
|
|
251
|
+
var T = 1e4 > z.recentlyCreatedOwnerStacks++;
|
|
252
|
+
return E(
|
|
253
|
+
e,
|
|
254
|
+
l,
|
|
255
|
+
d,
|
|
256
|
+
!1,
|
|
257
|
+
h,
|
|
258
|
+
x,
|
|
259
|
+
T ? Error("react-stack-top-frame") : y,
|
|
260
|
+
T ? v(i(e)) : b
|
|
261
|
+
);
|
|
262
|
+
}, F.jsxs = function(e, l, d, h, x) {
|
|
263
|
+
var T = 1e4 > z.recentlyCreatedOwnerStacks++;
|
|
264
|
+
return E(
|
|
265
|
+
e,
|
|
266
|
+
l,
|
|
267
|
+
d,
|
|
268
|
+
!0,
|
|
269
|
+
h,
|
|
270
|
+
x,
|
|
271
|
+
T ? Error("react-stack-top-frame") : y,
|
|
272
|
+
T ? v(i(e)) : b
|
|
273
|
+
);
|
|
274
|
+
};
|
|
275
|
+
}()), F;
|
|
276
|
+
}
|
|
277
|
+
process.env.NODE_ENV === "production" ? K.exports = fe() : K.exports = de();
|
|
278
|
+
var A = K.exports;
|
|
279
|
+
const me = /\{[^{}]+\}/g, be = () => {
|
|
280
|
+
var r, n;
|
|
281
|
+
return typeof process == "object" && Number.parseInt((n = (r = process == null ? void 0 : process.versions) == null ? void 0 : r.node) == null ? void 0 : n.substring(0, 2)) >= 18 && process.versions.undici;
|
|
282
|
+
};
|
|
283
|
+
function pe() {
|
|
284
|
+
return Math.random().toString(36).slice(2, 11);
|
|
285
|
+
}
|
|
286
|
+
function ye(r) {
|
|
287
|
+
let {
|
|
288
|
+
baseUrl: n = "",
|
|
289
|
+
Request: t = globalThis.Request,
|
|
290
|
+
fetch: i = globalThis.fetch,
|
|
291
|
+
querySerializer: o,
|
|
292
|
+
bodySerializer: s,
|
|
293
|
+
headers: u,
|
|
294
|
+
requestInitExt: f = void 0,
|
|
295
|
+
...j
|
|
296
|
+
} = { ...r };
|
|
297
|
+
f = be() ? f : void 0, n = oe(n);
|
|
298
|
+
const p = [];
|
|
299
|
+
async function E(a, c) {
|
|
300
|
+
const {
|
|
301
|
+
baseUrl: w,
|
|
302
|
+
fetch: L = i,
|
|
303
|
+
Request: Y = t,
|
|
304
|
+
headers: W,
|
|
305
|
+
params: S = {},
|
|
306
|
+
parseAs: I = "json",
|
|
307
|
+
querySerializer: O,
|
|
308
|
+
bodySerializer: M = s ?? he,
|
|
309
|
+
body: H,
|
|
310
|
+
...$
|
|
311
|
+
} = c || {};
|
|
312
|
+
let U = n;
|
|
313
|
+
w && (U = oe(w) ?? n);
|
|
314
|
+
let k = typeof o == "function" ? o : te(o);
|
|
315
|
+
O && (k = typeof O == "function" ? O : te({
|
|
316
|
+
...typeof o == "object" ? o : {},
|
|
317
|
+
...O
|
|
318
|
+
}));
|
|
319
|
+
const q = H === void 0 ? void 0 : M(
|
|
320
|
+
H,
|
|
321
|
+
// Note: we declare mergeHeaders() both here and below because it’s a bit of a chicken-or-egg situation:
|
|
322
|
+
// bodySerializer() needs all headers so we aren’t dropping ones set by the user, however,
|
|
323
|
+
// the result of this ALSO sets the lowest-priority content-type header. So we re-merge below,
|
|
324
|
+
// setting the content-type at the very beginning to be overwritten.
|
|
325
|
+
// Lastly, based on the way headers work, it’s not a simple “present-or-not” check becauase null intentionally un-sets headers.
|
|
326
|
+
ne(u, W, S.header)
|
|
327
|
+
), J = ne(
|
|
328
|
+
// with no body, we should not to set Content-Type
|
|
329
|
+
q === void 0 || // if serialized body is FormData; browser will correctly set Content-Type & boundary expression
|
|
330
|
+
q instanceof FormData ? {} : {
|
|
331
|
+
"Content-Type": "application/json"
|
|
332
|
+
},
|
|
333
|
+
u,
|
|
334
|
+
W,
|
|
335
|
+
S.header
|
|
336
|
+
), z = {
|
|
337
|
+
redirect: "follow",
|
|
338
|
+
...j,
|
|
339
|
+
...$,
|
|
340
|
+
body: q,
|
|
341
|
+
headers: J
|
|
342
|
+
};
|
|
343
|
+
let _, P, v = new t(
|
|
344
|
+
Re(a, { baseUrl: U, params: S, querySerializer: k }),
|
|
345
|
+
z
|
|
346
|
+
), m;
|
|
347
|
+
for (const y in $)
|
|
348
|
+
y in v || (v[y] = $[y]);
|
|
349
|
+
if (p.length) {
|
|
350
|
+
_ = pe(), P = Object.freeze({
|
|
351
|
+
baseUrl: U,
|
|
352
|
+
fetch: L,
|
|
353
|
+
parseAs: I,
|
|
354
|
+
querySerializer: k,
|
|
355
|
+
bodySerializer: M
|
|
356
|
+
});
|
|
357
|
+
for (const y of p)
|
|
358
|
+
if (y && typeof y == "object" && typeof y.onRequest == "function") {
|
|
359
|
+
const b = await y.onRequest({
|
|
360
|
+
request: v,
|
|
361
|
+
schemaPath: a,
|
|
362
|
+
params: S,
|
|
363
|
+
options: P,
|
|
364
|
+
id: _
|
|
365
|
+
});
|
|
366
|
+
if (b)
|
|
367
|
+
if (b instanceof t)
|
|
368
|
+
v = b;
|
|
369
|
+
else if (b instanceof Response) {
|
|
370
|
+
m = b;
|
|
371
|
+
break;
|
|
372
|
+
} else
|
|
373
|
+
throw new Error("onRequest: must return new Request() or Response() when modifying the request");
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
if (!m) {
|
|
377
|
+
try {
|
|
378
|
+
m = await L(v, f);
|
|
379
|
+
} catch (y) {
|
|
380
|
+
let b = y;
|
|
381
|
+
if (p.length)
|
|
382
|
+
for (let g = p.length - 1; g >= 0; g--) {
|
|
383
|
+
const e = p[g];
|
|
384
|
+
if (e && typeof e == "object" && typeof e.onError == "function") {
|
|
385
|
+
const l = await e.onError({
|
|
386
|
+
request: v,
|
|
387
|
+
error: b,
|
|
388
|
+
schemaPath: a,
|
|
389
|
+
params: S,
|
|
390
|
+
options: P,
|
|
391
|
+
id: _
|
|
392
|
+
});
|
|
393
|
+
if (l) {
|
|
394
|
+
if (l instanceof Response) {
|
|
395
|
+
b = void 0, m = l;
|
|
396
|
+
break;
|
|
397
|
+
}
|
|
398
|
+
if (l instanceof Error) {
|
|
399
|
+
b = l;
|
|
400
|
+
continue;
|
|
401
|
+
}
|
|
402
|
+
throw new Error("onError: must return new Response() or instance of Error");
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
if (b)
|
|
407
|
+
throw b;
|
|
408
|
+
}
|
|
409
|
+
if (p.length)
|
|
410
|
+
for (let y = p.length - 1; y >= 0; y--) {
|
|
411
|
+
const b = p[y];
|
|
412
|
+
if (b && typeof b == "object" && typeof b.onResponse == "function") {
|
|
413
|
+
const g = await b.onResponse({
|
|
414
|
+
request: v,
|
|
415
|
+
response: m,
|
|
416
|
+
schemaPath: a,
|
|
417
|
+
params: S,
|
|
418
|
+
options: P,
|
|
419
|
+
id: _
|
|
420
|
+
});
|
|
421
|
+
if (g) {
|
|
422
|
+
if (!(g instanceof Response))
|
|
423
|
+
throw new Error("onResponse: must return new Response() when modifying the response");
|
|
424
|
+
m = g;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
if (m.status === 204 || v.method === "HEAD" || m.headers.get("Content-Length") === "0")
|
|
430
|
+
return m.ok ? { data: void 0, response: m } : { error: void 0, response: m };
|
|
431
|
+
if (m.ok)
|
|
432
|
+
return I === "stream" ? { data: m.body, response: m } : { data: await m[I](), response: m };
|
|
433
|
+
let C = await m.text();
|
|
434
|
+
try {
|
|
435
|
+
C = JSON.parse(C);
|
|
436
|
+
} catch {
|
|
437
|
+
}
|
|
438
|
+
return { error: C, response: m };
|
|
439
|
+
}
|
|
440
|
+
return {
|
|
441
|
+
request(a, c, w) {
|
|
442
|
+
return E(c, { ...w, method: a.toUpperCase() });
|
|
443
|
+
},
|
|
444
|
+
/** Call a GET endpoint */
|
|
445
|
+
GET(a, c) {
|
|
446
|
+
return E(a, { ...c, method: "GET" });
|
|
447
|
+
},
|
|
448
|
+
/** Call a PUT endpoint */
|
|
449
|
+
PUT(a, c) {
|
|
450
|
+
return E(a, { ...c, method: "PUT" });
|
|
451
|
+
},
|
|
452
|
+
/** Call a POST endpoint */
|
|
453
|
+
POST(a, c) {
|
|
454
|
+
return E(a, { ...c, method: "POST" });
|
|
455
|
+
},
|
|
456
|
+
/** Call a DELETE endpoint */
|
|
457
|
+
DELETE(a, c) {
|
|
458
|
+
return E(a, { ...c, method: "DELETE" });
|
|
459
|
+
},
|
|
460
|
+
/** Call a OPTIONS endpoint */
|
|
461
|
+
OPTIONS(a, c) {
|
|
462
|
+
return E(a, { ...c, method: "OPTIONS" });
|
|
463
|
+
},
|
|
464
|
+
/** Call a HEAD endpoint */
|
|
465
|
+
HEAD(a, c) {
|
|
466
|
+
return E(a, { ...c, method: "HEAD" });
|
|
467
|
+
},
|
|
468
|
+
/** Call a PATCH endpoint */
|
|
469
|
+
PATCH(a, c) {
|
|
470
|
+
return E(a, { ...c, method: "PATCH" });
|
|
471
|
+
},
|
|
472
|
+
/** Call a TRACE endpoint */
|
|
473
|
+
TRACE(a, c) {
|
|
474
|
+
return E(a, { ...c, method: "TRACE" });
|
|
475
|
+
},
|
|
476
|
+
/** Register middleware */
|
|
477
|
+
use(...a) {
|
|
478
|
+
for (const c of a)
|
|
479
|
+
if (c) {
|
|
480
|
+
if (typeof c != "object" || !("onRequest" in c || "onResponse" in c || "onError" in c))
|
|
481
|
+
throw new Error("Middleware must be an object with one of `onRequest()`, `onResponse() or `onError()`");
|
|
482
|
+
p.push(c);
|
|
483
|
+
}
|
|
484
|
+
},
|
|
485
|
+
/** Unregister middleware */
|
|
486
|
+
eject(...a) {
|
|
487
|
+
for (const c of a) {
|
|
488
|
+
const w = p.indexOf(c);
|
|
489
|
+
w !== -1 && p.splice(w, 1);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
function G(r, n, t) {
|
|
495
|
+
if (n == null)
|
|
496
|
+
return "";
|
|
497
|
+
if (typeof n == "object")
|
|
498
|
+
throw new Error(
|
|
499
|
+
"Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these."
|
|
500
|
+
);
|
|
501
|
+
return `${r}=${(t == null ? void 0 : t.allowReserved) === !0 ? n : encodeURIComponent(n)}`;
|
|
502
|
+
}
|
|
503
|
+
function ae(r, n, t) {
|
|
504
|
+
if (!n || typeof n != "object")
|
|
505
|
+
return "";
|
|
506
|
+
const i = [], o = {
|
|
507
|
+
simple: ",",
|
|
508
|
+
label: ".",
|
|
509
|
+
matrix: ";"
|
|
510
|
+
}[t.style] || "&";
|
|
511
|
+
if (t.style !== "deepObject" && t.explode === !1) {
|
|
512
|
+
for (const f in n)
|
|
513
|
+
i.push(f, t.allowReserved === !0 ? n[f] : encodeURIComponent(n[f]));
|
|
514
|
+
const u = i.join(",");
|
|
515
|
+
switch (t.style) {
|
|
516
|
+
case "form":
|
|
517
|
+
return `${r}=${u}`;
|
|
518
|
+
case "label":
|
|
519
|
+
return `.${u}`;
|
|
520
|
+
case "matrix":
|
|
521
|
+
return `;${r}=${u}`;
|
|
522
|
+
default:
|
|
523
|
+
return u;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
for (const u in n) {
|
|
527
|
+
const f = t.style === "deepObject" ? `${r}[${u}]` : u;
|
|
528
|
+
i.push(G(f, n[u], t));
|
|
529
|
+
}
|
|
530
|
+
const s = i.join(o);
|
|
531
|
+
return t.style === "label" || t.style === "matrix" ? `${o}${s}` : s;
|
|
532
|
+
}
|
|
533
|
+
function ie(r, n, t) {
|
|
534
|
+
if (!Array.isArray(n))
|
|
535
|
+
return "";
|
|
536
|
+
if (t.explode === !1) {
|
|
537
|
+
const s = { form: ",", spaceDelimited: "%20", pipeDelimited: "|" }[t.style] || ",", u = (t.allowReserved === !0 ? n : n.map((f) => encodeURIComponent(f))).join(s);
|
|
538
|
+
switch (t.style) {
|
|
539
|
+
case "simple":
|
|
540
|
+
return u;
|
|
541
|
+
case "label":
|
|
542
|
+
return `.${u}`;
|
|
543
|
+
case "matrix":
|
|
544
|
+
return `;${r}=${u}`;
|
|
545
|
+
default:
|
|
546
|
+
return `${r}=${u}`;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
const i = { simple: ",", label: ".", matrix: ";" }[t.style] || "&", o = [];
|
|
550
|
+
for (const s of n)
|
|
551
|
+
t.style === "simple" || t.style === "label" ? o.push(t.allowReserved === !0 ? s : encodeURIComponent(s)) : o.push(G(r, s, t));
|
|
552
|
+
return t.style === "label" || t.style === "matrix" ? `${i}${o.join(i)}` : o.join(i);
|
|
553
|
+
}
|
|
554
|
+
function te(r) {
|
|
555
|
+
return function(t) {
|
|
556
|
+
const i = [];
|
|
557
|
+
if (t && typeof t == "object")
|
|
558
|
+
for (const o in t) {
|
|
559
|
+
const s = t[o];
|
|
560
|
+
if (s != null) {
|
|
561
|
+
if (Array.isArray(s)) {
|
|
562
|
+
if (s.length === 0)
|
|
563
|
+
continue;
|
|
564
|
+
i.push(
|
|
565
|
+
ie(o, s, {
|
|
566
|
+
style: "form",
|
|
567
|
+
explode: !0,
|
|
568
|
+
...r == null ? void 0 : r.array,
|
|
569
|
+
allowReserved: (r == null ? void 0 : r.allowReserved) || !1
|
|
570
|
+
})
|
|
571
|
+
);
|
|
572
|
+
continue;
|
|
573
|
+
}
|
|
574
|
+
if (typeof s == "object") {
|
|
575
|
+
i.push(
|
|
576
|
+
ae(o, s, {
|
|
577
|
+
style: "deepObject",
|
|
578
|
+
explode: !0,
|
|
579
|
+
...r == null ? void 0 : r.object,
|
|
580
|
+
allowReserved: (r == null ? void 0 : r.allowReserved) || !1
|
|
581
|
+
})
|
|
582
|
+
);
|
|
583
|
+
continue;
|
|
584
|
+
}
|
|
585
|
+
i.push(G(o, s, r));
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
return i.join("&");
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
function Ee(r, n) {
|
|
592
|
+
let t = r;
|
|
593
|
+
for (const i of r.match(me) ?? []) {
|
|
594
|
+
let o = i.substring(1, i.length - 1), s = !1, u = "simple";
|
|
595
|
+
if (o.endsWith("*") && (s = !0, o = o.substring(0, o.length - 1)), o.startsWith(".") ? (u = "label", o = o.substring(1)) : o.startsWith(";") && (u = "matrix", o = o.substring(1)), !n || n[o] === void 0 || n[o] === null)
|
|
596
|
+
continue;
|
|
597
|
+
const f = n[o];
|
|
598
|
+
if (Array.isArray(f)) {
|
|
599
|
+
t = t.replace(i, ie(o, f, { style: u, explode: s }));
|
|
600
|
+
continue;
|
|
601
|
+
}
|
|
602
|
+
if (typeof f == "object") {
|
|
603
|
+
t = t.replace(i, ae(o, f, { style: u, explode: s }));
|
|
604
|
+
continue;
|
|
605
|
+
}
|
|
606
|
+
if (u === "matrix") {
|
|
607
|
+
t = t.replace(i, `;${G(o, f)}`);
|
|
608
|
+
continue;
|
|
609
|
+
}
|
|
610
|
+
t = t.replace(i, u === "label" ? `.${encodeURIComponent(f)}` : encodeURIComponent(f));
|
|
611
|
+
}
|
|
612
|
+
return t;
|
|
613
|
+
}
|
|
614
|
+
function he(r, n) {
|
|
615
|
+
return r instanceof FormData ? r : n && (n.get instanceof Function ? n.get("Content-Type") ?? n.get("content-type") : n["Content-Type"] ?? n["content-type"]) === "application/x-www-form-urlencoded" ? new URLSearchParams(r).toString() : JSON.stringify(r);
|
|
616
|
+
}
|
|
617
|
+
function Re(r, n) {
|
|
618
|
+
var o;
|
|
619
|
+
let t = `${n.baseUrl}${r}`;
|
|
620
|
+
(o = n.params) != null && o.path && (t = Ee(t, n.params.path));
|
|
621
|
+
let i = n.querySerializer(n.params.query ?? {});
|
|
622
|
+
return i.startsWith("?") && (i = i.substring(1)), i && (t += `?${i}`), t;
|
|
623
|
+
}
|
|
624
|
+
function ne(...r) {
|
|
625
|
+
const n = new Headers();
|
|
626
|
+
for (const t of r) {
|
|
627
|
+
if (!t || typeof t != "object")
|
|
628
|
+
continue;
|
|
629
|
+
const i = t instanceof Headers ? t.entries() : Object.entries(t);
|
|
630
|
+
for (const [o, s] of i)
|
|
631
|
+
if (s === null)
|
|
632
|
+
n.delete(o);
|
|
633
|
+
else if (Array.isArray(s))
|
|
634
|
+
for (const u of s)
|
|
635
|
+
n.append(o, u);
|
|
636
|
+
else s !== void 0 && n.set(o, s);
|
|
637
|
+
}
|
|
638
|
+
return n;
|
|
639
|
+
}
|
|
640
|
+
function oe(r) {
|
|
641
|
+
return r.endsWith("/") ? r.substring(0, r.length - 1) : r;
|
|
642
|
+
}
|
|
643
|
+
const we = {
|
|
644
|
+
baseUrl: "http://localhost:3000"
|
|
645
|
+
}, ve = {
|
|
646
|
+
development: {
|
|
647
|
+
baseUrl: "http://localhost:3000"
|
|
648
|
+
},
|
|
649
|
+
test: {
|
|
650
|
+
baseUrl: "https://xnkjmdy4v8.execute-api.ap-southeast-2.amazonaws.com/staging"
|
|
651
|
+
},
|
|
652
|
+
production: {
|
|
653
|
+
// Use Vite's import.meta.env instead of process.env
|
|
654
|
+
baseUrl: "https://xnkjmdy4v8.execute-api.ap-southeast-2.amazonaws.com/staging"
|
|
655
|
+
}
|
|
656
|
+
}, ge = () => ve["production"] || we, Te = ge(), se = ye({
|
|
657
|
+
baseUrl: Te.baseUrl
|
|
658
|
+
}), je = (r, n) => {
|
|
659
|
+
const [t, i] = Q(!n), [o, s] = Q(null), [u, f] = Q(n), j = Z(async () => {
|
|
660
|
+
i(!0), s(null);
|
|
661
|
+
try {
|
|
662
|
+
const { data: a, error: c } = await se.GET(
|
|
663
|
+
"/api/v1/dismissible/{itemId}",
|
|
664
|
+
{
|
|
665
|
+
params: {
|
|
666
|
+
path: {
|
|
667
|
+
itemId: r
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
);
|
|
672
|
+
if (c)
|
|
673
|
+
throw new Error(c.error.message || "Failed to fetch dismissible item");
|
|
674
|
+
f(a.data);
|
|
675
|
+
} catch (a) {
|
|
676
|
+
s(
|
|
677
|
+
a instanceof Error ? a : new Error("Unknown error occurred")
|
|
678
|
+
);
|
|
679
|
+
} finally {
|
|
680
|
+
i(!1);
|
|
681
|
+
}
|
|
682
|
+
}, [r]);
|
|
683
|
+
ue(() => {
|
|
684
|
+
n || j();
|
|
685
|
+
}, [r, n, j]);
|
|
686
|
+
const p = Z(async () => {
|
|
687
|
+
i(!0), s(null);
|
|
688
|
+
try {
|
|
689
|
+
const { data: a, error: c } = await se.DELETE(
|
|
690
|
+
"/api/v1/dismissible/{itemId}",
|
|
691
|
+
{
|
|
692
|
+
params: {
|
|
693
|
+
path: {
|
|
694
|
+
itemId: r
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
);
|
|
699
|
+
if (c)
|
|
700
|
+
throw new Error(c.error.message || "Failed to dismiss item");
|
|
701
|
+
f(a.data);
|
|
702
|
+
} catch (a) {
|
|
703
|
+
throw s(a instanceof Error ? a : new Error("Failed to dismiss item")), a;
|
|
704
|
+
} finally {
|
|
705
|
+
i(!1);
|
|
706
|
+
}
|
|
707
|
+
}, [r]), E = Z(async () => {
|
|
708
|
+
s(null), i(!0);
|
|
709
|
+
try {
|
|
710
|
+
throw console.warn(
|
|
711
|
+
"Restore functionality requires a backend API endpoint that does not exist yet."
|
|
712
|
+
), new Error("Restore functionality not implemented in API");
|
|
713
|
+
} catch (a) {
|
|
714
|
+
throw s(a instanceof Error ? a : new Error("Failed to restore item")), a;
|
|
715
|
+
} finally {
|
|
716
|
+
i(!1);
|
|
717
|
+
}
|
|
718
|
+
}, []);
|
|
719
|
+
return {
|
|
720
|
+
dismissedOn: (u == null ? void 0 : u.dismissedAt) ?? null,
|
|
721
|
+
dismiss: p,
|
|
722
|
+
restore: E,
|
|
723
|
+
isLoading: t,
|
|
724
|
+
error: o
|
|
725
|
+
};
|
|
726
|
+
}, Se = () => /* @__PURE__ */ A.jsx("div", { className: "dismissible-loading", "aria-live": "polite", children: "Loading..." }), xe = ({ error: r }) => /* @__PURE__ */ A.jsxs("div", { className: "dismissible-error", role: "alert", children: [
|
|
727
|
+
"Error loading dismissible item: ",
|
|
728
|
+
r.message
|
|
729
|
+
] }), Ae = ({ id: r, onDismiss: n, ariaLabel: t }) => /* @__PURE__ */ A.jsx(
|
|
730
|
+
"button",
|
|
731
|
+
{
|
|
732
|
+
id: r,
|
|
733
|
+
className: "dismissible-button",
|
|
734
|
+
onClick: n,
|
|
735
|
+
"aria-label": t,
|
|
736
|
+
type: "button",
|
|
737
|
+
children: "×"
|
|
738
|
+
}
|
|
739
|
+
), Oe = ({
|
|
740
|
+
id: r,
|
|
741
|
+
children: n,
|
|
742
|
+
onDismiss: t,
|
|
743
|
+
onRestore: i,
|
|
744
|
+
LoadingComponent: o = Se,
|
|
745
|
+
ErrorComponent: s = xe,
|
|
746
|
+
DismissButtonComponent: u = Ae
|
|
747
|
+
}) => {
|
|
748
|
+
const { dismissedOn: f, isLoading: j, error: p, dismiss: E, restore: a } = je(r), c = async () => {
|
|
749
|
+
try {
|
|
750
|
+
await E(), t == null || t();
|
|
751
|
+
} catch (w) {
|
|
752
|
+
console.error("Failed to dismiss item:", w);
|
|
753
|
+
}
|
|
754
|
+
};
|
|
755
|
+
return j && o ? /* @__PURE__ */ A.jsx(o, { id: r }) : p && s ? /* @__PURE__ */ A.jsx(s, { id: r, error: p }) : f ? null : /* @__PURE__ */ A.jsxs("div", { className: "dismissible-container", children: [
|
|
756
|
+
/* @__PURE__ */ A.jsx("div", { className: "dismissible-content", children: n }),
|
|
757
|
+
u ? /* @__PURE__ */ A.jsx(
|
|
758
|
+
u,
|
|
759
|
+
{
|
|
760
|
+
id: r,
|
|
761
|
+
onDismiss: c,
|
|
762
|
+
ariaLabel: `Dismiss ${r}`
|
|
763
|
+
}
|
|
764
|
+
) : null
|
|
765
|
+
] });
|
|
766
|
+
}, ke = "0.1.0";
|
|
767
|
+
export {
|
|
768
|
+
Oe as Dismissible,
|
|
769
|
+
ke as VERSION,
|
|
770
|
+
je as useDismissibleItem
|
|
771
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
(function(S,w){typeof exports=="object"&&typeof module<"u"?w(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],w):(S=typeof globalThis<"u"?globalThis:S||self,w(S.DismissibleClient={},S.React))})(this,function(S,w){"use strict";var B={exports:{}},D={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react-jsx-runtime.production.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var ee;function ce(){if(ee)return D;ee=1;var r=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function t(i,o,s){var u=null;if(s!==void 0&&(u=""+s),o.key!==void 0&&(u=""+o.key),"key"in o){s={};for(var f in o)f!=="key"&&(s[f]=o[f])}else s=o;return o=s.ref,{$$typeof:r,type:i,key:u,ref:o!==void 0?o:null,props:s}}return D.Fragment=n,D.jsx=t,D.jsxs=t,D}var z={};/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react-jsx-runtime.development.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/var re;function ue(){return re||(re=1,process.env.NODE_ENV!=="production"&&function(){function r(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===X?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case H:return"Fragment";case x:return"Profiler";case G:return"StrictMode";case J:return"Suspense";case L:return"SuspenseList";case q:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case W:return"Portal";case C:return(e.displayName||"Context")+".Provider";case F:return(e._context.displayName||"Context")+".Consumer";case V:var l=e.render;return e=e.displayName,e||(e=l.displayName||l.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case $:return l=e.displayName||null,l!==null?l:r(e.type)||"Memo";case P:l=e._payload,e=e._init;try{return r(e(l))}catch{}}return null}function n(e){return""+e}function t(e){try{n(e);var l=!1}catch{l=!0}if(l){l=console;var d=l.error,E=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return d.call(l,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",E),n(e)}}function i(e){if(e===H)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===P)return"<...>";try{var l=r(e);return l?"<"+l+">":"<...>"}catch{return"<...>"}}function o(){var e=Y.A;return e===null?null:e.getOwner()}function s(){return Error("react-stack-top-frame")}function u(e){if(k.call(e,"key")){var l=Object.getOwnPropertyDescriptor(e,"key").get;if(l&&l.isReactWarning)return!1}return e.key!==void 0}function f(e,l){function d(){m||(m=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",l))}d.isReactWarning=!0,Object.defineProperty(e,"key",{get:d,configurable:!0})}function _(){var e=r(this.type);return I[e]||(I[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function p(e,l,d,E,O,j,Q,Z){return d=j.ref,e={$$typeof:v,type:e,key:l,props:j,_owner:O},(d!==void 0?d:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:_}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:Q}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Z}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function h(e,l,d,E,O,j,Q,Z){var R=l.children;if(R!==void 0)if(E)if(N(R)){for(E=0;E<R.length;E++)a(R[E]);Object.freeze&&Object.freeze(R)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else a(R);if(k.call(l,"key")){R=r(e);var U=Object.keys(l).filter(function(Ae){return Ae!=="key"});E=0<U.length?"{key: someKey, "+U.join(": ..., ")+": ...}":"{key: someKey}",T[R+E]||(U=0<U.length?"{"+U.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
|
+
let props = %s;
|
|
19
|
+
<%s {...props} />
|
|
20
|
+
React keys must be passed directly to JSX without using spread:
|
|
21
|
+
let props = %s;
|
|
22
|
+
<%s key={someKey} {...props} />`,E,R,U,R),T[R+E]=!0)}if(R=null,d!==void 0&&(t(d),R=""+d),u(l)&&(t(l.key),R=""+l.key),"key"in l){d={};for(var K in l)K!=="key"&&(d[K]=l[K])}else d=l;return R&&f(d,typeof e=="function"?e.displayName||e.name||"Unknown":e),p(e,R,j,O,o(),d,Q,Z)}function a(e){typeof e=="object"&&e!==null&&e.$$typeof===v&&e._store&&(e._store.validated=1)}var c=w,v=Symbol.for("react.transitional.element"),W=Symbol.for("react.portal"),H=Symbol.for("react.fragment"),G=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),F=Symbol.for("react.consumer"),C=Symbol.for("react.context"),V=Symbol.for("react.forward_ref"),J=Symbol.for("react.suspense"),L=Symbol.for("react.suspense_list"),$=Symbol.for("react.memo"),P=Symbol.for("react.lazy"),q=Symbol.for("react.activity"),X=Symbol.for("react.client.reference"),Y=c.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,k=Object.prototype.hasOwnProperty,N=Array.isArray,g=console.createTask?console.createTask:function(){return null};c={"react-stack-bottom-frame":function(e){return e()}};var m,I={},y=c["react-stack-bottom-frame"].bind(c,s)(),b=g(i(s)),T={};z.Fragment=H,z.jsx=function(e,l,d,E,O){var j=1e4>Y.recentlyCreatedOwnerStacks++;return h(e,l,d,!1,E,O,j?Error("react-stack-top-frame"):y,j?g(i(e)):b)},z.jsxs=function(e,l,d,E,O){var j=1e4>Y.recentlyCreatedOwnerStacks++;return h(e,l,d,!0,E,O,j?Error("react-stack-top-frame"):y,j?g(i(e)):b)}}()),z}process.env.NODE_ENV==="production"?B.exports=ce():B.exports=ue();var A=B.exports;const fe=/\{[^{}]+\}/g,de=()=>{var r,n;return typeof process=="object"&&Number.parseInt((n=(r=process==null?void 0:process.versions)==null?void 0:r.node)==null?void 0:n.substring(0,2))>=18&&process.versions.undici};function me(){return Math.random().toString(36).slice(2,11)}function be(r){let{baseUrl:n="",Request:t=globalThis.Request,fetch:i=globalThis.fetch,querySerializer:o,bodySerializer:s,headers:u,requestInitExt:f=void 0,..._}={...r};f=de()?f:void 0,n=ae(n);const p=[];async function h(a,c){const{baseUrl:v,fetch:W=i,Request:H=t,headers:G,params:x={},parseAs:F="json",querySerializer:C,bodySerializer:V=s??ye,body:J,...L}=c||{};let $=n;v&&($=ae(v)??n);let P=typeof o=="function"?o:oe(o);C&&(P=typeof C=="function"?C:oe({...typeof o=="object"?o:{},...C}));const q=J===void 0?void 0:V(J,se(u,G,x.header)),X=se(q===void 0||q instanceof FormData?{}:{"Content-Type":"application/json"},u,G,x.header),Y={redirect:"follow",..._,...L,body:q,headers:X};let k,N,g=new t(he(a,{baseUrl:$,params:x,querySerializer:P}),Y),m;for(const y in L)y in g||(g[y]=L[y]);if(p.length){k=me(),N=Object.freeze({baseUrl:$,fetch:W,parseAs:F,querySerializer:P,bodySerializer:V});for(const y of p)if(y&&typeof y=="object"&&typeof y.onRequest=="function"){const b=await y.onRequest({request:g,schemaPath:a,params:x,options:N,id:k});if(b)if(b instanceof t)g=b;else if(b instanceof Response){m=b;break}else throw new Error("onRequest: must return new Request() or Response() when modifying the request")}}if(!m){try{m=await W(g,f)}catch(y){let b=y;if(p.length)for(let T=p.length-1;T>=0;T--){const e=p[T];if(e&&typeof e=="object"&&typeof e.onError=="function"){const l=await e.onError({request:g,error:b,schemaPath:a,params:x,options:N,id:k});if(l){if(l instanceof Response){b=void 0,m=l;break}if(l instanceof Error){b=l;continue}throw new Error("onError: must return new Response() or instance of Error")}}}if(b)throw b}if(p.length)for(let y=p.length-1;y>=0;y--){const b=p[y];if(b&&typeof b=="object"&&typeof b.onResponse=="function"){const T=await b.onResponse({request:g,response:m,schemaPath:a,params:x,options:N,id:k});if(T){if(!(T instanceof Response))throw new Error("onResponse: must return new Response() when modifying the response");m=T}}}}if(m.status===204||g.method==="HEAD"||m.headers.get("Content-Length")==="0")return m.ok?{data:void 0,response:m}:{error:void 0,response:m};if(m.ok)return F==="stream"?{data:m.body,response:m}:{data:await m[F](),response:m};let I=await m.text();try{I=JSON.parse(I)}catch{}return{error:I,response:m}}return{request(a,c,v){return h(c,{...v,method:a.toUpperCase()})},GET(a,c){return h(a,{...c,method:"GET"})},PUT(a,c){return h(a,{...c,method:"PUT"})},POST(a,c){return h(a,{...c,method:"POST"})},DELETE(a,c){return h(a,{...c,method:"DELETE"})},OPTIONS(a,c){return h(a,{...c,method:"OPTIONS"})},HEAD(a,c){return h(a,{...c,method:"HEAD"})},PATCH(a,c){return h(a,{...c,method:"PATCH"})},TRACE(a,c){return h(a,{...c,method:"TRACE"})},use(...a){for(const c of a)if(c){if(typeof c!="object"||!("onRequest"in c||"onResponse"in c||"onError"in c))throw new Error("Middleware must be an object with one of `onRequest()`, `onResponse() or `onError()`");p.push(c)}},eject(...a){for(const c of a){const v=p.indexOf(c);v!==-1&&p.splice(v,1)}}}}function M(r,n,t){if(n==null)return"";if(typeof n=="object")throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${r}=${(t==null?void 0:t.allowReserved)===!0?n:encodeURIComponent(n)}`}function te(r,n,t){if(!n||typeof n!="object")return"";const i=[],o={simple:",",label:".",matrix:";"}[t.style]||"&";if(t.style!=="deepObject"&&t.explode===!1){for(const f in n)i.push(f,t.allowReserved===!0?n[f]:encodeURIComponent(n[f]));const u=i.join(",");switch(t.style){case"form":return`${r}=${u}`;case"label":return`.${u}`;case"matrix":return`;${r}=${u}`;default:return u}}for(const u in n){const f=t.style==="deepObject"?`${r}[${u}]`:u;i.push(M(f,n[u],t))}const s=i.join(o);return t.style==="label"||t.style==="matrix"?`${o}${s}`:s}function ne(r,n,t){if(!Array.isArray(n))return"";if(t.explode===!1){const s={form:",",spaceDelimited:"%20",pipeDelimited:"|"}[t.style]||",",u=(t.allowReserved===!0?n:n.map(f=>encodeURIComponent(f))).join(s);switch(t.style){case"simple":return u;case"label":return`.${u}`;case"matrix":return`;${r}=${u}`;default:return`${r}=${u}`}}const i={simple:",",label:".",matrix:";"}[t.style]||"&",o=[];for(const s of n)t.style==="simple"||t.style==="label"?o.push(t.allowReserved===!0?s:encodeURIComponent(s)):o.push(M(r,s,t));return t.style==="label"||t.style==="matrix"?`${i}${o.join(i)}`:o.join(i)}function oe(r){return function(t){const i=[];if(t&&typeof t=="object")for(const o in t){const s=t[o];if(s!=null){if(Array.isArray(s)){if(s.length===0)continue;i.push(ne(o,s,{style:"form",explode:!0,...r==null?void 0:r.array,allowReserved:(r==null?void 0:r.allowReserved)||!1}));continue}if(typeof s=="object"){i.push(te(o,s,{style:"deepObject",explode:!0,...r==null?void 0:r.object,allowReserved:(r==null?void 0:r.allowReserved)||!1}));continue}i.push(M(o,s,r))}}return i.join("&")}}function pe(r,n){let t=r;for(const i of r.match(fe)??[]){let o=i.substring(1,i.length-1),s=!1,u="simple";if(o.endsWith("*")&&(s=!0,o=o.substring(0,o.length-1)),o.startsWith(".")?(u="label",o=o.substring(1)):o.startsWith(";")&&(u="matrix",o=o.substring(1)),!n||n[o]===void 0||n[o]===null)continue;const f=n[o];if(Array.isArray(f)){t=t.replace(i,ne(o,f,{style:u,explode:s}));continue}if(typeof f=="object"){t=t.replace(i,te(o,f,{style:u,explode:s}));continue}if(u==="matrix"){t=t.replace(i,`;${M(o,f)}`);continue}t=t.replace(i,u==="label"?`.${encodeURIComponent(f)}`:encodeURIComponent(f))}return t}function ye(r,n){return r instanceof FormData?r:n&&(n.get instanceof Function?n.get("Content-Type")??n.get("content-type"):n["Content-Type"]??n["content-type"])==="application/x-www-form-urlencoded"?new URLSearchParams(r).toString():JSON.stringify(r)}function he(r,n){var o;let t=`${n.baseUrl}${r}`;(o=n.params)!=null&&o.path&&(t=pe(t,n.params.path));let i=n.querySerializer(n.params.query??{});return i.startsWith("?")&&(i=i.substring(1)),i&&(t+=`?${i}`),t}function se(...r){const n=new Headers;for(const t of r){if(!t||typeof t!="object")continue;const i=t instanceof Headers?t.entries():Object.entries(t);for(const[o,s]of i)if(s===null)n.delete(o);else if(Array.isArray(s))for(const u of s)n.append(o,u);else s!==void 0&&n.set(o,s)}return n}function ae(r){return r.endsWith("/")?r.substring(0,r.length-1):r}const Ee={baseUrl:"http://localhost:3000"},Re={development:{baseUrl:"http://localhost:3000"},test:{baseUrl:"https://xnkjmdy4v8.execute-api.ap-southeast-2.amazonaws.com/staging"},production:{baseUrl:"https://xnkjmdy4v8.execute-api.ap-southeast-2.amazonaws.com/staging"}},we=Re["production"]||Ee,ie=be({baseUrl:we.baseUrl}),le=(r,n)=>{const[t,i]=w.useState(!n),[o,s]=w.useState(null),[u,f]=w.useState(n),_=w.useCallback(async()=>{i(!0),s(null);try{const{data:a,error:c}=await ie.GET("/api/v1/dismissible/{itemId}",{params:{path:{itemId:r}}});if(c)throw new Error(c.error.message||"Failed to fetch dismissible item");f(a.data)}catch(a){s(a instanceof Error?a:new Error("Unknown error occurred"))}finally{i(!1)}},[r]);w.useEffect(()=>{n||_()},[r,n,_]);const p=w.useCallback(async()=>{i(!0),s(null);try{const{data:a,error:c}=await ie.DELETE("/api/v1/dismissible/{itemId}",{params:{path:{itemId:r}}});if(c)throw new Error(c.error.message||"Failed to dismiss item");f(a.data)}catch(a){throw s(a instanceof Error?a:new Error("Failed to dismiss item")),a}finally{i(!1)}},[r]),h=w.useCallback(async()=>{s(null),i(!0);try{throw console.warn("Restore functionality requires a backend API endpoint that does not exist yet."),new Error("Restore functionality not implemented in API")}catch(a){throw s(a instanceof Error?a:new Error("Failed to restore item")),a}finally{i(!1)}},[]);return{dismissedOn:(u==null?void 0:u.dismissedAt)??null,dismiss:p,restore:h,isLoading:t,error:o}},ve=()=>A.jsx("div",{className:"dismissible-loading","aria-live":"polite",children:"Loading..."}),ge=({error:r})=>A.jsxs("div",{className:"dismissible-error",role:"alert",children:["Error loading dismissible item: ",r.message]}),Te=({id:r,onDismiss:n,ariaLabel:t})=>A.jsx("button",{id:r,className:"dismissible-button",onClick:n,"aria-label":t,type:"button",children:"×"}),je=({id:r,children:n,onDismiss:t,onRestore:i,LoadingComponent:o=ve,ErrorComponent:s=ge,DismissButtonComponent:u=Te})=>{const{dismissedOn:f,isLoading:_,error:p,dismiss:h,restore:a}=le(r),c=async()=>{try{await h(),t==null||t()}catch(v){console.error("Failed to dismiss item:",v)}};return _&&o?A.jsx(o,{id:r}):p&&s?A.jsx(s,{id:r,error:p}):f?null:A.jsxs("div",{className:"dismissible-container",children:[A.jsx("div",{className:"dismissible-content",children:n}),u?A.jsx(u,{id:r,onDismiss:c,ariaLabel:`Dismiss ${r}`}):null]})},Se="0.1.0";S.Dismissible=je,S.VERSION=Se,S.useDismissibleItem=le,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Mock Service Worker.
|
|
6
|
+
* @see https://github.com/mswjs/msw
|
|
7
|
+
* - Please do NOT modify this file.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const PACKAGE_VERSION = '2.10.3'
|
|
11
|
+
const INTEGRITY_CHECKSUM = 'f5825c521429caf22a4dd13b66e243af'
|
|
12
|
+
const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
|
|
13
|
+
const activeClientIds = new Set()
|
|
14
|
+
|
|
15
|
+
addEventListener('install', function () {
|
|
16
|
+
self.skipWaiting()
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
addEventListener('activate', function (event) {
|
|
20
|
+
event.waitUntil(self.clients.claim())
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
addEventListener('message', async function (event) {
|
|
24
|
+
const clientId = Reflect.get(event.source || {}, 'id')
|
|
25
|
+
|
|
26
|
+
if (!clientId || !self.clients) {
|
|
27
|
+
return
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const client = await self.clients.get(clientId)
|
|
31
|
+
|
|
32
|
+
if (!client) {
|
|
33
|
+
return
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const allClients = await self.clients.matchAll({
|
|
37
|
+
type: 'window',
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
switch (event.data) {
|
|
41
|
+
case 'KEEPALIVE_REQUEST': {
|
|
42
|
+
sendToClient(client, {
|
|
43
|
+
type: 'KEEPALIVE_RESPONSE',
|
|
44
|
+
})
|
|
45
|
+
break
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
case 'INTEGRITY_CHECK_REQUEST': {
|
|
49
|
+
sendToClient(client, {
|
|
50
|
+
type: 'INTEGRITY_CHECK_RESPONSE',
|
|
51
|
+
payload: {
|
|
52
|
+
packageVersion: PACKAGE_VERSION,
|
|
53
|
+
checksum: INTEGRITY_CHECKSUM,
|
|
54
|
+
},
|
|
55
|
+
})
|
|
56
|
+
break
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
case 'MOCK_ACTIVATE': {
|
|
60
|
+
activeClientIds.add(clientId)
|
|
61
|
+
|
|
62
|
+
sendToClient(client, {
|
|
63
|
+
type: 'MOCKING_ENABLED',
|
|
64
|
+
payload: {
|
|
65
|
+
client: {
|
|
66
|
+
id: client.id,
|
|
67
|
+
frameType: client.frameType,
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
})
|
|
71
|
+
break
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
case 'MOCK_DEACTIVATE': {
|
|
75
|
+
activeClientIds.delete(clientId)
|
|
76
|
+
break
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
case 'CLIENT_CLOSED': {
|
|
80
|
+
activeClientIds.delete(clientId)
|
|
81
|
+
|
|
82
|
+
const remainingClients = allClients.filter((client) => {
|
|
83
|
+
return client.id !== clientId
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
// Unregister itself when there are no more clients
|
|
87
|
+
if (remainingClients.length === 0) {
|
|
88
|
+
self.registration.unregister()
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
break
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
addEventListener('fetch', function (event) {
|
|
97
|
+
// Bypass navigation requests.
|
|
98
|
+
if (event.request.mode === 'navigate') {
|
|
99
|
+
return
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Opening the DevTools triggers the "only-if-cached" request
|
|
103
|
+
// that cannot be handled by the worker. Bypass such requests.
|
|
104
|
+
if (
|
|
105
|
+
event.request.cache === 'only-if-cached' &&
|
|
106
|
+
event.request.mode !== 'same-origin'
|
|
107
|
+
) {
|
|
108
|
+
return
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Bypass all requests when there are no active clients.
|
|
112
|
+
// Prevents the self-unregistered worked from handling requests
|
|
113
|
+
// after it's been deleted (still remains active until the next reload).
|
|
114
|
+
if (activeClientIds.size === 0) {
|
|
115
|
+
return
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const requestId = crypto.randomUUID()
|
|
119
|
+
event.respondWith(handleRequest(event, requestId))
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* @param {FetchEvent} event
|
|
124
|
+
* @param {string} requestId
|
|
125
|
+
*/
|
|
126
|
+
async function handleRequest(event, requestId) {
|
|
127
|
+
const client = await resolveMainClient(event)
|
|
128
|
+
const requestCloneForEvents = event.request.clone()
|
|
129
|
+
const response = await getResponse(event, client, requestId)
|
|
130
|
+
|
|
131
|
+
// Send back the response clone for the "response:*" life-cycle events.
|
|
132
|
+
// Ensure MSW is active and ready to handle the message, otherwise
|
|
133
|
+
// this message will pend indefinitely.
|
|
134
|
+
if (client && activeClientIds.has(client.id)) {
|
|
135
|
+
const serializedRequest = await serializeRequest(requestCloneForEvents)
|
|
136
|
+
|
|
137
|
+
// Clone the response so both the client and the library could consume it.
|
|
138
|
+
const responseClone = response.clone()
|
|
139
|
+
|
|
140
|
+
sendToClient(
|
|
141
|
+
client,
|
|
142
|
+
{
|
|
143
|
+
type: 'RESPONSE',
|
|
144
|
+
payload: {
|
|
145
|
+
isMockedResponse: IS_MOCKED_RESPONSE in response,
|
|
146
|
+
request: {
|
|
147
|
+
id: requestId,
|
|
148
|
+
...serializedRequest,
|
|
149
|
+
},
|
|
150
|
+
response: {
|
|
151
|
+
type: responseClone.type,
|
|
152
|
+
status: responseClone.status,
|
|
153
|
+
statusText: responseClone.statusText,
|
|
154
|
+
headers: Object.fromEntries(responseClone.headers.entries()),
|
|
155
|
+
body: responseClone.body,
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
responseClone.body ? [serializedRequest.body, responseClone.body] : [],
|
|
160
|
+
)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return response
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Resolve the main client for the given event.
|
|
168
|
+
* Client that issues a request doesn't necessarily equal the client
|
|
169
|
+
* that registered the worker. It's with the latter the worker should
|
|
170
|
+
* communicate with during the response resolving phase.
|
|
171
|
+
* @param {FetchEvent} event
|
|
172
|
+
* @returns {Promise<Client | undefined>}
|
|
173
|
+
*/
|
|
174
|
+
async function resolveMainClient(event) {
|
|
175
|
+
const client = await self.clients.get(event.clientId)
|
|
176
|
+
|
|
177
|
+
if (activeClientIds.has(event.clientId)) {
|
|
178
|
+
return client
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (client?.frameType === 'top-level') {
|
|
182
|
+
return client
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const allClients = await self.clients.matchAll({
|
|
186
|
+
type: 'window',
|
|
187
|
+
})
|
|
188
|
+
|
|
189
|
+
return allClients
|
|
190
|
+
.filter((client) => {
|
|
191
|
+
// Get only those clients that are currently visible.
|
|
192
|
+
return client.visibilityState === 'visible'
|
|
193
|
+
})
|
|
194
|
+
.find((client) => {
|
|
195
|
+
// Find the client ID that's recorded in the
|
|
196
|
+
// set of clients that have registered the worker.
|
|
197
|
+
return activeClientIds.has(client.id)
|
|
198
|
+
})
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* @param {FetchEvent} event
|
|
203
|
+
* @param {Client | undefined} client
|
|
204
|
+
* @param {string} requestId
|
|
205
|
+
* @returns {Promise<Response>}
|
|
206
|
+
*/
|
|
207
|
+
async function getResponse(event, client, requestId) {
|
|
208
|
+
// Clone the request because it might've been already used
|
|
209
|
+
// (i.e. its body has been read and sent to the client).
|
|
210
|
+
const requestClone = event.request.clone()
|
|
211
|
+
|
|
212
|
+
function passthrough() {
|
|
213
|
+
// Cast the request headers to a new Headers instance
|
|
214
|
+
// so the headers can be manipulated with.
|
|
215
|
+
const headers = new Headers(requestClone.headers)
|
|
216
|
+
|
|
217
|
+
// Remove the "accept" header value that marked this request as passthrough.
|
|
218
|
+
// This prevents request alteration and also keeps it compliant with the
|
|
219
|
+
// user-defined CORS policies.
|
|
220
|
+
const acceptHeader = headers.get('accept')
|
|
221
|
+
if (acceptHeader) {
|
|
222
|
+
const values = acceptHeader.split(',').map((value) => value.trim())
|
|
223
|
+
const filteredValues = values.filter(
|
|
224
|
+
(value) => value !== 'msw/passthrough',
|
|
225
|
+
)
|
|
226
|
+
|
|
227
|
+
if (filteredValues.length > 0) {
|
|
228
|
+
headers.set('accept', filteredValues.join(', '))
|
|
229
|
+
} else {
|
|
230
|
+
headers.delete('accept')
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
return fetch(requestClone, { headers })
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// Bypass mocking when the client is not active.
|
|
238
|
+
if (!client) {
|
|
239
|
+
return passthrough()
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// Bypass initial page load requests (i.e. static assets).
|
|
243
|
+
// The absence of the immediate/parent client in the map of the active clients
|
|
244
|
+
// means that MSW hasn't dispatched the "MOCK_ACTIVATE" event yet
|
|
245
|
+
// and is not ready to handle requests.
|
|
246
|
+
if (!activeClientIds.has(client.id)) {
|
|
247
|
+
return passthrough()
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// Notify the client that a request has been intercepted.
|
|
251
|
+
const serializedRequest = await serializeRequest(event.request)
|
|
252
|
+
const clientMessage = await sendToClient(
|
|
253
|
+
client,
|
|
254
|
+
{
|
|
255
|
+
type: 'REQUEST',
|
|
256
|
+
payload: {
|
|
257
|
+
id: requestId,
|
|
258
|
+
...serializedRequest,
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
[serializedRequest.body],
|
|
262
|
+
)
|
|
263
|
+
|
|
264
|
+
switch (clientMessage.type) {
|
|
265
|
+
case 'MOCK_RESPONSE': {
|
|
266
|
+
return respondWithMock(clientMessage.data)
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
case 'PASSTHROUGH': {
|
|
270
|
+
return passthrough()
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
return passthrough()
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* @param {Client} client
|
|
279
|
+
* @param {any} message
|
|
280
|
+
* @param {Array<Transferable>} transferrables
|
|
281
|
+
* @returns {Promise<any>}
|
|
282
|
+
*/
|
|
283
|
+
function sendToClient(client, message, transferrables = []) {
|
|
284
|
+
return new Promise((resolve, reject) => {
|
|
285
|
+
const channel = new MessageChannel()
|
|
286
|
+
|
|
287
|
+
channel.port1.onmessage = (event) => {
|
|
288
|
+
if (event.data && event.data.error) {
|
|
289
|
+
return reject(event.data.error)
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
resolve(event.data)
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
client.postMessage(message, [
|
|
296
|
+
channel.port2,
|
|
297
|
+
...transferrables.filter(Boolean),
|
|
298
|
+
])
|
|
299
|
+
})
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* @param {Response} response
|
|
304
|
+
* @returns {Response}
|
|
305
|
+
*/
|
|
306
|
+
function respondWithMock(response) {
|
|
307
|
+
// Setting response status code to 0 is a no-op.
|
|
308
|
+
// However, when responding with a "Response.error()", the produced Response
|
|
309
|
+
// instance will have status code set to 0. Since it's not possible to create
|
|
310
|
+
// a Response instance with status code 0, handle that use-case separately.
|
|
311
|
+
if (response.status === 0) {
|
|
312
|
+
return Response.error()
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
const mockedResponse = new Response(response.body, response)
|
|
316
|
+
|
|
317
|
+
Reflect.defineProperty(mockedResponse, IS_MOCKED_RESPONSE, {
|
|
318
|
+
value: true,
|
|
319
|
+
enumerable: true,
|
|
320
|
+
})
|
|
321
|
+
|
|
322
|
+
return mockedResponse
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* @param {Request} request
|
|
327
|
+
*/
|
|
328
|
+
async function serializeRequest(request) {
|
|
329
|
+
return {
|
|
330
|
+
url: request.url,
|
|
331
|
+
mode: request.mode,
|
|
332
|
+
method: request.method,
|
|
333
|
+
headers: Object.fromEntries(request.headers.entries()),
|
|
334
|
+
cache: request.cache,
|
|
335
|
+
credentials: request.credentials,
|
|
336
|
+
destination: request.destination,
|
|
337
|
+
integrity: request.integrity,
|
|
338
|
+
redirect: request.redirect,
|
|
339
|
+
referrer: request.referrer,
|
|
340
|
+
referrerPolicy: request.referrerPolicy,
|
|
341
|
+
body: await request.arrayBuffer(),
|
|
342
|
+
keepalive: request.keepalive,
|
|
343
|
+
}
|
|
344
|
+
}
|
package/dist/style.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.dismissible-container{position:relative;display:inline-block;width:100%}.dismissible-content{width:100%}.dismissible-button{position:absolute;top:8px;right:8px;background:#0000001a;border:none;border-radius:50%;width:24px;height:24px;display:flex;align-items:center;justify-content:center;cursor:pointer;font-size:16px;line-height:1;color:#666;transition:all .2s ease}.dismissible-button:hover{background:#0003;color:#333}.dismissible-button:focus{outline:2px solid #007bff;outline-offset:2px}.dismissible-button:active{transform:scale(.95)}.dismissible-loading{padding:16px;text-align:center;color:#666;font-style:italic}.dismissible-error{padding:16px;background:#fee;border:1px solid #fcc;border-radius:4px;color:#c33;font-size:14px}@media (max-width: 768px){.dismissible-button{width:32px;height:32px;font-size:18px}}
|
package/package.json
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dismissible/react-client",
|
|
3
|
+
"version": "0.0.1-canary.3",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist",
|
|
7
|
+
"README.md"
|
|
8
|
+
],
|
|
9
|
+
"main": "./dist/dismissible-client.umd.js",
|
|
10
|
+
"module": "./dist/dismissible-client.es.js",
|
|
11
|
+
"types": "./dist/root.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": "./dist/dismissible-client.es.js",
|
|
15
|
+
"require": "./dist/dismissible-client.umd.js",
|
|
16
|
+
"types": "./dist/root.d.ts"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"dev": "vite",
|
|
21
|
+
"build": "tsc --project tsconfig.build.json && vite build",
|
|
22
|
+
"lint": "eslint \"{.storybook,src,test}/**/*.{ts,tsx}\" --fix",
|
|
23
|
+
"format": "prettier --write \"src/**/*.{ts,tsx}\"",
|
|
24
|
+
"preview": "vite preview",
|
|
25
|
+
"test": "vitest run",
|
|
26
|
+
"test:watch": "vitest",
|
|
27
|
+
"storybook": "storybook dev -p 6006",
|
|
28
|
+
"build-storybook": "storybook build",
|
|
29
|
+
"script": "ts-node -r tsconfig-paths/register --project tsconfig.json",
|
|
30
|
+
"generate:clean": "rm -rf ./src/generated/contract/*",
|
|
31
|
+
"generate:api": "npm run generate:clean && npx openapi-typescript http://localhost:3000/docs-yaml -o ./src/generated/contract/index.d.ts"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"openapi-fetch": "^0.14.0"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"react": ">=18.0.0",
|
|
38
|
+
"react-dom": ">=18.0.0"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@storybook/addon-a11y": "^9.0.15",
|
|
42
|
+
"@storybook/addon-docs": "^9.0.15",
|
|
43
|
+
"@storybook/react-vite": "^9.0.15",
|
|
44
|
+
"@testing-library/jest-dom": "^6.6.3",
|
|
45
|
+
"@testing-library/react": "^16.3.0",
|
|
46
|
+
"@types/node": "^24.0.10",
|
|
47
|
+
"@types/react": "^19.1.8",
|
|
48
|
+
"@types/react-dom": "^19.1.6",
|
|
49
|
+
"@typescript-eslint/eslint-plugin": "^8.36.0",
|
|
50
|
+
"@typescript-eslint/parser": "^8.36.0",
|
|
51
|
+
"@vitejs/plugin-react": "^4.0.3",
|
|
52
|
+
"eslint": "^8.45.0",
|
|
53
|
+
"eslint-plugin-react": "^7.37.5",
|
|
54
|
+
"eslint-plugin-react-hooks": "^5.2.0",
|
|
55
|
+
"eslint-plugin-storybook": "^9.0.15",
|
|
56
|
+
"happy-dom": "^18.0.1",
|
|
57
|
+
"msw": "^2.10.3",
|
|
58
|
+
"msw-storybook-addon": "^2.0.5",
|
|
59
|
+
"openapi-typescript": "^7.8.0",
|
|
60
|
+
"prettier": "^3.0.0",
|
|
61
|
+
"react": "^19.1.0",
|
|
62
|
+
"react-dom": "^19.1.0",
|
|
63
|
+
"storybook": "^9.0.15",
|
|
64
|
+
"ts-node": "^10.9.2",
|
|
65
|
+
"typescript": "^5.8.3",
|
|
66
|
+
"vite": "^5.0.10",
|
|
67
|
+
"vitest": "^3.2.4"
|
|
68
|
+
},
|
|
69
|
+
"eslintConfig": {
|
|
70
|
+
"extends": [
|
|
71
|
+
"plugin:storybook/recommended",
|
|
72
|
+
"plugin:storybook/recommended"
|
|
73
|
+
]
|
|
74
|
+
},
|
|
75
|
+
"msw": {
|
|
76
|
+
"workerDirectory": [
|
|
77
|
+
"public"
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
}
|