solid-js 2.0.0-beta.1 → 2.0.0-beta.10
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/CHEATSHEET.md +640 -0
- package/README.md +42 -188
- package/dist/dev.cjs +431 -283
- package/dist/dev.js +411 -286
- package/dist/server.cjs +701 -281
- package/dist/server.js +684 -284
- package/dist/solid.cjs +423 -255
- package/dist/solid.js +403 -258
- package/package.json +67 -39
- package/types/client/component.d.ts +64 -19
- package/types/client/core.d.ts +110 -34
- package/types/client/flow.d.ts +176 -42
- package/types/client/hydration.d.ts +514 -36
- package/types/index.d.ts +9 -12
- package/types/server/component.d.ts +11 -11
- package/types/server/core.d.ts +19 -14
- package/types/server/flow.d.ts +76 -21
- package/types/server/hydration.d.ts +34 -9
- package/types/server/index.d.ts +5 -7
- package/types/server/shared.d.ts +5 -1
- package/types/server/signals.d.ts +44 -19
- package/types/types.d.ts +15 -0
- package/types-cjs/client/component.d.cts +120 -0
- package/types-cjs/client/core.d.cts +141 -0
- package/types-cjs/client/flow.d.cts +234 -0
- package/types-cjs/client/hydration.d.cts +570 -0
- package/types-cjs/index.d.cts +17 -0
- package/types-cjs/package.json +3 -0
- package/types-cjs/server/component.d.cts +67 -0
- package/types-cjs/server/core.d.cts +49 -0
- package/types-cjs/server/flow.d.cts +115 -0
- package/types-cjs/server/hydration.d.cts +63 -0
- package/types-cjs/server/index.d.cts +10 -0
- package/types-cjs/server/shared.d.cts +50 -0
- package/types-cjs/server/signals.d.cts +87 -0
- package/types-cjs/types.d.cts +15 -0
- package/jsx-runtime.d.ts +0 -1
- package/types/jsx.d.ts +0 -4129
package/types/client/flow.d.ts
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
import type { Accessor } from "@solidjs/signals";
|
|
2
|
-
|
|
1
|
+
import type { Accessor, RevealOrder } from "@solidjs/signals";
|
|
2
|
+
export type { RevealOrder };
|
|
3
|
+
import type { Element as SolidElement } from "../types.js";
|
|
4
|
+
type NonZeroParams<T extends (...args: any[]) => any> = Parameters<T>["length"] extends 0 ? never : T;
|
|
5
|
+
type ConditionalRenderCallback<T> = (item: Accessor<NonNullable<T>>) => SolidElement;
|
|
6
|
+
type ConditionalRenderChildren<T, F extends ConditionalRenderCallback<T> = ConditionalRenderCallback<T>> = SolidElement | NonZeroParams<F>;
|
|
3
7
|
/**
|
|
4
|
-
* Creates a list of elements from a list
|
|
8
|
+
* Creates a list of elements from a list.
|
|
5
9
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
10
|
+
* Receives a map function as its child that takes list element and index
|
|
11
|
+
* accessors and returns a JSX element; if the list is empty, an optional
|
|
12
|
+
* `fallback` is rendered instead.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
8
16
|
* <For each={items} fallback={<div>No items</div>}>
|
|
9
17
|
* {(item, index) => <div data-index={index()}>{item()}</div>}
|
|
10
18
|
* </For>
|
|
@@ -12,17 +20,20 @@ import type { JSX } from "../jsx.js";
|
|
|
12
20
|
*
|
|
13
21
|
* @description https://docs.solidjs.com/reference/components/for
|
|
14
22
|
*/
|
|
15
|
-
export declare function For<T extends readonly any[], U extends
|
|
23
|
+
export declare function For<T extends readonly any[], U extends SolidElement>(props: {
|
|
16
24
|
each: T | undefined | null | false;
|
|
17
|
-
fallback?:
|
|
25
|
+
fallback?: SolidElement;
|
|
18
26
|
keyed?: boolean | ((item: T[number]) => any);
|
|
19
27
|
children: (item: Accessor<T[number]>, index: Accessor<number>) => U;
|
|
20
|
-
}):
|
|
28
|
+
}): SolidElement;
|
|
21
29
|
/**
|
|
22
|
-
* Creates a list elements from a count
|
|
30
|
+
* Creates a list of elements from a count.
|
|
31
|
+
*
|
|
32
|
+
* Receives a map function as its child that takes the index and returns a JSX
|
|
33
|
+
* element; if the count is zero, an optional `fallback` is rendered instead.
|
|
23
34
|
*
|
|
24
|
-
*
|
|
25
|
-
* ```
|
|
35
|
+
* @example
|
|
36
|
+
* ```tsx
|
|
26
37
|
* <Repeat count={items.length} fallback={<div>No items</div>}>
|
|
27
38
|
* {(index) => <div data-index={index}>{items[index]}</div>}
|
|
28
39
|
* </Repeat>
|
|
@@ -30,25 +41,43 @@ export declare function For<T extends readonly any[], U extends JSX.Element>(pro
|
|
|
30
41
|
*
|
|
31
42
|
* @description https://docs.solidjs.com/reference/components/repeat
|
|
32
43
|
*/
|
|
33
|
-
export declare function Repeat<T extends
|
|
44
|
+
export declare function Repeat<T extends SolidElement>(props: {
|
|
34
45
|
count: number;
|
|
35
46
|
from?: number | undefined;
|
|
36
|
-
fallback?:
|
|
47
|
+
fallback?: SolidElement;
|
|
37
48
|
children: ((index: number) => T) | T;
|
|
38
|
-
}):
|
|
49
|
+
}): SolidElement;
|
|
39
50
|
/**
|
|
40
|
-
* Conditionally
|
|
51
|
+
* Conditionally renders its children when `when` is truthy, otherwise renders
|
|
52
|
+
* the optional `fallback`.
|
|
53
|
+
*
|
|
54
|
+
* The function-child form receives an accessor for the narrowed value — call
|
|
55
|
+
* it to read. Without `keyed` (default), the child is preserved across
|
|
56
|
+
* truthy values; with `keyed`, the child remounts whenever the value's
|
|
57
|
+
* identity changes.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```tsx
|
|
61
|
+
* <Show when={user()} fallback={<SignIn />}>
|
|
62
|
+
* {u => <Greeting name={u().name} />}
|
|
63
|
+
* </Show>
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
41
66
|
* @description https://docs.solidjs.com/reference/components/show
|
|
42
67
|
*/
|
|
43
|
-
export declare function Show<T
|
|
68
|
+
export declare function Show<T, F extends ConditionalRenderCallback<T>>(props: {
|
|
44
69
|
when: T | undefined | null | false;
|
|
45
70
|
keyed?: boolean;
|
|
46
|
-
fallback?:
|
|
47
|
-
children:
|
|
48
|
-
}):
|
|
71
|
+
fallback?: SolidElement;
|
|
72
|
+
children: ConditionalRenderChildren<T, F>;
|
|
73
|
+
}): SolidElement;
|
|
49
74
|
/**
|
|
50
|
-
* Switches between content based on mutually exclusive conditions
|
|
51
|
-
*
|
|
75
|
+
* Switches between content based on mutually exclusive conditions. Renders
|
|
76
|
+
* the first `<Match>` whose `when` is truthy; falls back to `fallback` when
|
|
77
|
+
* none match.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```tsx
|
|
52
81
|
* <Switch fallback={<FourOhFour />}>
|
|
53
82
|
* <Match when={state.route === 'home'}>
|
|
54
83
|
* <Home />
|
|
@@ -58,43 +87,148 @@ export declare function Show<T>(props: {
|
|
|
58
87
|
* </Match>
|
|
59
88
|
* </Switch>
|
|
60
89
|
* ```
|
|
90
|
+
*
|
|
61
91
|
* @description https://docs.solidjs.com/reference/components/switch-and-match
|
|
62
92
|
*/
|
|
63
93
|
export declare function Switch(props: {
|
|
64
|
-
fallback?:
|
|
65
|
-
children:
|
|
66
|
-
}):
|
|
67
|
-
export type MatchProps<T> = {
|
|
94
|
+
fallback?: SolidElement;
|
|
95
|
+
children: SolidElement;
|
|
96
|
+
}): SolidElement;
|
|
97
|
+
export type MatchProps<T, F extends ConditionalRenderCallback<T> = ConditionalRenderCallback<T>> = {
|
|
68
98
|
when: T | undefined | null | false;
|
|
69
99
|
keyed?: boolean;
|
|
70
|
-
children:
|
|
100
|
+
children: ConditionalRenderChildren<T, F>;
|
|
71
101
|
};
|
|
72
102
|
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
103
|
+
* A branch inside a `<Switch>`. The first `<Match>` whose `when` is truthy
|
|
104
|
+
* wins; remaining matches are skipped.
|
|
105
|
+
*
|
|
106
|
+
* Like `<Show>`, `<Match>` supports a function child that receives an
|
|
107
|
+
* accessor for the narrowed value.
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```tsx
|
|
111
|
+
* <Switch fallback={<NotFound />}>
|
|
112
|
+
* <Match when={user()}>
|
|
113
|
+
* {u => <Profile name={u().name} />}
|
|
114
|
+
* </Match>
|
|
115
|
+
* <Match when={loading()}>
|
|
116
|
+
* <Spinner />
|
|
117
|
+
* </Match>
|
|
118
|
+
* </Switch>
|
|
78
119
|
* ```
|
|
120
|
+
*
|
|
79
121
|
* @description https://docs.solidjs.com/reference/components/switch-and-match
|
|
80
122
|
*/
|
|
81
|
-
export declare function Match<T
|
|
123
|
+
export declare function Match<T, F extends ConditionalRenderCallback<T>>(props: MatchProps<T, F>): SolidElement;
|
|
82
124
|
/**
|
|
83
|
-
* Catches uncaught errors inside
|
|
125
|
+
* Catches uncaught errors inside its subtree and renders fallback content
|
|
126
|
+
* instead. The `fallback` prop can be a JSX element, or a callback that
|
|
127
|
+
* receives the error and a `reset()` function for retry affordances.
|
|
84
128
|
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
129
|
+
* Errors thrown from the fallback itself can be caught by a parent
|
|
130
|
+
* `<Errored>`.
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```tsx
|
|
134
|
+
* <Errored fallback={(err, reset) => (
|
|
135
|
+
* <div onClick={reset}>Error: {err.toString()}</div>
|
|
136
|
+
* )}>
|
|
90
137
|
* <MyComp />
|
|
91
138
|
* </Errored>
|
|
92
139
|
* ```
|
|
93
|
-
* Errors thrown from the fallback can be caught by a parent Errored
|
|
94
140
|
*
|
|
95
141
|
* @description https://docs.solidjs.com/reference/components/error-boundary
|
|
96
142
|
*/
|
|
97
143
|
export declare function Errored(props: {
|
|
98
|
-
fallback:
|
|
99
|
-
children:
|
|
100
|
-
}):
|
|
144
|
+
fallback: SolidElement | ((err: any, reset: () => void) => SolidElement);
|
|
145
|
+
children: SolidElement;
|
|
146
|
+
}): SolidElement;
|
|
147
|
+
/**
|
|
148
|
+
* Renders a `fallback` while pending async reads inside the subtree settle.
|
|
149
|
+
*
|
|
150
|
+
* Any computation (`createMemo`, `createSignal(fn)`, `createStore(fn)`,
|
|
151
|
+
* `lazy(...)`, etc.) that throws because data isn't ready is caught by the
|
|
152
|
+
* nearest enclosing `<Loading>`. The boundary swaps to its `fallback` until
|
|
153
|
+
* every pending read has resolved, then renders the children.
|
|
154
|
+
*
|
|
155
|
+
* The optional `on` prop scopes the boundary so it ignores transitions
|
|
156
|
+
* caused by writes to other reactive sources — those transitions stay on the
|
|
157
|
+
* previous content (with `isPending()` flipping during the transition).
|
|
158
|
+
*
|
|
159
|
+
* Scope `<Loading>` around the data-dependent slot, not the surrounding
|
|
160
|
+
* shell. Wrapping layout chrome (header, nav, footer) in the same boundary
|
|
161
|
+
* as the data means revalidation replaces the entire screen with the
|
|
162
|
+
* fallback; rendering chrome outside the boundary keeps it stable while
|
|
163
|
+
* only the affordance flips.
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```tsx
|
|
167
|
+
* const Profile = lazy(() => import("./Profile"));
|
|
168
|
+
*
|
|
169
|
+
* <Loading fallback={<Spinner />}>
|
|
170
|
+
* <Profile />
|
|
171
|
+
* </Loading>
|
|
172
|
+
* ```
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```tsx
|
|
176
|
+
* // Only show the fallback for transitions caused by writes to `route`.
|
|
177
|
+
* <Loading fallback={<Skeleton />} on={route}>
|
|
178
|
+
* <Page />
|
|
179
|
+
* </Loading>
|
|
180
|
+
* ```
|
|
181
|
+
*
|
|
182
|
+
* @description https://docs.solidjs.com/reference/components/suspense
|
|
183
|
+
*/
|
|
184
|
+
export declare function Loading(props: {
|
|
185
|
+
fallback?: SolidElement;
|
|
186
|
+
on?: any;
|
|
187
|
+
children: SolidElement;
|
|
188
|
+
}): SolidElement;
|
|
189
|
+
export type RevealProps = {
|
|
190
|
+
order?: RevealOrder;
|
|
191
|
+
collapsed?: boolean;
|
|
192
|
+
children: SolidElement;
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
195
|
+
* Coordinates the reveal timing of sibling `<Loading>` boundaries.
|
|
196
|
+
*
|
|
197
|
+
* The `order` prop picks the reveal policy:
|
|
198
|
+
* - `"sequential"` (default) — boundaries reveal in registration order; later boundaries
|
|
199
|
+
* stay on their fallback until earlier ones resolve.
|
|
200
|
+
* - `"together"` — every direct slot stays on its fallback until the whole group is
|
|
201
|
+
* "minimally ready" (every direct slot has its own first visible content available),
|
|
202
|
+
* then the group releases in one cohesive reveal.
|
|
203
|
+
* - `"natural"` — each boundary reveals as its own data resolves. At the top level
|
|
204
|
+
* this is equivalent to omitting `<Reveal>`; the mode exists for nesting, where
|
|
205
|
+
* the group registers as a single composite slot in an enclosing `<Reveal>`.
|
|
206
|
+
*
|
|
207
|
+
* The `collapsed` prop is only consulted when `order="sequential"` (the default);
|
|
208
|
+
* it is ignored under `"together"` and `"natural"`. When set, tail boundaries past
|
|
209
|
+
* the frontier suppress their own fallback output.
|
|
210
|
+
*
|
|
211
|
+
* Nested `<Reveal>` groups compose: the inner group is one slot in the outer order
|
|
212
|
+
* and is held on its fallbacks until the outer releases the slot. Once released, the
|
|
213
|
+
* inner group runs its own `order` locally over whatever is still pending. There is
|
|
214
|
+
* no escape hatch — nesting under an outer group means participating in its ordering.
|
|
215
|
+
* See `documentation/solid-2.0/03-control-flow.md` for the full nesting matrix and the
|
|
216
|
+
* "minimally ready" definition per order.
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* ```tsx
|
|
220
|
+
* // Default order is "sequential"; the inner group composes as one slot
|
|
221
|
+
* // and runs its own "natural" order locally once the outer releases it.
|
|
222
|
+
* <Reveal>
|
|
223
|
+
* <Loading fallback={<Skeleton />}><ProfileHeader /></Loading>
|
|
224
|
+
* <Reveal order="natural">
|
|
225
|
+
* <Loading fallback={<Skeleton />}><PostA /></Loading>
|
|
226
|
+
* <Loading fallback={<Skeleton />}><PostB /></Loading>
|
|
227
|
+
* </Reveal>
|
|
228
|
+
* <Loading fallback={<Skeleton />}><Comments /></Loading>
|
|
229
|
+
* </Reveal>
|
|
230
|
+
* ```
|
|
231
|
+
*
|
|
232
|
+
* @description https://docs.solidjs.com/reference/components/reveal
|
|
233
|
+
*/
|
|
234
|
+
export declare function Reveal(props: RevealProps): SolidElement;
|