dothtml-interfaces 0.3.14 → 0.4.1
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 +12 -12
- package/src/i-reactive.d.ts +16 -7
- package/src/index.d.ts +1 -1
- package/src/styles/css-types.d.ts +3 -3
- package/src/styles/i-css-prop.d.ts +2 -2
- package/src/styles/i-dot-css.d.ts +1 -8
- 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 +3 -3
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 {IReactive} from "./i-reactive";
|
|
5
|
+
import {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> | IBoundReactive;//|(()=>DotContent);
|
|
11
11
|
|
|
12
|
-
type AttrVal<T = string | number | boolean> = T |
|
|
12
|
+
type AttrVal<T = string | number | boolean> = T | IBoundReactive<any>;
|
|
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: IBoundReactive | 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 | IBoundReactive): 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 | IBoundReactive): 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:
|
|
68
|
+
each<T>(a: 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 = IBoundReactive | 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: IBoundReactive | 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.
|
|
@@ -432,7 +432,7 @@ export interface IDotGlobalAttrs {
|
|
|
432
432
|
// TODO: this needs to be redone now.
|
|
433
433
|
// The better way might be using the new reactive system instead of references.
|
|
434
434
|
// For now I'll leave it like this:
|
|
435
|
-
ref?: IReactive<HTMLElement>;
|
|
435
|
+
// ref?: IReactive<HTMLElement>;
|
|
436
436
|
|
|
437
437
|
/** @deprecated Deprecated in HTML5. Use CSS. */
|
|
438
438
|
bgColor?: AttrVal<unknown>;
|
|
@@ -763,8 +763,8 @@ interface IDotInput extends IDotGlobalAttrs {
|
|
|
763
763
|
src?: AttrVal<string>;
|
|
764
764
|
step?: AttrVal<string> | AttrVal<number>;
|
|
765
765
|
type?: "button" | "checkbox" | "color" | "date" | "datetime-local" | "email" | "file" | "hidden" | "image" | "month" | "number" | "password" | "radio" | "range" | "reset" | "search" | "submit" | "tel" | "text" | "time" | "url" | "week";
|
|
766
|
-
whichForm?: AttrVal<string>; // form
|
|
767
766
|
value?: AttrVal<string>;
|
|
767
|
+
whichForm?: AttrVal<string>; // form
|
|
768
768
|
width?: AttrVal<number>;
|
|
769
769
|
|
|
770
770
|
// Special functions:
|
|
@@ -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?: IBoundReactive<unknown>; // 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,25 +1,34 @@
|
|
|
1
1
|
|
|
2
|
-
export interface IReactive<
|
|
2
|
+
export interface IReactive<T = any> extends IBoundReactive<T, T>{
|
|
3
3
|
// The untransformed value.
|
|
4
|
-
_value:
|
|
4
|
+
_value: T;
|
|
5
5
|
// Get the value.
|
|
6
|
-
getValue():
|
|
6
|
+
getValue(): T;
|
|
7
7
|
// Set the value.
|
|
8
|
-
setValue(v:
|
|
8
|
+
setValue(v: T|null|undefined);
|
|
9
9
|
|
|
10
10
|
// Key is used for observable array proxy bindings.
|
|
11
11
|
// If a key is provided, it's used to uniquely identify array elements.
|
|
12
12
|
// If a key is not provided, identification is done automatically by the framework by comparing object references.
|
|
13
13
|
key: string;
|
|
14
|
-
// Optional transformer that can transform the input.
|
|
15
|
-
transform?: (input: Ti)=>To;
|
|
16
14
|
// subscribeNode(node: Node): number;
|
|
17
15
|
// subscribeAttr(node: HTMLElement, attributeName: string): number;
|
|
18
|
-
subscribeCallback(callback: (value:
|
|
16
|
+
subscribeCallback(callback: (value: T)=>void): number;
|
|
19
17
|
detachBinding(id: number);
|
|
20
18
|
updateObservers(): void;
|
|
19
|
+
|
|
20
|
+
bindAs<Td = string>(transform: {
|
|
21
|
+
display?: (v: T)=>Td;
|
|
22
|
+
read?: (v: string)=>T;
|
|
23
|
+
}): IBoundReactive<T, Td>;
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
export interface IReactiveWatcher<T = any>{
|
|
24
27
|
observerUpdate(value: T, obsreverId: number): void;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface IBoundReactive<T = any, Td = T>{
|
|
31
|
+
_source: IReactive<T>;
|
|
32
|
+
_get: ()=>Td;
|
|
33
|
+
_set: (v: string)=>void;
|
|
25
34
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -8,5 +8,5 @@ export * from "./styles/i-dot-css";
|
|
|
8
8
|
|
|
9
9
|
export { default as IDotComponent, FrameworkItems } from "./i-dot-component";
|
|
10
10
|
|
|
11
|
-
export { IReactive, IReactiveWatcher } from "./i-reactive";
|
|
11
|
+
export { IReactive, IReactiveWatcher, IBoundReactive } from "./i-reactive";
|
|
12
12
|
export { default as IEventBus } from "./i-event-bus";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IBoundReactive } from "../i-reactive";
|
|
2
2
|
|
|
3
3
|
// Global keyword values.
|
|
4
|
-
export type GKV =
|
|
4
|
+
export type GKV = IBoundReactive<string>|"inherit"|"initial"|"unset"|"revert"|"revert-layer";
|
|
5
5
|
|
|
6
6
|
export type ComplexType = string;
|
|
7
7
|
|
|
8
|
-
export type ValueOrReactive<T> = T|
|
|
8
|
+
export type ValueOrReactive<T> = T|IBoundReactive<T>;
|
|
9
9
|
|
|
10
10
|
// BASIC TYPES
|
|
11
11
|
export type Str = `"${string|""}"`|`'${string|""}'`; // TODO: wherever str is required, we could just inject quotes...
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
|
|
2
|
-
import { IReactive } from "../i-reactive";
|
|
3
2
|
import { GKV, ValueOrReactive } from "./css-types";
|
|
4
3
|
import IFilterProp from "./complex-css-types/i-filter-prop";
|
|
5
4
|
import IShadowProp from "./complex-css-types/i-shadow-prop";
|
|
6
5
|
import ITransformationProp from "./complex-css-types/i-transformation-prop";
|
|
7
6
|
import ColorProp from "./mapped-types/color-props";
|
|
8
7
|
import LengthProp from "./mapped-types/length-prop";
|
|
8
|
+
import { IBoundReactive } 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<
|
|
96
|
+
backgroundBlendMode?: GKV|Array<IBoundReactive<string>|"darken"|"luminocity"|"normal">; // ✔️
|
|
97
97
|
backgroundPosition?: GKV|BackgroundPositionShorthand2D;
|
|
98
98
|
backgroundRepeat?: GKV|BackgroundRepeatValues2d;
|
|
99
99
|
backgroundClip?: GKV|string;
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
// import { GKV, Color, ComplexType, Percentage } from "./css-types";
|
|
3
|
-
// import IDotcssProp from "./i-css-prop";
|
|
4
|
-
// import IFilterProp from "./i-filter-prop";
|
|
5
|
-
// import IShadowProp from "./i-shadow-prop";
|
|
6
|
-
// import { ITransformationProp } from "./i-transformation-prop";
|
|
7
|
-
// import ColorProp from "./mapped-types/color-props";
|
|
8
|
-
// import LengthProp from "./mapped-types/length-prop";
|
|
1
|
+
|
|
9
2
|
|
|
10
3
|
import IAtColorProfileBuilder from "./at-rules/i-at-color-profile-builder";
|
|
11
4
|
import IAtCounterStyleBuilder from "./at-rules/i-at-counter-style-builder";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IBoundReactive } from "../../i-reactive";
|
|
2
2
|
|
|
3
|
-
type V =
|
|
3
|
+
type V = IBoundReactive<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 "" ?
|
|
23
|
+
(Key extends "" ? IBoundReactive<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,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IBoundReactive } from "../../i-reactive";
|
|
2
2
|
import { GKV } from "../css-types";
|
|
3
3
|
// import { NumericLength } from "./css-types";
|
|
4
4
|
|
|
5
5
|
type LengthUnitSuffix = "" | "Cm" | "Ch" | "Em" | "Ex" | "In" | "Mm" | "P" | "Pc" | "Pt" | "Px" | "Rem" | "Vh" | "Vw" | "VMax" | "VMin";
|
|
6
6
|
|
|
7
|
-
type V<S> =
|
|
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|IBoundReactive<any> = 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) |
|