amateras 0.6.0 → 0.7.1

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 (280) hide show
  1. package/index.ts +1 -0
  2. package/package.json +31 -30
  3. package/packages/core/package.json +32 -0
  4. package/packages/core/src/env.browser.ts +21 -0
  5. package/packages/core/src/env.node.ts +21 -0
  6. package/packages/core/src/global.ts +18 -0
  7. package/{src/core.ts → packages/core/src/index.ts} +42 -30
  8. package/{src → packages/core/src}/lib/assignProperties.ts +1 -1
  9. package/packages/core/src/lib/chain.ts +17 -0
  10. package/packages/core/src/lib/dom.ts +20 -0
  11. package/packages/core/src/main.ts +4 -0
  12. package/{src → packages/core/src}/node/$Element.ts +22 -10
  13. package/{src → packages/core/src}/node/$EventTarget.ts +13 -10
  14. package/{src → packages/core/src}/node/$HTMLElement.ts +1 -1
  15. package/{src → packages/core/src}/node/$Node.ts +7 -11
  16. package/{src → packages/core/src}/node/$Virtual.ts +5 -5
  17. package/packages/css/package.json +17 -0
  18. package/{ext/css/src/lib → packages/css/src/ext}/colors/amber.ts +2 -2
  19. package/{ext/css/src/lib → packages/css/src/ext}/colors/blackwhite.ts +2 -2
  20. package/{ext/css/src/lib → packages/css/src/ext}/colors/blue.ts +2 -2
  21. package/{ext/css/src/lib → packages/css/src/ext}/colors/cyan.ts +2 -2
  22. package/{ext/css/src/lib → packages/css/src/ext}/colors/emerald.ts +2 -2
  23. package/{ext/css/src/lib → packages/css/src/ext}/colors/fuchsia.ts +2 -2
  24. package/{ext/css/src/lib → packages/css/src/ext}/colors/gray.ts +2 -2
  25. package/{ext/css/src/lib → packages/css/src/ext}/colors/green.ts +2 -2
  26. package/{ext/css/src/lib → packages/css/src/ext}/colors/indigo.ts +2 -2
  27. package/{ext/css/src/lib → packages/css/src/ext}/colors/lime.ts +2 -2
  28. package/{ext/css/src/lib → packages/css/src/ext}/colors/neutral.ts +2 -2
  29. package/{ext/css/src/lib → packages/css/src/ext}/colors/orange.ts +2 -2
  30. package/{ext/css/src/lib → packages/css/src/ext}/colors/pink.ts +2 -2
  31. package/{ext/css/src/lib → packages/css/src/ext}/colors/purple.ts +2 -2
  32. package/{ext/css/src/lib → packages/css/src/ext}/colors/red.ts +2 -2
  33. package/{ext/css/src/lib → packages/css/src/ext}/colors/rose.ts +2 -2
  34. package/{ext/css/src/lib → packages/css/src/ext}/colors/sky.ts +2 -2
  35. package/{ext/css/src/lib → packages/css/src/ext}/colors/slate.ts +2 -2
  36. package/{ext/css/src/lib → packages/css/src/ext}/colors/stone.ts +2 -2
  37. package/{ext/css/src/lib → packages/css/src/ext}/colors/teal.ts +2 -2
  38. package/{ext/css/src/lib → packages/css/src/ext}/colors/violet.ts +2 -2
  39. package/{ext/css/src/lib → packages/css/src/ext}/colors/yellow.ts +2 -2
  40. package/{ext/css/src/lib → packages/css/src/ext}/colors/zinc.ts +2 -2
  41. package/packages/css/src/ext/container.ts +32 -0
  42. package/packages/css/src/ext/keyframes.ts +54 -0
  43. package/packages/css/src/ext/media.ts +32 -0
  44. package/packages/css/src/ext/property.ts +48 -0
  45. package/packages/css/src/ext/variable.ts +51 -0
  46. package/{ext → packages}/css/src/index.ts +107 -183
  47. package/{ext → packages}/css/src/lib/colorAssign.ts +1 -1
  48. package/packages/css/src/lib/utils.ts +11 -0
  49. package/{ext → packages}/css/src/structure/$CSSContainerRule.ts +1 -1
  50. package/{ext → packages}/css/src/structure/$CSSKeyframesRule.ts +0 -1
  51. package/{ext → packages}/css/src/structure/$CSSMediaRule.ts +1 -1
  52. package/packages/css/src/structure/$CSSProperty.ts +19 -0
  53. package/{ext → packages}/css/src/structure/$CSSRule.ts +1 -1
  54. package/{ext → packages}/css/src/structure/$CSSStyleRule.ts +1 -1
  55. package/packages/css/src/structure/$CSSVariable.ts +30 -0
  56. package/packages/dom/package.json +20 -0
  57. package/packages/dom/src/lib/HTMLElementMap.ts +213 -0
  58. package/packages/dom/src/lib/assignAttributes.ts +16 -0
  59. package/packages/dom/src/structure/CSS.ts +7 -0
  60. package/packages/dom/src/structure/CSSStyleSheet.ts +10 -0
  61. package/packages/dom/src/structure/DOMTokenList.ts +19 -0
  62. package/packages/dom/src/structure/Document.ts +36 -0
  63. package/packages/dom/src/structure/Element.ts +106 -0
  64. package/packages/dom/src/structure/HTMLElement.ts +34 -0
  65. package/packages/dom/src/structure/History.ts +11 -0
  66. package/packages/dom/src/structure/Location.ts +9 -0
  67. package/packages/dom/src/structure/Node.ts +51 -0
  68. package/packages/dom/src/structure/NodeList.ts +10 -0
  69. package/packages/dom/src/structure/Storage.ts +8 -0
  70. package/packages/dom/src/structure/Text.ts +20 -0
  71. package/packages/dom/src/structure/Window.ts +14 -0
  72. package/packages/dom/src/structure/html/HTMLAbbrElement.ts +16 -0
  73. package/packages/dom/src/structure/html/HTMLAddressElement.ts +16 -0
  74. package/packages/dom/src/structure/html/HTMLAnchorElement.ts +25 -0
  75. package/packages/dom/src/structure/html/HTMLAreaElement.ts +26 -0
  76. package/packages/dom/src/structure/html/HTMLArticleElement.ts +16 -0
  77. package/packages/dom/src/structure/html/HTMLAsideElement.ts +16 -0
  78. package/packages/dom/src/structure/html/HTMLAudioElement.ts +16 -0
  79. package/packages/dom/src/structure/html/HTMLBDIElement.ts +16 -0
  80. package/packages/dom/src/structure/html/HTMLBDOElement.ts +16 -0
  81. package/packages/dom/src/structure/html/HTMLBElement.ts +16 -0
  82. package/packages/dom/src/structure/html/HTMLBRElement.ts +17 -0
  83. package/packages/dom/src/structure/html/HTMLBaseElement.ts +18 -0
  84. package/packages/dom/src/structure/html/HTMLBodyElement.ts +22 -0
  85. package/packages/dom/src/structure/html/HTMLButtonElement.ts +26 -0
  86. package/packages/dom/src/structure/html/HTMLCanvasElement.ts +18 -0
  87. package/packages/dom/src/structure/html/HTMLCiteElement.ts +16 -0
  88. package/packages/dom/src/structure/html/HTMLCodeElement.ts +16 -0
  89. package/packages/dom/src/structure/html/HTMLDDElement.ts +16 -0
  90. package/packages/dom/src/structure/html/HTMLDFNElement.ts +16 -0
  91. package/packages/dom/src/structure/html/HTMLDListElement.ts +17 -0
  92. package/packages/dom/src/structure/html/HTMLDTElement.ts +16 -0
  93. package/packages/dom/src/structure/html/HTMLDataElement.ts +17 -0
  94. package/packages/dom/src/structure/html/HTMLDataListElement.ts +16 -0
  95. package/packages/dom/src/structure/html/HTMLDetailsElement.ts +17 -0
  96. package/packages/dom/src/structure/html/HTMLDialogElement.ts +18 -0
  97. package/packages/dom/src/structure/html/HTMLDivElement.ts +17 -0
  98. package/packages/dom/src/structure/html/HTMLEMElement.ts +16 -0
  99. package/packages/dom/src/structure/html/HTMLEmbedElement.ts +20 -0
  100. package/packages/dom/src/structure/html/HTMLFieldSetElement.ts +19 -0
  101. package/packages/dom/src/structure/html/HTMLFigCaptionElement.ts +16 -0
  102. package/packages/dom/src/structure/html/HTMLFigureElement.ts +16 -0
  103. package/packages/dom/src/structure/html/HTMLFooterElement.ts +16 -0
  104. package/packages/dom/src/structure/html/HTMLFormElement.ts +24 -0
  105. package/packages/dom/src/structure/html/HTMLHGroupElement.ts +16 -0
  106. package/packages/dom/src/structure/html/HTMLHRElement.ts +21 -0
  107. package/packages/dom/src/structure/html/HTMLHeadElement.ts +16 -0
  108. package/packages/dom/src/structure/html/HTMLHeaderElement.ts +16 -0
  109. package/packages/dom/src/structure/html/HTMLHeadingElement.ts +17 -0
  110. package/packages/dom/src/structure/html/HTMLHtmlElement.ts +18 -0
  111. package/packages/dom/src/structure/html/HTMLIElement.ts +16 -0
  112. package/packages/dom/src/structure/html/HTMLIFrameElement.ts +31 -0
  113. package/packages/dom/src/structure/html/HTMLImageElement.ts +38 -0
  114. package/packages/dom/src/structure/html/HTMLInputElement.ts +55 -0
  115. package/packages/dom/src/structure/html/HTMLKBDElement.ts +16 -0
  116. package/packages/dom/src/structure/html/HTMLLIElement.ts +18 -0
  117. package/packages/dom/src/structure/html/HTMLLabelElement.ts +18 -0
  118. package/packages/dom/src/structure/html/HTMLLegendElement.ts +17 -0
  119. package/packages/dom/src/structure/html/HTMLLinkElement.ts +31 -0
  120. package/packages/dom/src/structure/html/HTMLMainElement.ts +16 -0
  121. package/packages/dom/src/structure/html/HTMLMapElement.ts +17 -0
  122. package/packages/dom/src/structure/html/HTMLMarkElement.ts +16 -0
  123. package/packages/dom/src/structure/html/HTMLMediaElement.ts +48 -0
  124. package/packages/dom/src/structure/html/HTMLMenuElement.ts +18 -0
  125. package/packages/dom/src/structure/html/HTMLMetaElement.ts +22 -0
  126. package/packages/dom/src/structure/html/HTMLMeterElement.ts +23 -0
  127. package/packages/dom/src/structure/html/HTMLModElement.ts +18 -0
  128. package/packages/dom/src/structure/html/HTMLNavElement.ts +16 -0
  129. package/packages/dom/src/structure/html/HTMLNoscriptElement.ts +16 -0
  130. package/packages/dom/src/structure/html/HTMLOListElement.ts +20 -0
  131. package/packages/dom/src/structure/html/HTMLObjectElement.ts +34 -0
  132. package/packages/dom/src/structure/html/HTMLOptGroupElement.ts +18 -0
  133. package/packages/dom/src/structure/html/HTMLOptionElement.ts +20 -0
  134. package/packages/dom/src/structure/html/HTMLOutputElement.ts +20 -0
  135. package/packages/dom/src/structure/html/HTMLParagraphElement.ts +17 -0
  136. package/packages/dom/src/structure/html/HTMLPictureElement.ts +16 -0
  137. package/packages/dom/src/structure/html/HTMLPreElement.ts +17 -0
  138. package/packages/dom/src/structure/html/HTMLProgressElement.ts +19 -0
  139. package/packages/dom/src/structure/html/HTMLQuoteElement.ts +17 -0
  140. package/packages/dom/src/structure/html/HTMLRPElement.ts +16 -0
  141. package/packages/dom/src/structure/html/HTMLRTElement.ts +16 -0
  142. package/packages/dom/src/structure/html/HTMLRubyElement.ts +16 -0
  143. package/packages/dom/src/structure/html/HTMLSElement.ts +16 -0
  144. package/packages/dom/src/structure/html/HTMLSampElement.ts +16 -0
  145. package/packages/dom/src/structure/html/HTMLScriptElement.ts +27 -0
  146. package/packages/dom/src/structure/html/HTMLSectionElement.ts +16 -0
  147. package/packages/dom/src/structure/html/HTMLSelectElement.ts +27 -0
  148. package/packages/dom/src/structure/html/HTMLSlotElement.ts +17 -0
  149. package/packages/dom/src/structure/html/HTMLSmallElement.ts +16 -0
  150. package/packages/dom/src/structure/html/HTMLSourceElement.ts +21 -0
  151. package/packages/dom/src/structure/html/HTMLSpanElement.ts +16 -0
  152. package/packages/dom/src/structure/html/HTMLStrongElement.ts +16 -0
  153. package/packages/dom/src/structure/html/HTMLStyleElement.ts +18 -0
  154. package/packages/dom/src/structure/html/HTMLSubElement.ts +16 -0
  155. package/packages/dom/src/structure/html/HTMLSummaryElement.ts +16 -0
  156. package/packages/dom/src/structure/html/HTMLSupElement.ts +16 -0
  157. package/packages/dom/src/structure/html/HTMLTableCaptionElement.ts +17 -0
  158. package/packages/dom/src/structure/html/HTMLTableCellElement.ts +31 -0
  159. package/packages/dom/src/structure/html/HTMLTableColElement.ts +23 -0
  160. package/packages/dom/src/structure/html/HTMLTableElement.ts +26 -0
  161. package/packages/dom/src/structure/html/HTMLTableRowElement.ts +23 -0
  162. package/packages/dom/src/structure/html/HTMLTableSectionElement.ts +20 -0
  163. package/packages/dom/src/structure/html/HTMLTemplateElement.ts +17 -0
  164. package/packages/dom/src/structure/html/HTMLTextAreaElement.ts +33 -0
  165. package/packages/dom/src/structure/html/HTMLTimeElement.ts +17 -0
  166. package/packages/dom/src/structure/html/HTMLTitleElement.ts +17 -0
  167. package/packages/dom/src/structure/html/HTMLTrackElement.ts +21 -0
  168. package/packages/dom/src/structure/html/HTMLUElement.ts +16 -0
  169. package/packages/dom/src/structure/html/HTMLUListElement.ts +18 -0
  170. package/packages/dom/src/structure/html/HTMLVarElement.ts +16 -0
  171. package/packages/dom/src/structure/html/HTMLVideoElement.ts +22 -0
  172. package/packages/dom/src/structure/html/HTMLWBRElement.ts +16 -0
  173. package/packages/html/package.json +18 -0
  174. package/{ext/html/html.ts → packages/html/src/index.ts} +1 -1
  175. package/{ext/html → packages/html/src}/node/$Anchor.ts +3 -3
  176. package/packages/html/src/node/$Canvas.ts +38 -0
  177. package/{ext/html → packages/html/src}/node/$Dialog.ts +3 -3
  178. package/{ext/html → packages/html/src}/node/$Form.ts +3 -3
  179. package/{ext/html → packages/html/src}/node/$Image.ts +3 -3
  180. package/{ext/html → packages/html/src}/node/$Input.ts +3 -3
  181. package/{ext/html → packages/html/src}/node/$Label.ts +3 -3
  182. package/{ext/html → packages/html/src}/node/$Media.ts +3 -3
  183. package/{ext/html → packages/html/src}/node/$OptGroup.ts +3 -3
  184. package/{ext/html → packages/html/src}/node/$Option.ts +3 -3
  185. package/{ext/html → packages/html/src}/node/$Select.ts +3 -3
  186. package/{ext/html → packages/html/src}/node/$TextArea.ts +3 -3
  187. package/packages/i18n/package.json +19 -0
  188. package/{ext → packages}/i18n/src/index.ts +6 -14
  189. package/{ext → packages}/i18n/src/structure/I18n.ts +2 -2
  190. package/{ext → packages}/i18n/src/structure/I18nDictionary.ts +1 -1
  191. package/{ext → packages}/i18n/src/structure/I18nTranslation.ts +10 -4
  192. package/packages/idb/package.json +19 -0
  193. package/{ext → packages}/idb/src/index.ts +2 -2
  194. package/{ext → packages}/idb/src/lib/$IDBRequest.ts +1 -1
  195. package/{ext → packages}/idb/src/structure/$IDB.ts +1 -1
  196. package/{ext → packages}/idb/src/structure/$IDBCursor.ts +1 -1
  197. package/{ext → packages}/idb/src/structure/$IDBIndex.ts +1 -1
  198. package/{ext → packages}/idb/src/structure/$IDBStore.ts +1 -1
  199. package/{ext → packages}/idb/src/structure/$IDBStoreBase.ts +1 -1
  200. package/{ext → packages}/idb/src/structure/$IDBTransaction.ts +1 -1
  201. package/{ext → packages}/idb/src/structure/builder/$IDBBuilder.ts +1 -2
  202. package/{ext → packages}/idb/src/structure/builder/$IDBStoreBuilder.ts +1 -1
  203. package/packages/markdown/package.json +19 -0
  204. package/{ext → packages}/markdown/src/lib/util.ts +1 -1
  205. package/{ext → packages}/markdown/src/structure/MarkdownLexer.ts +2 -2
  206. package/{ext → packages}/markdown/src/structure/MarkdownParser.ts +2 -1
  207. package/{ext → packages}/markdown/src/syntax/alert.ts +1 -1
  208. package/{ext → packages}/markdown/src/syntax/codeblock.ts +1 -1
  209. package/{ext → packages}/markdown/src/syntax/link.ts +2 -2
  210. package/{ext → packages}/markdown/src/syntax/list.ts +1 -1
  211. package/{ext → packages}/markdown/src/syntax/table.ts +1 -1
  212. package/packages/router/package.json +19 -0
  213. package/{ext → packages}/router/src/index.ts +4 -5
  214. package/{ext → packages}/router/src/node/Page.ts +8 -4
  215. package/{ext → packages}/router/src/node/Router.ts +79 -58
  216. package/{ext → packages}/router/src/node/RouterAnchor.ts +2 -2
  217. package/{ext → packages}/router/src/structure/PageBuilder.ts +3 -3
  218. package/{ext → packages}/router/src/structure/Route.ts +1 -1
  219. package/packages/signal/package.json +18 -0
  220. package/packages/signal/src/index.ts +221 -0
  221. package/{ext → packages}/signal/src/structure/Signal.ts +1 -1
  222. package/{ext → packages}/ui/lib/VirtualScroll.ts +5 -5
  223. package/{ext → packages}/ui/node/Accordian.ts +4 -4
  224. package/packages/ui/node/Carousel.ts +20 -0
  225. package/{ext → packages}/ui/node/Form.ts +7 -6
  226. package/packages/ui/node/Modal.ts +45 -0
  227. package/{ext → packages}/ui/node/Table.ts +1 -1
  228. package/{ext → packages}/ui/node/Tabs.ts +28 -13
  229. package/{ext → packages}/ui/node/Toast.ts +2 -2
  230. package/packages/ui/node/Waterfall.ts +94 -0
  231. package/packages/ui/package.json +21 -0
  232. package/packages/utils/package.json +17 -0
  233. package/{src → packages/utils/src}/global.ts +5 -18
  234. package/{src/lib/native.ts → packages/utils/src/index.ts} +34 -1
  235. package/tsconfig.json +1 -1
  236. package/ext/css/package.json +0 -9
  237. package/ext/css/src/structure/$CSSVariable.ts +0 -12
  238. package/ext/html/node/$Canvas.ts +0 -16
  239. package/ext/i18n/package.json +0 -10
  240. package/ext/idb/package.json +0 -13
  241. package/ext/markdown/package.json +0 -15
  242. package/ext/router/package.json +0 -10
  243. package/ext/signal/package.json +0 -9
  244. package/ext/signal/src/index.ts +0 -128
  245. package/ext/ssr/env.ts +0 -61
  246. package/ext/ssr/index.ts +0 -49
  247. package/ext/ssr/package.json +0 -10
  248. package/ext/ui/node/Waterfall.ts +0 -72
  249. package/ext/ui/package.json +0 -11
  250. package/src/index.ts +0 -2
  251. package/src/lib/chain.ts +0 -13
  252. package/src/lib/debounce.ts +0 -7
  253. package/src/lib/env.ts +0 -2
  254. package/src/lib/randomId.ts +0 -9
  255. package/src/lib/sleep.ts +0 -3
  256. package/src/lib/toArray.ts +0 -9
  257. package/src/lib/trycatch.ts +0 -17
  258. package/src/lib/uppercase.ts +0 -3
  259. /package/{src/node.ts → packages/core/src/lib/assignNodeProperties.ts} +0 -0
  260. /package/{ext → packages}/css/README.md +0 -0
  261. /package/{ext/css/src/lib → packages/css/src/ext}/colors.ts +0 -0
  262. /package/{ext → packages}/css/src/structure/$CSSDeclaration.ts +0 -0
  263. /package/{ext → packages}/i18n/README.md +0 -0
  264. /package/{ext → packages}/idb/README.md +0 -0
  265. /package/{ext → packages}/idb/src/core.ts +0 -0
  266. /package/{ext → packages}/markdown/README.md +0 -0
  267. /package/{ext → packages}/markdown/src/index.ts +0 -0
  268. /package/{ext → packages}/markdown/src/lib/type.ts +0 -0
  269. /package/{ext → packages}/markdown/src/structure/Markdown.ts +0 -0
  270. /package/{ext → packages}/markdown/src/syntax/blockquote.ts +0 -0
  271. /package/{ext → packages}/markdown/src/syntax/bold.ts +0 -0
  272. /package/{ext → packages}/markdown/src/syntax/code.ts +0 -0
  273. /package/{ext → packages}/markdown/src/syntax/heading.ts +0 -0
  274. /package/{ext → packages}/markdown/src/syntax/horizontalRule.ts +0 -0
  275. /package/{ext → packages}/markdown/src/syntax/image.ts +0 -0
  276. /package/{ext → packages}/markdown/src/syntax/italic.ts +0 -0
  277. /package/{ext → packages}/markdown/src/syntax/text.ts +0 -0
  278. /package/{ext → packages}/router/README.md +0 -0
  279. /package/{ext → packages}/signal/README.md +0 -0
  280. /package/{ext → packages}/ui/node/Grid.ts +0 -0
