@lexriver/dome 1.5.10 → 2.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 (47) hide show
  1. package/out/{AnimatedArray.d.ts → src/AnimatedArray.d.mts} +29 -29
  2. package/out/{AnimatedArray.js → src/AnimatedArray.mjs} +52 -51
  3. package/out/{AnimatedTable.d.ts → src/AnimatedTable.d.mts} +38 -38
  4. package/out/{AnimatedTable.js → src/AnimatedTable.mjs} +88 -91
  5. package/out/{AnimatedText.d.ts → src/AnimatedText.d.mts} +13 -13
  6. package/out/{AnimatedText.js → src/AnimatedText.mjs} +24 -24
  7. package/out/{Animation.d.ts → src/Animation.d.mts} +4 -4
  8. package/out/{temp-test.d.ts → src/Animation.mjs} +1 -1
  9. package/out/{Dome.d.ts → src/Dome.d.mts} +9 -9
  10. package/out/{Dome.js → src/Dome.mjs} +291 -295
  11. package/out/{DomeComponent.d.ts → src/DomeComponent.d.mts} +22 -19
  12. package/out/{DomeComponent.js → src/DomeComponent.mjs} +47 -44
  13. package/out/{DomeManipulator.d.ts → src/DomeManipulator.d.mts} +48 -48
  14. package/out/{DomeManipulator.js → src/DomeManipulator.mjs} +329 -329
  15. package/out/src/DomeRouter.console-test.d.mts +1 -0
  16. package/out/{DomeRouter.console-test.js → src/DomeRouter.console-test.mjs} +44 -44
  17. package/out/{DomeRouter.d.ts → src/DomeRouter.d.mts} +30 -30
  18. package/out/{DomeRouter.js → src/DomeRouter.mjs} +236 -237
  19. package/out/{LongestCommonSubsequence.d.ts → src/LongestCommonSubsequence.d.mts} +15 -15
  20. package/out/{LongestCommonSubsequence.js → src/LongestCommonSubsequence.mjs} +164 -164
  21. package/out/src/index.d.mts +11 -0
  22. package/out/src/index.mjs +11 -0
  23. package/out/src/temp-test.d.mts +1 -0
  24. package/out/{temp-test.js → src/temp-test.mjs} +20 -20
  25. package/out/vitest.config.d.ts +2 -0
  26. package/out/vitest.config.js +9 -0
  27. package/package.json +16 -14
  28. package/src/{AnimatedArray.ts → AnimatedArray.mts} +3 -3
  29. package/src/{AnimatedTable.ts → AnimatedTable.mts} +6 -6
  30. package/src/{AnimatedText.ts → AnimatedText.mts} +4 -4
  31. package/src/{Dome.ts → Dome.mts} +7 -11
  32. package/src/{DomeComponent.ts → DomeComponent.mts} +3 -3
  33. package/src/{DomeManipulator.ts → DomeManipulator.mts} +5 -5
  34. package/src/{DomeRouter.ts → DomeRouter.mts} +3 -3
  35. package/src/index.mts +12 -0
  36. package/src/{temp-test.ts → temp-test.mts} +1 -1
  37. package/tsconfig.json +57 -60
  38. package/vitest.config.ts +10 -0
  39. package/jest.config.js +0 -22
  40. package/out/Animation.js +0 -0
  41. package/out/DomeRouter.console-test.d.ts +0 -0
  42. package/out/index.d.ts +0 -12
  43. package/out/index.js +0 -14
  44. package/src/index.ts +0 -14
  45. /package/src/{Animation.ts → Animation.mts} +0 -0
  46. /package/src/{DomeRouter.console-test.ts → DomeRouter.console-test.mts} +0 -0
  47. /package/src/{LongestCommonSubsequence.ts → LongestCommonSubsequence.mts} +0 -0
