@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
package/jsx.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/prop.d.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
export type ArgsToSignals<T extends [...unknown[]]> = T extends [] ? [] : T extends [infer U, ...infer V] ? [Signal<U>, ...ArgsToSignals<V>] : [];
|
|
2
|
-
declare const $isSignal: unique symbol;
|
|
3
|
-
declare const $isProp: unique symbol;
|
|
4
|
-
export type Value<T> = T | Signal<T>;
|
|
5
|
-
export declare class Signal<T> {
|
|
6
|
-
protected _value: T;
|
|
7
|
-
static of<T>(value: T): Signal<T>;
|
|
8
|
-
static ofValue<T>(value: Value<T> | null | undefined): Signal<T> | undefined;
|
|
9
|
-
static wrap<T>(value: T | Signal<T>): Signal<T>;
|
|
10
|
-
static isSignal<T = unknown>(x: unknown): x is Signal<T>;
|
|
11
|
-
static unwrap<T>(value: Value<T>): T;
|
|
12
|
-
/**
|
|
13
|
-
* Combines many into one using a merging function
|
|
14
|
-
*/
|
|
15
|
-
static combine<Args extends [...unknown[]], Out>(signals: ArgsToSignals<Args>, f: (...args: Args) => Out): Signal<Out>;
|
|
16
|
-
readonly [$isSignal] = true;
|
|
17
|
-
protected readonly _listeners: Array<(value: T) => void>;
|
|
18
|
-
constructor(_value: T);
|
|
19
|
-
readonly get: () => T;
|
|
20
|
-
readonly subscribe: (listener: (value: T) => void) => () => void;
|
|
21
|
-
readonly map: <V>(f: (value: T) => V) => Signal<V>;
|
|
22
|
-
readonly flatMap: <V>(f: (value: T) => Signal<V>) => Signal<V>;
|
|
23
|
-
readonly flatMapProp: <V>(f: (value: T) => Prop<V>) => Prop<V>;
|
|
24
|
-
readonly tap: (f: (value: T) => void) => this;
|
|
25
|
-
readonly at: <K extends keyof T>(key: K) => Signal<T[K]>;
|
|
26
|
-
readonly filter: (predicate: (value: T) => boolean) => Signal<T>;
|
|
27
|
-
readonly distinct: (equality: (a: T, b: T) => boolean) => Signal<T>;
|
|
28
|
-
readonly mapAsync: <V>(f: (value: T) => Promise<V>, alt: V) => Signal<V>;
|
|
29
|
-
readonly mapMaybe: <V>(f: (value: T) => V | null | undefined, alt: V) => Signal<V>;
|
|
30
|
-
readonly combine: <V, Z>(other: Signal<V>, f: (a: T, b: V) => Z) => Signal<Z>;
|
|
31
|
-
readonly feed: (prop: Prop<T>) => () => void;
|
|
32
|
-
readonly deriveProp: () => Prop<T>;
|
|
33
|
-
readonly clean: () => void;
|
|
34
|
-
readonly count: () => Signal<number>;
|
|
35
|
-
readonly animate: (duration: number, interpolate: (start: T, end: T, delta: number) => T, initialValue?: T | null, easing?: (t: number) => number) => Signal<T>;
|
|
36
|
-
readonly equals: (other: Signal<T>, equality?: ((a: T, b: T) => boolean) | undefined) => Signal<boolean>;
|
|
37
|
-
readonly isNull: () => Signal<boolean>;
|
|
38
|
-
readonly isNotNull: () => Signal<boolean>;
|
|
39
|
-
readonly isEmpty: () => Signal<boolean>;
|
|
40
|
-
readonly isNotEmpty: () => Signal<boolean>;
|
|
41
|
-
}
|
|
42
|
-
export declare class Prop<T> extends Signal<T> {
|
|
43
|
-
static isProp<T = unknown>(x: unknown): x is Prop<T>;
|
|
44
|
-
static of<T>(value: T): Prop<T>;
|
|
45
|
-
static ofStorage<T>(key: string, defaultValue: T, store: {
|
|
46
|
-
getItem: (key: string) => string | null;
|
|
47
|
-
setItem: (key: string, value: string) => void;
|
|
48
|
-
}, serialize?: (v: T) => string, deserilize?: (v: string) => T): Prop<T>;
|
|
49
|
-
static ofLocalStorage<T>(key: string, defaultValue: T, serialize?: (v: T) => string, deserilize?: (v: string) => T): Prop<T>;
|
|
50
|
-
static ofSessionStorage<T>(key: string, defaultValue: T, serialize?: (v: T) => string, deserilize?: (v: string) => T): Prop<T>;
|
|
51
|
-
readonly [$isProp] = true;
|
|
52
|
-
readonly set: (value: T) => void;
|
|
53
|
-
readonly update: (f: (value: T) => T) => void;
|
|
54
|
-
readonly atLens: <K extends keyof T>(key: K) => Prop<T[K]>;
|
|
55
|
-
readonly reducer: <V>(f: (state: T, action: V) => T) => (action: V) => void;
|
|
56
|
-
readonly iso: <V>(map: (value: T) => V, reverse: (value: V) => T) => Prop<V>;
|
|
57
|
-
}
|
|
58
|
-
export {};
|
package/prop.js
DELETED
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
const $isSignal = Symbol('isSignal');
|
|
2
|
-
const $isProp = Symbol('isProp');
|
|
3
|
-
export class Signal {
|
|
4
|
-
_value;
|
|
5
|
-
static of(value) {
|
|
6
|
-
return new Signal(value);
|
|
7
|
-
}
|
|
8
|
-
static ofValue(value) {
|
|
9
|
-
return value == null ? undefined : Signal.wrap(value);
|
|
10
|
-
}
|
|
11
|
-
static wrap(value) {
|
|
12
|
-
return Signal.isSignal(value) ? value : new Signal(value);
|
|
13
|
-
}
|
|
14
|
-
static isSignal(x) {
|
|
15
|
-
const s = x;
|
|
16
|
-
return s != null && typeof s.get === 'function' && typeof s.subscribe === 'function';
|
|
17
|
-
}
|
|
18
|
-
static unwrap(value) {
|
|
19
|
-
return (Signal.isSignal(value) ? value.get() : value);
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Combines many into one using a merging function
|
|
23
|
-
*/
|
|
24
|
-
static combine(signals, f) {
|
|
25
|
-
function getValues(others) {
|
|
26
|
-
return others.map(other => other.get());
|
|
27
|
-
}
|
|
28
|
-
const prop = new Prop(f(...getValues(signals)));
|
|
29
|
-
signals.forEach((other) => {
|
|
30
|
-
other.subscribe(() => {
|
|
31
|
-
prop.set(f(...getValues(signals)));
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
return prop;
|
|
35
|
-
}
|
|
36
|
-
[$isSignal] = true;
|
|
37
|
-
_listeners = [];
|
|
38
|
-
constructor(_value) {
|
|
39
|
-
this._value = _value;
|
|
40
|
-
}
|
|
41
|
-
get = () => {
|
|
42
|
-
return this._value;
|
|
43
|
-
};
|
|
44
|
-
subscribe = (listener) => {
|
|
45
|
-
this._listeners.push(listener);
|
|
46
|
-
return () => {
|
|
47
|
-
const index = this._listeners.indexOf(listener);
|
|
48
|
-
if (index >= 0) {
|
|
49
|
-
this._listeners.splice(index, 1);
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
map = (f) => {
|
|
54
|
-
const prop = new Prop(f(this._value));
|
|
55
|
-
this.subscribe(value => { prop.set(f(value)); });
|
|
56
|
-
return prop;
|
|
57
|
-
};
|
|
58
|
-
flatMap = (f) => {
|
|
59
|
-
let signal = f(this._value);
|
|
60
|
-
const prop = new Prop(signal.get());
|
|
61
|
-
this.subscribe(value => {
|
|
62
|
-
signal.clean();
|
|
63
|
-
signal = f(value);
|
|
64
|
-
signal.subscribe(value => { prop.set(value); });
|
|
65
|
-
});
|
|
66
|
-
return prop;
|
|
67
|
-
};
|
|
68
|
-
flatMapProp = (f) => {
|
|
69
|
-
let tprop = f(this._value);
|
|
70
|
-
const prop = Prop.of(tprop.get());
|
|
71
|
-
let cancel = prop.feed(tprop);
|
|
72
|
-
this.subscribe(value => {
|
|
73
|
-
cancel();
|
|
74
|
-
tprop = f(value);
|
|
75
|
-
prop.set(tprop.get());
|
|
76
|
-
cancel = prop.feed(tprop);
|
|
77
|
-
});
|
|
78
|
-
return prop;
|
|
79
|
-
};
|
|
80
|
-
tap = (f) => {
|
|
81
|
-
f(this._value);
|
|
82
|
-
this.subscribe(f);
|
|
83
|
-
return this;
|
|
84
|
-
};
|
|
85
|
-
at = (key) => {
|
|
86
|
-
return this.map(value => value[key]);
|
|
87
|
-
};
|
|
88
|
-
filter = (predicate) => {
|
|
89
|
-
const prop = new Prop(this._value);
|
|
90
|
-
this.subscribe(value => {
|
|
91
|
-
if (predicate(value)) {
|
|
92
|
-
prop.set(value);
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
return prop;
|
|
96
|
-
};
|
|
97
|
-
distinct = (equality) => {
|
|
98
|
-
let lastValue = this._value;
|
|
99
|
-
return this.filter(value => {
|
|
100
|
-
const result = !equality(value, lastValue);
|
|
101
|
-
lastValue = value;
|
|
102
|
-
return result;
|
|
103
|
-
});
|
|
104
|
-
};
|
|
105
|
-
mapAsync = (f, alt) => {
|
|
106
|
-
let counter = 0;
|
|
107
|
-
const prop = new Prop(alt);
|
|
108
|
-
f(this._value)
|
|
109
|
-
.then(value => {
|
|
110
|
-
if (counter === 0)
|
|
111
|
-
prop.set(value);
|
|
112
|
-
})
|
|
113
|
-
.catch(e => {
|
|
114
|
-
throw e;
|
|
115
|
-
});
|
|
116
|
-
this.subscribe(value => {
|
|
117
|
-
const matchCounter = ++counter;
|
|
118
|
-
f(value)
|
|
119
|
-
.then(value => {
|
|
120
|
-
if (matchCounter === counter) {
|
|
121
|
-
prop.set(value);
|
|
122
|
-
}
|
|
123
|
-
})
|
|
124
|
-
.catch(e => {
|
|
125
|
-
throw e;
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
return prop;
|
|
129
|
-
};
|
|
130
|
-
mapMaybe = (f, alt) => {
|
|
131
|
-
const prop = new Prop(f(this._value) ?? alt);
|
|
132
|
-
this.subscribe(value => {
|
|
133
|
-
const newValue = f(value);
|
|
134
|
-
if (newValue != null)
|
|
135
|
-
prop.set(newValue);
|
|
136
|
-
});
|
|
137
|
-
return prop;
|
|
138
|
-
};
|
|
139
|
-
combine = (other, f) => {
|
|
140
|
-
const prop = new Prop(f(this._value, other.get()));
|
|
141
|
-
this.subscribe(value => { prop.set(f(value, other.get())); });
|
|
142
|
-
other.subscribe(value => { prop.set(f(this._value, value)); });
|
|
143
|
-
return prop;
|
|
144
|
-
};
|
|
145
|
-
feed = (prop) => {
|
|
146
|
-
return this.subscribe(value => { prop.set(value); });
|
|
147
|
-
};
|
|
148
|
-
deriveProp = () => {
|
|
149
|
-
const prop = new Prop(this._value);
|
|
150
|
-
this.feed(prop);
|
|
151
|
-
return prop;
|
|
152
|
-
};
|
|
153
|
-
clean = () => {
|
|
154
|
-
this._listeners.length = 0;
|
|
155
|
-
};
|
|
156
|
-
count = () => {
|
|
157
|
-
let count = 0;
|
|
158
|
-
return this.map(() => ++count);
|
|
159
|
-
};
|
|
160
|
-
animate = (duration, interpolate, initialValue = null, easing = t => t) => {
|
|
161
|
-
let startValue = initialValue ?? this.get();
|
|
162
|
-
let endValue = this.get();
|
|
163
|
-
const prop = new Prop(startValue);
|
|
164
|
-
let startTime = 0;
|
|
165
|
-
let endTime = 0;
|
|
166
|
-
let animationFrame = null;
|
|
167
|
-
const animate = (time) => {
|
|
168
|
-
if (this._listeners.length === 0) {
|
|
169
|
-
animationFrame = null;
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
if (time < endTime) {
|
|
173
|
-
const delta = (time - startTime) / (endTime - startTime);
|
|
174
|
-
prop.set(interpolate(startValue, endValue, easing(delta)));
|
|
175
|
-
animationFrame = requestAnimationFrame(animate);
|
|
176
|
-
}
|
|
177
|
-
else {
|
|
178
|
-
prop.set(endValue);
|
|
179
|
-
animationFrame = null;
|
|
180
|
-
}
|
|
181
|
-
};
|
|
182
|
-
this.subscribe(value => {
|
|
183
|
-
if (animationFrame != null)
|
|
184
|
-
cancelAnimationFrame(animationFrame);
|
|
185
|
-
if (this._listeners.length === 0) {
|
|
186
|
-
animationFrame = null;
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
startValue = prop.get();
|
|
190
|
-
endValue = value;
|
|
191
|
-
startTime = performance.now();
|
|
192
|
-
endTime = startTime + duration;
|
|
193
|
-
animationFrame = requestAnimationFrame(animate);
|
|
194
|
-
});
|
|
195
|
-
return prop;
|
|
196
|
-
};
|
|
197
|
-
equals = (other, equality) => {
|
|
198
|
-
return this.combine(other, (a, b) => {
|
|
199
|
-
if (equality != null)
|
|
200
|
-
return equality(a, b);
|
|
201
|
-
return a === b;
|
|
202
|
-
});
|
|
203
|
-
};
|
|
204
|
-
isNull = () => this.map(value => value == null);
|
|
205
|
-
isNotNull = () => this.map(value => value != null);
|
|
206
|
-
isEmpty = () => this.map(value => value == null || (Reflect.has(value, 'length') && Reflect.get(value, 'length') === 0));
|
|
207
|
-
isNotEmpty = () => this.map(value => value != null && (!Reflect.has(value, 'length') || Reflect.get(value, 'length') !== 0));
|
|
208
|
-
}
|
|
209
|
-
export class Prop extends Signal {
|
|
210
|
-
static isProp(x) {
|
|
211
|
-
const p = x;
|
|
212
|
-
return Signal.isSignal(x) && typeof p.set === 'function';
|
|
213
|
-
// return x != null && (x as Prop<T>)[$isProp] === true
|
|
214
|
-
}
|
|
215
|
-
static of(value) {
|
|
216
|
-
return new Prop(value);
|
|
217
|
-
}
|
|
218
|
-
static ofStorage(key, defaultValue, store, serialize = JSON.stringify, deserilize = JSON.parse) {
|
|
219
|
-
const initialValue = store.getItem(key);
|
|
220
|
-
const prop = new Prop(initialValue !== null ? deserilize(initialValue) : defaultValue);
|
|
221
|
-
prop.subscribe((value) => {
|
|
222
|
-
store.setItem(key, serialize(value));
|
|
223
|
-
});
|
|
224
|
-
return prop;
|
|
225
|
-
}
|
|
226
|
-
static ofLocalStorage(key, defaultValue, serialize = JSON.stringify, deserilize = JSON.parse) {
|
|
227
|
-
return Prop.ofStorage(key, defaultValue, window.localStorage, serialize, deserilize);
|
|
228
|
-
}
|
|
229
|
-
static ofSessionStorage(key, defaultValue, serialize = JSON.stringify, deserilize = JSON.parse) {
|
|
230
|
-
return Prop.ofStorage(key, defaultValue, window.sessionStorage, serialize, deserilize);
|
|
231
|
-
}
|
|
232
|
-
[$isProp] = true;
|
|
233
|
-
set = (value) => {
|
|
234
|
-
if (this._value === value)
|
|
235
|
-
return;
|
|
236
|
-
this._value = value;
|
|
237
|
-
this._listeners.forEach(listener => { listener(value); });
|
|
238
|
-
};
|
|
239
|
-
update = (f) => {
|
|
240
|
-
this.set(f(this._value));
|
|
241
|
-
};
|
|
242
|
-
atLens = (key) => {
|
|
243
|
-
return this.iso(value => value[key], value => ({ ...this._value, [key]: value }));
|
|
244
|
-
};
|
|
245
|
-
reducer = (f) => {
|
|
246
|
-
return (action) => {
|
|
247
|
-
this.set(f(this._value, action));
|
|
248
|
-
};
|
|
249
|
-
};
|
|
250
|
-
iso = (map, reverse) => {
|
|
251
|
-
const prop = new Prop(map(this._value));
|
|
252
|
-
this.subscribe(value => { prop.set(map(value)); });
|
|
253
|
-
prop.subscribe(value => { this.set(reverse(value)); });
|
|
254
|
-
return prop;
|
|
255
|
-
};
|
|
256
|
-
}
|
package/render.d.ts
DELETED
package/render.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { DOMContext } from './dom-context';
|
|
2
|
-
import { makeRenderable } from './jsx-runtime';
|
|
3
|
-
export function render(renderable, element) {
|
|
4
|
-
const ctx = DOMContext.of(element);
|
|
5
|
-
const clear = makeRenderable(renderable).appendTo(ctx);
|
|
6
|
-
return () => { clear(true); };
|
|
7
|
-
}
|
package/renderable.d.ts
DELETED
package/renderable.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|