@tempots/dom 9.0.1 → 10.0.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/README.md +6 -1
- package/{components → dom}/animatable.d.ts +7 -1
- package/dom/attr.d.ts +73 -0
- package/dom/dom-context.d.ts +108 -0
- package/dom/dom-utils.d.ts +21 -0
- package/dom/handle-anchor-click.d.ts +13 -0
- package/dom/ssr-tracker.d.ts +1 -0
- package/dom/ssr.d.ts +8 -0
- package/index.cjs +1 -0
- package/index.d.ts +52 -34
- package/index.js +1397 -31
- package/mountable/appearance.d.ts +38 -0
- package/mountable/async.d.ts +7 -0
- package/mountable/attribute.d.ts +489 -0
- package/mountable/autofocus.d.ts +3 -0
- package/mountable/autoselect.d.ts +3 -0
- package/mountable/bind.d.ts +16 -0
- package/mountable/conjunction.d.ts +8 -0
- package/mountable/consumers.d.ts +12 -0
- package/mountable/ctx.d.ts +3 -0
- package/mountable/domel.d.ts +3 -0
- package/mountable/element.d.ts +236 -0
- package/mountable/empty.d.ts +3 -0
- package/mountable/ensure.d.ts +4 -0
- package/mountable/foreach.d.ts +5 -0
- package/mountable/fragment.d.ts +3 -0
- package/mountable/handler.d.ts +102 -0
- package/mountable/hidden-when-empty.d.ts +3 -0
- package/mountable/html-title.d.ts +3 -0
- package/mountable/inviewport.d.ts +6 -0
- package/mountable/map-signal.d.ts +4 -0
- package/mountable/not-empty.d.ts +4 -0
- package/mountable/ondispose.d.ts +4 -0
- package/mountable/oneof.d.ts +22 -0
- package/mountable/onmount.d.ts +3 -0
- package/mountable/portal.d.ts +4 -0
- package/mountable/providers.d.ts +16 -0
- package/mountable/render.d.ts +8 -0
- package/mountable/repeat.d.ts +5 -0
- package/mountable/size.d.ts +8 -0
- package/mountable/style.d.ts +504 -0
- package/mountable/task.d.ts +7 -0
- package/mountable/text.d.ts +6 -0
- package/mountable/when.d.ts +4 -0
- package/package.json +15 -8
- package/std/interpolate.d.ts +5 -0
- package/std/position.d.ts +9 -0
- package/std/signal.d.ts +120 -0
- package/types/aria-attributes.d.ts +50 -0
- package/types/css-styles.d.ts +3 -0
- package/types/domain.d.ts +14 -0
- package/types/html-attributes.d.ts +115 -0
- package/types/html-events.d.ts +89 -0
- package/types/html-tags.d.ts +113 -0
- package/types/mathml-attributes.d.ts +50 -0
- package/types/mathml-tags.d.ts +30 -0
- package/types/svg-attributes.d.ts +243 -0
- package/types/svg-tags.d.ts +64 -0
- package/clean.d.ts +0 -2
- package/clean.js +0 -1
- package/components/Attribute.d.ts +0 -15
- package/components/Attribute.js +0 -16
- package/components/Autofocus.d.ts +0 -2
- package/components/Autofocus.js +0 -4
- package/components/BooleanAttribute.d.ts +0 -15
- package/components/BooleanAttribute.js +0 -16
- package/components/ClassName.d.ts +0 -13
- package/components/ClassName.js +0 -14
- package/components/El.d.ts +0 -15
- package/components/El.js +0 -21
- package/components/FadeIn.d.ts +0 -20
- package/components/FadeIn.js +0 -54
- package/components/FadeOut.d.ts +0 -16
- package/components/FadeOut.js +0 -39
- package/components/For.d.ts +0 -18
- package/components/For.js +0 -27
- package/components/Fragment.d.ts +0 -12
- package/components/Fragment.js +0 -16
- package/components/HiddenWhenEmpty.d.ts +0 -7
- package/components/HiddenWhenEmpty.js +0 -13
- package/components/If.d.ts +0 -14
- package/components/If.js +0 -19
- package/components/InnerHTML.d.ts +0 -13
- package/components/InnerHTML.js +0 -23
- package/components/Lifecycle.d.ts +0 -14
- package/components/Lifecycle.js +0 -18
- package/components/NotEmpty.d.ts +0 -9
- package/components/NotEmpty.js +0 -11
- package/components/On.d.ts +0 -15
- package/components/On.js +0 -14
- package/components/OnRemove.d.ts +0 -6
- package/components/OnRemove.js +0 -4
- package/components/OneOf.d.ts +0 -62
- package/components/OneOf.js +0 -68
- package/components/Portal.d.ts +0 -15
- package/components/Portal.js +0 -20
- package/components/Property.d.ts +0 -15
- package/components/Property.js +0 -16
- package/components/Provider.d.ts +0 -28
- package/components/Provider.js +0 -44
- package/components/Repeat.d.ts +0 -28
- package/components/Repeat.js +0 -146
- package/components/Show.d.ts +0 -15
- package/components/Show.js +0 -8
- package/components/Text.d.ts +0 -15
- package/components/Text.js +0 -33
- package/components/TextContent.d.ts +0 -13
- package/components/TextContent.js +0 -23
- package/components/animatable.js +0 -283
- package/dom-context.d.ts +0 -39
- package/dom-context.js +0 -263
- package/helpers/handle-anchor-click.d.ts +0 -4
- package/helpers/handle-anchor-click.js +0 -43
- package/helpers/handle-text-input.d.ts +0 -1
- package/helpers/handle-text-input.js +0 -4
- package/helpers/is-empty-element.d.ts +0 -2
- package/helpers/is-empty-element.js +0 -8
- package/jsx-dev-runtime.d.ts +0 -1
- package/jsx-dev-runtime.js +0 -1
- package/jsx-runtime.d.ts +0 -9
- package/jsx-runtime.js +0 -157
- package/jsx.d.ts +0 -806
- package/jsx.js +0 -1
- package/prop.d.ts +0 -58
- package/prop.js +0 -256
- package/render.d.ts +0 -3
- package/render.js +0 -7
- package/renderable.d.ts +0 -5
- package/renderable.js +0 -1
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export class HiddenWhenEmptyImpl {
|
|
2
|
-
appendTo(ctx) {
|
|
3
|
-
const initial = ctx.getStyle(':empty');
|
|
4
|
-
ctx.setStyle(':empty', 'display: none');
|
|
5
|
-
return (removeTree) => {
|
|
6
|
-
if (removeTree)
|
|
7
|
-
ctx.setStyle(':empty', initial);
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
export function HiddenWhenEmpty() {
|
|
12
|
-
return new HiddenWhenEmptyImpl();
|
|
13
|
-
}
|
package/components/If.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { type JSX } from '../jsx-runtime';
|
|
2
|
-
import { type Signal } from '../prop';
|
|
3
|
-
export interface IfProps {
|
|
4
|
-
is: Signal<boolean>;
|
|
5
|
-
then?: () => JSX.DOMNode;
|
|
6
|
-
otherwise?: () => JSX.DOMNode;
|
|
7
|
-
}
|
|
8
|
-
export declare function If({ is, then, otherwise }: IfProps): JSX.DOMNode;
|
|
9
|
-
export interface WhenProps {
|
|
10
|
-
is: Signal<boolean>;
|
|
11
|
-
children?: () => JSX.DOMNode;
|
|
12
|
-
}
|
|
13
|
-
export declare function When({ is, children }: WhenProps): JSX.DOMNode;
|
|
14
|
-
export declare function Unless({ is, children }: WhenProps): JSX.DOMNode;
|
package/components/If.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { OneOfImpl } from './OneOf';
|
|
2
|
-
export function If({ is, then, otherwise }) {
|
|
3
|
-
return new OneOfImpl(is.map(v => v ? { then: true } : { otherwise: false }), {
|
|
4
|
-
then: then || (() => null),
|
|
5
|
-
otherwise: otherwise || (() => null)
|
|
6
|
-
});
|
|
7
|
-
}
|
|
8
|
-
export function When({ is, children }) {
|
|
9
|
-
return new OneOfImpl(is.map(v => v ? { then: true } : { otherwise: false }), {
|
|
10
|
-
then: children,
|
|
11
|
-
otherwise: (() => null)
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
export function Unless({ is, children }) {
|
|
15
|
-
return new OneOfImpl(is.map(v => v ? { then: true } : { otherwise: false }), {
|
|
16
|
-
then: (() => null),
|
|
17
|
-
otherwise: children
|
|
18
|
-
});
|
|
19
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { type Signal } from '../prop';
|
|
2
|
-
import { type Clear } from '../clean';
|
|
3
|
-
import { type DOMContext } from '../dom-context';
|
|
4
|
-
import { type Renderable } from '../renderable';
|
|
5
|
-
export declare class InnerHTMLImpl implements Renderable {
|
|
6
|
-
private readonly html;
|
|
7
|
-
constructor(html: Signal<string> | Signal<string | undefined>);
|
|
8
|
-
readonly appendTo: (ctx: DOMContext) => Clear;
|
|
9
|
-
}
|
|
10
|
-
export interface InnerHTMLProps {
|
|
11
|
-
html: Signal<string> | Signal<string | undefined>;
|
|
12
|
-
}
|
|
13
|
-
export declare function InnerHTML({ html }: InnerHTMLProps): InnerHTMLImpl;
|
package/components/InnerHTML.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export class InnerHTMLImpl {
|
|
2
|
-
html;
|
|
3
|
-
constructor(html) {
|
|
4
|
-
this.html = html;
|
|
5
|
-
}
|
|
6
|
-
appendTo = (ctx) => {
|
|
7
|
-
const el = ctx.getElement();
|
|
8
|
-
const previous = el.innerHTML;
|
|
9
|
-
el.innerHTML = this.html.get() ?? '';
|
|
10
|
-
const cancel = this.html.subscribe(value => {
|
|
11
|
-
el.innerHTML = value ?? '';
|
|
12
|
-
});
|
|
13
|
-
return (removeTree) => {
|
|
14
|
-
cancel();
|
|
15
|
-
if (removeTree) {
|
|
16
|
-
el.innerHTML = previous;
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
export function InnerHTML({ html }) {
|
|
22
|
-
return new InnerHTMLImpl(html);
|
|
23
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { type Clear } from '../clean';
|
|
2
|
-
import { type DOMContext } from '../dom-context';
|
|
3
|
-
import { type Renderable } from '../renderable';
|
|
4
|
-
export declare class LifecycleImpl implements Renderable {
|
|
5
|
-
private readonly onMount;
|
|
6
|
-
private readonly onUnmount;
|
|
7
|
-
constructor(onMount: (el: HTMLElement) => void, onUnmount: (el: HTMLElement, removeTree: boolean) => void);
|
|
8
|
-
readonly appendTo: (ctx: DOMContext) => Clear;
|
|
9
|
-
}
|
|
10
|
-
export interface LifecycleProps {
|
|
11
|
-
onMount?: (el: HTMLElement) => void;
|
|
12
|
-
onUnmount?: (el: HTMLElement, removeTree: boolean) => void;
|
|
13
|
-
}
|
|
14
|
-
export declare function Lifecycle({ onMount, onUnmount }: LifecycleProps): Renderable;
|
package/components/Lifecycle.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export class LifecycleImpl {
|
|
2
|
-
onMount;
|
|
3
|
-
onUnmount;
|
|
4
|
-
constructor(onMount, onUnmount) {
|
|
5
|
-
this.onMount = onMount;
|
|
6
|
-
this.onUnmount = onUnmount;
|
|
7
|
-
}
|
|
8
|
-
appendTo = (ctx) => {
|
|
9
|
-
this.onMount(ctx.getElement());
|
|
10
|
-
return (removeTree) => {
|
|
11
|
-
this.onUnmount(ctx.getElement(), removeTree);
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
export function Lifecycle({ onMount, onUnmount }) {
|
|
16
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
17
|
-
return new LifecycleImpl(onMount ?? (() => { }), onUnmount ?? (() => { }));
|
|
18
|
-
}
|
package/components/NotEmpty.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/** @jsxImportSource .. */
|
|
2
|
-
import { type Signal } from '../prop';
|
|
3
|
-
import { type JSX } from '../jsx-runtime';
|
|
4
|
-
export interface NotEmptyProps<T> {
|
|
5
|
-
on: Signal<T>;
|
|
6
|
-
whenEmpty?: () => JSX.DOMNode;
|
|
7
|
-
display: () => JSX.DOMNode;
|
|
8
|
-
}
|
|
9
|
-
export declare function NotEmpty<T extends unknown[] | Record<any, unknown>>({ on, display, whenEmpty }: NotEmptyProps<T>): JSX.DOMNode;
|
package/components/NotEmpty.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "../jsx-runtime";
|
|
2
|
-
import { If } from './If';
|
|
3
|
-
function isEmpty(obj) {
|
|
4
|
-
return Object.keys(obj).length === 0;
|
|
5
|
-
}
|
|
6
|
-
// <NotEmpty on={maybevalue} whenEmpty={<span>nothing to show</span>}}>{value => value.toText()}</NotEmpty>
|
|
7
|
-
export function NotEmpty({ on, display, whenEmpty }) {
|
|
8
|
-
return (_jsx(If, { is: on.map((v) =>
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
-
Array.isArray(v) ? v.length > 0 : v != null && !isEmpty(v)), then: display, otherwise: whenEmpty }));
|
|
11
|
-
}
|
package/components/On.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { type Renderable } from '../renderable';
|
|
2
|
-
import { type Clear } from '../clean';
|
|
3
|
-
import { type DOMContext } from '../dom-context';
|
|
4
|
-
export type OnFn<T> = (value: T) => void;
|
|
5
|
-
export declare class OnImpl<T> implements Renderable {
|
|
6
|
-
private readonly name;
|
|
7
|
-
private readonly handler;
|
|
8
|
-
constructor(name: string, handler: OnFn<T>);
|
|
9
|
-
readonly appendTo: (ctx: DOMContext) => Clear;
|
|
10
|
-
}
|
|
11
|
-
export interface OnProps<T> {
|
|
12
|
-
name: string;
|
|
13
|
-
handler: OnFn<T>;
|
|
14
|
-
}
|
|
15
|
-
export declare function On<T>({ name, handler }: OnProps<T>): Renderable;
|
package/components/On.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export class OnImpl {
|
|
2
|
-
name;
|
|
3
|
-
handler;
|
|
4
|
-
constructor(name, handler) {
|
|
5
|
-
this.name = name;
|
|
6
|
-
this.handler = handler;
|
|
7
|
-
}
|
|
8
|
-
appendTo = (ctx) => {
|
|
9
|
-
return ctx.createHandler(this.name, this.handler);
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
export function On({ name, handler }) {
|
|
13
|
-
return new OnImpl(name, handler);
|
|
14
|
-
}
|
package/components/OnRemove.d.ts
DELETED
package/components/OnRemove.js
DELETED
package/components/OneOf.d.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { type Signal } from '../prop';
|
|
2
|
-
import { type Clear } from '../clean';
|
|
3
|
-
import { type DOMContext } from '../dom-context';
|
|
4
|
-
import { type Renderable } from '../renderable';
|
|
5
|
-
import { type JSX } from '../jsx';
|
|
6
|
-
export declare class OneOfImpl<T extends Record<string, unknown>> implements Renderable {
|
|
7
|
-
private readonly match;
|
|
8
|
-
private readonly cases;
|
|
9
|
-
constructor(match: Signal<T>, cases: {
|
|
10
|
-
[KK in keyof T]: (value: Signal<T[KK]>) => JSX.DOMNode;
|
|
11
|
-
});
|
|
12
|
-
readonly appendTo: (ctx: DOMContext) => Clear;
|
|
13
|
-
}
|
|
14
|
-
export type OneOfProps<T extends Record<string, unknown>> = {
|
|
15
|
-
match: Signal<T>;
|
|
16
|
-
} & {
|
|
17
|
-
[KK in keyof T]: (value: Signal<T[KK]>) => JSX.DOMNode;
|
|
18
|
-
};
|
|
19
|
-
export declare function OneOf<T extends Record<string, unknown>>(props: OneOfProps<T>): JSX.DOMNode;
|
|
20
|
-
export type OneOfLiteralProps<K extends string> = {
|
|
21
|
-
match: Signal<K>;
|
|
22
|
-
} & {
|
|
23
|
-
[KK in K]: JSX.DOMNode;
|
|
24
|
-
};
|
|
25
|
-
export declare function OneOfLiteral<K extends string>(props: OneOfLiteralProps<K>): JSX.DOMNode;
|
|
26
|
-
export type OneOfUnionProps<T extends {
|
|
27
|
-
[_ in K]: string;
|
|
28
|
-
}, K extends string> = {
|
|
29
|
-
match: Signal<T>;
|
|
30
|
-
using: K;
|
|
31
|
-
} & {
|
|
32
|
-
[KK in T[K]]: (value: Signal<T extends {
|
|
33
|
-
[_ in K]: KK;
|
|
34
|
-
} ? T : never>) => JSX.DOMNode;
|
|
35
|
-
};
|
|
36
|
-
export declare function OneOfUnion<T extends {
|
|
37
|
-
[_ in K]: string;
|
|
38
|
-
}, K extends string>(props: OneOfUnionProps<T, K>): JSX.DOMNode;
|
|
39
|
-
export type OneOfUnionTypeProps<T extends {
|
|
40
|
-
[_ in 'type']: string;
|
|
41
|
-
}> = {
|
|
42
|
-
match: Signal<T>;
|
|
43
|
-
} & {
|
|
44
|
-
[KK in T['type']]: (value: Signal<T extends {
|
|
45
|
-
[_ in 'type']: KK;
|
|
46
|
-
} ? T : never>) => JSX.DOMNode;
|
|
47
|
-
};
|
|
48
|
-
export declare function OneOfUnionType<T extends {
|
|
49
|
-
type: string;
|
|
50
|
-
}>(props: OneOfUnionTypeProps<T>): JSX.DOMNode;
|
|
51
|
-
export type OneOfUnionKindProps<T extends {
|
|
52
|
-
[_ in 'kind']: string;
|
|
53
|
-
}> = {
|
|
54
|
-
match: Signal<T>;
|
|
55
|
-
} & {
|
|
56
|
-
[KK in T['kind']]: (value: Signal<T extends {
|
|
57
|
-
[_ in 'kind']: KK;
|
|
58
|
-
} ? T : never>) => JSX.DOMNode;
|
|
59
|
-
};
|
|
60
|
-
export declare function OneOfUnionKind<T extends {
|
|
61
|
-
kind: string;
|
|
62
|
-
}>(props: OneOfUnionKindProps<T>): JSX.DOMNode;
|
package/components/OneOf.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { Prop } from '../prop';
|
|
2
|
-
import { makeRenderable } from '../jsx-runtime';
|
|
3
|
-
export class OneOfImpl {
|
|
4
|
-
match;
|
|
5
|
-
cases;
|
|
6
|
-
constructor(match, cases) {
|
|
7
|
-
this.match = match;
|
|
8
|
-
this.cases = cases;
|
|
9
|
-
}
|
|
10
|
-
appendTo = (ctx) => {
|
|
11
|
-
const pair = this.match.get();
|
|
12
|
-
let key = Object.keys(pair)[0];
|
|
13
|
-
const value = pair[key];
|
|
14
|
-
let prop = new Prop(value);
|
|
15
|
-
let newCtx = ctx.makeReference();
|
|
16
|
-
let clear = makeRenderable(this.cases[key](prop)).appendTo(newCtx);
|
|
17
|
-
const cancel = this.match.subscribe((newPair) => {
|
|
18
|
-
const newKey = Object.keys(newPair)[0];
|
|
19
|
-
const newValue = newPair[newKey];
|
|
20
|
-
if (newKey !== key) {
|
|
21
|
-
newCtx.requestClear(true, () => {
|
|
22
|
-
newCtx = newCtx.makeReference();
|
|
23
|
-
key = newKey;
|
|
24
|
-
prop.clean();
|
|
25
|
-
prop = new Prop(newValue);
|
|
26
|
-
clear(true);
|
|
27
|
-
clear = makeRenderable(this.cases[key](prop)).appendTo(newCtx);
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
prop.set(newValue);
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
return (removeTree) => {
|
|
35
|
-
newCtx.requestClear(removeTree, () => {
|
|
36
|
-
clear(removeTree);
|
|
37
|
-
cancel();
|
|
38
|
-
prop.clean();
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
// <OneOf match={counter.map(v => v % 2 == 0 ? {1: "odd"} : {2: "even"})} 1={t => <b>{t}</b>} 2={t => <i>{t}</i>} /
|
|
44
|
-
export function OneOf(props) {
|
|
45
|
-
return new OneOfImpl(props.match, props);
|
|
46
|
-
}
|
|
47
|
-
export function OneOfLiteral(props) {
|
|
48
|
-
const { match, ...cases } = props;
|
|
49
|
-
const keys = Object.keys(cases);
|
|
50
|
-
const obj = keys.reduce((acc, k) => {
|
|
51
|
-
acc[k] = () => cases[k];
|
|
52
|
-
return acc;
|
|
53
|
-
// eslint-disable-next-line @typescript-eslint/prefer-reduce-type-parameter, @typescript-eslint/consistent-type-assertions
|
|
54
|
-
}, {});
|
|
55
|
-
return new OneOfImpl(
|
|
56
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
57
|
-
match.map(k => ({ [k]: null })), obj);
|
|
58
|
-
}
|
|
59
|
-
export function OneOfUnion(props) {
|
|
60
|
-
const { match, using, ...cases } = props;
|
|
61
|
-
return new OneOfImpl(match.map(t => ({ [t != null ? t[using] : '']: t })), cases);
|
|
62
|
-
}
|
|
63
|
-
export function OneOfUnionType(props) {
|
|
64
|
-
return OneOfUnion({ ...props, using: 'type' });
|
|
65
|
-
}
|
|
66
|
-
export function OneOfUnionKind(props) {
|
|
67
|
-
return OneOfUnion({ ...props, using: 'kind' });
|
|
68
|
-
}
|
package/components/Portal.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { type Clear } from '../clean';
|
|
2
|
-
import { type DOMContext } from '../dom-context';
|
|
3
|
-
import { type Renderable } from '../renderable';
|
|
4
|
-
import { type JSX } from '../jsx';
|
|
5
|
-
export declare class PortalImpl implements Renderable {
|
|
6
|
-
private readonly selector;
|
|
7
|
-
private readonly children;
|
|
8
|
-
constructor(selector: string, children: JSX.DOMNode);
|
|
9
|
-
appendTo(ctx: DOMContext): Clear;
|
|
10
|
-
}
|
|
11
|
-
export interface PortalProps {
|
|
12
|
-
selector: string;
|
|
13
|
-
children?: JSX.DOMNode;
|
|
14
|
-
}
|
|
15
|
-
export declare function Portal(props: PortalProps): JSX.DOMNode;
|
package/components/Portal.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { render } from '../render';
|
|
2
|
-
import { makeRenderable } from '../jsx-runtime';
|
|
3
|
-
export class PortalImpl {
|
|
4
|
-
selector;
|
|
5
|
-
children;
|
|
6
|
-
constructor(selector, children) {
|
|
7
|
-
this.selector = selector;
|
|
8
|
-
this.children = children;
|
|
9
|
-
}
|
|
10
|
-
appendTo(ctx) {
|
|
11
|
-
const element = ctx.getDocument().querySelector(this.selector);
|
|
12
|
-
if (element === null) {
|
|
13
|
-
throw new Error(`Cannot find element by selector: ${this.selector}`);
|
|
14
|
-
}
|
|
15
|
-
return render(makeRenderable(this.children), element);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
export function Portal(props) {
|
|
19
|
-
return new PortalImpl(props.selector, props.children);
|
|
20
|
-
}
|
package/components/Property.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { type Signal } from '../prop';
|
|
2
|
-
import { type Renderable } from '../renderable';
|
|
3
|
-
import { type Clear } from '../clean';
|
|
4
|
-
import { type DOMContext } from '../dom-context';
|
|
5
|
-
export declare class PropertyImpl<T> implements Renderable {
|
|
6
|
-
private readonly name;
|
|
7
|
-
private readonly value;
|
|
8
|
-
constructor(name: string, value: Signal<T>);
|
|
9
|
-
readonly appendTo: (ctx: DOMContext) => Clear;
|
|
10
|
-
}
|
|
11
|
-
export interface PropertyProps<T> {
|
|
12
|
-
name: string;
|
|
13
|
-
value: Signal<T>;
|
|
14
|
-
}
|
|
15
|
-
export declare function Property<T>({ name, value }: PropertyProps<T>): Renderable;
|
package/components/Property.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { subscribeToSignal } from './Text';
|
|
2
|
-
export class PropertyImpl {
|
|
3
|
-
name;
|
|
4
|
-
value;
|
|
5
|
-
constructor(name, value) {
|
|
6
|
-
this.name = name;
|
|
7
|
-
this.value = value;
|
|
8
|
-
}
|
|
9
|
-
appendTo = (ctx) => {
|
|
10
|
-
const [set, clear] = ctx.createProperty(this.name, this.value.get());
|
|
11
|
-
return subscribeToSignal(this.value, set, clear);
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
export function Property({ name, value }) {
|
|
15
|
-
return new PropertyImpl(name, value);
|
|
16
|
-
}
|
package/components/Provider.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { type Clear } from '../clean';
|
|
2
|
-
import { type DOMContext, type ProviderMark } from '../dom-context';
|
|
3
|
-
import { type Renderable } from '../renderable';
|
|
4
|
-
import { type JSX } from '../jsx';
|
|
5
|
-
export declare class ProviderImpl<T> implements Renderable {
|
|
6
|
-
private readonly mark;
|
|
7
|
-
private readonly provider;
|
|
8
|
-
private readonly children;
|
|
9
|
-
constructor(mark: ProviderMark<T>, provider: T, children: JSX.DOMNode);
|
|
10
|
-
readonly appendTo: (ctx: DOMContext) => Clear;
|
|
11
|
-
}
|
|
12
|
-
export interface ProviderProps<T> {
|
|
13
|
-
mark: ProviderMark<T>;
|
|
14
|
-
value: T;
|
|
15
|
-
children?: JSX.DOMNode;
|
|
16
|
-
}
|
|
17
|
-
export declare function Provider<T>({ mark, value, children }: ProviderProps<T>): JSX.DOMNode;
|
|
18
|
-
export declare class ConsumerImpl<T> implements Renderable {
|
|
19
|
-
private readonly mark;
|
|
20
|
-
private readonly children;
|
|
21
|
-
constructor(mark: ProviderMark<T>, children: (provider: T) => JSX.DOMNode);
|
|
22
|
-
readonly appendTo: (ctx: DOMContext) => Clear;
|
|
23
|
-
}
|
|
24
|
-
export interface ConsumerProps<T> {
|
|
25
|
-
mark: ProviderMark<T>;
|
|
26
|
-
children?: (provider: T) => JSX.DOMNode;
|
|
27
|
-
}
|
|
28
|
-
export declare function Consumer<T>({ mark, children }: ConsumerProps<T>): JSX.DOMNode;
|
package/components/Provider.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { makeRenderable } from '../jsx-runtime';
|
|
2
|
-
export class ProviderImpl {
|
|
3
|
-
mark;
|
|
4
|
-
provider;
|
|
5
|
-
children;
|
|
6
|
-
constructor(mark, provider, children) {
|
|
7
|
-
this.mark = mark;
|
|
8
|
-
this.provider = provider;
|
|
9
|
-
this.children = children;
|
|
10
|
-
}
|
|
11
|
-
appendTo = (ctx) => {
|
|
12
|
-
const newCtx = ctx.withProvider(this.mark, this.provider);
|
|
13
|
-
const clear = makeRenderable(this.children).appendTo(newCtx);
|
|
14
|
-
return (removeTree) => {
|
|
15
|
-
newCtx.requestClear(removeTree, () => {
|
|
16
|
-
clear(removeTree);
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
export function Provider({ mark, value, children }) {
|
|
22
|
-
return new ProviderImpl(mark, value, children);
|
|
23
|
-
}
|
|
24
|
-
export class ConsumerImpl {
|
|
25
|
-
mark;
|
|
26
|
-
children;
|
|
27
|
-
constructor(mark, children) {
|
|
28
|
-
this.mark = mark;
|
|
29
|
-
this.children = children;
|
|
30
|
-
}
|
|
31
|
-
appendTo = (ctx) => {
|
|
32
|
-
const provider = ctx.getProvider(this.mark);
|
|
33
|
-
if (provider == null) {
|
|
34
|
-
throw new Error('No provider found for mark');
|
|
35
|
-
}
|
|
36
|
-
const clear = makeRenderable(this.children(provider)).appendTo(ctx);
|
|
37
|
-
return (removeTree) => {
|
|
38
|
-
clear(removeTree);
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
export function Consumer({ mark, children }) {
|
|
43
|
-
return new ConsumerImpl(mark, children ?? (() => []));
|
|
44
|
-
}
|
package/components/Repeat.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/** @jsxImportSource .. */
|
|
2
|
-
import { type Signal } from '../prop';
|
|
3
|
-
import { type Clear } from '../clean';
|
|
4
|
-
import { type DOMContext } from '../dom-context';
|
|
5
|
-
import { type Renderable } from '../renderable';
|
|
6
|
-
import { type JSX } from '../jsx';
|
|
7
|
-
export interface PositionProps {
|
|
8
|
-
readonly first: boolean;
|
|
9
|
-
readonly last: boolean;
|
|
10
|
-
readonly index: number;
|
|
11
|
-
}
|
|
12
|
-
export declare function makePosition(index: number, length: number): PositionProps;
|
|
13
|
-
export declare class RepeatImpl implements Renderable {
|
|
14
|
-
private readonly times;
|
|
15
|
-
private readonly children;
|
|
16
|
-
private readonly separator?;
|
|
17
|
-
constructor(times: Signal<number>, children: (pos: Signal<PositionProps>) => JSX.DOMNode, separator?: ((sep: Signal<PositionProps>) => JSX.DOMNode) | undefined);
|
|
18
|
-
readonly appendTo: (ctx: DOMContext) => Clear;
|
|
19
|
-
readonly appendToWithoutSeparator: (ctx: DOMContext) => Clear;
|
|
20
|
-
readonly appendToWithSeparator: (ctx: DOMContext, separator: (sep: Signal<PositionProps>) => JSX.DOMNode) => Clear;
|
|
21
|
-
}
|
|
22
|
-
export interface RepeatProps {
|
|
23
|
-
times: Signal<number>;
|
|
24
|
-
children?: (pos: Signal<PositionProps>) => JSX.DOMNode;
|
|
25
|
-
separator?: (sep: Signal<PositionProps>) => JSX.DOMNode;
|
|
26
|
-
}
|
|
27
|
-
export declare function Repeat(props: RepeatProps): Renderable;
|
|
28
|
-
export declare function conjuctions(other: JSX.DOMNode, lastConjunction?: JSX.DOMNode, firstConjunction?: JSX.DOMNode): (sep: Signal<PositionProps>) => JSX.DOMNode;
|
package/components/Repeat.js
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "../jsx-runtime";
|
|
2
|
-
/** @jsxImportSource .. */
|
|
3
|
-
import { Prop } from '../prop';
|
|
4
|
-
import { Fragment } from './Fragment';
|
|
5
|
-
import { makeRenderable } from '../jsx-runtime';
|
|
6
|
-
import { OneOf } from './OneOf';
|
|
7
|
-
export function makePosition(index, length) {
|
|
8
|
-
return {
|
|
9
|
-
first: index === 0,
|
|
10
|
-
last: index === length - 1,
|
|
11
|
-
index
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
export class RepeatImpl {
|
|
15
|
-
times;
|
|
16
|
-
children;
|
|
17
|
-
separator;
|
|
18
|
-
constructor(times, children, separator) {
|
|
19
|
-
this.times = times;
|
|
20
|
-
this.children = children;
|
|
21
|
-
this.separator = separator;
|
|
22
|
-
}
|
|
23
|
-
appendTo = (ctx) => {
|
|
24
|
-
if (this.separator == null) {
|
|
25
|
-
return this.appendToWithoutSeparator(ctx);
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
return this.appendToWithSeparator(ctx, this.separator);
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
appendToWithoutSeparator = (ctx) => {
|
|
32
|
-
const newCtx = ctx.makeReference();
|
|
33
|
-
const count = this.times.get();
|
|
34
|
-
const clears = new Array(count);
|
|
35
|
-
const positions = new Array(count);
|
|
36
|
-
for (let i = 0; i < count; i++) {
|
|
37
|
-
positions[i] = new Prop(makePosition(i, count));
|
|
38
|
-
clears[i] = makeRenderable(this.children(positions[i])).appendTo(newCtx);
|
|
39
|
-
}
|
|
40
|
-
const cancel = this.times.subscribe((newCount) => {
|
|
41
|
-
while (newCount < clears.length) {
|
|
42
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
43
|
-
clears.pop()(true);
|
|
44
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
45
|
-
positions.pop().clean();
|
|
46
|
-
}
|
|
47
|
-
for (let i = 0; i < positions.length; i++) {
|
|
48
|
-
positions[i].set(makePosition(i, newCount));
|
|
49
|
-
}
|
|
50
|
-
for (let i = clears.length; i < newCount; i++) {
|
|
51
|
-
positions[i] = new Prop(makePosition(i, count));
|
|
52
|
-
clears[i] = makeRenderable(this.children(positions[i])).appendTo(newCtx);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
return (removeTree) => {
|
|
56
|
-
newCtx.requestClear(removeTree, () => {
|
|
57
|
-
cancel();
|
|
58
|
-
clears.forEach(clear => { clear(removeTree); });
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
appendToWithSeparator = (ctx, separator) => {
|
|
63
|
-
const newCtx = ctx.makeReference();
|
|
64
|
-
const count = this.times.get();
|
|
65
|
-
const separatorProps = new Array(Math.max(0, count - 1));
|
|
66
|
-
const separatorClears = new Array(Math.max(0, count - 1));
|
|
67
|
-
const clears = new Array(count);
|
|
68
|
-
const positions = new Array(count);
|
|
69
|
-
for (let i = 0; i < count; i++) {
|
|
70
|
-
positions[i] = new Prop(makePosition(i, count));
|
|
71
|
-
clears[i] = makeRenderable(this.children(positions[i])).appendTo(newCtx);
|
|
72
|
-
if (i < count - 1) {
|
|
73
|
-
separatorProps[i] = Prop.of({
|
|
74
|
-
first: i === 0,
|
|
75
|
-
last: i === count - 2,
|
|
76
|
-
index: i
|
|
77
|
-
});
|
|
78
|
-
separatorClears[i] = makeRenderable(separator(separatorProps[i])).appendTo(newCtx);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
const cancel = this.times.subscribe((newCount) => {
|
|
82
|
-
while (newCount < clears.length) {
|
|
83
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
84
|
-
clears.pop()(true);
|
|
85
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
86
|
-
positions.pop().clean();
|
|
87
|
-
if (separatorClears.length > 0) {
|
|
88
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
89
|
-
separatorClears.pop()(true);
|
|
90
|
-
}
|
|
91
|
-
if (separatorProps.length > 0) {
|
|
92
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
93
|
-
separatorProps.pop().clean();
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
for (let i = 0; i < positions.length; i++) {
|
|
97
|
-
positions[i].set(makePosition(i, newCount));
|
|
98
|
-
}
|
|
99
|
-
for (let i = 0; i < separatorProps.length; i++) {
|
|
100
|
-
separatorProps[i].set({
|
|
101
|
-
first: i === 0,
|
|
102
|
-
last: i === newCount - 2,
|
|
103
|
-
index: i
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
for (let i = clears.length; i < newCount; i++) {
|
|
107
|
-
positions[i] = new Prop(makePosition(i, count));
|
|
108
|
-
clears[i] = makeRenderable(this.children(positions[i])).appendTo(newCtx);
|
|
109
|
-
if (i < newCount - 1) {
|
|
110
|
-
separatorProps[i] = Prop.of({
|
|
111
|
-
first: i === 0,
|
|
112
|
-
last: i === newCount - 2,
|
|
113
|
-
index: i
|
|
114
|
-
});
|
|
115
|
-
separatorClears[i] = makeRenderable(separator(separatorProps[i])).appendTo(newCtx);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
return (removeTree) => {
|
|
120
|
-
newCtx.requestClear(removeTree, () => {
|
|
121
|
-
cancel();
|
|
122
|
-
clears.forEach(clear => { clear(removeTree); });
|
|
123
|
-
separatorClears.forEach(clear => { clear(removeTree); });
|
|
124
|
-
separatorProps.forEach(signal => { signal.clean(); });
|
|
125
|
-
});
|
|
126
|
-
};
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
export function Repeat(props) {
|
|
130
|
-
return new RepeatImpl(props.times, props.children ?? (() => Fragment({ children: [] })), props.separator);
|
|
131
|
-
}
|
|
132
|
-
export function conjuctions(other, lastConjunction, firstConjunction) {
|
|
133
|
-
return (sep) => {
|
|
134
|
-
return _jsx(OneOf, { match: sep.map(({ first, last }) => {
|
|
135
|
-
if (last) {
|
|
136
|
-
return { last: true };
|
|
137
|
-
}
|
|
138
|
-
else if (first) {
|
|
139
|
-
return { first: true };
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
return { other: true };
|
|
143
|
-
}
|
|
144
|
-
}), first: () => firstConjunction ?? other, last: () => lastConjunction ?? other, other: () => other });
|
|
145
|
-
};
|
|
146
|
-
}
|
package/components/Show.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/** @jsxImportSource .. */
|
|
2
|
-
import { type Signal } from '../prop';
|
|
3
|
-
import { type JSX } from '../jsx';
|
|
4
|
-
import { OneOfImpl } from './OneOf';
|
|
5
|
-
export type Condition<T> = Signal<T | null | undefined> | Signal<T | undefined> | Signal<T | null> | Signal<T>;
|
|
6
|
-
export interface ShowProps<T> {
|
|
7
|
-
when: Condition<T>;
|
|
8
|
-
otherwise?: () => JSX.DOMNode;
|
|
9
|
-
children?: (value: Signal<NonNullable<T>>) => JSX.DOMNode;
|
|
10
|
-
}
|
|
11
|
-
export declare function Show<T>({ when, children, otherwise }: ShowProps<T>): OneOfImpl<{
|
|
12
|
-
then: NonNullable<T>;
|
|
13
|
-
} | {
|
|
14
|
-
otherwise: false;
|
|
15
|
-
}>;
|
package/components/Show.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx } from "../jsx-runtime";
|
|
2
|
-
import { OneOfImpl } from './OneOf';
|
|
3
|
-
export function Show({ when, children, otherwise }) {
|
|
4
|
-
return new OneOfImpl(when.map(v => (v != null ? { then: v } : { otherwise: false })), {
|
|
5
|
-
then: (v) => ((children && children(v)) || _jsx(_Fragment, {})),
|
|
6
|
-
otherwise: otherwise || (() => _jsx(_Fragment, {}))
|
|
7
|
-
});
|
|
8
|
-
}
|