@@ -1,29 +1,29 @@
1
- import { Animation } from './Animation';
2
- interface KeyToElementPair {
3
- key: string;
4
- element: HTMLElement;
5
- }
6
- export declare class AnimatedArray<T> {
7
- protected params: {
8
- parentElement?: HTMLElement;
9
- array?: T[];
10
- getKey: (o: T) => string;
11
- getHtmlElement: (o: T) => HTMLElement;
12
- animationShow?: Animation;
13
- animationHide?: Animation;
14
- emptyList?: HTMLElement;
15
- };
16
- arrayOfKeyToElement: KeyToElementPair[];
17
- constructor(params: {
18
- parentElement?: HTMLElement;
19
- array?: T[];
20
- getKey: (o: T) => string;
21
- getHtmlElement: (o: T) => HTMLElement;
22
- animationShow?: Animation;
23
- animationHide?: Animation;
24
- emptyList?: HTMLElement;
25
- });
26
- get size(): number;
27
- update(array: T[], parentElement?: HTMLElement | Element): void;
28
- }
29
- export {};
1
+ import { Animation } from './Animation.mjs';
2
+ interface KeyToElementPair {
3
+ key: string;
4
+ element: HTMLElement;
5
+ }
6
+ export declare class AnimatedArray<T> {
7
+ protected params: {
8
+ parentElement?: HTMLElement;
9
+ array?: T[];
10
+ getKey: (o: T) => string;
11
+ getHtmlElement: (o: T) => HTMLElement;
12
+ animationShow?: Animation;
13
+ animationHide?: Animation;
14
+ emptyList?: HTMLElement;
15
+ };
16
+ arrayOfKeyToElement: KeyToElementPair[];
17
+ constructor(params: {
18
+ parentElement?: HTMLElement;
19
+ array?: T[];
20
+ getKey: (o: T) => string;
21
+ getHtmlElement: (o: T) => HTMLElement;
22
+ animationShow?: Animation;
23
+ animationHide?: Animation;
24
+ emptyList?: HTMLElement;
25
+ });
26
+ get size(): number;
27
+ update(array: T[], parentElement?: HTMLElement | Element): void;
28
+ }
29
+ export {};
@@ -1,51 +1,52 @@
1
- import { DomeManipulator } from "./DomeManipulator";
2
- import { LongestCommonSubsequence } from "./LongestCommonSubsequence";
3
- export class AnimatedArray {
4
- constructor(params) {
5
- this.params = params;
6
- this.arrayOfKeyToElement = [];
7
- if (params.array && params.parentElement) {
8
- this.update(params.array);
9
- }
10
- }
11
- get size() {
12
- return this.arrayOfKeyToElement.length;
13
- }
14
- update(array, parentElement) {
15
- parentElement = parentElement || this.params.parentElement;
16
- if (!parentElement) {
17
- console.warn('AnimatedArray unable to update, no parentElement');
18
- return;
19
- }
20
- if (array.length == 0 && this.params.emptyList) {
21
- DomeManipulator.replaceAllChildrenAsync(parentElement, this.params.emptyList);
22
- return;
23
- }
24
- if (array.length > 0 && this.params.emptyList) {
25
- DomeManipulator.removeElementAsync(this.params.emptyList, this.params.animationHide);
26
- }
27
- //let arrayOfKeyToElement:KeyToElementPair[] = []
28
- let newArrayOfKeys = array.map((item) => this.params.getKey(item));
29
- let oldArrayOfKeys = this.arrayOfKeyToElement.map(x => x.key);
30
- LongestCommonSubsequence.getPatchOrdered({
31
- oldArray: oldArrayOfKeys,
32
- newArray: newArrayOfKeys,
33
- onAdd: (index, key) => {
34
- if (!parentElement)
35
- throw new Error('no parent element'); //TODO: remove this
36
- let itemIndex = newArrayOfKeys.indexOf(key);
37
- if (itemIndex == -1)
38
- throw new Error('no itemIndex'); //TODO: remove this
39
- let item = array[itemIndex];
40
- let element = this.params.getHtmlElement(item);
41
- this.arrayOfKeyToElement.splice(index, 0, { key, element });
42
- DomeManipulator.insertByIndexAsync(element, index, parentElement, this.params.animationShow);
43
- //this.insertNewElementWithAnimation(element, index, parentElement)
44
- },
45
- onRemove: (index, key) => {
46
- DomeManipulator.removeElementAsync(this.arrayOfKeyToElement[index].element, this.params.animationHide);
47
- this.arrayOfKeyToElement.splice(index, 1);
48
- }
49
- });
50
- }
51
- }
1
+ import { DomeManipulator } from "./DomeManipulator.mjs";
2
+ import { LongestCommonSubsequence } from "./LongestCommonSubsequence.mjs";
3
+ export class AnimatedArray {
4
+ params;
5
+ arrayOfKeyToElement = [];
6
+ constructor(params) {
7
+ this.params = params;
8
+ if (params.array && params.parentElement) {
9
+ this.update(params.array);
10
+ }
11
+ }
12
+ get size() {
13
+ return this.arrayOfKeyToElement.length;
14
+ }
15
+ update(array, parentElement) {
16
+ parentElement = parentElement || this.params.parentElement;
17
+ if (!parentElement) {
18
+ console.warn('AnimatedArray unable to update, no parentElement');
19
+ return;
20
+ }
21
+ if (array.length == 0 && this.params.emptyList) {
22
+ DomeManipulator.replaceAllChildrenAsync(parentElement, this.params.emptyList);
23
+ return;
24
+ }
25
+ if (array.length > 0 && this.params.emptyList) {
26
+ DomeManipulator.removeElementAsync(this.params.emptyList, this.params.animationHide);
27
+ }
28
+ //let arrayOfKeyToElement:KeyToElementPair[] = []
29
+ let newArrayOfKeys = array.map((item) => this.params.getKey(item));
30
+ let oldArrayOfKeys = this.arrayOfKeyToElement.map(x => x.key);
31
+ LongestCommonSubsequence.getPatchOrdered({
32
+ oldArray: oldArrayOfKeys,
33
+ newArray: newArrayOfKeys,
34
+ onAdd: (index, key) => {
35
+ if (!parentElement)
36
+ throw new Error('no parent element'); //TODO: remove this
37
+ let itemIndex = newArrayOfKeys.indexOf(key);
38
+ if (itemIndex == -1)
39
+ throw new Error('no itemIndex'); //TODO: remove this
40
+ let item = array[itemIndex];
41
+ let element = this.params.getHtmlElement(item);
42
+ this.arrayOfKeyToElement.splice(index, 0, { key, element });
43
+ DomeManipulator.insertByIndexAsync(element, index, parentElement, this.params.animationShow);
44
+ //this.insertNewElementWithAnimation(element, index, parentElement)
45
+ },
46
+ onRemove: (index, key) => {
47
+ DomeManipulator.removeElementAsync(this.arrayOfKeyToElement[index].element, this.params.animationHide);
48
+ this.arrayOfKeyToElement.splice(index, 1);
49
+ }
50
+ });
51
+ }
52
+ }
@@ -1,38 +1,38 @@
1
- import { DomeComponent, AnimatedArray } from ".";
2
- import { Animation } from './Animation';
3
- import { ObservableValue } from '@lexriver/observable';
4
- interface Attrs<T> {
5
- isLoadingO?: ObservableValue<boolean>;
6
- itemsO: ObservableValue<T[]>;
7
- animationShowRow: Animation;
8
- animationHideRow: Animation;
9
- animationHideTable?: Animation;
10
- animationShowTable?: Animation;
11
- animationHideEmptyList?: Animation;
12
- animationShowEmptyList?: Animation;
13
- animationShowLoading?: Animation;
14
- animationHideLoading?: Animation;
15
- getKey: (item: T) => string;
16
- rootElement?: HTMLElement;
17
- tableElement?: HTMLElement;
18
- tableBody?: HTMLElement;
19
- renderTableHead?: (items: T[]) => HTMLElement;
20
- renderTableRow: (item: T) => HTMLElement;
21
- renderTableFooter?: (items: T[]) => HTMLElement;
22
- renderEmptyList: () => HTMLElement;
23
- renderLoading?: () => HTMLElement;
24
- }
25
- export declare class AnimatedTable<T> extends DomeComponent<Attrs<T>> {
26
- refRoot: HTMLElement;
27
- refTable: HTMLElement;
28
- refTableHead: Element;
29
- refTableBody: HTMLElement;
30
- refTableFooter: Element;
31
- refEmptyList: Element;
32
- refLoading: Element;
33
- animatedArray: AnimatedArray<T>;
34
- render(): HTMLElement;
35
- afterRender(): void;
36
- updateAsync(): Promise<void>;
37
- }
38
- export {};
1
+ import { ObservableVariable } from '@lexriver/observable';
2
+ import { Animation } from './Animation.mjs';
3
+ import { AnimatedArray, DomeComponent } from "./index.mjs";
4
+ interface Attrs<T> {
5
+ isLoadingO?: ObservableVariable<boolean>;
6
+ itemsO: ObservableVariable<T[]>;
7
+ animationShowRow: Animation;
8
+ animationHideRow: Animation;
9
+ animationHideTable?: Animation;
10
+ animationShowTable?: Animation;
11
+ animationHideEmptyList?: Animation;
12
+ animationShowEmptyList?: Animation;
13
+ animationShowLoading?: Animation;
14
+ animationHideLoading?: Animation;
15
+ getKey: (item: T) => string;
16
+ rootElement?: HTMLElement;
17
+ tableElement?: HTMLElement;
18
+ tableBody?: HTMLElement;
19
+ renderTableHead?: (items: T[]) => HTMLElement;
20
+ renderTableRow: (item: T) => HTMLElement;
21
+ renderTableFooter?: (items: T[]) => HTMLElement;
22
+ renderEmptyList: () => HTMLElement;
23
+ renderLoading?: () => HTMLElement;
24
+ }
25
+ export declare class AnimatedTable<T> extends DomeComponent<Attrs<T>> {
26
+ refRoot: HTMLElement;
27
+ refTable: HTMLElement;
28
+ refTableHead: Element;
29
+ refTableBody: HTMLElement;
30
+ refTableFooter: Element;
31
+ refEmptyList: Element;
32
+ refLoading: Element;
33
+ animatedArray: AnimatedArray<T>;
34
+ render(): HTMLElement;
35
+ afterRender(): void;
36
+ updateAsync(): Promise<void>;
37
+ }
38
+ export {};
@@ -1,91 +1,88 @@
1
- import { DomeComponent, AnimatedArray } from ".";
2
- import { DomeManipulator } from "./DomeManipulator";
3
- export class AnimatedTable extends DomeComponent {
4
- constructor() {
5
- super(...arguments);
6
- // rootElement
7
- // table
8
- // thead
9
- // tbody
10
- // tfooter
11
- // emptyList
12
- this.refRoot = this.attrs.rootElement || document.createElement('div');
13
- this.refTable = this.attrs.tableElement || document.createElement('table');
14
- this.refTableHead = this.attrs.renderTableHead ? this.attrs.renderTableHead(this.attrs.itemsO.get()) : document.createElement('thead');
15
- this.refTableBody = this.attrs.tableBody || document.createElement('tbody');
16
- this.refTableFooter = this.attrs.renderTableFooter ? this.attrs.renderTableFooter(this.attrs.itemsO.get()) : document.createElement('tfoot');
17
- this.refEmptyList = this.attrs.renderEmptyList ? this.attrs.renderEmptyList() : document.createElement('div');
18
- this.refLoading = this.attrs.renderLoading ? this.attrs.renderLoading() : document.createElement('div');
19
- this.animatedArray = new AnimatedArray({
20
- animationHide: this.attrs.animationHideRow,
21
- animationShow: this.attrs.animationShowRow,
22
- array: [],
23
- getKey: this.attrs.getKey,
24
- getHtmlElement: this.attrs.renderTableRow
25
- });
26
- }
27
- render() {
28
- // refRoot
29
- // refTable
30
- // refTableHead
31
- // refTableBody
32
- // refTableFooter
33
- // refEmptyListEl
34
- // refLoading
35
- this.refRoot.appendChild(this.refTable);
36
- this.refRoot.appendChild(this.refEmptyList);
37
- this.refRoot.appendChild(this.refLoading);
38
- if (this.refTableHead)
39
- this.refTable.appendChild(this.refTableHead);
40
- if (this.refTableBody)
41
- this.refTable.appendChild(this.refTableBody);
42
- if (this.refTableFooter)
43
- this.refTable.appendChild(this.refTableFooter);
44
- console.log('AnimatedTable render()', 'refRoot=', this.refRoot);
45
- return this.refRoot;
46
- }
47
- afterRender() {
48
- this.updateAsync();
49
- //this.animatedArray.update(this.attrs.items, this.el)
50
- }
51
- async updateAsync() {
52
- try {
53
- if (this.attrs.renderLoading) {
54
- this.refLoading = await DomeManipulator.replaceAsync(this.refLoading, this.attrs.renderLoading());
55
- }
56
- if (this.attrs.isLoadingO && this.attrs.isLoadingO.get()) {
57
- // show loading
58
- await DomeManipulator.unhideElementAsync(this.refLoading, this.attrs.animationShowLoading);
59
- }
60
- else {
61
- // hide loading
62
- await DomeManipulator.hideElementAsync(this.refLoading, this.attrs.animationHideLoading);
63
- }
64
- const items = this.attrs.itemsO.get();
65
- const currentCount = items.length;
66
- if (currentCount == 0) {
67
- // render empty list
68
- await DomeManipulator.hideElementAsync(this.refTable, this.attrs.animationHideTable);
69
- if (this.attrs.renderEmptyList) {
70
- this.refEmptyList = await DomeManipulator.replaceAsync(this.refEmptyList, this.attrs.renderEmptyList());
71
- }
72
- await DomeManipulator.unhideElementAsync(this.refEmptyList, this.attrs.animationShowEmptyList);
73
- }
74
- else {
75
- // render list with items
76
- await DomeManipulator.hideElementAsync(this.refEmptyList, this.attrs.animationHideEmptyList);
77
- if (this.attrs.renderTableHead) {
78
- this.refTableHead = await DomeManipulator.replaceAsync(this.refTableHead, this.attrs.renderTableHead(items));
79
- }
80
- if (this.attrs.renderTableFooter) {
81
- this.refTableFooter = await DomeManipulator.replaceAsync(this.refTableFooter, this.attrs.renderTableFooter(items));
82
- }
83
- await DomeManipulator.unhideElementAsync(this.refTable, this.attrs.animationShowTable);
84
- this.animatedArray.update(items, this.refTableBody);
85
- }
86
- }
87
- catch (x) {
88
- console.error('AnimatedTable update failed', x);
89
- }
90
- }
91
- }
1
+ import { DomeManipulator } from "./DomeManipulator.mjs";
2
+ import { AnimatedArray, DomeComponent } from "./index.mjs";
3
+ export class AnimatedTable extends DomeComponent {
4
+ // rootElement
5
+ // table
6
+ // thead
7
+ // tbody
8
+ // tfooter
9
+ // emptyList
10
+ refRoot = this.attrs.rootElement || document.createElement('div');
11
+ refTable = this.attrs.tableElement || document.createElement('table');
12
+ refTableHead = this.attrs.renderTableHead ? this.attrs.renderTableHead(this.attrs.itemsO.get()) : document.createElement('thead');
13
+ refTableBody = this.attrs.tableBody || document.createElement('tbody');
14
+ refTableFooter = this.attrs.renderTableFooter ? this.attrs.renderTableFooter(this.attrs.itemsO.get()) : document.createElement('tfoot');
15
+ refEmptyList = this.attrs.renderEmptyList ? this.attrs.renderEmptyList() : document.createElement('div');
16
+ refLoading = this.attrs.renderLoading ? this.attrs.renderLoading() : document.createElement('div');
17
+ animatedArray = new AnimatedArray({
18
+ animationHide: this.attrs.animationHideRow,
19
+ animationShow: this.attrs.animationShowRow,
20
+ array: [],
21
+ getKey: this.attrs.getKey,
22
+ getHtmlElement: this.attrs.renderTableRow
23
+ });
24
+ render() {
25
+ // refRoot
26
+ // refTable
27
+ // refTableHead
28
+ // refTableBody
29
+ // refTableFooter
30
+ // refEmptyListEl
31
+ // refLoading
32
+ this.refRoot.appendChild(this.refTable);
33
+ this.refRoot.appendChild(this.refEmptyList);
34
+ this.refRoot.appendChild(this.refLoading);
35
+ if (this.refTableHead)
36
+ this.refTable.appendChild(this.refTableHead);
37
+ if (this.refTableBody)
38
+ this.refTable.appendChild(this.refTableBody);
39
+ if (this.refTableFooter)
40
+ this.refTable.appendChild(this.refTableFooter);
41
+ console.log('AnimatedTable render()', 'refRoot=', this.refRoot);
42
+ return this.refRoot;
43
+ }
44
+ afterRender() {
45
+ this.updateAsync();
46
+ //this.animatedArray.update(this.attrs.items, this.el)
47
+ }
48
+ async updateAsync() {
49
+ try {
50
+ if (this.attrs.renderLoading) {
51
+ this.refLoading = await DomeManipulator.replaceAsync(this.refLoading, this.attrs.renderLoading());
52
+ }
53
+ if (this.attrs.isLoadingO && this.attrs.isLoadingO.get()) {
54
+ // show loading
55
+ await DomeManipulator.unhideElementAsync(this.refLoading, this.attrs.animationShowLoading);
56
+ }
57
+ else {
58
+ // hide loading
59
+ await DomeManipulator.hideElementAsync(this.refLoading, this.attrs.animationHideLoading);
60
+ }
61
+ const items = this.attrs.itemsO.get();
62
+ const currentCount = items.length;
63
+ if (currentCount == 0) {
64
+ // render empty list
65
+ await DomeManipulator.hideElementAsync(this.refTable, this.attrs.animationHideTable);
66
+ if (this.attrs.renderEmptyList) {
67
+ this.refEmptyList = await DomeManipulator.replaceAsync(this.refEmptyList, this.attrs.renderEmptyList());
68
+ }
69
+ await DomeManipulator.unhideElementAsync(this.refEmptyList, this.attrs.animationShowEmptyList);
70
+ }
71
+ else {
72
+ // render list with items
73
+ await DomeManipulator.hideElementAsync(this.refEmptyList, this.attrs.animationHideEmptyList);
74
+ if (this.attrs.renderTableHead) {
75
+ this.refTableHead = await DomeManipulator.replaceAsync(this.refTableHead, this.attrs.renderTableHead(items));
76
+ }
77
+ if (this.attrs.renderTableFooter) {
78
+ this.refTableFooter = await DomeManipulator.replaceAsync(this.refTableFooter, this.attrs.renderTableFooter(items));
79
+ }
80
+ await DomeManipulator.unhideElementAsync(this.refTable, this.attrs.animationShowTable);
81
+ this.animatedArray.update(items, this.refTableBody);
82
+ }
83
+ }
84
+ catch (x) {
85
+ console.error('AnimatedTable update failed', x);
86
+ }
87
+ }
88
+ }
@@ -1,13 +1,13 @@
1
- import { ObservableValue } from "@lexriver/observable";
2
- import { DomeComponent } from ".";
3
- import { CssClass } from "./DomeManipulator";
4
- interface Attrs {
5
- textO: ObservableValue<string>;
6
- tag?: string;
7
- class?: CssClass;
8
- }
9
- export declare class AnimatedText extends DomeComponent<Attrs> {
10
- render(): HTMLElement;
11
- updateAsync(): Promise<void>;
12
- }
13
- export {};
1
+ import { ObservableVariable } from "@lexriver/observable";
2
+ import { CssClass } from "./DomeManipulator.mjs";
3
+ import { DomeComponent } from "./index.mjs";
4
+ interface Attrs {
5
+ textO: ObservableVariable<string>;
6
+ tag?: string;
7
+ class?: CssClass;
8
+ }
9
+ export declare class AnimatedText extends DomeComponent<Attrs> {
10
+ render(): HTMLElement;
11
+ updateAsync(): Promise<void>;
12
+ }
13
+ export {};
@@ -1,24 +1,24 @@
1
- import { DomeComponent } from ".";
2
- import { DomeManipulator } from "./DomeManipulator";
3
- export class AnimatedText extends DomeComponent {
4
- render() {
5
- //const result = this.attrs.tag ? document.createElement(this.attrs.tag) : document.createElement('span')
6
- const result = document.createElement(this.attrs.tag || 'span');
7
- //console.log('AnimatedText', 'this.attrs.class=',this.attrs.class)
8
- if (this.attrs.class) {
9
- DomeManipulator.setCssClasses(result, this.attrs.class);
10
- }
11
- result.append(this.attrs.textO.get());
12
- return result;
13
- }
14
- async updateAsync() {
15
- if (!this.rootElement)
16
- return;
17
- try {
18
- this.rootElement = await DomeManipulator.replaceAsync(this.rootElement, this.render(), this.attrs.onHideAnimation, this.attrs.onShowAnimation);
19
- }
20
- catch (x) {
21
- console.error('AnimatedText update failed', x);
22
- }
23
- }
24
- }
1
+ import { DomeManipulator } from "./DomeManipulator.mjs";
2
+ import { DomeComponent } from "./index.mjs";
3
+ export class AnimatedText extends DomeComponent {
4
+ render() {
5
+ //const result = this.attrs.tag ? document.createElement(this.attrs.tag) : document.createElement('span')
6
+ const result = document.createElement(this.attrs.tag || 'span');
7
+ //console.log('AnimatedText', 'this.attrs.class=',this.attrs.class)
8
+ if (this.attrs.class) {
9
+ DomeManipulator.setCssClasses(result, this.attrs.class);
10
+ }
11
+ result.append(this.attrs.textO.get());
12
+ return result;
13
+ }
14
+ async updateAsync() {
15
+ if (!this.rootElement)
16
+ return;
17
+ try {
18
+ this.rootElement = await DomeManipulator.replaceAsync(this.rootElement, this.render(), this.attrs.onHideAnimation, this.attrs.onShowAnimation);
19
+ }
20
+ catch (x) {
21
+ console.error('AnimatedText update failed', x);
22
+ }
23
+ }
24
+ }
@@ -1,4 +1,4 @@
1
- export interface Animation {
2
- cssClassName: string;
3
- timeMs: number;
4
- }
1
+ export interface Animation {
2
+ cssClassName: string;
3
+ timeMs: number;
4
+ }
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1,9 +1,9 @@
1
- export declare function h(tagName: any, attrs: any, ...childrenArgs: any[]): any;
2
- export declare const React: {
3
- createElement: typeof h;
4
- Fragment: {
5
- new (): DocumentFragment;
6
- prototype: DocumentFragment;
7
- } | (() => void);
8
- };
9
- export default React;
1
+ export declare function h(tagName: any, attrs: any, ...childrenArgs: any[]): any;
2
+ export declare const React: {
3
+ createElement: typeof h;
4
+ Fragment: {
5
+ new (): DocumentFragment;
6
+ prototype: DocumentFragment;
7
+ } | (() => void);
8
+ };
9
+ export default React;