@opentui/solid 0.1.22 → 0.1.24
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/dist/index.d.ts +132 -0
- package/index.d.ts +8 -0
- package/index.js +637 -300
- package/jsx-runtime.d.ts +14 -2
- package/package.json +8 -7
- package/scripts/solid-plugin.ts +6 -0
- package/src/elements/extras.d.ts +41 -0
- package/src/elements/index.d.ts +32 -1
- package/src/elements/slot.d.ts +37 -0
- package/src/reconciler.d.ts +5 -4
- package/src/renderer/index.d.ts +3 -0
- package/src/renderer/universal.d.ts +29 -0
- package/src/types/elements.d.ts +12 -6
- package/src/elements/text-node.d.ts +0 -48
package/jsx-runtime.d.ts
CHANGED
|
@@ -5,24 +5,36 @@ import type {
|
|
|
5
5
|
ExtendedIntrinsicElements,
|
|
6
6
|
InputProps,
|
|
7
7
|
OpenTUIComponents,
|
|
8
|
+
ScrollBoxProps,
|
|
8
9
|
SelectProps,
|
|
10
|
+
SpanProps,
|
|
9
11
|
TabSelectProps,
|
|
10
12
|
TextProps,
|
|
11
13
|
} from "./src/types/elements"
|
|
14
|
+
import type { DomNode } from "./dist"
|
|
12
15
|
|
|
13
16
|
declare namespace JSX {
|
|
14
17
|
// Replace Node with Renderable
|
|
15
|
-
type Element =
|
|
18
|
+
type Element = DomNode | ArrayElement | string | number | boolean | null | undefined
|
|
16
19
|
|
|
17
|
-
|
|
20
|
+
type ArrayElement = Array<Element>
|
|
18
21
|
|
|
19
22
|
interface IntrinsicElements extends ExtendedIntrinsicElements<OpenTUIComponents> {
|
|
20
23
|
box: BoxProps
|
|
21
24
|
text: TextProps
|
|
25
|
+
span: SpanProps
|
|
22
26
|
input: InputProps
|
|
23
27
|
select: SelectProps
|
|
24
28
|
ascii_font: AsciiFontProps
|
|
25
29
|
tab_select: TabSelectProps
|
|
30
|
+
scrollbox: ScrollBoxProps
|
|
31
|
+
|
|
32
|
+
b: SpanProps
|
|
33
|
+
strong: SpanProps
|
|
34
|
+
i: SpanProps
|
|
35
|
+
em: SpanProps
|
|
36
|
+
u: SpanProps
|
|
37
|
+
br: {}
|
|
26
38
|
}
|
|
27
39
|
|
|
28
40
|
interface ElementChildrenAttribute {
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"version": "0.1.
|
|
7
|
+
"version": "0.1.24",
|
|
8
8
|
"description": "SolidJS renderer for OpenTUI",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
@@ -25,18 +25,19 @@
|
|
|
25
25
|
"./jsx-dev-runtime": "./jsx-runtime.d.ts"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@opentui/core": "0.1.22",
|
|
29
|
-
"babel-plugin-module-resolver": "5.0.2",
|
|
30
28
|
"@babel/core": "7.28.0",
|
|
31
29
|
"@babel/preset-typescript": "7.27.1",
|
|
32
|
-
"
|
|
30
|
+
"@opentui/core": "0.1.24",
|
|
31
|
+
"babel-plugin-module-resolver": "5.0.2",
|
|
32
|
+
"babel-preset-solid": "1.9.9",
|
|
33
|
+
"s-js": "^0.4.9"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
36
|
"@types/babel__core": "7.20.5",
|
|
36
|
-
"@types/bun": "latest"
|
|
37
|
+
"@types/bun": "latest",
|
|
38
|
+
"typescript": "^5"
|
|
37
39
|
},
|
|
38
40
|
"peerDependencies": {
|
|
39
|
-
"solid-js": "1.9.9"
|
|
40
|
-
"typescript": "^5"
|
|
41
|
+
"solid-js": "1.9.9"
|
|
41
42
|
}
|
|
42
43
|
}
|
package/scripts/solid-plugin.ts
CHANGED
|
@@ -14,6 +14,12 @@ const solidTransformPlugin: BunPlugin = {
|
|
|
14
14
|
const code = await file.text()
|
|
15
15
|
return { contents: code, loader: "js" }
|
|
16
16
|
})
|
|
17
|
+
build.onLoad({ filter: /\/node_modules\/solid-js\/store\/dist\/server\.js$/ }, async (args) => {
|
|
18
|
+
const path = args.path.replace("server.js", "store.js")
|
|
19
|
+
const file = Bun.file(path)
|
|
20
|
+
const code = await file.text()
|
|
21
|
+
return { contents: code, loader: "js" }
|
|
22
|
+
})
|
|
17
23
|
build.onLoad({ filter: /\.(js|ts)x$/ }, async (args) => {
|
|
18
24
|
const file = Bun.file(args.path)
|
|
19
25
|
const code = await file.text()
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type DomNode } from "../reconciler";
|
|
2
|
+
import type { JSX } from "../../jsx-runtime";
|
|
3
|
+
import type { ValidComponent, ComponentProps } from "solid-js";
|
|
4
|
+
/**
|
|
5
|
+
* Renders components somewhere else in the DOM
|
|
6
|
+
*
|
|
7
|
+
* Useful for inserting modals and tooltips outside of an cropping layout. If no mount point is given, the portal is inserted on the root renderable; it is wrapped in a `<box>`
|
|
8
|
+
*
|
|
9
|
+
* @description https://docs.solidjs.com/reference/components/portal
|
|
10
|
+
*/
|
|
11
|
+
export declare function Portal(props: {
|
|
12
|
+
mount?: DomNode;
|
|
13
|
+
ref?: (el: {}) => void;
|
|
14
|
+
children: JSX.Element;
|
|
15
|
+
}): DomNode;
|
|
16
|
+
export type DynamicProps<T extends ValidComponent, P = ComponentProps<T>> = {
|
|
17
|
+
[K in keyof P]: P[K];
|
|
18
|
+
} & {
|
|
19
|
+
component: T | undefined;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Renders an arbitrary component or element with the given props
|
|
23
|
+
*
|
|
24
|
+
* This is a lower level version of the `Dynamic` component, useful for
|
|
25
|
+
* performance optimizations in libraries. Do not use this unless you know
|
|
26
|
+
* what you are doing.
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const element = () => multiline() ? 'textarea' : 'input';
|
|
29
|
+
* createDynamic(element, { value: value() });
|
|
30
|
+
* ```
|
|
31
|
+
* @description https://docs.solidjs.com/reference/components/dynamic
|
|
32
|
+
*/
|
|
33
|
+
export declare function createDynamic<T extends ValidComponent>(component: () => T | undefined, props: ComponentProps<T>): JSX.Element;
|
|
34
|
+
/**
|
|
35
|
+
* Renders an arbitrary custom or native component and passes the other props
|
|
36
|
+
* ```typescript
|
|
37
|
+
* <Dynamic component={multiline() ? 'textarea' : 'input'} value={value()} />
|
|
38
|
+
* ```
|
|
39
|
+
* @description https://docs.solidjs.com/reference/components/dynamic
|
|
40
|
+
*/
|
|
41
|
+
export declare function Dynamic<T extends ValidComponent>(props: DynamicProps<T>): JSX.Element;
|
package/src/elements/index.d.ts
CHANGED
|
@@ -1,6 +1,30 @@
|
|
|
1
|
-
import { ASCIIFontRenderable, BoxRenderable, InputRenderable, ScrollBoxRenderable, SelectRenderable, TabSelectRenderable, TextRenderable } from "@opentui/core";
|
|
1
|
+
import { ASCIIFontRenderable, BoxRenderable, InputRenderable, ScrollBoxRenderable, SelectRenderable, TabSelectRenderable, TextNodeRenderable, TextRenderable, type RenderContext, type TextNodeOptions } from "@opentui/core";
|
|
2
2
|
import type { RenderableConstructor } from "../types/elements";
|
|
3
3
|
export * from "./hooks";
|
|
4
|
+
export * from "./extras";
|
|
5
|
+
export * from "./slot";
|
|
6
|
+
declare class SpanRenderable extends TextNodeRenderable {
|
|
7
|
+
private readonly _ctx;
|
|
8
|
+
constructor(_ctx: RenderContext | null, options: TextNodeOptions);
|
|
9
|
+
}
|
|
10
|
+
export declare const textNodeKeys: readonly ["span", "b", "strong", "i", "em", "u"];
|
|
11
|
+
export type TextNodeKey = (typeof textNodeKeys)[number];
|
|
12
|
+
declare class TextModifierRenderable extends SpanRenderable {
|
|
13
|
+
constructor(options: any, modifier?: TextNodeKey);
|
|
14
|
+
}
|
|
15
|
+
export declare class BoldSpanRenderable extends TextModifierRenderable {
|
|
16
|
+
constructor(options: any);
|
|
17
|
+
}
|
|
18
|
+
export declare class ItalicSpanRenderable extends TextModifierRenderable {
|
|
19
|
+
constructor(options: any);
|
|
20
|
+
}
|
|
21
|
+
export declare class UnderlineSpanRenderable extends TextModifierRenderable {
|
|
22
|
+
constructor(options: any);
|
|
23
|
+
}
|
|
24
|
+
export declare class LineBreakRenderable extends SpanRenderable {
|
|
25
|
+
constructor(_ctx: RenderContext | null, options: TextNodeOptions);
|
|
26
|
+
add(): number;
|
|
27
|
+
}
|
|
4
28
|
export declare const baseComponents: {
|
|
5
29
|
box: typeof BoxRenderable;
|
|
6
30
|
text: typeof TextRenderable;
|
|
@@ -9,6 +33,13 @@ export declare const baseComponents: {
|
|
|
9
33
|
ascii_font: typeof ASCIIFontRenderable;
|
|
10
34
|
tab_select: typeof TabSelectRenderable;
|
|
11
35
|
scrollbox: typeof ScrollBoxRenderable;
|
|
36
|
+
span: typeof SpanRenderable;
|
|
37
|
+
strong: typeof BoldSpanRenderable;
|
|
38
|
+
b: typeof BoldSpanRenderable;
|
|
39
|
+
em: typeof ItalicSpanRenderable;
|
|
40
|
+
i: typeof ItalicSpanRenderable;
|
|
41
|
+
u: typeof UnderlineSpanRenderable;
|
|
42
|
+
br: typeof LineBreakRenderable;
|
|
12
43
|
};
|
|
13
44
|
type ComponentCatalogue = Record<string, RenderableConstructor>;
|
|
14
45
|
export declare const componentCatalogue: ComponentCatalogue;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { BaseRenderable, TextNodeRenderable, Yoga } from "@opentui/core";
|
|
2
|
+
declare class SlotBaseRenderable extends BaseRenderable {
|
|
3
|
+
constructor(id: string);
|
|
4
|
+
add(obj: BaseRenderable | unknown, index?: number): number;
|
|
5
|
+
getChildren(): BaseRenderable[];
|
|
6
|
+
remove(id: string): void;
|
|
7
|
+
insertBefore(obj: BaseRenderable | unknown, anchor: BaseRenderable | unknown): void;
|
|
8
|
+
getRenderable(id: string): BaseRenderable | undefined;
|
|
9
|
+
getChildrenCount(): number;
|
|
10
|
+
requestRender(): void;
|
|
11
|
+
}
|
|
12
|
+
export declare class TextSlotRenderable extends TextNodeRenderable {
|
|
13
|
+
protected slotParent?: SlotRenderable;
|
|
14
|
+
protected destroyed: boolean;
|
|
15
|
+
constructor(id: string, parent?: SlotRenderable);
|
|
16
|
+
destroy(): void;
|
|
17
|
+
}
|
|
18
|
+
export declare class LayoutSlotRenderable extends SlotBaseRenderable {
|
|
19
|
+
protected yogaNode: Yoga.Node;
|
|
20
|
+
protected slotParent?: SlotRenderable;
|
|
21
|
+
protected destroyed: boolean;
|
|
22
|
+
constructor(id: string, parent?: SlotRenderable);
|
|
23
|
+
getLayoutNode(): Yoga.Node;
|
|
24
|
+
updateFromLayout(): void;
|
|
25
|
+
updateLayout(): void;
|
|
26
|
+
onRemove(): void;
|
|
27
|
+
destroy(): void;
|
|
28
|
+
}
|
|
29
|
+
export declare class SlotRenderable extends SlotBaseRenderable {
|
|
30
|
+
layoutNode?: LayoutSlotRenderable;
|
|
31
|
+
textNode?: TextSlotRenderable;
|
|
32
|
+
protected destroyed: boolean;
|
|
33
|
+
constructor(id: string);
|
|
34
|
+
getSlotChild(parent: BaseRenderable): TextSlotRenderable | LayoutSlotRenderable;
|
|
35
|
+
destroy(): void;
|
|
36
|
+
}
|
|
37
|
+
export {};
|
package/src/reconciler.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export type DomNode =
|
|
4
|
-
export declare
|
|
1
|
+
import { BaseRenderable } from "@opentui/core";
|
|
2
|
+
import { SlotRenderable } from "./elements";
|
|
3
|
+
export type DomNode = BaseRenderable;
|
|
4
|
+
export declare function createSlotNode(): SlotRenderable;
|
|
5
|
+
export declare const _render: (code: () => BaseRenderable, node: BaseRenderable) => () => void, effect: <T>(fn: (prev?: T) => T, init?: T) => void, memo: <T>(fn: () => T, equal: boolean) => () => T, createComponent: <T>(Comp: (props: T) => BaseRenderable, props: T) => BaseRenderable, createElement: (tag: string) => BaseRenderable, createTextNode: (value: string) => BaseRenderable, insertNode: (parent: BaseRenderable, node: BaseRenderable, anchor?: BaseRenderable | undefined) => void, insert: <T>(parent: any, accessor: T | (() => T), marker?: any | null, initial?: any) => BaseRenderable, spread: <T>(node: any, accessor: (() => T) | T, skipChildren?: boolean) => void, setProp: <T>(node: BaseRenderable, name: string, value: T, prev?: T | undefined) => T, mergeProps: (...sources: unknown[]) => unknown, use: <A, T>(fn: (element: BaseRenderable, arg: A) => T, element: BaseRenderable, arg: A) => T;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export function createRenderer({ createElement, createTextNode, createSlotNode, isTextNode, replaceText, insertNode, removeNode, setProperty, getParentNode, getFirstChild, getNextSibling, }: {
|
|
2
|
+
createElement: any;
|
|
3
|
+
createTextNode: any;
|
|
4
|
+
createSlotNode: any;
|
|
5
|
+
isTextNode: any;
|
|
6
|
+
replaceText: any;
|
|
7
|
+
insertNode: any;
|
|
8
|
+
removeNode: any;
|
|
9
|
+
setProperty: any;
|
|
10
|
+
getParentNode: any;
|
|
11
|
+
getFirstChild: any;
|
|
12
|
+
getNextSibling: any;
|
|
13
|
+
}): {
|
|
14
|
+
render(code: any, element: any): undefined;
|
|
15
|
+
insert: (parent: any, accessor: any, marker: any, initial: any) => any;
|
|
16
|
+
spread(node: any, accessor: any, skipChildren: any): void;
|
|
17
|
+
createElement: any;
|
|
18
|
+
createTextNode: any;
|
|
19
|
+
insertNode: any;
|
|
20
|
+
setProp(node: any, name: any, value: any, prev: any): any;
|
|
21
|
+
mergeProps: typeof mergeProps;
|
|
22
|
+
effect: typeof createRenderEffect;
|
|
23
|
+
memo: (fn: any) => import("solid-js").Accessor<any>;
|
|
24
|
+
createComponent: typeof createComponent;
|
|
25
|
+
use(fn: any, element: any, arg: any): any;
|
|
26
|
+
};
|
|
27
|
+
import { mergeProps } from "solid-js";
|
|
28
|
+
import { createRenderEffect } from "solid-js";
|
|
29
|
+
import { createComponent } from "solid-js";
|
package/src/types/elements.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { ASCIIFontOptions, ASCIIFontRenderable, BoxOptions, BoxRenderable, InputRenderable, InputRenderableOptions,
|
|
2
|
-
import type {
|
|
1
|
+
import type { ASCIIFontOptions, ASCIIFontRenderable, BaseRenderable, BoxOptions, BoxRenderable, InputRenderable, InputRenderableOptions, RenderableOptions, RenderContext, ScrollBoxOptions, ScrollBoxRenderable, SelectOption, SelectRenderable, SelectRenderableOptions, TabSelectOption, TabSelectRenderable, TabSelectRenderableOptions, TextNodeRenderable, TextOptions, TextRenderable } from "@opentui/core";
|
|
2
|
+
import type { Ref } from "solid-js";
|
|
3
|
+
import type { JSX } from "../../jsx-runtime";
|
|
3
4
|
/** Properties that should not be included in the style prop */
|
|
4
5
|
export type NonStyledProps = "id" | "buffered" | "live" | "enableLayout" | "selectable" | "renderAfter" | "renderBefore" | `on${string}`;
|
|
5
6
|
/** Solid-specific props for all components */
|
|
@@ -7,7 +8,7 @@ export type ElementProps<TRenderable = unknown> = {
|
|
|
7
8
|
ref?: Ref<TRenderable>;
|
|
8
9
|
};
|
|
9
10
|
/** Base type for any renderable constructor */
|
|
10
|
-
export type RenderableConstructor<TRenderable extends
|
|
11
|
+
export type RenderableConstructor<TRenderable extends BaseRenderable = BaseRenderable> = new (ctx: RenderContext, options: any) => TRenderable;
|
|
11
12
|
/** Extract the options type from a renderable constructor */
|
|
12
13
|
type ExtractRenderableOptions<TConstructor> = TConstructor extends new (ctx: RenderContext, options: infer TOptions) => any ? TOptions : never;
|
|
13
14
|
/** Extract the renderable type from a constructor */
|
|
@@ -19,13 +20,16 @@ type ContainerProps<TOptions> = TOptions & {
|
|
|
19
20
|
children?: JSX.Element;
|
|
20
21
|
};
|
|
21
22
|
/** Smart component props that automatically determine excluded properties */
|
|
22
|
-
type ComponentProps<TOptions extends RenderableOptions<TRenderable>, TRenderable extends
|
|
23
|
+
type ComponentProps<TOptions extends RenderableOptions<TRenderable>, TRenderable extends BaseRenderable> = TOptions & {
|
|
23
24
|
style?: Partial<Omit<TOptions, GetNonStyledProperties<RenderableConstructor<TRenderable>>>>;
|
|
24
25
|
} & ElementProps<TRenderable>;
|
|
25
26
|
/** Valid text content types for Text component children */
|
|
26
|
-
type TextChildren =
|
|
27
|
+
type TextChildren = string | number | boolean | null | undefined | JSX.Element;
|
|
27
28
|
export type TextProps = ComponentProps<TextOptions, TextRenderable> & {
|
|
28
|
-
children?: TextChildren |
|
|
29
|
+
children?: TextChildren | Array<TextChildren>;
|
|
30
|
+
};
|
|
31
|
+
export type SpanProps = ComponentProps<{}, TextNodeRenderable> & {
|
|
32
|
+
children?: TextChildren | Array<TextChildren>;
|
|
29
33
|
};
|
|
30
34
|
export type BoxProps = ComponentProps<ContainerProps<BoxOptions>, BoxRenderable>;
|
|
31
35
|
export type InputProps = ComponentProps<InputRenderableOptions, InputRenderable> & {
|
|
@@ -47,6 +51,8 @@ export type TabSelectProps = ComponentProps<TabSelectRenderableOptions, TabSelec
|
|
|
47
51
|
};
|
|
48
52
|
export type ScrollBoxProps = ComponentProps<ContainerProps<ScrollBoxOptions>, ScrollBoxRenderable> & {
|
|
49
53
|
focused?: boolean;
|
|
54
|
+
stickyScroll?: boolean;
|
|
55
|
+
stickyStart?: "bottom" | "top" | "left" | "right";
|
|
50
56
|
};
|
|
51
57
|
/** Convert renderable constructor to component props with proper style exclusions */
|
|
52
58
|
export type ExtendedComponentProps<TConstructor extends RenderableConstructor, TOptions = ExtractRenderableOptions<TConstructor>> = TOptions & {
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { Renderable, TextRenderable, type RenderContext, type TextChunk, type TextOptions } from "@opentui/core";
|
|
2
|
-
import { type DomNode } from "../reconciler";
|
|
3
|
-
export declare const isTextChunk: (node: any) => node is TextChunk;
|
|
4
|
-
/**
|
|
5
|
-
* Represents a text node in the SolidJS reconciler.
|
|
6
|
-
*/
|
|
7
|
-
export declare class TextNode {
|
|
8
|
-
id: string;
|
|
9
|
-
chunk: TextChunk;
|
|
10
|
-
parent?: Renderable;
|
|
11
|
-
textParent?: TextRenderable | GhostTextRenderable;
|
|
12
|
-
constructor(chunk: TextChunk);
|
|
13
|
-
/**
|
|
14
|
-
* Replaces the current text chunk with a new one.
|
|
15
|
-
* @param newChunk The new text chunk to replace with.
|
|
16
|
-
*/
|
|
17
|
-
replaceText(newChunk: TextChunk): void;
|
|
18
|
-
/**
|
|
19
|
-
* Retrieves the TextNode associated with a given TextChunk.
|
|
20
|
-
* @param chunk The text chunk to look up.
|
|
21
|
-
* @returns The associated TextNode or undefined if not found.
|
|
22
|
-
*/
|
|
23
|
-
static getTextNodeFromChunk(chunk: TextChunk): TextNode | undefined;
|
|
24
|
-
/**
|
|
25
|
-
* Inserts this text node into the DOM structure.
|
|
26
|
-
* @param parent The parent DOM node.
|
|
27
|
-
* @param anchor The anchor node for positioning.
|
|
28
|
-
*/
|
|
29
|
-
insert(parent: DomNode, anchor?: DomNode): void;
|
|
30
|
-
/**
|
|
31
|
-
* Removes this text node from the DOM structure.
|
|
32
|
-
* @param parent The parent DOM node.
|
|
33
|
-
*/
|
|
34
|
-
remove(parent: DomNode): void;
|
|
35
|
-
/**
|
|
36
|
-
* Gets or creates a ghost text node for rendering text content.
|
|
37
|
-
* @param parent The parent renderable.
|
|
38
|
-
* @param anchor The anchor node for positioning.
|
|
39
|
-
* @returns The text renderable ghost node.
|
|
40
|
-
* @private
|
|
41
|
-
*/
|
|
42
|
-
private getOrCreateTextGhostNode;
|
|
43
|
-
}
|
|
44
|
-
declare class GhostTextRenderable extends TextRenderable {
|
|
45
|
-
constructor(ctx: RenderContext, options: TextOptions);
|
|
46
|
-
static isGhostNode(node: DomNode): node is GhostTextRenderable;
|
|
47
|
-
}
|
|
48
|
-
export {};
|