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.
Files changed (89) hide show
  1. package/README.md +39 -38
  2. package/build/core.js +1 -1
  3. package/build/css-keyframes.js +1 -0
  4. package/build/css-property.js +1 -0
  5. package/build/css-variable.js +1 -0
  6. package/build/for.js +1 -1
  7. package/build/i18n.js +1 -1
  8. package/build/if.js +1 -1
  9. package/build/import-map.js +1 -1
  10. package/build/match.js +1 -1
  11. package/build/meta.js +1 -1
  12. package/build/prefetch.js +1 -1
  13. package/build/router.js +1 -1
  14. package/build/signal.js +1 -1
  15. package/build/store.js +1 -1
  16. package/build/ui.js +1 -1
  17. package/build/utils.js +1 -1
  18. package/build/widget.js +1 -1
  19. package/package.json +3 -2
  20. package/packages/core/src/index.ts +86 -31
  21. package/packages/core/src/lib/hmr.ts +4 -4
  22. package/packages/core/src/structure/ElementProto.ts +33 -11
  23. package/packages/core/src/structure/GlobalState.ts +13 -4
  24. package/packages/core/src/structure/NodeProto.ts +2 -4
  25. package/packages/core/src/structure/Proto.ts +37 -23
  26. package/packages/core/src/structure/TextProto.ts +1 -2
  27. package/packages/css/README.md +18 -15
  28. package/packages/css/src/ext/property.ts +2 -3
  29. package/packages/css/src/index.ts +1 -1
  30. package/packages/css/src/structure/$CSSProperty.ts +4 -0
  31. package/packages/css/src/structure/$CSSVariable.ts +1 -1
  32. package/packages/css/src/types.ts +5 -0
  33. package/packages/for/src/global.ts +12 -3
  34. package/packages/for/src/structure/For.ts +5 -3
  35. package/packages/i18n/README.md +16 -24
  36. package/packages/i18n/src/index.ts +26 -5
  37. package/packages/i18n/src/structure/I18n.ts +2 -4
  38. package/packages/i18n/src/structure/I18nSession.ts +4 -2
  39. package/packages/i18n/src/structure/I18nTranslation.ts +15 -26
  40. package/packages/idb/src/structure/$IDBStore.ts +2 -2
  41. package/packages/if/src/global.ts +15 -4
  42. package/packages/if/src/index.ts +18 -8
  43. package/packages/if/src/structure/Condition.ts +16 -13
  44. package/packages/if/src/structure/ConditionStatement.ts +9 -9
  45. package/packages/match/src/global.ts +9 -3
  46. package/packages/match/src/structure/Match.ts +1 -1
  47. package/packages/meta/src/index.ts +4 -5
  48. package/packages/prefetch/src/index.ts +30 -9
  49. package/packages/router/src/global.ts +17 -4
  50. package/packages/router/src/index.ts +25 -18
  51. package/packages/router/src/structure/Route.ts +2 -1
  52. package/packages/router/src/structure/RouteNode.ts +8 -6
  53. package/packages/router/src/structure/RouteSlot.ts +15 -2
  54. package/packages/router/src/structure/Router.ts +28 -19
  55. package/packages/router/src/structure/RouterConstructor.ts +5 -5
  56. package/packages/router/src/types.ts +2 -2
  57. package/packages/signal/README.md +28 -48
  58. package/packages/signal/src/index.ts +61 -38
  59. package/packages/signal/src/structure/Signal.ts +40 -7
  60. package/packages/store/src/structure/Store.ts +1 -1
  61. package/packages/ui/package.json +2 -1
  62. package/packages/ui/src/icon/check.svg.ts +1 -0
  63. package/packages/ui/src/icon/x.svg.ts +1 -0
  64. package/packages/ui/src/index.ts +9 -2
  65. package/packages/ui/src/lib/combobox_style.ts +20 -0
  66. package/packages/ui/src/lib/hover.ts +2 -0
  67. package/packages/ui/src/structure/Badge.ts +10 -1
  68. package/packages/ui/src/structure/Button.ts +54 -27
  69. package/packages/ui/src/structure/Card.ts +3 -4
  70. package/packages/ui/src/structure/Combobox/Combobox.ts +312 -0
  71. package/packages/ui/src/structure/Combobox/ComboboxChips.ts +178 -0
  72. package/packages/ui/src/structure/Combobox/ComboboxList.ts +209 -0
  73. package/packages/ui/src/structure/ContextMenu.ts +89 -0
  74. package/packages/ui/src/structure/Field.ts +109 -0
  75. package/packages/ui/src/structure/Input.ts +29 -0
  76. package/packages/ui/src/structure/Select/Select.ts +18 -8
  77. package/packages/ui/src/structure/Select/SelectContent.ts +6 -1
  78. package/packages/ui/src/structure/Select/SelectItem.ts +2 -1
  79. package/packages/ui/src/structure/Slideshow.ts +2 -2
  80. package/packages/ui/src/structure/Switch.ts +45 -0
  81. package/packages/ui/src/structure/Tabs.ts +3 -3
  82. package/packages/ui/src/structure/Toggle.ts +155 -0
  83. package/packages/ui/src/structure/Waterfall.ts +1 -1
  84. package/packages/ui/src/structure/WaterfallItem.ts +1 -1
  85. package/packages/utils/src/lib/utils.ts +30 -8
  86. package/packages/utils/src/structure/UID.ts +1 -1
  87. package/packages/widget/src/index.ts +29 -9
  88. package/packages/widget/src/structure/Widget.ts +7 -3
  89. package/packages/ui/src/structure/TextBlock.ts +0 -11
@@ -1,19 +1,31 @@
1
- import { WidgetConstructor, type Widget } from '#structure/Widget';
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>): Widget<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>(block: Widget<Props, Parent>, ...args: BlockCraftArguments<Props, Parent>): Widget<Props, Parent>;
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
- type BlockCraftArguments<Props, Parent extends Proto> =
14
- RequiredKeys<Props> extends never
15
- ? [children?: $.Layout<Parent>] | [props?: $.Props<Props>, children?: $.Layout<Parent>]
16
- : [props: $.Props<Props>, children?: $.Layout<Parent>];
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 = 'Block';
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
- }