@@ -1,4 +1,4 @@
1
- import { $HTMLElement } from "../../../src/node/$HTMLElement";
1
+ import { $HTMLElement } from "@amateras/core/node/$HTMLElement";
2
2
 
3
3
  export class Table extends $HTMLElement {
4
4
  constructor() {
@@ -1,8 +1,23 @@
1
- import { _Array_from, _instanceof, forEach, isUndefined } from "amateras/lib/native";
2
- import { $HTMLElement } from "amateras/node/$HTMLElement";
3
- import type { $Node } from "amateras/node/$Node";
1
+ import { chain } from "@amateras/core/lib/chain";
2
+ import { $HTMLElement } from "@amateras/core/node/$HTMLElement";
3
+ import type { $Node } from "@amateras/core/node/$Node";
4
+ import { _Array_from, _instanceof, forEach, isUndefined } from "@amateras/utils";
4
5
 
5
- $.style('tabs,tabs-container,tabs-list,tabs-content{display: block}')
6
+ const TAB = 'tab';
7
+ const TAB_CONTENT = 'tab-content';
8
+ const TAB_TRIGGER = 'tab-trigger';
9
+ const TAB_CONTAINER = 'tab-container';
10
+ const TAB_LIST = 'tab-list';
11
+
12
+ const DISPLAY_BLOCK = 'display:block'
13
+
14
+ forEach([
15
+ `${TAB}{${DISPLAY_BLOCK}}`,
16
+ `${TAB_CONTENT}{${DISPLAY_BLOCK}}`,
17
+ `${TAB_LIST}{${DISPLAY_BLOCK}}`,
18
+ `${TAB_CONTAINER}{${DISPLAY_BLOCK}}`,
19
+ `${TAB_TRIGGER}{cursor:pointer}`
20
+ ], $.style)
6
21
 
7
22
  export class Tabs extends $HTMLElement {
8
23
  #value: null | string = null;
@@ -10,7 +25,7 @@ export class Tabs extends $HTMLElement {
10
25
  $container: null | TabsContainer = null;
11
26
  $list: null | TabsList = null;
12
27
  constructor() {
13
- super('tabs');
28
+ super(TAB);
14
29
  }
15
30
 
16
31
  value(): string | null;
@@ -22,13 +37,17 @@ export class Tabs extends $HTMLElement {
22
37
  this.$list?.check();
23
38
  })
24
39
  }
40
+
41
+ mounted($parent: $Node): void {
42
+ this.$list?.check();
43
+ }
25
44
  }
26
45
 
27
46
  export class TabsContainer extends $HTMLElement {
28
47
  $tabs?: Tabs;
29
48
  contentMap = new Map<string, TabsContent>();
30
49
  constructor($tabs?: Tabs) {
31
- super('tabs-container');
50
+ super(TAB_CONTAINER);
32
51
  this.$tabs = $tabs;
33
52
  }
34
53
 
@@ -46,7 +65,7 @@ export class TabsContent extends $HTMLElement {
46
65
  #value: string;
47
66
  $container: null | TabsContainer = null;
48
67
  constructor(value: string) {
49
- super('tabs-content');
68
+ super(TAB_CONTENT);
50
69
  this.#value = value
51
70
  }
52
71
 
@@ -73,7 +92,7 @@ export class TabsList extends $HTMLElement {
73
92
  $tabs?: null | Tabs = null;
74
93
  triggers = new Map<string, TabsTrigger>();
75
94
  constructor($tabs?: Tabs) {
76
- super('tabs-list');
95
+ super(TAB_LIST);
77
96
  this.$tabs = $tabs;
78
97
  this.on('click', _ => this.check())
79
98
  }
@@ -97,7 +116,7 @@ export class TabsTrigger extends $HTMLElement {
97
116
  #value: string;
98
117
  $tabs?: null | Tabs = null;
99
118
  constructor(value: string) {
100
- super('tabs-trigger');
119
+ super(TAB_TRIGGER);
101
120
  this.#value = value;
102
121
  this.on('click', _ => this.$tabs?.value(this.#value ?? undefined))
103
122
  }
@@ -107,8 +126,4 @@ export class TabsTrigger extends $HTMLElement {
107
126
  value(value?: string) {
108
127
  return chain(this, arguments, () => this.#value, value, value => this.#value = value)
109
128
  }
110
- }
111
-
112
- function chain<T, R, V>(_this: T, args: IArguments, get: () => R, value: V, set: (value: Exclude<V, undefined>) => any) {
113
- return !args.length ? get() : isUndefined(value) ? _this : (set(value as any), _this);
114
129
  }
@@ -1,5 +1,5 @@
1
- import { _document } from "../../../src/lib/env";
2
- import { $HTMLElement } from "../../../src/node/$HTMLElement";
1
+ import { _document } from "@amateras/core/env";
2
+ import { $HTMLElement } from "@amateras/core/node/$HTMLElement";
3
3
 
4
4
  $.style('toast{position:absolute}')
5
5
 
@@ -0,0 +1,94 @@
1
+ import { onclient, onserver } from "@amateras/core/env";
2
+ import { chain } from "@amateras/core/lib/chain";
3
+ import type { $Element } from "@amateras/core/node/$Element";
4
+ import { $HTMLElement } from "@amateras/core/node/$HTMLElement";
5
+ import { $Virtual } from "@amateras/core/node/$Virtual";
6
+ import { _Array_from, _instanceof, forEach } from "@amateras/utils";
7
+
8
+ const getRect = (el: $Element) => el.getBoundingClientRect();
9
+ const px = (value: number) => `${value}px`;
10
+ $.style(`waterfall{display:block;position:relative}`)
11
+
12
+ export class Waterfall extends $Virtual {
13
+ #column: number | null = null;
14
+ #columnWidth: number = 200;
15
+ #mode: WaterfallMode = 'fill';
16
+ #gap = 0;
17
+ #width = 0;
18
+ constructor() {
19
+ super('waterfall');
20
+ onclient(() => {
21
+ new ResizeObserver(_ => this.inDOM() && this.#width !== getRect(this).width && (this.dispatchEvent(new Event('resize', {cancelable: true})) && this.layout())).observe(this.node);
22
+ })
23
+ }
24
+
25
+ mode(): WaterfallMode;
26
+ mode(mode: $Parameter<'fill' | 'fixed'>): this;
27
+ mode(mode?: $Parameter<'fill' | 'fixed'>) {
28
+ return chain(this, arguments, () => this.#mode, mode, value => this.#mode = value);
29
+ }
30
+
31
+ column(): number | null;
32
+ column(column: $Parameter<number | null>): this;
33
+ column(column?: $Parameter<number | null>) {
34
+ return chain(this, arguments, () => this.#column, column, value => this.#column = value);
35
+ }
36
+
37
+ columnWidth(): number
38
+ columnWidth(width: $Parameter<number>): this
39
+ columnWidth(width?: $Parameter<number>) {
40
+ return chain(this, arguments, () => this.#columnWidth, width, value => this.#columnWidth = value)
41
+ }
42
+
43
+ gap(): number;
44
+ gap(gap: $Parameter<number>): this;
45
+ gap(gap?: $Parameter<number>) {
46
+ return chain(this, arguments, () => this.#gap, gap, value => this.#gap = value);
47
+ }
48
+
49
+ layout() {
50
+ if (onserver()) return;
51
+ const items = _Array_from(this.nodes).map(item => item);
52
+ const { width } = getRect(this);
53
+ this.#width = width;
54
+ const gap = this.#gap;
55
+ const columnCount = (() => {
56
+ if (this.#column) return this.#column;
57
+ const colCount = Math.floor(width / this.#columnWidth) || 1;
58
+ return ((colCount - 1) * gap) + this.#columnWidth * colCount > width ? colCount - 1 || 1 : colCount;
59
+ })()
60
+ const maxColumnWidth = (width - ((columnCount - 1) * gap)) / columnCount
61
+ const columnWidth = this.#mode === 'fill' ? maxColumnWidth : this.#columnWidth;
62
+ const padding = (width - columnWidth * columnCount - gap * (columnCount - 1)) / 2;
63
+ const columns = _Array_from({length: columnCount}).map((_, i) => ({ i, h: 0, x: i * (columnWidth + gap) + padding }))
64
+ const getColumnByHeight = (i: number) => columns.sort((a, b) => a.h - b.h ? a.h - b.h : a.i - b.i).at(i) as typeof columns[number];
65
+ forEach(items, item => {
66
+ if (!_instanceof(item, $HTMLElement)) return;
67
+ const { height, width } = item.attr();
68
+ const shortestSection = getColumnByHeight(0);
69
+ item.style({
70
+ position: 'absolute',
71
+ top: px(shortestSection.h),
72
+ left: px(shortestSection.x),
73
+ width: px(columnWidth),
74
+ });
75
+ if (width && height) {
76
+ // get ratio from attributes and calculate item's height
77
+ let itemHeight = columnWidth / (+width / +height);
78
+ item.style({ height: px(itemHeight) })
79
+ shortestSection.h += +itemHeight + gap;
80
+ } else {
81
+ item.style({ visibility: 'hidden', height: '' })
82
+ if (this.hiddenNodes.has(item)) this.show(item).render().hide(item);
83
+ let itemHeight = getRect(item).height;
84
+ item.style({ visibility: '', height: px(itemHeight) })
85
+ shortestSection.h += +itemHeight + gap;
86
+ }
87
+ })
88
+ this.style({ height: px(getColumnByHeight(-1).h) });
89
+ this.dispatchEvent(new Event('layout'))
90
+ return this;
91
+ }
92
+ }
93
+
94
+ export type WaterfallMode = 'fill' | 'fixed'
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@amateras/ui",
3
+ "peerDependencies": {
4
+ "@amateras/core": "workspace:*",
5
+ "@amateras/html": "workspace:*",
6
+ "@amateras/utils": "workspace:*"
7
+ },
8
+ "imports": {
9
+ "#structure/*": "./src/structure/*.ts",
10
+ "#lib/*": "./src/lib/*.ts",
11
+ "#node/*": "./src/node/*.ts"
12
+ },
13
+ "exports": {
14
+ "./structure/*": "./src/structure/*.ts",
15
+ "./lib/*": "./src/lib/*.ts",
16
+ "./node/*": "./src/node/*.ts",
17
+ "./waterfall": "./node/Waterfall.ts",
18
+ "./tabs": "./node/Tabs.ts",
19
+ "./virtual-scroll": "./lib/VirtualScroll.ts"
20
+ }
21
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "@amateras/utils",
3
+ "peerDependencies": {
4
+ "@amateras/core": "workspace:*"
5
+ },
6
+ "imports": {
7
+ "#structure/*": "./src/structure/*.ts",
8
+ "#lib/*": "./src/lib/*.ts",
9
+ "#node/*": "./src/node/*.ts"
10
+ },
11
+ "exports": {
12
+ ".": "./src/index.ts",
13
+ "./structure/*": "./src/structure/*.ts",
14
+ "./lib/*": "./src/lib/*.ts",
15
+ "./node/*": "./src/node/*.ts"
16
+ }
17
+ }
@@ -1,10 +1,4 @@
1
- import type { $Element } from '#node/$Element';
2
- import type { $Node } from '#node/$Node';
3
- import * as core from '#core';
4
- import type { $EventTarget } from '#node/$EventTarget';
5
-
6
1
  declare global {
7
- export import $ = core.$;
8
2
  type Nullish = null | undefined;
9
3
  type OrArray<T> = T | T[];
10
4
  type OrMatrix<T> = T | OrMatrix<T>[];
@@ -15,24 +9,17 @@ declare global {
15
9
  -readonly [P in keyof T]: T[P];
16
10
  }
17
11
  type AsyncFunction<T> = () => Promise<T>;
18
- type $Parameter<T> = T | undefined | $.$NodeParameterExtends<T>
19
12
  type Ok<D> = [data: D, err: null];
20
13
  type Err<E> = [data: null, err: E]
21
14
  type Result<D, E> = Ok<D> | Err<E>
22
15
  type Repeat<T, N extends number, Acc extends T[] = []> =
23
- Acc['length'] extends N
24
- ? Acc
16
+ Acc['length'] extends 500
17
+ ? T[]
18
+ : Acc['length'] extends N
19
+ ? Acc
25
20
  : Repeat<T, N, [...Acc, T]>;
26
21
  type Prettify<T> = {
27
22
  [K in keyof T]: T[K];
28
23
  } & {};
29
- interface Node {
30
- readonly $: $Node
31
- }
32
- interface EventTarget {
33
- readonly $: $EventTarget
34
- }
35
- interface Element {
36
- readonly $: $Element
37
- }
24
+ type Narrow<T> = T extends boolean ? boolean : T;
38
25
  }
@@ -1,3 +1,5 @@
1
+ import './global';
2
+
1
3
  // Value
2
4
  export const _null = null;
3
5
  export const _undefined = undefined;
@@ -54,4 +56,35 @@ export const slice: slice = (target: any, start?: number, end?: number) => targe
54
56
  // Function
55
57
  export const _bind = <T extends Function>(target: T, obj: Object): T => target.bind(obj);
56
58
  // Promise
57
- export const _Promise = Promise;
59
+ export const _Promise = Promise;
60
+
61
+ // utils function
62
+ export const debounce = () => {
63
+ let timer: number;
64
+ return (fn: Function, timeout: number) => {
65
+ if (timer) clearTimeout(timer);
66
+ timer = setTimeout(fn, timeout);
67
+ }
68
+ }
69
+
70
+ const LOWER = 'abcdefghijklmnopqrstuvwxyz';
71
+ const UPPER = LOWER.toUpperCase();
72
+ export const randomId = (options?: {length?: number, lettercase?: 'any' | 'lower' | 'upper'}): string => {
73
+ options = {length: 5, lettercase: 'any', ...options};
74
+ const char = options.lettercase === 'any' ? LOWER + UPPER : options.lettercase === 'lower' ? LOWER : UPPER;
75
+ return _Array_from({length: options.length as number}, (_, i) => char[Math.round(Math.random() * char.length)]).join('');
76
+ }
77
+
78
+ export const sleep = async (ms: number) => new _Promise(resolve => setTimeout(resolve, ms));
79
+
80
+ export const toArray = <T>(item: OrArray<T>): T[] => _instanceof(item, Array) ? item : [item];
81
+
82
+ export const trycatch = <D>(callback: () => D): Result<D, Error> => {
83
+ try {
84
+ return [callback(), _null];
85
+ } catch (err) {
86
+ return [_null, _instanceof(err, Error) ? err : new Error(_JSON_stringify(err))];
87
+ }
88
+ }
89
+
90
+ export const uppercase = (str: string, start?: number, end?: number) => `${slice(str, 0, start)}${slice(str, start, end).toUpperCase()}${end ? slice(str, end) : ''}`
package/tsconfig.json CHANGED
@@ -25,5 +25,5 @@
25
25
  "noUnusedParameters": false,
26
26
  "noPropertyAccessFromIndexSignature": false
27
27
  },
28
- "exclude": ["dist"]
28
+ "exclude": ["deprecated"]
29
29
  }
@@ -1,9 +0,0 @@
1
- {
2
- "name": "@amateras/css",
3
- "peerDependencies": {
4
- "amateras": "../../"
5
- },
6
- "imports": {
7
- "#structure/*": "./src/structure/*.ts"
8
- }
9
- }
@@ -1,12 +0,0 @@
1
- export class $CSSVariable<V = string> {
2
- key: string;
3
- value: V;
4
- constructor(key: string, value: V) {
5
- this.key = key;
6
- this.value = value;
7
- }
8
-
9
- toString() {
10
- return `var(--${this.key})`
11
- }
12
- }
@@ -1,16 +0,0 @@
1
- import { assignProperties } from "#lib/assignProperties";
2
- import { $HTMLElement } from "#node/$HTMLElement";
3
-
4
- export class $Canvas extends $HTMLElement<HTMLCanvasElement> {
5
- constructor() {
6
- super('canvas')
7
- }
8
- }
9
-
10
- export interface $Canvas extends $HTMLElement<HTMLCanvasElement> {}
11
-
12
- assignProperties(HTMLCanvasElement, $Canvas, 'canvas');
13
-
14
- declare module '#core' {
15
- export function $(nodeName: 'canvas'): $Canvas
16
- }
@@ -1,10 +0,0 @@
1
- {
2
- "name": "@amateras/i18n",
3
- "peerDependencies": {
4
- "amateras": "../../"
5
- },
6
- "imports": {
7
- "#structure/*": "./src/structure/*.ts",
8
- "#node/*": "./src/node/*.ts"
9
- }
10
- }
@@ -1,13 +0,0 @@
1
- {
2
- "name": "@amateras/idb",
3
- "peerDependencies": {
4
- "amateras": "../../"
5
- },
6
- "imports": {
7
- "#structure/*": "./src/structure/*.ts",
8
- "#lib/*": "./src/lib/*.ts"
9
- },
10
- "exports": {
11
- "./core": "./src/core.ts"
12
- }
13
- }
@@ -1,15 +0,0 @@
1
- {
2
- "name": "@amateras/markdown",
3
- "peerDependencies": {
4
- "amateras": "../../"
5
- },
6
- "imports": {
7
- "#structure/*": "./src/structure/*.ts",
8
- "#lib/*": "./src/lib/*.ts"
9
- },
10
- "exports": {
11
- "./structure/*": "./src/structure/*.ts",
12
- "./lib/*": "./src/lib/*.ts",
13
- "./syntax/*": "./src/syntax/*.ts"
14
- }
15
- }
@@ -1,10 +0,0 @@
1
- {
2
- "name": "@amateras/router",
3
- "peerDependencies": {
4
- "amateras": "../../"
5
- },
6
- "imports": {
7
- "#node/*": "./src/node/*.ts",
8
- "#structure/*": "./src/structure/*.ts"
9
- }
10
- }
@@ -1,9 +0,0 @@
1
- {
2
- "name": "@amateras/signal",
3
- "peerDependencies": {
4
- "amateras": "../../"
5
- },
6
- "imports": {
7
- "#structure/*": "./src/structure/*.ts"
8
- }
9
- }
@@ -1,128 +0,0 @@
1
- import { Signal } from "#structure/Signal";
2
- import { _document } from "amateras/lib/env";
3
- import { _instanceof, isObject, _JSON_stringify, _Object_assign, forEach, _null, _Object_defineProperty, _Object_entries, isNull, isFunction } from "amateras/lib/native";
4
- import { $Node, $Text } from "amateras/node/$Node";
5
-
6
- // handle $Node content process
7
- $Node.processors.add((_, content) => {
8
- const signal = (content as SignalFunction<any>)?.signal;
9
- if (_instanceof(signal, Signal)) {
10
- const resolver = (content as SignalFunction<any>)();
11
- if (_instanceof(resolver, $Node)) {
12
- // handler signal $Node result
13
- let node = resolver;
14
- const set = (value: any) => {
15
- node.replace(value);
16
- node = value;
17
- }
18
- signal.subscribe(set);
19
- return [resolver];
20
- } else {
21
- // handler signal other type result
22
- const $text = new $Text()
23
- const set = (value: any) => $text.textContent(isObject(value) ? _JSON_stringify(value) : value);
24
- signal.subscribe(set);
25
- set(resolver);
26
- return [$text];
27
- }
28
- }
29
- })
30
-
31
- // handle $Node native method setter
32
- $Node.setters.add((value, set) => {
33
- const signal = value?.signal
34
- if (isFunction(value) && _instanceof(signal, Signal)) {
35
- signal.subscribe(set);
36
- return value();
37
- }
38
- })
39
-
40
- declare module 'amateras/core' {
41
- export namespace $ {
42
- export function signal<T>(value: T): SignalFunction<T>;
43
- export function compute<T>(process: () => T): ComputeFunction<T>;
44
- export function effect(process: () => void): void;
45
- export interface $NodeContentMap {
46
- signalFn: SignalFunction<any>;
47
- computeFn: ComputeFunction<any>;
48
- }
49
- export interface $NodeParameterMap<T> {
50
- signalFn: SignalFunction<T>
51
- }
52
- }
53
- }
54
-
55
- type SignalObject<T> = T extends Array<any> ? {} : T extends object ? { [key in keyof T as `${string & key}$`]: SignalFunction<T[key]> } : {};
56
- export type SignalFunction<T> = {
57
- signal: Signal<T>,
58
- set: (newValue: T | ((oldValue: T) => T)) => SignalFunction<T>,
59
- value: () => T;
60
- } & (() => T) & SignalObject<T>;
61
- export type ComputeFunction<T> = ({(): T}) & { signal: Signal<T> };
62
-
63
- const signalComputeListeners = new Set<(signal: Signal<any>) => void>();
64
- const signalEffectListeners = new Set<(signal: Signal<any>) => void>();
65
- const signalFnMap = new Map<any, SignalFunction<any> | ComputeFunction<any>>();
66
-
67
- // experiment feature
68
- const nestedComputeFn = (value: any, parentSignalFn: SignalFunction<any> | ComputeFunction<any>) => {
69
- if (isObject(value) && !isNull(value)) {
70
- forEach(_Object_entries(value), ([key, val]) => {
71
- const cachedFn = signalFnMap.get(val);
72
- const val$ = cachedFn ?? $.compute(() => parentSignalFn()[key]);
73
- if (!cachedFn && isObject(val)) {
74
- signalFnMap.set(val, val$);
75
- nestedComputeFn(val, val$)
76
- }
77
- _Object_defineProperty(parentSignalFn, `${key}$`, {value: val$});
78
- })
79
- }
80
- }
81
-
82
- _Object_assign($, {
83
- // signal function
84
- signal<T>(value: T): SignalFunction<T> {
85
- const signal = new Signal<T>(value);
86
- const signalFn = function () {
87
- forEach([...signalComputeListeners, ...signalEffectListeners], fn => fn(signal));
88
- return signal.value();
89
- } as SignalFunction<T>
90
- nestedComputeFn(value, signalFn);
91
- _Object_assign(signalFn, {
92
- signal,
93
- set: (newValue: T) => (signal.value(newValue), signalFn),
94
- value: () => signal.value()
95
- })
96
- return signalFn
97
- },
98
-
99
- // compute function
100
- compute<T>(process: () => T): ComputeFunction<T> {
101
- let subscribed = false;
102
- const signalFn: SignalFunction<any> = $.signal(_null);
103
- const computeFn = () => {
104
- if (!subscribed) return signalFn.set(subscribe()).value();
105
- else return signalFn.set(process()).value();
106
- }
107
- const subscribe = () => {
108
- const signalHandler = (signal: Signal<any>) =>
109
- signal.subscribe(() => signalFn.set(process()))
110
- signalComputeListeners.add(signalHandler);
111
- const result = process();
112
- signalComputeListeners.delete(signalHandler);
113
- subscribed = true;
114
- return result;
115
- }
116
- _Object_assign(computeFn, { signal: signalFn.signal });
117
- return computeFn as ComputeFunction<T>
118
- },
119
-
120
- // effect
121
- effect(process: () => void) {
122
- const signalHandler = (signal: Signal<any>) =>
123
- signal.subscribe(process);
124
- signalEffectListeners.add(signalHandler);
125
- process();
126
- signalEffectListeners.delete(signalHandler);
127
- }
128
- })
package/ext/ssr/env.ts DELETED
@@ -1,61 +0,0 @@
1
- import { NODE } from "esm-env";
2
- import { _Array_from, _Object_assign, _Object_entries, isNull } from "../../src/lib/native";
3
- import type { $Node } from "../../src/node/$Node";
4
-
5
- if (NODE) {
6
- //@ts-expect-error
7
- global.window = undefined;
8
- //@ts-expect-error
9
- global.document = undefined;
10
- //@ts-expect-error
11
- global.Node = class Node {
12
- nodeName: string;
13
- attributes = {};
14
- childNodes = new Set<Node>();
15
- parent?: Node;
16
- $!: $Node;
17
- constructor(nodeName: string) {
18
- this.nodeName = nodeName.toUpperCase();
19
- }
20
- get textContent() { return _Array_from(this.childNodes.values()).map(node => node.textContent).join() }
21
- set textContent(content: string | null) {
22
- this.childNodes.clear();
23
- content && this.childNodes.add(new Text(content) as unknown as Node);
24
- }
25
- appendChild(node: Node) {
26
- if (this.childNodes.has(node)) this.childNodes.delete(node);
27
- this.childNodes.add(node);
28
- node.parent = this;
29
- }
30
- addEventListener(type: string, cb: () => void) { }
31
- setAttribute(key: string, value: string) { _Object_assign(this.attributes, {[key]: value}) }
32
- remove() {
33
- this.parent?.removeChild(this);
34
- }
35
- removeChild(node: Node) {
36
- this.childNodes.delete(node);
37
- }
38
-
39
- get outerHTML() {
40
- const attr = _Object_entries(this.attributes).map(([key, value]) => `${key}="${value}"`).join(' ');
41
- const tagName = this.nodeName.toLowerCase();
42
- const IS_VOID_ELEMENT = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr'].includes(tagName);
43
- return `<${tagName}${attr ? ` ${attr}` : ''}>${_Array_from(this.childNodes).map(node => `${node.$}`).join('')}${IS_VOID_ELEMENT && !this.childNodes.size ? '' : `</${tagName}>`}`;
44
- }
45
- }
46
- //@ts-expect-error
47
- global.Element = class Element {}
48
- //@ts-expect-error
49
- global.HTMLElement = class HTMLElement {}
50
- //@ts-expect-error
51
- global.Text = class Text {
52
- textContent: string;
53
- $: this;
54
- constructor(textContent: string) {
55
- this.textContent = textContent;
56
- this.$ = this;
57
- }
58
-
59
- toString() { return this.textContent }
60
- }
61
- }