@tempots/dom 10.0.28 → 11.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.
Files changed (41) hide show
  1. package/README.md +2 -0
  2. package/dom/handle-anchor-click.d.ts +5 -4
  3. package/dom/ssr.d.ts +2 -2
  4. package/index.cjs +1 -1
  5. package/index.js +254 -229
  6. package/mountable/appearance.d.ts +5 -6
  7. package/mountable/async.d.ts +5 -5
  8. package/mountable/attribute.d.ts +435 -431
  9. package/mountable/autofocus.d.ts +2 -2
  10. package/mountable/autoselect.d.ts +2 -2
  11. package/mountable/bind.d.ts +5 -5
  12. package/mountable/conjunction.d.ts +5 -5
  13. package/mountable/consumers.d.ts +5 -5
  14. package/mountable/ctx.d.ts +2 -2
  15. package/mountable/element.d.ts +227 -227
  16. package/mountable/empty.d.ts +2 -2
  17. package/mountable/ensure.d.ts +2 -2
  18. package/mountable/foreach.d.ts +2 -2
  19. package/mountable/fragment.d.ts +2 -2
  20. package/mountable/handler.d.ts +89 -89
  21. package/mountable/hidden-when-empty.d.ts +2 -2
  22. package/mountable/inviewport.d.ts +3 -3
  23. package/mountable/map-signal.d.ts +2 -2
  24. package/mountable/not-empty.d.ts +2 -2
  25. package/mountable/ondispose.d.ts +2 -2
  26. package/mountable/oneof.d.ts +9 -9
  27. package/mountable/onmount.d.ts +2 -2
  28. package/mountable/portal.d.ts +2 -2
  29. package/mountable/providers.d.ts +6 -6
  30. package/mountable/render.d.ts +3 -3
  31. package/mountable/repeat.d.ts +2 -2
  32. package/mountable/size.d.ts +3 -3
  33. package/mountable/style.d.ts +499 -499
  34. package/mountable/task.d.ts +5 -5
  35. package/mountable/text.d.ts +4 -4
  36. package/mountable/when.d.ts +3 -3
  37. package/package.json +22 -6
  38. package/std/signal.d.ts +24 -7
  39. package/types/css-styles.d.ts +1 -2
  40. package/types/domain.d.ts +2 -2
  41. package/types/html-attributes.d.ts +2 -1
@@ -1,7 +1,7 @@
1
- import { Child, Mountable } from '../types/domain';
1
+ import { TNode, Renderable } from '../types/domain';
2
2
 
3
3
  export declare const Task: <T>(task: () => Promise<T>, options: {
4
- pending?: Child;
5
- then: (value: T) => Child;
6
- error?: (error: unknown) => Child;
7
- } | ((value: T) => Child)) => Mountable;
4
+ pending?: TNode;
5
+ then: (value: T) => TNode;
6
+ error?: (error: unknown) => TNode;
7
+ } | ((value: T) => TNode)) => Renderable;
@@ -1,6 +1,6 @@
1
- import { Mountable } from '../types/domain';
1
+ import { Renderable } from '../types/domain';
2
2
  import { Signal, Value } from '../std/signal';
3
3
 
4
- export declare const staticText: (text: string) => Mountable;
5
- export declare const signalText: (signal: Signal<string>) => Mountable;
6
- export declare function Text(value: Value<string>): Mountable;
4
+ export declare const staticText: (text: string) => Renderable;
5
+ export declare const signalText: (signal: Signal<string>) => Renderable;
6
+ export declare function Text(value: Value<string>): Renderable;
@@ -1,4 +1,4 @@
1
- import { Child, Signal } from '..';
1
+ import { TNode, Signal } from '..';
2
2
 
3
- export declare const When: (condition: Signal<boolean>, then: Child, otherwise?: Child) => import('..').Mountable;
4
- export declare const Unless: (condition: Signal<boolean>, then: Child, otherwise?: Child) => import('..').Mountable;
3
+ export declare const When: (condition: Signal<boolean>, then: TNode, otherwise?: TNode) => import('..').Renderable;
4
+ export declare const Unless: (condition: Signal<boolean>, then: TNode, otherwise?: TNode) => import('..').Renderable;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tempots/dom",
3
- "version": "10.0.28",
3
+ "version": "11.0.0",
4
4
  "type": "module",
