solid-js 2.0.0-beta.3 → 2.0.0-beta.5

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.
@@ -1,5 +1,8 @@
1
1
  import type { Accessor } from "@solidjs/signals";
2
2
  import type { JSX } from "../jsx.js";
3
+ type NonZeroParams<T extends (...args: any[]) => any> = Parameters<T>["length"] extends 0 ? never : T;
4
+ type ConditionalRenderCallback<T> = (item: Accessor<NonNullable<T>>) => JSX.Element;
5
+ type ConditionalRenderChildren<T, F extends ConditionalRenderCallback<T> = ConditionalRenderCallback<T>> = JSX.Element | NonZeroParams<F>;
3
6
  /**
4
7
  * Creates a list of elements from a list
5
8
  *
@@ -40,11 +43,11 @@ export declare function Repeat<T extends JSX.Element>(props: {
40
43
  * Conditionally render its children or an optional fallback component
41
44
  * @description https://docs.solidjs.com/reference/components/show
42
45
  */
43
- export declare function Show<T>(props: {
46
+ export declare function Show<T, F extends ConditionalRenderCallback<T>>(props: {
44
47
  when: T | undefined | null | false;
45
48
  keyed?: boolean;
46
49
  fallback?: JSX.Element;
47
- children: JSX.Element | ((item: Accessor<NonNullable<T>>) => JSX.Element);
50
+ children: ConditionalRenderChildren<T, F>;
48
51
  }): JSX.Element;
49
52
  /**
50
53
  * Switches between content based on mutually exclusive conditions
@@ -64,10 +67,10 @@ export declare function Switch(props: {
64
67
  fallback?: JSX.Element;
65
68
  children: JSX.Element;
66
69
  }): JSX.Element;
67
- export type MatchProps<T> = {
70
+ export type MatchProps<T, F extends ConditionalRenderCallback<T> = ConditionalRenderCallback<T>> = {
68
71
  when: T | undefined | null | false;
69
72
  keyed?: boolean;
70
- children: JSX.Element | ((item: Accessor<NonNullable<T>>) => JSX.Element);
73
+ children: ConditionalRenderChildren<T, F>;
71
74
  };
72
75
  /**
73
76
  * Selects a content based on condition when inside a `<Switch>` control flow
@@ -78,7 +81,7 @@ export type MatchProps<T> = {
78
81
  * ```
79
82
  * @description https://docs.solidjs.com/reference/components/switch-and-match
80
83
  */
81
- export declare function Match<T>(props: MatchProps<T>): JSX.Element;
84
+ export declare function Match<T, F extends ConditionalRenderCallback<T>>(props: MatchProps<T, F>): JSX.Element;
82
85
  /**
83
86
  * Catches uncaught errors inside components and renders a fallback content
84
87
  *
@@ -98,3 +101,20 @@ export declare function Errored(props: {
98
101
  fallback: JSX.Element | ((err: any, reset: () => void) => JSX.Element);
99
102
  children: JSX.Element;
100
103
  }): JSX.Element;
104
+ /**
105
+ * Tracks all resources inside a component and renders a fallback until they are all resolved
106
+ * ```typescript
107
+ * const AsyncComponent = lazy(() => import('./component'));
108
+ *
109
+ * <Loading fallback={<LoadingIndicator />}>
110
+ * <AsyncComponent />
111
+ * </Loading>
112
+ * ```
113
+ * @description https://docs.solidjs.com/reference/components/suspense
114
+ */
115
+ export declare function Loading(props: {
116
+ fallback?: JSX.Element;
117
+ on?: any;
118
+ children: JSX.Element;
119
+ }): JSX.Element;
120
+ export {};
@@ -1,17 +1,15 @@
1
1
  import { createErrorBoundary as coreErrorBoundary, createMemo as coreMemo, createSignal as coreSignal, createOptimistic as coreOptimistic, createRenderEffect as coreRenderEffect, createEffect as coreEffect, $REFRESH, type ProjectionOptions, type Store, type StoreSetter, type Context } from "@solidjs/signals";
2
2
  import { JSX } from "../jsx.js";
3
+ type HydrationSsrFields = {
4
+ deferStream?: boolean;
5
+ ssrSource?: "server" | "hybrid" | "initial" | "client";
6
+ };
3
7
  declare module "@solidjs/signals" {
4
- interface MemoOptions<T> {
5
- deferStream?: boolean;
6
- ssrSource?: "server" | "hybrid" | "initial" | "client";
8
+ interface MemoOptions<T> extends HydrationSsrFields {
7
9
  }
8
- interface SignalOptions<T> {
9
- deferStream?: boolean;
10
- ssrSource?: "server" | "hybrid" | "initial" | "client";
10
+ interface SignalOptions<T> extends HydrationSsrFields {
11
11
  }
12
- interface EffectOptions {
13
- deferStream?: boolean;
14
- ssrSource?: "server" | "hybrid" | "initial" | "client";
12
+ interface EffectOptions extends HydrationSsrFields {
15
13
  }
16
14
  }
17
15
  export type HydrationProjectionOptions = ProjectionOptions & {
@@ -76,11 +74,9 @@ export declare const createEffect: typeof coreEffect;
76
74
  * ```
77
75
  * @description https://docs.solidjs.com/reference/components/suspense
78
76
  */
79
- export declare function Loading(props: {
80
- fallback?: JSX.Element;
77
+ export declare function createLoadingBoundary(fn: () => any, fallback: () => any, options?: {
81
78
  on?: () => any;
82
- children: JSX.Element;
83
- }): JSX.Element;
79
+ }): () => unknown;
84
80
  /**
85
81
  * Disables hydration for its children on the client.
86
82
  * During hydration, skips the subtree entirely (returns undefined so DOM is left untouched).
package/types/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- export { $PROXY, $REFRESH, $TRACK, action, createErrorBoundary, createLoadingBoundary, createOwner, createReaction, createRoot, createTrackedEffect, deep, flatten, flush, getNextChildId, getObserver, getOwner, isEqual, isRefreshing, isPending, isWrappable, mapArray, merge, omit, onCleanup, onSettled, latest, reconcile, refresh, repeat, resolve, NotReadyError, runWithOwner, enableExternalSource, enforceLoadingBoundary, snapshot, storePath, untrack } from "@solidjs/signals";
1
+ export { $PROXY, $REFRESH, $TRACK, action, createOwner, createReaction, createRoot, createTrackedEffect, deep, flatten, flush, getNextChildId, getObserver, getOwner, isEqual, isRefreshing, isPending, isWrappable, mapArray, merge, omit, onCleanup, onSettled, latest, reconcile, refresh, repeat, resolve, NotReadyError, runWithOwner, enableExternalSource, enforceLoadingBoundary, snapshot, storePath, untrack } from "@solidjs/signals";
2
2
  export type { Accessor, ComputeFunction, EffectFunction, EffectOptions, ExternalSource, ExternalSourceConfig, ExternalSourceFactory, Merge, NoInfer, NotWrappable, Omit, Owner, Signal, SignalOptions, Setter, Store, SolidStore, StoreNode, StoreSetter, StorePathRange, ArrayFilterFn, CustomPartial, Part, PathSetter } from "@solidjs/signals";
3
3
  export { $DEVCOMP, children, createContext, useContext } from "./client/core.js";
4
4
  export type { ChildrenReturn, Context, ContextProviderComponent, ResolvedChildren, ResolvedJSXElement } from "./client/core.js";
5
5
  export * from "./client/component.js";
6
6
  export * from "./client/flow.js";
7
- export { sharedConfig, Loading, enableHydration, createMemo, createSignal, createStore, createProjection, createOptimistic, createOptimisticStore, createRenderEffect, createEffect, NoHydration, Hydration, NoHydrateContext } from "./client/hydration.js";
7
+ export { sharedConfig, enableHydration, createErrorBoundary, createLoadingBoundary, createMemo, createSignal, createStore, createProjection, createOptimistic, createOptimisticStore, createRenderEffect, createEffect, NoHydration, Hydration, NoHydrateContext } from "./client/hydration.js";
8
8
  export declare function ssrHandleError(): void;
9
9
  export declare function ssrRunInScope(): void;
10
10
  import type { JSX } from "./jsx.js";