@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,43 +0,0 @@
|
|
|
1
|
-
function shouldNotApplyCallback(e, checkExtension, checkExternalUrl) {
|
|
2
|
-
let target = e.target;
|
|
3
|
-
while ((target != null) && !(target instanceof HTMLAnchorElement)) {
|
|
4
|
-
target = target.parentElement;
|
|
5
|
-
}
|
|
6
|
-
if (target == null)
|
|
7
|
-
return true;
|
|
8
|
-
const anchor = target;
|
|
9
|
-
// Check for modifier keys and non-left-button, which indicate the user wants to control
|
|
10
|
-
// navigation
|
|
11
|
-
if (e.button !== 0 || e.ctrlKey || e.metaKey) {
|
|
12
|
-
return true;
|
|
13
|
-
}
|
|
14
|
-
// If there is a target and it is not `_self` then we take this
|
|
15
|
-
// as a signal that it doesn't want to be intercepted.
|
|
16
|
-
if (anchor.target !== '_self' && anchor.target !== '') {
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
if (anchor.getAttribute('download') != null) {
|
|
20
|
-
return true; // let the download happen
|
|
21
|
-
}
|
|
22
|
-
if (checkExternalUrl) {
|
|
23
|
-
const { pathname, search, hash } = anchor;
|
|
24
|
-
const relativeUrl = pathname + search + hash;
|
|
25
|
-
// don't navigate if external link or has extension
|
|
26
|
-
if (anchor.getAttribute('href') !== relativeUrl ||
|
|
27
|
-
(checkExtension && !/\/[^/.]*$/.test(pathname))) {
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
export const handleAnchorClick = (callback, options = {
|
|
34
|
-
checkExtension: true,
|
|
35
|
-
checkExternalUrl: true
|
|
36
|
-
}) => (e) => {
|
|
37
|
-
const { checkExtension, checkExternalUrl } = options;
|
|
38
|
-
if (shouldNotApplyCallback(e, checkExtension === true, checkExternalUrl === true)) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
if (callback())
|
|
42
|
-
e.preventDefault();
|
|
43
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const handleTextInput: (f: (input: string) => void) => (e: Event) => void;
|
package/jsx-dev-runtime.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Fragment, jsx, jsxs, jsxDEV, makeRenderable, makeRenderables } from './jsx-runtime';
|
package/jsx-dev-runtime.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Fragment, jsx, jsxs, jsxDEV, makeRenderable, makeRenderables } from './jsx-runtime';
|
package/jsx-runtime.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type JSX } from './jsx';
|
|
2
|
-
import { type Renderable } from './renderable';
|
|
3
|
-
export declare function makeRenderables(value: any): Renderable[];
|
|
4
|
-
export declare function makeRenderable(value: any): Renderable;
|
|
5
|
-
declare function makeFragment({ children }: {
|
|
6
|
-
children: any[];
|
|
7
|
-
}): Renderable;
|
|
8
|
-
declare function makeElement(Name: any, ...args: any[]): Renderable;
|
|
9
|
-
export { makeElement as jsx, makeElement as jsxs, makeElement as jsxDEV, makeFragment as Fragment, type JSX };
|
package/jsx-runtime.js
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import { ElImpl } from './components/El';
|
|
2
|
-
import { AttributeImpl } from './components/Attribute';
|
|
3
|
-
import { BooleanAttributeImpl } from './components/BooleanAttribute';
|
|
4
|
-
import { PropertyImpl } from './components/Property';
|
|
5
|
-
import { ClassNameImpl } from './components/ClassName';
|
|
6
|
-
import { Prop, Signal } from './prop';
|
|
7
|
-
import { TextImpl } from './components/Text';
|
|
8
|
-
import { OnImpl } from './components/On';
|
|
9
|
-
import { FragmentImpl } from './components/Fragment';
|
|
10
|
-
const domBooleanAttributes = new Set([
|
|
11
|
-
'allowfullscreen',
|
|
12
|
-
'allowpaymentrequest',
|
|
13
|
-
'async',
|
|
14
|
-
'autofocus',
|
|
15
|
-
'autoplay',
|
|
16
|
-
'capture',
|
|
17
|
-
'controls',
|
|
18
|
-
'default',
|
|
19
|
-
'defer',
|
|
20
|
-
'disabled',
|
|
21
|
-
'disablepictureinpicture',
|
|
22
|
-
'disableremoteplayback',
|
|
23
|
-
'download',
|
|
24
|
-
'draggable',
|
|
25
|
-
'formnovalidate',
|
|
26
|
-
'hidden',
|
|
27
|
-
'ismap',
|
|
28
|
-
'itemscope',
|
|
29
|
-
'loop',
|
|
30
|
-
'nomodule',
|
|
31
|
-
'novalidate',
|
|
32
|
-
'open',
|
|
33
|
-
'playsinline',
|
|
34
|
-
'readonly',
|
|
35
|
-
'required',
|
|
36
|
-
'reversed',
|
|
37
|
-
'scoped',
|
|
38
|
-
'seamless',
|
|
39
|
-
'spellcheck',
|
|
40
|
-
'truespeed'
|
|
41
|
-
]);
|
|
42
|
-
const domProperties = new Set([
|
|
43
|
-
'checked',
|
|
44
|
-
'checked',
|
|
45
|
-
'classList',
|
|
46
|
-
'className',
|
|
47
|
-
'contentEditable',
|
|
48
|
-
'dataset',
|
|
49
|
-
'innerHTML',
|
|
50
|
-
'multiple',
|
|
51
|
-
'muted',
|
|
52
|
-
'scrollLeft',
|
|
53
|
-
'scrollTop',
|
|
54
|
-
'selected',
|
|
55
|
-
'style',
|
|
56
|
-
'tabIndex',
|
|
57
|
-
'textContent',
|
|
58
|
-
'value'
|
|
59
|
-
]);
|
|
60
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
61
|
-
function isPrimitive(value) {
|
|
62
|
-
return typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean' || typeof value === 'bigint' || value instanceof Date;
|
|
63
|
-
}
|
|
64
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
65
|
-
export function makeRenderables(value) {
|
|
66
|
-
if (value == null) {
|
|
67
|
-
return [];
|
|
68
|
-
}
|
|
69
|
-
if (Array.isArray(value)) {
|
|
70
|
-
return value.flatMap(makeRenderables);
|
|
71
|
-
}
|
|
72
|
-
if (typeof value === 'string') {
|
|
73
|
-
return [new TextImpl(new Prop(value))];
|
|
74
|
-
}
|
|
75
|
-
if (Signal.isSignal(value)) {
|
|
76
|
-
return [new TextImpl(value)];
|
|
77
|
-
}
|
|
78
|
-
if (typeof value === 'object' && 'appendTo' in value) {
|
|
79
|
-
return [value];
|
|
80
|
-
}
|
|
81
|
-
if (isPrimitive(value)) {
|
|
82
|
-
return [new TextImpl(new Prop(value).map(String))];
|
|
83
|
-
}
|
|
84
|
-
throw new Error(`Unkwown renderable: ${String(value)}`);
|
|
85
|
-
}
|
|
86
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
87
|
-
export function makeRenderable(value) {
|
|
88
|
-
const renderables = makeRenderables(value);
|
|
89
|
-
if (renderables.length === 0) {
|
|
90
|
-
return new FragmentImpl([]);
|
|
91
|
-
}
|
|
92
|
-
if (renderables.length === 1) {
|
|
93
|
-
return renderables[0];
|
|
94
|
-
}
|
|
95
|
-
return new FragmentImpl(renderables);
|
|
96
|
-
}
|
|
97
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
98
|
-
function isNamedConstructor(obj) {
|
|
99
|
-
return obj.prototype?.constructor?.name != null;
|
|
100
|
-
}
|
|
101
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
102
|
-
function makeFragment({ children }) {
|
|
103
|
-
if (Array.isArray(children)) {
|
|
104
|
-
return new FragmentImpl(children.flatMap(makeRenderables));
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
return makeRenderable(children);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
111
|
-
function makeElement(Name, ...args) {
|
|
112
|
-
if (typeof Name === 'function') {
|
|
113
|
-
if (isNamedConstructor(Name)) {
|
|
114
|
-
const el = new Name(...args);
|
|
115
|
-
return el;
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
const el = Name(...args);
|
|
119
|
-
return el;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
const { children: untypedChildren, ...rest } = args[0] ?? {};
|
|
123
|
-
const children = [];
|
|
124
|
-
if (Array.isArray(untypedChildren)) {
|
|
125
|
-
children.push(...(untypedChildren.flatMap(makeRenderables)));
|
|
126
|
-
}
|
|
127
|
-
else if (untypedChildren !== undefined) {
|
|
128
|
-
children.push(...makeRenderables(untypedChildren));
|
|
129
|
-
}
|
|
130
|
-
for (const [key, value] of Object.entries(rest)) {
|
|
131
|
-
if (key.startsWith('on')) {
|
|
132
|
-
const eventName = key.slice(2).toLowerCase();
|
|
133
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
134
|
-
children.push(new OnImpl(eventName, value));
|
|
135
|
-
continue;
|
|
136
|
-
}
|
|
137
|
-
if (value == null) {
|
|
138
|
-
continue;
|
|
139
|
-
}
|
|
140
|
-
const prop = isPrimitive(value) ? new Prop(value) : value;
|
|
141
|
-
if (key === 'class' || key === 'className') {
|
|
142
|
-
children.push(new ClassNameImpl(prop));
|
|
143
|
-
continue;
|
|
144
|
-
}
|
|
145
|
-
if (domProperties.has(key)) {
|
|
146
|
-
children.push(new PropertyImpl(key, prop));
|
|
147
|
-
continue;
|
|
148
|
-
}
|
|
149
|
-
if (domBooleanAttributes.has(key)) {
|
|
150
|
-
children.push(new BooleanAttributeImpl(key, prop));
|
|
151
|
-
continue;
|
|
152
|
-
}
|
|
153
|
-
children.push(new AttributeImpl(key, prop));
|
|
154
|
-
}
|
|
155
|
-
return new ElImpl(Name, children);
|
|
156
|
-
}
|
|
157
|
-
export { makeElement as jsx, makeElement as jsxs, makeElement as jsxDEV, makeFragment as Fragment };
|