@tempots/ui 0.9.0 → 0.10.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/index.cjs +1 -0
- package/index.d.ts +16 -0
- package/index.js +1788 -0
- package/package.json +1 -4
- package/renderables/anchor.d.ts +3 -0
- package/renderables/appearance.d.ts +31 -0
- package/renderables/async-result-view.d.ts +9 -0
- package/renderables/autofocus.d.ts +3 -0
- package/renderables/autoselect.d.ts +3 -0
- package/renderables/hidden-when-empty.d.ts +3 -0
- package/renderables/html-title.d.ts +3 -0
- package/renderables/inviewport.d.ts +5 -0
- package/renderables/pop-over.d.ts +13 -0
- package/renderables/result-view.d.ts +7 -0
- package/renderables/router/location.d.ts +15 -0
- package/renderables/router/match.d.ts +14 -0
- package/renderables/router/route-info.d.ts +27 -0
- package/renderables/router/router.d.ts +6 -0
- package/renderables/select-on-focus.d.ts +1 -0
- package/renderables/size.d.ts +6 -0
package/package.json
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tempots/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.cjs",
|
|
6
6
|
"module": "./index.js",
|
|
7
7
|
"types": "./index.d.ts",
|
|
8
8
|
"description": "Provides a higher level of renderables to help fast development with Tempo.",
|
|
9
|
-
"files": [
|
|
10
|
-
"dist"
|
|
11
|
-
],
|
|
12
9
|
"keywords": [
|
|
13
10
|
"tempo",
|
|
14
11
|
"tempots",
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Signal, TNode } from '@tempots/dom';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Defines the possible appearance types for the application.
|
|
5
|
+
* @type AppearanceType
|
|
6
|
+
*/
|
|
7
|
+
export type AppearanceType = 'light' | 'dark';
|
|
8
|
+
/**
|
|
9
|
+
* A provider mark for a signal representing the current appearance type.
|
|
10
|
+
*/
|
|
11
|
+
export declare const appearanceMarker: import('@tempots/dom').ProviderMark<Signal<AppearanceType>>;
|
|
12
|
+
/**
|
|
13
|
+
* Provides a child component with an appearance context, which can be used to
|
|
14
|
+
* determine the current appearance (light or dark) based on the user's system
|
|
15
|
+
* preferences.
|
|
16
|
+
*
|
|
17
|
+
* The appearance context is updated whenever the user's system preferences
|
|
18
|
+
* change, and the component is cleaned up when it is no longer needed.
|
|
19
|
+
*
|
|
20
|
+
* @param child - The child component to be provided with the appearance context.
|
|
21
|
+
* @returns The child component with the appearance context.
|
|
22
|
+
*/
|
|
23
|
+
export declare const ProvideAppearance: (child: TNode) => TNode;
|
|
24
|
+
/**
|
|
25
|
+
* Makes the AppearanceType available to the child component by consuming the signal provided by the parent.
|
|
26
|
+
* The result of the function is returned as the final output.
|
|
27
|
+
*
|
|
28
|
+
* @param fn - A function that accepts the `AppearanceType` signal and returns a `TNode` element.
|
|
29
|
+
* @returns The `TNode` element returned by the provided function.
|
|
30
|
+
*/
|
|
31
|
+
export declare const UseAppearance: (fn: (appearance: Signal<AppearanceType>) => TNode) => TNode;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TNode, Signal, Value } from '@tempots/dom';
|
|
2
|
+
import { AsyncResult } from '@tempots/std/async-result';
|
|
3
|
+
|
|
4
|
+
export declare function AsyncResultView<T, E>(result: Value<AsyncResult<T, E>>, options: {
|
|
5
|
+
success: (value: Signal<T>) => TNode;
|
|
6
|
+
failure?: (error: Signal<E>) => TNode;
|
|
7
|
+
notAsked?: () => TNode;
|
|
8
|
+
loading?: (previousValue: Signal<T | undefined>) => TNode;
|
|
9
|
+
} | ((value: Signal<T>) => TNode)): import('@tempots/dom').Renderable;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Signal, TNode, Renderable } from '@tempots/dom';
|
|
2
|
+
|
|
3
|
+
export type InViewportMode = 'partial' | 'full';
|
|
4
|
+
export declare function InViewport(mode: InViewportMode, fn: (value: Signal<boolean>) => TNode): Renderable;
|
|
5
|
+
export declare const WhenInViewport: (mode: InViewportMode, then: TNode, otherwise?: TNode) => Renderable;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TNode, DOMContext, Value } from '@tempots/dom';
|
|
2
|
+
|
|
3
|
+
export type Placement = 'top' | 'top-start' | 'top-end' | 'right' | 'right-start' | 'right-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end';
|
|
4
|
+
export interface PopOverProps {
|
|
5
|
+
open: Value<boolean>;
|
|
6
|
+
content: () => TNode;
|
|
7
|
+
placement?: Placement;
|
|
8
|
+
offset?: {
|
|
9
|
+
mainAxis?: number;
|
|
10
|
+
crossAxis?: number;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export declare function PopOver({ content, open, placement, offset: { mainAxis, crossAxis }, }: PopOverProps): (ctx: DOMContext) => import('@tempots/dom').Clear;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TNode, Signal, Value } from '@tempots/dom';
|
|
2
|
+
import { Result } from '@tempots/std/result';
|
|
3
|
+
|
|
4
|
+
export declare function ResultView<T, E>(result: Value<Result<T, E>>, options: {
|
|
5
|
+
success: (value: Signal<T>) => TNode;
|
|
6
|
+
failure?: (error: Signal<E>) => TNode;
|
|
7
|
+
} | ((value: Signal<T>) => TNode)): import('@tempots/dom').Renderable;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TNode, Prop } from '@tempots/dom';
|
|
2
|
+
|
|
3
|
+
export interface Location {
|
|
4
|
+
pathname: string;
|
|
5
|
+
search: Record<string, string>;
|
|
6
|
+
hash?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const LocationProviderMarker: import('@tempots/dom').ProviderMark<Prop<Location>>;
|
|
9
|
+
export declare function makeLocation(): Location;
|
|
10
|
+
export declare function equalsLocation(a: Location, b: Location): boolean;
|
|
11
|
+
export declare function locationFromURL(url: string): Location;
|
|
12
|
+
export declare function setLocationFromUrl(prop: Prop<Location>, url: string): Prop<Location>;
|
|
13
|
+
export declare function makeLocationProp(): Prop<Location>;
|
|
14
|
+
export declare function ProvideLocation(child: TNode): import('@tempots/dom').Renderable;
|
|
15
|
+
export declare function UseLocation(fn: (location: Prop<Location>) => TNode): import('@tempots/dom').Renderable;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ExtractParams, Route } from './route-info';
|
|
2
|
+
|
|
3
|
+
export type MatchResult<P extends string> = {
|
|
4
|
+
params: ExtractParams<P>;
|
|
5
|
+
path: P;
|
|
6
|
+
} | null;
|
|
7
|
+
export type MatchResultWithRoute<P extends string, R extends string> = {
|
|
8
|
+
params: ExtractParams<P>;
|
|
9
|
+
route: R;
|
|
10
|
+
path: P;
|
|
11
|
+
} | null;
|
|
12
|
+
export declare function matchesRoute<P extends string>(route: Route, path: P): MatchResult<P>;
|
|
13
|
+
export declare function parseRouteSegments(route: string): Route;
|
|
14
|
+
export declare function makeRouteMatcher<Routes extends string[]>(routes: Routes): <S extends string>(path: S) => MatchResultWithRoute<S, Routes[number]>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { SplitLiteral, TupleToUnion } from '@tempots/std/domain';
|
|
2
|
+
|
|
3
|
+
export interface RouteInfo<P, R = string> {
|
|
4
|
+
params: P;
|
|
5
|
+
route: R;
|
|
6
|
+
path: string;
|
|
7
|
+
search: Record<string, string>;
|
|
8
|
+
hash?: string;
|
|
9
|
+
}
|
|
10
|
+
export type RouteParam = {
|
|
11
|
+
type: 'param';
|
|
12
|
+
name: string;
|
|
13
|
+
};
|
|
14
|
+
export type RouteLiteral = {
|
|
15
|
+
type: 'literal';
|
|
16
|
+
value: string;
|
|
17
|
+
};
|
|
18
|
+
export type RouteCatchAll = {
|
|
19
|
+
type: 'catch-all';
|
|
20
|
+
};
|
|
21
|
+
export type RouteSegment = RouteParam | RouteLiteral | RouteCatchAll;
|
|
22
|
+
export type Route = RouteSegment[];
|
|
23
|
+
export type MakeParams<P> = P extends string[] ? {
|
|
24
|
+
[K in TupleToUnion<P>]: string;
|
|
25
|
+
} : never;
|
|
26
|
+
export type ExtractParamsFromTuple<S extends unknown[]> = S extends [] ? [] : S extends [infer H, ...infer R] ? H extends `:${infer P}` ? [P, ...ExtractParamsFromTuple<R>] : ExtractParamsFromTuple<R> : never;
|
|
27
|
+
export type ExtractParams<S extends string> = SplitLiteral<S, '/'> extends infer T ? T extends unknown[] ? ExtractParamsFromTuple<T> : never : never;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { TNode, Renderable, Signal } from '@tempots/dom';
|
|
2
|
+
import { ExtractParams, MakeParams, RouteInfo } from './route-info';
|
|
3
|
+
|
|
4
|
+
export declare function Router<T extends {
|
|
5
|
+
[K in keyof T]: (info: K extends string ? Signal<RouteInfo<MakeParams<ExtractParams<K>>, K>> : never) => TNode;
|
|
6
|
+
}>(routes: T): Renderable;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function SelectOnFocus(): import('@tempots/dom').Renderable;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DOMContext, Signal, TNode, Size } from '@tempots/dom';
|
|
2
|
+
|
|
3
|
+
export declare const size: {
|
|
4
|
+
element: (fn: (size: Signal<Size>) => TNode) => (ctx: DOMContext) => (removeTree: boolean) => void;
|
|
5
|
+
window: (fn: (size: Signal<Size>) => TNode) => (ctx: DOMContext) => (removeTree: boolean) => void;
|
|
6
|
+
};
|