Skip to main content

Module: sjdon

Type Aliases​

SjdonElement​

Ƭ SjdonElement: [SjdonElementType, ...(SjdonElementOrPrimitive | Props)[]]

A SjdonElement is an array containing at least one element. The first element is of type SjdonElementType and specifies the type of the SjdonElement. The other elements are either children or props of the element. Chidren can be either a complete SjdonElement or a Primitive. Props are always an object of type Props.

Example

// a heading 1 with no content
const minimalElement: SjdonElement = ['h1']
// a div containing a text and a paragraph
const elementWithChildren: SjdonElement = ['div', 'Test', ['p', 'Hello World!']]
// a button with specified onclick props and a text child.
const elementWithProps: SjdonElement = [
'button',
{ onclick: () => console.log('Button clicked!') },
'Click me!'
]

Defined in​

sjdon.ts:49


SjdonElementFunction​

Ƭ SjdonElementFunction<T>: (props?: T & { children?: SjdonElementOrPrimitive[] }) => SjdonElement

Type parameters​

NameType
TRecord<string, unknown>

Type declaration​

▸ (props?): SjdonElement

A SjdonElementFunction takes in props as a parameter and returns a SjdonElement.

Parameters​
NameTypeDescription
props?T & { children?: SjdonElementOrPrimitive[] }The props of the element. Children are automatically passed via the reserved children property.
Returns​

SjdonElement

Defined in​

sjdon.ts:15


SjdonElementOrPrimitive​

Ƭ SjdonElementOrPrimitive: SjdonElement | Primitive

A SjdonElementOrPrimitive is either a SjdonElement or a Primitive.

Defined in​

sjdon.ts:27


SjdonElementType​

Ƭ SjdonElementType: keyof HTMLElementTagNameMap | SjdonElementFunction

The type of a SjdonElement, which is specified in the first element of the array. It can either be a HTML tag or a SjdonElementFunction.

Defined in​

sjdon.ts:9

Functions​

parseSjdon​

▸ parseSjdon<T>(param0, create): T

Parses a SjdonElement with all its children and creates a fiber tree. Uses the createElement function to create all fibers.

Type parameters​

Name
T

Parameters​

NameTypeDescription
param0SjdonElementThe SjdonElement which should be parsed.
createCreateElementFunction<T>The function which is used to create the elements. It works properly with the SuiWeb implementation createElement, but also other implementations, like React.createElement, could be used. Note, however, that this is only partially supported, as the typing don't match and the props are not fully compatible.

Returns​

T

The root element of the tree containing all children.

Defined in​

sjdon.ts:94