amateras 0.13.2 → 0.14.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/README.md +39 -38
- package/build/core.js +1 -1
- package/build/css-keyframes.js +1 -0
- package/build/css-property.js +1 -0
- package/build/css-variable.js +1 -0
- package/build/for.js +1 -1
- package/build/i18n.js +1 -1
- package/build/if.js +1 -1
- package/build/import-map.js +1 -1
- package/build/match.js +1 -1
- package/build/meta.js +1 -1
- package/build/prefetch.js +1 -1
- package/build/router.js +1 -1
- package/build/signal.js +1 -1
- package/build/store.js +1 -1
- package/build/ui.js +1 -1
- package/build/utils.js +1 -1
- package/build/widget.js +1 -1
- package/package.json +3 -2
- package/packages/core/src/index.ts +86 -31
- package/packages/core/src/lib/hmr.ts +4 -4
- package/packages/core/src/structure/ElementProto.ts +33 -11
- package/packages/core/src/structure/GlobalState.ts +13 -4
- package/packages/core/src/structure/NodeProto.ts +2 -4
- package/packages/core/src/structure/Proto.ts +37 -23
- package/packages/core/src/structure/TextProto.ts +1 -2
- package/packages/css/README.md +18 -15
- package/packages/css/src/ext/property.ts +2 -3
- package/packages/css/src/index.ts +1 -1
- package/packages/css/src/structure/$CSSProperty.ts +4 -0
- package/packages/css/src/structure/$CSSVariable.ts +1 -1
- package/packages/css/src/types.ts +5 -0
- package/packages/for/src/global.ts +12 -3
- package/packages/for/src/structure/For.ts +5 -3
- package/packages/i18n/README.md +16 -24
- package/packages/i18n/src/index.ts +26 -5
- package/packages/i18n/src/structure/I18n.ts +2 -4
- package/packages/i18n/src/structure/I18nSession.ts +4 -2
- package/packages/i18n/src/structure/I18nTranslation.ts +15 -26
- package/packages/idb/src/structure/$IDBStore.ts +2 -2
- package/packages/if/src/global.ts +15 -4
- package/packages/if/src/index.ts +18 -8
- package/packages/if/src/structure/Condition.ts +16 -13
- package/packages/if/src/structure/ConditionStatement.ts +9 -9
- package/packages/match/src/global.ts +9 -3
- package/packages/match/src/structure/Match.ts +1 -1
- package/packages/meta/src/index.ts +4 -5
- package/packages/prefetch/src/index.ts +30 -9
- package/packages/router/src/global.ts +17 -4
- package/packages/router/src/index.ts +25 -18
- package/packages/router/src/structure/Route.ts +2 -1
- package/packages/router/src/structure/RouteNode.ts +8 -6
- package/packages/router/src/structure/RouteSlot.ts +15 -2
- package/packages/router/src/structure/Router.ts +28 -19
- package/packages/router/src/structure/RouterConstructor.ts +5 -5
- package/packages/router/src/types.ts +2 -2
- package/packages/signal/README.md +28 -48
- package/packages/signal/src/index.ts +61 -38
- package/packages/signal/src/structure/Signal.ts +40 -7
- package/packages/store/src/structure/Store.ts +1 -1
- package/packages/ui/package.json +2 -1
- package/packages/ui/src/icon/check.svg.ts +1 -0
- package/packages/ui/src/icon/x.svg.ts +1 -0
- package/packages/ui/src/index.ts +9 -2
- package/packages/ui/src/lib/combobox_style.ts +20 -0
- package/packages/ui/src/lib/hover.ts +2 -0
- package/packages/ui/src/structure/Badge.ts +10 -1
- package/packages/ui/src/structure/Button.ts +54 -27
- package/packages/ui/src/structure/Card.ts +3 -4
- package/packages/ui/src/structure/Combobox/Combobox.ts +312 -0
- package/packages/ui/src/structure/Combobox/ComboboxChips.ts +178 -0
- package/packages/ui/src/structure/Combobox/ComboboxList.ts +209 -0
- package/packages/ui/src/structure/ContextMenu.ts +89 -0
- package/packages/ui/src/structure/Field.ts +109 -0
- package/packages/ui/src/structure/Input.ts +29 -0
- package/packages/ui/src/structure/Select/Select.ts +18 -8
- package/packages/ui/src/structure/Select/SelectContent.ts +6 -1
- package/packages/ui/src/structure/Select/SelectItem.ts +2 -1
- package/packages/ui/src/structure/Slideshow.ts +2 -2
- package/packages/ui/src/structure/Switch.ts +45 -0
- package/packages/ui/src/structure/Tabs.ts +3 -3
- package/packages/ui/src/structure/Toggle.ts +155 -0
- package/packages/ui/src/structure/Waterfall.ts +1 -1
- package/packages/ui/src/structure/WaterfallItem.ts +1 -1
- package/packages/utils/src/lib/utils.ts +30 -8
- package/packages/utils/src/structure/UID.ts +1 -1
- package/packages/widget/src/index.ts +29 -9
- package/packages/widget/src/structure/Widget.ts +7 -3
- package/packages/ui/src/structure/TextBlock.ts +0 -11
|
@@ -1,19 +1,31 @@
|
|
|
1
|
-
import { WidgetConstructor
|
|
2
|
-
import { type Proto } from '@amateras/core';
|
|
3
|
-
import { _Object_assign } from '@amateras/utils';
|
|
1
|
+
import { WidgetConstructor } from '#structure/Widget';
|
|
2
|
+
import { symbol_ProtoType, type Proto } from '@amateras/core';
|
|
3
|
+
import { _Object_assign, isFunction } from '@amateras/utils';
|
|
4
4
|
|
|
5
5
|
declare global {
|
|
6
6
|
export namespace $ {
|
|
7
|
-
export function widget<Props = {}, Parent extends Proto = never>(builder: WidgetBuilder<Props, Parent>):
|
|
7
|
+
export function widget<Props = {}, Parent extends Proto = never>(builder: WidgetBuilder<Props, Parent>): WidgetConstructor<Props, Parent>;
|
|
8
|
+
|
|
9
|
+
export interface Overload<I> {
|
|
10
|
+
widget: [
|
|
11
|
+
input: [WidgetConstructor<any, any>],
|
|
12
|
+
output: I[0] extends WidgetConstructor ? InstanceType<I[0]> : never,
|
|
13
|
+
args: I[0] extends WidgetConstructor<infer Props, infer Parent>
|
|
14
|
+
? WidgetConstructorArguments<Props, Parent>
|
|
15
|
+
: never
|
|
16
|
+
]
|
|
17
|
+
}
|
|
8
18
|
}
|
|
9
19
|
|
|
10
|
-
export function $<Props, Parent extends Proto>(
|
|
20
|
+
// export function $<Props, Parent extends Proto>(widget: WidgetConstructor<Props, Parent>, ...args: WidgetConstructorArguments<Props, Parent>): Widget<Props, Parent>;
|
|
11
21
|
}
|
|
22
|
+
|
|
12
23
|
export type WidgetBuilder<Props = any, Parent extends Proto = any> = (props: $.Props<Props>, children: $.Layout<Parent>) => void;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
24
|
+
|
|
25
|
+
type WidgetConstructorArguments<Props, Parent extends Proto> =
|
|
26
|
+
RequiredKeys<Props> extends never
|
|
27
|
+
? [props?: $.Props<Props>, children?: $.Layout<Parent>] | [children?: $.Layout<Parent>]
|
|
28
|
+
: [props: $.Props<Props>, children?: $.Layout<Parent>];
|
|
17
29
|
|
|
18
30
|
_Object_assign($, {
|
|
19
31
|
widget(builder: WidgetBuilder) {
|
|
@@ -21,4 +33,12 @@ _Object_assign($, {
|
|
|
21
33
|
}
|
|
22
34
|
})
|
|
23
35
|
|
|
36
|
+
$.process.craft.add((widget, ...args) => {
|
|
37
|
+
if (widget[symbol_ProtoType] === 'Widget') {
|
|
38
|
+
let [arg1] = args;
|
|
39
|
+
args = isFunction(arg1) ? [{}, arg1] : args;
|
|
40
|
+
return new widget(...args)
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
|
|
24
44
|
export * from '#structure/Widget';
|
|
@@ -4,15 +4,19 @@ import type { WidgetBuilder } from "..";
|
|
|
4
4
|
export const WidgetConstructor = (builder: WidgetBuilder) => {
|
|
5
5
|
return class extends Proto {
|
|
6
6
|
static override [symbol_ProtoType] = 'Widget';
|
|
7
|
-
static override name = '
|
|
7
|
+
static override name = 'Widget';
|
|
8
8
|
constructor(props: $.Props, layout?: $.Layout) {
|
|
9
9
|
super(() => builder(props, (proto) => layout?.(proto)));
|
|
10
10
|
}
|
|
11
|
-
}
|
|
11
|
+
} as unknown as WidgetConstructor
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface WidgetConstructor<Props = {}, Parent extends Proto = any> extends Constructor<Proto> {
|
|
15
|
+
[symbol_ProtoType]: 'Widget';
|
|
16
|
+
new (builder: WidgetBuilder): Widget<Props, Parent>;
|
|
12
17
|
}
|
|
13
18
|
|
|
14
19
|
export interface Widget<Props = {}, Parent extends Proto = any> extends Proto {
|
|
15
|
-
new (builder: WidgetBuilder): Widget<Props, Parent>
|
|
16
20
|
props: Props;
|
|
17
21
|
parent: Parent;
|
|
18
22
|
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ElementProto } from "@amateras/core";
|
|
2
|
-
|
|
3
|
-
export class TextBlock extends ElementProto {
|
|
4
|
-
constructor(props: $.Props, layout?: $.Layout<TextBlock>) {
|
|
5
|
-
super('text-block', props, layout);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
static {
|
|
9
|
-
$.style(TextBlock, 'text-block{display:block}')
|
|
10
|
-
}
|
|
11
|
-
}
|