5
5
  "main": "./index.cjs",
6
6
  "module": "./index.js",
@@ -12,12 +12,28 @@
12
12
  }
13
13
  },
14
14
  "license": "Apache-2.0",
15
- "repository": {
16
- "type": "git",
17
- "url": "git+https://github.com/fponticelli/tempots.git"
18
- },
15
+ "description": "Fully-typed frontend framework alternative to React and Angular",
16
+ "keywords": [
17
+ "tempo",
18
+ "tempots",
19
+ "ui",
20
+ "framework",
21
+ "typescript",
22
+ "dom",
23
+ "angular-alternative",
24
+ "react-alternative"
25
+ ],
26
+ "homepage": "https://github.com/fponticelli/tempots",
19
27
  "bugs": {
20
28
  "url": "https://github.com/fponticelli/tempots/issues"
21
29
  },
22
- "homepage": "https://github.com/fponticelli/tempots#readme"
30
+ "author": {
31
+ "name": "Franco Ponticelli",
32
+ "email": "franco.ponticelli@gmail.com",
33
+ "url": "https://github.com/fponticelli"
34
+ },
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "git+https://github.com/fponticelli/tempots.git"
38
+ }
23
39
  }
package/std/signal.d.ts CHANGED
@@ -1,6 +1,10 @@
1
- declare const $isSignal: unique symbol;
2
- declare const $isProp: unique symbol;
3
- declare const $isComputed: unique symbol;
1
+ declare const $isSignal = "$__signal__";
2
+ declare const $isProp = "$__prop__";
3
+ declare const $isComputed = "$__computed__";
4
+ export type AnySignal<T = any> = Signal<T> | Prop<T> | Computed<T>;
5
+ /**
6
+ * @category Signal Implementation
7
+ */
4
8
  export declare class Signal<T> {
5
9
  readonly equals: (a: T, b: T) => boolean;
6
10
  static ofPromise<T>(promise: Promise<T>, init: T, recover?: (error: unknown) => T, equals?: (a: T, b: T) => boolean): Signal<T>;
@@ -28,6 +32,7 @@ export declare class Signal<T> {
28
32
  readonly flatMap: <U>(fn: (value: T) => Signal<U>, equals?: (a: U, b: U) => boolean) => Computed<U>;
29
33
  readonly tap: (fn: (value: T) => void) => Computed<T>;
30
34
  readonly at: <K extends keyof T>(key: K) => Signal<T[K]>;
35
+ readonly $: { [K in keyof T]: Signal<T[K]>; };
31
36
  readonly filter: (fn: (value: T) => boolean, startValue?: T) => Computed<T>;
32
37
  readonly filterMap: <U>(fn: (value: T) => U | undefined | null, startValue: U, equals?: (a: U, b: U) => boolean) => Computed<U>;
33
38
  readonly mapAsync: <U>(fn: (value: T) => Promise<U>, alt: U, recover?: (error: unknown) => U, equals?: (a: U, b: U) => boolean) => Prop<U>;
@@ -37,6 +42,9 @@ export declare class Signal<T> {
37
42
  readonly count: () => Computed<number>;
38
43
  readonly setDerivative: <U>(computed: Computed<U>) => void;
39
44
  }
45
+ /**
46
+ * @category Signal Implementation
47
+ */
40
48
  export declare class Computed<T> extends Signal<T> {
41
49
  private readonly _fn;
42
50
  static is<T = unknown>(value: unknown): value is Computed<T>;
@@ -49,19 +57,28 @@ export declare class Computed<T> extends Signal<T> {
49
57
  readonly get: () => T;
50
58
  get value(): T;
51
59
  }
60
+ export type ReducerEffect<S, A> = (data: {
61
+ previousState: S;
62
+ state: S;
63
+ action: A;
64
+ dispatch: (action: A) => void;
65
+ }) => void;
66
+ /**
67
+ * @category Signal Implementation
68
+ */
52
69
  export declare class Prop<T> extends Signal<T> {
53
70
  static is<T = unknown>(value: unknown): value is Prop<T>;
54
71
  protected readonly [$isProp] = true;
55
72
  readonly set: (value: T) => void;
56
73
  readonly update: (fn: (value: T) => T) => void;
57
- readonly reducer: <U>(fn: (acc: T, value: U) => T) => (action: U) => void;
74
+ readonly reducer: <A>(fn: (acc: T, value: A) => T, ...effects: ReducerEffect<T, A>[]) => (action: A) => void;
58
75
  readonly iso: <U>(to: (value: T) => U, from: (value: U) => T, equals?: (a: U, b: U) => boolean) => Prop<U>;
59
76
  readonly atProp: <K extends keyof T>(key: K) => Prop<T[K]>;
60
77
  get value(): T;
61
78
  set value(value: T);
62
79
  }
63
- export declare function computed<T>(fn: () => T, signals: Array<Signal<any>>, equals?: (a: T, b: T) => boolean): Computed<T>;
64
- export declare function effect(fn: () => void, signals: Array<Signal<any>>): () => void;
80
+ export declare function computed<T>(fn: () => T, signals: Array<AnySignal>, equals?: (a: T, b: T) => boolean): Computed<T>;
81
+ export declare function effect(fn: () => void, signals: Array<AnySignal>): () => void;
65
82
  export declare function prop<T>(value: T, equals?: (a: T, b: T) => boolean): Prop<T>;
66
83
  export declare function signal<T>(value: T, equals?: (a: T, b: T) => boolean): Signal<T>;
67
84
  export declare class MemoryStore {
@@ -97,7 +114,7 @@ export declare function propOfSessionStorage<T>(options: {
97
114
  equals?: (a: T, b: T) => boolean;
98
115
  onLoad?: (value: T) => T;
99
116
  }): Prop<T>;
100
- export declare function animate<T>(initialValue: T, fn: () => T, signals: Array<Signal<any>>, options?: {
117
+ export declare function animate<T>(initialValue: T, fn: () => T, signals: Array<AnySignal>, options?: {
101
118
  interpolate?: (start: T, end: T, delta: number) => T;
102
119
  duration?: Value<number>;
103
120
  easing?: (t: number) => number;
@@ -1,3 +1,2 @@
1
- type ExcludeFromStyle = 'getPropertyPriority' | 'getPropertyValue' | 'item' | 'removeProperty' | 'setProperty' | 'parentRule' | 'length' | 'name' | number;
1
+ export type ExcludeFromStyle = 'getPropertyPriority' | 'getPropertyValue' | 'item' | 'removeProperty' | 'setProperty' | 'parentRule' | 'length' | 'name' | number;
2
2
  export type CSSStyles = Omit<CSSStyleDeclaration, ExcludeFromStyle>;
3
- export {};
package/types/domain.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { DOMContext } from '../dom/dom-context';
2
2
  import { Value } from '../std/signal';
3
3
 
4
- export type Mountable = (ctx: DOMContext) => Clear;
5
- export type Child = Mountable | Value<string> | undefined | null | Mountable[];
4
+ export type Renderable = (ctx: DOMContext) => Clear;
5
+ export type TNode = Renderable | Value<string> | undefined | null | Renderable[];
6
6
  export type Clear = (removeTree: boolean) => void;
7
7
  export type ProviderMark<T> = symbol & {
8
8
  readonly __type: T;
@@ -77,6 +77,7 @@ export type HTMLAttributes = {
77
77
  rel: string;
78
78
  required: string;
79
79
  reversed: string;
80
+ role: string;
80
81
  rows: number;
81
82
  rowspan: number;
82
83
  sandbox: string;
@@ -100,7 +101,7 @@ export type HTMLAttributes = {
100
101
  target: string;
101
102
  title: string;
102
103
  translate: string;
103
- type: InputTypes;
104
+ type: string;
104
105
  usemap: string;
105
106
  value: string;
106
107
  valueAsNumber: number;