@amateras/widget 0.1.0 → 0.2.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.
- package/package.json +2 -2
- package/src/index.ts +1 -4
- package/src/structure/Widget.ts +13 -4
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amateras/widget",
|
|
3
3
|
"peerDependencies": {
|
|
4
|
-
"@amateras/core": "0.
|
|
4
|
+
"@amateras/core": "0.18.0",
|
|
5
5
|
"@amateras/utils": "0.1.0"
|
|
6
6
|
},
|
|
7
7
|
"imports": {
|
|
@@ -11,5 +11,5 @@
|
|
|
11
11
|
"exports": {
|
|
12
12
|
".": "./src/index.ts"
|
|
13
13
|
},
|
|
14
|
-
"version": "0.
|
|
14
|
+
"version": "0.2.0"
|
|
15
15
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WidgetConstructor } from '#structure/Widget';
|
|
1
|
+
import { WidgetConstructor, type WidgetBuilder } from '#structure/Widget';
|
|
2
2
|
import { symbol_ProtoType, type Proto } from '@amateras/core';
|
|
3
3
|
import { Utils } from '@amateras/utils';
|
|
4
4
|
|
|
@@ -16,11 +16,8 @@ declare global {
|
|
|
16
16
|
]
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
// export function $<Props, Parent extends Proto>(widget: WidgetConstructor<Props, Parent>, ...args: WidgetConstructorArguments<Props, Parent>): Widget<Props, Parent>;
|
|
21
19
|
}
|
|
22
20
|
|
|
23
|
-
export type WidgetBuilder<Props = any, Parent extends Proto = any> = (props: $.Props<Props>, children: $.Layout<Parent>) => void;
|
|
24
21
|
|
|
25
22
|
type WidgetConstructorArguments<Props, Parent extends Proto> =
|
|
26
23
|
RequiredKeys<Props> extends never
|
package/src/structure/Widget.ts
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
import { Proto, ProxyProto, symbol_ProtoType } from "@amateras/core";
|
|
2
|
-
import
|
|
2
|
+
import { Utils } from "@amateras/utils";
|
|
3
3
|
|
|
4
4
|
export const WidgetConstructor = (builder: WidgetBuilder) => {
|
|
5
5
|
const Widget = class extends ProxyProto {
|
|
6
6
|
static override readonly [symbol_ProtoType] = 'Widget' as any;
|
|
7
7
|
static override name = 'Widget';
|
|
8
8
|
static builder = builder;
|
|
9
|
+
props = {};
|
|
10
|
+
place: $.Layout | null = Utils.Null;
|
|
9
11
|
constructor(props: $.Props, layout?: $.Layout) {
|
|
10
|
-
super(() =>
|
|
12
|
+
super(() => {
|
|
13
|
+
this.props = props;
|
|
14
|
+
this.place = layout ?? Utils.Null;
|
|
15
|
+
Widget.builder(this as unknown as Widget)
|
|
16
|
+
});
|
|
11
17
|
}
|
|
12
18
|
} as unknown as WidgetConstructor
|
|
13
19
|
return Widget;
|
|
14
20
|
}
|
|
15
21
|
|
|
22
|
+
export type WidgetBuilder<Props = any, Parent extends Proto = any> = ($$: Widget<Props, Parent>) => void;
|
|
23
|
+
|
|
16
24
|
export interface WidgetConstructor<Props = {}, Parent extends Proto = any> {
|
|
17
25
|
[symbol_ProtoType]: 'Widget';
|
|
18
26
|
builder: WidgetBuilder;
|
|
@@ -20,6 +28,7 @@ export interface WidgetConstructor<Props = {}, Parent extends Proto = any> {
|
|
|
20
28
|
}
|
|
21
29
|
|
|
22
30
|
export interface Widget<Props = {}, Parent extends Proto = any> extends Proto {
|
|
23
|
-
props: Props
|
|
31
|
+
props: $.Props<Props>;
|
|
24
32
|
parent: Parent;
|
|
25
|
-
|
|
33
|
+
place: $.Layout | null
|
|
34
|
+
}
|