dothtml-interfaces 6.0.4 → 6.0.6

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dothtml-interfaces",
3
- "version": "6.0.4",
3
+ "version": "6.0.6",
4
4
  "description": "Dependency injection interfaces for DOTHtml.",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -1,5 +1,9 @@
1
1
  import { IWatcher } from "./i-watcher";
2
+ import { DotContent } from "../i-dot";
2
3
 
3
4
  export interface IRef<T = any> extends IWatcher<T | null> {
4
5
  get element(): T;
6
+ ready(): Promise<T>;
7
+ append(content: DotContent): this;
8
+ prepend(content: DotContent): this;
5
9
  }
package/src/i-dot.ts CHANGED
@@ -6,9 +6,10 @@ import {IReactive} from "./bindings/i-reactive";
6
6
  import { IBinding } from "./bindings/i-binding";
7
7
  import { IWatcher } from "./bindings/i-watcher";
8
8
  import IDotcssProp from "./styles/i-css-prop";
9
+ import { IDotStyleBuilder } from "./styles/i-dot-style-builder";
9
10
  import { IRef } from "./bindings/i-ref";
10
11
 
11
- type DotContentPrimitive = string | number | boolean | undefined | null;
12
+ export type DotContentPrimitive = string | number | boolean | undefined | null;
12
13
  type DotContentBasic = DotContentPrimitive | Node | Element | NodeList | IDotComponent | IDotDocument//typeof DotDocument;
13
14
  export type DotContent = DotContentBasic | Array<DotContent> | IReactive;//|(()=>DotContent);
14
15
 
@@ -51,19 +52,27 @@ export interface IDotDocument {
51
52
  /**
52
53
  * Creates a generic HTML node that can render a string, HTML nodes, or dotHTML content.
53
54
  */
54
- html(content: string | number | boolean | IReactive): IDotDocument;
55
+ html(content: DotContent): IDotDocument;
55
56
  /**
56
57
  * Creates a text node that will render as a string, rather than being parsed as markup.
57
58
  */
58
- text(content: string | number | boolean | IReactive): IDotDocument;
59
+ text(content: DotContent): IDotDocument;
59
60
  /**
60
61
  * Creates a text node that will render as a string, rather than being parsed as markup.
61
62
  */
62
- md(content: string | number | boolean | IReactive): IDotDocument;
63
+ md(content: DotContent): IDotDocument;
63
64
  /**
64
- * Mounts a component.
65
+ * Mounts a component or appends content.
65
66
  */
66
- mount<T extends IDotComponent>(component: T, ...args: any[]): IDotDocument;
67
+ mount(content: DotContent, ...args: any[]): IDotDocument;
68
+ /**
69
+ * Appends content to the current document.
70
+ */
71
+ append(content: DotContent): this;
72
+ /**
73
+ * Prepends content to the current document.
74
+ */
75
+ prepend(content: DotContent): this;
67
76
  slot(name?: string | any, fallback?: any): IDotDocument;
68
77
  // mount<T extends IComponent>(init: (c: IMountedComponent<T>) => IMountedComponent<T> | void, component: T): IDotDocument;
69
78
  // mount(component: IComponent, init: (init=>IMountedComponent): IMountedComponent|void): IDotDocument;
@@ -86,7 +95,7 @@ export interface IDotDocument {
86
95
  */
87
96
  remove(): void;
88
97
 
89
- style(c: string | ISignal<any> | IBinding<any, any> | IDotCss | ((s: IDotCss) => void)): this;
98
+ style(c: string | ISignal<any> | IBinding<any, any> | IDotcssProp | IDotStyleBuilder | ((s: IDotStyleBuilder) => void)): this;
90
99
  attr(name: string, value: any): this;
91
100
  on(event: string, callback: (e: any) => void): this;
92
101
  onEnter(callback: (el: HTMLElement) => void): this;
@@ -452,7 +461,7 @@ export interface IDotGlobalAttrs<T extends HTMLElement = HTMLElement> {
452
461
  part?: AttrVal<string>;
453
462
  role?: AttrVal<string>;
454
463
  spellCheck?: AttrVal<"true"> | AttrVal<"false">;
455
- style?: AttrVal<string> | IDotcssProp | ((s: IDotCss) => void);
464
+ style?: AttrVal<string> | IDotcssProp | IDotStyleBuilder | ((s: IDotStyleBuilder) => void);
456
465
  tabIndex?: AttrVal<number>;
457
466
  title?: AttrVal<string>;
458
467
  translate?: AttrVal<string>;
package/src/index.ts CHANGED
@@ -4,6 +4,8 @@ export * from "./i-dot";
4
4
 
5
5
  export { default as IDotCss } from "./styles/i-dot-css";
6
6
  export * from "./styles/i-dot-css";
7
+ export { default as IDotcssProp } from "./styles/i-css-prop";
8
+ export { IDotStyleBuilder } from "./styles/i-dot-style-builder";
7
9
 
8
10
 
9
11
  export { default as IDotComponent, FrameworkItems } from "./i-dot-component";
@@ -6,6 +6,7 @@ import IAtFontPaletteValues from "./at-rules/i-at-font-palette-values";
6
6
  import IAtKeyframesBuilder from "./at-rules/i-at-keyframes-builder";
7
7
  import IAtPageBuilder from "./at-rules/i-at-page-builder";
8
8
  import IDotcssProp from "./i-css-prop";
9
+ import { IDotStyleBuilder } from "./i-dot-style-builder";
9
10
 
10
11
 
11
12
 
@@ -148,7 +149,7 @@ type Flex = `${number}fr`;
148
149
  // type FlexFlowShorthand = BasicCommonValues|`${FlexDirectionNames} ${FlexWrapNames}`;
149
150
  // type FlexShorthand = BasicCommonValues|`${BasicCommonValues|number} ${BasicCommonValues|number} ${BasicCommonValues|`${number}${AllLengthUnits}`}`;
150
151
 
151
- export default interface IDotCss extends IDotcssProp{
152
+ export default interface IDotCss extends IDotStyleBuilder{
152
153
  // TODO: ensure each of these has test cases.
153
154
  // Right now, most of these don't actually work. But they're typed so that they can progressively be added to the librrary.
154
155
  (selector: "@charset", charset: string): void;
@@ -177,10 +178,6 @@ export default interface IDotCss extends IDotcssProp{
177
178
  (selector: Array<HTMLElement>|HTMLElement|string, styles: IDotcssProp): void;
178
179
  (styles: IDotcssProp): void;
179
180
 
180
- variable(name: string, value: any): this;
181
- v(name: string): string;
182
- [prop: string]: any;
183
-
184
181
  version: string;
185
182
  }
186
183
 
@@ -0,0 +1,13 @@
1
+ import IDotcssProp from "./i-css-prop";
2
+
3
+ /**
4
+ * A fluent builder for CSS properties.
5
+ * Transforms all properties from IDotcssProp into methods that return the builder.
6
+ */
7
+ export type IDotStyleBuilder = {
8
+ [K in keyof IDotcssProp]-?: (value: Exclude<IDotcssProp[K], undefined>) => IDotStyleBuilder;
9
+ } & {
10
+ variable(name: string, value: any): IDotStyleBuilder;
11
+ v(name: string): string;
12
+ [prop: string]: any;
13
+ };