solid-js 2.0.0-beta.7 → 2.0.0-beta.9
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 +562 -0
- package/README.md +44 -188
- package/dist/dev.cjs +21 -41
- package/dist/dev.js +21 -41
- package/dist/server.cjs +122 -37
- package/dist/server.js +122 -37
- package/dist/solid.cjs +21 -41
- package/dist/solid.js +21 -41
- package/package.json +7 -5
- package/types/client/component.d.ts +50 -0
- package/types/client/core.d.ts +98 -21
- package/types/client/flow.d.ts +97 -24
- package/types/client/hydration.d.ts +409 -22
- package/types/index.d.ts +1 -1
- package/types/jsx-properties.d.ts +2 -5
- package/types/jsx.d.ts +108 -77
- package/types/server/core.d.ts +14 -9
- package/types/server/flow.d.ts +40 -7
- package/types/server/hydration.d.ts +18 -1
- package/types/server/index.d.ts +1 -1
- package/types/server/signals.d.ts +30 -10
- package/types-cjs/client/component.d.cts +50 -0
- package/types-cjs/client/core.d.cts +98 -21
- package/types-cjs/client/flow.d.cts +97 -24
- package/types-cjs/client/hydration.d.cts +409 -22
- package/types-cjs/index.d.cts +1 -1
- package/types-cjs/jsx-properties.d.cts +2 -5
- package/types-cjs/jsx.d.cts +108 -77
- package/types-cjs/server/core.d.cts +14 -9
- package/types-cjs/server/flow.d.cts +40 -7
- package/types-cjs/server/hydration.d.cts +18 -1
- package/types-cjs/server/index.d.cts +1 -1
- package/types-cjs/server/signals.d.cts +30 -10
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { createRoot, createOwner, runWithOwner, getOwner, isDisposed, onCleanup, getNextChildId, createContext, setContext, getContext, NotReadyError, NoOwnerError, ContextNotFoundError, isEqual, isWrappable, SUPPORTS_PROXY, enableExternalSource, enforceLoadingBoundary } from "@solidjs/signals";
|
|
2
2
|
export { flatten } from "@solidjs/signals";
|
|
3
3
|
export { snapshot, merge, omit, storePath, $PROXY, $REFRESH, $TRACK } from "@solidjs/signals";
|
|
4
|
-
export type { Accessor, ComputeFunction, EffectFunction, EffectBundle, EffectOptions, ExternalSource, ExternalSourceConfig, ExternalSourceFactory, MemoOptions, NoInfer, SignalOptions, Setter, Signal, Owner, Maybe, Store, StoreSetter, StoreNode, NotWrappable, SolidStore, Merge, Omit, Context, ContextRecord, IQueue, StorePathRange, ArrayFilterFn, CustomPartial, Part, PathSetter } from "@solidjs/signals";
|
|
4
|
+
export type { Accessor, ComputeFunction, EffectFunction, EffectBundle, EffectOptions, ExternalSource, ExternalSourceConfig, ExternalSourceFactory, MemoOptions, NoInfer, SignalOptions, Setter, Signal, Owner, Refreshable, Maybe, Store, StoreSetter, StoreNode, NotWrappable, SolidStore, Merge, Omit, Context, ContextRecord, IQueue, StorePathRange, ArrayFilterFn, CustomPartial, Part, PathSetter } from "@solidjs/signals";
|
|
5
5
|
import type { Accessor, ComputeFunction, EffectFunction, EffectBundle, EffectOptions, MemoOptions, SignalOptions, Signal, Owner, Store, StoreSetter, Context } from "@solidjs/signals";
|
|
6
6
|
import { sharedConfig, NoHydrateContext } from "./shared.js";
|
|
7
7
|
interface ServerComputation<T = any> {
|
|
@@ -12,27 +12,46 @@ interface ServerComputation<T = any> {
|
|
|
12
12
|
computed: boolean;
|
|
13
13
|
disposed: boolean;
|
|
14
14
|
}
|
|
15
|
+
type SsrSourceMode = "server" | "hybrid" | "client";
|
|
16
|
+
type ServerSsrOptions = {
|
|
17
|
+
deferStream?: boolean;
|
|
18
|
+
ssrSource?: SsrSourceMode;
|
|
19
|
+
};
|
|
20
|
+
type ServerClientMemoOptions<T> = Omit<MemoOptions<T>, "ssrSource"> & {
|
|
21
|
+
ssrSource: "client";
|
|
22
|
+
};
|
|
23
|
+
type ServerMemoOptions<T> = Omit<MemoOptions<T>, "ssrSource"> & {
|
|
24
|
+
ssrSource?: "server" | "hybrid";
|
|
25
|
+
};
|
|
26
|
+
type ServerClientSignalOptions<T> = Omit<SignalOptions<T>, "ssrSource"> & {
|
|
27
|
+
ssrSource: "client";
|
|
28
|
+
};
|
|
29
|
+
type ServerSignalOptions<T> = Omit<SignalOptions<T>, "ssrSource"> & {
|
|
30
|
+
ssrSource?: "server" | "hybrid";
|
|
31
|
+
};
|
|
15
32
|
export declare function getObserver(): ServerComputation<any> | null;
|
|
16
33
|
export declare function createSignal<T>(): Signal<T | undefined>;
|
|
17
34
|
export declare function createSignal<T>(value: Exclude<T, Function>, options?: SignalOptions<T>): Signal<T>;
|
|
18
|
-
export declare function createSignal<T>(fn: ComputeFunction<undefined | NoInfer<T>, T>, options
|
|
19
|
-
export declare function
|
|
35
|
+
export declare function createSignal<T>(fn: ComputeFunction<undefined | NoInfer<T>, T>, options: ServerClientSignalOptions<T>): Signal<T | undefined>;
|
|
36
|
+
export declare function createSignal<T>(fn: ComputeFunction<undefined | NoInfer<T>, T>, options?: ServerSignalOptions<T>): Signal<T>;
|
|
37
|
+
export declare function createMemo<T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, options: ServerClientMemoOptions<T>): Accessor<T | undefined>;
|
|
38
|
+
export declare function createMemo<T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, options?: ServerMemoOptions<T>): Accessor<T>;
|
|
20
39
|
export type PatchOp = [path: PropertyKey[]] | [path: PropertyKey[], value: any] | [path: PropertyKey[], value: any, insert: 1];
|
|
21
40
|
export declare function createDeepProxy<T extends object>(target: T, patches: PatchOp[], basePath?: PropertyKey[]): T;
|
|
22
41
|
export declare function createEffect<T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, effect: EffectFunction<NoInfer<T>, T> | EffectBundle<NoInfer<T>, T>, options?: EffectOptions): void;
|
|
23
42
|
export declare function createRenderEffect<T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, effectFn: EffectFunction<NoInfer<T>, T>, options?: EffectOptions): void;
|
|
24
|
-
export declare function createTrackedEffect(compute: () => void | (() => void), options?:
|
|
43
|
+
export declare function createTrackedEffect(compute: () => void | (() => void), options?: {
|
|
44
|
+
name?: string;
|
|
45
|
+
}): void;
|
|
25
46
|
export declare function createReaction(effectFn: EffectFunction<undefined> | EffectBundle<undefined>, options?: EffectOptions): (tracking: () => void) => void;
|
|
26
47
|
export declare function createOptimistic<T>(): Signal<T | undefined>;
|
|
27
48
|
export declare function createOptimistic<T>(value: Exclude<T, Function>, options?: SignalOptions<T>): Signal<T>;
|
|
28
|
-
export declare function createOptimistic<T>(fn: ComputeFunction<undefined | NoInfer<T>, T>, options
|
|
49
|
+
export declare function createOptimistic<T>(fn: ComputeFunction<undefined | NoInfer<T>, T>, options: ServerClientSignalOptions<T>): Signal<T | undefined>;
|
|
50
|
+
export declare function createOptimistic<T>(fn: ComputeFunction<undefined | NoInfer<T>, T>, options?: ServerSignalOptions<T>): Signal<T>;
|
|
29
51
|
export declare function createStore<T extends object>(store: T | Store<T>): [get: Store<T>, set: StoreSetter<T>];
|
|
30
52
|
export declare function createStore<T extends object>(fn: (store: T) => void | T | Promise<void | T>, store: Partial<T> | Store<T>): [get: Store<T>, set: StoreSetter<T>];
|
|
31
53
|
export declare const createOptimisticStore: typeof createStore;
|
|
32
|
-
export declare function createProjection<T extends object>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, initialValue: Partial<T>, options?:
|
|
33
|
-
deferStream?: boolean;
|
|
34
|
-
ssrSource?: string;
|
|
35
|
-
}): Store<T>;
|
|
54
|
+
export declare function createProjection<T extends object>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, initialValue: Partial<T>, options?: ServerSsrOptions): Store<T>;
|
|
36
55
|
export declare function reconcile<T extends U, U extends object>(value: T): (state: U) => T;
|
|
37
56
|
export declare function deep<T extends object>(store: Store<T>): Store<T>;
|
|
38
57
|
export declare function mapArray<T, U>(list: Accessor<readonly T[] | undefined | null | false>, mapFn: (v: Accessor<T>, i: Accessor<number>) => U, options?: {
|
|
@@ -51,8 +70,9 @@ export declare function createErrorBoundary<U>(fn: () => any, fallback: (error:
|
|
|
51
70
|
export declare function createLoadingBoundary(fn: () => any, fallback: () => any, options?: {
|
|
52
71
|
on?: () => any;
|
|
53
72
|
}): () => unknown;
|
|
73
|
+
export type RevealOrder = "sequential" | "together" | "natural";
|
|
54
74
|
export declare function createRevealOrder<T>(fn: () => T, _options?: {
|
|
55
|
-
|
|
75
|
+
order?: () => RevealOrder;
|
|
56
76
|
collapsed?: () => boolean;
|
|
57
77
|
}): T;
|
|
58
78
|
export declare function untrack<T>(fn: () => T): T;
|
|
@@ -63,7 +63,39 @@ export type ComponentProps<T extends ValidComponent> = T extends Component<infer
|
|
|
63
63
|
* @example Component<{ref: Ref<Element>}>
|
|
64
64
|
*/
|
|
65
65
|
export type Ref<T> = T | ((val: T) => void);
|
|
66
|
+
/**
|
|
67
|
+
* Invokes a component, wrapping the call in `untrack` so that reactive reads
|
|
68
|
+
* inside the component body don't subscribe the parent computation. Compiled
|
|
69
|
+
* JSX uses this internally; manual calls are rarely needed unless authoring a
|
|
70
|
+
* custom JSX factory or renderer.
|
|
71
|
+
*/
|
|
66
72
|
export declare function createComponent<T extends Record<string, any>>(Comp: Component<T>, props: T): JSX.Element;
|
|
73
|
+
/**
|
|
74
|
+
* Defines a code-split component. The returned component triggers its dynamic
|
|
75
|
+
* import on first render and suspends through any enclosing `<Loading>`
|
|
76
|
+
* boundary while the chunk is in flight. Call `.preload()` to start the
|
|
77
|
+
* import early (e.g. on hover).
|
|
78
|
+
*
|
|
79
|
+
* @param fn dynamic import returning the module's default export
|
|
80
|
+
* @param moduleUrl optional module URL used during hydration to look up
|
|
81
|
+
* preloaded chunks; usually injected by the bundler integration
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```tsx
|
|
85
|
+
* const Profile = lazy(() => import("./Profile"));
|
|
86
|
+
*
|
|
87
|
+
* function App() {
|
|
88
|
+
* return (
|
|
89
|
+
* <Loading fallback={<Spinner />}>
|
|
90
|
+
* <Profile id="42" />
|
|
91
|
+
* </Loading>
|
|
92
|
+
* );
|
|
93
|
+
* }
|
|
94
|
+
*
|
|
95
|
+
* // Preload before the user clicks
|
|
96
|
+
* <button onMouseEnter={() => Profile.preload()}>Open profile</button>
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
67
99
|
export declare function lazy<T extends Component<any>>(fn: () => Promise<{
|
|
68
100
|
default: T;
|
|
69
101
|
}>, moduleUrl?: string): T & {
|
|
@@ -72,4 +104,22 @@ export declare function lazy<T extends Component<any>>(fn: () => Promise<{
|
|
|
72
104
|
}>;
|
|
73
105
|
moduleUrl?: string;
|
|
74
106
|
};
|
|
107
|
+
/**
|
|
108
|
+
* Returns a stable id string that matches between server-rendered and
|
|
109
|
+
* client-hydrated trees. Use it for `<label for>`, `aria-labelledby`, and
|
|
110
|
+
* other attributes that need consistent ids across SSR.
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```tsx
|
|
114
|
+
* function Field(props: { label: string }) {
|
|
115
|
+
* const id = createUniqueId();
|
|
116
|
+
* return (
|
|
117
|
+
* <>
|
|
118
|
+
* <label for={id}>{props.label}</label>
|
|
119
|
+
* <input id={id} />
|
|
120
|
+
* </>
|
|
121
|
+
* );
|
|
122
|
+
* }
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
75
125
|
export declare function createUniqueId(): string;
|
|
@@ -9,34 +9,101 @@ export type ContextProviderComponent<T> = FlowComponent<{
|
|
|
9
9
|
}>;
|
|
10
10
|
export interface Context<T> extends ContextProviderComponent<T> {
|
|
11
11
|
id: symbol;
|
|
12
|
-
defaultValue: T;
|
|
12
|
+
defaultValue: T | undefined;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
* Creates a Context
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
15
|
+
* Creates a Context for sharing state with descendants of a Provider in the
|
|
16
|
+
* component tree.
|
|
17
|
+
*
|
|
18
|
+
* The returned `Context` is itself a provider component — pass it a `value`
|
|
19
|
+
* prop to scope a value to its children. Read it inside descendants with
|
|
20
|
+
* `useContext`.
|
|
21
|
+
*
|
|
22
|
+
* Two forms:
|
|
23
|
+
*
|
|
24
|
+
* - **`createContext<T>()`** (default-less, the canonical form). Reading via
|
|
25
|
+
* `useContext` outside an enclosing Provider throws `ContextNotFoundError`.
|
|
26
|
+
* Use this for everything that carries reactive state — signals, stores,
|
|
27
|
+
* `[state, actions]` tuples, services. The Provider is mandatory by
|
|
28
|
+
* construction; the throw makes a missing Provider a loud bug instead of a
|
|
29
|
+
* silent no-op. The annotation `<T>` is required because there is no value
|
|
30
|
+
* to infer from.
|
|
31
|
+
* - **`createContext<T>(defaultValue)`** (default form). Reserved for the
|
|
32
|
+
* narrow case of contexts whose value is a primitive with a meaningful
|
|
33
|
+
* static fallback (theme, locale, frozen config). Outside any Provider,
|
|
34
|
+
* `useContext` returns `defaultValue`.
|
|
35
|
+
*
|
|
36
|
+
* If you want truly app-wide state, **don't use Context** — a module-scope
|
|
37
|
+
* signal/store *is* a global. Context is for scoping state to a subtree;
|
|
38
|
+
* that's why a Provider is required.
|
|
39
|
+
*
|
|
40
|
+
* @param defaultValue optional default; only meaningful for primitive
|
|
41
|
+
* fallbacks. Omit for any context carrying reactive state.
|
|
42
|
+
* @param options `{ name }` for debugging in development
|
|
43
|
+
* @returns a context object that doubles as its own provider component
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```tsx
|
|
47
|
+
* // Reactive payload — default-less, throws if no Provider.
|
|
48
|
+
* type TodosCtx = readonly [Store<Todo[]>, TodoActions];
|
|
49
|
+
* const TodosContext = createContext<TodosCtx>();
|
|
50
|
+
*
|
|
51
|
+
* function App() {
|
|
52
|
+
* return (
|
|
53
|
+
* <TodosContext value={createTodos()}>
|
|
54
|
+
* <TodoList />
|
|
55
|
+
* </TodosContext>
|
|
56
|
+
* );
|
|
57
|
+
* }
|
|
58
|
+
*
|
|
59
|
+
* function TodoList() {
|
|
60
|
+
* const [todos, { addTodo }] = useContext(TodosContext); // typed as TodosCtx
|
|
61
|
+
* // ...
|
|
62
|
+
* }
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```tsx
|
|
67
|
+
* // Primitive default — falls back to "light" outside a Provider.
|
|
68
|
+
* const ThemeContext = createContext<"light" | "dark">("light");
|
|
69
|
+
*
|
|
70
|
+
* function Button() {
|
|
71
|
+
* const theme = useContext(ThemeContext); // "light" | "dark"
|
|
72
|
+
* return <button class={theme}>Click</button>;
|
|
21
73
|
* }
|
|
22
|
-
* export function createContext<T>(
|
|
23
|
-
* defaultValue?: T,
|
|
24
|
-
* options?: { name?: string }
|
|
25
|
-
* ): Context<T | undefined>;
|
|
26
74
|
* ```
|
|
27
|
-
* @param defaultValue optional default to inject into context
|
|
28
|
-
* @param options allows to set a name in dev mode for debugging purposes
|
|
29
|
-
* @returns The context that contains the Provider Component and that can be used with `useContext`
|
|
30
75
|
*
|
|
31
76
|
* @description https://docs.solidjs.com/reference/component-apis/create-context
|
|
32
77
|
*/
|
|
33
|
-
export declare function createContext<T>(defaultValue?:
|
|
34
|
-
export declare function createContext<T>(defaultValue: T, options?: EffectOptions): Context<T>;
|
|
78
|
+
export declare function createContext<T>(defaultValue?: T, options?: EffectOptions): Context<T>;
|
|
35
79
|
/**
|
|
36
|
-
*
|
|
80
|
+
* Reads the current value of a context.
|
|
81
|
+
*
|
|
82
|
+
* - For `createContext<T>()` (default-less): returns the value from the
|
|
83
|
+
* nearest enclosing Provider, or throws `ContextNotFoundError` if none is
|
|
84
|
+
* mounted. Return type is `T` (no narrowing required).
|
|
85
|
+
* - For `createContext<T>(defaultValue)`: returns the value from the nearest
|
|
86
|
+
* enclosing Provider, or `defaultValue` if none is mounted.
|
|
37
87
|
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
88
|
+
* In Solid, `useContext` is the canonical way to read context. There is no
|
|
89
|
+
* need for a wrapper hook that throws on missing Provider — the default-less
|
|
90
|
+
* form already does that, and its return type is `T`.
|
|
91
|
+
*
|
|
92
|
+
* @param context a context returned from `createContext`
|
|
93
|
+
* @returns the value provided by the nearest enclosing Provider, or the
|
|
94
|
+
* default if one was supplied to `createContext`
|
|
95
|
+
* @throws `ContextNotFoundError` if no Provider is mounted and the context
|
|
96
|
+
* was created without a default
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```tsx
|
|
100
|
+
* const TodosContext = createContext<TodosCtx>();
|
|
101
|
+
*
|
|
102
|
+
* function TodoList() {
|
|
103
|
+
* const [todos, { addTodo }] = useContext(TodosContext); // throws if no Provider
|
|
104
|
+
* // ...
|
|
105
|
+
* }
|
|
106
|
+
* ```
|
|
40
107
|
*
|
|
41
108
|
* @description https://docs.solidjs.com/reference/component-apis/use-context
|
|
42
109
|
*/
|
|
@@ -47,10 +114,20 @@ export type ChildrenReturn = Accessor<ResolvedChildren> & {
|
|
|
47
114
|
toArray: () => ResolvedJSXElement[];
|
|
48
115
|
};
|
|
49
116
|
/**
|
|
50
|
-
* Resolves
|
|
117
|
+
* Resolves a `children` accessor and exposes the result as an accessor with
|
|
118
|
+
* a `.toArray()` helper. Use this when a component needs to inspect or
|
|
119
|
+
* iterate over its children rather than just render them through.
|
|
51
120
|
*
|
|
52
121
|
* @param fn an accessor for the children
|
|
53
|
-
* @returns
|
|
122
|
+
* @returns an accessor of the resolved children, with `.toArray()` for iteration
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```tsx
|
|
126
|
+
* function List(props: { children: JSX.Element }) {
|
|
127
|
+
* const items = children(() => props.children);
|
|
128
|
+
* return <ul>{items.toArray().map(item => <li>{item}</li>)}</ul>;
|
|
129
|
+
* }
|
|
130
|
+
* ```
|
|
54
131
|
*
|
|
55
132
|
* @description https://docs.solidjs.com/reference/component-apis/children
|
|
56
133
|
*/
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { Accessor } from "@solidjs/signals";
|
|
1
|
+
import type { Accessor, RevealOrder } from "@solidjs/signals";
|
|
2
|
+
export type { RevealOrder };
|
|
2
3
|
import type { JSX } from "../jsx.cjs";
|
|
3
4
|
type NonZeroParams<T extends (...args: any[]) => any> = Parameters<T>["length"] extends 0 ? never : T;
|
|
4
5
|
type ConditionalRenderCallback<T> = (item: Accessor<NonNullable<T>>) => JSX.Element;
|
|
@@ -40,7 +41,21 @@ export declare function Repeat<T extends JSX.Element>(props: {
|
|
|
40
41
|
children: ((index: number) => T) | T;
|
|
41
42
|
}): JSX.Element;
|
|
42
43
|
/**
|
|
43
|
-
* Conditionally
|
|
44
|
+
* Conditionally renders its children when `when` is truthy, otherwise renders
|
|
45
|
+
* the optional `fallback`.
|
|
46
|
+
*
|
|
47
|
+
* The function-child form receives an accessor for the narrowed value — call
|
|
48
|
+
* it to read. Without `keyed` (default), the child is preserved across
|
|
49
|
+
* truthy values; with `keyed`, the child remounts whenever the value's
|
|
50
|
+
* identity changes.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```tsx
|
|
54
|
+
* <Show when={user()} fallback={<SignIn />}>
|
|
55
|
+
* {u => <Greeting name={u().name} />}
|
|
56
|
+
* </Show>
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
44
59
|
* @description https://docs.solidjs.com/reference/components/show
|
|
45
60
|
*/
|
|
46
61
|
export declare function Show<T, F extends ConditionalRenderCallback<T>>(props: {
|
|
@@ -73,12 +88,24 @@ export type MatchProps<T, F extends ConditionalRenderCallback<T> = ConditionalRe
|
|
|
73
88
|
children: ConditionalRenderChildren<T, F>;
|
|
74
89
|
};
|
|
75
90
|
/**
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
91
|
+
* A branch inside a `<Switch>`. The first `<Match>` whose `when` is truthy
|
|
92
|
+
* wins; remaining matches are skipped.
|
|
93
|
+
*
|
|
94
|
+
* Like `<Show>`, `<Match>` supports a function child that receives an
|
|
95
|
+
* accessor for the narrowed value.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```tsx
|
|
99
|
+
* <Switch fallback={<NotFound />}>
|
|
100
|
+
* <Match when={user()}>
|
|
101
|
+
* {u => <Profile name={u().name} />}
|
|
102
|
+
* </Match>
|
|
103
|
+
* <Match when={loading()}>
|
|
104
|
+
* <Spinner />
|
|
105
|
+
* </Match>
|
|
106
|
+
* </Switch>
|
|
81
107
|
* ```
|
|
108
|
+
*
|
|
82
109
|
* @description https://docs.solidjs.com/reference/components/switch-and-match
|
|
83
110
|
*/
|
|
84
111
|
export declare function Match<T, F extends ConditionalRenderCallback<T>>(props: MatchProps<T, F>): JSX.Element;
|
|
@@ -102,14 +129,40 @@ export declare function Errored(props: {
|
|
|
102
129
|
children: JSX.Element;
|
|
103
130
|
}): JSX.Element;
|
|
104
131
|
/**
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
132
|
+
* Renders a `fallback` while pending async reads inside the subtree settle.
|
|
133
|
+
*
|
|
134
|
+
* Any computation (`createMemo`, `createSignal(fn)`, `createStore(fn)`,
|
|
135
|
+
* `lazy(...)`, etc.) that throws because data isn't ready is caught by the
|
|
136
|
+
* nearest enclosing `<Loading>`. The boundary swaps to its `fallback` until
|
|
137
|
+
* every pending read has resolved, then renders the children.
|
|
138
|
+
*
|
|
139
|
+
* The optional `on` prop scopes the boundary so it ignores transitions
|
|
140
|
+
* caused by writes to other reactive sources — those transitions stay on the
|
|
141
|
+
* previous content (with `isPending()` flipping during the transition).
|
|
108
142
|
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
143
|
+
* Scope `<Loading>` around the data-dependent slot, not the surrounding
|
|
144
|
+
* shell. Wrapping layout chrome (header, nav, footer) in the same boundary
|
|
145
|
+
* as the data means revalidation replaces the entire screen with the
|
|
146
|
+
* fallback; rendering chrome outside the boundary keeps it stable while
|
|
147
|
+
* only the affordance flips.
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```tsx
|
|
151
|
+
* const Profile = lazy(() => import("./Profile"));
|
|
152
|
+
*
|
|
153
|
+
* <Loading fallback={<Spinner />}>
|
|
154
|
+
* <Profile />
|
|
111
155
|
* </Loading>
|
|
112
156
|
* ```
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```tsx
|
|
160
|
+
* // Only show the fallback for transitions caused by writes to `route`.
|
|
161
|
+
* <Loading fallback={<Skeleton />} on={route}>
|
|
162
|
+
* <Page />
|
|
163
|
+
* </Loading>
|
|
164
|
+
* ```
|
|
165
|
+
*
|
|
113
166
|
* @description https://docs.solidjs.com/reference/components/suspense
|
|
114
167
|
*/
|
|
115
168
|
export declare function Loading(props: {
|
|
@@ -117,26 +170,46 @@ export declare function Loading(props: {
|
|
|
117
170
|
on?: any;
|
|
118
171
|
children: JSX.Element;
|
|
119
172
|
}): JSX.Element;
|
|
173
|
+
export type RevealProps = {
|
|
174
|
+
order?: RevealOrder;
|
|
175
|
+
collapsed?: boolean;
|
|
176
|
+
children: JSX.Element;
|
|
177
|
+
};
|
|
120
178
|
/**
|
|
121
179
|
* Coordinates the reveal timing of sibling `<Loading>` boundaries.
|
|
122
180
|
*
|
|
123
|
-
*
|
|
124
|
-
* -
|
|
125
|
-
*
|
|
126
|
-
*
|
|
181
|
+
* The `order` prop picks the reveal policy:
|
|
182
|
+
* - `"sequential"` (default) — boundaries reveal in registration order; later boundaries
|
|
183
|
+
* stay on their fallback until earlier ones resolve.
|
|
184
|
+
* - `"together"` — every direct slot stays on its fallback until the whole group is
|
|
185
|
+
* "minimally ready" (every direct slot has its own first visible content available),
|
|
186
|
+
* then the group releases in one cohesive reveal.
|
|
187
|
+
* - `"natural"` — each boundary reveals as its own data resolves. At the top level
|
|
188
|
+
* this is equivalent to omitting `<Reveal>`; the mode exists for nesting, where
|
|
189
|
+
* the group registers as a single composite slot in an enclosing `<Reveal>`.
|
|
190
|
+
*
|
|
191
|
+
* The `collapsed` prop is only consulted when `order="sequential"` (the default);
|
|
192
|
+
* it is ignored under `"together"` and `"natural"`. When set, tail boundaries past
|
|
193
|
+
* the frontier suppress their own fallback output.
|
|
194
|
+
*
|
|
195
|
+
* Nested `<Reveal>` groups compose: the inner group is one slot in the outer order
|
|
196
|
+
* and is held on its fallbacks until the outer releases the slot. Once released, the
|
|
197
|
+
* inner group runs its own `order` locally over whatever is still pending. There is
|
|
198
|
+
* no escape hatch — nesting under an outer group means participating in its ordering.
|
|
199
|
+
* See `documentation/solid-2.0/03-control-flow.md` for the full nesting matrix and the
|
|
200
|
+
* "minimally ready" definition per order.
|
|
127
201
|
*
|
|
128
202
|
* ```typescript
|
|
129
|
-
* <Reveal>
|
|
203
|
+
* <Reveal order="sequential">
|
|
130
204
|
* <Loading fallback={<Skeleton />}><ProfileHeader /></Loading>
|
|
131
|
-
* <
|
|
205
|
+
* <Reveal order="natural">
|
|
206
|
+
* <Loading fallback={<Skeleton />}><PostA /></Loading>
|
|
207
|
+
* <Loading fallback={<Skeleton />}><PostB /></Loading>
|
|
208
|
+
* </Reveal>
|
|
209
|
+
* <Loading fallback={<Skeleton />}><Comments /></Loading>
|
|
132
210
|
* </Reveal>
|
|
133
211
|
* ```
|
|
134
212
|
*
|
|
135
213
|
* @description https://docs.solidjs.com/reference/components/reveal
|
|
136
214
|
*/
|
|
137
|
-
export declare function Reveal(props:
|
|
138
|
-
together?: boolean;
|
|
139
|
-
collapsed?: boolean;
|
|
140
|
-
children: JSX.Element;
|
|
141
|
-
}): JSX.Element;
|
|
142
|
-
export {};
|
|
215
|
+
export declare function Reveal(props: RevealProps): JSX.Element;
|