dothtml-interfaces 0.4.1 → 0.4.2
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/package.json +1 -1
- package/src/i-dot.d.ts +10 -10
- package/src/i-reactive.d.ts +19 -9
- package/src/styles/css-types.d.ts +3 -3
- package/src/styles/i-css-prop.d.ts +2 -2
- package/src/styles/mapped-types/angle-prop.d.ts +2 -2
- package/src/styles/mapped-types/color-props.d.ts +3 -3
- package/src/styles/mapped-types/length-prop.d.ts +2 -2
package/package.json
CHANGED
package/src/i-dot.d.ts
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
import IDotComponent from "./i-dot-component";
|
|
3
3
|
import IDotCss from "./styles/i-dot-css";
|
|
4
4
|
import IEventBus from "./i-event-bus";
|
|
5
|
-
import {IBoundReactive, IReactive} from "./i-reactive";
|
|
5
|
+
import {AnyReactive, IBoundReactive, IReactive} from "./i-reactive";
|
|
6
6
|
import IDotcssProp from "./styles/i-css-prop";
|
|
7
7
|
|
|
8
8
|
type DotContentPrimitive = string | number | boolean;
|
|
9
9
|
type DotContentBasic = DotContentPrimitive | Node | Element | NodeList | IDotComponent | IDotDocument//typeof DotDocument;
|
|
10
|
-
export type DotContent = DotContentBasic | Array<DotContent> |
|
|
10
|
+
export type DotContent = DotContentBasic | Array<DotContent> | AnyReactive;//|(()=>DotContent);
|
|
11
11
|
|
|
12
|
-
type AttrVal<T = string | number | boolean> = T |
|
|
12
|
+
type AttrVal<T = string | number | boolean> = T | AnyReactive;
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Global interface containing elements.
|
|
@@ -25,7 +25,7 @@ export interface IDotDocument {
|
|
|
25
25
|
/**
|
|
26
26
|
* A conditional function, analogous to if. Renders the specified DOT if a condition is met. Dynamic binding is possible when condition and callback are functions.
|
|
27
27
|
*/
|
|
28
|
-
when(condition:
|
|
28
|
+
when(condition: AnyReactive | boolean, DotContent): IDotConditionalDocument;
|
|
29
29
|
|
|
30
30
|
// Main functions.
|
|
31
31
|
// TODO: please make this into a test case.
|
|
@@ -46,11 +46,11 @@ export interface IDotDocument {
|
|
|
46
46
|
/**
|
|
47
47
|
* Creates a generic HTML node that can render a string, HTML nodes, or dotHTML content.
|
|
48
48
|
*/
|
|
49
|
-
html(content: string | number | boolean |
|
|
49
|
+
html(content: string | number | boolean | AnyReactive): IDotDocument;
|
|
50
50
|
/**
|
|
51
51
|
* Creates a text node that will render as a string, rather than being parsed as markup.
|
|
52
52
|
*/
|
|
53
|
-
text(content: string | number | boolean |
|
|
53
|
+
text(content: string | number | boolean | AnyReactive): IDotDocument;
|
|
54
54
|
/**
|
|
55
55
|
* Mounts a component.
|
|
56
56
|
* TODO: add second arg.
|
|
@@ -65,7 +65,7 @@ export interface IDotDocument {
|
|
|
65
65
|
*/
|
|
66
66
|
iterate(n: number, callback: (i: number) => DotContent): IDotDocument;
|
|
67
67
|
each<T>(a: Array<T> | { [key: string | number]: T }, callback: (x: T, i: number, k: string | number) => DotContent): IDotDocument;
|
|
68
|
-
each<T>(a: IBoundReactive<any, Array<T> | { [key: string | number]: T }>, callback: (x: T, i: IBoundReactive<number>, k: string | number) => DotContent): IDotDocument;
|
|
68
|
+
each<T>(a: IReactive<Array<T>>|IBoundReactive<any, Array<T> | { [key: string | number]: T }>, callback: (x: T, i: IBoundReactive<number>, k: string | number) => DotContent): IDotDocument;
|
|
69
69
|
|
|
70
70
|
/**
|
|
71
71
|
* Removes the targeted document and everything in it.
|
|
@@ -372,7 +372,7 @@ export interface IDotCore extends IDotDocument {
|
|
|
372
372
|
bus: IEventBus;
|
|
373
373
|
window: IDotWindowBuilder;
|
|
374
374
|
|
|
375
|
-
watch<Ti =
|
|
375
|
+
watch<Ti = AnyReactive | Array<any> | { [key: string | number]: any } | string | number | boolean>(initValue?: Ti, key?: (Ti extends Array<any> | { [key: string | number]: any } ? string : never)): IReactive<Ti>;
|
|
376
376
|
|
|
377
377
|
// Keep these around for a bit to show how it was done before in case I need to change anything prior to the v6 launch.
|
|
378
378
|
// component<T extends IComponent>(Base: new (...args: Parameters<T['build']>) => T): new (...args: Parameters<T['build']>) => T;
|
|
@@ -407,7 +407,7 @@ export interface IDotConditionalDocument extends IDotDocument {
|
|
|
407
407
|
* A conditional catch, analogous to else if. Can be used after a when function. Evaluates if the previous when's condition was false.
|
|
408
408
|
* Renders the specified DOT if a condition is met. Dynamic binding is possible when condition and callback are functions.
|
|
409
409
|
*/
|
|
410
|
-
otherwiseWhen(condition:
|
|
410
|
+
otherwiseWhen(condition: AnyReactive | boolean, callback: DotContent): IDotConditionalDocument;
|
|
411
411
|
/**
|
|
412
412
|
* A conditional final catch, analogous to else. Can be used after a when or otherwiseWhen function. Evaluates if the previous when/otherwiseWhen evaluated to false.
|
|
413
413
|
* Renders the specified DOT if a condition is met. Dynamic binding is possible when callback is a function.
|
|
@@ -995,7 +995,7 @@ interface IDotTrack extends IDotGlobalAttrs {
|
|
|
995
995
|
|
|
996
996
|
interface IDotVideo extends IDotGlobalAttrs {
|
|
997
997
|
autoPlay?: AttrVal<boolean>;
|
|
998
|
-
buffered?:
|
|
998
|
+
buffered?: AnyReactive; // Managed by browser not user. TODO: we can possibly use events to update observable objects.
|
|
999
999
|
controls?: AttrVal<boolean>;
|
|
1000
1000
|
crossOrigin?: AttrVal<"anonymous"> | AttrVal<"use-credentials">;
|
|
1001
1001
|
height?: AttrVal<number>;
|
package/src/i-reactive.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
|
|
2
|
-
export interface IReactive<T = any>
|
|
3
|
-
// The untransformed value.
|
|
4
|
-
_value: T;
|
|
2
|
+
export interface IReactive<T = any>{
|
|
5
3
|
// Get the value.
|
|
6
|
-
|
|
4
|
+
get value(): T;
|
|
7
5
|
// Set the value.
|
|
8
|
-
|
|
6
|
+
set value(v: T|null|undefined);
|
|
9
7
|
|
|
10
8
|
// Key is used for observable array proxy bindings.
|
|
11
9
|
// If a key is provided, it's used to uniquely identify array elements.
|
|
@@ -13,14 +11,24 @@ export interface IReactive<T = any> extends IBoundReactive<T, T>{
|
|
|
13
11
|
key: string;
|
|
14
12
|
// subscribeNode(node: Node): number;
|
|
15
13
|
// subscribeAttr(node: HTMLElement, attributeName: string): number;
|
|
16
|
-
subscribeCallback(callback: (value: T)=>void): number;
|
|
17
|
-
detachBinding(id: number);
|
|
14
|
+
// subscribeCallback(callback: (value: T)=>void): number;
|
|
15
|
+
// detachBinding(id: number);
|
|
16
|
+
|
|
17
|
+
_subscribe(boundReactive: IBoundReactive, item: any);
|
|
18
|
+
_detachBinding(id: number);
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Called manually by the user to trigger an update.
|
|
22
|
+
* Useful for arrays and objects.
|
|
23
|
+
*/
|
|
18
24
|
updateObservers(): void;
|
|
19
25
|
|
|
20
26
|
bindAs<Td = string>(transform: {
|
|
21
27
|
display?: (v: T)=>Td;
|
|
22
28
|
read?: (v: string)=>T;
|
|
23
29
|
}): IBoundReactive<T, Td>;
|
|
30
|
+
|
|
31
|
+
bind(): IBoundReactive<T>;
|
|
24
32
|
}
|
|
25
33
|
|
|
26
34
|
export interface IReactiveWatcher<T = any>{
|
|
@@ -30,5 +38,7 @@ export interface IReactiveWatcher<T = any>{
|
|
|
30
38
|
export interface IBoundReactive<T = any, Td = T>{
|
|
31
39
|
_source: IReactive<T>;
|
|
32
40
|
_get: ()=>Td;
|
|
33
|
-
_set: (v: string)=>void;
|
|
34
|
-
}
|
|
41
|
+
_set: (v: string|number|boolean)=>void;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type AnyReactive = IBoundReactive|IReactive;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { IBoundReactive } from "../i-reactive";
|
|
1
|
+
import { IBoundReactive, IReactive } from "../i-reactive";
|
|
2
2
|
|
|
3
3
|
// Global keyword values.
|
|
4
|
-
export type GKV = IBoundReactive<string>|"inherit"|"initial"|"unset"|"revert"|"revert-layer";
|
|
4
|
+
export type GKV = IReactive<string>|IBoundReactive<any, string>|"inherit"|"initial"|"unset"|"revert"|"revert-layer";
|
|
5
5
|
|
|
6
6
|
export type ComplexType = string;
|
|
7
7
|
|
|
8
|
-
export type ValueOrReactive<T> = T|IBoundReactive<T>;
|
|
8
|
+
export type ValueOrReactive<T> = T|IBoundReactive<any, T>|IReactive<T>;
|
|
9
9
|
|
|
10
10
|
// BASIC TYPES
|
|
11
11
|
export type Str = `"${string|""}"`|`'${string|""}'`; // TODO: wherever str is required, we could just inject quotes...
|
|
@@ -5,7 +5,7 @@ import IShadowProp from "./complex-css-types/i-shadow-prop";
|
|
|
5
5
|
import ITransformationProp from "./complex-css-types/i-transformation-prop";
|
|
6
6
|
import ColorProp from "./mapped-types/color-props";
|
|
7
7
|
import LengthProp from "./mapped-types/length-prop";
|
|
8
|
-
import { IBoundReactive } from "../i-reactive";
|
|
8
|
+
import { IBoundReactive, IReactive } from "../i-reactive";
|
|
9
9
|
|
|
10
10
|
type BackgroundPositionShorthand2D = string;
|
|
11
11
|
type BackgroundRepeatValues2d = "no-repeat"|"repeat"|"space"|"round";
|
|
@@ -93,7 +93,7 @@ export default interface IDotcssProp extends
|
|
|
93
93
|
|
|
94
94
|
background?: GKV|string; // TODO: shorthand. Requires advanced typing.
|
|
95
95
|
backgroundAttachment?: GKV|"scroll"|"fixed"|"local"; // ✔️
|
|
96
|
-
backgroundBlendMode?: GKV|Array<IBoundReactive<string>|"darken"|"luminocity"|"normal">; // ✔️
|
|
96
|
+
backgroundBlendMode?: GKV|Array<IBoundReactive<any, string>|IReactive<string>|"darken"|"luminocity"|"normal">; // ✔️
|
|
97
97
|
backgroundPosition?: GKV|BackgroundPositionShorthand2D;
|
|
98
98
|
backgroundRepeat?: GKV|BackgroundRepeatValues2d;
|
|
99
99
|
backgroundClip?: GKV|string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IBoundReactive } from "../../i-reactive";
|
|
1
|
+
import { IBoundReactive, IReactive } from "../../i-reactive";
|
|
2
2
|
|
|
3
|
-
type V = IBoundReactive<number|string> | number | string;
|
|
3
|
+
type V = IBoundReactive<any, number|string>| IReactive<number|string> | number | string;
|
|
4
4
|
|
|
5
5
|
type ColorUnitSuffix = ""
|
|
6
6
|
| "Rgb"
|
|
@@ -20,7 +20,7 @@ type SpecialColors = "currentcolor"|"transparent";
|
|
|
20
20
|
|
|
21
21
|
type ColorProp<Prefix extends string> = {
|
|
22
22
|
[Key in ColorUnitSuffix as `${Prefix}${Key}`]?: (
|
|
23
|
-
(Key extends "" ? IBoundReactive<string> | NamedColor | SystemColor | SpecialColors | `#${string}` | `${"rgb"|"rgba"|"hsl"|"hsla"|"hwb"|"lab"|"lch"|"oklab"|"oklch"|"color"}(${string})` : void) |
|
|
23
|
+
(Key extends "" ? IBoundReactive<any, string> | IReactive<string> | NamedColor | SystemColor | SpecialColors | `#${string}` | `${"rgb"|"rgba"|"hsl"|"hsla"|"hwb"|"lab"|"lch"|"oklab"|"oklch"|"color"}(${string})` : void) |
|
|
24
24
|
(Key extends "Rgb" | "Hsl" | "HslDeg" | "HslGrad" | "HslRad" | "HslTurn" | "Hwb" | "HwbDeg" | "HwbGrad" | "HwbRad" | "HwbTurn" | "Lab" | "Lch" | "LchDeg" | "LchGrad" | "LchRad" | "LchTurn" | "Oklch" | "OklchDeg" | "OklchGrad" | "OklchRad" | "OklchTurn" ? [V, V, V] | [V, V, V, V] : void) |
|
|
25
25
|
(Key extends "Srgb" | "SrgbLinear" | "DisplayP3" | "A98Rgb" | "ProphotoRgb" | "Rec2020" | "Xyz" | "XyzD50" | "XyzD65" ? [V, V, V] : void)
|
|
26
26
|
);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IBoundReactive } from "../../i-reactive";
|
|
1
|
+
import { AnyReactive, IBoundReactive } from "../../i-reactive";
|
|
2
2
|
import { GKV } from "../css-types";
|
|
3
3
|
// import { NumericLength } from "./css-types";
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@ type LengthUnitSuffix = "" | "Cm" | "Ch" | "Em" | "Ex" | "In" | "Mm" | "P" | "Pc
|
|
|
6
6
|
|
|
7
7
|
type V<S> = IBoundReactive<any> | number | S;
|
|
8
8
|
|
|
9
|
-
type LengthProp<Prefix extends string, Qty extends 1|2|3|4 = 1, S extends string|
|
|
9
|
+
type LengthProp<Prefix extends string, Qty extends 1|2|3|4 = 1, S extends string|AnyReactive = GKV> = {
|
|
10
10
|
[Key in LengthUnitSuffix as `${Prefix}${Key}`]?: (
|
|
11
11
|
(Qty extends 1 ? V<S>|[V<S>] : void) |
|
|
12
12
|
(Qty extends 2 ? [V<S>, V<S>] : void) |
|