@drfed/web 0.0.0-stage → 0.1.0-dev.561
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/.output/nitro.json +17 -0
- package/.output/public/.vite/manifest.json +483 -0
- package/.output/public/_build/assets/ActorDetailQuery.graphql-D96mwq1k.js +60 -0
- package/.output/public/_build/assets/ActorDetailQuery.graphql-DrxSNh1X.js +60 -0
- package/.output/public/_build/assets/CompleteLoginChallenge.graphql-C5Zq3wNh.js +10 -0
- package/.output/public/_build/assets/CopyButton-B2l484wE.js +1 -0
- package/.output/public/_build/assets/CopyButton-Bi-ZR8x9.css +1 -0
- package/.output/public/_build/assets/CreateInstanceMutation.graphql-B4CRy6cl.js +19 -0
- package/.output/public/_build/assets/CreateObjectMutation.graphql-B4A01dgV.js +23 -0
- package/.output/public/_build/assets/GenerateActorsMutation.graphql-mlHJNIbe.js +23 -0
- package/.output/public/_build/assets/GetHostQuery.graphql-CuzDdOdW.js +17 -0
- package/.output/public/_build/assets/GetHostQuery.graphql-o9K0Qkg0.js +17 -0
- package/.output/public/_build/assets/HomeViewerQuery.graphql-B903WWKs.js +8 -0
- package/.output/public/_build/assets/HttpStatusCode-bgaVzuLy.js +1 -0
- package/.output/public/_build/assets/InstanceActorListQuery.graphql-DmNwiEhM.js +24 -0
- package/.output/public/_build/assets/InstanceActorListQuery.graphql-paa7teUO.js +24 -0
- package/.output/public/_build/assets/InstanceDetailQuery.graphql-B52nR132.js +66 -0
- package/.output/public/_build/assets/InstanceDetailQuery.graphql-DSA2BcAV.js +66 -0
- package/.output/public/_build/assets/JNCCF6MP-CNMywyiC.js +1 -0
- package/.output/public/_build/assets/LP6E37CW-Cwv6G3n1.js +1 -0
- package/.output/public/_build/assets/SignInMutation.graphql-BalZYNFu.js +9 -0
- package/.output/public/_build/assets/TSB6MOZK-CpiH97G1.js +1 -0
- package/.output/public/_build/assets/Toast-3-eXCAKc.css +1 -0
- package/.output/public/_build/assets/Toast-C1zr9crB.js +1 -0
- package/.output/public/_build/assets/WorkspaceQuery.graphql-UoI7QDs4.js +23 -0
- package/.output/public/_build/assets/_...404_-WZ8kAljY.js +1 -0
- package/.output/public/_build/assets/_challengeId_-Dk-0l7zl.js +1 -0
- package/.output/public/_build/assets/_id_-YcZZShAv.css +1 -0
- package/.output/public/_build/assets/_id_-bpxdclBj.js +1 -0
- package/.output/public/_build/assets/_slug_-CyTA2aW7.css +1 -0
- package/.output/public/_build/assets/_slug_-DXfRknzJ.js +200 -0
- package/.output/public/_build/assets/about-DIrbzRsi.js +1 -0
- package/.output/public/_build/assets/actors-HfZh_afh.js +24 -0
- package/.output/public/_build/assets/client-CGFoRcqH.js +3 -0
- package/.output/public/_build/assets/components-5MVu7IcD.js +1 -0
- package/.output/public/_build/assets/dist-BrJ_B8nU.js +1 -0
- package/.output/public/_build/assets/dist-DVo0HS5G.js +1 -0
- package/.output/public/_build/assets/dist-WrlGlK67.js +1 -0
- package/.output/public/_build/assets/entry-client-BurSTYr9.css +1 -0
- package/.output/public/_build/assets/entry-client-Do7ocrsL.js +8 -0
- package/.output/public/_build/assets/form-BxigYd7J.css +1 -0
- package/.output/public/_build/assets/form.module-BecmEfV_.js +1 -0
- package/.output/public/_build/assets/index-BHn6sAgH.js +23 -0
- package/.output/public/_build/assets/index-BSLqnqN7.js +8 -0
- package/.output/public/_build/assets/index-B_xLBDOo.css +1 -0
- package/.output/public/_build/assets/instance-tpMrvJNZ.js +35 -0
- package/.output/public/_build/assets/label-Mv8GZ4jc.js +1 -0
- package/.output/public/_build/assets/objects-DPb8DI8A.css +1 -0
- package/.output/public/_build/assets/objects-DR9TfL-V.js +25 -0
- package/.output/public/_build/assets/relay-runtime-BX3uubtA.js +7 -0
- package/.output/public/_build/assets/routing-DMN2NHu6.js +1 -0
- package/.output/public/_build/assets/sign-in-B67sv7z8.js +10 -0
- package/.output/public/_build/assets/web-DB_Nkq2D.js +1 -0
- package/.output/public/apple-touch-icon.png +0 -0
- package/.output/public/favicon.ico +0 -0
- package/.output/public/icon-192.png +0 -0
- package/.output/public/icon-512.png +0 -0
- package/.output/public/icon-mask.png +0 -0
- package/.output/public/icon.svg +395 -0
- package/.output/public/manifest.webmanifest +13 -0
- package/.output/server/_...404_-DDEH5apf.mjs +16 -0
- package/.output/server/_challengeId_-C_n_Bww9.mjs +100 -0
- package/.output/server/_chunks/ssr-renderer.mjs +26 -0
- package/.output/server/_id_-DqytvZEf.mjs +505 -0
- package/.output/server/_libs/@shikijs/core+[...].mjs +7173 -0
- package/.output/server/_libs/@shikijs/engine-javascript+[...].mjs +3110 -0
- package/.output/server/_libs/babel__runtime.mjs +243 -0
- package/.output/server/_libs/dequal.mjs +25 -0
- package/.output/server/_libs/faker-js__faker.mjs +13150 -0
- package/.output/server/_libs/fbjs.mjs +115 -0
- package/.output/server/_libs/h3+rou3+srvx.mjs +650 -0
- package/.output/server/_libs/hookable.mjs +41 -0
- package/.output/server/_libs/invariant.mjs +36 -0
- package/.output/server/_libs/relay-runtime.mjs +9704 -0
- package/.output/server/_libs/seroval-plugins.mjs +563 -0
- package/.output/server/_libs/seroval.mjs +2956 -0
- package/.output/server/_libs/shikijs__langs.mjs +3 -0
- package/.output/server/_libs/shikijs__themes.mjs +7 -0
- package/.output/server/_libs/solid-js.mjs +1248 -0
- package/.output/server/_libs/solid-relay+tiny-invariant.mjs +1029 -0
- package/.output/server/_libs/ufo.mjs +64 -0
- package/.output/server/_libs/valibot.mjs +711 -0
- package/.output/server/_runtime.mjs +33 -0
- package/.output/server/_slug_-CBOaSqoF.mjs +978 -0
- package/.output/server/_ssr/ActorDetailQuery.graphql-C1mWRP1B.mjs +283 -0
- package/.output/server/_ssr/CompleteLoginChallenge.graphql-CM7o_Md1.mjs +78 -0
- package/.output/server/_ssr/CopyButton-CQNR5D1y.mjs +43 -0
- package/.output/server/_ssr/CreateInstanceMutation.graphql-C-h2lGxz.mjs +116 -0
- package/.output/server/_ssr/CreateObjectMutation.graphql-C393Hp7q.mjs +166 -0
- package/.output/server/_ssr/GenerateActorsMutation.graphql-D2ADtn1j.mjs +163 -0
- package/.output/server/_ssr/GetHostQuery.graphql-C45XQo1i.mjs +127 -0
- package/.output/server/_ssr/HomeViewerQuery.graphql-Dote4Pkz.mjs +81 -0
- package/.output/server/_ssr/InstanceActorListQuery.graphql-DgItgN5t.mjs +167 -0
- package/.output/server/_ssr/InstanceDetailQuery.graphql-DP5wWWjX.mjs +367 -0
- package/.output/server/_ssr/JNCCF6MP-BAZlBnvx.mjs +419 -0
- package/.output/server/_ssr/LP6E37CW-D2Ih_b_K.mjs +163 -0
- package/.output/server/_ssr/SignInMutation.graphql-BBXmiay6.mjs +72 -0
- package/.output/server/_ssr/TSB6MOZK-D06WZb6o.mjs +166 -0
- package/.output/server/_ssr/Toast-Bb1gcxED.mjs +947 -0
- package/.output/server/_ssr/WorkspaceQuery.graphql-DnCO8t-4.mjs +153 -0
- package/.output/server/_ssr/about-CD3QIgf_.mjs +14 -0
- package/.output/server/_ssr/actors-CMWf-xQU.mjs +1160 -0
- package/.output/server/_ssr/dist-D6rgyh-L.mjs +81 -0
- package/.output/server/_ssr/dist-I7KRMRbA.mjs +432 -0
- package/.output/server/_ssr/form.module-CTvIl1lm.mjs +192 -0
- package/.output/server/_ssr/index-C4crD6q-.mjs +347 -0
- package/.output/server/_ssr/index-yuhuc6-X.mjs +111 -0
- package/.output/server/_ssr/instance-ZYWGeWd3.mjs +280 -0
- package/.output/server/_ssr/label-DAXzanI9.mjs +9 -0
- package/.output/server/_ssr/objects-D5MVukzB.mjs +4316 -0
- package/.output/server/_ssr/routing-DKTLkkbY.mjs +620 -0
- package/.output/server/_ssr/sign-in-CNHZb_zL.mjs +264 -0
- package/.output/server/_ssr/ssr.mjs +6121 -0
- package/.output/server/index.mjs +684 -0
- package/LICENSE +661 -0
- package/README.md +143 -2
- package/dist/bridge.d.mts +39 -0
- package/dist/bridge.mjs +104 -0
- package/dist/bridge.mjs.map +1 -0
- package/dist/request-policy.d.mts +8 -0
- package/dist/request-policy.mjs +94 -0
- package/dist/request-policy.mjs.map +1 -0
- package/dist/runtime.d.mts +14 -0
- package/dist/runtime.mjs +44 -0
- package/dist/runtime.mjs.map +1 -0
- package/package.json +123 -3
|
@@ -0,0 +1,947 @@
|
|
|
1
|
+
import { r as __toESM } from "../_runtime.mjs";
|
|
2
|
+
import { n as require_relay_runtime } from "../_libs/relay-runtime.mjs";
|
|
3
|
+
import { $ as splitProps, D as Show, F as createContext, H as createUniqueId, I as createEffect, J as onCleanup, K as mergeProps, L as createMemo, N as createComponent, V as createSignal, Y as onMount, h as ssr, l as Portal, n as createStore, nt as useContext, q as on, tt as untrack, v as ssrHydrationKey, w as For } from "../_libs/solid-js.mjs";
|
|
4
|
+
import { D as mergeDefaultProps, S as isFunction, a as __export, c as contains, h as getDocument, i as Polymorphic, l as createGenerateId, n as ButtonRoot, o as callHandler, u as createRegisterId, v as getWindow } from "./JNCCF6MP-BAZlBnvx.mjs";
|
|
5
|
+
import { _ as safeParse, b as string, d as object, h as pipe, l as nonEmpty, m as picklist, p as parseJson } from "../_libs/valibot.mjs";
|
|
6
|
+
//#region node_modules/.nitro/vite/services/ssr/_build/assets/InstanceActorListQuery.graphql-Co_KwEO-.js
|
|
7
|
+
var import_relay_runtime = /* @__PURE__ */ __toESM(require_relay_runtime());
|
|
8
|
+
/**
|
|
9
|
+
* @generated SignedSource<<2cf63a91cd9704068a66b688800ac78d>>
|
|
10
|
+
* @lightSyntaxTransform
|
|
11
|
+
*/
|
|
12
|
+
var { ConcreteRequest } = import_relay_runtime?.default?.default?.__esModule ? import_relay_runtime.default.default : import_relay_runtime?.default?.__esModule ? import_relay_runtime.default : import_relay_runtime;
|
|
13
|
+
var node = function() {
|
|
14
|
+
var v0 = [{
|
|
15
|
+
"defaultValue": null,
|
|
16
|
+
"kind": "LocalArgument",
|
|
17
|
+
"name": "instanceId"
|
|
18
|
+
}], v1 = [{
|
|
19
|
+
"kind": "Variable",
|
|
20
|
+
"name": "id",
|
|
21
|
+
"variableName": "instanceId"
|
|
22
|
+
}], v2 = {
|
|
23
|
+
"alias": null,
|
|
24
|
+
"args": null,
|
|
25
|
+
"kind": "ScalarField",
|
|
26
|
+
"name": "id",
|
|
27
|
+
"storageKey": null
|
|
28
|
+
}, v3 = {
|
|
29
|
+
"alias": null,
|
|
30
|
+
"args": null,
|
|
31
|
+
"kind": "ScalarField",
|
|
32
|
+
"name": "host",
|
|
33
|
+
"storageKey": null
|
|
34
|
+
}, v4 = {
|
|
35
|
+
"alias": null,
|
|
36
|
+
"args": null,
|
|
37
|
+
"kind": "ScalarField",
|
|
38
|
+
"name": "url",
|
|
39
|
+
"storageKey": null
|
|
40
|
+
}, v5 = {
|
|
41
|
+
"alias": null,
|
|
42
|
+
"args": [{
|
|
43
|
+
"kind": "Literal",
|
|
44
|
+
"name": "first",
|
|
45
|
+
"value": 100
|
|
46
|
+
}],
|
|
47
|
+
"concreteType": "InstanceActorsConnection",
|
|
48
|
+
"kind": "LinkedField",
|
|
49
|
+
"name": "actors",
|
|
50
|
+
"plural": false,
|
|
51
|
+
"selections": [{
|
|
52
|
+
"alias": null,
|
|
53
|
+
"args": null,
|
|
54
|
+
"kind": "ScalarField",
|
|
55
|
+
"name": "totalCount",
|
|
56
|
+
"storageKey": null
|
|
57
|
+
}, {
|
|
58
|
+
"alias": null,
|
|
59
|
+
"args": null,
|
|
60
|
+
"concreteType": "InstanceActorsConnectionEdge",
|
|
61
|
+
"kind": "LinkedField",
|
|
62
|
+
"name": "edges",
|
|
63
|
+
"plural": true,
|
|
64
|
+
"selections": [{
|
|
65
|
+
"alias": null,
|
|
66
|
+
"args": null,
|
|
67
|
+
"concreteType": "Actor",
|
|
68
|
+
"kind": "LinkedField",
|
|
69
|
+
"name": "node",
|
|
70
|
+
"plural": false,
|
|
71
|
+
"selections": [
|
|
72
|
+
{
|
|
73
|
+
"alias": null,
|
|
74
|
+
"args": null,
|
|
75
|
+
"kind": "ScalarField",
|
|
76
|
+
"name": "handle",
|
|
77
|
+
"storageKey": null
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"alias": null,
|
|
81
|
+
"args": null,
|
|
82
|
+
"kind": "ScalarField",
|
|
83
|
+
"name": "iri",
|
|
84
|
+
"storageKey": null
|
|
85
|
+
},
|
|
86
|
+
v2
|
|
87
|
+
],
|
|
88
|
+
"storageKey": null
|
|
89
|
+
}],
|
|
90
|
+
"storageKey": null
|
|
91
|
+
}],
|
|
92
|
+
"storageKey": "actors(first:100)"
|
|
93
|
+
};
|
|
94
|
+
return {
|
|
95
|
+
"fragment": {
|
|
96
|
+
"argumentDefinitions": v0,
|
|
97
|
+
"kind": "Fragment",
|
|
98
|
+
"metadata": null,
|
|
99
|
+
"name": "InstanceActorListQuery",
|
|
100
|
+
"selections": [{
|
|
101
|
+
"alias": "instance",
|
|
102
|
+
"args": v1,
|
|
103
|
+
"concreteType": null,
|
|
104
|
+
"kind": "LinkedField",
|
|
105
|
+
"name": "node",
|
|
106
|
+
"plural": false,
|
|
107
|
+
"selections": [{
|
|
108
|
+
"kind": "InlineFragment",
|
|
109
|
+
"selections": [
|
|
110
|
+
v2,
|
|
111
|
+
v3,
|
|
112
|
+
v4,
|
|
113
|
+
v5
|
|
114
|
+
],
|
|
115
|
+
"type": "Instance",
|
|
116
|
+
"abstractKey": null
|
|
117
|
+
}],
|
|
118
|
+
"storageKey": null
|
|
119
|
+
}],
|
|
120
|
+
"type": "Query",
|
|
121
|
+
"abstractKey": null
|
|
122
|
+
},
|
|
123
|
+
"kind": "Request",
|
|
124
|
+
"operation": {
|
|
125
|
+
"argumentDefinitions": v0,
|
|
126
|
+
"kind": "Operation",
|
|
127
|
+
"name": "InstanceActorListQuery",
|
|
128
|
+
"selections": [{
|
|
129
|
+
"alias": "instance",
|
|
130
|
+
"args": v1,
|
|
131
|
+
"concreteType": null,
|
|
132
|
+
"kind": "LinkedField",
|
|
133
|
+
"name": "node",
|
|
134
|
+
"plural": false,
|
|
135
|
+
"selections": [
|
|
136
|
+
{
|
|
137
|
+
"alias": null,
|
|
138
|
+
"args": null,
|
|
139
|
+
"kind": "ScalarField",
|
|
140
|
+
"name": "__typename",
|
|
141
|
+
"storageKey": null
|
|
142
|
+
},
|
|
143
|
+
v2,
|
|
144
|
+
{
|
|
145
|
+
"kind": "InlineFragment",
|
|
146
|
+
"selections": [
|
|
147
|
+
v3,
|
|
148
|
+
v4,
|
|
149
|
+
v5
|
|
150
|
+
],
|
|
151
|
+
"type": "Instance",
|
|
152
|
+
"abstractKey": null
|
|
153
|
+
}
|
|
154
|
+
],
|
|
155
|
+
"storageKey": null
|
|
156
|
+
}]
|
|
157
|
+
},
|
|
158
|
+
"params": {
|
|
159
|
+
"cacheID": "2362d2d169cd79f7485c1243b70c22d7",
|
|
160
|
+
"id": null,
|
|
161
|
+
"metadata": {},
|
|
162
|
+
"name": "InstanceActorListQuery",
|
|
163
|
+
"operationKind": "query",
|
|
164
|
+
"text": "query InstanceActorListQuery(\n $instanceId: ID!\n) {\n instance: node(id: $instanceId) {\n __typename\n ... on Instance {\n id\n host\n url\n actors(first: 100) {\n totalCount\n edges {\n node {\n handle\n iri\n id\n }\n }\n }\n }\n id\n }\n}\n"
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
}();
|
|
168
|
+
node.hash = "dfa1afc83b486dcdebbeb32921ca4595";
|
|
169
|
+
//#endregion
|
|
170
|
+
//#region node_modules/.nitro/vite/services/ssr/_build/assets/Toast-Bb1gcxED.js
|
|
171
|
+
var extractCSSregex = /((?:--)?(?:\w+-?)+)\s*:\s*([^;]*)/g;
|
|
172
|
+
/**
|
|
173
|
+
* converts inline string styles to object form
|
|
174
|
+
* @example
|
|
175
|
+
* const styles = stringStyleToObject("margin: 24px; border: 1px solid #121212");
|
|
176
|
+
* styles; // { margin: "24px", border: "1px solid #121212" }
|
|
177
|
+
* */
|
|
178
|
+
function stringStyleToObject(style) {
|
|
179
|
+
const object = {};
|
|
180
|
+
let match;
|
|
181
|
+
while (match = extractCSSregex.exec(style)) object[match[1]] = match[2];
|
|
182
|
+
return object;
|
|
183
|
+
}
|
|
184
|
+
function combineStyle(a, b) {
|
|
185
|
+
if (typeof a === "string") {
|
|
186
|
+
if (typeof b === "string") return `${a};${b}`;
|
|
187
|
+
a = stringStyleToObject(a);
|
|
188
|
+
} else if (typeof b === "string") b = stringStyleToObject(b);
|
|
189
|
+
return {
|
|
190
|
+
...a,
|
|
191
|
+
...b
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
var DATA_TOP_LAYER_ATTR = "data-kb-top-layer";
|
|
195
|
+
var originalBodyPointerEvents;
|
|
196
|
+
var hasDisabledBodyPointerEvents = false;
|
|
197
|
+
var layers = [];
|
|
198
|
+
function indexOf(node) {
|
|
199
|
+
return layers.findIndex((layer) => layer.node === node);
|
|
200
|
+
}
|
|
201
|
+
function find(node) {
|
|
202
|
+
return layers[indexOf(node)];
|
|
203
|
+
}
|
|
204
|
+
function isTopMostLayer(node) {
|
|
205
|
+
return layers.length > 0 && layers[layers.length - 1].node === node;
|
|
206
|
+
}
|
|
207
|
+
function getPointerBlockingLayers() {
|
|
208
|
+
return layers.filter((layer) => layer.isPointerBlocking);
|
|
209
|
+
}
|
|
210
|
+
function getTopMostPointerBlockingLayer() {
|
|
211
|
+
return [...getPointerBlockingLayers()].slice(-1)[0];
|
|
212
|
+
}
|
|
213
|
+
function hasPointerBlockingLayer() {
|
|
214
|
+
return getPointerBlockingLayers().length > 0;
|
|
215
|
+
}
|
|
216
|
+
function isBelowPointerBlockingLayer(node) {
|
|
217
|
+
const highestBlockingIndex = indexOf(getTopMostPointerBlockingLayer()?.node);
|
|
218
|
+
return indexOf(node) < highestBlockingIndex;
|
|
219
|
+
}
|
|
220
|
+
function addLayer(layer) {
|
|
221
|
+
layers.push(layer);
|
|
222
|
+
}
|
|
223
|
+
function removeLayer(node) {
|
|
224
|
+
const index = indexOf(node);
|
|
225
|
+
if (index < 0) return;
|
|
226
|
+
layers.splice(index, 1);
|
|
227
|
+
}
|
|
228
|
+
function assignPointerEventToLayers() {
|
|
229
|
+
for (const { node } of layers) node.style.pointerEvents = isBelowPointerBlockingLayer(node) ? "none" : "auto";
|
|
230
|
+
}
|
|
231
|
+
function disableBodyPointerEvents(node) {
|
|
232
|
+
if (hasPointerBlockingLayer() && !hasDisabledBodyPointerEvents) {
|
|
233
|
+
const ownerDocument = getDocument(node);
|
|
234
|
+
originalBodyPointerEvents = document.body.style.pointerEvents;
|
|
235
|
+
ownerDocument.body.style.pointerEvents = "none";
|
|
236
|
+
hasDisabledBodyPointerEvents = true;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
function restoreBodyPointerEvents(node) {
|
|
240
|
+
if (hasPointerBlockingLayer()) return;
|
|
241
|
+
const ownerDocument = getDocument(node);
|
|
242
|
+
ownerDocument.body.style.pointerEvents = originalBodyPointerEvents;
|
|
243
|
+
if (ownerDocument.body.style.length === 0) ownerDocument.body.removeAttribute("style");
|
|
244
|
+
hasDisabledBodyPointerEvents = false;
|
|
245
|
+
}
|
|
246
|
+
var layerStack = {
|
|
247
|
+
layers,
|
|
248
|
+
isTopMostLayer,
|
|
249
|
+
hasPointerBlockingLayer,
|
|
250
|
+
isBelowPointerBlockingLayer,
|
|
251
|
+
addLayer,
|
|
252
|
+
removeLayer,
|
|
253
|
+
indexOf,
|
|
254
|
+
find,
|
|
255
|
+
assignPointerEventToLayers,
|
|
256
|
+
disableBodyPointerEvents,
|
|
257
|
+
restoreBodyPointerEvents
|
|
258
|
+
};
|
|
259
|
+
var access = (v) => typeof v === "function" ? v() : v;
|
|
260
|
+
var createPresence = (props) => {
|
|
261
|
+
const refStyles = createMemo(() => {
|
|
262
|
+
const element = access(props.element);
|
|
263
|
+
if (!element) return;
|
|
264
|
+
return getComputedStyle(element);
|
|
265
|
+
});
|
|
266
|
+
const getAnimationName = () => {
|
|
267
|
+
return refStyles()?.animationName ?? "none";
|
|
268
|
+
};
|
|
269
|
+
const [presentState, setPresentStateInternal] = createSignal(access(props.show) ? "present" : "hidden");
|
|
270
|
+
const setPresentState = (state) => {
|
|
271
|
+
setPresentStateInternal(state);
|
|
272
|
+
props.onStateChange?.(state);
|
|
273
|
+
};
|
|
274
|
+
let animationName = "none";
|
|
275
|
+
createEffect((prevShow) => {
|
|
276
|
+
const show = access(props.show);
|
|
277
|
+
untrack(() => {
|
|
278
|
+
if (prevShow === show) return show;
|
|
279
|
+
const prevAnimationName = animationName;
|
|
280
|
+
const currentAnimationName = getAnimationName();
|
|
281
|
+
if (show) setPresentState("present");
|
|
282
|
+
else if (currentAnimationName === "none" || refStyles()?.display === "none") setPresentState("hidden");
|
|
283
|
+
else if (prevShow === true && prevAnimationName !== currentAnimationName) setPresentState("hiding");
|
|
284
|
+
else setPresentState("hidden");
|
|
285
|
+
});
|
|
286
|
+
return show;
|
|
287
|
+
}, access(props.show));
|
|
288
|
+
createEffect(() => {
|
|
289
|
+
const element = access(props.element);
|
|
290
|
+
if (!element) return;
|
|
291
|
+
const handleAnimationStart = (event) => {
|
|
292
|
+
if (event.target === element) animationName = getAnimationName();
|
|
293
|
+
};
|
|
294
|
+
const handleAnimationEnd = (event) => {
|
|
295
|
+
const isCurrentAnimation = getAnimationName().includes(event.animationName);
|
|
296
|
+
if (event.target === element && isCurrentAnimation && presentState() === "hiding") setPresentState("hidden");
|
|
297
|
+
};
|
|
298
|
+
element.addEventListener("animationstart", handleAnimationStart);
|
|
299
|
+
element.addEventListener("animationcancel", handleAnimationEnd);
|
|
300
|
+
element.addEventListener("animationend", handleAnimationEnd);
|
|
301
|
+
onCleanup(() => {
|
|
302
|
+
element.removeEventListener("animationstart", handleAnimationStart);
|
|
303
|
+
element.removeEventListener("animationcancel", handleAnimationEnd);
|
|
304
|
+
element.removeEventListener("animationend", handleAnimationEnd);
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
return {
|
|
308
|
+
present: () => presentState() === "present" || presentState() === "hiding",
|
|
309
|
+
state: presentState
|
|
310
|
+
};
|
|
311
|
+
};
|
|
312
|
+
var index_default = createPresence;
|
|
313
|
+
__export({}, {
|
|
314
|
+
CloseButton: () => ToastCloseButton,
|
|
315
|
+
Description: () => ToastDescription,
|
|
316
|
+
List: () => ToastList,
|
|
317
|
+
ProgressFill: () => ToastProgressFill,
|
|
318
|
+
ProgressTrack: () => ToastProgressTrack,
|
|
319
|
+
Region: () => ToastRegion$1,
|
|
320
|
+
Root: () => ToastRoot,
|
|
321
|
+
Title: () => ToastTitle,
|
|
322
|
+
Toast: () => Toast,
|
|
323
|
+
toaster: () => toaster,
|
|
324
|
+
useToastContext: () => useToastContext
|
|
325
|
+
});
|
|
326
|
+
var ToastContext = createContext();
|
|
327
|
+
function useToastContext() {
|
|
328
|
+
const context = useContext(ToastContext);
|
|
329
|
+
if (context === void 0) throw new Error("[kobalte]: `useToastContext` must be used within a `Toast.Root` component");
|
|
330
|
+
return context;
|
|
331
|
+
}
|
|
332
|
+
function ToastCloseButton(props) {
|
|
333
|
+
const context = useToastContext();
|
|
334
|
+
const [local, others] = splitProps(props, ["aria-label", "onClick"]);
|
|
335
|
+
const onClick = (e) => {
|
|
336
|
+
callHandler(e, local.onClick);
|
|
337
|
+
context.close();
|
|
338
|
+
};
|
|
339
|
+
return createComponent(ButtonRoot, mergeProps({
|
|
340
|
+
get ["aria-label"]() {
|
|
341
|
+
return local["aria-label"] || context.translations().close;
|
|
342
|
+
},
|
|
343
|
+
onClick
|
|
344
|
+
}, others));
|
|
345
|
+
}
|
|
346
|
+
function ToastDescription(props) {
|
|
347
|
+
const context = useToastContext();
|
|
348
|
+
const [local, others] = splitProps(mergeDefaultProps({ id: context.generateId("description") }, props), ["id"]);
|
|
349
|
+
createEffect(() => onCleanup(context.registerDescriptionId(local.id)));
|
|
350
|
+
return createComponent(Polymorphic, mergeProps({
|
|
351
|
+
as: "div",
|
|
352
|
+
get id() {
|
|
353
|
+
return local.id;
|
|
354
|
+
}
|
|
355
|
+
}, others));
|
|
356
|
+
}
|
|
357
|
+
var ToastRegionContext = createContext();
|
|
358
|
+
function useToastRegionContext() {
|
|
359
|
+
const context = useContext(ToastRegionContext);
|
|
360
|
+
if (context === void 0) throw new Error("[kobalte]: `useToastRegionContext` must be used within a `Toast.Region` component");
|
|
361
|
+
return context;
|
|
362
|
+
}
|
|
363
|
+
function ToastList(props) {
|
|
364
|
+
let ref;
|
|
365
|
+
const context = useToastRegionContext();
|
|
366
|
+
const [local, others] = splitProps(props, [
|
|
367
|
+
"ref",
|
|
368
|
+
"onFocusIn",
|
|
369
|
+
"onFocusOut",
|
|
370
|
+
"onPointerMove",
|
|
371
|
+
"onPointerLeave"
|
|
372
|
+
]);
|
|
373
|
+
const onFocusIn = (e) => {
|
|
374
|
+
callHandler(e, local.onFocusIn);
|
|
375
|
+
if (context.pauseOnInteraction() && !context.isPaused()) context.pauseAllTimer();
|
|
376
|
+
};
|
|
377
|
+
const onFocusOut = (e) => {
|
|
378
|
+
callHandler(e, local.onFocusOut);
|
|
379
|
+
if (!contains(ref, e.relatedTarget)) context.resumeAllTimer();
|
|
380
|
+
};
|
|
381
|
+
const onPointerMove = (e) => {
|
|
382
|
+
callHandler(e, local.onPointerMove);
|
|
383
|
+
if (context.pauseOnInteraction() && !context.isPaused()) context.pauseAllTimer();
|
|
384
|
+
};
|
|
385
|
+
const onPointerLeave = (e) => {
|
|
386
|
+
callHandler(e, local.onPointerLeave);
|
|
387
|
+
if (!contains(ref, getDocument(ref).activeElement)) context.resumeAllTimer();
|
|
388
|
+
};
|
|
389
|
+
createEffect(on([() => ref, () => context.hotkey()], ([ref2, hotkey]) => {}));
|
|
390
|
+
createEffect(() => {
|
|
391
|
+
if (!context.pauseOnPageIdle()) return;
|
|
392
|
+
const win = getWindow(ref);
|
|
393
|
+
win.addEventListener("blur", context.pauseAllTimer);
|
|
394
|
+
win.addEventListener("focus", context.resumeAllTimer);
|
|
395
|
+
onCleanup(() => {
|
|
396
|
+
win.removeEventListener("blur", context.pauseAllTimer);
|
|
397
|
+
win.removeEventListener("focus", context.resumeAllTimer);
|
|
398
|
+
});
|
|
399
|
+
});
|
|
400
|
+
return createComponent(Polymorphic, mergeProps({
|
|
401
|
+
as: "ol",
|
|
402
|
+
tabIndex: -1,
|
|
403
|
+
onFocusIn,
|
|
404
|
+
onFocusOut,
|
|
405
|
+
onPointerMove,
|
|
406
|
+
onPointerLeave
|
|
407
|
+
}, others, { get children() {
|
|
408
|
+
return createComponent(For, {
|
|
409
|
+
get each() {
|
|
410
|
+
return context.toasts();
|
|
411
|
+
},
|
|
412
|
+
children: (toast) => toast.toastComponent({ get toastId() {
|
|
413
|
+
return toast.id;
|
|
414
|
+
} })
|
|
415
|
+
});
|
|
416
|
+
} }));
|
|
417
|
+
}
|
|
418
|
+
function ToastProgressFill(props) {
|
|
419
|
+
const rootContext = useToastRegionContext();
|
|
420
|
+
const context = useToastContext();
|
|
421
|
+
const [local, others] = splitProps(props, ["style"]);
|
|
422
|
+
const [lifeTime, setLifeTime] = createSignal(100);
|
|
423
|
+
let totalElapsedTime = 0;
|
|
424
|
+
createEffect(() => {
|
|
425
|
+
if (rootContext.isPaused() || context.isPersistent()) return;
|
|
426
|
+
const intervalId = setInterval(() => {
|
|
427
|
+
const elapsedTime = (/* @__PURE__ */ new Date()).getTime() - context.closeTimerStartTime() + totalElapsedTime;
|
|
428
|
+
const life = Math.trunc(100 - elapsedTime / context.duration() * 100);
|
|
429
|
+
setLifeTime(life < 0 ? 0 : life);
|
|
430
|
+
});
|
|
431
|
+
onCleanup(() => {
|
|
432
|
+
totalElapsedTime += (/* @__PURE__ */ new Date()).getTime() - context.closeTimerStartTime();
|
|
433
|
+
clearInterval(intervalId);
|
|
434
|
+
});
|
|
435
|
+
});
|
|
436
|
+
return createComponent(Polymorphic, mergeProps({
|
|
437
|
+
as: "div",
|
|
438
|
+
get style() {
|
|
439
|
+
return combineStyle({ "--kb-toast-progress-fill-width": `${lifeTime()}%` }, local.style);
|
|
440
|
+
}
|
|
441
|
+
}, others));
|
|
442
|
+
}
|
|
443
|
+
function ToastProgressTrack(props) {
|
|
444
|
+
return createComponent(Polymorphic, mergeProps({
|
|
445
|
+
as: "div",
|
|
446
|
+
"aria-hidden": "true",
|
|
447
|
+
role: "presentation"
|
|
448
|
+
}, props));
|
|
449
|
+
}
|
|
450
|
+
var [state, setState] = createStore({ toasts: [] });
|
|
451
|
+
function add(toast) {
|
|
452
|
+
setState("toasts", (prev) => [...prev, toast]);
|
|
453
|
+
}
|
|
454
|
+
function get(id) {
|
|
455
|
+
return state.toasts.find((toast) => toast.id === id);
|
|
456
|
+
}
|
|
457
|
+
function update(id, toast) {
|
|
458
|
+
const index = state.toasts.findIndex((toast2) => toast2.id === id);
|
|
459
|
+
if (index !== -1) setState("toasts", (prev) => [
|
|
460
|
+
...prev.slice(0, index),
|
|
461
|
+
toast,
|
|
462
|
+
...prev.slice(index + 1)
|
|
463
|
+
]);
|
|
464
|
+
}
|
|
465
|
+
function dismiss(id) {
|
|
466
|
+
setState("toasts", (toast) => toast.id === id, "dismiss", true);
|
|
467
|
+
}
|
|
468
|
+
function remove(id) {
|
|
469
|
+
setState("toasts", (prev) => prev.filter((toast) => toast.id !== id));
|
|
470
|
+
}
|
|
471
|
+
function clear() {
|
|
472
|
+
setState("toasts", []);
|
|
473
|
+
}
|
|
474
|
+
var toastStore = {
|
|
475
|
+
toasts: () => state.toasts,
|
|
476
|
+
add,
|
|
477
|
+
get,
|
|
478
|
+
update,
|
|
479
|
+
dismiss,
|
|
480
|
+
remove,
|
|
481
|
+
clear
|
|
482
|
+
};
|
|
483
|
+
var TOAST_HOTKEY_PLACEHOLDER = "{hotkey}";
|
|
484
|
+
var TOAST_INTL_TRANSLATIONS = { close: "Close" };
|
|
485
|
+
var TOAST_REGION_INTL_TRANSLATIONS = { notifications: (hotkeyPlaceholder) => `Notifications (${hotkeyPlaceholder})` };
|
|
486
|
+
function ToastRegion$1(props) {
|
|
487
|
+
const [local, others] = splitProps(mergeDefaultProps({
|
|
488
|
+
id: `toast-region-${createUniqueId()}`,
|
|
489
|
+
hotkey: ["altKey", "KeyT"],
|
|
490
|
+
duration: 5e3,
|
|
491
|
+
limit: 3,
|
|
492
|
+
swipeDirection: "right",
|
|
493
|
+
swipeThreshold: 50,
|
|
494
|
+
pauseOnInteraction: true,
|
|
495
|
+
pauseOnPageIdle: true,
|
|
496
|
+
topLayer: true,
|
|
497
|
+
translations: TOAST_REGION_INTL_TRANSLATIONS
|
|
498
|
+
}, props), [
|
|
499
|
+
"translations",
|
|
500
|
+
"style",
|
|
501
|
+
"hotkey",
|
|
502
|
+
"duration",
|
|
503
|
+
"limit",
|
|
504
|
+
"swipeDirection",
|
|
505
|
+
"swipeThreshold",
|
|
506
|
+
"pauseOnInteraction",
|
|
507
|
+
"pauseOnPageIdle",
|
|
508
|
+
"topLayer",
|
|
509
|
+
"aria-label",
|
|
510
|
+
"regionId"
|
|
511
|
+
]);
|
|
512
|
+
const toasts = createMemo(() => toastStore.toasts().filter((toast) => toast.region === local.regionId && toast.dismiss === false).slice(0, local.limit));
|
|
513
|
+
const [isPaused, setIsPaused] = createSignal(false);
|
|
514
|
+
const hasToasts = () => toasts().length > 0;
|
|
515
|
+
const hotkeyLabel = () => {
|
|
516
|
+
return local.hotkey.join("+").replace(/Key/g, "").replace(/Digit/g, "");
|
|
517
|
+
};
|
|
518
|
+
const ariaLabel = () => {
|
|
519
|
+
return (local["aria-label"] || local.translations.notifications(TOAST_HOTKEY_PLACEHOLDER)).replace(TOAST_HOTKEY_PLACEHOLDER, hotkeyLabel());
|
|
520
|
+
};
|
|
521
|
+
const topLayerAttr = () => ({ [DATA_TOP_LAYER_ATTR]: local.topLayer ? "" : void 0 });
|
|
522
|
+
const context = {
|
|
523
|
+
isPaused,
|
|
524
|
+
toasts,
|
|
525
|
+
hotkey: () => local.hotkey,
|
|
526
|
+
duration: () => local.duration,
|
|
527
|
+
swipeDirection: () => local.swipeDirection,
|
|
528
|
+
swipeThreshold: () => local.swipeThreshold,
|
|
529
|
+
pauseOnInteraction: () => local.pauseOnInteraction,
|
|
530
|
+
pauseOnPageIdle: () => local.pauseOnPageIdle,
|
|
531
|
+
pauseAllTimer: () => setIsPaused(true),
|
|
532
|
+
resumeAllTimer: () => setIsPaused(false),
|
|
533
|
+
generateId: createGenerateId(() => others.id)
|
|
534
|
+
};
|
|
535
|
+
return createComponent(ToastRegionContext.Provider, {
|
|
536
|
+
value: context,
|
|
537
|
+
get children() {
|
|
538
|
+
return createComponent(Polymorphic, mergeProps({
|
|
539
|
+
as: "div",
|
|
540
|
+
role: "region",
|
|
541
|
+
tabIndex: -1,
|
|
542
|
+
get ["aria-label"]() {
|
|
543
|
+
return ariaLabel();
|
|
544
|
+
},
|
|
545
|
+
get style() {
|
|
546
|
+
return combineStyle({ "pointer-events": hasToasts() ? local.topLayer ? "auto" : void 0 : "none" }, local.style);
|
|
547
|
+
}
|
|
548
|
+
}, topLayerAttr, others));
|
|
549
|
+
}
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
var TOAST_SWIPE_START_EVENT = "toast.swipeStart";
|
|
553
|
+
var TOAST_SWIPE_MOVE_EVENT = "toast.swipeMove";
|
|
554
|
+
var TOAST_SWIPE_CANCEL_EVENT = "toast.swipeCancel";
|
|
555
|
+
var TOAST_SWIPE_END_EVENT = "toast.swipeEnd";
|
|
556
|
+
function ToastRoot(props) {
|
|
557
|
+
const rootContext = useToastRegionContext();
|
|
558
|
+
const [local, others] = splitProps(mergeDefaultProps({
|
|
559
|
+
id: `toast-${createUniqueId()}`,
|
|
560
|
+
priority: "high",
|
|
561
|
+
translations: TOAST_INTL_TRANSLATIONS
|
|
562
|
+
}, props), [
|
|
563
|
+
"ref",
|
|
564
|
+
"translations",
|
|
565
|
+
"toastId",
|
|
566
|
+
"style",
|
|
567
|
+
"priority",
|
|
568
|
+
"duration",
|
|
569
|
+
"persistent",
|
|
570
|
+
"onPause",
|
|
571
|
+
"onResume",
|
|
572
|
+
"onSwipeStart",
|
|
573
|
+
"onSwipeMove",
|
|
574
|
+
"onSwipeCancel",
|
|
575
|
+
"onSwipeEnd",
|
|
576
|
+
"onEscapeKeyDown",
|
|
577
|
+
"onKeyDown",
|
|
578
|
+
"onPointerDown",
|
|
579
|
+
"onPointerMove",
|
|
580
|
+
"onPointerUp"
|
|
581
|
+
]);
|
|
582
|
+
const [isOpen, setIsOpen] = createSignal(true);
|
|
583
|
+
const [titleId, setTitleId] = createSignal();
|
|
584
|
+
const [descriptionId, setDescriptionId] = createSignal();
|
|
585
|
+
const [isAnimationEnabled, setIsAnimationEnabled] = createSignal(true);
|
|
586
|
+
const [ref, setRef] = createSignal();
|
|
587
|
+
const { present } = index_default({
|
|
588
|
+
show: isOpen,
|
|
589
|
+
element: () => ref() ?? null
|
|
590
|
+
});
|
|
591
|
+
const duration = createMemo(() => local.duration || rootContext.duration());
|
|
592
|
+
let closeTimerId;
|
|
593
|
+
let closeTimerStartTime = 0;
|
|
594
|
+
let closeTimerRemainingTime = duration();
|
|
595
|
+
let pointerStart = null;
|
|
596
|
+
let swipeDelta = null;
|
|
597
|
+
const close = () => {
|
|
598
|
+
setIsOpen(false);
|
|
599
|
+
setIsAnimationEnabled(true);
|
|
600
|
+
};
|
|
601
|
+
const deleteToast = () => {
|
|
602
|
+
toastStore.remove(local.toastId);
|
|
603
|
+
};
|
|
604
|
+
const startTimer = (duration2) => {
|
|
605
|
+
if (!duration2 || local.persistent) return;
|
|
606
|
+
window.clearTimeout(closeTimerId);
|
|
607
|
+
closeTimerStartTime = (/* @__PURE__ */ new Date()).getTime();
|
|
608
|
+
closeTimerId = window.setTimeout(close, duration2);
|
|
609
|
+
};
|
|
610
|
+
const resumeTimer = () => {
|
|
611
|
+
startTimer(closeTimerRemainingTime);
|
|
612
|
+
local.onResume?.();
|
|
613
|
+
};
|
|
614
|
+
const pauseTimer = () => {
|
|
615
|
+
const elapsedTime = (/* @__PURE__ */ new Date()).getTime() - closeTimerStartTime;
|
|
616
|
+
closeTimerRemainingTime = closeTimerRemainingTime - elapsedTime;
|
|
617
|
+
window.clearTimeout(closeTimerId);
|
|
618
|
+
local.onPause?.();
|
|
619
|
+
};
|
|
620
|
+
const onKeyDown = (e) => {
|
|
621
|
+
callHandler(e, local.onKeyDown);
|
|
622
|
+
if (e.key !== "Escape") return;
|
|
623
|
+
local.onEscapeKeyDown?.(e);
|
|
624
|
+
if (!e.defaultPrevented) close();
|
|
625
|
+
};
|
|
626
|
+
const onPointerDown = (e) => {
|
|
627
|
+
callHandler(e, local.onPointerDown);
|
|
628
|
+
if (e.button !== 0) return;
|
|
629
|
+
pointerStart = {
|
|
630
|
+
x: e.clientX,
|
|
631
|
+
y: e.clientY
|
|
632
|
+
};
|
|
633
|
+
};
|
|
634
|
+
const onPointerMove = (e) => {
|
|
635
|
+
callHandler(e, local.onPointerMove);
|
|
636
|
+
if (!pointerStart) return;
|
|
637
|
+
const x = e.clientX - pointerStart.x;
|
|
638
|
+
const y = e.clientY - pointerStart.y;
|
|
639
|
+
const hasSwipeMoveStarted = Boolean(swipeDelta);
|
|
640
|
+
const isHorizontalSwipe = ["left", "right"].includes(rootContext.swipeDirection());
|
|
641
|
+
const clamp = ["left", "up"].includes(rootContext.swipeDirection()) ? Math.min : Math.max;
|
|
642
|
+
const clampedX = isHorizontalSwipe ? clamp(0, x) : 0;
|
|
643
|
+
const clampedY = !isHorizontalSwipe ? clamp(0, y) : 0;
|
|
644
|
+
const moveStartBuffer = e.pointerType === "touch" ? 10 : 2;
|
|
645
|
+
const delta = {
|
|
646
|
+
x: clampedX,
|
|
647
|
+
y: clampedY
|
|
648
|
+
};
|
|
649
|
+
const eventDetail = {
|
|
650
|
+
originalEvent: e,
|
|
651
|
+
delta
|
|
652
|
+
};
|
|
653
|
+
if (hasSwipeMoveStarted) {
|
|
654
|
+
swipeDelta = delta;
|
|
655
|
+
handleAndDispatchCustomEvent(TOAST_SWIPE_MOVE_EVENT, local.onSwipeMove, eventDetail);
|
|
656
|
+
const { x: x2, y: y2 } = delta;
|
|
657
|
+
e.currentTarget.setAttribute("data-swipe", "move");
|
|
658
|
+
e.currentTarget.style.setProperty("--kb-toast-swipe-move-x", `${x2}px`);
|
|
659
|
+
e.currentTarget.style.setProperty("--kb-toast-swipe-move-y", `${y2}px`);
|
|
660
|
+
} else if (isDeltaInDirection(delta, rootContext.swipeDirection(), moveStartBuffer)) {
|
|
661
|
+
swipeDelta = delta;
|
|
662
|
+
handleAndDispatchCustomEvent(TOAST_SWIPE_START_EVENT, local.onSwipeStart, eventDetail);
|
|
663
|
+
e.currentTarget.setAttribute("data-swipe", "start");
|
|
664
|
+
e.target.setPointerCapture(e.pointerId);
|
|
665
|
+
} else if (Math.abs(x) > moveStartBuffer || Math.abs(y) > moveStartBuffer) pointerStart = null;
|
|
666
|
+
};
|
|
667
|
+
const onPointerUp = (e) => {
|
|
668
|
+
callHandler(e, local.onPointerUp);
|
|
669
|
+
const delta = swipeDelta;
|
|
670
|
+
const target = e.target;
|
|
671
|
+
if (target.hasPointerCapture(e.pointerId)) target.releasePointerCapture(e.pointerId);
|
|
672
|
+
swipeDelta = null;
|
|
673
|
+
pointerStart = null;
|
|
674
|
+
if (delta) {
|
|
675
|
+
const toast = e.currentTarget;
|
|
676
|
+
const eventDetail = {
|
|
677
|
+
originalEvent: e,
|
|
678
|
+
delta
|
|
679
|
+
};
|
|
680
|
+
if (isDeltaInDirection(delta, rootContext.swipeDirection(), rootContext.swipeThreshold())) {
|
|
681
|
+
handleAndDispatchCustomEvent(TOAST_SWIPE_END_EVENT, local.onSwipeEnd, eventDetail);
|
|
682
|
+
const { x, y } = delta;
|
|
683
|
+
e.currentTarget.setAttribute("data-swipe", "end");
|
|
684
|
+
e.currentTarget.style.removeProperty("--kb-toast-swipe-move-x");
|
|
685
|
+
e.currentTarget.style.removeProperty("--kb-toast-swipe-move-y");
|
|
686
|
+
e.currentTarget.style.setProperty("--kb-toast-swipe-end-x", `${x}px`);
|
|
687
|
+
e.currentTarget.style.setProperty("--kb-toast-swipe-end-y", `${y}px`);
|
|
688
|
+
close();
|
|
689
|
+
} else {
|
|
690
|
+
handleAndDispatchCustomEvent(TOAST_SWIPE_CANCEL_EVENT, local.onSwipeCancel, eventDetail);
|
|
691
|
+
e.currentTarget.setAttribute("data-swipe", "cancel");
|
|
692
|
+
e.currentTarget.style.removeProperty("--kb-toast-swipe-move-x");
|
|
693
|
+
e.currentTarget.style.removeProperty("--kb-toast-swipe-move-y");
|
|
694
|
+
e.currentTarget.style.removeProperty("--kb-toast-swipe-end-x");
|
|
695
|
+
e.currentTarget.style.removeProperty("--kb-toast-swipe-end-y");
|
|
696
|
+
}
|
|
697
|
+
toast.addEventListener("click", (event) => event.preventDefault(), { once: true });
|
|
698
|
+
}
|
|
699
|
+
};
|
|
700
|
+
onMount(() => {
|
|
701
|
+
if (rootContext.toasts().find((toast) => toast.id === local.toastId && toast.update)) setIsAnimationEnabled(false);
|
|
702
|
+
});
|
|
703
|
+
createEffect(on(() => rootContext.isPaused(), (isPaused) => {
|
|
704
|
+
if (isPaused) pauseTimer();
|
|
705
|
+
else resumeTimer();
|
|
706
|
+
}, { defer: true }));
|
|
707
|
+
createEffect(on([isOpen, duration], ([isOpen2, duration2]) => {
|
|
708
|
+
if (isOpen2 && !rootContext.isPaused()) startTimer(duration2);
|
|
709
|
+
}));
|
|
710
|
+
createEffect(on(() => toastStore.get(local.toastId)?.dismiss, (dismiss3) => dismiss3 && close()));
|
|
711
|
+
createEffect(on(() => present(), (isPresent) => !isPresent && deleteToast()));
|
|
712
|
+
const context = {
|
|
713
|
+
translations: () => local.translations,
|
|
714
|
+
close,
|
|
715
|
+
duration,
|
|
716
|
+
isPersistent: () => local.persistent ?? false,
|
|
717
|
+
closeTimerStartTime: () => closeTimerStartTime,
|
|
718
|
+
generateId: createGenerateId(() => others.id),
|
|
719
|
+
registerTitleId: createRegisterId(setTitleId),
|
|
720
|
+
registerDescriptionId: createRegisterId(setDescriptionId)
|
|
721
|
+
};
|
|
722
|
+
return createComponent(Show, {
|
|
723
|
+
get when() {
|
|
724
|
+
return present();
|
|
725
|
+
},
|
|
726
|
+
get children() {
|
|
727
|
+
return createComponent(ToastContext.Provider, {
|
|
728
|
+
value: context,
|
|
729
|
+
get children() {
|
|
730
|
+
return createComponent(Polymorphic, mergeProps({
|
|
731
|
+
as: "li",
|
|
732
|
+
role: "status",
|
|
733
|
+
tabIndex: 0,
|
|
734
|
+
get style() {
|
|
735
|
+
return combineStyle({
|
|
736
|
+
animation: isAnimationEnabled() ? void 0 : "none",
|
|
737
|
+
"user-select": "none",
|
|
738
|
+
"touch-action": "none"
|
|
739
|
+
}, local.style);
|
|
740
|
+
},
|
|
741
|
+
get ["aria-live"]() {
|
|
742
|
+
return local.priority === "high" ? "assertive" : "polite";
|
|
743
|
+
},
|
|
744
|
+
"aria-atomic": "true",
|
|
745
|
+
get ["aria-labelledby"]() {
|
|
746
|
+
return titleId();
|
|
747
|
+
},
|
|
748
|
+
get ["aria-describedby"]() {
|
|
749
|
+
return descriptionId();
|
|
750
|
+
},
|
|
751
|
+
get ["data-opened"]() {
|
|
752
|
+
return isOpen() ? "" : void 0;
|
|
753
|
+
},
|
|
754
|
+
get ["data-closed"]() {
|
|
755
|
+
return !isOpen() ? "" : void 0;
|
|
756
|
+
},
|
|
757
|
+
get ["data-swipe-direction"]() {
|
|
758
|
+
return rootContext.swipeDirection();
|
|
759
|
+
},
|
|
760
|
+
onKeyDown,
|
|
761
|
+
onPointerDown,
|
|
762
|
+
onPointerMove,
|
|
763
|
+
onPointerUp
|
|
764
|
+
}, others));
|
|
765
|
+
}
|
|
766
|
+
});
|
|
767
|
+
}
|
|
768
|
+
});
|
|
769
|
+
}
|
|
770
|
+
function isDeltaInDirection(delta, direction, threshold = 0) {
|
|
771
|
+
const deltaX = Math.abs(delta.x);
|
|
772
|
+
const deltaY = Math.abs(delta.y);
|
|
773
|
+
const isDeltaX = deltaX > deltaY;
|
|
774
|
+
if (direction === "left" || direction === "right") return isDeltaX && deltaX > threshold;
|
|
775
|
+
return !isDeltaX && deltaY > threshold;
|
|
776
|
+
}
|
|
777
|
+
function handleAndDispatchCustomEvent(name, handler, detail) {
|
|
778
|
+
const currentTarget = detail.originalEvent.currentTarget;
|
|
779
|
+
const event = new CustomEvent(name, {
|
|
780
|
+
bubbles: true,
|
|
781
|
+
cancelable: true,
|
|
782
|
+
detail
|
|
783
|
+
});
|
|
784
|
+
if (handler) currentTarget.addEventListener(name, handler, { once: true });
|
|
785
|
+
currentTarget.dispatchEvent(event);
|
|
786
|
+
}
|
|
787
|
+
function ToastTitle(props) {
|
|
788
|
+
const context = useToastContext();
|
|
789
|
+
const [local, others] = splitProps(mergeDefaultProps({ id: context.generateId("title") }, props), ["id"]);
|
|
790
|
+
createEffect(() => onCleanup(context.registerTitleId(local.id)));
|
|
791
|
+
return createComponent(Polymorphic, mergeProps({
|
|
792
|
+
as: "div",
|
|
793
|
+
get id() {
|
|
794
|
+
return local.id;
|
|
795
|
+
}
|
|
796
|
+
}, others));
|
|
797
|
+
}
|
|
798
|
+
var toastsCounter = 0;
|
|
799
|
+
function show(toastComponent, options) {
|
|
800
|
+
const id = toastsCounter++;
|
|
801
|
+
toastStore.add({
|
|
802
|
+
id,
|
|
803
|
+
toastComponent,
|
|
804
|
+
dismiss: false,
|
|
805
|
+
update: false,
|
|
806
|
+
region: options?.region
|
|
807
|
+
});
|
|
808
|
+
return id;
|
|
809
|
+
}
|
|
810
|
+
function update2(id, toastComponent) {
|
|
811
|
+
toastStore.update(id, {
|
|
812
|
+
id,
|
|
813
|
+
toastComponent,
|
|
814
|
+
dismiss: false,
|
|
815
|
+
update: true
|
|
816
|
+
});
|
|
817
|
+
}
|
|
818
|
+
function promise(promise2, toastComponent, options) {
|
|
819
|
+
const id = show((props) => {
|
|
820
|
+
return toastComponent({
|
|
821
|
+
get toastId() {
|
|
822
|
+
return props.toastId;
|
|
823
|
+
},
|
|
824
|
+
state: "pending"
|
|
825
|
+
});
|
|
826
|
+
}, options);
|
|
827
|
+
(isFunction(promise2) ? promise2() : promise2).then((data) => update2(id, (props) => {
|
|
828
|
+
return toastComponent({
|
|
829
|
+
get toastId() {
|
|
830
|
+
return props.toastId;
|
|
831
|
+
},
|
|
832
|
+
state: "fulfilled",
|
|
833
|
+
data
|
|
834
|
+
});
|
|
835
|
+
})).catch((error) => update2(id, (props) => {
|
|
836
|
+
return toastComponent({
|
|
837
|
+
get toastId() {
|
|
838
|
+
return props.toastId;
|
|
839
|
+
},
|
|
840
|
+
state: "rejected",
|
|
841
|
+
error
|
|
842
|
+
});
|
|
843
|
+
}));
|
|
844
|
+
return id;
|
|
845
|
+
}
|
|
846
|
+
function dismiss2(id) {
|
|
847
|
+
toastStore.dismiss(id);
|
|
848
|
+
return id;
|
|
849
|
+
}
|
|
850
|
+
function clear2() {
|
|
851
|
+
toastStore.clear();
|
|
852
|
+
}
|
|
853
|
+
var toaster = {
|
|
854
|
+
show,
|
|
855
|
+
update: update2,
|
|
856
|
+
promise,
|
|
857
|
+
dismiss: dismiss2,
|
|
858
|
+
clear: clear2
|
|
859
|
+
};
|
|
860
|
+
var Toast = Object.assign(ToastRoot, {
|
|
861
|
+
CloseButton: ToastCloseButton,
|
|
862
|
+
Description: ToastDescription,
|
|
863
|
+
List: ToastList,
|
|
864
|
+
ProgressFill: ToastProgressFill,
|
|
865
|
+
ProgressTrack: ToastProgressTrack,
|
|
866
|
+
Region: ToastRegion$1,
|
|
867
|
+
Title: ToastTitle,
|
|
868
|
+
toaster
|
|
869
|
+
});
|
|
870
|
+
var toast_module_default = {
|
|
871
|
+
region: "_region_3lsca_19",
|
|
872
|
+
list: "_list_3lsca_27",
|
|
873
|
+
toast: "_toast_3lsca_36",
|
|
874
|
+
success: "_success_3lsca_48",
|
|
875
|
+
fail: "_fail_3lsca_52",
|
|
876
|
+
title: "_title_3lsca_56",
|
|
877
|
+
close: "_close_3lsca_62"
|
|
878
|
+
};
|
|
879
|
+
var _tmpl$ = ["<span", " aria-hidden=\"true\">×</span>"];
|
|
880
|
+
var pendingToastKey = "drfed:toast:";
|
|
881
|
+
var toastMessage = pipe(string(), nonEmpty());
|
|
882
|
+
var storedToastSchema = pipe(string(), parseJson(), object({
|
|
883
|
+
message: toastMessage,
|
|
884
|
+
status: picklist(["success", "fail"])
|
|
885
|
+
}));
|
|
886
|
+
function ToastRegion() {
|
|
887
|
+
onMount(() => {
|
|
888
|
+
const key = pendingToastKey + globalThis.location.pathname;
|
|
889
|
+
try {
|
|
890
|
+
const stored = sessionStorage.getItem(key);
|
|
891
|
+
sessionStorage.removeItem(key);
|
|
892
|
+
const result = safeParse(storedToastSchema, stored);
|
|
893
|
+
if (result.success) showToast(result.output.message, result.output.status);
|
|
894
|
+
} catch {}
|
|
895
|
+
});
|
|
896
|
+
return createComponent(Portal, { get children() {
|
|
897
|
+
return createComponent(Toast.Region, {
|
|
898
|
+
get ["class"]() {
|
|
899
|
+
return toast_module_default.region;
|
|
900
|
+
},
|
|
901
|
+
duration: 5e3,
|
|
902
|
+
get children() {
|
|
903
|
+
return createComponent(Toast.List, { get ["class"]() {
|
|
904
|
+
return toast_module_default.list;
|
|
905
|
+
} });
|
|
906
|
+
}
|
|
907
|
+
});
|
|
908
|
+
} });
|
|
909
|
+
}
|
|
910
|
+
function showToast(message, status) {
|
|
911
|
+
return toaster.show((props) => createComponent(Toast, {
|
|
912
|
+
get toastId() {
|
|
913
|
+
return props.toastId;
|
|
914
|
+
},
|
|
915
|
+
get ["class"]() {
|
|
916
|
+
return `${toast_module_default.toast} ${toast_module_default[status]}`;
|
|
917
|
+
},
|
|
918
|
+
get children() {
|
|
919
|
+
return [createComponent(Toast.Title, {
|
|
920
|
+
get ["class"]() {
|
|
921
|
+
return toast_module_default.title;
|
|
922
|
+
},
|
|
923
|
+
children: message
|
|
924
|
+
}), createComponent(Toast.CloseButton, {
|
|
925
|
+
get ["class"]() {
|
|
926
|
+
return toast_module_default.close;
|
|
927
|
+
},
|
|
928
|
+
"aria-label": "Dismiss notification",
|
|
929
|
+
get children() {
|
|
930
|
+
return ssr(_tmpl$, ssrHydrationKey());
|
|
931
|
+
}
|
|
932
|
+
})];
|
|
933
|
+
}
|
|
934
|
+
}));
|
|
935
|
+
}
|
|
936
|
+
/** Load a fresh page and show a one-time notification there. */
|
|
937
|
+
function navigateWithToast(path, message, status) {
|
|
938
|
+
try {
|
|
939
|
+
sessionStorage.setItem(pendingToastKey + path, JSON.stringify({
|
|
940
|
+
message,
|
|
941
|
+
status
|
|
942
|
+
}));
|
|
943
|
+
} catch {}
|
|
944
|
+
globalThis.location.assign(path);
|
|
945
|
+
}
|
|
946
|
+
//#endregion
|
|
947
|
+
export { index_default as a, node as c, combineStyle as i, ToastRegion as n, layerStack as o, access as r, navigateWithToast as s, DATA_TOP_LAYER_ATTR as t };
|