amateras 0.7.4 → 0.10.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 (257) hide show
  1. package/README.md +76 -85
  2. package/package.json +29 -33
  3. package/tsconfig.json +4 -3
  4. package/packages/core/package.json +0 -32
  5. package/packages/core/src/env.browser.ts +0 -21
  6. package/packages/core/src/env.node.ts +0 -21
  7. package/packages/core/src/global.ts +0 -18
  8. package/packages/core/src/index.ts +0 -96
  9. package/packages/core/src/lib/assignNodeProperties.ts +0 -11
  10. package/packages/core/src/lib/assignProperties.ts +0 -57
  11. package/packages/core/src/lib/chain.ts +0 -17
  12. package/packages/core/src/lib/dom.ts +0 -20
  13. package/packages/core/src/main.ts +0 -4
  14. package/packages/core/src/node/$Element.ts +0 -366
  15. package/packages/core/src/node/$EventTarget.ts +0 -48
  16. package/packages/core/src/node/$HTMLElement.ts +0 -99
  17. package/packages/core/src/node/$Node.ts +0 -201
  18. package/packages/core/src/node/$Virtual.ts +0 -65
  19. package/packages/css/README.md +0 -128
  20. package/packages/css/package.json +0 -17
  21. package/packages/css/src/ext/colors/amber.ts +0 -25
  22. package/packages/css/src/ext/colors/blackwhite.ts +0 -13
  23. package/packages/css/src/ext/colors/blue.ts +0 -25
  24. package/packages/css/src/ext/colors/cyan.ts +0 -25
  25. package/packages/css/src/ext/colors/emerald.ts +0 -25
  26. package/packages/css/src/ext/colors/fuchsia.ts +0 -25
  27. package/packages/css/src/ext/colors/gray.ts +0 -25
  28. package/packages/css/src/ext/colors/green.ts +0 -25
  29. package/packages/css/src/ext/colors/indigo.ts +0 -25
  30. package/packages/css/src/ext/colors/lime.ts +0 -25
  31. package/packages/css/src/ext/colors/neutral.ts +0 -25
  32. package/packages/css/src/ext/colors/orange.ts +0 -25
  33. package/packages/css/src/ext/colors/pink.ts +0 -25
  34. package/packages/css/src/ext/colors/purple.ts +0 -25
  35. package/packages/css/src/ext/colors/red.ts +0 -25
  36. package/packages/css/src/ext/colors/rose.ts +0 -25
  37. package/packages/css/src/ext/colors/sky.ts +0 -25
  38. package/packages/css/src/ext/colors/slate.ts +0 -25
  39. package/packages/css/src/ext/colors/stone.ts +0 -25
  40. package/packages/css/src/ext/colors/teal.ts +0 -25
  41. package/packages/css/src/ext/colors/violet.ts +0 -25
  42. package/packages/css/src/ext/colors/yellow.ts +0 -25
  43. package/packages/css/src/ext/colors/zinc.ts +0 -25
  44. package/packages/css/src/ext/colors.ts +0 -23
  45. package/packages/css/src/ext/container.ts +0 -32
  46. package/packages/css/src/ext/keyframes.ts +0 -54
  47. package/packages/css/src/ext/media.ts +0 -32
  48. package/packages/css/src/ext/property.ts +0 -48
  49. package/packages/css/src/ext/variable.ts +0 -51
  50. package/packages/css/src/index.ts +0 -436
  51. package/packages/css/src/lib/colorAssign.ts +0 -6
  52. package/packages/css/src/lib/utils.ts +0 -11
  53. package/packages/css/src/structure/$CSSContainerRule.ts +0 -13
  54. package/packages/css/src/structure/$CSSDeclaration.ts +0 -16
  55. package/packages/css/src/structure/$CSSKeyframesRule.ts +0 -13
  56. package/packages/css/src/structure/$CSSMediaRule.ts +0 -10
  57. package/packages/css/src/structure/$CSSProperty.ts +0 -19
  58. package/packages/css/src/structure/$CSSRule.ts +0 -13
  59. package/packages/css/src/structure/$CSSStyleRule.ts +0 -14
  60. package/packages/css/src/structure/$CSSVariable.ts +0 -30
  61. package/packages/dom/package.json +0 -20
  62. package/packages/dom/src/lib/HTMLElementMap.ts +0 -213
  63. package/packages/dom/src/lib/assignAttributes.ts +0 -16
  64. package/packages/dom/src/structure/CSS.ts +0 -7
  65. package/packages/dom/src/structure/CSSStyleSheet.ts +0 -10
  66. package/packages/dom/src/structure/DOMTokenList.ts +0 -19
  67. package/packages/dom/src/structure/Document.ts +0 -36
  68. package/packages/dom/src/structure/Element.ts +0 -106
  69. package/packages/dom/src/structure/HTMLElement.ts +0 -34
  70. package/packages/dom/src/structure/History.ts +0 -11
  71. package/packages/dom/src/structure/Location.ts +0 -9
  72. package/packages/dom/src/structure/Node.ts +0 -51
  73. package/packages/dom/src/structure/NodeList.ts +0 -10
  74. package/packages/dom/src/structure/Storage.ts +0 -8
  75. package/packages/dom/src/structure/Text.ts +0 -20
  76. package/packages/dom/src/structure/Window.ts +0 -14
  77. package/packages/dom/src/structure/html/HTMLAbbrElement.ts +0 -16
  78. package/packages/dom/src/structure/html/HTMLAddressElement.ts +0 -16
  79. package/packages/dom/src/structure/html/HTMLAnchorElement.ts +0 -25
  80. package/packages/dom/src/structure/html/HTMLAreaElement.ts +0 -26
  81. package/packages/dom/src/structure/html/HTMLArticleElement.ts +0 -16
  82. package/packages/dom/src/structure/html/HTMLAsideElement.ts +0 -16
  83. package/packages/dom/src/structure/html/HTMLAudioElement.ts +0 -16
  84. package/packages/dom/src/structure/html/HTMLBDIElement.ts +0 -16
  85. package/packages/dom/src/structure/html/HTMLBDOElement.ts +0 -16
  86. package/packages/dom/src/structure/html/HTMLBElement.ts +0 -16
  87. package/packages/dom/src/structure/html/HTMLBRElement.ts +0 -17
  88. package/packages/dom/src/structure/html/HTMLBaseElement.ts +0 -18
  89. package/packages/dom/src/structure/html/HTMLBodyElement.ts +0 -22
  90. package/packages/dom/src/structure/html/HTMLButtonElement.ts +0 -26
  91. package/packages/dom/src/structure/html/HTMLCanvasElement.ts +0 -18
  92. package/packages/dom/src/structure/html/HTMLCiteElement.ts +0 -16
  93. package/packages/dom/src/structure/html/HTMLCodeElement.ts +0 -16
  94. package/packages/dom/src/structure/html/HTMLDDElement.ts +0 -16
  95. package/packages/dom/src/structure/html/HTMLDFNElement.ts +0 -16
  96. package/packages/dom/src/structure/html/HTMLDListElement.ts +0 -17
  97. package/packages/dom/src/structure/html/HTMLDTElement.ts +0 -16
  98. package/packages/dom/src/structure/html/HTMLDataElement.ts +0 -17
  99. package/packages/dom/src/structure/html/HTMLDataListElement.ts +0 -16
  100. package/packages/dom/src/structure/html/HTMLDetailsElement.ts +0 -17
  101. package/packages/dom/src/structure/html/HTMLDialogElement.ts +0 -18
  102. package/packages/dom/src/structure/html/HTMLDivElement.ts +0 -17
  103. package/packages/dom/src/structure/html/HTMLEMElement.ts +0 -16
  104. package/packages/dom/src/structure/html/HTMLEmbedElement.ts +0 -20
  105. package/packages/dom/src/structure/html/HTMLFieldSetElement.ts +0 -19
  106. package/packages/dom/src/structure/html/HTMLFigCaptionElement.ts +0 -16
  107. package/packages/dom/src/structure/html/HTMLFigureElement.ts +0 -16
  108. package/packages/dom/src/structure/html/HTMLFooterElement.ts +0 -16
  109. package/packages/dom/src/structure/html/HTMLFormElement.ts +0 -24
  110. package/packages/dom/src/structure/html/HTMLHGroupElement.ts +0 -16
  111. package/packages/dom/src/structure/html/HTMLHRElement.ts +0 -21
  112. package/packages/dom/src/structure/html/HTMLHeadElement.ts +0 -16
  113. package/packages/dom/src/structure/html/HTMLHeaderElement.ts +0 -16
  114. package/packages/dom/src/structure/html/HTMLHeadingElement.ts +0 -17
  115. package/packages/dom/src/structure/html/HTMLHtmlElement.ts +0 -18
  116. package/packages/dom/src/structure/html/HTMLIElement.ts +0 -16
  117. package/packages/dom/src/structure/html/HTMLIFrameElement.ts +0 -31
  118. package/packages/dom/src/structure/html/HTMLImageElement.ts +0 -38
  119. package/packages/dom/src/structure/html/HTMLInputElement.ts +0 -55
  120. package/packages/dom/src/structure/html/HTMLKBDElement.ts +0 -16
  121. package/packages/dom/src/structure/html/HTMLLIElement.ts +0 -18
  122. package/packages/dom/src/structure/html/HTMLLabelElement.ts +0 -18
  123. package/packages/dom/src/structure/html/HTMLLegendElement.ts +0 -17
  124. package/packages/dom/src/structure/html/HTMLLinkElement.ts +0 -31
  125. package/packages/dom/src/structure/html/HTMLMainElement.ts +0 -16
  126. package/packages/dom/src/structure/html/HTMLMapElement.ts +0 -17
  127. package/packages/dom/src/structure/html/HTMLMarkElement.ts +0 -16
  128. package/packages/dom/src/structure/html/HTMLMediaElement.ts +0 -48
  129. package/packages/dom/src/structure/html/HTMLMenuElement.ts +0 -18
  130. package/packages/dom/src/structure/html/HTMLMetaElement.ts +0 -22
  131. package/packages/dom/src/structure/html/HTMLMeterElement.ts +0 -23
  132. package/packages/dom/src/structure/html/HTMLModElement.ts +0 -18
  133. package/packages/dom/src/structure/html/HTMLNavElement.ts +0 -16
  134. package/packages/dom/src/structure/html/HTMLNoscriptElement.ts +0 -16
  135. package/packages/dom/src/structure/html/HTMLOListElement.ts +0 -20
  136. package/packages/dom/src/structure/html/HTMLObjectElement.ts +0 -34
  137. package/packages/dom/src/structure/html/HTMLOptGroupElement.ts +0 -18
  138. package/packages/dom/src/structure/html/HTMLOptionElement.ts +0 -20
  139. package/packages/dom/src/structure/html/HTMLOutputElement.ts +0 -20
  140. package/packages/dom/src/structure/html/HTMLParagraphElement.ts +0 -17
  141. package/packages/dom/src/structure/html/HTMLPictureElement.ts +0 -16
  142. package/packages/dom/src/structure/html/HTMLPreElement.ts +0 -17
  143. package/packages/dom/src/structure/html/HTMLProgressElement.ts +0 -19
  144. package/packages/dom/src/structure/html/HTMLQuoteElement.ts +0 -17
  145. package/packages/dom/src/structure/html/HTMLRPElement.ts +0 -16
  146. package/packages/dom/src/structure/html/HTMLRTElement.ts +0 -16
  147. package/packages/dom/src/structure/html/HTMLRubyElement.ts +0 -16
  148. package/packages/dom/src/structure/html/HTMLSElement.ts +0 -16
  149. package/packages/dom/src/structure/html/HTMLSampElement.ts +0 -16
  150. package/packages/dom/src/structure/html/HTMLScriptElement.ts +0 -27
  151. package/packages/dom/src/structure/html/HTMLSectionElement.ts +0 -16
  152. package/packages/dom/src/structure/html/HTMLSelectElement.ts +0 -27
  153. package/packages/dom/src/structure/html/HTMLSlotElement.ts +0 -17
  154. package/packages/dom/src/structure/html/HTMLSmallElement.ts +0 -16
  155. package/packages/dom/src/structure/html/HTMLSourceElement.ts +0 -21
  156. package/packages/dom/src/structure/html/HTMLSpanElement.ts +0 -16
  157. package/packages/dom/src/structure/html/HTMLStrongElement.ts +0 -16
  158. package/packages/dom/src/structure/html/HTMLStyleElement.ts +0 -18
  159. package/packages/dom/src/structure/html/HTMLSubElement.ts +0 -16
  160. package/packages/dom/src/structure/html/HTMLSummaryElement.ts +0 -16
  161. package/packages/dom/src/structure/html/HTMLSupElement.ts +0 -16
  162. package/packages/dom/src/structure/html/HTMLTableCaptionElement.ts +0 -17
  163. package/packages/dom/src/structure/html/HTMLTableCellElement.ts +0 -31
  164. package/packages/dom/src/structure/html/HTMLTableColElement.ts +0 -23
  165. package/packages/dom/src/structure/html/HTMLTableElement.ts +0 -26
  166. package/packages/dom/src/structure/html/HTMLTableRowElement.ts +0 -23
  167. package/packages/dom/src/structure/html/HTMLTableSectionElement.ts +0 -20
  168. package/packages/dom/src/structure/html/HTMLTemplateElement.ts +0 -17
  169. package/packages/dom/src/structure/html/HTMLTextAreaElement.ts +0 -33
  170. package/packages/dom/src/structure/html/HTMLTimeElement.ts +0 -17
  171. package/packages/dom/src/structure/html/HTMLTitleElement.ts +0 -17
  172. package/packages/dom/src/structure/html/HTMLTrackElement.ts +0 -21
  173. package/packages/dom/src/structure/html/HTMLUElement.ts +0 -16
  174. package/packages/dom/src/structure/html/HTMLUListElement.ts +0 -18
  175. package/packages/dom/src/structure/html/HTMLVarElement.ts +0 -16
  176. package/packages/dom/src/structure/html/HTMLVideoElement.ts +0 -22
  177. package/packages/dom/src/structure/html/HTMLWBRElement.ts +0 -16
  178. package/packages/html/package.json +0 -18
  179. package/packages/html/src/index.ts +0 -13
  180. package/packages/html/src/node/$Anchor.ts +0 -49
  181. package/packages/html/src/node/$Canvas.ts +0 -38
  182. package/packages/html/src/node/$Dialog.ts +0 -16
  183. package/packages/html/src/node/$Form.ts +0 -16
  184. package/packages/html/src/node/$Image.ts +0 -72
  185. package/packages/html/src/node/$Input.ts +0 -193
  186. package/packages/html/src/node/$Label.ts +0 -25
  187. package/packages/html/src/node/$Media.ts +0 -16
  188. package/packages/html/src/node/$OptGroup.ts +0 -23
  189. package/packages/html/src/node/$Option.ts +0 -40
  190. package/packages/html/src/node/$Select.ts +0 -76
  191. package/packages/html/src/node/$TextArea.ts +0 -16
  192. package/packages/i18n/README.md +0 -73
  193. package/packages/i18n/package.json +0 -19
  194. package/packages/i18n/src/index.ts +0 -140
  195. package/packages/i18n/src/structure/I18n.ts +0 -44
  196. package/packages/i18n/src/structure/I18nDictionary.ts +0 -31
  197. package/packages/i18n/src/structure/I18nTranslation.ts +0 -41
  198. package/packages/idb/README.md +0 -127
  199. package/packages/idb/package.json +0 -19
  200. package/packages/idb/src/core.ts +0 -6
  201. package/packages/idb/src/index.ts +0 -17
  202. package/packages/idb/src/lib/$IDBRequest.ts +0 -8
  203. package/packages/idb/src/structure/$IDB.ts +0 -63
  204. package/packages/idb/src/structure/$IDBCursor.ts +0 -34
  205. package/packages/idb/src/structure/$IDBIndex.ts +0 -48
  206. package/packages/idb/src/structure/$IDBStore.ts +0 -103
  207. package/packages/idb/src/structure/$IDBStoreBase.ts +0 -30
  208. package/packages/idb/src/structure/$IDBTransaction.ts +0 -38
  209. package/packages/idb/src/structure/builder/$IDBBuilder.ts +0 -229
  210. package/packages/idb/src/structure/builder/$IDBStoreBuilder.ts +0 -100
  211. package/packages/markdown/README.md +0 -53
  212. package/packages/markdown/package.json +0 -19
  213. package/packages/markdown/src/index.ts +0 -3
  214. package/packages/markdown/src/lib/type.ts +0 -26
  215. package/packages/markdown/src/lib/util.ts +0 -21
  216. package/packages/markdown/src/structure/Markdown.ts +0 -54
  217. package/packages/markdown/src/structure/MarkdownLexer.ts +0 -111
  218. package/packages/markdown/src/structure/MarkdownParser.ts +0 -34
  219. package/packages/markdown/src/syntax/alert.ts +0 -46
  220. package/packages/markdown/src/syntax/blockquote.ts +0 -35
  221. package/packages/markdown/src/syntax/bold.ts +0 -11
  222. package/packages/markdown/src/syntax/code.ts +0 -11
  223. package/packages/markdown/src/syntax/codeblock.ts +0 -44
  224. package/packages/markdown/src/syntax/heading.ts +0 -14
  225. package/packages/markdown/src/syntax/horizontalRule.ts +0 -11
  226. package/packages/markdown/src/syntax/image.ts +0 -23
  227. package/packages/markdown/src/syntax/italic.ts +0 -11
  228. package/packages/markdown/src/syntax/link.ts +0 -46
  229. package/packages/markdown/src/syntax/list.ts +0 -121
  230. package/packages/markdown/src/syntax/table.ts +0 -67
  231. package/packages/markdown/src/syntax/text.ts +0 -19
  232. package/packages/router/README.md +0 -175
  233. package/packages/router/package.json +0 -19
  234. package/packages/router/src/index.ts +0 -68
  235. package/packages/router/src/node/Page.ts +0 -38
  236. package/packages/router/src/node/Router.ts +0 -212
  237. package/packages/router/src/node/RouterAnchor.ts +0 -24
  238. package/packages/router/src/structure/PageBuilder.ts +0 -24
  239. package/packages/router/src/structure/Route.ts +0 -105
  240. package/packages/signal/README.md +0 -93
  241. package/packages/signal/package.json +0 -18
  242. package/packages/signal/src/index.ts +0 -221
  243. package/packages/signal/src/structure/Signal.ts +0 -38
  244. package/packages/ui/lib/VirtualScroll.ts +0 -25
  245. package/packages/ui/node/Accordian.ts +0 -97
  246. package/packages/ui/node/Carousel.ts +0 -20
  247. package/packages/ui/node/Form.ts +0 -54
  248. package/packages/ui/node/Grid.ts +0 -0
  249. package/packages/ui/node/Modal.ts +0 -45
  250. package/packages/ui/node/Table.ts +0 -43
  251. package/packages/ui/node/Tabs.ts +0 -129
  252. package/packages/ui/node/Toast.ts +0 -16
  253. package/packages/ui/node/Waterfall.ts +0 -94
  254. package/packages/ui/package.json +0 -21
  255. package/packages/utils/package.json +0 -17
  256. package/packages/utils/src/global.ts +0 -25
  257. package/packages/utils/src/index.ts +0 -90
