@tempots/dom 31.5.0 → 31.6.1
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/index.cjs +1 -1
- package/index.js +1819 -1869
- package/package.json +1 -1
- package/renderable/attribute.d.ts +9 -0
- package/renderable/on-dispose.d.ts +4 -1
- package/renderable/style.d.ts +3 -0
- package/renderable/utils.d.ts +30 -0
- package/types/html-attributes.d.ts +1 -0
package/index.js
CHANGED
|
@@ -1,66 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
var Ue = (s, e, t) => e in s ? We(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
6
|
-
var o = (s, e, t) => Ue(s, typeof e != "symbol" ? e + "" : e, t), ge = (s, e, t) => e.has(s) || pe("Cannot " + t);
|
|
7
|
-
var J = (s, e, t) => (ge(s, e, "read from private field"), t ? t.call(s) : e.get(s)), me = (s, e, t) => e.has(s) ? pe("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(s) : e.set(s, t), le = (s, e, t, r) => (ge(s, e, "write to private field"), r ? r.call(s, t) : e.set(s, t), t);
|
|
8
|
-
const Je = (s, e, t) => s + (e - s) * t;
|
|
9
|
-
const Ge = (s, e, t) => {
|
|
10
|
-
const r = Math.max(s.length, e.length);
|
|
1
|
+
const ke = (t, e, s) => t + (e - t) * s;
|
|
2
|
+
const $e = (t, e, s) => {
|
|
3
|
+
const r = Math.max(t.length, e.length);
|
|
11
4
|
let n = "";
|
|
12
5
|
for (let i = 0; i < r; i++) {
|
|
13
|
-
let
|
|
14
|
-
isNaN(
|
|
15
|
-
let
|
|
16
|
-
isNaN(
|
|
6
|
+
let o = t.charCodeAt(i);
|
|
7
|
+
isNaN(o) && (o = 97);
|
|
8
|
+
let l = e.charCodeAt(i);
|
|
9
|
+
isNaN(l) && (l = 97), n += String.fromCharCode(o + (l - o) * s);
|
|
17
10
|
}
|
|
18
11
|
return n;
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
class ce {
|
|
12
|
+
}, Ne = (t, e, s) => new Date(t.getTime() + (e.getTime() - t.getTime()) * s), Re = (t, e) => e, Ve = (t) => typeof t == "number" ? ke : typeof t == "string" ? $e : t instanceof Date ? Ne : Re;
|
|
13
|
+
class se {
|
|
22
14
|
/**
|
|
23
15
|
* Creates a new instance of `ElementPosition`.
|
|
24
16
|
* @param index - The index of the element.
|
|
25
17
|
* @param total - The total number of elements in the collection.
|
|
26
18
|
*/
|
|
27
|
-
constructor(e,
|
|
28
|
-
|
|
29
|
-
* The counter of the element starting from 1.
|
|
30
|
-
*/
|
|
31
|
-
o(this, "counter");
|
|
32
|
-
/**
|
|
33
|
-
* Checks if the element is the first element in the collection.
|
|
34
|
-
* @returns `true` if the element is the first element, `false` otherwise.
|
|
35
|
-
*/
|
|
36
|
-
o(this, "isFirst");
|
|
37
|
-
/**
|
|
38
|
-
* Checks if the counter of the element is even.
|
|
39
|
-
* @returns `true` if the counter is even, `false` otherwise.
|
|
40
|
-
*/
|
|
41
|
-
o(this, "isEven");
|
|
42
|
-
/**
|
|
43
|
-
* Checks if the counter of the element is odd.
|
|
44
|
-
* @returns `true` if the counter is odd, `false` otherwise.
|
|
45
|
-
*/
|
|
46
|
-
o(this, "isOdd");
|
|
47
|
-
me(this, M);
|
|
48
|
-
o(this, "dispose", () => {
|
|
49
|
-
var e;
|
|
50
|
-
(e = J(this, M)) == null || e.dispose(), le(this, M, void 0);
|
|
51
|
-
});
|
|
52
|
-
this.index = e, this.total = t, this.counter = e + 1, this.isFirst = e === 0, this.isEven = e % 2 === 1, this.isOdd = e % 2 === 0;
|
|
19
|
+
constructor(e, s) {
|
|
20
|
+
this.index = e, this.total = s, this.counter = e + 1, this.isFirst = e === 0, this.isEven = e % 2 === 1, this.isOdd = e % 2 === 0;
|
|
53
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* The counter of the element starting from 1.
|
|
24
|
+
*/
|
|
25
|
+
counter;
|
|
26
|
+
/**
|
|
27
|
+
* Checks if the element is the first element in the collection.
|
|
28
|
+
* @returns `true` if the element is the first element, `false` otherwise.
|
|
29
|
+
*/
|
|
30
|
+
isFirst;
|
|
31
|
+
/**
|
|
32
|
+
* Checks if the counter of the element is even.
|
|
33
|
+
* @returns `true` if the counter is even, `false` otherwise.
|
|
34
|
+
*/
|
|
35
|
+
isEven;
|
|
36
|
+
/**
|
|
37
|
+
* Checks if the counter of the element is odd.
|
|
38
|
+
* @returns `true` if the counter is odd, `false` otherwise.
|
|
39
|
+
*/
|
|
40
|
+
isOdd;
|
|
41
|
+
#e;
|
|
54
42
|
/**
|
|
55
43
|
* Checks if the element is the last element in the collection.
|
|
56
44
|
* @returns `true` if the element is the last element, `false` otherwise.
|
|
57
45
|
*/
|
|
58
46
|
get isLast() {
|
|
59
|
-
return
|
|
47
|
+
return this.#e == null && (this.#e = this.total.map((e) => this.counter === e)), this.#e;
|
|
60
48
|
}
|
|
49
|
+
dispose = () => {
|
|
50
|
+
this.#e?.dispose(), this.#e = void 0;
|
|
51
|
+
};
|
|
61
52
|
}
|
|
62
|
-
|
|
63
|
-
const F = class F {
|
|
53
|
+
class m {
|
|
64
54
|
/**
|
|
65
55
|
* Represents a signal with a value of type T.
|
|
66
56
|
*
|
|
@@ -68,316 +58,94 @@ const F = class F {
|
|
|
68
58
|
* @param equals - A function that determines whether two values of type T are equal.
|
|
69
59
|
* @public
|
|
70
60
|
*/
|
|
71
|
-
constructor(e,
|
|
72
|
-
|
|
73
|
-
* @internal
|
|
74
|
-
*/
|
|
75
|
-
o(this, "$__signal__", !0);
|
|
76
|
-
/**
|
|
77
|
-
* @internal
|
|
78
|
-
*/
|
|
79
|
-
o(this, "_value");
|
|
80
|
-
/**
|
|
81
|
-
* @internal
|
|
82
|
-
*/
|
|
83
|
-
o(this, "_derivatives", []);
|
|
84
|
-
/**
|
|
85
|
-
* @internal
|
|
86
|
-
*/
|
|
87
|
-
o(this, "_onValueListeners", []);
|
|
88
|
-
/**
|
|
89
|
-
* @internal
|
|
90
|
-
*/
|
|
91
|
-
o(this, "_onDisposeListeners", []);
|
|
92
|
-
/**
|
|
93
|
-
* Gets the current value of the signal.
|
|
94
|
-
* @returns The current value of the signal.
|
|
95
|
-
*/
|
|
96
|
-
o(this, "get", () => this._value);
|
|
97
|
-
/**
|
|
98
|
-
* Checks if the signal has any registered listeners.
|
|
99
|
-
* @returns `true` if the signal has listeners, `false` otherwise.
|
|
100
|
-
*/
|
|
101
|
-
o(this, "hasListeners", () => this._onValueListeners.length > 0);
|
|
102
|
-
/**
|
|
103
|
-
* Registers a listener function to be called whenever the value of the signal changes.
|
|
104
|
-
* The listener function will be immediately called with the current value of the signal.
|
|
105
|
-
* Returns a function that can be called to unregister the listener.
|
|
106
|
-
*
|
|
107
|
-
* @param listener - The listener function to be called when the value of the signal changes.
|
|
108
|
-
* @param options - Options for the listener.
|
|
109
|
-
*/
|
|
110
|
-
o(this, "on", (e, t = {}) => {
|
|
111
|
-
t.skipInitial || e(this.get(), void 0);
|
|
112
|
-
const r = t.once ? (i, l) => {
|
|
113
|
-
n(), e(i, l);
|
|
114
|
-
} : e;
|
|
115
|
-
this._onValueListeners.push(r);
|
|
116
|
-
const n = () => {
|
|
117
|
-
this._onValueListeners.splice(
|
|
118
|
-
this._onValueListeners.indexOf(r),
|
|
119
|
-
1
|
|
120
|
-
), t.abortSignal != null && t.abortSignal.removeEventListener("abort", n);
|
|
121
|
-
};
|
|
122
|
-
return t.abortSignal != null && t.abortSignal.addEventListener("abort", n), n;
|
|
123
|
-
});
|
|
124
|
-
/**
|
|
125
|
-
* @internal
|
|
126
|
-
*/
|
|
127
|
-
o(this, "_setAndNotify", (e) => {
|
|
128
|
-
if (this._disposed) return;
|
|
129
|
-
const t = this._value;
|
|
130
|
-
this.equals(t, e) || (this._value = e, this._onValueListeners.forEach((n) => n(e, t)));
|
|
131
|
-
});
|
|
132
|
-
/**
|
|
133
|
-
* @internal
|
|
134
|
-
*/
|
|
135
|
-
o(this, "_disposed", !1);
|
|
136
|
-
/**
|
|
137
|
-
* Checks whether the signal is disposed.
|
|
138
|
-
* @returns True if the signal is disposed, false otherwise.
|
|
139
|
-
*/
|
|
140
|
-
o(this, "isDisposed", () => this._disposed);
|
|
141
|
-
/**
|
|
142
|
-
* Adds a listener function to be called when the object is disposed.
|
|
143
|
-
* @param listener - The listener function to be called when the object is disposed.
|
|
144
|
-
* @returns A function that can be called to remove the listener.
|
|
145
|
-
*/
|
|
146
|
-
o(this, "onDispose", (e) => {
|
|
147
|
-
this._onDisposeListeners.push(e);
|
|
148
|
-
});
|
|
149
|
-
/**
|
|
150
|
-
* Disposes the signal, releasing any resources associated with it.
|
|
151
|
-
*/
|
|
152
|
-
o(this, "dispose", () => {
|
|
153
|
-
this._disposed || (this._disposed = !0, this._onDisposeListeners.forEach((e) => e()), this._onDisposeListeners.length = 0, this._derivatives.length = 0);
|
|
154
|
-
});
|
|
155
|
-
/**
|
|
156
|
-
* Creates a new computed signal by applying a transformation function to this signal's value.
|
|
157
|
-
*
|
|
158
|
-
* The `map` method is one of the most commonly used signal operations. It creates a new
|
|
159
|
-
* computed signal that automatically updates whenever the source signal changes. The
|
|
160
|
-
* transformation function is called with the current value and should return the new value.
|
|
161
|
-
*
|
|
162
|
-
* @example
|
|
163
|
-
* ```typescript
|
|
164
|
-
* const count = prop(5)
|
|
165
|
-
*
|
|
166
|
-
* // Transform to different types
|
|
167
|
-
* const doubled = count.map(n => n * 2)
|
|
168
|
-
* const message = count.map(n => `Count is ${n}`)
|
|
169
|
-
* const isEven = count.map(n => n % 2 === 0)
|
|
170
|
-
*
|
|
171
|
-
* // Use in UI
|
|
172
|
-
* html.div(
|
|
173
|
-
* html.div('Original: ', count.map(String)),
|
|
174
|
-
* html.div('Doubled: ', doubled.map(String)),
|
|
175
|
-
* html.div('Message: ', message),
|
|
176
|
-
* html.div('Is even: ', isEven.map(String))
|
|
177
|
-
* )
|
|
178
|
-
* ```
|
|
179
|
-
*
|
|
180
|
-
* @example
|
|
181
|
-
* ```typescript
|
|
182
|
-
* // Chain multiple transformations
|
|
183
|
-
* const user = prop({ name: 'John', age: 30 })
|
|
184
|
-
* const greeting = user
|
|
185
|
-
* .map(u => u.name)
|
|
186
|
-
* .map(name => name.toUpperCase())
|
|
187
|
-
* .map(name => `Hello, ${name}!`)
|
|
188
|
-
* ```
|
|
189
|
-
*
|
|
190
|
-
* @example
|
|
191
|
-
* ```typescript
|
|
192
|
-
* // With custom equality function for objects
|
|
193
|
-
* const items = prop([{ id: 1, name: 'Item 1' }])
|
|
194
|
-
* const itemNames = items.map(
|
|
195
|
-
* items => items.map(item => item.name),
|
|
196
|
-
* (a, b) => JSON.stringify(a) === JSON.stringify(b) // deep equality
|
|
197
|
-
* )
|
|
198
|
-
* ```
|
|
199
|
-
*
|
|
200
|
-
* @typeParam O - The type of the transformed value
|
|
201
|
-
* @param fn - Function that transforms the signal's value to a new value
|
|
202
|
-
* @param equals - Optional function to determine if two transformed values are equal (defaults to strict equality)
|
|
203
|
-
* @returns A new computed signal with the transformed value
|
|
204
|
-
*/
|
|
205
|
-
o(this, "map", (e, t = (r, n) => r === n) => {
|
|
206
|
-
const r = new N(() => {
|
|
207
|
-
try {
|
|
208
|
-
return e(this.get());
|
|
209
|
-
} catch (n) {
|
|
210
|
-
throw console.error("Error in Signal.map:", n), n;
|
|
211
|
-
}
|
|
212
|
-
}, t);
|
|
213
|
-
return this.setDerivative(r), r;
|
|
214
|
-
});
|
|
215
|
-
/**
|
|
216
|
-
* Returns a new Signal that applies the given function to the value of the current Signal,
|
|
217
|
-
* and then flattens the resulting Signal.
|
|
218
|
-
*
|
|
219
|
-
* @typeParam O - The type of the value emitted by the resulting Signal.
|
|
220
|
-
* @param fn - The function to apply to the value of the current Signal.
|
|
221
|
-
* @param equals - A function that determines whether two values of type O are equal.
|
|
222
|
-
* Defaults to a strict equality check (===).
|
|
223
|
-
* @returns A new Signal that emits the values of the resulting Signal.
|
|
224
|
-
*/
|
|
225
|
-
o(this, "flatMap", (e, t = (r, n) => r === n) => {
|
|
226
|
-
const r = new N(() => {
|
|
227
|
-
try {
|
|
228
|
-
return e(this.get()).get();
|
|
229
|
-
} catch (n) {
|
|
230
|
-
throw console.error("Error in Signal.flatMap:", n), n;
|
|
231
|
-
}
|
|
232
|
-
}, t);
|
|
233
|
-
return this.setDerivative(r), r;
|
|
234
|
-
});
|
|
235
|
-
/**
|
|
236
|
-
* Invokes a callback function with the current value of the signal, without modifying the signal.
|
|
237
|
-
*
|
|
238
|
-
* @param fn - The callback function to be invoked with the current value of the signal.
|
|
239
|
-
* @returns A new signal that emits the same value as the original signal and invokes the callback function.
|
|
240
|
-
*/
|
|
241
|
-
o(this, "tap", (e) => this.map((t) => (e(t), t)));
|
|
242
|
-
/**
|
|
243
|
-
* Returns a new Signal that emits the value at the specified key of the current value.
|
|
244
|
-
*
|
|
245
|
-
* @param key - The key of the value to retrieve.
|
|
246
|
-
* @returns A new Signal that emits the value at the specified key.
|
|
247
|
-
*/
|
|
248
|
-
o(this, "at", (e) => this.map((t) => t[e]));
|
|
249
|
-
/**
|
|
250
|
-
* @internal
|
|
251
|
-
*/
|
|
252
|
-
o(this, "_$");
|
|
253
|
-
o(this, "filter", (e, t) => {
|
|
254
|
-
let r = t ?? this.get();
|
|
255
|
-
const n = new N(() => {
|
|
256
|
-
try {
|
|
257
|
-
const i = this.get();
|
|
258
|
-
return r = e(i) ? i : r;
|
|
259
|
-
} catch (i) {
|
|
260
|
-
throw console.error("Error in Signal.filter:", i), i;
|
|
261
|
-
}
|
|
262
|
-
}, this.equals);
|
|
263
|
-
return this.setDerivative(n), n;
|
|
264
|
-
});
|
|
265
|
-
/**
|
|
266
|
-
* Returns a new Computed object that applies the provided mapping function to the value of this Signal,
|
|
267
|
-
* and filters out values that are `undefined` or `null`.
|
|
268
|
-
*
|
|
269
|
-
* @typeParam O - The type of the mapped value.
|
|
270
|
-
* @param fn - The mapping function to apply to the value of this Signal.
|
|
271
|
-
* @param startValue - The initial value for the Computed object.
|
|
272
|
-
* @param equals - Optional equality function to determine if two values are equal.
|
|
273
|
-
* @returns - A new Computed object with the mapped and filtered values.
|
|
274
|
-
*/
|
|
275
|
-
o(this, "filterMap", (e, t, r = (n, i) => n === i) => {
|
|
276
|
-
let n = t;
|
|
277
|
-
const i = new N(() => {
|
|
278
|
-
try {
|
|
279
|
-
const l = this.get(), c = e(l);
|
|
280
|
-
return n = c ?? n;
|
|
281
|
-
} catch (l) {
|
|
282
|
-
throw console.error("Error in Signal.filterMap:", l), l;
|
|
283
|
-
}
|
|
284
|
-
}, r);
|
|
285
|
-
return this.setDerivative(i), i;
|
|
286
|
-
});
|
|
287
|
-
/**
|
|
288
|
-
* Maps the values emitted by the signal to a new value asynchronously using the provided function.
|
|
289
|
-
* If the function throws an error, it will be caught and logged.
|
|
290
|
-
* If a recovery function is provided, it will be called with the error and its return value will be used as the mapped value.
|
|
291
|
-
* If no recovery function is provided, the error will be logged as an unhandled promise rejection.
|
|
292
|
-
*
|
|
293
|
-
* @typeParam O - The type of the mapped value.
|
|
294
|
-
* @param fn - The function to map the values emitted by the signal. The second argument to this function allows to cancel the previously running mapping function if it has not completed by the time a new value is emitted.
|
|
295
|
-
* @param alt - The alternate value to use if the signal is disposed or the mapping function throws an error.
|
|
296
|
-
* @param recover - The recovery function to handle errors thrown by the mapping function.
|
|
297
|
-
* @param equals - The equality function to compare the mapped values for equality.
|
|
298
|
-
* @returns A property that holds the mapped value and can be observed for changes.
|
|
299
|
-
*/
|
|
300
|
-
o(this, "mapAsync", (e, t, r, n = (i, l) => i === l) => {
|
|
301
|
-
const i = w(t, n);
|
|
302
|
-
let l = 0, c = new AbortController();
|
|
303
|
-
return i.onDispose(
|
|
304
|
-
this.on(async (a) => {
|
|
305
|
-
const u = ++l;
|
|
306
|
-
c.abort(), c = new AbortController();
|
|
307
|
-
try {
|
|
308
|
-
const h = await e(a, { abortSignal: c.signal });
|
|
309
|
-
u === l && i.set(h);
|
|
310
|
-
} catch (h) {
|
|
311
|
-
if (u === l)
|
|
312
|
-
if (r != null)
|
|
313
|
-
i.set(r(h));
|
|
314
|
-
else
|
|
315
|
-
throw h;
|
|
316
|
-
}
|
|
317
|
-
})
|
|
318
|
-
), i;
|
|
319
|
-
});
|
|
320
|
-
/**
|
|
321
|
-
* Maps the values of the signal using the provided function `fn`, and returns a new signal
|
|
322
|
-
* containing the mapped values. If the mapped value is `undefined` or `null`, it is replaced
|
|
323
|
-
* with the provided `alt` value.
|
|
324
|
-
*
|
|
325
|
-
* @typeParam O - The type of the mapped value.
|
|
326
|
-
* @param fn - The function used to map the values of the signal.
|
|
327
|
-
* @param alt - The alternative value to use when the mapped value is `undefined` or `null`.
|
|
328
|
-
* @returns A new signal containing the mapped values.
|
|
329
|
-
*/
|
|
330
|
-
o(this, "mapMaybe", (e, t) => this.map((r) => e(r) ?? t));
|
|
331
|
-
/**
|
|
332
|
-
* Feeds a property into the signal and sets up disposal behavior.
|
|
333
|
-
* @param prop - The property to feed into the signal.
|
|
334
|
-
* @param autoDisposeProp - Determines whether the property should be automatically disposed when the signal is disposed.
|
|
335
|
-
* @returns The input property.
|
|
336
|
-
*/
|
|
337
|
-
o(this, "feedProp", (e, t = !1) => {
|
|
338
|
-
const r = this.on(e.set);
|
|
339
|
-
return e.onDispose(r), t ? this.onDispose(e.dispose) : this.onDispose(r), e;
|
|
340
|
-
});
|
|
341
|
-
/**
|
|
342
|
-
* Derives a new property from the current signal.
|
|
343
|
-
* @param options - The options for the derived property.
|
|
344
|
-
* @param options.autoDisposeProp - Determines whether the derived property should be automatically disposed.
|
|
345
|
-
* @param options.equals - A function that determines if two values are equal.
|
|
346
|
-
* @returns The derived property.
|
|
347
|
-
*/
|
|
348
|
-
o(this, "deriveProp", ({
|
|
349
|
-
autoDisposeProp: e = !0,
|
|
350
|
-
equals: t
|
|
351
|
-
} = {}) => this.feedProp(w(this.get(), t), e));
|
|
352
|
-
/**
|
|
353
|
-
* Derives a new signal from the current signal. Useful to create a new signal that emits the same values as the current signal but can be disposed independently.
|
|
354
|
-
* @returns A new signal that emits the same values as the current signal.
|
|
355
|
-
*/
|
|
356
|
-
o(this, "derive", () => this.map((e) => e));
|
|
357
|
-
/**
|
|
358
|
-
* Returns a signal that emits the count of values received so far.
|
|
359
|
-
* @returns A signal that emits the count of values received so far.
|
|
360
|
-
*/
|
|
361
|
-
o(this, "count", () => {
|
|
362
|
-
let e = 0;
|
|
363
|
-
return this.map(() => ++e);
|
|
364
|
-
});
|
|
365
|
-
/**
|
|
366
|
-
* Adds a computed value as a derivative of the signal.
|
|
367
|
-
* When the computed value is disposed, it is automatically removed from the derivatives list.
|
|
368
|
-
* Additionally, when the computed value is disposed, it sets the signal as dirty.
|
|
369
|
-
* @param computed - The computed value to add as a derivative.
|
|
370
|
-
*/
|
|
371
|
-
o(this, "setDerivative", (e) => {
|
|
372
|
-
this._derivatives.push(e), e.onDispose(() => {
|
|
373
|
-
this._derivatives.splice(
|
|
374
|
-
this._derivatives.indexOf(e),
|
|
375
|
-
1
|
|
376
|
-
);
|
|
377
|
-
}), e.onDispose(this.on(e.setDirty)), this.onDispose(e.dispose);
|
|
378
|
-
});
|
|
379
|
-
this.equals = t, this._value = e;
|
|
61
|
+
constructor(e, s) {
|
|
62
|
+
this.equals = s, this._value = e;
|
|
380
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Creates a Signal that holds the result of a Promise, with proper error handling.
|
|
66
|
+
*
|
|
67
|
+
* This static method creates a signal that starts with an initial value and updates
|
|
68
|
+
* when the promise resolves. If the promise rejects, an optional recovery function
|
|
69
|
+
* can provide a fallback value.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* // Basic usage with API call
|
|
74
|
+
* const userData = Signal.ofPromise(
|
|
75
|
+
* fetch('/api/user').then(r => r.json()),
|
|
76
|
+
* { loading: true }, // initial state
|
|
77
|
+
* error => ({ error: error.message, loading: false }) // error recovery
|
|
78
|
+
* )
|
|
79
|
+
*
|
|
80
|
+
* // Use in UI
|
|
81
|
+
* Ensure(userData,
|
|
82
|
+
* (user) => html.div('Welcome, ', user.map(u => u.name)),
|
|
83
|
+
* () => html.div('Loading...')
|
|
84
|
+
* )
|
|
85
|
+
* ```
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```typescript
|
|
89
|
+
* // With custom equality function
|
|
90
|
+
* const config = Signal.ofPromise(
|
|
91
|
+
* loadConfig(),
|
|
92
|
+
* {},
|
|
93
|
+
* () => ({}),
|
|
94
|
+
* (a, b) => JSON.stringify(a) === JSON.stringify(b) // deep equality
|
|
95
|
+
* )
|
|
96
|
+
* ```
|
|
97
|
+
*
|
|
98
|
+
* @typeParam O - The type of the value returned by the Promise
|
|
99
|
+
* @param promise - The Promise to use to feed the Signal
|
|
100
|
+
* @param init - The initial value of the Signal before the Promise resolves
|
|
101
|
+
* @param recover - Optional function to recover from Promise rejection and provide an alternative value
|
|
102
|
+
* @param equals - Function to compare two values for equality (defaults to strict equality)
|
|
103
|
+
* @returns A Signal that represents the result of the Promise
|
|
104
|
+
*/
|
|
105
|
+
static ofPromise = (e, s, r, n = (i, o) => i === o) => {
|
|
106
|
+
const i = new m(s, n);
|
|
107
|
+
return e.then((o) => i._setAndNotify(o)).catch((o) => {
|
|
108
|
+
r != null ? i._setAndNotify(r(o)) : console.error(
|
|
109
|
+
"Unhandled promise rejection in Signal.ofPromise:",
|
|
110
|
+
o
|
|
111
|
+
);
|
|
112
|
+
}), i;
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Checks if a value is a Signal.
|
|
116
|
+
*
|
|
117
|
+
* @param value - The value to check.
|
|
118
|
+
* @returns `true` if the value is a Signal, `false` otherwise.
|
|
119
|
+
*/
|
|
120
|
+
static is = (e) => (
|
|
121
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
122
|
+
e != null && e.$__signal__ === !0
|
|
123
|
+
);
|
|
124
|
+
/**
|
|
125
|
+
* @internal
|
|
126
|
+
*/
|
|
127
|
+
$__signal__ = !0;
|
|
128
|
+
/**
|
|
129
|
+
* @internal
|
|
130
|
+
*/
|
|
131
|
+
_value;
|
|
132
|
+
/**
|
|
133
|
+
* @internal
|
|
134
|
+
*/
|
|
135
|
+
_derivatives = [];
|
|
136
|
+
/**
|
|
137
|
+
* @internal
|
|
138
|
+
*/
|
|
139
|
+
_onValueListeners = [];
|
|
140
|
+
/**
|
|
141
|
+
* @internal
|
|
142
|
+
*/
|
|
143
|
+
_onDisposeListeners = [];
|
|
144
|
+
/**
|
|
145
|
+
* Gets the current value of the signal.
|
|
146
|
+
* @returns The current value of the signal.
|
|
147
|
+
*/
|
|
148
|
+
get = () => this._value;
|
|
381
149
|
/**
|
|
382
150
|
* Gets the value of the signal.
|
|
383
151
|
* @returns The current value of the signal.
|
|
@@ -385,119 +153,307 @@ const F = class F {
|
|
|
385
153
|
get value() {
|
|
386
154
|
return this._value;
|
|
387
155
|
}
|
|
156
|
+
/**
|
|
157
|
+
* Checks if the signal has any registered listeners.
|
|
158
|
+
* @returns `true` if the signal has listeners, `false` otherwise.
|
|
159
|
+
*/
|
|
160
|
+
hasListeners = () => this._onValueListeners.length > 0;
|
|
161
|
+
/**
|
|
162
|
+
* Registers a listener function to be called whenever the value of the signal changes.
|
|
163
|
+
* The listener function will be immediately called with the current value of the signal.
|
|
164
|
+
* Returns a function that can be called to unregister the listener.
|
|
165
|
+
*
|
|
166
|
+
* @param listener - The listener function to be called when the value of the signal changes.
|
|
167
|
+
* @param options - Options for the listener.
|
|
168
|
+
*/
|
|
169
|
+
on = (e, s = {}) => {
|
|
170
|
+
s.skipInitial || e(this.get(), void 0);
|
|
171
|
+
const r = s.once ? (i, o) => {
|
|
172
|
+
n(), e(i, o);
|
|
173
|
+
} : e;
|
|
174
|
+
this._onValueListeners.push(r);
|
|
175
|
+
const n = () => {
|
|
176
|
+
this._onValueListeners.splice(
|
|
177
|
+
this._onValueListeners.indexOf(r),
|
|
178
|
+
1
|
|
179
|
+
), s.abortSignal != null && s.abortSignal.removeEventListener("abort", n);
|
|
180
|
+
};
|
|
181
|
+
return s.abortSignal != null && s.abortSignal.addEventListener("abort", n), n;
|
|
182
|
+
};
|
|
183
|
+
/**
|
|
184
|
+
* @internal
|
|
185
|
+
*/
|
|
186
|
+
_setAndNotify = (e) => {
|
|
187
|
+
if (this._disposed) return;
|
|
188
|
+
const s = this._value;
|
|
189
|
+
this.equals(s, e) || (this._value = e, this._onValueListeners.forEach((n) => n(e, s)));
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* @internal
|
|
193
|
+
*/
|
|
194
|
+
_disposed = !1;
|
|
195
|
+
/**
|
|
196
|
+
* Checks whether the signal is disposed.
|
|
197
|
+
* @returns True if the signal is disposed, false otherwise.
|
|
198
|
+
*/
|
|
199
|
+
isDisposed = () => this._disposed;
|
|
200
|
+
/**
|
|
201
|
+
* Adds a listener function to be called when the object is disposed.
|
|
202
|
+
* @param listener - The listener function to be called when the object is disposed.
|
|
203
|
+
* @returns A function that can be called to remove the listener.
|
|
204
|
+
*/
|
|
205
|
+
onDispose = (e) => {
|
|
206
|
+
this._onDisposeListeners.push(e);
|
|
207
|
+
};
|
|
208
|
+
/**
|
|
209
|
+
* Disposes the signal, releasing any resources associated with it.
|
|
210
|
+
*/
|
|
211
|
+
dispose = () => {
|
|
212
|
+
this._disposed || (this._disposed = !0, this._onDisposeListeners.forEach((e) => e()), this._onDisposeListeners.length = 0, this._derivatives.length = 0);
|
|
213
|
+
};
|
|
214
|
+
/**
|
|
215
|
+
* Creates a new computed signal by applying a transformation function to this signal's value.
|
|
216
|
+
*
|
|
217
|
+
* The `map` method is one of the most commonly used signal operations. It creates a new
|
|
218
|
+
* computed signal that automatically updates whenever the source signal changes. The
|
|
219
|
+
* transformation function is called with the current value and should return the new value.
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* ```typescript
|
|
223
|
+
* const count = prop(5)
|
|
224
|
+
*
|
|
225
|
+
* // Transform to different types
|
|
226
|
+
* const doubled = count.map(n => n * 2)
|
|
227
|
+
* const message = count.map(n => `Count is ${n}`)
|
|
228
|
+
* const isEven = count.map(n => n % 2 === 0)
|
|
229
|
+
*
|
|
230
|
+
* // Use in UI
|
|
231
|
+
* html.div(
|
|
232
|
+
* html.div('Original: ', count.map(String)),
|
|
233
|
+
* html.div('Doubled: ', doubled.map(String)),
|
|
234
|
+
* html.div('Message: ', message),
|
|
235
|
+
* html.div('Is even: ', isEven.map(String))
|
|
236
|
+
* )
|
|
237
|
+
* ```
|
|
238
|
+
*
|
|
239
|
+
* @example
|
|
240
|
+
* ```typescript
|
|
241
|
+
* // Chain multiple transformations
|
|
242
|
+
* const user = prop({ name: 'John', age: 30 })
|
|
243
|
+
* const greeting = user
|
|
244
|
+
* .map(u => u.name)
|
|
245
|
+
* .map(name => name.toUpperCase())
|
|
246
|
+
* .map(name => `Hello, ${name}!`)
|
|
247
|
+
* ```
|
|
248
|
+
*
|
|
249
|
+
* @example
|
|
250
|
+
* ```typescript
|
|
251
|
+
* // With custom equality function for objects
|
|
252
|
+
* const items = prop([{ id: 1, name: 'Item 1' }])
|
|
253
|
+
* const itemNames = items.map(
|
|
254
|
+
* items => items.map(item => item.name),
|
|
255
|
+
* (a, b) => JSON.stringify(a) === JSON.stringify(b) // deep equality
|
|
256
|
+
* )
|
|
257
|
+
* ```
|
|
258
|
+
*
|
|
259
|
+
* @typeParam O - The type of the transformed value
|
|
260
|
+
* @param fn - Function that transforms the signal's value to a new value
|
|
261
|
+
* @param equals - Optional function to determine if two transformed values are equal (defaults to strict equality)
|
|
262
|
+
* @returns A new computed signal with the transformed value
|
|
263
|
+
*/
|
|
264
|
+
map = (e, s = (r, n) => r === n) => {
|
|
265
|
+
const r = new H(() => {
|
|
266
|
+
try {
|
|
267
|
+
return e(this.get());
|
|
268
|
+
} catch (n) {
|
|
269
|
+
throw console.error("Error in Signal.map:", n), n;
|
|
270
|
+
}
|
|
271
|
+
}, s);
|
|
272
|
+
return this.setDerivative(r), r;
|
|
273
|
+
};
|
|
274
|
+
/**
|
|
275
|
+
* Returns a new Signal that applies the given function to the value of the current Signal,
|
|
276
|
+
* and then flattens the resulting Signal.
|
|
277
|
+
*
|
|
278
|
+
* @typeParam O - The type of the value emitted by the resulting Signal.
|
|
279
|
+
* @param fn - The function to apply to the value of the current Signal.
|
|
280
|
+
* @param equals - A function that determines whether two values of type O are equal.
|
|
281
|
+
* Defaults to a strict equality check (===).
|
|
282
|
+
* @returns A new Signal that emits the values of the resulting Signal.
|
|
283
|
+
*/
|
|
284
|
+
flatMap = (e, s = (r, n) => r === n) => {
|
|
285
|
+
const r = new H(() => {
|
|
286
|
+
try {
|
|
287
|
+
return e(this.get()).get();
|
|
288
|
+
} catch (n) {
|
|
289
|
+
throw console.error("Error in Signal.flatMap:", n), n;
|
|
290
|
+
}
|
|
291
|
+
}, s);
|
|
292
|
+
return this.setDerivative(r), r;
|
|
293
|
+
};
|
|
294
|
+
/**
|
|
295
|
+
* Invokes a callback function with the current value of the signal, without modifying the signal.
|
|
296
|
+
*
|
|
297
|
+
* @param fn - The callback function to be invoked with the current value of the signal.
|
|
298
|
+
* @returns A new signal that emits the same value as the original signal and invokes the callback function.
|
|
299
|
+
*/
|
|
300
|
+
tap = (e) => this.map((s) => (e(s), s));
|
|
301
|
+
/**
|
|
302
|
+
* Returns a new Signal that emits the value at the specified key of the current value.
|
|
303
|
+
*
|
|
304
|
+
* @param key - The key of the value to retrieve.
|
|
305
|
+
* @returns A new Signal that emits the value at the specified key.
|
|
306
|
+
*/
|
|
307
|
+
at = (e) => this.map((s) => s[e]);
|
|
308
|
+
/**
|
|
309
|
+
* @internal
|
|
310
|
+
*/
|
|
311
|
+
_$;
|
|
388
312
|
/**
|
|
389
313
|
* Represents a collection of signals mapping to each key/field in the wrapped value.
|
|
390
314
|
* @typeParam T - The type of the signals.
|
|
391
315
|
*/
|
|
392
316
|
get $() {
|
|
393
317
|
return this._$ !== void 0 ? this._$ : this._$ = new Proxy(this, {
|
|
394
|
-
get: (e,
|
|
318
|
+
get: (e, s) => this.at(s)
|
|
395
319
|
});
|
|
396
320
|
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
);
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
o
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
)
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
321
|
+
filter = (e, s) => {
|
|
322
|
+
let r = s ?? this.get();
|
|
323
|
+
const n = new H(() => {
|
|
324
|
+
try {
|
|
325
|
+
const i = this.get();
|
|
326
|
+
return r = e(i) ? i : r;
|
|
327
|
+
} catch (i) {
|
|
328
|
+
throw console.error("Error in Signal.filter:", i), i;
|
|
329
|
+
}
|
|
330
|
+
}, this.equals);
|
|
331
|
+
return this.setDerivative(n), n;
|
|
332
|
+
};
|
|
333
|
+
/**
|
|
334
|
+
* Returns a new Computed object that applies the provided mapping function to the value of this Signal,
|
|
335
|
+
* and filters out values that are `undefined` or `null`.
|
|
336
|
+
*
|
|
337
|
+
* @typeParam O - The type of the mapped value.
|
|
338
|
+
* @param fn - The mapping function to apply to the value of this Signal.
|
|
339
|
+
* @param startValue - The initial value for the Computed object.
|
|
340
|
+
* @param equals - Optional equality function to determine if two values are equal.
|
|
341
|
+
* @returns - A new Computed object with the mapped and filtered values.
|
|
342
|
+
*/
|
|
343
|
+
filterMap = (e, s, r = (n, i) => n === i) => {
|
|
344
|
+
let n = s;
|
|
345
|
+
const i = new H(() => {
|
|
346
|
+
try {
|
|
347
|
+
const o = this.get(), l = e(o);
|
|
348
|
+
return n = l ?? n;
|
|
349
|
+
} catch (o) {
|
|
350
|
+
throw console.error("Error in Signal.filterMap:", o), o;
|
|
351
|
+
}
|
|
352
|
+
}, r);
|
|
353
|
+
return this.setDerivative(i), i;
|
|
354
|
+
};
|
|
355
|
+
/**
|
|
356
|
+
* Maps the values emitted by the signal to a new value asynchronously using the provided function.
|
|
357
|
+
* If the function throws an error, it will be caught and logged.
|
|
358
|
+
* If a recovery function is provided, it will be called with the error and its return value will be used as the mapped value.
|
|
359
|
+
* If no recovery function is provided, the error will be logged as an unhandled promise rejection.
|
|
360
|
+
*
|
|
361
|
+
* @typeParam O - The type of the mapped value.
|
|
362
|
+
* @param fn - The function to map the values emitted by the signal. The second argument to this function allows to cancel the previously running mapping function if it has not completed by the time a new value is emitted.
|
|
363
|
+
* @param alt - The alternate value to use if the signal is disposed or the mapping function throws an error.
|
|
364
|
+
* @param recover - The recovery function to handle errors thrown by the mapping function.
|
|
365
|
+
* @param equals - The equality function to compare the mapped values for equality.
|
|
366
|
+
* @returns A property that holds the mapped value and can be observed for changes.
|
|
367
|
+
*/
|
|
368
|
+
mapAsync = (e, s, r, n = (i, o) => i === o) => {
|
|
369
|
+
const i = _(s, n);
|
|
370
|
+
let o = 0, l = new AbortController();
|
|
371
|
+
return i.onDispose(
|
|
372
|
+
this.on(async (c) => {
|
|
373
|
+
const a = ++o;
|
|
374
|
+
l.abort(), l = new AbortController();
|
|
375
|
+
try {
|
|
376
|
+
const u = await e(c, { abortSignal: l.signal });
|
|
377
|
+
a === o && i.set(u);
|
|
378
|
+
} catch (u) {
|
|
379
|
+
if (a === o)
|
|
380
|
+
if (r != null)
|
|
381
|
+
i.set(r(u));
|
|
382
|
+
else
|
|
383
|
+
throw u;
|
|
384
|
+
}
|
|
385
|
+
})
|
|
386
|
+
), i;
|
|
387
|
+
};
|
|
388
|
+
/**
|
|
389
|
+
* Maps the values of the signal using the provided function `fn`, and returns a new signal
|
|
390
|
+
* containing the mapped values. If the mapped value is `undefined` or `null`, it is replaced
|
|
391
|
+
* with the provided `alt` value.
|
|
392
|
+
*
|
|
393
|
+
* @typeParam O - The type of the mapped value.
|
|
394
|
+
* @param fn - The function used to map the values of the signal.
|
|
395
|
+
* @param alt - The alternative value to use when the mapped value is `undefined` or `null`.
|
|
396
|
+
* @returns A new signal containing the mapped values.
|
|
397
|
+
*/
|
|
398
|
+
mapMaybe = (e, s) => this.map((r) => e(r) ?? s);
|
|
399
|
+
/**
|
|
400
|
+
* Feeds a property into the signal and sets up disposal behavior.
|
|
401
|
+
* @param prop - The property to feed into the signal.
|
|
402
|
+
* @param autoDisposeProp - Determines whether the property should be automatically disposed when the signal is disposed.
|
|
403
|
+
* @returns The input property.
|
|
404
|
+
*/
|
|
405
|
+
feedProp = (e, s = !1) => {
|
|
406
|
+
const r = this.on(e.set);
|
|
407
|
+
return e.onDispose(r), s ? this.onDispose(e.dispose) : this.onDispose(r), e;
|
|
408
|
+
};
|
|
409
|
+
/**
|
|
410
|
+
* Derives a new property from the current signal.
|
|
411
|
+
* @param options - The options for the derived property.
|
|
412
|
+
* @param options.autoDisposeProp - Determines whether the derived property should be automatically disposed.
|
|
413
|
+
* @param options.equals - A function that determines if two values are equal.
|
|
414
|
+
* @returns The derived property.
|
|
415
|
+
*/
|
|
416
|
+
deriveProp = ({
|
|
417
|
+
autoDisposeProp: e = !0,
|
|
418
|
+
equals: s
|
|
419
|
+
} = {}) => this.feedProp(_(this.get(), s), e);
|
|
420
|
+
/**
|
|
421
|
+
* Derives a new signal from the current signal. Useful to create a new signal that emits the same values as the current signal but can be disposed independently.
|
|
422
|
+
* @returns A new signal that emits the same values as the current signal.
|
|
423
|
+
*/
|
|
424
|
+
derive = () => this.map((e) => e);
|
|
425
|
+
/**
|
|
426
|
+
* Returns a signal that emits the count of values received so far.
|
|
427
|
+
* @returns A signal that emits the count of values received so far.
|
|
428
|
+
*/
|
|
429
|
+
count = () => {
|
|
430
|
+
let e = 0;
|
|
431
|
+
return this.map(() => ++e);
|
|
432
|
+
};
|
|
433
|
+
/**
|
|
434
|
+
* Adds a computed value as a derivative of the signal.
|
|
435
|
+
* When the computed value is disposed, it is automatically removed from the derivatives list.
|
|
436
|
+
* Additionally, when the computed value is disposed, it sets the signal as dirty.
|
|
437
|
+
* @param computed - The computed value to add as a derivative.
|
|
438
|
+
*/
|
|
439
|
+
setDerivative = (e) => {
|
|
440
|
+
this._derivatives.push(e), e.onDispose(() => {
|
|
441
|
+
this._derivatives.splice(
|
|
442
|
+
this._derivatives.indexOf(e),
|
|
443
|
+
1
|
|
444
|
+
);
|
|
445
|
+
}), e.onDispose(this.on(e.setDirty)), this.onDispose(e.dispose);
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
const je = typeof queueMicrotask == "function" ? queueMicrotask : (t) => Promise.resolve().then(t);
|
|
449
|
+
class H extends m {
|
|
460
450
|
/**
|
|
461
451
|
* Represents a Signal object.
|
|
462
452
|
* @param _fn - The function that returns the value of the signal.
|
|
463
453
|
* @param equals - The function used to compare two values of type T for equality.
|
|
464
454
|
*/
|
|
465
|
-
constructor(
|
|
466
|
-
super(void 0,
|
|
467
|
-
/**
|
|
468
|
-
* @internal
|
|
469
|
-
*/
|
|
470
|
-
o(this, "$__computed__", !0);
|
|
471
|
-
/**
|
|
472
|
-
* @internal
|
|
473
|
-
*/
|
|
474
|
-
o(this, "_isDirty", !1);
|
|
475
|
-
/**
|
|
476
|
-
* Marks the signal as dirty, indicating that its value has changed and needs to be recalculated.
|
|
477
|
-
* If the signal is already dirty or disposed, this method does nothing.
|
|
478
|
-
* It also marks all dependent signals as dirty and schedules a notification to update their values.
|
|
479
|
-
*/
|
|
480
|
-
o(this, "setDirty", () => {
|
|
481
|
-
this._isDirty || this._disposed || (this._isDirty = !0, this._derivatives.forEach((t) => t.setDirty()), this._scheduleNotify());
|
|
482
|
-
});
|
|
483
|
-
/**
|
|
484
|
-
* @internal
|
|
485
|
-
*/
|
|
486
|
-
o(this, "_scheduleCount", 0);
|
|
487
|
-
/**
|
|
488
|
-
* Schedules a notification to be executed asynchronously.
|
|
489
|
-
* If the signal is dirty, it will be updated and notified.
|
|
490
|
-
* @internal
|
|
491
|
-
*/
|
|
492
|
-
o(this, "_scheduleNotify", () => {
|
|
493
|
-
const t = ++this._scheduleCount;
|
|
494
|
-
Ze(() => {
|
|
495
|
-
this._scheduleCount !== t || this._disposed || this._isDirty && (this._isDirty = !1, this._setAndNotify(this._fn()));
|
|
496
|
-
});
|
|
497
|
-
});
|
|
498
|
-
/** {@inheritDoc Signal.get} */
|
|
499
|
-
o(this, "get", () => (this._isDirty && (this._isDirty = !1, this._setAndNotify(this._fn())), this._value));
|
|
500
|
-
this._fn = t, this.setDirty();
|
|
455
|
+
constructor(e, s) {
|
|
456
|
+
super(void 0, s), this._fn = e, this.setDirty();
|
|
501
457
|
}
|
|
502
458
|
/**
|
|
503
459
|
* Checks if a value is an instance of `Computed`.
|
|
@@ -505,135 +461,164 @@ class N extends d {
|
|
|
505
461
|
* @param value - The value to check.
|
|
506
462
|
* @returns `true` if the value is an instance of `Computed`, `false` otherwise.
|
|
507
463
|
*/
|
|
508
|
-
static is(
|
|
509
|
-
return
|
|
464
|
+
static is(e) {
|
|
465
|
+
return e != null && e.$__computed__ === !0;
|
|
510
466
|
}
|
|
467
|
+
/**
|
|
468
|
+
* @internal
|
|
469
|
+
*/
|
|
470
|
+
$__computed__ = !0;
|
|
471
|
+
/**
|
|
472
|
+
* @internal
|
|
473
|
+
*/
|
|
474
|
+
_isDirty = !1;
|
|
475
|
+
/**
|
|
476
|
+
* Marks the signal as dirty, indicating that its value has changed and needs to be recalculated.
|
|
477
|
+
* If the signal is already dirty or disposed, this method does nothing.
|
|
478
|
+
* It also marks all dependent signals as dirty and schedules a notification to update their values.
|
|
479
|
+
*/
|
|
480
|
+
setDirty = () => {
|
|
481
|
+
this._isDirty || this._disposed || (this._isDirty = !0, this._derivatives.forEach((e) => e.setDirty()), this._scheduleNotify());
|
|
482
|
+
};
|
|
483
|
+
/**
|
|
484
|
+
* @internal
|
|
485
|
+
*/
|
|
486
|
+
_scheduleCount = 0;
|
|
487
|
+
/**
|
|
488
|
+
* Schedules a notification to be executed asynchronously.
|
|
489
|
+
* If the signal is dirty, it will be updated and notified.
|
|
490
|
+
* @internal
|
|
491
|
+
*/
|
|
492
|
+
_scheduleNotify = () => {
|
|
493
|
+
const e = ++this._scheduleCount;
|
|
494
|
+
je(() => {
|
|
495
|
+
this._scheduleCount !== e || this._disposed || this._isDirty && (this._isDirty = !1, this._setAndNotify(this._fn()));
|
|
496
|
+
});
|
|
497
|
+
};
|
|
498
|
+
/** {@inheritDoc Signal.get} */
|
|
499
|
+
get = () => (this._isDirty && (this._isDirty = !1, this._setAndNotify(this._fn())), this._value);
|
|
511
500
|
/** {@inheritDoc Signal.value} */
|
|
512
501
|
get value() {
|
|
513
502
|
return this.get();
|
|
514
503
|
}
|
|
515
504
|
}
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
505
|
+
class Y extends m {
|
|
506
|
+
/**
|
|
507
|
+
* Checks if a value is a Prop.
|
|
508
|
+
* @param value - The value to check.
|
|
509
|
+
* @returns `true` if the value is a Prop, `false` otherwise.
|
|
510
|
+
*/
|
|
511
|
+
static is = (e) => (
|
|
512
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
513
|
+
e != null && e.$__prop__ === !0
|
|
514
|
+
);
|
|
515
|
+
/**
|
|
516
|
+
* @internal
|
|
517
|
+
*/
|
|
518
|
+
$__prop__ = !0;
|
|
519
|
+
/**
|
|
520
|
+
* Changes the value of the property and notifies its listeners.
|
|
521
|
+
*
|
|
522
|
+
* @param value - The new value of the property.
|
|
523
|
+
*/
|
|
524
|
+
set = (e) => {
|
|
525
|
+
this._setAndNotify(e);
|
|
526
|
+
};
|
|
527
|
+
/**
|
|
528
|
+
* Updates the value of the signal by applying the provided function to the current value.
|
|
529
|
+
* @param fn - The function to apply to the current value.
|
|
530
|
+
*/
|
|
531
|
+
update = (e) => {
|
|
532
|
+
this._setAndNotify(e(this.get()));
|
|
533
|
+
};
|
|
534
|
+
/**
|
|
535
|
+
* Creates a reducer function that combines the provided reducer function and effects.
|
|
536
|
+
* @param fn - The reducer function that takes the current state and an action, and returns the new state.
|
|
537
|
+
* @param effects - An array of effects to be executed after the state is updated.
|
|
538
|
+
* @returns A dispatch function that can be used to update the state and trigger the effects.
|
|
539
|
+
*/
|
|
540
|
+
reducer = (e, ...s) => {
|
|
541
|
+
const r = this;
|
|
542
|
+
return function n(i) {
|
|
543
|
+
const o = r.value;
|
|
544
|
+
r.update((l) => e(l, i)), !r.equals(o, r.value) && s.forEach(
|
|
545
|
+
(l) => l({
|
|
546
|
+
previousState: o,
|
|
547
|
+
state: r.value,
|
|
548
|
+
action: i,
|
|
549
|
+
dispatch: n
|
|
550
|
+
})
|
|
551
|
+
);
|
|
552
|
+
};
|
|
553
|
+
};
|
|
554
|
+
/**
|
|
555
|
+
* Creates an isomorphism for the Signal.
|
|
556
|
+
* An isomorphism is a pair of functions that convert values between two types,
|
|
557
|
+
* along with an equality function to compare values of the second type.
|
|
558
|
+
*
|
|
559
|
+
* @param to - A function that converts values from type T to type O.
|
|
560
|
+
* @param from - A function that converts values from type O to type T.
|
|
561
|
+
* @param equals - An optional function that compares values of type O for equality.
|
|
562
|
+
* Defaults to a strict equality check (===).
|
|
563
|
+
* @returns A Prop object representing the isomorphism.
|
|
564
|
+
*/
|
|
565
|
+
iso = (e, s, r = (n, i) => n === i) => {
|
|
566
|
+
const n = new Y(e(this.get()), r);
|
|
567
|
+
return n.onDispose(this.on((i) => n.set(e(i)))), n.on((i) => this._setAndNotify(s(i))), n;
|
|
568
|
+
};
|
|
569
|
+
/**
|
|
570
|
+
* Returns a `Prop` that represents the value at the specified key of the current value.
|
|
571
|
+
*
|
|
572
|
+
* @param key - The key of the value to access.
|
|
573
|
+
* @returns A `Prop` that represents the value at the specified key.
|
|
574
|
+
*/
|
|
575
|
+
atProp = (e) => this.iso(
|
|
576
|
+
(s) => s[e],
|
|
577
|
+
(s) => ({ ...this.value, [e]: s })
|
|
578
|
+
);
|
|
584
579
|
/**
|
|
585
580
|
* Access for the current value of the property.
|
|
586
581
|
*/
|
|
587
582
|
get value() {
|
|
588
583
|
return this.get();
|
|
589
584
|
}
|
|
590
|
-
set value(
|
|
591
|
-
this._setAndNotify(
|
|
585
|
+
set value(e) {
|
|
586
|
+
this._setAndNotify(e);
|
|
592
587
|
}
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
* @param value - The value to check.
|
|
597
|
-
* @returns `true` if the value is a Prop, `false` otherwise.
|
|
598
|
-
*/
|
|
599
|
-
o(te, "is", (t) => (
|
|
600
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
601
|
-
t != null && t.$__prop__ === !0
|
|
602
|
-
));
|
|
603
|
-
let X = te;
|
|
604
|
-
const ae = (s, e, t = (r, n) => r === n) => {
|
|
605
|
-
const r = new N(s, t);
|
|
588
|
+
}
|
|
589
|
+
const re = (t, e, s = (r, n) => r === n) => {
|
|
590
|
+
const r = new H(t, s);
|
|
606
591
|
return e.forEach((n) => n.setDerivative(r)), r;
|
|
607
|
-
},
|
|
608
|
-
let r =
|
|
609
|
-
i(),
|
|
610
|
-
} :
|
|
611
|
-
if (
|
|
612
|
-
let
|
|
613
|
-
const
|
|
592
|
+
}, qe = (t, e, s = {}) => {
|
|
593
|
+
let r = s.once ? () => {
|
|
594
|
+
i(), t();
|
|
595
|
+
} : t;
|
|
596
|
+
if (s.skipInitial) {
|
|
597
|
+
let o = !1;
|
|
598
|
+
const l = r;
|
|
614
599
|
r = () => {
|
|
615
|
-
|
|
600
|
+
o ? l() : o = !0;
|
|
616
601
|
};
|
|
617
602
|
}
|
|
618
|
-
const n =
|
|
619
|
-
n.dispose(),
|
|
603
|
+
const n = re(r, e), i = () => {
|
|
604
|
+
n.dispose(), s.abortSignal != null && s.abortSignal.removeEventListener("abort", i);
|
|
620
605
|
};
|
|
621
|
-
return
|
|
622
|
-
},
|
|
606
|
+
return s.abortSignal != null && s.abortSignal.addEventListener("abort", i), i;
|
|
607
|
+
}, _ = (t, e = (s, r) => s === r) => new Y(t, e), Q = (t, e = (s, r) => s === r) => new m(t, e), ne = () => (
|
|
623
608
|
/* c8 ignore next */
|
|
624
609
|
typeof window < "u" ? window : void 0
|
|
625
610
|
);
|
|
626
|
-
function
|
|
627
|
-
return
|
|
611
|
+
function he(t) {
|
|
612
|
+
return t != null && t !== !1 && t !== 0 && t !== "";
|
|
628
613
|
}
|
|
629
|
-
function
|
|
630
|
-
return !
|
|
614
|
+
function Fe(t) {
|
|
615
|
+
return !he(t);
|
|
631
616
|
}
|
|
632
|
-
function
|
|
633
|
-
return
|
|
617
|
+
function Be(t) {
|
|
618
|
+
return t == null;
|
|
634
619
|
}
|
|
635
|
-
function
|
|
636
|
-
return
|
|
620
|
+
function We(t) {
|
|
621
|
+
return t != null;
|
|
637
622
|
}
|
|
638
623
|
const y = {
|
|
639
624
|
/**
|
|
@@ -647,7 +632,7 @@ const y = {
|
|
|
647
632
|
* @param fn - The function to map the value.
|
|
648
633
|
* @returns The mapped value.
|
|
649
634
|
*/
|
|
650
|
-
map: (
|
|
635
|
+
map: (t, e) => m.is(t) ? t.map(e) : e(t),
|
|
651
636
|
/**
|
|
652
637
|
* Wraps a value or a Signal instance into a Signal.
|
|
653
638
|
* If the value is already a Signal, it returns the value itself.
|
|
@@ -658,30 +643,30 @@ const y = {
|
|
|
658
643
|
* @param equals - A function that determines if two values are equal. Defaults to strict equality (===).
|
|
659
644
|
* @returns A Signal instance.
|
|
660
645
|
*/
|
|
661
|
-
toSignal: (
|
|
646
|
+
toSignal: (t, e) => m.is(t) ? t.derive() : Q(t, e),
|
|
662
647
|
/**
|
|
663
648
|
* Wraps a value in a `Signal` if it is not already a `Signal`.
|
|
664
649
|
* If the value is `null` or `undefined`, it returns `null` or `undefined` respectively.
|
|
665
650
|
* @param value - The value to wrap or check.
|
|
666
651
|
* @returns The wrapped value if it is not `null` or `undefined`, otherwise `null` or `undefined`.
|
|
667
652
|
*/
|
|
668
|
-
maybeToSignal: (
|
|
669
|
-
if (
|
|
670
|
-
return y.toSignal(
|
|
653
|
+
maybeToSignal: (t, e) => {
|
|
654
|
+
if (t != null)
|
|
655
|
+
return y.toSignal(t, e);
|
|
671
656
|
},
|
|
672
657
|
/**
|
|
673
658
|
* Gets the value from a `Signal` or the value itself if it is not a `Signal`.
|
|
674
659
|
* @param value - The value or Signal instance to get the value from.
|
|
675
660
|
* @returns The value.
|
|
676
661
|
*/
|
|
677
|
-
get: (
|
|
662
|
+
get: (t) => m.is(t) ? t.get() : t,
|
|
678
663
|
/**
|
|
679
664
|
* Adds a listener to a `Signal` or calls the listener immediately if it is not a `Signal`.
|
|
680
665
|
* @param value - The value or Signal instance to add the listener to.
|
|
681
666
|
* @param listener - The listener to call when the value changes.
|
|
682
667
|
* @returns A function to remove the listener.
|
|
683
668
|
*/
|
|
684
|
-
on: (
|
|
669
|
+
on: (t, e) => m.is(t) ? t.on(e) : (e(t), () => {
|
|
685
670
|
}),
|
|
686
671
|
/**
|
|
687
672
|
* Disposes of a value or a Signal.
|
|
@@ -689,8 +674,8 @@ const y = {
|
|
|
689
674
|
* If the value is not a Signal, it does nothing.
|
|
690
675
|
* @param value - The value or Signal instance to dispose of.
|
|
691
676
|
*/
|
|
692
|
-
dispose: (
|
|
693
|
-
|
|
677
|
+
dispose: (t) => {
|
|
678
|
+
m.is(t) && t.dispose();
|
|
694
679
|
},
|
|
695
680
|
/**
|
|
696
681
|
* Derives a Prop from a Signal.
|
|
@@ -702,522 +687,271 @@ const y = {
|
|
|
702
687
|
* @param options.equals - A function that determines if two values are equal.
|
|
703
688
|
* @returns A Prop instance.
|
|
704
689
|
*/
|
|
705
|
-
deriveProp: (
|
|
690
|
+
deriveProp: (t, {
|
|
706
691
|
autoDisposeProp: e = !0,
|
|
707
|
-
equals:
|
|
708
|
-
} = {}) =>
|
|
692
|
+
equals: s
|
|
693
|
+
} = {}) => m.is(t) ? t.deriveProp({ autoDisposeProp: e, equals: s }) : _(t, s),
|
|
709
694
|
/**
|
|
710
695
|
* Creates a new signal that emits `true` if the value is truthy, `false` otherwise.
|
|
711
696
|
* @param value - The value or signal to check.
|
|
712
697
|
* @returns A signal that emits `true` if the value is truthy, `false` otherwise.
|
|
713
698
|
*/
|
|
714
|
-
truthy: (
|
|
699
|
+
truthy: (t) => y.map(t, he),
|
|
715
700
|
/**
|
|
716
701
|
* Creates a new signal that emits `true` if the value is falsy, `false` otherwise.
|
|
717
702
|
* @param value - The value or signal to check.
|
|
718
703
|
* @returns A signal that emits `true` if the value is falsy, `false` otherwise.
|
|
719
704
|
*/
|
|
720
|
-
falsy: (
|
|
705
|
+
falsy: (t) => y.map(t, Fe),
|
|
721
706
|
/**
|
|
722
707
|
* Creates a new signal that emits `true` if the value is null or undefined, `false` otherwise.
|
|
723
708
|
* @param value - The value or signal to check.
|
|
724
709
|
* @returns A signal that emits `true` if the value is null or undefined, `false` otherwise.
|
|
725
710
|
*/
|
|
726
|
-
nil: (
|
|
711
|
+
nil: (t) => y.map(t, Be),
|
|
727
712
|
/**
|
|
728
713
|
* Creates a new signal that emits `true` if the value is not null or undefined, `false` otherwise.
|
|
729
714
|
* @param value - The value or signal to check.
|
|
730
715
|
* @returns A signal that emits `true` if the value is not null or undefined, `false` otherwise.
|
|
731
716
|
*/
|
|
732
|
-
defined: (
|
|
733
|
-
},
|
|
734
|
-
if (
|
|
735
|
-
return y.toSignal(
|
|
736
|
-
const r =
|
|
737
|
-
return
|
|
738
|
-
() => e(...
|
|
717
|
+
defined: (t) => y.map(t, We)
|
|
718
|
+
}, ie = (...t) => (e, s) => {
|
|
719
|
+
if (t.length === 1)
|
|
720
|
+
return y.toSignal(t[0]).map(e);
|
|
721
|
+
const r = t.filter((n) => m.is(n));
|
|
722
|
+
return re(
|
|
723
|
+
() => e(...t.map((n) => y.get(n))),
|
|
739
724
|
r,
|
|
740
|
-
|
|
725
|
+
s
|
|
741
726
|
);
|
|
742
|
-
},
|
|
743
|
-
const e = Object.keys(
|
|
744
|
-
return
|
|
745
|
-
(...
|
|
727
|
+
}, Ht = (t) => {
|
|
728
|
+
const e = Object.keys(t);
|
|
729
|
+
return ie(...Object.values(t))(
|
|
730
|
+
(...s) => Object.fromEntries(e.map((r, n) => [r, s[n]]))
|
|
746
731
|
);
|
|
747
|
-
},
|
|
748
|
-
const r =
|
|
749
|
-
return
|
|
750
|
-
() => e(...
|
|
732
|
+
}, kt = (...t) => (e, s = {}) => {
|
|
733
|
+
const r = t.filter((n) => m.is(n));
|
|
734
|
+
return qe(
|
|
735
|
+
() => e(...t.map(y.get)),
|
|
751
736
|
r,
|
|
752
|
-
|
|
737
|
+
s
|
|
753
738
|
);
|
|
754
739
|
};
|
|
755
|
-
class
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
});
|
|
772
|
-
}
|
|
740
|
+
class fe {
|
|
741
|
+
_store = /* @__PURE__ */ new Map();
|
|
742
|
+
/**
|
|
743
|
+
* Retrieves the value associated with the specified key from the memory store.
|
|
744
|
+
* @param key - The key to retrieve the value for.
|
|
745
|
+
* @returns The value associated with the key, or `null` if the key is not found.
|
|
746
|
+
*/
|
|
747
|
+
getItem = (e) => this._store.get(e) ?? null;
|
|
748
|
+
/**
|
|
749
|
+
* Sets the value associated with the specified key in the memory store.
|
|
750
|
+
* @param key - The key to set the value for.
|
|
751
|
+
* @param value - The value to set.
|
|
752
|
+
*/
|
|
753
|
+
setItem = (e, s) => {
|
|
754
|
+
this._store.set(e, s);
|
|
755
|
+
};
|
|
773
756
|
}
|
|
774
|
-
const
|
|
775
|
-
key:
|
|
757
|
+
const de = ({
|
|
758
|
+
key: t,
|
|
776
759
|
defaultValue: e,
|
|
777
|
-
store:
|
|
760
|
+
store: s,
|
|
778
761
|
serialize: r = JSON.stringify,
|
|
779
762
|
deserialize: n = JSON.parse,
|
|
780
|
-
equals: i = (
|
|
781
|
-
onLoad:
|
|
782
|
-
syncTabs:
|
|
783
|
-
onKeyChange:
|
|
763
|
+
equals: i = (a, u) => a === u,
|
|
764
|
+
onLoad: o = (a) => a,
|
|
765
|
+
syncTabs: l = !0,
|
|
766
|
+
onKeyChange: c = "load"
|
|
784
767
|
}) => {
|
|
785
|
-
let
|
|
786
|
-
const
|
|
787
|
-
|
|
768
|
+
let a = y.get(t);
|
|
769
|
+
const u = s.getItem(a), p = new Y(
|
|
770
|
+
u != null ? o(n(u)) : typeof e == "function" ? e() : e,
|
|
788
771
|
i
|
|
789
|
-
),
|
|
790
|
-
let
|
|
791
|
-
const
|
|
792
|
-
if (!
|
|
793
|
-
const
|
|
794
|
-
const
|
|
795
|
-
if (!(
|
|
772
|
+
), d = ne(), f = l && typeof d?.BroadcastChannel == "function";
|
|
773
|
+
let g = !1, w = null, C = null;
|
|
774
|
+
const S = (b) => {
|
|
775
|
+
if (!f) return null;
|
|
776
|
+
const D = `tempo:storedProp:${b}`, A = new d.BroadcastChannel(D), O = `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`, x = (j) => {
|
|
777
|
+
const v = j.data;
|
|
778
|
+
if (!(v == null || typeof v != "object" || v.key !== b || typeof v.value != "string" || v.sourceId != null && v.sourceId === O))
|
|
796
779
|
try {
|
|
797
|
-
|
|
798
|
-
const
|
|
799
|
-
p.set(
|
|
800
|
-
} catch (
|
|
780
|
+
g = !0;
|
|
781
|
+
const te = o(n(v.value));
|
|
782
|
+
p.set(te);
|
|
783
|
+
} catch (te) {
|
|
801
784
|
console.warn(
|
|
802
785
|
`Failed to sync storedProp for key "${b}" via BroadcastChannel`,
|
|
803
|
-
|
|
786
|
+
te
|
|
804
787
|
);
|
|
805
788
|
} finally {
|
|
806
|
-
|
|
789
|
+
g = !1;
|
|
807
790
|
}
|
|
808
791
|
};
|
|
809
|
-
return A.addEventListener("message",
|
|
810
|
-
A
|
|
811
|
-
}), { channel: A, instanceId:
|
|
812
|
-
},
|
|
813
|
-
|
|
814
|
-
const
|
|
815
|
-
const
|
|
816
|
-
if (
|
|
817
|
-
const A = p.get(),
|
|
818
|
-
if (
|
|
819
|
-
const
|
|
820
|
-
if (
|
|
792
|
+
return A.addEventListener("message", x), p.onDispose(() => {
|
|
793
|
+
A?.removeEventListener("message", x), A?.close();
|
|
794
|
+
}), { channel: A, instanceId: O, handleMessage: x };
|
|
795
|
+
}, P = S(a);
|
|
796
|
+
P && (w = P.channel, C = P.instanceId);
|
|
797
|
+
const ee = (b) => {
|
|
798
|
+
const D = a;
|
|
799
|
+
if (D === b) return;
|
|
800
|
+
const A = p.get(), O = r(A);
|
|
801
|
+
if (s.setItem(D, O), w != null && (w.close(), w = null, C = null), a = b, c === "load") {
|
|
802
|
+
const j = s.getItem(b);
|
|
803
|
+
if (j != null)
|
|
821
804
|
try {
|
|
822
|
-
const
|
|
823
|
-
p.set(
|
|
824
|
-
} catch (
|
|
805
|
+
const v = o(n(j));
|
|
806
|
+
p.set(v);
|
|
807
|
+
} catch (v) {
|
|
825
808
|
console.warn(
|
|
826
809
|
`Failed to load storedProp from new key "${b}"`,
|
|
827
|
-
|
|
810
|
+
v
|
|
828
811
|
);
|
|
829
812
|
}
|
|
830
813
|
else
|
|
831
|
-
|
|
832
|
-
} else
|
|
833
|
-
const
|
|
834
|
-
|
|
814
|
+
s.setItem(b, O);
|
|
815
|
+
} else c === "migrate" && s.setItem(b, O);
|
|
816
|
+
const x = S(b);
|
|
817
|
+
x && (w = x.channel, C = x.instanceId);
|
|
835
818
|
};
|
|
836
|
-
return
|
|
819
|
+
return m.is(t) && p.onDispose(t.on(ee)), p.on((b, D) => {
|
|
837
820
|
const A = r(b);
|
|
838
|
-
|
|
839
|
-
key:
|
|
821
|
+
s.setItem(a, A), w != null && !g && D !== void 0 && C != null && w.postMessage({
|
|
822
|
+
key: a,
|
|
840
823
|
value: A,
|
|
841
|
-
sourceId:
|
|
824
|
+
sourceId: C
|
|
842
825
|
});
|
|
843
826
|
}), p;
|
|
844
|
-
},
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
/* c8 ignore next 3 */
|
|
856
|
-
store: ((e = ue()) == null ? void 0 : e.sessionStorage) ?? new Ae()
|
|
857
|
-
});
|
|
858
|
-
};
|
|
859
|
-
function ye(s) {
|
|
860
|
-
return typeof requestAnimationFrame == "function" ? requestAnimationFrame(s) : setTimeout(s, 0);
|
|
827
|
+
}, $t = (t) => de({
|
|
828
|
+
...t,
|
|
829
|
+
/* c8 ignore next 3 */
|
|
830
|
+
store: ne()?.localStorage ?? new fe()
|
|
831
|
+
}), Nt = (t) => de({
|
|
832
|
+
...t,
|
|
833
|
+
/* c8 ignore next 3 */
|
|
834
|
+
store: ne()?.sessionStorage ?? new fe()
|
|
835
|
+
});
|
|
836
|
+
function ae(t) {
|
|
837
|
+
return typeof requestAnimationFrame == "function" ? requestAnimationFrame(t) : setTimeout(t, 0);
|
|
861
838
|
}
|
|
862
|
-
const
|
|
863
|
-
const n =
|
|
864
|
-
let
|
|
865
|
-
const
|
|
866
|
-
|
|
839
|
+
const Ue = (t, e, s, r) => {
|
|
840
|
+
const n = r?.duration ?? 300, i = r?.easing ?? ((S) => S), o = r?.equals ?? ((S, P) => S === P);
|
|
841
|
+
let l = r?.interpolate, c = t, a = e(), u = performance.now(), p = null, d = !0;
|
|
842
|
+
const f = new H(e, o), g = _(t, o);
|
|
843
|
+
g.onDispose(() => {
|
|
867
844
|
p !== null && cancelAnimationFrame(p);
|
|
868
|
-
}),
|
|
869
|
-
|
|
845
|
+
}), g.onDispose(f.dispose), s.forEach((S) => {
|
|
846
|
+
S.setDerivative(f), S.onDispose(g.dispose);
|
|
870
847
|
});
|
|
871
|
-
const
|
|
872
|
-
|
|
873
|
-
},
|
|
874
|
-
const
|
|
875
|
-
|
|
876
|
-
let b = c
|
|
877
|
-
|
|
878
|
-
};
|
|
879
|
-
return
|
|
880
|
-
},
|
|
881
|
-
const { initialValue:
|
|
882
|
-
return
|
|
848
|
+
const w = (S) => {
|
|
849
|
+
a = S, u = performance.now(), c = g.value, d && (d = !1, p = ae(C));
|
|
850
|
+
}, C = () => {
|
|
851
|
+
const P = (performance.now() - u) / y.get(n), ee = i(P);
|
|
852
|
+
l == null && (l = Ve(c));
|
|
853
|
+
let b = l(c, a, ee);
|
|
854
|
+
P >= 1 ? (d = !0, b = a) : p = ae(C), g.set(b);
|
|
855
|
+
};
|
|
856
|
+
return f.on(w), g;
|
|
857
|
+
}, Rt = (t, e) => {
|
|
858
|
+
const { initialValue: s, ...r } = e ?? {};
|
|
859
|
+
return Ue(
|
|
883
860
|
/* c8 ignore next 2 */
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
[
|
|
861
|
+
s ?? t.get(),
|
|
862
|
+
t.get,
|
|
863
|
+
[t],
|
|
887
864
|
r
|
|
888
865
|
);
|
|
889
|
-
},
|
|
890
|
-
const
|
|
891
|
-
return
|
|
866
|
+
}, Je = (t, e) => {
|
|
867
|
+
const s = Object.values(t).filter(m.is), r = Object.keys(t);
|
|
868
|
+
return re(() => {
|
|
892
869
|
const n = {};
|
|
893
870
|
for (const i of r)
|
|
894
|
-
n[i] = y.get(
|
|
871
|
+
n[i] = y.get(t[i]);
|
|
895
872
|
return e(n);
|
|
896
|
-
},
|
|
897
|
-
},
|
|
898
|
-
const
|
|
873
|
+
}, s);
|
|
874
|
+
}, Vt = (t) => Je(t, (e) => e), jt = (t, e) => {
|
|
875
|
+
const s = _(t.get());
|
|
899
876
|
let r = null;
|
|
900
|
-
const n =
|
|
877
|
+
const n = t.on((i) => {
|
|
901
878
|
r != null && clearTimeout(r), r = setTimeout(
|
|
902
879
|
() => {
|
|
903
|
-
r = null,
|
|
880
|
+
r = null, s.set(i);
|
|
904
881
|
},
|
|
905
882
|
typeof e == "function" ? e(i) : e
|
|
906
883
|
);
|
|
907
884
|
});
|
|
908
|
-
return
|
|
885
|
+
return s.onDispose(() => {
|
|
909
886
|
n(), r != null && clearTimeout(r);
|
|
910
|
-
}),
|
|
911
|
-
},
|
|
887
|
+
}), s;
|
|
888
|
+
}, qt = (t) => {
|
|
912
889
|
let e;
|
|
913
|
-
return
|
|
890
|
+
return t.map((s) => {
|
|
914
891
|
const r = e;
|
|
915
|
-
return e =
|
|
892
|
+
return e = s, r;
|
|
916
893
|
});
|
|
917
|
-
},
|
|
918
|
-
size:
|
|
894
|
+
}, Ft = ({
|
|
895
|
+
size: t = void 0,
|
|
919
896
|
signal: e
|
|
920
897
|
}) => {
|
|
921
|
-
const
|
|
922
|
-
return e.map((r) => (
|
|
923
|
-
},
|
|
924
|
-
|
|
898
|
+
const s = [];
|
|
899
|
+
return e.map((r) => (s.push(r), t != null && s.length > t && s.shift(), s.slice()));
|
|
900
|
+
}, Bt = (t) => (...e) => ie(
|
|
901
|
+
t,
|
|
925
902
|
...e
|
|
926
|
-
)((
|
|
927
|
-
function
|
|
928
|
-
return
|
|
929
|
-
for (const
|
|
903
|
+
)((s, ...r) => s(...r));
|
|
904
|
+
function Wt(...t) {
|
|
905
|
+
return ie(...t)((...e) => {
|
|
906
|
+
for (const s of e) if (s != null) return s;
|
|
930
907
|
});
|
|
931
908
|
}
|
|
932
|
-
const
|
|
909
|
+
const pe = /* @__PURE__ */ new Set(["checked", "disabled", "hidden"]), me = /* @__PURE__ */ new Set(["selected"]), ge = /* @__PURE__ */ new Set([
|
|
933
910
|
"rowSpan",
|
|
934
911
|
"colSpan",
|
|
935
912
|
"tabIndex",
|
|
936
|
-
"valueAsNumber"
|
|
937
|
-
]),
|
|
938
|
-
"value",
|
|
939
|
-
"textContent",
|
|
940
|
-
"innerText",
|
|
941
|
-
"innerHTML",
|
|
942
|
-
"outerHTML",
|
|
943
|
-
"className",
|
|
944
|
-
"classList"
|
|
945
|
-
]),
|
|
946
|
-
|
|
947
|
-
} :
|
|
948
|
-
|
|
949
|
-
} :
|
|
950
|
-
|
|
951
|
-
} :
|
|
952
|
-
|
|
953
|
-
} :
|
|
954
|
-
|
|
955
|
-
} : (
|
|
956
|
-
|
|
957
|
-
},
|
|
958
|
-
const e =
|
|
959
|
-
e && e.onblur && (e.onblur = null), !(!
|
|
960
|
-
},
|
|
961
|
-
class
|
|
962
|
-
constructor(e) {
|
|
963
|
-
super(`Provider not found: ${e.description}`);
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
class
|
|
967
|
-
/**
|
|
968
|
-
* Constructs a new `DOMContext` instance.
|
|
969
|
-
*
|
|
970
|
-
* @param document - The `Document` instance associated with this context.
|
|
971
|
-
* @param element - The `Element` instance associated with this context.
|
|
972
|
-
* @param reference - An optional `Node` instance that serves as a reference for this context.
|
|
973
|
-
* @param providers - The `Providers` instance associated with this context.
|
|
974
|
-
* @param isFirstLevel - A boolean value indicating whether this context is at the first level, meaning the outermost node in the generated DOM.
|
|
975
|
-
*/
|
|
976
|
-
constructor(e,
|
|
977
|
-
|
|
978
|
-
* Creates a new DOM element (eg: HTML or SVG) with the specified tag name and namespace.
|
|
979
|
-
*
|
|
980
|
-
* @param tagName - The tag name of the element to create.
|
|
981
|
-
* @param namespace - The namespace URI to create the element in, or `undefined` to create a standard HTML element.
|
|
982
|
-
* @returns The newly created element.
|
|
983
|
-
*/
|
|
984
|
-
o(this, "createElement", (e, t) => t !== void 0 ? this.document.createElementNS(t, e) : this.document.createElement(e));
|
|
985
|
-
/**
|
|
986
|
-
* Creates a new child element and appends it to the current element, returning a new context.
|
|
987
|
-
*
|
|
988
|
-
* This method creates a new DOM element with the specified tag name and namespace,
|
|
989
|
-
* appends it to the current element, and returns a new DOMContext focused on the
|
|
990
|
-
* newly created child element. This is the primary method for building DOM trees.
|
|
991
|
-
*
|
|
992
|
-
* @example
|
|
993
|
-
* ```typescript
|
|
994
|
-
* // Create HTML elements
|
|
995
|
-
* const divCtx = ctx.makeChildElement('div', undefined)
|
|
996
|
-
* const spanCtx = divCtx.makeChildElement('span', undefined)
|
|
997
|
-
*
|
|
998
|
-
* // Create SVG elements
|
|
999
|
-
* const svgCtx = ctx.makeChildElement('svg', 'http://www.w3.org/2000/svg')
|
|
1000
|
-
* const circleCtx = svgCtx.makeChildElement('circle', 'http://www.w3.org/2000/svg')
|
|
1001
|
-
* ```
|
|
1002
|
-
*
|
|
1003
|
-
* @param tagName - The tag name of the element to create (e.g., 'div', 'span', 'svg')
|
|
1004
|
-
* @param namespace - The namespace URI for the element, or undefined for HTML elements
|
|
1005
|
-
* @returns A new DOMContext focused on the newly created child element
|
|
1006
|
-
*/
|
|
1007
|
-
o(this, "makeChildElement", (e, t) => {
|
|
1008
|
-
const r = this.createElement(e, t);
|
|
1009
|
-
return this.appendOrInsert(r), this.withElement(r);
|
|
1010
|
-
});
|
|
1011
|
-
/**
|
|
1012
|
-
* Creates a new text node with the specified text content.
|
|
1013
|
-
* @param text - The text content for the new text node.
|
|
1014
|
-
* @returns A new `Text` node with the specified text content.
|
|
1015
|
-
*/
|
|
1016
|
-
o(this, "createText", (e) => this.document.createTextNode(e));
|
|
1017
|
-
/**
|
|
1018
|
-
* Creates a new text node with the specified text content and appends it to the current element.
|
|
1019
|
-
* @param text - The text content for the new text node.
|
|
1020
|
-
* @returns A new `DOMContext` with a reference to the new text node.
|
|
1021
|
-
*/
|
|
1022
|
-
o(this, "makeChildText", (e) => {
|
|
1023
|
-
const t = this.createText(e);
|
|
1024
|
-
return this.appendOrInsert(t), this.withReference(t);
|
|
1025
|
-
});
|
|
1026
|
-
/**
|
|
1027
|
-
* Sets the text content of the current element.
|
|
1028
|
-
* @param text - The text content to set.
|
|
1029
|
-
*/
|
|
1030
|
-
o(this, "setText", (e) => {
|
|
1031
|
-
this.reference.nodeValue = e;
|
|
1032
|
-
});
|
|
1033
|
-
/**
|
|
1034
|
-
* Gets the text content of the current element or text node.
|
|
1035
|
-
* @returns The text content of the current element or text node.
|
|
1036
|
-
*/
|
|
1037
|
-
o(this, "getText", () => {
|
|
1038
|
-
var e;
|
|
1039
|
-
return ((e = this.reference) == null ? void 0 : e.nodeValue) ?? this.element.textContent ?? "";
|
|
1040
|
-
});
|
|
1041
|
-
/**
|
|
1042
|
-
* Creates a new `DOMContext` with a reference to a newly created text node.
|
|
1043
|
-
* The text node is appended or inserted to the current `DOMContext`.
|
|
1044
|
-
* The new `DOMContext` with the reference is returned.
|
|
1045
|
-
*/
|
|
1046
|
-
o(this, "makeRef", () => {
|
|
1047
|
-
const e = this.createText("");
|
|
1048
|
-
return this.appendOrInsert(e), this.withReference(e);
|
|
1049
|
-
});
|
|
1050
|
-
/**
|
|
1051
|
-
* Appends or inserts a child node to the element, depending on whether a reference node is provided.
|
|
1052
|
-
*
|
|
1053
|
-
* @param child - The child node to append or insert.
|
|
1054
|
-
*/
|
|
1055
|
-
o(this, "appendOrInsert", (e) => {
|
|
1056
|
-
this.reference === void 0 ? this.element.appendChild(e) : this.element.insertBefore(e, this.reference);
|
|
1057
|
-
});
|
|
1058
|
-
/**
|
|
1059
|
-
* Creates a new `DOMContext` instance with the provided `element`.
|
|
1060
|
-
* @param element - The DOM element to use in the new `DOMContext` instance.
|
|
1061
|
-
* @returns A new `DOMContext` instance with the provided `element`.
|
|
1062
|
-
*/
|
|
1063
|
-
o(this, "withElement", (e) => new R(this.document, e, void 0, this.providers));
|
|
1064
|
-
/**
|
|
1065
|
-
* Creates a portal to render content in a different part of the DOM tree.
|
|
1066
|
-
*
|
|
1067
|
-
* Portals allow you to render child components into a DOM node that exists outside
|
|
1068
|
-
* the parent component's DOM hierarchy. This is useful for modals, tooltips,
|
|
1069
|
-
* dropdowns, and other UI elements that need to break out of their container's
|
|
1070
|
-
* styling or z-index context.
|
|
1071
|
-
*
|
|
1072
|
-
* @example
|
|
1073
|
-
* ```typescript
|
|
1074
|
-
* // Portal to a modal container
|
|
1075
|
-
* const modalCtx = ctx.makePortal('#modal-root')
|
|
1076
|
-
* const modal = modalCtx.makeChildElement('div', undefined)
|
|
1077
|
-
*
|
|
1078
|
-
* // Add modal content
|
|
1079
|
-
* modal.makeChildText('This renders in #modal-root')
|
|
1080
|
-
* ```
|
|
1081
|
-
*
|
|
1082
|
-
* @example
|
|
1083
|
-
* ```typescript
|
|
1084
|
-
* // Portal to an existing element reference
|
|
1085
|
-
* const tooltipContainer = document.getElementById('tooltip-container')!
|
|
1086
|
-
* const tooltipCtx = ctx.makePortal(tooltipContainer)
|
|
1087
|
-
*
|
|
1088
|
-
* // Render tooltip content
|
|
1089
|
-
* const tooltip = tooltipCtx.makeChildElement('div', undefined)
|
|
1090
|
-
* tooltip.addClasses(['tooltip', 'tooltip-top'])
|
|
1091
|
-
* ```
|
|
1092
|
-
*
|
|
1093
|
-
* @example
|
|
1094
|
-
* ```typescript
|
|
1095
|
-
* // Portal for dropdown menu
|
|
1096
|
-
* const dropdownCtx = ctx.makePortal('body') // Render at body level
|
|
1097
|
-
* const dropdown = dropdownCtx.makeChildElement('div', undefined)
|
|
1098
|
-
* dropdown.addClasses(['dropdown-menu'])
|
|
1099
|
-
* dropdown.setStyle('position', 'absolute')
|
|
1100
|
-
* dropdown.setStyle('top', '100px')
|
|
1101
|
-
* dropdown.setStyle('left', '50px')
|
|
1102
|
-
* ```
|
|
1103
|
-
*
|
|
1104
|
-
* @param selector - CSS selector string or HTMLElement reference for the portal target
|
|
1105
|
-
* @returns A new DOMContext focused on the portal target element
|
|
1106
|
-
* @throws {Error} When the selector doesn't match any element in the document
|
|
1107
|
-
*/
|
|
1108
|
-
o(this, "makePortal", (e) => {
|
|
1109
|
-
const t = typeof e == "string" ? this.document.querySelector(e) : e;
|
|
1110
|
-
if (t == null)
|
|
1111
|
-
throw new Error(`Cannot find element by selector for portal: ${e}`);
|
|
1112
|
-
return this.withElement(t);
|
|
1113
|
-
});
|
|
1114
|
-
/**
|
|
1115
|
-
* Creates a new `DOMContext` instance with the specified reference.
|
|
1116
|
-
*
|
|
1117
|
-
* @param reference - The optional `Text` node to use as the reference for the new `DOMContext`.
|
|
1118
|
-
* @returns A new `DOMContext` instance with the specified reference.
|
|
1119
|
-
*/
|
|
1120
|
-
o(this, "withReference", (e) => new R(this.document, this.element, e, this.providers));
|
|
1121
|
-
/**
|
|
1122
|
-
* Sets a provider for the given provider mark.
|
|
1123
|
-
*
|
|
1124
|
-
* @param mark - The provider mark to set the provider for.
|
|
1125
|
-
* @param value - The provider to set for the given mark.
|
|
1126
|
-
* @returns A new `DOMContext` instance with the specified provider.
|
|
1127
|
-
*/
|
|
1128
|
-
o(this, "setProvider", (e, t, r) => new R(this.document, this.element, this.reference, {
|
|
1129
|
-
...this.providers,
|
|
1130
|
-
[e]: [t, r]
|
|
1131
|
-
}));
|
|
1132
|
-
/**
|
|
1133
|
-
* Retrieves a provider for the given provider mark.
|
|
1134
|
-
*
|
|
1135
|
-
* @param mark - The provider mark to retrieve the provider for.
|
|
1136
|
-
* @returns The provider for the given mark.
|
|
1137
|
-
* @throws Throws `ProviderNotFoundError` if the provider for the given mark is not found.
|
|
1138
|
-
*/
|
|
1139
|
-
o(this, "getProvider", (e) => {
|
|
1140
|
-
if (this.providers[e] === void 0)
|
|
1141
|
-
throw new De(e);
|
|
1142
|
-
const [t, r] = this.providers[e];
|
|
1143
|
-
return { value: t, onUse: r };
|
|
1144
|
-
});
|
|
1145
|
-
o(this, "clear", (e) => {
|
|
1146
|
-
e && (this.reference !== void 0 ? Y(this.reference) : Y(this.element));
|
|
1147
|
-
});
|
|
1148
|
-
/**
|
|
1149
|
-
* Adds classes to the element.
|
|
1150
|
-
* @param tokens - The class names to add.
|
|
1151
|
-
*/
|
|
1152
|
-
o(this, "addClasses", (e) => {
|
|
1153
|
-
this.element.classList.add(...e);
|
|
1154
|
-
});
|
|
1155
|
-
/**
|
|
1156
|
-
* Removes classes from the element.
|
|
1157
|
-
* @param tokens - The class names to remove.
|
|
1158
|
-
*/
|
|
1159
|
-
o(this, "removeClasses", (e) => {
|
|
1160
|
-
this.element.classList.remove(...e);
|
|
1161
|
-
});
|
|
1162
|
-
/**
|
|
1163
|
-
* Gets the classes of the element.
|
|
1164
|
-
* @returns The classes of the element.
|
|
1165
|
-
*/
|
|
1166
|
-
o(this, "getClasses", () => Array.from(this.element.classList));
|
|
1167
|
-
/**
|
|
1168
|
-
* Adds an event listener to the element.
|
|
1169
|
-
* @param event - The event to listen for.
|
|
1170
|
-
* @param listener - The listener to call when the event occurs.
|
|
1171
|
-
* @param options - The options for the event listener.
|
|
1172
|
-
* @returns A function to remove the event listener.
|
|
1173
|
-
*/
|
|
1174
|
-
o(this, "on", (e, t, r) => {
|
|
1175
|
-
const n = (i) => t(i, this);
|
|
1176
|
-
return this.element.addEventListener(e, n, r), (i) => {
|
|
1177
|
-
i && this.element.removeEventListener(e, n, r);
|
|
1178
|
-
};
|
|
1179
|
-
});
|
|
1180
|
-
/**
|
|
1181
|
-
* Returns `true` if the context is a browser DOM context.
|
|
1182
|
-
* @returns `true` if the context is a browser DOM context.
|
|
1183
|
-
* @deprecated Use `isBrowser()` instead.
|
|
1184
|
-
*/
|
|
1185
|
-
o(this, "isBrowserDOM", () => !0);
|
|
1186
|
-
/**
|
|
1187
|
-
* Returns `true` if the context is a browser context.
|
|
1188
|
-
* @returns `true` if the context is a browser context.
|
|
1189
|
-
*/
|
|
1190
|
-
o(this, "isBrowser", () => !0);
|
|
1191
|
-
/**
|
|
1192
|
-
* Returns `true` if the context is a headless DOM context.
|
|
1193
|
-
* @returns `true` if the context is a headless DOM context.
|
|
1194
|
-
*/
|
|
1195
|
-
o(this, "isHeadlessDOM", () => !1);
|
|
1196
|
-
/**
|
|
1197
|
-
* Returns `true` if the context is a headless context.
|
|
1198
|
-
* @returns `true` if the context is a headless context.
|
|
1199
|
-
*/
|
|
1200
|
-
o(this, "isHeadless", () => !1);
|
|
1201
|
-
/**
|
|
1202
|
-
* Sets the style of the element.
|
|
1203
|
-
* @param name - The name of the style to set.
|
|
1204
|
-
* @param value - The value of the style to set.
|
|
1205
|
-
*/
|
|
1206
|
-
o(this, "setStyle", (e, t) => {
|
|
1207
|
-
this.element.style[e] = t;
|
|
1208
|
-
});
|
|
1209
|
-
/**
|
|
1210
|
-
* Gets the style of the element.
|
|
1211
|
-
* @param name - The name of the style to get.
|
|
1212
|
-
* @returns The value of the style.
|
|
1213
|
-
*/
|
|
1214
|
-
o(this, "getStyle", (e) => this.element.style[e]);
|
|
1215
|
-
o(this, "makeAccessors", (e) => ({
|
|
1216
|
-
get: it(e, this.element),
|
|
1217
|
-
set: nt(e, this.element)
|
|
1218
|
-
}));
|
|
1219
|
-
o(this, "getWindow", () => this.document.defaultView);
|
|
1220
|
-
this.document = e, this.element = t, this.reference = r, this.providers = n;
|
|
913
|
+
"valueAsNumber"
|
|
914
|
+
]), ye = /* @__PURE__ */ new Set(["valueAsDate"]), be = /* @__PURE__ */ new Set([
|
|
915
|
+
"value",
|
|
916
|
+
"textContent",
|
|
917
|
+
"innerText",
|
|
918
|
+
"innerHTML",
|
|
919
|
+
"outerHTML",
|
|
920
|
+
"className",
|
|
921
|
+
"classList"
|
|
922
|
+
]), Ge = (t, e) => me.has(t) ? (s) => {
|
|
923
|
+
s == null || s !== !0 ? e.removeAttribute(t) : e.setAttribute(t, "");
|
|
924
|
+
} : pe.has(t) ? (s) => {
|
|
925
|
+
s == null ? e[t] = null : e[t] = !!s;
|
|
926
|
+
} : ge.has(t) ? (s) => {
|
|
927
|
+
s == null ? e[t] = null : e[t] = Number(s);
|
|
928
|
+
} : ye.has(t) ? (s) => {
|
|
929
|
+
s == null ? e[t] = null : e[t] = s;
|
|
930
|
+
} : be.has(t) ? (s) => {
|
|
931
|
+
s == null ? e[t] = null : e[t] = String(s);
|
|
932
|
+
} : (s) => {
|
|
933
|
+
s == null ? e.removeAttribute(t) : e.setAttribute(t, s);
|
|
934
|
+
}, Xe = (t, e) => me.has(t) ? () => e.hasAttribute(t) : pe.has(t) ? () => !!e[t] : ge.has(t) ? () => Number(e[t]) : ye.has(t) ? () => e[t] : be.has(t) ? () => String(e[t]) : () => e.getAttribute(t), B = (t) => {
|
|
935
|
+
const e = t;
|
|
936
|
+
e && e.onblur && (e.onblur = null), !(!t || t.ownerDocument === void 0) && t.parentElement && t.parentElement.removeChild(t);
|
|
937
|
+
}, Ye = (t) => we(t) ? t : t.parentElement, we = (t) => t.nodeType === 1;
|
|
938
|
+
class Se extends Error {
|
|
939
|
+
constructor(e) {
|
|
940
|
+
super(`Provider not found: ${e.description}`);
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
class k {
|
|
944
|
+
/**
|
|
945
|
+
* Constructs a new `DOMContext` instance.
|
|
946
|
+
*
|
|
947
|
+
* @param document - The `Document` instance associated with this context.
|
|
948
|
+
* @param element - The `Element` instance associated with this context.
|
|
949
|
+
* @param reference - An optional `Node` instance that serves as a reference for this context.
|
|
950
|
+
* @param providers - The `Providers` instance associated with this context.
|
|
951
|
+
* @param isFirstLevel - A boolean value indicating whether this context is at the first level, meaning the outermost node in the generated DOM.
|
|
952
|
+
*/
|
|
953
|
+
constructor(e, s, r, n) {
|
|
954
|
+
this.document = e, this.element = s, this.reference = r, this.providers = n;
|
|
1221
955
|
}
|
|
1222
956
|
/**
|
|
1223
957
|
* Creates a new `DOMContext` instance for the given `Element` and optional reference `Node`.
|
|
@@ -1227,509 +961,739 @@ class R {
|
|
|
1227
961
|
* @param providers - The providers to associate with the `DOMContext`.
|
|
1228
962
|
* @returns A new `DOMContext` instance.
|
|
1229
963
|
*/
|
|
1230
|
-
static of(e,
|
|
1231
|
-
return new
|
|
964
|
+
static of(e, s, r) {
|
|
965
|
+
return new k(e.ownerDocument, e, s, r);
|
|
1232
966
|
}
|
|
967
|
+
/**
|
|
968
|
+
* Creates a new DOM element (eg: HTML or SVG) with the specified tag name and namespace.
|
|
969
|
+
*
|
|
970
|
+
* @param tagName - The tag name of the element to create.
|
|
971
|
+
* @param namespace - The namespace URI to create the element in, or `undefined` to create a standard HTML element.
|
|
972
|
+
* @returns The newly created element.
|
|
973
|
+
*/
|
|
974
|
+
createElement = (e, s) => s !== void 0 ? this.document.createElementNS(s, e) : this.document.createElement(e);
|
|
975
|
+
/**
|
|
976
|
+
* Creates a new child element and appends it to the current element, returning a new context.
|
|
977
|
+
*
|
|
978
|
+
* This method creates a new DOM element with the specified tag name and namespace,
|
|
979
|
+
* appends it to the current element, and returns a new DOMContext focused on the
|
|
980
|
+
* newly created child element. This is the primary method for building DOM trees.
|
|
981
|
+
*
|
|
982
|
+
* @example
|
|
983
|
+
* ```typescript
|
|
984
|
+
* // Create HTML elements
|
|
985
|
+
* const divCtx = ctx.makeChildElement('div', undefined)
|
|
986
|
+
* const spanCtx = divCtx.makeChildElement('span', undefined)
|
|
987
|
+
*
|
|
988
|
+
* // Create SVG elements
|
|
989
|
+
* const svgCtx = ctx.makeChildElement('svg', 'http://www.w3.org/2000/svg')
|
|
990
|
+
* const circleCtx = svgCtx.makeChildElement('circle', 'http://www.w3.org/2000/svg')
|
|
991
|
+
* ```
|
|
992
|
+
*
|
|
993
|
+
* @param tagName - The tag name of the element to create (e.g., 'div', 'span', 'svg')
|
|
994
|
+
* @param namespace - The namespace URI for the element, or undefined for HTML elements
|
|
995
|
+
* @returns A new DOMContext focused on the newly created child element
|
|
996
|
+
*/
|
|
997
|
+
makeChildElement = (e, s) => {
|
|
998
|
+
const r = this.createElement(e, s);
|
|
999
|
+
return this.appendOrInsert(r), this.withElement(r);
|
|
1000
|
+
};
|
|
1001
|
+
/**
|
|
1002
|
+
* Creates a new text node with the specified text content.
|
|
1003
|
+
* @param text - The text content for the new text node.
|
|
1004
|
+
* @returns A new `Text` node with the specified text content.
|
|
1005
|
+
*/
|
|
1006
|
+
createText = (e) => this.document.createTextNode(e);
|
|
1007
|
+
/**
|
|
1008
|
+
* Creates a new text node with the specified text content and appends it to the current element.
|
|
1009
|
+
* @param text - The text content for the new text node.
|
|
1010
|
+
* @returns A new `DOMContext` with a reference to the new text node.
|
|
1011
|
+
*/
|
|
1012
|
+
makeChildText = (e) => {
|
|
1013
|
+
const s = this.createText(e);
|
|
1014
|
+
return this.appendOrInsert(s), this.withReference(s);
|
|
1015
|
+
};
|
|
1016
|
+
/**
|
|
1017
|
+
* Sets the text content of the current element.
|
|
1018
|
+
* @param text - The text content to set.
|
|
1019
|
+
*/
|
|
1020
|
+
setText = (e) => {
|
|
1021
|
+
this.reference.nodeValue = e;
|
|
1022
|
+
};
|
|
1023
|
+
/**
|
|
1024
|
+
* Gets the text content of the current element or text node.
|
|
1025
|
+
* @returns The text content of the current element or text node.
|
|
1026
|
+
*/
|
|
1027
|
+
getText = () => this.reference?.nodeValue ?? this.element.textContent ?? "";
|
|
1028
|
+
/**
|
|
1029
|
+
* Creates a new `DOMContext` with a reference to a newly created text node.
|
|
1030
|
+
* The text node is appended or inserted to the current `DOMContext`.
|
|
1031
|
+
* The new `DOMContext` with the reference is returned.
|
|
1032
|
+
*/
|
|
1033
|
+
makeRef = () => {
|
|
1034
|
+
const e = this.createText("");
|
|
1035
|
+
return this.appendOrInsert(e), this.withReference(e);
|
|
1036
|
+
};
|
|
1037
|
+
/**
|
|
1038
|
+
* Appends or inserts a child node to the element, depending on whether a reference node is provided.
|
|
1039
|
+
*
|
|
1040
|
+
* @param child - The child node to append or insert.
|
|
1041
|
+
*/
|
|
1042
|
+
appendOrInsert = (e) => {
|
|
1043
|
+
this.reference === void 0 ? this.element.appendChild(e) : this.element.insertBefore(e, this.reference);
|
|
1044
|
+
};
|
|
1045
|
+
/**
|
|
1046
|
+
* Creates a new `DOMContext` instance with the provided `element`.
|
|
1047
|
+
* @param element - The DOM element to use in the new `DOMContext` instance.
|
|
1048
|
+
* @returns A new `DOMContext` instance with the provided `element`.
|
|
1049
|
+
*/
|
|
1050
|
+
withElement = (e) => new k(this.document, e, void 0, this.providers);
|
|
1051
|
+
/**
|
|
1052
|
+
* Creates a portal to render content in a different part of the DOM tree.
|
|
1053
|
+
*
|
|
1054
|
+
* Portals allow you to render child components into a DOM node that exists outside
|
|
1055
|
+
* the parent component's DOM hierarchy. This is useful for modals, tooltips,
|
|
1056
|
+
* dropdowns, and other UI elements that need to break out of their container's
|
|
1057
|
+
* styling or z-index context.
|
|
1058
|
+
*
|
|
1059
|
+
* @example
|
|
1060
|
+
* ```typescript
|
|
1061
|
+
* // Portal to a modal container
|
|
1062
|
+
* const modalCtx = ctx.makePortal('#modal-root')
|
|
1063
|
+
* const modal = modalCtx.makeChildElement('div', undefined)
|
|
1064
|
+
*
|
|
1065
|
+
* // Add modal content
|
|
1066
|
+
* modal.makeChildText('This renders in #modal-root')
|
|
1067
|
+
* ```
|
|
1068
|
+
*
|
|
1069
|
+
* @example
|
|
1070
|
+
* ```typescript
|
|
1071
|
+
* // Portal to an existing element reference
|
|
1072
|
+
* const tooltipContainer = document.getElementById('tooltip-container')!
|
|
1073
|
+
* const tooltipCtx = ctx.makePortal(tooltipContainer)
|
|
1074
|
+
*
|
|
1075
|
+
* // Render tooltip content
|
|
1076
|
+
* const tooltip = tooltipCtx.makeChildElement('div', undefined)
|
|
1077
|
+
* tooltip.addClasses(['tooltip', 'tooltip-top'])
|
|
1078
|
+
* ```
|
|
1079
|
+
*
|
|
1080
|
+
* @example
|
|
1081
|
+
* ```typescript
|
|
1082
|
+
* // Portal for dropdown menu
|
|
1083
|
+
* const dropdownCtx = ctx.makePortal('body') // Render at body level
|
|
1084
|
+
* const dropdown = dropdownCtx.makeChildElement('div', undefined)
|
|
1085
|
+
* dropdown.addClasses(['dropdown-menu'])
|
|
1086
|
+
* dropdown.setStyle('position', 'absolute')
|
|
1087
|
+
* dropdown.setStyle('top', '100px')
|
|
1088
|
+
* dropdown.setStyle('left', '50px')
|
|
1089
|
+
* ```
|
|
1090
|
+
*
|
|
1091
|
+
* @param selector - CSS selector string or HTMLElement reference for the portal target
|
|
1092
|
+
* @returns A new DOMContext focused on the portal target element
|
|
1093
|
+
* @throws {Error} When the selector doesn't match any element in the document
|
|
1094
|
+
*/
|
|
1095
|
+
makePortal = (e) => {
|
|
1096
|
+
const s = typeof e == "string" ? this.document.querySelector(e) : e;
|
|
1097
|
+
if (s == null)
|
|
1098
|
+
throw new Error(`Cannot find element by selector for portal: ${e}`);
|
|
1099
|
+
return this.withElement(s);
|
|
1100
|
+
};
|
|
1101
|
+
/**
|
|
1102
|
+
* Creates a new `DOMContext` instance with the specified reference.
|
|
1103
|
+
*
|
|
1104
|
+
* @param reference - The optional `Text` node to use as the reference for the new `DOMContext`.
|
|
1105
|
+
* @returns A new `DOMContext` instance with the specified reference.
|
|
1106
|
+
*/
|
|
1107
|
+
withReference = (e) => new k(this.document, this.element, e, this.providers);
|
|
1108
|
+
/**
|
|
1109
|
+
* Sets a provider for the given provider mark.
|
|
1110
|
+
*
|
|
1111
|
+
* @param mark - The provider mark to set the provider for.
|
|
1112
|
+
* @param value - The provider to set for the given mark.
|
|
1113
|
+
* @returns A new `DOMContext` instance with the specified provider.
|
|
1114
|
+
*/
|
|
1115
|
+
setProvider = (e, s, r) => new k(this.document, this.element, this.reference, {
|
|
1116
|
+
...this.providers,
|
|
1117
|
+
[e]: [s, r]
|
|
1118
|
+
});
|
|
1119
|
+
/**
|
|
1120
|
+
* Retrieves a provider for the given provider mark.
|
|
1121
|
+
*
|
|
1122
|
+
* @param mark - The provider mark to retrieve the provider for.
|
|
1123
|
+
* @returns The provider for the given mark.
|
|
1124
|
+
* @throws Throws `ProviderNotFoundError` if the provider for the given mark is not found.
|
|
1125
|
+
*/
|
|
1126
|
+
getProvider = (e) => {
|
|
1127
|
+
if (this.providers[e] === void 0)
|
|
1128
|
+
throw new Se(e);
|
|
1129
|
+
const [s, r] = this.providers[e];
|
|
1130
|
+
return { value: s, onUse: r };
|
|
1131
|
+
};
|
|
1132
|
+
clear = (e) => {
|
|
1133
|
+
e && (this.reference !== void 0 ? B(this.reference) : B(this.element));
|
|
1134
|
+
};
|
|
1135
|
+
/**
|
|
1136
|
+
* Adds classes to the element.
|
|
1137
|
+
* @param tokens - The class names to add.
|
|
1138
|
+
*/
|
|
1139
|
+
addClasses = (e) => {
|
|
1140
|
+
this.element.classList.add(...e);
|
|
1141
|
+
};
|
|
1142
|
+
/**
|
|
1143
|
+
* Removes classes from the element.
|
|
1144
|
+
* @param tokens - The class names to remove.
|
|
1145
|
+
*/
|
|
1146
|
+
removeClasses = (e) => {
|
|
1147
|
+
this.element.classList.remove(...e);
|
|
1148
|
+
};
|
|
1149
|
+
/**
|
|
1150
|
+
* Gets the classes of the element.
|
|
1151
|
+
* @returns The classes of the element.
|
|
1152
|
+
*/
|
|
1153
|
+
getClasses = () => Array.from(this.element.classList);
|
|
1154
|
+
/**
|
|
1155
|
+
* Adds an event listener to the element.
|
|
1156
|
+
* @param event - The event to listen for.
|
|
1157
|
+
* @param listener - The listener to call when the event occurs.
|
|
1158
|
+
* @param options - The options for the event listener.
|
|
1159
|
+
* @returns A function to remove the event listener.
|
|
1160
|
+
*/
|
|
1161
|
+
on = (e, s, r) => {
|
|
1162
|
+
const n = (i) => s(i, this);
|
|
1163
|
+
return this.element.addEventListener(e, n, r), (i) => {
|
|
1164
|
+
i && this.element.removeEventListener(e, n, r);
|
|
1165
|
+
};
|
|
1166
|
+
};
|
|
1167
|
+
/**
|
|
1168
|
+
* Returns `true` if the context is a browser DOM context.
|
|
1169
|
+
* @returns `true` if the context is a browser DOM context.
|
|
1170
|
+
* @deprecated Use `isBrowser()` instead.
|
|
1171
|
+
*/
|
|
1172
|
+
isBrowserDOM = () => !0;
|
|
1173
|
+
/**
|
|
1174
|
+
* Returns `true` if the context is a browser context.
|
|
1175
|
+
* @returns `true` if the context is a browser context.
|
|
1176
|
+
*/
|
|
1177
|
+
isBrowser = () => !0;
|
|
1178
|
+
/**
|
|
1179
|
+
* Returns `true` if the context is a headless DOM context.
|
|
1180
|
+
* @returns `true` if the context is a headless DOM context.
|
|
1181
|
+
*/
|
|
1182
|
+
isHeadlessDOM = () => !1;
|
|
1183
|
+
/**
|
|
1184
|
+
* Returns `true` if the context is a headless context.
|
|
1185
|
+
* @returns `true` if the context is a headless context.
|
|
1186
|
+
*/
|
|
1187
|
+
isHeadless = () => !1;
|
|
1188
|
+
/**
|
|
1189
|
+
* Sets the style of the element.
|
|
1190
|
+
* @param name - The name of the style to set.
|
|
1191
|
+
* @param value - The value of the style to set.
|
|
1192
|
+
*/
|
|
1193
|
+
setStyle = (e, s) => {
|
|
1194
|
+
this.element.style[e] = s;
|
|
1195
|
+
};
|
|
1196
|
+
/**
|
|
1197
|
+
* Gets the style of the element.
|
|
1198
|
+
* @param name - The name of the style to get.
|
|
1199
|
+
* @returns The value of the style.
|
|
1200
|
+
*/
|
|
1201
|
+
getStyle = (e) => this.element.style[e];
|
|
1202
|
+
makeAccessors = (e) => ({
|
|
1203
|
+
get: Xe(e, this.element),
|
|
1204
|
+
set: Ge(e, this.element)
|
|
1205
|
+
});
|
|
1206
|
+
getWindow = () => this.document.defaultView;
|
|
1233
1207
|
}
|
|
1234
|
-
const
|
|
1235
|
-
const
|
|
1236
|
-
return (r = !0) =>
|
|
1237
|
-
},
|
|
1238
|
-
const
|
|
1239
|
-
if (
|
|
1240
|
-
throw new
|
|
1208
|
+
const Qe = (t) => Symbol(t), oe = (t, e) => {
|
|
1209
|
+
const s = t(e);
|
|
1210
|
+
return (r = !0) => s(r);
|
|
1211
|
+
}, Ut = (t, e, { doc: s, clear: r, disposeWithParent: n = !0, providers: i = {} } = {}) => {
|
|
1212
|
+
const o = typeof e == "string" ? (s ?? document).querySelector(e) : e;
|
|
1213
|
+
if (o === null)
|
|
1214
|
+
throw new Ze(
|
|
1241
1215
|
`Cannot find element by selector for render: ${e}`
|
|
1242
1216
|
);
|
|
1243
|
-
r !== !1 && (
|
|
1244
|
-
const
|
|
1217
|
+
r !== !1 && (s ?? o.ownerDocument) != null && o.nodeType === 1 && (o.innerHTML = "");
|
|
1218
|
+
const l = Ye(o), c = we(o) ? void 0 : o, a = k.of(l, c, i), u = oe(t, a);
|
|
1245
1219
|
let p;
|
|
1246
|
-
return n && (p = new MutationObserver((
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
m === l && (p == null || p.disconnect(), h(l.nodeType !== 1));
|
|
1220
|
+
return n && (p = new MutationObserver((d) => {
|
|
1221
|
+
d[0]?.removedNodes.forEach((f) => {
|
|
1222
|
+
f === o && (p?.disconnect(), u(o.nodeType !== 1));
|
|
1250
1223
|
});
|
|
1251
|
-
}), p.observe(
|
|
1224
|
+
}), p.observe(o.parentElement, {
|
|
1252
1225
|
childList: !0,
|
|
1253
1226
|
subtree: !1,
|
|
1254
1227
|
attributes: !1
|
|
1255
1228
|
})), () => {
|
|
1256
|
-
p
|
|
1229
|
+
p?.disconnect(), u(!0);
|
|
1257
1230
|
};
|
|
1258
|
-
},
|
|
1231
|
+
}, Jt = (t, {
|
|
1259
1232
|
startUrl: e = "https://example.com",
|
|
1260
|
-
selector:
|
|
1233
|
+
selector: s,
|
|
1261
1234
|
providers: r = {}
|
|
1262
1235
|
} = {
|
|
1263
1236
|
selector: "body"
|
|
1264
1237
|
}) => {
|
|
1265
|
-
const n = y.toSignal(e).deriveProp(), i = new
|
|
1238
|
+
const n = y.toSignal(e).deriveProp(), i = new Ee(s, void 0), o = new $(i, void 0, { currentURL: n }, r);
|
|
1266
1239
|
return {
|
|
1267
|
-
clear:
|
|
1240
|
+
clear: oe(t(), o),
|
|
1268
1241
|
root: i,
|
|
1269
1242
|
currentURL: n
|
|
1270
1243
|
};
|
|
1271
1244
|
};
|
|
1272
|
-
class
|
|
1245
|
+
class Ze extends Error {
|
|
1273
1246
|
constructor(e) {
|
|
1274
1247
|
super(e);
|
|
1275
1248
|
}
|
|
1276
1249
|
}
|
|
1277
|
-
const
|
|
1278
|
-
class
|
|
1250
|
+
const Te = "data-tts-node", W = "data-tts-class", U = "data-tts-style", J = "data-tts-html", G = "data-tts-text", X = "data-tts-attrs";
|
|
1251
|
+
class Gt {
|
|
1252
|
+
/**
|
|
1253
|
+
* Selects elements from the headless environment.
|
|
1254
|
+
* @param selector - The selector to select elements from. The supported selectors are CSS selectors whose complexity depends on the adapter implementation.
|
|
1255
|
+
* @returns An array of elements.
|
|
1256
|
+
*/
|
|
1257
|
+
select;
|
|
1258
|
+
/**
|
|
1259
|
+
* Gets the value of an attribute from an element.
|
|
1260
|
+
* @param el - The element to get the attribute from.
|
|
1261
|
+
* @param attr - The attribute to get the value from.
|
|
1262
|
+
* @returns The value of the attribute or null if the attribute is not set.
|
|
1263
|
+
*/
|
|
1264
|
+
getAttribute;
|
|
1265
|
+
/**
|
|
1266
|
+
* Sets the value of an attribute on an element.
|
|
1267
|
+
* @param el - The element to set the attribute on.
|
|
1268
|
+
* @param attr - The attribute to set the value of.
|
|
1269
|
+
* @param value - The value to set the attribute to.
|
|
1270
|
+
*/
|
|
1271
|
+
setAttribute;
|
|
1272
|
+
/**
|
|
1273
|
+
* Gets the class of an element.
|
|
1274
|
+
* @param el - The element to get the class from.
|
|
1275
|
+
* @returns The class of the element or an empty string if the class is not set.
|
|
1276
|
+
*/
|
|
1277
|
+
getClass;
|
|
1278
|
+
/**
|
|
1279
|
+
* Sets the class of an element.
|
|
1280
|
+
* @param el - The element to set the class on.
|
|
1281
|
+
* @param cls - The class to set.
|
|
1282
|
+
*/
|
|
1283
|
+
setClass;
|
|
1284
|
+
/**
|
|
1285
|
+
* Gets the styles of an element.
|
|
1286
|
+
* @param el - The element to get the styles from.
|
|
1287
|
+
* @returns The styles of the element.
|
|
1288
|
+
*/
|
|
1289
|
+
getStyles;
|
|
1290
|
+
/**
|
|
1291
|
+
* Sets the styles of an element.
|
|
1292
|
+
* @param el - The element to set the styles on.
|
|
1293
|
+
*/
|
|
1294
|
+
setStyles;
|
|
1295
|
+
/**
|
|
1296
|
+
* Appends HTML to an element.
|
|
1297
|
+
* @param el - The element to append the HTML to.
|
|
1298
|
+
* @param html - The HTML to append.
|
|
1299
|
+
*/
|
|
1300
|
+
appendHTML;
|
|
1301
|
+
/**
|
|
1302
|
+
* Gets the inner HTML of an element.
|
|
1303
|
+
* @param el - The element to get the inner HTML from.
|
|
1304
|
+
* @returns The inner HTML of the element or an empty string if the inner HTML is not set.
|
|
1305
|
+
*/
|
|
1306
|
+
getInnerHTML;
|
|
1307
|
+
/**
|
|
1308
|
+
* Sets the inner HTML of an element.
|
|
1309
|
+
* @param el - The element to set the inner HTML on.
|
|
1310
|
+
* @param html - The inner HTML to set.
|
|
1311
|
+
*/
|
|
1312
|
+
setInnerHTML;
|
|
1313
|
+
/**
|
|
1314
|
+
* Gets the inner text of an element.
|
|
1315
|
+
* @param el - The element to get the inner text from.
|
|
1316
|
+
* @returns The inner text of the element or an empty string if the inner text is not set.
|
|
1317
|
+
*/
|
|
1318
|
+
getInnerText;
|
|
1319
|
+
/**
|
|
1320
|
+
* Sets the inner text of an element.
|
|
1321
|
+
* @param el - The element to set the inner text on.
|
|
1322
|
+
* @param text - The inner text to set.
|
|
1323
|
+
*/
|
|
1324
|
+
setInnerText;
|
|
1279
1325
|
constructor({
|
|
1280
1326
|
select: e,
|
|
1281
|
-
getAttribute:
|
|
1327
|
+
getAttribute: s,
|
|
1282
1328
|
setAttribute: r,
|
|
1283
1329
|
getClass: n,
|
|
1284
1330
|
setClass: i,
|
|
1285
|
-
getStyles:
|
|
1286
|
-
setStyles:
|
|
1287
|
-
appendHTML:
|
|
1288
|
-
getInnerHTML:
|
|
1289
|
-
setInnerHTML:
|
|
1331
|
+
getStyles: o,
|
|
1332
|
+
setStyles: l,
|
|
1333
|
+
appendHTML: c,
|
|
1334
|
+
getInnerHTML: a,
|
|
1335
|
+
setInnerHTML: u,
|
|
1290
1336
|
getInnerText: p,
|
|
1291
|
-
setInnerText:
|
|
1337
|
+
setInnerText: d
|
|
1292
1338
|
}) {
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
* @param el - The element to get the class from.
|
|
1316
|
-
* @returns The class of the element or an empty string if the class is not set.
|
|
1317
|
-
*/
|
|
1318
|
-
o(this, "getClass");
|
|
1319
|
-
/**
|
|
1320
|
-
* Sets the class of an element.
|
|
1321
|
-
* @param el - The element to set the class on.
|
|
1322
|
-
* @param cls - The class to set.
|
|
1323
|
-
*/
|
|
1324
|
-
o(this, "setClass");
|
|
1325
|
-
/**
|
|
1326
|
-
* Gets the styles of an element.
|
|
1327
|
-
* @param el - The element to get the styles from.
|
|
1328
|
-
* @returns The styles of the element.
|
|
1329
|
-
*/
|
|
1330
|
-
o(this, "getStyles");
|
|
1331
|
-
/**
|
|
1332
|
-
* Sets the styles of an element.
|
|
1333
|
-
* @param el - The element to set the styles on.
|
|
1334
|
-
*/
|
|
1335
|
-
o(this, "setStyles");
|
|
1336
|
-
/**
|
|
1337
|
-
* Appends HTML to an element.
|
|
1338
|
-
* @param el - The element to append the HTML to.
|
|
1339
|
-
* @param html - The HTML to append.
|
|
1340
|
-
*/
|
|
1341
|
-
o(this, "appendHTML");
|
|
1342
|
-
/**
|
|
1343
|
-
* Gets the inner HTML of an element.
|
|
1344
|
-
* @param el - The element to get the inner HTML from.
|
|
1345
|
-
* @returns The inner HTML of the element or an empty string if the inner HTML is not set.
|
|
1346
|
-
*/
|
|
1347
|
-
o(this, "getInnerHTML");
|
|
1348
|
-
/**
|
|
1349
|
-
* Sets the inner HTML of an element.
|
|
1350
|
-
* @param el - The element to set the inner HTML on.
|
|
1351
|
-
* @param html - The inner HTML to set.
|
|
1352
|
-
*/
|
|
1353
|
-
o(this, "setInnerHTML");
|
|
1354
|
-
/**
|
|
1355
|
-
* Gets the inner text of an element.
|
|
1356
|
-
* @param el - The element to get the inner text from.
|
|
1357
|
-
* @returns The inner text of the element or an empty string if the inner text is not set.
|
|
1358
|
-
*/
|
|
1359
|
-
o(this, "getInnerText");
|
|
1360
|
-
/**
|
|
1361
|
-
* Sets the inner text of an element.
|
|
1362
|
-
* @param el - The element to set the inner text on.
|
|
1363
|
-
* @param text - The inner text to set.
|
|
1364
|
-
*/
|
|
1365
|
-
o(this, "setInnerText");
|
|
1366
|
-
/**
|
|
1367
|
-
* Sets the content of the root element from a HeadlessPortal. Generally this will be the same instance that is
|
|
1368
|
-
* returned by `runHeadless`.
|
|
1369
|
-
*
|
|
1370
|
-
* @param root - The HeadlessPortal containing the content to set.
|
|
1371
|
-
* @param setPlaceholders - Whether to set placeholders for the content. This allows you to restore the original content
|
|
1372
|
-
* when you render on the server and then hydrate on the client.
|
|
1373
|
-
*/
|
|
1374
|
-
o(this, "setFromRoot", (e, t) => {
|
|
1375
|
-
e.getPortals().forEach((n) => {
|
|
1376
|
-
const i = typeof n.selector == "string" ? this.select(n.selector) : [n.selector];
|
|
1377
|
-
for (const l of i) {
|
|
1378
|
-
if (l == null)
|
|
1379
|
-
throw new Error(
|
|
1380
|
-
`Cannot find element by selector for render: ${n.selector}`
|
|
1381
|
-
);
|
|
1382
|
-
if (n.hasChildren() && this.appendHTML(l, n.contentToHTML(t)), n.hasInnerHTML()) {
|
|
1383
|
-
if (t) {
|
|
1384
|
-
const c = this.getInnerHTML(l);
|
|
1385
|
-
c != null && this.setAttribute(l, z, c);
|
|
1386
|
-
}
|
|
1387
|
-
this.setInnerHTML(l, n.getInnerHTML());
|
|
1339
|
+
this.select = e, this.getAttribute = s, this.setAttribute = r, this.getClass = n, this.setClass = i, this.getStyles = o, this.setStyles = l, this.appendHTML = c, this.getInnerHTML = a, this.setInnerHTML = u, this.getInnerText = p, this.setInnerText = d;
|
|
1340
|
+
}
|
|
1341
|
+
/**
|
|
1342
|
+
* Sets the content of the root element from a HeadlessPortal. Generally this will be the same instance that is
|
|
1343
|
+
* returned by `runHeadless`.
|
|
1344
|
+
*
|
|
1345
|
+
* @param root - The HeadlessPortal containing the content to set.
|
|
1346
|
+
* @param setPlaceholders - Whether to set placeholders for the content. This allows you to restore the original content
|
|
1347
|
+
* when you render on the server and then hydrate on the client.
|
|
1348
|
+
*/
|
|
1349
|
+
setFromRoot = (e, s) => {
|
|
1350
|
+
e.getPortals().forEach((n) => {
|
|
1351
|
+
const i = typeof n.selector == "string" ? this.select(n.selector) : [n.selector];
|
|
1352
|
+
for (const o of i) {
|
|
1353
|
+
if (o == null)
|
|
1354
|
+
throw new Error(
|
|
1355
|
+
`Cannot find element by selector for render: ${n.selector}`
|
|
1356
|
+
);
|
|
1357
|
+
if (n.hasChildren() && this.appendHTML(o, n.contentToHTML(s)), n.hasInnerHTML()) {
|
|
1358
|
+
if (s) {
|
|
1359
|
+
const l = this.getInnerHTML(o);
|
|
1360
|
+
l != null && this.setAttribute(o, J, l);
|
|
1388
1361
|
}
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
this.
|
|
1362
|
+
this.setInnerHTML(o, n.getInnerHTML());
|
|
1363
|
+
}
|
|
1364
|
+
if (n.hasInnerText()) {
|
|
1365
|
+
if (s) {
|
|
1366
|
+
const l = this.getInnerText(o);
|
|
1367
|
+
l != null && this.setAttribute(o, G, l);
|
|
1395
1368
|
}
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
this.
|
|
1369
|
+
this.setInnerText(o, n.getInnerText());
|
|
1370
|
+
}
|
|
1371
|
+
if (n.hasClasses()) {
|
|
1372
|
+
if (s) {
|
|
1373
|
+
const l = this.getClass(o);
|
|
1374
|
+
l != null && this.setAttribute(o, W, l);
|
|
1402
1375
|
}
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1376
|
+
this.setClass(o, n.getClasses().join(" "));
|
|
1377
|
+
}
|
|
1378
|
+
if (n.hasStyles()) {
|
|
1379
|
+
if (s) {
|
|
1380
|
+
const l = this.getStyles(o);
|
|
1381
|
+
Object.keys(l).length > 0 && this.setAttribute(
|
|
1382
|
+
o,
|
|
1383
|
+
U,
|
|
1384
|
+
JSON.stringify(l)
|
|
1385
|
+
);
|
|
1413
1386
|
}
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
this.setAttribute(l, a, u);
|
|
1429
|
-
});
|
|
1387
|
+
this.setStyles(o, n.getStyles());
|
|
1388
|
+
}
|
|
1389
|
+
if (n.hasAttributes()) {
|
|
1390
|
+
const l = n.getAttributes();
|
|
1391
|
+
if (s) {
|
|
1392
|
+
const c = [];
|
|
1393
|
+
l.forEach(([a]) => {
|
|
1394
|
+
const u = this.getAttribute(o, a);
|
|
1395
|
+
u != null && c.push([a, u]);
|
|
1396
|
+
}), c.length > 0 && this.setAttribute(
|
|
1397
|
+
o,
|
|
1398
|
+
X,
|
|
1399
|
+
JSON.stringify(Object.fromEntries(c))
|
|
1400
|
+
);
|
|
1430
1401
|
}
|
|
1402
|
+
l.forEach(([c, a]) => {
|
|
1403
|
+
this.setAttribute(o, c, a);
|
|
1404
|
+
});
|
|
1431
1405
|
}
|
|
1432
|
-
}
|
|
1406
|
+
}
|
|
1433
1407
|
});
|
|
1434
|
-
|
|
1435
|
-
}
|
|
1408
|
+
};
|
|
1436
1409
|
}
|
|
1437
|
-
const
|
|
1438
|
-
document.querySelectorAll(`[${
|
|
1439
|
-
},
|
|
1440
|
-
const e =
|
|
1441
|
-
|
|
1442
|
-
},
|
|
1443
|
-
document.querySelectorAll(`[${
|
|
1444
|
-
},
|
|
1445
|
-
const e =
|
|
1446
|
-
|
|
1447
|
-
},
|
|
1448
|
-
document.querySelectorAll(`[${
|
|
1449
|
-
},
|
|
1450
|
-
const e =
|
|
1451
|
-
|
|
1452
|
-
},
|
|
1453
|
-
document.querySelectorAll(`[${
|
|
1454
|
-
},
|
|
1455
|
-
const e =
|
|
1456
|
-
if (
|
|
1457
|
-
const
|
|
1458
|
-
Object.entries(
|
|
1459
|
-
|
|
1410
|
+
const ze = () => {
|
|
1411
|
+
document.querySelectorAll(`[${Te}]`).forEach(B);
|
|
1412
|
+
}, Ke = (t) => {
|
|
1413
|
+
const e = t.getAttribute(W);
|
|
1414
|
+
t.removeAttribute(W), e != null && t.setAttribute("class", e);
|
|
1415
|
+
}, et = () => {
|
|
1416
|
+
document.querySelectorAll(`[${W}]`).forEach((e) => Ke(e));
|
|
1417
|
+
}, tt = (t) => {
|
|
1418
|
+
const e = t.getAttribute(J);
|
|
1419
|
+
t.removeAttribute(J), e != null && (t.innerHTML = e);
|
|
1420
|
+
}, st = () => {
|
|
1421
|
+
document.querySelectorAll(`[${J}]`).forEach((e) => tt(e));
|
|
1422
|
+
}, rt = (t) => {
|
|
1423
|
+
const e = t.getAttribute(G);
|
|
1424
|
+
t.removeAttribute(G), e != null && (t.innerText = e);
|
|
1425
|
+
}, nt = () => {
|
|
1426
|
+
document.querySelectorAll(`[${G}]`).forEach((e) => rt(e));
|
|
1427
|
+
}, ve = (t) => JSON.parse(t.replace(/"/g, '"')), it = (t) => {
|
|
1428
|
+
const e = t.getAttribute(U);
|
|
1429
|
+
if (t.removeAttribute(U), e != null) {
|
|
1430
|
+
const s = ve(e);
|
|
1431
|
+
Object.entries(s).forEach(([r, n]) => {
|
|
1432
|
+
t.style.setProperty(r, n);
|
|
1460
1433
|
});
|
|
1461
1434
|
}
|
|
1462
|
-
},
|
|
1463
|
-
document.querySelectorAll(`[${
|
|
1464
|
-
},
|
|
1465
|
-
const e =
|
|
1466
|
-
if (
|
|
1467
|
-
const
|
|
1468
|
-
Object.entries(
|
|
1469
|
-
n == null ?
|
|
1435
|
+
}, ot = () => {
|
|
1436
|
+
document.querySelectorAll(`[${U}]`).forEach((e) => it(e));
|
|
1437
|
+
}, lt = (t) => {
|
|
1438
|
+
const e = t.getAttribute(X);
|
|
1439
|
+
if (t.removeAttribute(X), e != null) {
|
|
1440
|
+
const s = ve(e);
|
|
1441
|
+
Object.entries(s).forEach(([r, n]) => {
|
|
1442
|
+
n == null ? t.removeAttribute(r) : t.setAttribute(r, n);
|
|
1470
1443
|
});
|
|
1471
1444
|
}
|
|
1472
|
-
},
|
|
1473
|
-
document.querySelectorAll(`[${
|
|
1474
|
-
},
|
|
1475
|
-
|
|
1476
|
-
},
|
|
1477
|
-
class
|
|
1445
|
+
}, ct = () => {
|
|
1446
|
+
document.querySelectorAll(`[${X}]`).forEach((e) => lt(e));
|
|
1447
|
+
}, Xt = () => {
|
|
1448
|
+
ze(), et(), nt(), st(), ot(), ct();
|
|
1449
|
+
}, M = Symbol("class"), I = Symbol("style"), q = Symbol("handler"), Ae = () => Math.random().toString(36).substring(2, 15), at = (t) => t.replace(/<[^>]*>?/g, "");
|
|
1450
|
+
class _e {
|
|
1478
1451
|
constructor(e) {
|
|
1479
|
-
o(this, "id", Oe());
|
|
1480
|
-
o(this, "properties", {});
|
|
1481
|
-
o(this, "children", []);
|
|
1482
|
-
o(this, "isElement", () => !0);
|
|
1483
|
-
o(this, "isText", () => !1);
|
|
1484
|
-
o(this, "getText", () => this.properties.innerText != null ? this.properties.innerText : this.properties.innerHTML != null ? St(this.properties.innerHTML) : this.children.map((e) => e.getText()).join(""));
|
|
1485
|
-
o(this, "removeChild", (e) => {
|
|
1486
|
-
const t = this.children.indexOf(e);
|
|
1487
|
-
t !== -1 && this.children.splice(t, 1);
|
|
1488
|
-
});
|
|
1489
|
-
o(this, "remove", () => {
|
|
1490
|
-
if (this.parent != null)
|
|
1491
|
-
this.parent.removeChild(this);
|
|
1492
|
-
else
|
|
1493
|
-
throw new Error("Parent is undefined");
|
|
1494
|
-
});
|
|
1495
|
-
o(this, "getPortals", () => {
|
|
1496
|
-
const e = this.elements().flatMap((t) => t.isPortal() ? [t, ...t.getPortals()] : t.getPortals());
|
|
1497
|
-
return this.isPortal() && e.unshift(this), e;
|
|
1498
|
-
});
|
|
1499
|
-
o(this, "elements", () => this.children.filter((e) => e.isElement()));
|
|
1500
|
-
o(this, "hasInnerHTML", () => this.properties.innerHTML != null);
|
|
1501
|
-
o(this, "getInnerHTML", () => this.properties.innerHTML ?? "");
|
|
1502
|
-
o(this, "getInnerText", () => this.properties.innerText ?? "");
|
|
1503
|
-
o(this, "hasInnerText", () => this.properties.innerText != null);
|
|
1504
|
-
o(this, "hasChildren", () => this.children.length > 0);
|
|
1505
|
-
o(this, "hasClasses", () => this.properties[C] != null);
|
|
1506
|
-
o(this, "hasStyles", () => this.properties[L] != null);
|
|
1507
|
-
o(this, "hasAttributes", () => Object.keys(this.properties).length > 0);
|
|
1508
|
-
o(this, "hasHandlers", () => this.properties[$] != null);
|
|
1509
|
-
o(this, "hasRenderableProperties", () => this.hasClasses() || this.hasAttributes() || this.hasStyles());
|
|
1510
|
-
o(this, "getById", (e) => {
|
|
1511
|
-
if (this.properties.id === e)
|
|
1512
|
-
return this;
|
|
1513
|
-
for (const t of this.elements()) {
|
|
1514
|
-
const r = t.getById(e);
|
|
1515
|
-
if (r != null)
|
|
1516
|
-
return r;
|
|
1517
|
-
}
|
|
1518
|
-
});
|
|
1519
|
-
o(this, "trigger", (e, t) => {
|
|
1520
|
-
((this.properties[$] ?? {})[e] ?? []).forEach((n) => n(t));
|
|
1521
|
-
});
|
|
1522
|
-
o(this, "click", () => {
|
|
1523
|
-
this.trigger("click", {});
|
|
1524
|
-
});
|
|
1525
|
-
o(this, "on", (e, t, r, n) => {
|
|
1526
|
-
var a;
|
|
1527
|
-
const i = (a = this.properties)[$] ?? (a[$] = {}), l = n != null && n.once ? (u) => {
|
|
1528
|
-
c(), t(u, r);
|
|
1529
|
-
} : (u) => t(u, r);
|
|
1530
|
-
i[e] = [...i[e] ?? [], l];
|
|
1531
|
-
const c = () => {
|
|
1532
|
-
const u = i[e] ?? [], h = u.indexOf(l);
|
|
1533
|
-
h !== -1 && (u.splice(h, 1), u.length === 0 ? (delete i[e], Object.keys(i).length === 0 && delete this.properties[$]) : i[e] = u, (n == null ? void 0 : n.signal) != null && n.signal.removeEventListener("abort", c));
|
|
1534
|
-
};
|
|
1535
|
-
return (n == null ? void 0 : n.signal) != null && n.signal.addEventListener("abort", c), c;
|
|
1536
|
-
});
|
|
1537
|
-
o(this, "addClasses", (e) => {
|
|
1538
|
-
var r;
|
|
1539
|
-
if (e.length === 0)
|
|
1540
|
-
return;
|
|
1541
|
-
const t = (r = this.properties)[C] ?? (r[C] = []);
|
|
1542
|
-
e.forEach((n) => {
|
|
1543
|
-
t.includes(n) || t.push(n);
|
|
1544
|
-
});
|
|
1545
|
-
});
|
|
1546
|
-
o(this, "removeClasses", (e) => {
|
|
1547
|
-
var r;
|
|
1548
|
-
if (e.length === 0)
|
|
1549
|
-
return;
|
|
1550
|
-
const t = (r = this.properties)[C] ?? (r[C] = []);
|
|
1551
|
-
e.forEach((n) => {
|
|
1552
|
-
const i = t.indexOf(n);
|
|
1553
|
-
i !== -1 && t.splice(i, 1);
|
|
1554
|
-
}), t.length === 0 && delete this.properties[C];
|
|
1555
|
-
});
|
|
1556
|
-
o(this, "getClasses", () => this.properties[C] ?? []);
|
|
1557
|
-
o(this, "getAttributes", () => Object.entries(this.properties).filter(
|
|
1558
|
-
([e]) => !["innerText", "innerHTML"].includes(e)
|
|
1559
|
-
));
|
|
1560
|
-
o(this, "getVisibleAttributes", () => Reflect.ownKeys(this.properties).flatMap(
|
|
1561
|
-
(e) => e === C ? [["class", this.getClasses()]] : e === L ? [["style", this.getStyles()]] : typeof e == "string" ? [[e, String(this.properties[e])]] : []
|
|
1562
|
-
));
|
|
1563
|
-
o(this, "setStyle", (e, t) => {
|
|
1564
|
-
var n;
|
|
1565
|
-
const r = (n = this.properties)[L] ?? (n[L] = {});
|
|
1566
|
-
r[e] = t, t === "" && (delete r[e], Object.keys(r).length === 0 && delete this.properties[L]);
|
|
1567
|
-
});
|
|
1568
|
-
o(this, "getStyle", (e) => {
|
|
1569
|
-
var t;
|
|
1570
|
-
return ((t = this.properties[L]) == null ? void 0 : t[e]) ?? "";
|
|
1571
|
-
});
|
|
1572
|
-
o(this, "getStyles", () => this.properties[L] ?? {});
|
|
1573
|
-
o(this, "makeAccessors", (e) => {
|
|
1574
|
-
const t = this.properties;
|
|
1575
|
-
return {
|
|
1576
|
-
get: () => t[e],
|
|
1577
|
-
set: (r) => t[e] = r
|
|
1578
|
-
};
|
|
1579
|
-
});
|
|
1580
1452
|
this.parent = e;
|
|
1581
1453
|
}
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1454
|
+
id = Ae();
|
|
1455
|
+
properties = {};
|
|
1456
|
+
children = [];
|
|
1457
|
+
isElement = () => !0;
|
|
1458
|
+
isText = () => !1;
|
|
1459
|
+
getText = () => this.properties.innerText != null ? this.properties.innerText : this.properties.innerHTML != null ? at(this.properties.innerHTML) : this.children.map((e) => e.getText()).join("");
|
|
1460
|
+
removeChild = (e) => {
|
|
1461
|
+
const s = this.children.indexOf(e);
|
|
1462
|
+
s !== -1 && this.children.splice(s, 1);
|
|
1463
|
+
};
|
|
1464
|
+
remove = () => {
|
|
1465
|
+
if (this.parent != null)
|
|
1466
|
+
this.parent.removeChild(this);
|
|
1467
|
+
else
|
|
1468
|
+
throw new Error("Parent is undefined");
|
|
1469
|
+
};
|
|
1470
|
+
getPortals = () => {
|
|
1471
|
+
const e = this.elements().flatMap((s) => s.isPortal() ? [s, ...s.getPortals()] : s.getPortals());
|
|
1472
|
+
return this.isPortal() && e.unshift(this), e;
|
|
1473
|
+
};
|
|
1474
|
+
elements = () => this.children.filter((e) => e.isElement());
|
|
1475
|
+
hasInnerHTML = () => this.properties.innerHTML != null;
|
|
1476
|
+
getInnerHTML = () => this.properties.innerHTML ?? "";
|
|
1477
|
+
getInnerText = () => this.properties.innerText ?? "";
|
|
1478
|
+
hasInnerText = () => this.properties.innerText != null;
|
|
1479
|
+
hasChildren = () => this.children.length > 0;
|
|
1480
|
+
hasClasses = () => this.properties[M] != null;
|
|
1481
|
+
hasStyles = () => this.properties[I] != null;
|
|
1482
|
+
hasAttributes = () => Object.keys(this.properties).length > 0;
|
|
1483
|
+
hasHandlers = () => this.properties[q] != null;
|
|
1484
|
+
hasRenderableProperties = () => this.hasClasses() || this.hasAttributes() || this.hasStyles();
|
|
1485
|
+
getById = (e) => {
|
|
1486
|
+
if (this.properties.id === e)
|
|
1487
|
+
return this;
|
|
1488
|
+
for (const s of this.elements()) {
|
|
1489
|
+
const r = s.getById(e);
|
|
1490
|
+
if (r != null)
|
|
1491
|
+
return r;
|
|
1492
|
+
}
|
|
1493
|
+
};
|
|
1494
|
+
trigger = (e, s) => {
|
|
1495
|
+
((this.properties[q] ?? {})[e] ?? []).forEach((n) => n(s));
|
|
1496
|
+
};
|
|
1497
|
+
click = () => {
|
|
1498
|
+
this.trigger("click", {});
|
|
1499
|
+
};
|
|
1500
|
+
on = (e, s, r, n) => {
|
|
1501
|
+
const i = this.properties[q] ??= {}, o = n?.once ? (c) => {
|
|
1502
|
+
l(), s(c, r);
|
|
1503
|
+
} : (c) => s(c, r);
|
|
1504
|
+
i[e] = [...i[e] ?? [], o];
|
|
1505
|
+
const l = () => {
|
|
1506
|
+
const c = i[e] ?? [], a = c.indexOf(o);
|
|
1507
|
+
a !== -1 && (c.splice(a, 1), c.length === 0 ? (delete i[e], Object.keys(i).length === 0 && delete this.properties[q]) : i[e] = c, n?.signal != null && n.signal.removeEventListener("abort", l));
|
|
1508
|
+
};
|
|
1509
|
+
return n?.signal != null && n.signal.addEventListener("abort", l), l;
|
|
1510
|
+
};
|
|
1511
|
+
addClasses = (e) => {
|
|
1512
|
+
if (e.length === 0)
|
|
1513
|
+
return;
|
|
1514
|
+
const s = this.properties[M] ??= [];
|
|
1515
|
+
e.forEach((r) => {
|
|
1516
|
+
s.includes(r) || s.push(r);
|
|
1593
1517
|
});
|
|
1594
|
-
|
|
1518
|
+
};
|
|
1519
|
+
removeClasses = (e) => {
|
|
1520
|
+
if (e.length === 0)
|
|
1521
|
+
return;
|
|
1522
|
+
const s = this.properties[M] ??= [];
|
|
1523
|
+
e.forEach((r) => {
|
|
1524
|
+
const n = s.indexOf(r);
|
|
1525
|
+
n !== -1 && s.splice(n, 1);
|
|
1526
|
+
}), s.length === 0 && delete this.properties[M];
|
|
1527
|
+
};
|
|
1528
|
+
getClasses = () => this.properties[M] ?? [];
|
|
1529
|
+
getAttributes = () => Object.entries(this.properties).filter(
|
|
1530
|
+
([e]) => !["innerText", "innerHTML"].includes(e)
|
|
1531
|
+
);
|
|
1532
|
+
getVisibleAttributes = () => Reflect.ownKeys(this.properties).flatMap(
|
|
1533
|
+
(e) => e === M ? [["class", this.getClasses()]] : e === I ? [["style", this.getStyles()]] : typeof e == "string" ? [[e, String(this.properties[e])]] : []
|
|
1534
|
+
);
|
|
1535
|
+
setStyle = (e, s) => {
|
|
1536
|
+
const r = this.properties[I] ??= {};
|
|
1537
|
+
r[e] = s, s === "" && (delete r[e], Object.keys(r).length === 0 && delete this.properties[I]);
|
|
1538
|
+
};
|
|
1539
|
+
getStyle = (e) => this.properties[I]?.[e] ?? "";
|
|
1540
|
+
getStyles = () => this.properties[I] ?? {};
|
|
1541
|
+
makeAccessors = (e) => {
|
|
1542
|
+
const s = this.properties;
|
|
1543
|
+
return {
|
|
1544
|
+
get: () => s[e],
|
|
1545
|
+
set: (r) => s[e] = r
|
|
1546
|
+
};
|
|
1547
|
+
};
|
|
1548
|
+
}
|
|
1549
|
+
const ut = (t) => t.replace(/"/g, """), ht = (t) => t.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
1550
|
+
class ft extends _e {
|
|
1551
|
+
constructor(e, s, r) {
|
|
1552
|
+
super(r), this.tagName = e, this.namespace = s;
|
|
1595
1553
|
}
|
|
1554
|
+
isPortal = () => !1;
|
|
1555
|
+
toHTML = (e = !1) => {
|
|
1556
|
+
const s = this.children.map((l) => l.toHTML()).join(""), r = this.namespace ? ` xmlns="${this.namespace}"` : "";
|
|
1557
|
+
let n = null;
|
|
1558
|
+
const i = this.getVisibleAttributes().map(([l, c]) => l === "class" ? ` class="${c.join(" ")}"` : l === "style" ? typeof c == "string" ? ` style="${c}"` : ` style="${Object.entries(c).map(([a, u]) => `${a}: ${u};`).join(" ")}"` : pt.has(l) ? ` ${l}` : l === "innerHTML" ? (n = c, "") : l === "innerText" ? (n = ht(c), "") : ` ${l}="${ut(c)}"`).join(""), o = e ? ` ${Te}` : "";
|
|
1559
|
+
return mt.has(this.tagName) && s === "" ? `<${this.tagName}${r}${i}${o} />` : `<${this.tagName}${r}${i}${o}>${n ?? s}</${this.tagName}>`;
|
|
1560
|
+
};
|
|
1596
1561
|
}
|
|
1597
|
-
class
|
|
1598
|
-
constructor(
|
|
1599
|
-
super(
|
|
1600
|
-
o(this, "isPortal", () => !0);
|
|
1601
|
-
o(this, "toHTML", () => "");
|
|
1602
|
-
o(this, "contentToHTML", (t = !1) => this.children.map((r) => r.toHTML(t)).join(""));
|
|
1603
|
-
this.selector = t;
|
|
1562
|
+
class Ee extends _e {
|
|
1563
|
+
constructor(e, s) {
|
|
1564
|
+
super(s), this.selector = e;
|
|
1604
1565
|
}
|
|
1566
|
+
isPortal = () => !0;
|
|
1567
|
+
toHTML = () => "";
|
|
1568
|
+
contentToHTML = (e = !1) => this.children.map((s) => s.toHTML(e)).join("");
|
|
1605
1569
|
}
|
|
1606
|
-
class
|
|
1570
|
+
class dt {
|
|
1607
1571
|
constructor(e) {
|
|
1608
|
-
o(this, "id", Oe());
|
|
1609
|
-
o(this, "isElement", () => !1);
|
|
1610
|
-
o(this, "isText", () => !0);
|
|
1611
|
-
o(this, "getText", () => this.text);
|
|
1612
|
-
o(this, "toHTML", () => this.text);
|
|
1613
1572
|
this.text = e;
|
|
1614
1573
|
}
|
|
1574
|
+
id = Ae();
|
|
1575
|
+
isElement = () => !1;
|
|
1576
|
+
isText = () => !0;
|
|
1577
|
+
getText = () => this.text;
|
|
1578
|
+
toHTML = () => this.text;
|
|
1615
1579
|
}
|
|
1616
|
-
class
|
|
1617
|
-
constructor(e,
|
|
1618
|
-
|
|
1619
|
-
if (this.reference != null) {
|
|
1620
|
-
const t = this.element.children.indexOf(this.reference);
|
|
1621
|
-
this.element.children.splice(t, 0, e);
|
|
1622
|
-
} else
|
|
1623
|
-
this.element.children.push(e);
|
|
1624
|
-
});
|
|
1625
|
-
o(this, "makeChildElement", (e, t) => {
|
|
1626
|
-
const r = new _t(e, t, this.element);
|
|
1627
|
-
return this.appendOrInsert(r), new V(
|
|
1628
|
-
r,
|
|
1629
|
-
void 0,
|
|
1630
|
-
this.container,
|
|
1631
|
-
this.providers
|
|
1632
|
-
);
|
|
1633
|
-
});
|
|
1634
|
-
o(this, "makeChildText", (e) => {
|
|
1635
|
-
const t = new Et(e);
|
|
1636
|
-
return this.appendOrInsert(t), new V(
|
|
1637
|
-
this.element,
|
|
1638
|
-
t,
|
|
1639
|
-
this.container,
|
|
1640
|
-
this.providers
|
|
1641
|
-
);
|
|
1642
|
-
});
|
|
1643
|
-
o(this, "setText", (e) => {
|
|
1644
|
-
this.reference && this.reference.isText() && (this.reference.text = e);
|
|
1645
|
-
});
|
|
1646
|
-
o(this, "getText", () => {
|
|
1647
|
-
var e;
|
|
1648
|
-
return ((e = this.reference) == null ? void 0 : e.getText()) ?? this.element.getText();
|
|
1649
|
-
});
|
|
1650
|
-
o(this, "makeRef", () => this.makeChildText(""));
|
|
1651
|
-
o(this, "makePortal", (e) => {
|
|
1652
|
-
const t = new ke(e, this.element);
|
|
1653
|
-
return this.appendOrInsert(t), new V(
|
|
1654
|
-
t,
|
|
1655
|
-
void 0,
|
|
1656
|
-
this.container,
|
|
1657
|
-
this.providers
|
|
1658
|
-
);
|
|
1659
|
-
});
|
|
1660
|
-
/**
|
|
1661
|
-
* Sets a provider for the given provider mark.
|
|
1662
|
-
*
|
|
1663
|
-
* @param mark - The provider mark to set the provider for.
|
|
1664
|
-
* @param value - The provider to set for the given mark.
|
|
1665
|
-
* @returns A new `DOMContext` instance with the specified provider.
|
|
1666
|
-
*/
|
|
1667
|
-
o(this, "setProvider", (e, t, r) => new V(this.element, this.reference, this.container, {
|
|
1668
|
-
...this.providers,
|
|
1669
|
-
[e]: [t, r]
|
|
1670
|
-
}));
|
|
1671
|
-
o(this, "getProvider", (e) => {
|
|
1672
|
-
if (this.providers[e] === void 0)
|
|
1673
|
-
throw new De(e);
|
|
1674
|
-
const [t, r] = this.providers[e];
|
|
1675
|
-
return { value: t, onUse: r };
|
|
1676
|
-
});
|
|
1677
|
-
o(this, "clear", (e) => {
|
|
1678
|
-
e && (this.reference !== void 0 ? this.element.removeChild(this.reference) : this.element.remove());
|
|
1679
|
-
});
|
|
1680
|
-
o(this, "on", (e, t) => this.element.on(e, t, this));
|
|
1681
|
-
o(this, "addClasses", (e) => this.element.addClasses(e));
|
|
1682
|
-
o(this, "removeClasses", (e) => this.element.removeClasses(e));
|
|
1683
|
-
o(this, "getClasses", () => this.element.getClasses());
|
|
1684
|
-
o(this, "isBrowserDOM", () => !1);
|
|
1685
|
-
o(this, "isBrowser", () => !1);
|
|
1686
|
-
o(this, "isHeadlessDOM", () => !0);
|
|
1687
|
-
o(this, "isHeadless", () => !0);
|
|
1688
|
-
o(this, "setStyle", (e, t) => this.element.setStyle(e, t));
|
|
1689
|
-
o(this, "getStyle", (e) => this.element.getStyle(e));
|
|
1690
|
-
o(this, "makeAccessors", (e) => this.element.makeAccessors(e));
|
|
1691
|
-
this.element = e, this.reference = t, this.container = r, this.providers = n;
|
|
1580
|
+
class $ {
|
|
1581
|
+
constructor(e, s, r, n) {
|
|
1582
|
+
this.element = e, this.reference = s, this.container = r, this.providers = n;
|
|
1692
1583
|
}
|
|
1584
|
+
appendOrInsert = (e) => {
|
|
1585
|
+
if (this.reference != null) {
|
|
1586
|
+
const s = this.element.children.indexOf(this.reference);
|
|
1587
|
+
this.element.children.splice(s, 0, e);
|
|
1588
|
+
} else
|
|
1589
|
+
this.element.children.push(e);
|
|
1590
|
+
};
|
|
1591
|
+
makeChildElement = (e, s) => {
|
|
1592
|
+
const r = new ft(e, s, this.element);
|
|
1593
|
+
return this.appendOrInsert(r), new $(
|
|
1594
|
+
r,
|
|
1595
|
+
void 0,
|
|
1596
|
+
this.container,
|
|
1597
|
+
this.providers
|
|
1598
|
+
);
|
|
1599
|
+
};
|
|
1600
|
+
makeChildText = (e) => {
|
|
1601
|
+
const s = new dt(e);
|
|
1602
|
+
return this.appendOrInsert(s), new $(
|
|
1603
|
+
this.element,
|
|
1604
|
+
s,
|
|
1605
|
+
this.container,
|
|
1606
|
+
this.providers
|
|
1607
|
+
);
|
|
1608
|
+
};
|
|
1609
|
+
setText = (e) => {
|
|
1610
|
+
this.reference && this.reference.isText() && (this.reference.text = e);
|
|
1611
|
+
};
|
|
1612
|
+
getText = () => this.reference?.getText() ?? this.element.getText();
|
|
1613
|
+
makeRef = () => this.makeChildText("");
|
|
1614
|
+
makePortal = (e) => {
|
|
1615
|
+
const s = new Ee(e, this.element);
|
|
1616
|
+
return this.appendOrInsert(s), new $(
|
|
1617
|
+
s,
|
|
1618
|
+
void 0,
|
|
1619
|
+
this.container,
|
|
1620
|
+
this.providers
|
|
1621
|
+
);
|
|
1622
|
+
};
|
|
1623
|
+
/**
|
|
1624
|
+
* Sets a provider for the given provider mark.
|
|
1625
|
+
*
|
|
1626
|
+
* @param mark - The provider mark to set the provider for.
|
|
1627
|
+
* @param value - The provider to set for the given mark.
|
|
1628
|
+
* @returns A new `DOMContext` instance with the specified provider.
|
|
1629
|
+
*/
|
|
1630
|
+
setProvider = (e, s, r) => new $(this.element, this.reference, this.container, {
|
|
1631
|
+
...this.providers,
|
|
1632
|
+
[e]: [s, r]
|
|
1633
|
+
});
|
|
1634
|
+
getProvider = (e) => {
|
|
1635
|
+
if (this.providers[e] === void 0)
|
|
1636
|
+
throw new Se(e);
|
|
1637
|
+
const [s, r] = this.providers[e];
|
|
1638
|
+
return { value: s, onUse: r };
|
|
1639
|
+
};
|
|
1640
|
+
clear = (e) => {
|
|
1641
|
+
e && (this.reference !== void 0 ? this.element.removeChild(this.reference) : this.element.remove());
|
|
1642
|
+
};
|
|
1643
|
+
on = (e, s) => this.element.on(e, s, this);
|
|
1644
|
+
addClasses = (e) => this.element.addClasses(e);
|
|
1645
|
+
removeClasses = (e) => this.element.removeClasses(e);
|
|
1646
|
+
getClasses = () => this.element.getClasses();
|
|
1647
|
+
isBrowserDOM = () => !1;
|
|
1648
|
+
isBrowser = () => !1;
|
|
1649
|
+
isHeadlessDOM = () => !0;
|
|
1650
|
+
isHeadless = () => !0;
|
|
1651
|
+
setStyle = (e, s) => this.element.setStyle(e, s);
|
|
1652
|
+
getStyle = (e) => this.element.getStyle(e);
|
|
1653
|
+
makeAccessors = (e) => this.element.makeAccessors(e);
|
|
1693
1654
|
}
|
|
1694
|
-
const
|
|
1655
|
+
const pt = /* @__PURE__ */ new Set([
|
|
1695
1656
|
"checked",
|
|
1696
1657
|
"disabled",
|
|
1697
1658
|
"multiple",
|
|
1698
1659
|
"readonly",
|
|
1699
1660
|
"required",
|
|
1700
1661
|
"selected"
|
|
1701
|
-
]),
|
|
1702
|
-
const
|
|
1662
|
+
]), mt = /* @__PURE__ */ new Set(["img", "br", "hr", "input", "link", "meta"]), Ce = (t) => (e) => e.makeChildText(t).clear, Pe = (t) => (e) => {
|
|
1663
|
+
const s = e.makeChildText(t.value), r = t.on(s.setText);
|
|
1703
1664
|
return (n) => {
|
|
1704
|
-
r(),
|
|
1665
|
+
r(), s.clear(n);
|
|
1705
1666
|
};
|
|
1706
|
-
},
|
|
1707
|
-
const
|
|
1667
|
+
}, Yt = (t) => m.is(t) ? Pe(t) : Ce(t), T = (...t) => (e) => {
|
|
1668
|
+
const s = t.map((r) => h(r)(e));
|
|
1708
1669
|
return (r) => {
|
|
1709
|
-
|
|
1710
|
-
};
|
|
1711
|
-
},
|
|
1712
|
-
},
|
|
1713
|
-
|
|
1714
|
-
}),
|
|
1715
|
-
let
|
|
1716
|
-
const r =
|
|
1717
|
-
e.removeClasses(
|
|
1670
|
+
s.forEach((n) => n(r));
|
|
1671
|
+
};
|
|
1672
|
+
}, E = () => () => {
|
|
1673
|
+
}, gt = (t) => (e) => (e.addClasses(t), (s) => {
|
|
1674
|
+
s && e.removeClasses(t);
|
|
1675
|
+
}), yt = (t) => (e) => {
|
|
1676
|
+
let s = [];
|
|
1677
|
+
const r = t.on((n) => {
|
|
1678
|
+
e.removeClasses(s), s = (n ?? "").split(" ").filter((i) => i.length > 0), e.addClasses(s);
|
|
1718
1679
|
});
|
|
1719
1680
|
return (n) => {
|
|
1720
|
-
r(), n && e.removeClasses(
|
|
1681
|
+
r(), n && e.removeClasses(s), s.length = 0;
|
|
1721
1682
|
};
|
|
1722
|
-
},
|
|
1723
|
-
const { get: r, set: n } =
|
|
1724
|
-
return n(e), (
|
|
1725
|
-
|
|
1683
|
+
}, bt = (t, e) => (s) => {
|
|
1684
|
+
const { get: r, set: n } = s.makeAccessors(t), i = r();
|
|
1685
|
+
return n(e), (o) => {
|
|
1686
|
+
o && n(i);
|
|
1726
1687
|
};
|
|
1727
|
-
},
|
|
1728
|
-
const { get: r, set: n } =
|
|
1729
|
-
return (
|
|
1730
|
-
|
|
1688
|
+
}, wt = (t, e) => (s) => {
|
|
1689
|
+
const { get: r, set: n } = s.makeAccessors(t), i = r(), o = e.on(n);
|
|
1690
|
+
return (l) => {
|
|
1691
|
+
o(), l && n(i);
|
|
1731
1692
|
};
|
|
1732
|
-
},
|
|
1693
|
+
}, N = (t, e) => m.is(e) ? wt(t, e) : bt(t, e), Z = (t = "") => (e, s) => {
|
|
1694
|
+
const r = t ? `${t}${e}` : e;
|
|
1695
|
+
return N(r, s);
|
|
1696
|
+
}, R = new Proxy(
|
|
1733
1697
|
{},
|
|
1734
1698
|
{
|
|
1735
1699
|
/**
|
|
@@ -1743,18 +1707,12 @@ const Ct = /* @__PURE__ */ new Set([
|
|
|
1743
1707
|
* @returns The renderable component for the specified attribute.
|
|
1744
1708
|
*
|
|
1745
1709
|
*/
|
|
1746
|
-
get: (
|
|
1710
|
+
get: (t, e) => e === "class" ? (s) => m.is(s) ? yt(s) : gt(
|
|
1747
1711
|
/* c8 ignore next */
|
|
1748
|
-
(
|
|
1749
|
-
) : (
|
|
1750
|
-
e,
|
|
1751
|
-
t
|
|
1752
|
-
) : B(
|
|
1753
|
-
e,
|
|
1754
|
-
t
|
|
1755
|
-
)
|
|
1712
|
+
(s ?? "").split(" ").filter((r) => r.length > 0)
|
|
1713
|
+
) : e === "set" ? Z() : (s) => N(e, s)
|
|
1756
1714
|
}
|
|
1757
|
-
),
|
|
1715
|
+
), Qt = new Proxy(
|
|
1758
1716
|
{},
|
|
1759
1717
|
{
|
|
1760
1718
|
/**
|
|
@@ -1765,12 +1723,9 @@ const Ct = /* @__PURE__ */ new Set([
|
|
|
1765
1723
|
* @returns The renderable component for the specified attribute.
|
|
1766
1724
|
*
|
|
1767
1725
|
*/
|
|
1768
|
-
get: (
|
|
1769
|
-
`data-${e}`,
|
|
1770
|
-
t
|
|
1771
|
-
) : B(`data-${e}`, t)
|
|
1726
|
+
get: (t, e) => e === "set" ? Z("data-") : (s) => N(`data-${e}`, s)
|
|
1772
1727
|
}
|
|
1773
|
-
),
|
|
1728
|
+
), Zt = new Proxy(
|
|
1774
1729
|
{},
|
|
1775
1730
|
{
|
|
1776
1731
|
/**
|
|
@@ -1781,15 +1736,9 @@ const Ct = /* @__PURE__ */ new Set([
|
|
|
1781
1736
|
* @returns The renderable component for the specified attribute.
|
|
1782
1737
|
*
|
|
1783
1738
|
*/
|
|
1784
|
-
get: (
|
|
1785
|
-
`aria-${e}`,
|
|
1786
|
-
t
|
|
1787
|
-
) : B(
|
|
1788
|
-
`aria-${e}`,
|
|
1789
|
-
t
|
|
1790
|
-
)
|
|
1739
|
+
get: (t, e) => e === "set" ? Z("aria-") : (s) => N(`aria-${e}`, s)
|
|
1791
1740
|
}
|
|
1792
|
-
),
|
|
1741
|
+
), zt = new Proxy(
|
|
1793
1742
|
{},
|
|
1794
1743
|
{
|
|
1795
1744
|
/**
|
|
@@ -1800,15 +1749,9 @@ const Ct = /* @__PURE__ */ new Set([
|
|
|
1800
1749
|
* @returns The renderable component for the specified attribute.
|
|
1801
1750
|
*
|
|
1802
1751
|
*/
|
|
1803
|
-
get: (
|
|
1804
|
-
e,
|
|
1805
|
-
t
|
|
1806
|
-
) : B(
|
|
1807
|
-
e,
|
|
1808
|
-
t
|
|
1809
|
-
)
|
|
1752
|
+
get: (t, e) => e === "set" ? Z() : (s) => N(e, s)
|
|
1810
1753
|
}
|
|
1811
|
-
),
|
|
1754
|
+
), Kt = new Proxy(
|
|
1812
1755
|
{},
|
|
1813
1756
|
{
|
|
1814
1757
|
/**
|
|
@@ -1818,37 +1761,31 @@ const Ct = /* @__PURE__ */ new Set([
|
|
|
1818
1761
|
* @returns The renderable component for the specified attribute.
|
|
1819
1762
|
*
|
|
1820
1763
|
*/
|
|
1821
|
-
get: (
|
|
1822
|
-
e,
|
|
1823
|
-
t
|
|
1824
|
-
) : B(
|
|
1825
|
-
e,
|
|
1826
|
-
t
|
|
1827
|
-
)
|
|
1764
|
+
get: (t, e) => (s) => N(e, s)
|
|
1828
1765
|
}
|
|
1829
|
-
),
|
|
1830
|
-
if (
|
|
1831
|
-
return
|
|
1832
|
-
if (Array.isArray(
|
|
1833
|
-
return
|
|
1834
|
-
if (typeof
|
|
1835
|
-
return
|
|
1836
|
-
if (
|
|
1837
|
-
return
|
|
1838
|
-
if (typeof
|
|
1839
|
-
return
|
|
1840
|
-
throw new Error(`Unknown type: '${typeof
|
|
1841
|
-
},
|
|
1842
|
-
const r =
|
|
1766
|
+
), h = (t) => {
|
|
1767
|
+
if (t == null)
|
|
1768
|
+
return E;
|
|
1769
|
+
if (Array.isArray(t))
|
|
1770
|
+
return T(...t.map(h));
|
|
1771
|
+
if (typeof t == "string")
|
|
1772
|
+
return Ce(t);
|
|
1773
|
+
if (m.is(t))
|
|
1774
|
+
return Pe(t);
|
|
1775
|
+
if (typeof t == "function")
|
|
1776
|
+
return t;
|
|
1777
|
+
throw new Error(`Unknown type: '${typeof t}' for child: ${t}`);
|
|
1778
|
+
}, xe = (t, ...e) => (s) => {
|
|
1779
|
+
const r = s.makeChildElement(t, void 0), n = e.map((i) => h(i)(r));
|
|
1843
1780
|
return (i) => {
|
|
1844
|
-
n.forEach((
|
|
1781
|
+
n.forEach((o) => o(!1)), r.clear(i);
|
|
1845
1782
|
};
|
|
1846
|
-
},
|
|
1847
|
-
const n = r.makeChildElement(
|
|
1848
|
-
return (
|
|
1849
|
-
i.forEach((
|
|
1783
|
+
}, Le = (t, e, ...s) => (r) => {
|
|
1784
|
+
const n = r.makeChildElement(t, e), i = s.map((o) => h(o)(n));
|
|
1785
|
+
return (o) => {
|
|
1786
|
+
i.forEach((l) => l(!1)), n.clear(o);
|
|
1850
1787
|
};
|
|
1851
|
-
},
|
|
1788
|
+
}, es = new Proxy(
|
|
1852
1789
|
{},
|
|
1853
1790
|
{
|
|
1854
1791
|
/**
|
|
@@ -1856,9 +1793,9 @@ const Ct = /* @__PURE__ */ new Set([
|
|
|
1856
1793
|
* @param tagName - The HTML tag name.
|
|
1857
1794
|
* @returns A renderable function that creates and appends the HTML element to the DOM.
|
|
1858
1795
|
*/
|
|
1859
|
-
get: (
|
|
1796
|
+
get: (t, e) => (...s) => xe(e, s.flatMap(h))
|
|
1860
1797
|
}
|
|
1861
|
-
),
|
|
1798
|
+
), ts = new Proxy(
|
|
1862
1799
|
{},
|
|
1863
1800
|
{
|
|
1864
1801
|
/**
|
|
@@ -1866,9 +1803,9 @@ const Ct = /* @__PURE__ */ new Set([
|
|
|
1866
1803
|
* @param type - The input type name.
|
|
1867
1804
|
* @returns A renderable function that creates and appends the HTMLInput element to the DOM.
|
|
1868
1805
|
*/
|
|
1869
|
-
get: (
|
|
1806
|
+
get: (t, e) => (...s) => xe("input", R.type(e), ...s)
|
|
1870
1807
|
}
|
|
1871
|
-
),
|
|
1808
|
+
), St = "http://www.w3.org/2000/svg", ss = new Proxy(
|
|
1872
1809
|
{},
|
|
1873
1810
|
{
|
|
1874
1811
|
/**
|
|
@@ -1876,9 +1813,9 @@ const Ct = /* @__PURE__ */ new Set([
|
|
|
1876
1813
|
* @param tagName - The SVG tag name.
|
|
1877
1814
|
* @returns A renderable function that creates and appends the SVG element to the DOM.
|
|
1878
1815
|
*/
|
|
1879
|
-
get: (
|
|
1816
|
+
get: (t, e) => (...s) => Le(e, St, s.flatMap(h))
|
|
1880
1817
|
}
|
|
1881
|
-
),
|
|
1818
|
+
), Tt = "http://www.w3.org/1998/Math/MathML", rs = new Proxy(
|
|
1882
1819
|
{},
|
|
1883
1820
|
{
|
|
1884
1821
|
/**
|
|
@@ -1886,35 +1823,35 @@ const Ct = /* @__PURE__ */ new Set([
|
|
|
1886
1823
|
* @param tagName - The Math tag name.
|
|
1887
1824
|
* @returns A renderable function that creates and appends the Math element to the DOM.
|
|
1888
1825
|
*/
|
|
1889
|
-
get: (
|
|
1826
|
+
get: (t, e) => (...s) => Le(e, Tt, s.flatMap(h))
|
|
1890
1827
|
}
|
|
1891
|
-
),
|
|
1828
|
+
), De = (t, e) => {
|
|
1892
1829
|
if (typeof e == "function")
|
|
1893
|
-
return
|
|
1894
|
-
const
|
|
1830
|
+
return De(t, { then: e });
|
|
1831
|
+
const s = e.pending != null ? h(e.pending()) : E, r = e.then, n = e.error != null ? (i) => h(e.error(i)) : () => E;
|
|
1895
1832
|
return (i) => {
|
|
1896
|
-
let
|
|
1897
|
-
const
|
|
1898
|
-
let
|
|
1899
|
-
return
|
|
1900
|
-
(
|
|
1901
|
-
|
|
1833
|
+
let o = !0;
|
|
1834
|
+
const l = t(), c = i.makeRef();
|
|
1835
|
+
let a = h(s)(c);
|
|
1836
|
+
return l.then(
|
|
1837
|
+
(u) => {
|
|
1838
|
+
o && (a(!0), a = h(r(u))(c));
|
|
1902
1839
|
},
|
|
1903
|
-
(
|
|
1904
|
-
|
|
1840
|
+
(u) => {
|
|
1841
|
+
o && (a(!0), a = h(n(u))(c));
|
|
1905
1842
|
}
|
|
1906
|
-
), (
|
|
1907
|
-
|
|
1843
|
+
), (u) => {
|
|
1844
|
+
o = !1, a(u), c.clear(u);
|
|
1908
1845
|
};
|
|
1909
1846
|
};
|
|
1910
|
-
},
|
|
1847
|
+
}, ns = (t, e) => De(() => t, e), Oe = (t, e, s) => (r) => r.on(t, e, s), vt = (t) => Oe("click", (e, s) => {
|
|
1911
1848
|
e.preventDefault();
|
|
1912
1849
|
const r = e.target;
|
|
1913
1850
|
setTimeout(() => {
|
|
1914
|
-
const n = r.ownerDocument != null ? r
|
|
1915
|
-
n != null &&
|
|
1851
|
+
const n = r.ownerDocument != null ? r?.checked : void 0;
|
|
1852
|
+
n != null && t(!n, s);
|
|
1916
1853
|
}, 0);
|
|
1917
|
-
}),
|
|
1854
|
+
}), z = new Proxy(
|
|
1918
1855
|
{},
|
|
1919
1856
|
{
|
|
1920
1857
|
/**
|
|
@@ -1922,321 +1859,334 @@ const Ct = /* @__PURE__ */ new Set([
|
|
|
1922
1859
|
* @param fn - The function to call when the event is triggered.
|
|
1923
1860
|
* @returns A `Renderable` function that adds the event listener to the element.
|
|
1924
1861
|
*/
|
|
1925
|
-
get: (
|
|
1862
|
+
get: (t, e) => (s) => Oe(e, s)
|
|
1926
1863
|
}
|
|
1927
|
-
),
|
|
1928
|
-
|
|
1929
|
-
},
|
|
1930
|
-
const r =
|
|
1931
|
-
|
|
1932
|
-
}, e),
|
|
1933
|
-
(
|
|
1864
|
+
), At = (t, e) => (s) => {
|
|
1865
|
+
e?.preventDefault === !0 && s.preventDefault(), e?.stopPropagation === !0 && s.stopPropagation(), e?.stopImmediatePropagation === !0 && s.stopImmediatePropagation(), t(s);
|
|
1866
|
+
}, L = (t, e) => At((s) => {
|
|
1867
|
+
const r = s.target;
|
|
1868
|
+
t(r, s);
|
|
1869
|
+
}, e), _t = (t, e) => L(
|
|
1870
|
+
(s, r) => t(s.value, r),
|
|
1934
1871
|
e
|
|
1935
|
-
),
|
|
1936
|
-
(
|
|
1872
|
+
), Et = (t, e) => L(
|
|
1873
|
+
(s, r) => t(s.valueAsNumber, r),
|
|
1937
1874
|
e
|
|
1938
|
-
),
|
|
1939
|
-
if (
|
|
1875
|
+
), Ct = (t, e) => L((s, r) => {
|
|
1876
|
+
if (s.value === "")
|
|
1940
1877
|
return;
|
|
1941
|
-
const n =
|
|
1878
|
+
const n = s.value.split("-"), i = new Date(
|
|
1942
1879
|
Number(n[0]),
|
|
1943
1880
|
Number(n[1]) - 1,
|
|
1944
1881
|
Number(n[2].substring(0, 2))
|
|
1945
1882
|
);
|
|
1946
|
-
|
|
1947
|
-
}, e),
|
|
1948
|
-
if (
|
|
1949
|
-
|
|
1883
|
+
t(i, r);
|
|
1884
|
+
}, e), is = (t, e) => L((s, r) => {
|
|
1885
|
+
if (s.value === "") {
|
|
1886
|
+
t(null, r);
|
|
1950
1887
|
return;
|
|
1951
1888
|
}
|
|
1952
|
-
const n =
|
|
1889
|
+
const n = s.value.split("-"), i = new Date(
|
|
1953
1890
|
Number(n[0]),
|
|
1954
1891
|
Number(n[1]) - 1,
|
|
1955
1892
|
Number(n[2].substring(0, 2))
|
|
1956
1893
|
);
|
|
1957
|
-
|
|
1958
|
-
}, e),
|
|
1959
|
-
if (
|
|
1894
|
+
t(i, r);
|
|
1895
|
+
}, e), Pt = (t, e) => L((s, r) => {
|
|
1896
|
+
if (s.value === "")
|
|
1960
1897
|
return;
|
|
1961
|
-
const n =
|
|
1898
|
+
const n = s.value.split("T"), i = n[0].split("-"), o = new Date(
|
|
1962
1899
|
Number(i[0]),
|
|
1963
1900
|
Number(i[1]) - 1,
|
|
1964
1901
|
Number(i[2])
|
|
1965
|
-
),
|
|
1966
|
-
|
|
1967
|
-
}, e),
|
|
1968
|
-
if (
|
|
1969
|
-
|
|
1902
|
+
), l = n[1].split(":");
|
|
1903
|
+
o.setHours(Number(l[0])), o.setMinutes(Number(l[1])), o.setSeconds(Number(l[2])), t(o, r);
|
|
1904
|
+
}, e), os = (t, e) => L((s, r) => {
|
|
1905
|
+
if (s.value === "") {
|
|
1906
|
+
t(null, r);
|
|
1970
1907
|
return;
|
|
1971
1908
|
}
|
|
1972
|
-
const n =
|
|
1909
|
+
const n = s.value.split("T");
|
|
1973
1910
|
if (n.length !== 2) {
|
|
1974
|
-
|
|
1911
|
+
t(null, r);
|
|
1975
1912
|
return;
|
|
1976
1913
|
}
|
|
1977
|
-
const i = n[0].split("-"),
|
|
1914
|
+
const i = n[0].split("-"), o = new Date(
|
|
1978
1915
|
Number(i[0]),
|
|
1979
1916
|
Number(i[1]) - 1,
|
|
1980
1917
|
Number(i[2])
|
|
1981
|
-
),
|
|
1982
|
-
|
|
1983
|
-
}, e),
|
|
1984
|
-
s
|
|
1985
|
-
}, e),
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1918
|
+
), l = n[1].split(":");
|
|
1919
|
+
o.setHours(Number(l[0] ?? 0)), o.setMinutes(Number(l[1] ?? 0)), o.setSeconds(Number(l[2] ?? 0)), t(o, r);
|
|
1920
|
+
}, e), ls = (t, e) => L((s, r) => {
|
|
1921
|
+
t(s.checked, r);
|
|
1922
|
+
}, e), cs = (t, e = "input") => T(R.valueAsDate(t), z[e](Ct(t.set))), as = (t, e = "input") => T(R.valueAsDate(t), z[e](Pt(t.set))), us = (t, e = "input") => T(R.valueAsNumber(t), z[e](Et(t.set))), hs = (t, e = "input") => T(R.value(t), z[e](_t(t.set))), fs = (t) => T(R.checked(t), vt(t.set)), le = (t, e, s) => m.is(t) ? e(t) : s(t), xt = (t, e, s) => {
|
|
1923
|
+
const r = t.makeRef();
|
|
1924
|
+
let n = () => {
|
|
1925
|
+
};
|
|
1926
|
+
const i = e.on((o) => {
|
|
1927
|
+
n(!0), n = h(s(o))(r);
|
|
1928
|
+
});
|
|
1929
|
+
return (o) => {
|
|
1930
|
+
n(o), i(), r.clear(o);
|
|
1931
|
+
};
|
|
1932
|
+
}, K = (t, e) => {
|
|
1933
|
+
function s(n) {
|
|
1934
|
+
return (i) => {
|
|
1935
|
+
const o = i.makeRef();
|
|
1936
|
+
let l, c;
|
|
1937
|
+
const a = n.map((d) => Object.keys(d)[0]);
|
|
1938
|
+
let u;
|
|
1939
|
+
const p = a.on((d) => {
|
|
1940
|
+
if (d !== u) {
|
|
1941
|
+
u = d, c?.dispose(), l?.(!0), c = n.map((g) => g[d]);
|
|
1942
|
+
const f = e[d](c);
|
|
1943
|
+
l = h(f)(o);
|
|
1997
1944
|
}
|
|
1998
1945
|
});
|
|
1999
|
-
return (
|
|
2000
|
-
|
|
1946
|
+
return (d) => {
|
|
1947
|
+
c?.dispose(), p(), o.clear(d), l?.(d);
|
|
2001
1948
|
};
|
|
2002
1949
|
};
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
1950
|
+
}
|
|
1951
|
+
function r(n) {
|
|
1952
|
+
const i = Object.keys(n)[0];
|
|
1953
|
+
return h(e[i](Q(n[i])));
|
|
1954
|
+
}
|
|
1955
|
+
return le(t, s, r);
|
|
1956
|
+
}, Me = (t, e, s) => K(
|
|
1957
|
+
y.map(t, (r) => ({ [r[e]]: r })),
|
|
2007
1958
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2008
|
-
|
|
2009
|
-
),
|
|
2010
|
-
const
|
|
2011
|
-
return
|
|
2012
|
-
},
|
|
2013
|
-
y.map(
|
|
1959
|
+
s
|
|
1960
|
+
), ds = (t, e) => Me(t, "kind", e), ps = (t, e) => {
|
|
1961
|
+
const s = y.map(t, ([r, n]) => ({ [r]: n }));
|
|
1962
|
+
return K(s, e);
|
|
1963
|
+
}, ms = (t, e) => Me(t, "type", e), Lt = (t, e) => K(
|
|
1964
|
+
y.map(t, (s) => ({ [s]: !0 })),
|
|
2014
1965
|
e
|
|
2015
|
-
),
|
|
2016
|
-
const r =
|
|
2017
|
-
return
|
|
2018
|
-
|
|
1966
|
+
), gs = (t, e = {}) => (s) => {
|
|
1967
|
+
const r = e?.firstSeparator ?? t, n = e?.lastSeparator ?? t;
|
|
1968
|
+
return Lt(
|
|
1969
|
+
s.map((i) => i.isFirst ? "first" : i.isLast ? "last" : "other"),
|
|
2019
1970
|
{
|
|
2020
1971
|
first: r,
|
|
2021
1972
|
last: n,
|
|
2022
|
-
other:
|
|
1973
|
+
other: t
|
|
2023
1974
|
}
|
|
2024
1975
|
);
|
|
2025
|
-
},
|
|
2026
|
-
|
|
2027
|
-
}),
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
), c = !0);
|
|
1976
|
+
}, ys = (t) => (e) => (e.appendOrInsert(t), (s) => {
|
|
1977
|
+
s && B(t);
|
|
1978
|
+
}), bs = (t, e, s) => {
|
|
1979
|
+
function r(i) {
|
|
1980
|
+
return (o) => {
|
|
1981
|
+
const l = o.makeRef();
|
|
1982
|
+
let c = () => {
|
|
1983
|
+
}, a = !1, u = null;
|
|
1984
|
+
const p = i.on((d) => {
|
|
1985
|
+
d == null ? (c(!0), c = h(s?.())(l), a = !1, u?.dispose(), u = null) : a ? u.set(d) : (u = _(d), c(!0), c = h(e(u))(
|
|
1986
|
+
l
|
|
1987
|
+
), a = !0);
|
|
2038
1988
|
});
|
|
2039
|
-
return (
|
|
2040
|
-
|
|
1989
|
+
return (d) => {
|
|
1990
|
+
u?.dispose(), p(), c?.(d), l.clear(d);
|
|
2041
1991
|
};
|
|
2042
1992
|
};
|
|
2043
|
-
}
|
|
2044
|
-
|
|
2045
|
-
if (
|
|
2046
|
-
const
|
|
2047
|
-
return
|
|
1993
|
+
}
|
|
1994
|
+
function n(i) {
|
|
1995
|
+
if (i == null) {
|
|
1996
|
+
const o = s?.();
|
|
1997
|
+
return o != null ? h(o) : E;
|
|
2048
1998
|
}
|
|
2049
|
-
return
|
|
1999
|
+
return h(e(Q(i)));
|
|
2050
2000
|
}
|
|
2051
|
-
|
|
2001
|
+
return le(
|
|
2002
|
+
t,
|
|
2003
|
+
r,
|
|
2004
|
+
n
|
|
2005
|
+
);
|
|
2006
|
+
}, ws = (...t) => (e, s) => (r) => {
|
|
2052
2007
|
const n = r.makeRef();
|
|
2053
|
-
if (
|
|
2054
|
-
(
|
|
2008
|
+
if (t.some(
|
|
2009
|
+
(f) => !m.is(f) && f == null
|
|
2055
2010
|
))
|
|
2056
|
-
return (
|
|
2011
|
+
return (s != null ? h(s?.()) : E)(
|
|
2057
2012
|
n
|
|
2058
2013
|
);
|
|
2059
|
-
const
|
|
2060
|
-
(
|
|
2014
|
+
const o = t.map(() => null), l = t.map(
|
|
2015
|
+
(f) => m.is(f) ? f.value != null : f != null
|
|
2061
2016
|
);
|
|
2062
|
-
let
|
|
2063
|
-
const
|
|
2064
|
-
if (
|
|
2065
|
-
if (
|
|
2066
|
-
const
|
|
2067
|
-
|
|
2017
|
+
let c = null;
|
|
2018
|
+
const a = _(l.every((f) => f)), u = (f, g) => {
|
|
2019
|
+
if (f.value != null) {
|
|
2020
|
+
if (o[g] == null) {
|
|
2021
|
+
const w = _(f.value);
|
|
2022
|
+
o[g] = w;
|
|
2068
2023
|
} else
|
|
2069
|
-
|
|
2070
|
-
|
|
2024
|
+
o[g].value = f.value;
|
|
2025
|
+
l[g] = !0;
|
|
2071
2026
|
} else
|
|
2072
|
-
|
|
2027
|
+
l[g] = !1;
|
|
2073
2028
|
};
|
|
2074
|
-
let p =
|
|
2075
|
-
const
|
|
2076
|
-
if (!
|
|
2077
|
-
const
|
|
2078
|
-
return
|
|
2029
|
+
let p = t.length - 1;
|
|
2030
|
+
const d = t.map((f, g) => {
|
|
2031
|
+
if (!m.is(f)) {
|
|
2032
|
+
const w = _(f);
|
|
2033
|
+
return o[g] = w, () => {
|
|
2079
2034
|
};
|
|
2080
2035
|
}
|
|
2081
|
-
return
|
|
2082
|
-
|
|
2036
|
+
return f.on(() => {
|
|
2037
|
+
u(f, g), p === 0 ? a.value = l.every((w) => w) : p--;
|
|
2083
2038
|
});
|
|
2084
2039
|
});
|
|
2085
|
-
return
|
|
2086
|
-
|
|
2087
|
-
}), (
|
|
2088
|
-
|
|
2089
|
-
};
|
|
2090
|
-
},
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
l(a), c(), i.clear(a);
|
|
2102
|
-
};
|
|
2103
|
-
};
|
|
2104
|
-
} else {
|
|
2105
|
-
if (s) {
|
|
2040
|
+
return a.on((f) => {
|
|
2041
|
+
c?.(!0), c = null, f ? c = h(e(...o))(n) : c = h(s?.() ?? E)(n);
|
|
2042
|
+
}), (f) => {
|
|
2043
|
+
o.forEach((g) => g?.dispose()), a.dispose(), d.forEach((g) => g()), c?.(f), n.clear(f);
|
|
2044
|
+
};
|
|
2045
|
+
}, V = (...t) => (e) => (s) => t.forEach((r) => {
|
|
2046
|
+
typeof r == "function" ? r(s, e) : r.dispose(s, e);
|
|
2047
|
+
}), Ie = (t, e, s) => le(
|
|
2048
|
+
t,
|
|
2049
|
+
(r) => (n) => xt(
|
|
2050
|
+
n,
|
|
2051
|
+
r,
|
|
2052
|
+
(i) => i ? e() : s?.()
|
|
2053
|
+
),
|
|
2054
|
+
(r) => {
|
|
2055
|
+
if (r) {
|
|
2106
2056
|
const n = e();
|
|
2107
|
-
return n != null ?
|
|
2057
|
+
return n != null ? h(n) : E;
|
|
2108
2058
|
}
|
|
2109
|
-
return
|
|
2059
|
+
return h(s?.());
|
|
2110
2060
|
}
|
|
2111
|
-
|
|
2112
|
-
y.map(
|
|
2061
|
+
), Ss = (t, e, s) => Ie(
|
|
2062
|
+
y.map(t, (r) => !r),
|
|
2113
2063
|
e,
|
|
2114
|
-
|
|
2115
|
-
),
|
|
2116
|
-
if (
|
|
2117
|
-
return
|
|
2118
|
-
const n = new
|
|
2064
|
+
s
|
|
2065
|
+
), He = (t, e, s) => {
|
|
2066
|
+
if (s != null)
|
|
2067
|
+
return He(t, (r) => {
|
|
2068
|
+
const n = new se(
|
|
2119
2069
|
r.index,
|
|
2120
2070
|
r.total.map((i) => i - 1)
|
|
2121
2071
|
);
|
|
2122
|
-
return
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2072
|
+
return T(
|
|
2073
|
+
V(n.dispose),
|
|
2074
|
+
h(e(r)),
|
|
2075
|
+
Ie(
|
|
2126
2076
|
r.isLast,
|
|
2127
|
-
() =>
|
|
2128
|
-
() =>
|
|
2077
|
+
() => E,
|
|
2078
|
+
() => s(n)
|
|
2129
2079
|
)
|
|
2130
2080
|
);
|
|
2131
2081
|
});
|
|
2132
|
-
if (
|
|
2082
|
+
if (m.is(t))
|
|
2133
2083
|
return (r) => {
|
|
2134
|
-
const n =
|
|
2135
|
-
return n.on((
|
|
2136
|
-
const
|
|
2137
|
-
for (const
|
|
2138
|
-
|
|
2139
|
-
for (let
|
|
2140
|
-
const
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2084
|
+
const n = t.derive(), i = r.makeRef(), o = [];
|
|
2085
|
+
return n.on((l) => {
|
|
2086
|
+
const c = o.splice(l);
|
|
2087
|
+
for (const a of c)
|
|
2088
|
+
a(!0);
|
|
2089
|
+
for (let a = o.length; a < l; a++) {
|
|
2090
|
+
const u = new se(a, n);
|
|
2091
|
+
o.push(
|
|
2092
|
+
T(
|
|
2093
|
+
V(u.dispose),
|
|
2094
|
+
h(e(u))
|
|
2145
2095
|
)(i)
|
|
2146
2096
|
);
|
|
2147
2097
|
}
|
|
2148
|
-
}), (
|
|
2098
|
+
}), (l) => {
|
|
2149
2099
|
n.dispose();
|
|
2150
|
-
for (const
|
|
2151
|
-
|
|
2152
|
-
|
|
2100
|
+
for (const c of o)
|
|
2101
|
+
c(l);
|
|
2102
|
+
o.length = 0, i.clear(l);
|
|
2153
2103
|
};
|
|
2154
2104
|
};
|
|
2155
2105
|
{
|
|
2156
|
-
const r =
|
|
2157
|
-
return
|
|
2158
|
-
...Array.from({ length:
|
|
2159
|
-
const i = new
|
|
2160
|
-
return
|
|
2161
|
-
|
|
2162
|
-
|
|
2106
|
+
const r = Q(t);
|
|
2107
|
+
return T(
|
|
2108
|
+
...Array.from({ length: t }, (n, i) => i).map((n) => {
|
|
2109
|
+
const i = new se(n, r);
|
|
2110
|
+
return T(
|
|
2111
|
+
V(i.dispose),
|
|
2112
|
+
h(e(i))
|
|
2163
2113
|
);
|
|
2164
2114
|
})
|
|
2165
2115
|
);
|
|
2166
2116
|
}
|
|
2167
|
-
},
|
|
2168
|
-
const r = y.map(
|
|
2169
|
-
return
|
|
2117
|
+
}, Ts = (t, e, s) => {
|
|
2118
|
+
const r = y.map(t, (i) => i.length), n = y.toSignal(t);
|
|
2119
|
+
return He(
|
|
2170
2120
|
r,
|
|
2171
2121
|
(i) => {
|
|
2172
|
-
const
|
|
2173
|
-
return
|
|
2174
|
-
|
|
2175
|
-
|
|
2122
|
+
const o = n.map((l) => l[i.index]);
|
|
2123
|
+
return T(
|
|
2124
|
+
V(o.dispose),
|
|
2125
|
+
h(e(o, i))
|
|
2176
2126
|
);
|
|
2177
2127
|
},
|
|
2178
|
-
|
|
2128
|
+
s
|
|
2179
2129
|
);
|
|
2180
|
-
},
|
|
2181
|
-
if (
|
|
2182
|
-
const
|
|
2130
|
+
}, vs = (t, e) => {
|
|
2131
|
+
if (m.is(t)) {
|
|
2132
|
+
const s = t;
|
|
2183
2133
|
return (r) => {
|
|
2184
2134
|
r = r.makeRef();
|
|
2185
|
-
const n =
|
|
2135
|
+
const n = s.map((l) => h(e(l)));
|
|
2186
2136
|
let i = () => {
|
|
2187
2137
|
};
|
|
2188
|
-
const
|
|
2189
|
-
i(!0), i =
|
|
2138
|
+
const o = n.on((l) => {
|
|
2139
|
+
i(!0), i = l(r);
|
|
2190
2140
|
});
|
|
2191
|
-
return (
|
|
2192
|
-
|
|
2141
|
+
return (l) => {
|
|
2142
|
+
o(), i(l);
|
|
2193
2143
|
};
|
|
2194
2144
|
};
|
|
2195
2145
|
}
|
|
2196
|
-
return
|
|
2197
|
-
},
|
|
2146
|
+
return h(e(t));
|
|
2147
|
+
}, As = (t, e, s = () => E) => K(
|
|
2198
2148
|
y.map(
|
|
2199
|
-
|
|
2149
|
+
t,
|
|
2200
2150
|
(r) => r.length > 0 ? { notEmpty: r } : { whenEmpty: null }
|
|
2201
2151
|
),
|
|
2202
2152
|
{
|
|
2203
2153
|
notEmpty: (r) => e(r),
|
|
2204
|
-
whenEmpty: () =>
|
|
2154
|
+
whenEmpty: () => s()
|
|
2205
2155
|
}
|
|
2206
|
-
),
|
|
2207
|
-
const r =
|
|
2156
|
+
), _s = (t, e) => (s) => {
|
|
2157
|
+
const r = s.makePortal(t), n = oe(h(e), r);
|
|
2208
2158
|
return () => n(!0);
|
|
2209
|
-
},
|
|
2210
|
-
mark:
|
|
2159
|
+
}, F = /* @__PURE__ */ new Map(), Dt = (t) => ({
|
|
2160
|
+
mark: Qe(`Probe(${t.description})`),
|
|
2211
2161
|
create: ({ callback: e = () => {
|
|
2212
|
-
}, timeout:
|
|
2213
|
-
const r = (
|
|
2214
|
-
clearTimeout(n),
|
|
2162
|
+
}, timeout: s = 10 } = {}) => {
|
|
2163
|
+
const r = (l) => {
|
|
2164
|
+
clearTimeout(n), F.delete(t), e(l);
|
|
2215
2165
|
};
|
|
2216
|
-
if (
|
|
2217
|
-
throw new Error(`Probe already exists: ${
|
|
2218
|
-
const n = setTimeout(() => r("timeout"),
|
|
2219
|
-
return
|
|
2166
|
+
if (F.has(t))
|
|
2167
|
+
throw new Error(`Probe already exists: ${t.description}`);
|
|
2168
|
+
const n = setTimeout(() => r("timeout"), s), i = { counter: 0, timeoutId: n };
|
|
2169
|
+
return F.set(t, i), {
|
|
2220
2170
|
value: () => {
|
|
2221
2171
|
clearTimeout(n);
|
|
2222
|
-
const
|
|
2223
|
-
|
|
2172
|
+
const l = F.get(t);
|
|
2173
|
+
l != null && --l.counter === 0 && r("resolved");
|
|
2224
2174
|
},
|
|
2225
2175
|
dispose: () => r("disposed"),
|
|
2226
2176
|
onUse: () => i.counter++
|
|
2227
2177
|
};
|
|
2228
2178
|
}
|
|
2229
|
-
}),
|
|
2230
|
-
const r =
|
|
2231
|
-
return
|
|
2232
|
-
n &&
|
|
2179
|
+
}), Es = Dt(Symbol("GlobalProbe")), Ot = (t, e) => (s) => {
|
|
2180
|
+
const r = s.getStyle(t);
|
|
2181
|
+
return s.setStyle(t, e), (n) => {
|
|
2182
|
+
n && s.setStyle(t, r);
|
|
2233
2183
|
};
|
|
2234
|
-
},
|
|
2235
|
-
const r =
|
|
2184
|
+
}, Mt = (t, e) => (s) => {
|
|
2185
|
+
const r = s.getStyle(t), n = e.on((i) => s.setStyle(t, i));
|
|
2236
2186
|
return (i) => {
|
|
2237
|
-
n(), i &&
|
|
2187
|
+
n(), i && s.setStyle(t, r);
|
|
2238
2188
|
};
|
|
2239
|
-
},
|
|
2189
|
+
}, ue = (t, e) => m.is(e) ? Mt(t, e) : Ot(t, e), Cs = new Proxy({}, {
|
|
2240
2190
|
/**
|
|
2241
2191
|
* Creates a renderable component for the specified `style` property.
|
|
2242
2192
|
*
|
|
@@ -2245,168 +2195,168 @@ const Ct = /* @__PURE__ */ new Set([
|
|
|
2245
2195
|
* @returns The renderable component for the specified attribute.
|
|
2246
2196
|
*
|
|
2247
2197
|
*/
|
|
2248
|
-
get: (
|
|
2249
|
-
}),
|
|
2198
|
+
get: (t, e) => e === "variable" ? (s, r) => ue(s, r) : (s) => ue(e, s)
|
|
2199
|
+
}), It = (t) => (e) => {
|
|
2250
2200
|
if (e.isBrowser()) {
|
|
2251
|
-
const
|
|
2252
|
-
if (
|
|
2253
|
-
return
|
|
2201
|
+
const s = t(e);
|
|
2202
|
+
if (s != null)
|
|
2203
|
+
return h(s)(e);
|
|
2254
2204
|
}
|
|
2255
2205
|
return () => {
|
|
2256
2206
|
};
|
|
2257
|
-
},
|
|
2258
|
-
const
|
|
2259
|
-
return
|
|
2260
|
-
} :
|
|
2261
|
-
},
|
|
2207
|
+
}, Ps = (t) => (e) => {
|
|
2208
|
+
const s = t(e);
|
|
2209
|
+
return s == null ? () => {
|
|
2210
|
+
} : h(s)(e);
|
|
2211
|
+
}, xs = (t) => It((e) => t(e.element)), Ls = (t) => (e) => {
|
|
2262
2212
|
if (e.isHeadlessDOM()) {
|
|
2263
|
-
const
|
|
2264
|
-
if (
|
|
2265
|
-
return
|
|
2213
|
+
const s = t(e);
|
|
2214
|
+
if (s)
|
|
2215
|
+
return h(s)(e);
|
|
2266
2216
|
}
|
|
2267
2217
|
return () => {
|
|
2268
2218
|
};
|
|
2269
|
-
},
|
|
2270
|
-
let
|
|
2219
|
+
}, ce = (t) => (e) => {
|
|
2220
|
+
let s = e;
|
|
2271
2221
|
function r() {
|
|
2272
|
-
return
|
|
2222
|
+
return s;
|
|
2273
2223
|
}
|
|
2274
|
-
function n(
|
|
2275
|
-
|
|
2224
|
+
function n(l) {
|
|
2225
|
+
s = l;
|
|
2276
2226
|
}
|
|
2277
|
-
const i = [],
|
|
2278
|
-
use: ({ mark:
|
|
2279
|
-
const { value:
|
|
2280
|
-
return
|
|
2227
|
+
const i = [], o = t({
|
|
2228
|
+
use: ({ mark: l }) => {
|
|
2229
|
+
const { value: c, onUse: a } = r().getProvider(l);
|
|
2230
|
+
return a?.(), c;
|
|
2281
2231
|
},
|
|
2282
|
-
set: ({ mark:
|
|
2283
|
-
const { value:
|
|
2284
|
-
i.push(p), n(r().setProvider(
|
|
2232
|
+
set: ({ mark: l, create: c }, a) => {
|
|
2233
|
+
const { value: u, dispose: p, onUse: d } = c(a, r());
|
|
2234
|
+
i.push(p), n(r().setProvider(l, u, d));
|
|
2285
2235
|
}
|
|
2286
2236
|
});
|
|
2287
|
-
return
|
|
2288
|
-
} :
|
|
2289
|
-
|
|
2290
|
-
|
|
2237
|
+
return o == null ? () => {
|
|
2238
|
+
} : T(
|
|
2239
|
+
h(o),
|
|
2240
|
+
V(() => i.forEach((l) => l()))
|
|
2291
2241
|
)(r());
|
|
2292
|
-
},
|
|
2293
|
-
const r =
|
|
2242
|
+
}, Ds = (t, e, s) => ce(({ set: r }) => (r(t, e), s())), Os = (t, e) => ce(({ use: s }) => e(s(t))), Ms = (...t) => (e) => ce(({ use: s }) => {
|
|
2243
|
+
const r = t.map(s);
|
|
2294
2244
|
return e(...r);
|
|
2295
2245
|
});
|
|
2296
2246
|
export {
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2247
|
+
ns as Async,
|
|
2248
|
+
fs as BindChecked,
|
|
2249
|
+
cs as BindDate,
|
|
2250
|
+
as as BindDateTime,
|
|
2251
|
+
us as BindNumber,
|
|
2252
|
+
hs as BindText,
|
|
2253
|
+
k as BrowserContext,
|
|
2254
|
+
W as CLASS_PLACEHOLDER_ATTR,
|
|
2255
|
+
H as Computed,
|
|
2256
|
+
gs as Conjunction,
|
|
2257
|
+
ys as DOMNode,
|
|
2258
|
+
xe as El,
|
|
2259
|
+
Le as ElNS,
|
|
2260
|
+
se as ElementPosition,
|
|
2261
|
+
E as Empty,
|
|
2262
|
+
bs as Ensure,
|
|
2313
2263
|
ws as EnsureAll,
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2264
|
+
Ts as ForEach,
|
|
2265
|
+
T as Fragment,
|
|
2266
|
+
Es as GlobalProbe,
|
|
2267
|
+
Gt as HeadlessAdapter,
|
|
2268
|
+
$ as HeadlessContext,
|
|
2269
|
+
ft as HeadlessElement,
|
|
2270
|
+
Ee as HeadlessPortal,
|
|
2271
|
+
dt as HeadlessText,
|
|
2272
|
+
vs as MapSignal,
|
|
2273
|
+
fe as MemoryStore,
|
|
2274
|
+
As as NotEmpty,
|
|
2275
|
+
vt as OnChecked,
|
|
2276
|
+
V as OnDispose,
|
|
2277
|
+
K as OneOf,
|
|
2278
|
+
Me as OneOfField,
|
|
2279
|
+
ds as OneOfKind,
|
|
2280
|
+
ps as OneOfTuple,
|
|
2281
|
+
ms as OneOfType,
|
|
2282
|
+
Lt as OneOfValue,
|
|
2283
|
+
_s as Portal,
|
|
2284
|
+
Y as Prop,
|
|
2285
|
+
Ds as Provide,
|
|
2286
|
+
Se as ProviderNotFoundError,
|
|
2287
|
+
Ze as RenderingError,
|
|
2288
|
+
He as Repeat,
|
|
2289
|
+
m as Signal,
|
|
2290
|
+
De as Task,
|
|
2291
|
+
Yt as TextNode,
|
|
2292
|
+
Ss as Unless,
|
|
2293
|
+
Os as Use,
|
|
2294
|
+
Ms as UseMany,
|
|
2345
2295
|
y as Value,
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2296
|
+
Ie as When,
|
|
2297
|
+
It as WithBrowserCtx,
|
|
2298
|
+
Ps as WithCtx,
|
|
2299
|
+
xs as WithElement,
|
|
2300
|
+
Ls as WithHeadlessCtx,
|
|
2301
|
+
ce as WithProvider,
|
|
2302
|
+
Te as _NODE_PLACEHOLDER_ATTR,
|
|
2303
|
+
Ye as _getSelfOrParentElement,
|
|
2304
|
+
we as _isElement,
|
|
2305
|
+
Xe as _makeGetter,
|
|
2306
|
+
Ge as _makeSetter,
|
|
2307
|
+
B as _removeDOMNode,
|
|
2308
|
+
Pe as _signalText,
|
|
2309
|
+
Ce as _staticText,
|
|
2310
|
+
Rt as animateSignal,
|
|
2311
|
+
Ue as animateSignals,
|
|
2312
|
+
Zt as aria,
|
|
2313
|
+
R as attr,
|
|
2314
|
+
Bt as bind,
|
|
2315
|
+
Wt as coalesce,
|
|
2316
|
+
re as computed,
|
|
2317
|
+
ie as computedOf,
|
|
2318
|
+
Je as computedRecord,
|
|
2319
|
+
Qt as dataAttr,
|
|
2320
|
+
jt as delaySignal,
|
|
2321
|
+
qe as effect,
|
|
2322
|
+
kt as effectOf,
|
|
2323
|
+
At as emit,
|
|
2324
|
+
ls as emitChecked,
|
|
2325
|
+
L as emitTarget,
|
|
2326
|
+
_t as emitValue,
|
|
2327
|
+
Ct as emitValueAsDate,
|
|
2328
|
+
Pt as emitValueAsDateTime,
|
|
2329
|
+
is as emitValueAsNullableDate,
|
|
2330
|
+
os as emitValueAsNullableDateTime,
|
|
2331
|
+
Et as emitValueAsNumber,
|
|
2332
|
+
Re as endInterpolate,
|
|
2333
|
+
ne as getWindow,
|
|
2334
|
+
Ve as guessInterpolate,
|
|
2335
|
+
es as html,
|
|
2336
|
+
ts as input,
|
|
2337
|
+
Ne as interpolateDate,
|
|
2338
|
+
ke as interpolateNumber,
|
|
2339
|
+
$e as interpolateString,
|
|
2340
|
+
Ht as joinSignals,
|
|
2341
|
+
$t as localStorageProp,
|
|
2342
|
+
Dt as makeProbe,
|
|
2343
|
+
Qe as makeProviderMark,
|
|
2344
|
+
rs as math,
|
|
2345
|
+
Kt as mathAttr,
|
|
2346
|
+
Vt as merge,
|
|
2347
|
+
z as on,
|
|
2348
|
+
qt as previousSignal,
|
|
2349
|
+
_ as prop,
|
|
2350
|
+
Ut as render,
|
|
2351
|
+
oe as renderWithContext,
|
|
2352
|
+
h as renderableOfTNode,
|
|
2353
|
+
Xt as restoreTempoPlaceholders,
|
|
2354
|
+
Jt as runHeadless,
|
|
2355
|
+
Nt as sessionStorageProp,
|
|
2356
|
+
Q as signal,
|
|
2357
|
+
Ft as slidingWindowSignal,
|
|
2358
|
+
de as storedProp,
|
|
2359
|
+
Cs as style,
|
|
2360
|
+
ss as svg,
|
|
2361
|
+
zt as svgAttr
|
|
2412
2362
|
};
|