@xtia/jel 0.4.3 → 0.4.4

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.
Files changed (2) hide show
  1. package/index.d.ts +12 -12
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -1,8 +1,6 @@
1
1
  export type ElementClassDescriptor = string | Record<string, boolean> | ElementClassDescriptor[];
2
2
  export type DOMContent = number | null | string | Element | JelEntity<object> | Text | DOMContent[];
3
3
  export type DomEntity<T extends HTMLElement> = JelEntity<ElementAPI<T>>;
4
- export type ContainerDomEntity = DomEntity<ContainerElement>;
5
- type ContainerElement = HTMLElementTagNameMap[Exclude<keyof HTMLElementTagNameMap, ContentlessTag>];
6
4
  type PartConstructor<Spec, API extends object | void, EventDataMap> = (spec: Spec & EventSpec<EventDataMap>) => JelEntity<EventHost<API, EventDataMap>>;
7
5
  type EventSpec<EventDataMap> = EventDataMap extends object ? {
8
6
  on?: {
@@ -20,9 +18,11 @@ type StylesDescriptor = {
20
18
  ] extends [string, string] ? K : never]+?: CSSValue;
21
19
  };
22
20
  type StyleAccessor = StylesDescriptor & ((styles: StylesDescriptor) => void) & ((property: keyof StylesDescriptor, value: CSSValue) => void);
23
- type ContentlessTag = "area" | "base" | "basefont" | "br" | "col" | "frame" | "hr" | "img" | "input" | "isindex" | "link" | "meta" | "param" | "textarea";
21
+ type ContentlessTag = "area" | "br" | "hr" | "iframe" | "input" | "textarea" | "img" | "canvas" | "link" | "meta";
24
22
  type TagWithHref = "a" | "link";
25
23
  type TagWithSrc = "img" | "script" | "iframe" | "video" | "audio";
24
+ type TagWithValue = "input" | "textarea";
25
+ type ContentlessElement = HTMLElementTagNameMap[ContentlessTag];
26
26
  type ElementDescriptor<Tag extends string> = {
27
27
  classes?: ElementClassDescriptor;
28
28
  attribs?: Record<string, string | number | boolean>;
@@ -31,13 +31,13 @@ type ElementDescriptor<Tag extends string> = {
31
31
  };
32
32
  style?: StylesDescriptor;
33
33
  cssVariables?: Record<string, CSSValue>;
34
- } & (Tag extends "input" | "textarea" ? {
34
+ } & (Tag extends TagWithValue ? {
35
35
  value?: string | number;
36
- } : Tag extends ContentlessTag ? {} : {
36
+ } : {}) & (Tag extends ContentlessTag ? {} : {
37
37
  content?: DOMContent;
38
38
  }) & (Tag extends TagWithSrc ? {
39
39
  src?: string;
40
- } : Tag extends TagWithHref ? {
40
+ } : {}) & (Tag extends TagWithHref ? {
41
41
  href?: string;
42
42
  } : {});
43
43
  type ElementAPI<T extends HTMLElement> = EventHost<{
@@ -47,7 +47,6 @@ type ElementAPI<T extends HTMLElement> = EventHost<{
47
47
  [key: string]: string | null;
48
48
  };
49
49
  style: StyleAccessor;
50
- innerHTML: string;
51
50
  setCSSVariable(table: Record<string, CSSValue>): void;
52
51
  setCSSVariable(variableName: string, value: CSSValue): void;
53
52
  qsa(selector: string): (Element | DomEntity<HTMLElement>)[];
@@ -55,19 +54,20 @@ type ElementAPI<T extends HTMLElement> = EventHost<{
55
54
  getRect(): DOMRect;
56
55
  focus(): void;
57
56
  blur(): void;
58
- } & (T extends ContainerElement ? {
57
+ } & (T extends ContentlessElement ? {} : {
59
58
  append(...content: DOMContent[]): void;
59
+ innerHTML: string;
60
60
  content: DOMContent;
61
- } : {}) & (T extends HTMLInputElement ? {
61
+ }) & (T extends HTMLElementTagNameMap[TagWithValue] ? {
62
62
  value: string;
63
63
  select(): void;
64
- } : T extends HTMLCanvasElement ? {
64
+ } : {}) & (T extends HTMLCanvasElement ? {
65
65
  width: number;
66
66
  height: number;
67
67
  getContext: HTMLCanvasElement["getContext"];
68
- } : T extends HTMLElementTagNameMap[TagWithSrc] ? {
68
+ } : {}) & (T extends HTMLElementTagNameMap[TagWithSrc] ? {
69
69
  src: string;
70
- } : T extends HTMLElementTagNameMap[TagWithHref] ? {
70
+ } : {}) & (T extends HTMLElementTagNameMap[TagWithHref] ? {
71
71
  href: string;
72
72
  } : {}) & (T extends HTMLMediaElement ? {
73
73
  play(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xtia/jel",
3
- "version": "0.4.3",
3
+ "version": "0.4.4",
4
4
  "repository": {
5
5
  "url": "https://github.com/tiadrop/jel-ts",
6
6
  "type": "github"