@@ -1,45 +0,0 @@
1
- import { $HTMLElement } from "@amateras/core/node/$HTMLElement";
2
- import { forEach, isNull } from "@amateras/utils";
3
- const MODAL = 'modal';
4
- const MODAL_CONTENT = 'modal-content'
5
-
6
- forEach([
7
- `${MODAL}{display:flex;justify-content:center;align-items:center;position:fixed;top:0;left:0;height:100%;width:100%;background:#00000050}`,
8
- `${MODAL_CONTENT}{display:block;}`
9
- ], $.style)
10
- export class Modal extends $HTMLElement {
11
- name?: string;
12
- constructor(name?: string) {
13
- super(MODAL);
14
- this.name = name;
15
- if (name)
16
- $(window).on('routeopen', e => {
17
- const url = new URL(location.href);
18
- const param = url.searchParams.get(name);
19
- if (isNull(param)) return this.close();
20
- this.open();
21
- })
22
- }
23
-
24
- open() {
25
- $(document.body).insert(this);
26
- this.once('click', e => {
27
- if ($(e) === $(e.target)) {
28
- if (!this.name) this.close();
29
- else history.back();
30
- }
31
- })
32
- return this;
33
- }
34
-
35
- close() {
36
- this.remove();
37
- return this;
38
- }
39
- }
40
-
41
- export class ModalContent extends $HTMLElement {
42
- constructor() {
43
- super(MODAL_CONTENT);
44
- }
45
- }
@@ -1,43 +0,0 @@
1
- import { $HTMLElement } from "@amateras/core/node/$HTMLElement";
2
-
3
- export class Table extends $HTMLElement {
4
- constructor() {
5
- super('table');
6
- }
7
- }
8
-
9
- export class TableHeader extends $HTMLElement {
10
- constructor() {
11
- super('thead')
12
- }
13
- }
14
-
15
- export class TableBody extends $HTMLElement {
16
- constructor() {
17
- super('tbody')
18
- }
19
- }
20
-
21
- export class TableRow extends $HTMLElement {
22
- constructor() {
23
- super('tr')
24
- }
25
- }
26
-
27
- export class TableHead extends $HTMLElement {
28
- constructor() {
29
- super('th')
30
- }
31
- }
32
-
33
- export class TableCell extends $HTMLElement {
34
- constructor() {
35
- super('td')
36
- }
37
- }
38
-
39
- export class TableFooter extends $HTMLElement {
40
- constructor() {
41
- super('tfoot')
42
- }
43
- }
@@ -1,129 +0,0 @@
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";
5
-
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)
21
-
22
- export class Tabs extends $HTMLElement {
23
- #value: null | string = null;
24
- currentContent: null | TabsContent = null;
25
- $container: null | TabsContainer = null;
26
- $list: null | TabsList = null;
27
- constructor() {
28
- super(TAB);
29
- }
30
-
31
- value(): string | null;
32
- value(value: string | undefined): this;
33
- value(value?: string) {
34
- return chain(this, arguments, () => this.#value, value, value => {
35
- this.#value = value;
36
- this.$container?.content(this.$container.contentMap.get(value));
37
- this.$list?.check();
38
- })
39
- }
40
-
41
- mounted($parent: $Node): void {
42
- this.$list?.check();
43
- }
44
- }
45
-
46
- export class TabsContainer extends $HTMLElement {
47
- $tabs?: Tabs;
48
- contentMap = new Map<string, TabsContent>();
49
- constructor($tabs?: Tabs) {
50
- super(TAB_CONTAINER);
51
- this.$tabs = $tabs;
52
- }
53
-
54
- mounted($parent: $Node) {
55
- if (_instanceof($parent, Tabs)) this.$tabs = $parent;
56
- if (this.$tabs) {
57
- this.$tabs.$container = this;
58
- this.content(this.contentMap.get(this.$tabs.value() ?? ''))
59
- }
60
- return this;
61
- }
62
- }
63
-
64
- export class TabsContent extends $HTMLElement {
65
- #value: string;
66
- $container: null | TabsContainer = null;
67
- constructor(value: string) {
68
- super(TAB_CONTENT);
69
- this.#value = value
70
- }
71
-
72
- value(): string;
73
- value(value: string): this;
74
- value(value?: string) {
75
- return chain(this, arguments, () => this.#value, value, value => {
76
- this.#value = value;
77
- this.$container?.contentMap.set(value, this).delete(this.#value ?? '')
78
- })
79
- }
80
-
81
- mounted($parent: $Node) {
82
- if (!_instanceof($parent, TabsContainer)) return this;
83
- if ($parent && this.#value) {
84
- this.$container = $parent;
85
- $parent.contentMap.set(this.#value, this);
86
- }
87
- return this;
88
- }
89
- }
90
-
91
- export class TabsList extends $HTMLElement {
92
- $tabs?: null | Tabs = null;
93
- triggers = new Map<string, TabsTrigger>();
94
- constructor($tabs?: Tabs) {
95
- super(TAB_LIST);
96
- this.$tabs = $tabs;
97
- this.on('click', _ => this.check())
98
- }
99
-
100
- check() {
101
- this.triggers.forEach($trigger => $trigger.attr({selected: $trigger.value() === this.$tabs?.value() ? '' : null}))
102
- return this;
103
- }
104
-
105
- mounted($parent: $Node): this {
106
- if (_instanceof($parent, Tabs)) this.$tabs = $parent, $parent.$list = this;
107
- if (this.$tabs) forEach(_Array_from(this.childNodes), child => $(child).is(TabsTrigger)?.use($child => {
108
- this.triggers.set($child.value(), $child);
109
- $child.$tabs = this.$tabs;
110
- }));
111
- return this;
112
- }
113
- }
114
-
115
- export class TabsTrigger extends $HTMLElement {
116
- #value: string;
117
- $tabs?: null | Tabs = null;
118
- constructor(value: string) {
119
- super(TAB_TRIGGER);
120
- this.#value = value;
121
- this.on('click', _ => this.$tabs?.value(this.#value ?? undefined))
122
- }
123
-
124
- value(): string;
125
- value(value: string): this;
126
- value(value?: string) {
127
- return chain(this, arguments, () => this.#value, value, value => this.#value = value)
128
- }
129
- }
@@ -1,16 +0,0 @@
1
- import { _document } from "@amateras/core/env";
2
- import { $HTMLElement } from "@amateras/core/node/$HTMLElement";
3
-
4
- $.style('toast{position:absolute}')
5
-
6
- export class Toast extends $HTMLElement {
7
- constructor() {
8
- super('toast');
9
- }
10
-
11
- popup(duration = 3000) {
12
- $(_document.body).insert(this);
13
- setTimeout(() => this.remove(), duration)
14
- return this;
15
- }
16
- }
@@ -1,94 +0,0 @@
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'
@@ -1,21 +0,0 @@
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
- }
@@ -1,17 +0,0 @@
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,25 +0,0 @@
1
- declare global {
2
- type Nullish = null | undefined;
3
- type OrArray<T> = T | T[];
4
- type OrMatrix<T> = T | OrMatrix<T>[];
5
- type OrPromise<T> = T | Promise<T>;
6
- type OrNullish<T> = T | Nullish;
7
- type Constructor<T> = { new (...args: any[]): T }
8
- type Mutable<T> = {
9
- -readonly [P in keyof T]: T[P];
10
- }
11
- type AsyncFunction<T> = () => Promise<T>;
12
- type Ok<D> = [data: D, err: null];
13
- type Err<E> = [data: null, err: E]
14
- type Result<D, E> = Ok<D> | Err<E>
15
- type Repeat<T, N extends number, Acc extends T[] = []> =
16
- Acc['length'] extends 500
17
- ? T[]
18
- : Acc['length'] extends N
19
- ? Acc
20
- : Repeat<T, N, [...Acc, T]>;
21
- type Prettify<T> = {
22
- [K in keyof T]: T[K];
23
- } & {};
24
- type Narrow<T> = T extends boolean ? boolean : T;
25
- }
@@ -1,90 +0,0 @@
1
- import './global';
2
-
3
- // Value
4
- export const _null = null;
5
- export const _undefined = undefined;
6
- // Object
7
- export const _Object_fromEntries = Object.fromEntries;
8
- export const _Object_entries = Object.entries;
9
- export const _Object_assign = Object.assign;
10
- export const _Object_values = Object.values;
11
- export const _Object_defineProperty = Object.defineProperty;
12
- export const _Object_getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors;
13
- // Array
14
- export const _Array_from = Array.from;
15
- interface forEach {
16
- <T>(arr: Array<T>, fn: (value: T, index: number, array: Array<T>) => Promise<void>): Promise<void>;
17
- <T>(arr: Array<T>, fn: (value: T, index: number, array: Array<T>) => void): void;
18
- <T>(set: Set<T>, fn: (value: T, index: number, set: Set<T>) => Promise<void>): void;
19
- <T>(set: Set<T>, fn: (value: T, index: number, set: Set<T>) => void): void;
20
- <K, V>(map: Map<K, V>, fn: (value: [K, V], index: number, map: Map<K, V>) => Promise<void>): void;
21
- <K, V>(map: Map<K, V>, fn: (value: [K, V], index: number, map: Map<K, V>) => void): void;
22
- <N extends Node>(set: NodeListOf<N>, fn: (value: N, index: number, parent: NodeListOf<N>) => Promise<void>): void;
23
- <N extends Node>(set: NodeListOf<N>, fn: (value: N, index: number, parent: NodeListOf<N>) => void): void;
24
- }
25
- export const forEach: forEach = async (arr: any, fn: any) => {
26
- let i = 0;
27
- let isAsync = isAsyncFunction(fn);
28
- let handle = async () => { for (let item of arr) { isAsync ? await fn(item, i, arr) : fn(item, i, arr); i++; } }
29
- return isAsync ? new _Promise<void>(resolve => handle().then(resolve)) : handle();
30
- };
31
- // export const forEach: forEach = (arr: any, fn: any) => arr.forEach(fn);
32
- // type check
33
- export const _typeof = (target: any, type: 'string' | 'number' | 'object' | 'boolean' | 'function' | 'bigint' | 'symbol' | 'undefined') => typeof target === type;
34
- export const equal = <T, V extends T>(target: T, ...args: V[]): target is V => !!args.find(a => a === target);
35
- export const isString = (target: any): target is string => _typeof(target, 'string');
36
- export const isBoolean = (target: any): target is boolean => _typeof(target, 'boolean');
37
- export const isNumber = (target: any): target is number => _typeof(target, 'number');
38
- export const isObject = (target: any): target is object => _typeof(target, 'object');
39
- export const isFunction = (target: any): target is Function => _typeof(target, 'function');
40
- export const isAsyncFunction = (target: any): target is AsyncFunction<Awaited<ReturnType<typeof target>>> => _instanceof(target, (async () => 0).constructor as any)
41
- export const isUndefined = (target: any): target is undefined => target === undefined;
42
- export const isNull = (target: any): target is null => target === _null;
43
- export const isArray = Array.isArray;
44
- export const _instanceof = <T extends (abstract new (...args: any[]) => any)[]>(target: any, ...instance: T): target is InstanceType<T[number]> => !!instance.find(i => target instanceof i);
45
- // JSON
46
- export const _JSON_stringify = JSON.stringify;
47
- export const _JSON_parse = JSON.parse;
48
- // String
49
- export const startsWith = (target: string, ...str: string[]) => !!str.find(s => target.startsWith(s));
50
- // String & Array
51
- interface slice {
52
- (target: string, start?: number, end?: number): string;
53
- <T>(target: Array<T>, start?: number, end?: number): T[];
54
- }
55
- export const slice: slice = (target: any, start?: number, end?: number) => target.slice(start, end);
56
- // Function
57
- export const _bind = <T extends Function>(target: T, obj: Object): T => target.bind(obj);
58
- // 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) : ''}`