elements-kit 0.22.1 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -21
- package/README.md +27 -11
- package/dist/await.d.mts +1 -1
- package/dist/await.mjs +3 -5
- package/dist/children-BbHF-Dew.d.mts +253 -0
- package/dist/{element-Di0PYFX1.mjs → element-w3nDE2S5.mjs} +2 -2
- package/dist/for.d.mts +1 -1
- package/dist/for.mjs +1 -1
- package/dist/{fragment-Bvs1sGu1.mjs → fragment-DEhI5x0f.mjs} +2 -3
- package/dist/hydrate/index.mjs +1 -1
- package/dist/{hydrate-DvWdnV-e.mjs → hydrate-CrVzu88K.mjs} +4 -4
- package/dist/index-BR8XVkck.d.mts +392 -0
- package/dist/integrations/astro-client.mjs +2 -2
- package/dist/integrations/astro-server.mjs +3 -4
- package/dist/integrations/astro-slots.mjs +2 -2
- package/dist/integrations/react.d.mts +1 -1
- package/dist/jsx-runtime/index.d.mts +3 -2
- package/dist/jsx-runtime/index.mjs +2 -2
- package/dist/server/index.mjs +1 -1
- package/dist/{server-CTkyXTV6.mjs → server-D7ffi7b_.mjs} +4 -4
- package/dist/signals/index.d.mts +2 -2
- package/dist/signals/index.mjs +30 -20
- package/dist/ui/otp-input/index.d.mts +1 -1
- package/dist/utilities/active-element.d.mts +1 -1
- package/dist/utilities/async.d.mts +1 -1
- package/dist/utilities/debounced.d.mts +1 -1
- package/dist/utilities/element-rect.d.mts +1 -1
- package/dist/utilities/element-scroll.d.mts +1 -1
- package/dist/utilities/environment.d.mts +1 -1
- package/dist/utilities/event-driven.d.mts +1 -1
- package/dist/utilities/event-listener.d.mts +1 -1
- package/dist/utilities/focus-within.d.mts +1 -1
- package/dist/utilities/hover.d.mts +1 -1
- package/dist/utilities/interval.d.mts +1 -1
- package/dist/utilities/location.d.mts +1 -1
- package/dist/utilities/media-devices.d.mts +1 -1
- package/dist/utilities/media-player.d.mts +1 -1
- package/dist/utilities/media-query.d.mts +1 -1
- package/dist/utilities/network.d.mts +1 -1
- package/dist/utilities/orientation.d.mts +1 -1
- package/dist/utilities/previous.d.mts +1 -1
- package/dist/utilities/promise.d.mts +1 -1
- package/dist/utilities/routing.d.mts +1 -1
- package/dist/utilities/search-params.d.mts +1 -1
- package/dist/utilities/storage.d.mts +1 -1
- package/dist/utilities/throttled.d.mts +1 -1
- package/dist/utilities/timeout.d.mts +1 -1
- package/dist/utilities/window-focus.d.mts +1 -1
- package/dist/utilities/window-size.d.mts +1 -1
- package/package.json +1 -1
- package/dist/children-s3nFjpLA.d.mts +0 -581
- /package/dist/{environment-CTAGxqz_.d.mts → environment-Fg46vL6e.d.mts} +0 -0
- /package/dist/{polyfill-BVNd6ogU.d.mts → polyfill-C-CxgMqq.d.mts} +0 -0
package/LICENSE
CHANGED
|
@@ -1,21 +1,201 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
**Universal reactive primitives for the web.** Signals, JSX, custom elements, and browser-API helpers. Import one at a time, compose them, or use any of them inside vanilla JS, React, Vue, or any framework.
|
|
4
4
|
|
|
5
5
|
```tsx
|
|
6
|
-
import { signal, computed } from "elements-kit/signals";
|
|
6
|
+
import { signal, computed, resolve } from "elements-kit/signals";
|
|
7
7
|
import { render } from "elements-kit/render";
|
|
8
8
|
import type { Props } from "elements-kit/jsx-runtime";
|
|
9
9
|
|
|
10
10
|
function Counter(props: Props<{ initial?: number }>) {
|
|
11
|
-
const count = signal(props.initial
|
|
11
|
+
const count = signal(resolve(props.initial) ?? 0);
|
|
12
12
|
const doubled = computed(() => count() * 2);
|
|
13
13
|
|
|
14
14
|
return (
|
|
@@ -60,13 +60,13 @@ Every feature is a separate subpath export — import only what you use.
|
|
|
60
60
|
|
|
61
61
|
| Entry | Purpose |
|
|
62
62
|
|-------|---------|
|
|
63
|
-
| `elements-kit/signals` | `signal`, `computed`, `effect`, `effectScope`, `batch`, `untracked`, `trigger`, `onCleanup`, `MaybeReactive`, `resolve`, `
|
|
63
|
+
| `elements-kit/signals` | `signal`, `computed`, `effect`, `effectScope`, `batch`, `untracked`, `trigger`, `onCleanup`, `MaybeReactive`, `resolve`, `computedProps`, `@reactive` |
|
|
64
64
|
| `elements-kit/render` | `render(target, setup)` — mount a node with a scoped lifetime; returns `unmount` |
|
|
65
65
|
| `elements-kit/attributes` | `@attributes` decorator + `ATTRIBUTES` symbol |
|
|
66
66
|
| `elements-kit/slot` | `Slot` class + `@slot()` decorator + `SlotContent` type — comment-marker DOM regions as plain properties |
|
|
67
67
|
| `elements-kit/custom-elements` | `defineElement`, `CustomElementRegistry`, `PropertiesOf`, `AttributesOf`, `EventsOf`, `PublicPropKeys` — raw framework-agnostic extractors for a custom element's properties/attributes/events |
|
|
68
68
|
| `elements-kit/for` | `For` keyed-list component |
|
|
69
|
-
| `elements-kit/jsx-runtime` | JSX factory + type helpers (`PropsOf`, `MaybeReactiveProps`, `
|
|
69
|
+
| `elements-kit/jsx-runtime` | JSX factory + type helpers (`PropsOf`, `MaybeReactiveProps`, `Props`, `Require`) — configure via `jsxImportSource` |
|
|
70
70
|
| `elements-kit/server` | `renderToStream`, `renderToString` — streaming HTML rendering in any JS runtime (Node, edge/Workers), no DOM required *(experimental)* |
|
|
71
71
|
| `elements-kit/hydrate` | `hydrate(container, () => <App/>)` — adopt server-rendered DOM and make it interactive *(experimental)* |
|
|
72
72
|
| `elements-kit/await` | `Await` — loading boundary (Suspense equivalent); code splitting = `async` + dynamic import *(experimental)* |
|
|
@@ -418,25 +418,41 @@ A small set of type helpers derives JSX prop shapes from your components — no
|
|
|
418
418
|
| Helper | For |
|
|
419
419
|
| ------ | --- |
|
|
420
420
|
| `PropsOf<C>` | Unified — fn/class components give raw prop shapes; custom-element ctors give the full JSX surface (attrs, events, slots, children) |
|
|
421
|
-
| `Props<P>` |
|
|
422
|
-
| `MaybeReactiveProps<P>` |
|
|
423
|
-
| `
|
|
421
|
+
| `Props<P>` | Every prop accepts a value *or* a reactive source — declare it on a function component that should take signals (alias of `MaybeReactiveProps<P>`) |
|
|
422
|
+
| `MaybeReactiveProps<P>` | The same wrap under its descriptive name — used for class constructor params and the intrinsic-element surface |
|
|
423
|
+
| `ComputedProps<P>` | The mirror of `Props<P>` — what a body *reads* after `computedProps`: every key a `Computed<T>`, optional keys included |
|
|
424
424
|
| `MaybeReactive<T>` | Scalar value-or-getter (from `elements-kit/signals`) |
|
|
425
425
|
| `Require<P, K>` | Promote optional keys to required |
|
|
426
426
|
|
|
427
|
-
|
|
427
|
+
Intrinsic and custom-element attributes accept a static value *or* a signal at every JSX call site — the runtime's `LibraryManagedAttributes` handles that wrap for you.
|
|
428
428
|
|
|
429
|
-
|
|
429
|
+
Function components are different: props arrive **exactly as the caller wrote them**, so the declared type is the contract on both sides. Declare plain types for static-only props; declare `Props<P>` (or `MaybeReactive<T>` per key) to accept signals, and read with `resolve` or by handing the prop to JSX:
|
|
430
430
|
|
|
431
431
|
```tsx
|
|
432
|
+
import { resolve } from "elements-kit/signals";
|
|
432
433
|
import type { Props } from "elements-kit/jsx-runtime";
|
|
433
434
|
|
|
434
435
|
function Greeting(props: Props<{ name: string }>) {
|
|
435
|
-
return <p>Hello, {props.name}</p>;
|
|
436
|
+
return <p>Hello, {props.name}</p>; // JSX accepts either form
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
function Plain(props: { name: string }) {
|
|
440
|
+
return <p>Hello, {props.name}</p>; // callers may not pass a signal
|
|
441
|
+
}
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
To read one uniform shape instead, convert the props with `computedProps` — every key becomes a getter, so no read needs `resolve`. Defaults go on the call, since a getter is always truthy:
|
|
445
|
+
|
|
446
|
+
```tsx
|
|
447
|
+
import { computedProps } from "elements-kit/signals";
|
|
448
|
+
|
|
449
|
+
function Chat(raw: Props<{ placeholder?: string }>) {
|
|
450
|
+
const props = computedProps(raw);
|
|
451
|
+
return <input placeholder={props.placeholder() ?? "Ask anything…"} />;
|
|
436
452
|
}
|
|
437
453
|
```
|
|
438
454
|
|
|
439
|
-
`
|
|
455
|
+
A prop that takes arguments (a render prop, a handler with parameters) is rejected there — a callable cannot be told apart from a getter, since `Computed<T>` *is* `() => T`. Read those off the raw props instead.
|
|
440
456
|
|
|
441
457
|
## `@reactive()` Decorator
|
|
442
458
|
|
package/dist/await.d.mts
CHANGED
package/dist/await.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { f as effectsInert, t as ASYNC_REGION } from "./lib-DYypKhxk.mjs";
|
|
2
|
-
import { isReactive } from "./signals/index.mjs";
|
|
3
2
|
import { isReactivePromiseLike, promise } from "./utilities/promise.mjs";
|
|
4
3
|
import { isAsyncLike } from "./utilities/async.mjs";
|
|
5
4
|
//#region src/await.ts
|
|
@@ -14,16 +13,15 @@ function toAwaitables(value) {
|
|
|
14
13
|
return out;
|
|
15
14
|
}
|
|
16
15
|
function Await(props) {
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const when = read(props.when);
|
|
16
|
+
const children = props.children;
|
|
17
|
+
const when = props.when;
|
|
20
18
|
const fromChildren = toAwaitables(children);
|
|
21
19
|
const awaitables = when != null ? toAwaitables(when) : fromChildren;
|
|
22
20
|
if (awaitables.length === 0) return children;
|
|
23
21
|
if (effectsInert()) return promise(Promise.all(awaitables).then(() => () => children));
|
|
24
22
|
const fallback = props.fallback;
|
|
25
23
|
const pending = () => awaitables.some((a) => a.state !== "fulfilled" && a.state !== "rejected");
|
|
26
|
-
const region = () => pending() ?
|
|
24
|
+
const region = () => pending() ? fallback : children;
|
|
27
25
|
region[ASYNC_REGION] = {
|
|
28
26
|
ids: 1 + fromChildren.length,
|
|
29
27
|
pending
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { n as AttrChangeHandler, t as ATTRIBUTES } from "./attributes-DILeh3-s.mjs";
|
|
2
|
+
import { i as PropertiesOf, n as CustomElementRegistry, r as EventsOf } from "./custom-elements-CdpilMDu.mjs";
|
|
3
|
+
import { r as MaybeReactive } from "./index-BR8XVkck.mjs";
|
|
4
|
+
import * as CSS from "csstype";
|
|
5
|
+
import { JSX } from "dom-expressions/src/jsx";
|
|
6
|
+
|
|
7
|
+
//#region src/jsx-runtime/element.d.ts
|
|
8
|
+
type UnsupportedDomKeys = "ref" | "children" | "classList" | "$ServerOnly" | keyof JSX.CustomEventHandlersCamelCase<any> | keyof JSX.CustomEventHandlersLowerCase<any> | keyof JSX.DirectiveAttributes | keyof JSX.DirectiveFunctionAttributes<any> | keyof JSX.AttrAttributes | keyof JSX.BoolAttributes | keyof JSX.OnCaptureAttributes<any>;
|
|
9
|
+
type DOMIntrinsicElements = { [K in keyof JSX.IntrinsicElements]: Omit<JSX.IntrinsicElements[K], UnsupportedDomKeys> };
|
|
10
|
+
type DOMElements = { [K in keyof JSX.IntrinsicElements]: JSX.IntrinsicElements[K] extends {
|
|
11
|
+
ref?: infer R | undefined;
|
|
12
|
+
} ? Extract<R, (el: any) => any> extends ((el: infer E) => any) ? E : Element : Element };
|
|
13
|
+
declare function createElement(type: JSX$1.ElementType, allProps?: {
|
|
14
|
+
ref?: (el: Element) => void;
|
|
15
|
+
} & Record<string, unknown>): JSX$1.Element | null;
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/jsx-runtime/infer.d.ts
|
|
18
|
+
/**
|
|
19
|
+
* Promote keys `K` of `P` to required; leave the rest unchanged.
|
|
20
|
+
*
|
|
21
|
+
* @template P — the prop object type.
|
|
22
|
+
* @template K — the keys to make required.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* type Optional = { a?: number; b?: string; c?: boolean };
|
|
27
|
+
* type AB = Require<Optional, "a" | "b">;
|
|
28
|
+
* // { a: number; b: string; c?: boolean }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
type Require<P, K extends keyof P> = { [X in K]-?: P[X] } & Omit<P, K>;
|
|
32
|
+
/**
|
|
33
|
+
* Caller-facing wrap: each key accepts a plain value OR a reactive getter.
|
|
34
|
+
* Name it when typing a call-site shape by hand (e.g. a class component's
|
|
35
|
+
* constructor param, like `For`'s); the JSX checker applies it to intrinsic
|
|
36
|
+
* and custom-element props. Function-typed props are wrapped too
|
|
37
|
+
* (`Computed<F>` is zero-arg, so TS still picks the handler signature by
|
|
38
|
+
* arity for inline arrows). `Signal<F>` must never be added explicitly — its
|
|
39
|
+
* one-arg `Updater` half would collapse inline arrow params to implicit any.
|
|
40
|
+
*/
|
|
41
|
+
type MaybeReactiveProps<P> = { [K in keyof P]: undefined extends P[K] ? MaybeReactive<Exclude<P[K], undefined>> | undefined : MaybeReactive<P[K]> };
|
|
42
|
+
/**
|
|
43
|
+
* Props of a function component that accepts reactive values — the same type
|
|
44
|
+
* as {@link MaybeReactiveProps}, under the name components reach for. Each key
|
|
45
|
+
* holds a plain value or a reactive source; the runtime hands the prop over
|
|
46
|
+
* exactly as the caller wrote it.
|
|
47
|
+
*
|
|
48
|
+
* Read a key with `resolve(props.x)`, or pass it straight into JSX, which
|
|
49
|
+
* accepts either form. Omit it and declare the plain value type when a
|
|
50
|
+
* component takes static props only — callers then cannot pass a signal.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```tsx
|
|
54
|
+
* function Greeting(props: Props<{ name: string; excited?: boolean }>) {
|
|
55
|
+
* return <p>Hello, {props.name}{() => (resolve(props.excited) ? "!" : ".")}</p>;
|
|
56
|
+
* }
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
type Props<P> = MaybeReactiveProps<P>;
|
|
60
|
+
/**
|
|
61
|
+
* @internal Call-site prop resolution for `JSX.LibraryManagedAttributes`:
|
|
62
|
+
* - empty param (instance-field classes, no ctor) → wrap `PropsOf<C>`
|
|
63
|
+
* - any declared param → pass through verbatim
|
|
64
|
+
*
|
|
65
|
+
* Function components land in the pass-through branch: the runtime no longer
|
|
66
|
+
* transforms their props, so the declared type is the contract on both sides.
|
|
67
|
+
* A component opts into reactive props by declaring {@link Props} (or a
|
|
68
|
+
* per-key `MaybeReactive`) itself.
|
|
69
|
+
*
|
|
70
|
+
* Emptiness is checked FIRST so a no-ctor class still gets its instance fields
|
|
71
|
+
* wrapped; without that branch `<Toggle checked={x}/>` would have no prop type
|
|
72
|
+
* at all, since TS reads class attributes off the constructor parameter.
|
|
73
|
+
*/
|
|
74
|
+
type ResolveProps<C, P, NN = NonNullable<P>> = [keyof NN] extends [never] ? C extends JSX$1.ElementType | JSX$1.ElementClass ? MaybeReactiveProps<PropsOf<C>> : {} : NN;
|
|
75
|
+
type PropKeysOf<C> = keyof PropertiesOf<C> & string;
|
|
76
|
+
type AttrMap<C> = C extends {
|
|
77
|
+
[ATTRIBUTES]: infer M;
|
|
78
|
+
} ? M : {};
|
|
79
|
+
type HandlerValue<H> = H extends AttrChangeHandler<any> ? string | null : H;
|
|
80
|
+
type AttrsOf<C> = AttrMap<C> extends infer M ? M extends Record<string, unknown> ? string extends keyof M ? {} : { [K in Exclude<keyof M & string, PropKeysOf<C>>]?: HandlerValue<M[K]> } : {} : {};
|
|
81
|
+
type PropNamespacedOf<C> = { [K in PropKeysOf<C> as `prop:${K}`]?: NonNullable<PropertiesOf<C>[K]> };
|
|
82
|
+
type JsxEventsOf<C> = { [K in keyof EventsOf<C> & string as `on:${K}`]?: (ev: EventsOf<C>[K]) => void };
|
|
83
|
+
type ChildrenOf<C> = C extends {
|
|
84
|
+
children: never;
|
|
85
|
+
} ? {} : {
|
|
86
|
+
children?: Children;
|
|
87
|
+
};
|
|
88
|
+
type BaseDOMAttrs = JSX.DOMAttributes<HTMLElement>;
|
|
89
|
+
/**
|
|
90
|
+
* Full JSX prop type for a custom-element class (extends `HTMLElement`).
|
|
91
|
+
*
|
|
92
|
+
* Composes every surface the element can receive from JSX:
|
|
93
|
+
* - **Attributes** — keys from `static [ATTRIBUTES]` (typed `MaybeReactive<string | null>`).
|
|
94
|
+
* Keys also present on the instance are dropped here so the flat key carries the property type.
|
|
95
|
+
* - **Flat properties** — public instance fields, wrapped in `MaybeReactive`.
|
|
96
|
+
* - **`prop:*`** — explicit property assignment for every field.
|
|
97
|
+
* - **Events** — keys from `declare static events: { ... }` produce
|
|
98
|
+
* `on:${K}` typed handlers (the only event syntax the runtime attaches).
|
|
99
|
+
* - **Children** — `children?: Child` unless `static children: never`.
|
|
100
|
+
* - **DOM attrs** — the standard dom-expressions surface (`class`, `style`, `ref`, …).
|
|
101
|
+
*
|
|
102
|
+
* @template C — the custom-element class (constructor type).
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```ts
|
|
106
|
+
* \@attributes
|
|
107
|
+
* class XRange extends HTMLElement {
|
|
108
|
+
* static [ATTRIBUTES]: Attributes<XRange> = { min(v) { this.min = +v! } };
|
|
109
|
+
* declare static events: { commit: CustomEvent<number> };
|
|
110
|
+
* #slot = new Slot();
|
|
111
|
+
* get label() { return this.#slot.get(); }
|
|
112
|
+
* set label(value: Node) { this.#slot.set(value) }
|
|
113
|
+
* \@reactive() min = 0;
|
|
114
|
+
* }
|
|
115
|
+
*
|
|
116
|
+
* type Props = ElementProps<typeof XRange>;
|
|
117
|
+
* // {
|
|
118
|
+
* // min?: MaybeReactive<number>;
|
|
119
|
+
* // "prop:min"?: number;
|
|
120
|
+
* // "on:commit"?: (e: CustomEvent<number>) => void;
|
|
121
|
+
* // label?: Node
|
|
122
|
+
* // children?: Node;
|
|
123
|
+
* // // …plus ref, class, class:*, style, style:*, standard DOM events
|
|
124
|
+
* // }
|
|
125
|
+
* ```
|
|
126
|
+
*
|
|
127
|
+
* @see {@link PropsOf} for class-components / function components (no attr/event synthesis).
|
|
128
|
+
*/
|
|
129
|
+
type ElementProps<C extends AnyElementCtor> = BaseDOMAttrs & AttrsOf<C> & PropertiesOf<C> & PropNamespacedOf<C> & JsxEventsOf<C> & ChildrenOf<C>;
|
|
130
|
+
/**
|
|
131
|
+
* Props for any component — class or function.
|
|
132
|
+
*
|
|
133
|
+
* The combination of the two specialised helpers:
|
|
134
|
+
* - **Custom-element constructor** (`typeof Cls`, `Cls extends HTMLElement`)
|
|
135
|
+
* → `ElementProps<Cls>` — the full JSX surface (attrs, `prop:*`, `on:*`,children).
|
|
136
|
+
* - **Everything else** (function component, class component ctor or
|
|
137
|
+
* instance) → `ComponentProps<T>` — the raw prop shape.
|
|
138
|
+
*
|
|
139
|
+
* @template T — constructor, function, or instance.
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```ts
|
|
143
|
+
* // 1. Class instance (lets a generic flow)
|
|
144
|
+
* class For<T> { each: T[] = []; render() { return null } }
|
|
145
|
+
* type ForProps<T> = PropsOf<For<T>>;
|
|
146
|
+
* // ↑ { each?: T[] }
|
|
147
|
+
*
|
|
148
|
+
* // 2. Function component
|
|
149
|
+
* const Greeting = (_p: { name: string; excited?: boolean }) => null;
|
|
150
|
+
* type GreetingProps = PropsOf<typeof Greeting>;
|
|
151
|
+
* // ↑ { name: string; excited?: boolean }
|
|
152
|
+
*
|
|
153
|
+
* // 3. Class constructor
|
|
154
|
+
* class Counter { count = 0; render() { return null } }
|
|
155
|
+
* type CounterProps = PropsOf<typeof Counter>;
|
|
156
|
+
* // ↑ { count?: number }
|
|
157
|
+
* ```
|
|
158
|
+
*/
|
|
159
|
+
type PropsOf<T extends JSX$1.ElementType | JSX$1.ElementClass | AnyElementCtor> = T extends AnyElementCtor ? ElementProps<T> : T extends JSX$1.ElementType | JSX$1.ElementClass ? ComponentProps<T> : never;
|
|
160
|
+
/**
|
|
161
|
+
* Props of a function or class COMPONENT (not a custom element): function
|
|
162
|
+
* components use the first parameter as declared; classes use their public
|
|
163
|
+
* instance fields. The custom-element half of `PropsOf` is `ElementProps`.
|
|
164
|
+
*/
|
|
165
|
+
type ComponentProps<T extends JSX$1.ElementType | JSX$1.ElementClass> = T extends ((props: infer P, ...rest: any[]) => any) ? P extends object ? P : {} : PropertiesOf<T>;
|
|
166
|
+
type AnyElementCtor = abstract new (...args: any[]) => HTMLElement;
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region src/jsx-runtime/fragment.d.ts
|
|
169
|
+
/**
|
|
170
|
+
* Used by the JSX transform for `<>...</>` fragments.
|
|
171
|
+
*
|
|
172
|
+
* Each child is routed through `mountChild`, which handles Nodes, strings,
|
|
173
|
+
* numbers, arrays, and reactive getters — matching the behavior of any other
|
|
174
|
+
* JSX container. `mountChild` also wires each child's cleanup via its own
|
|
175
|
+
* `effectScope`, which links to the enclosing `effectScope` created by
|
|
176
|
+
* `createElement(Fragment, ...)` for disposal propagation.
|
|
177
|
+
*
|
|
178
|
+
* **Raw HTML mode** — `<Fragment html>{markup}</Fragment>`: the child is a
|
|
179
|
+
* `MaybeReactive<string>` rendered as markup inside a Slot region (comment
|
|
180
|
+
* markers), so the server renderer and the hydration claim pass share the
|
|
181
|
+
* region boundary. Reactive sources re-render the region on change. This is
|
|
182
|
+
* the library's only raw-HTML sink: the string is NOT escaped — sanitize
|
|
183
|
+
* untrusted input at the call site. `<script>` tags never execute.
|
|
184
|
+
*/
|
|
185
|
+
declare function Fragment(props: Props<{
|
|
186
|
+
children?: Children;
|
|
187
|
+
}> | {
|
|
188
|
+
html: true;
|
|
189
|
+
children: MaybeReactive<string>;
|
|
190
|
+
}): DocumentFragment;
|
|
191
|
+
//#endregion
|
|
192
|
+
//#region src/jsx-runtime/index.d.ts
|
|
193
|
+
declare namespace JSX$1 {
|
|
194
|
+
export type Element = globalThis.Element | globalThis.DocumentFragment;
|
|
195
|
+
export type ElementClass = {
|
|
196
|
+
render(): JSX$1.Element | null;
|
|
197
|
+
};
|
|
198
|
+
export type ElementType = string | JSX$1.Element | (new (props: any) => JSX$1.ElementClass) | ((props: any) => JSX$1.Element | null);
|
|
199
|
+
export interface ElementChildrenAttribute {
|
|
200
|
+
children: {};
|
|
201
|
+
}
|
|
202
|
+
export interface IntrinsicAttributes {}
|
|
203
|
+
export type LibraryManagedAttributes<C, P> = ResolveProps<C, P>;
|
|
204
|
+
type RegisteredElements = { [K in keyof CustomElementRegistry]: CustomElementRegistry[K] extends infer C extends AnyElementCtor ? MaybeReactiveProps<WithJsxNamespaces<Omit<ElementProps<C>, "children" | "ref">, InstanceType<C>>> & {
|
|
205
|
+
ref?: (el: InstanceType<C>) => void;
|
|
206
|
+
children?: Children;
|
|
207
|
+
} : never };
|
|
208
|
+
export type IntrinsicElements = { [K in keyof DOMIntrinsicElements]: MaybeReactiveProps<WithJsxNamespaces<DOMIntrinsicElements[K], DOMElements[K]>> & {
|
|
209
|
+
ref?: (el: DOMElements[K]) => void;
|
|
210
|
+
children?: Children;
|
|
211
|
+
} & (DOMElements[K] extends SVGElement ? SvgNamespaceAttrs : {}) } & RegisteredElements;
|
|
212
|
+
export {};
|
|
213
|
+
}
|
|
214
|
+
/** A class whose constructor returns a ComponentInstance. */
|
|
215
|
+
type ComponentClass<P extends Record<PropertyKey, unknown> = any> = new (props: P) => JSX$1.ElementClass;
|
|
216
|
+
type ComponentFn<P extends Record<PropertyKey, unknown> = any> = (props: P) => JSX$1.Element | null;
|
|
217
|
+
//#endregion
|
|
218
|
+
//#region src/jsx-runtime/properties.d.ts
|
|
219
|
+
interface CSSProperties extends CSS.PropertiesHyphen {
|
|
220
|
+
[key: `-${string}`]: string | number | undefined;
|
|
221
|
+
}
|
|
222
|
+
type CssStyleKey = Extract<keyof CSSProperties, string> extends infer K ? K extends `-${string}` ? never : K : never;
|
|
223
|
+
type StyleNamespace = { [K in CssStyleKey as `style:${K}`]?: CSSProperties[K] | null };
|
|
224
|
+
type PropNamespace<E> = { [K in keyof E as K extends string ? `prop:${K}` : never]?: E[K] };
|
|
225
|
+
type XlinkAttrs = {
|
|
226
|
+
"xlink:href"?: string | undefined;
|
|
227
|
+
"xlink:title"?: string | undefined;
|
|
228
|
+
"xlink:show"?: "new" | "replace" | "embed" | "other" | "none" | undefined;
|
|
229
|
+
"xlink:role"?: string | undefined;
|
|
230
|
+
"xlink:type"?: "simple" | "extended" | "locator" | "arc" | "resource" | "title" | undefined;
|
|
231
|
+
"xlink:arcrole"?: string | undefined;
|
|
232
|
+
"xlink:actuate"?: "onLoad" | "onRequest" | "other" | "none" | undefined;
|
|
233
|
+
};
|
|
234
|
+
type ClassNamespace = { [K in `class:${string}`]?: boolean };
|
|
235
|
+
type XmlAttrs = {
|
|
236
|
+
"xml:lang"?: string | undefined;
|
|
237
|
+
"xml:space"?: "default" | "preserve" | undefined;
|
|
238
|
+
"xml:base"?: string | undefined;
|
|
239
|
+
};
|
|
240
|
+
type SvgNamespaceAttrs = XlinkAttrs & XmlAttrs;
|
|
241
|
+
interface StyleAttrObject extends CSS.Properties {}
|
|
242
|
+
type JsxNamespaces<E extends Element = Element> = (E extends ElementCSSInlineStyle ? {
|
|
243
|
+
style?: string | StyleAttrObject;
|
|
244
|
+
} & StyleNamespace : {}) & PropNamespace<Omit<E, "children">> & ClassNamespace;
|
|
245
|
+
type JsxNamespaceKeys = "style" | `class:${string}` | `style:${string}` | `prop:${string}`;
|
|
246
|
+
type WithJsxNamespaces<T, E extends Element = Element> = Omit<T, JsxNamespaceKeys> & JsxNamespaces<E>;
|
|
247
|
+
//#endregion
|
|
248
|
+
//#region src/jsx-runtime/children.d.ts
|
|
249
|
+
type PrimitiveNodeType = Node | string | boolean | number | bigint | symbol | Date | RegExp | null | undefined;
|
|
250
|
+
type AnyFn = (...args: any[]) => Children;
|
|
251
|
+
type Children = PrimitiveNodeType | AnyFn | Element | DocumentFragment | Children[];
|
|
252
|
+
//#endregion
|
|
253
|
+
export { Fragment as a, PropsOf as c, JSX$1 as i, Require as l, ComponentClass as n, MaybeReactiveProps as o, ComponentFn as r, Props as s, Children as t, createElement as u };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { C as untracked, _ as onCleanup, d as effectScope, u as effect } from "./lib-DYypKhxk.mjs";
|
|
2
2
|
import "./polyfill-CdZVCxdo.mjs";
|
|
3
|
-
import { isReactive
|
|
3
|
+
import { isReactive } from "./signals/index.mjs";
|
|
4
4
|
import { on } from "./utilities/event-listener.mjs";
|
|
5
5
|
import { Slot } from "./slot.mjs";
|
|
6
6
|
//#region src/jsx-runtime/constants.ts
|
|
@@ -540,7 +540,7 @@ function createFunctionElement(type, props, ref) {
|
|
|
540
540
|
let dispose;
|
|
541
541
|
untracked(() => {
|
|
542
542
|
dispose = effectScope(() => {
|
|
543
|
-
el = type(
|
|
543
|
+
el = type(props);
|
|
544
544
|
if (typeof ref === "function" && el instanceof Element) ref(el);
|
|
545
545
|
});
|
|
546
546
|
});
|
package/dist/for.d.mts
CHANGED
package/dist/for.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { C as untracked, S as trigger, _ as onCleanup, d as effectScope, u as effect, x as signal } from "./lib-DYypKhxk.mjs";
|
|
2
2
|
import "./signals/index.mjs";
|
|
3
|
-
import { n as disposeElement } from "./element-
|
|
3
|
+
import { n as disposeElement } from "./element-w3nDE2S5.mjs";
|
|
4
4
|
//#region src/for.ts
|
|
5
5
|
/**
|
|
6
6
|
* Keyed list renderer. See {@link ForProps} for prop details.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _ as onCleanup, u as effect } from "./lib-DYypKhxk.mjs";
|
|
2
2
|
import "./signals/index.mjs";
|
|
3
|
-
import { a as mountChild } from "./element-
|
|
3
|
+
import { a as mountChild } from "./element-w3nDE2S5.mjs";
|
|
4
4
|
import { Slot } from "./slot.mjs";
|
|
5
5
|
//#region src/jsx-runtime/fragment.ts
|
|
6
6
|
/**
|
|
@@ -44,8 +44,7 @@ function Fragment(props) {
|
|
|
44
44
|
} else if (source != null) slot.set(parseHtml(String(source)));
|
|
45
45
|
return fragment;
|
|
46
46
|
}
|
|
47
|
-
const
|
|
48
|
-
const raw = typeof children === "function" ? children() : children;
|
|
47
|
+
const raw = props.children;
|
|
49
48
|
if (raw == null) return fragment;
|
|
50
49
|
const nodes = Array.isArray(raw) ? raw.flat(Infinity) : [raw];
|
|
51
50
|
for (const child of nodes) mountChild(fragment, child);
|
package/dist/hydrate/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as hydrate } from "../hydrate-
|
|
1
|
+
import { t as hydrate } from "../hydrate-CrVzu88K.mjs";
|
|
2
2
|
export { hydrate };
|