amateras 0.7.3 → 0.10.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 (257) hide show
  1. package/README.md +76 -85
  2. package/package.json +27 -21
  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,201 +0,0 @@
1
- import { _document } from "#env";
2
- import { _Array_from, _instanceof, _JSON_stringify, _null, _Promise, forEach, isFunction, isNull, isUndefined, toArray } from "@amateras/utils";
3
- import { $EventTarget } from "./$EventTarget";
4
-
5
- export class $Node<EvMap = {}> extends $EventTarget<EvMap> {
6
- declare node: Node & ChildNode & ParentNode;
7
- static processors = new Set<$NodeContentProcessor>();
8
- static setters = new Set<$NodeSetterHandler>();
9
- constructor(node: Node & ChildNode) {
10
- super(node);
11
- }
12
-
13
- content(children: $NodeContentResolver<this>) {
14
- forEach(_Array_from(this.childNodes), node => node.remove());
15
- return this.insert(children);
16
- }
17
-
18
- insert(resolver: $NodeContentResolver<this>, position = -1) {
19
- // process nodes
20
- forEach(toArray(resolver), resolve_child => forEach($Node.process(this, resolve_child), $node => {
21
- $Node.append(this, $node, position);
22
- if (position >= 0) position++;
23
- }));
24
- return this;
25
- }
26
-
27
- await<T>(promise: OrPromise<T>, callback: ($node: this, result: T) => void): this {
28
- if (_instanceof(promise, Promise)) promise.then(result => callback(this, result));
29
- else callback(this, promise);
30
- return this;
31
- }
32
-
33
- replace($node: $NodeContentResolver<$Node>) {
34
- if ($node)
35
- this.replaceWith(
36
- ...toArray($Node.process(this, $node)).filter($node => $node).map($node => $node?.node) as Node[]
37
- )
38
- return this;
39
- }
40
-
41
- inDOM() {
42
- return _document.contains(this.node);
43
- }
44
-
45
- toString() {
46
- return this.textContent();
47
- }
48
-
49
- mounted($parent: $Node) {}
50
-
51
- use<F extends ($ele: this, ...args: any) => void>(callback: F, ...args: F extends ($ele: this, ...args: infer P) => void ? P : never) {
52
- callback(this, ...args);
53
- return this;
54
- }
55
-
56
- is<T extends (abstract new (...args: any[]) => $Node)>(instance: T): InstanceType<T> | null {
57
- return _instanceof(this, instance) ? this : null;
58
- }
59
-
60
- static process<T extends $Node>($node: T, content: $NodeContentResolver<any>): Array<$Node | undefined | null> {
61
- for (const processor of this.processors) {
62
- const result = processor($node, content);
63
- if (result) content = result;
64
- }
65
- if (isUndefined(content) || isNull(content) || _instanceof(content, $Node)) return [content];
66
- // is Promise
67
- if (_instanceof(content, _Promise)) return [$('async').await(content, ($async, $child) => $async.replace($child as any))];
68
- // is SignalFunction or ContentHandler
69
- if (isFunction(content)) {
70
- const _content = content($node) as $NodeContentResolver<$Node>;
71
- if (_instanceof(_content, _Promise)) return this.process($node, _content as any);
72
- else return toArray(_content).map(content => this.process($node, content)).flat();
73
- }
74
- // is nested array
75
- if (_instanceof(content, Array)) return content.map(c => this.process($node, c)).flat();
76
- // is string | number | boolean
77
- return [new $Text(`${content}`)];
78
- }
79
-
80
- /** */
81
- static append($node: $Node, child: $Node | undefined | null, position: number) {
82
- if (child) {
83
- // get child node at position
84
- let positionChild = _Array_from($node.childNodes).at(position);
85
- if (!positionChild) $node.appendChild(child.node);
86
- else $node.insertBefore(child.node, position < 0 ? positionChild.nextSibling : positionChild);
87
- child.mounted($node);
88
- }
89
- }
90
- }
91
-
92
- export class $Text extends $Node {
93
- constructor(textContent?: string) {
94
- super(new Text(textContent));
95
- }
96
- }
97
-
98
- export type $NodeSetterHandler = (value: any, set: (value: any) => void) => any;
99
- export type $NodeContentProcessor = <N extends $Node>($node: N, content: $NodeContentResolver<N>) => $NodeContentResolver<N>;
100
- export type $NodeContentHandler<T extends $Node> = ($node: T) => OrPromise<$NodeContentResolver<T>>;
101
- export type $NodeContentTypes = $Node | string | number | boolean | $.$NodeContentTypeExtends | null | undefined;
102
- export type $NodeContentResolver<T extends $Node> = OrPromise<$NodeContentTypes | $NodeContentHandler<T> | $NodeContentResolver<T>[]>;
103
-
104
- export interface $Node<EvMap = {}> extends $EventTarget<EvMap> {
105
- /** {@link Node.baseURI} */
106
- readonly baseURI: string;
107
- /** {@link Node.childNodes} */
108
- readonly childNodes: NodeListOf<ChildNode>;
109
- /** {@link Node.firstChild} */
110
- readonly firstChild: ChildNode | null;
111
- /** {@link Node.isConnected} */
112
- readonly isConnected: boolean;
113
- /** {@link Node.lastChild} */
114
- readonly lastChild: ChildNode | null;
115
- /** {@link Node.nextSibling} */
116
- readonly nextSibling: ChildNode | null;
117
- /** {@link Node.nodeName} */
118
- readonly nodeName: string;
119
- /** {@link Node.nodeType} */
120
- readonly nodeType: number;
121
- /** {@link Node.ownerDocument} */
122
- readonly ownerDocument: Document | null;
123
- /** {@link Node.parentElement} */
124
- readonly parentElement?: HTMLElement | null;
125
- /** {@link Node.parentNode} */
126
- readonly parentNode?: ParentNode | null;
127
- /** {@link Node.previousSibling} */
128
- readonly previousSibling?: ChildNode | null;
129
- /** {@link ParentNode.childElementCount} */
130
- readonly childElementCount: number;
131
- /** {@link ParentNode.children} */
132
- readonly children: HTMLCollection;
133
- /** {@link ParentNode.firstElementChild} */
134
- readonly firstElementChild: Element | null;
135
- /** {@link ParentNode.lastElementChild} */
136
- readonly lastElementChild: Element | null;
137
-
138
- /** {@link Node.appendChild} */
139
- appendChild<T extends Node>(node: T): T;
140
- /** {@link Node.cloneNode} */
141
- cloneNode(subtree?: boolean): Node;
142
- /** {@link Node.compareDocumentPosition} */
143
- compareDocumentPosition(other: $EventTarget | Node): number;
144
- /** {@link Node.getRootNode} */
145
- getRootNode(options?: GetRootNodeOptions): Node;
146
- /** {@link Node.hasChildNodes} */
147
- hasChildNodes(): boolean;
148
- /** {@link Node.insertBefore} */
149
- insertBefore<T extends Node>(node: T, child: Node | null): T;
150
- /** {@link Node.isDefaultNamespace} */
151
- isDefaultNamespace(namespace: string | null): boolean;
152
- /** {@link Node.isEqualNode} */
153
- isEqualNode(otherNode: $EventTarget | Node | null): boolean;
154
- /** {@link Node.isSameNode} */
155
- isSameNode(otherNode: $EventTarget | Node | null): boolean;
156
- /** {@link Node.lookupNamespaceURI} */
157
- lookupNamespaceURI(prefix: string | null): string | null;
158
- /** {@link Node.lookupPrefix} */
159
- lookupPrefix(namespace: string | null): string | null;
160
- /** {@link Node.normalize} */
161
- normalize(): this;
162
- /** {@link Node.removeChild} */
163
- removeChild<T extends Node>(child: T): T;
164
- /** {@link Node.replaceChild} */
165
- replaceChild<T extends Node>(node: Node, child: T): T;
166
- /** {@link Node.contains} */
167
- contains(other: $EventTarget | EventTarget | null | undefined): boolean;
168
-
169
- /** {@link ChildNode.after} */
170
- after(...nodes: ($EventTarget | Node | string)[]): this;
171
- /** {@link ChildNode.before} */
172
- before(...nodes: ($EventTarget | Node | string)[]): this;
173
- /** {@link ChildNode.remove} */
174
- remove(): this;
175
- /** {@link ChildNode.replaceWith} */
176
- replaceWith(...nodes: ($EventTarget | Node | string)[]): this;
177
- /** {@link ParentNode.append} */
178
- append(...nodes: ($EventTarget | Node | string)[]): this;
179
- /** {@link ParentNode.prepend} */
180
- prepend(...nodes: ($EventTarget | Node | string)[]): this;
181
- /** {@link ParentNode.querySelector} */
182
- querySelector<K extends keyof HTMLElementTagNameMap>(selectors: K): HTMLElementTagNameMap[K] | null;
183
- querySelector<K extends keyof SVGElementTagNameMap>(selectors: K): SVGElementTagNameMap[K] | null;
184
- querySelector<K extends keyof MathMLElementTagNameMap>(selectors: K): MathMLElementTagNameMap[K] | null;
185
- querySelector<E extends Element = Element>(selectors: string): E | null;
186
- /** {@link ParentNode.querySelectorAll} */
187
- querySelectorAll<K extends keyof HTMLElementTagNameMap>(selectors: K): NodeListOf<HTMLElementTagNameMap[K]>;
188
- querySelectorAll<K extends keyof SVGElementTagNameMap>(selectors: K): NodeListOf<SVGElementTagNameMap[K]>;
189
- querySelectorAll<K extends keyof MathMLElementTagNameMap>(selectors: K): NodeListOf<MathMLElementTagNameMap[K]>;
190
- querySelectorAll<K extends keyof HTMLElementDeprecatedTagNameMap>(selectors: K): NodeListOf<HTMLElementDeprecatedTagNameMap[K]>;
191
- querySelectorAll<E extends Element = Element>(selectors: string): NodeListOf<E>;
192
- /** {@link ParentNode.replaceChildren} */
193
- replaceChildren(...nodes: ($EventTarget | Node | string)[]): this;
194
-
195
- /** {@link Node.nodeValue} */
196
- nodeValue(nodeValue: $Parameter<string | null>): this;
197
- nodeValue(): string | null;
198
- /** {@link Node.textContent} */
199
- textContent(textContent: $Parameter<string | null>): this;
200
- textContent(): string | null;
201
- }
@@ -1,65 +0,0 @@
1
- import { chain } from "#lib/chain";
2
- import { forEach, _Array_from, _instanceof, _null, toArray } from "@amateras/utils";
3
- import { $HTMLElement } from "#node/$HTMLElement";
4
- import { $Node, type $NodeContentResolver } from "#node/$Node";
5
-
6
- export class $Virtual<Ele extends HTMLElement = HTMLElement, EvMap = HTMLElementEventMap> extends $HTMLElement<Ele, EvMap> {
7
- nodes = new Set<$Node>();
8
- hiddenNodes = new Set<$Node>();
9
- constructor(resolver: string | Ele) {
10
- super(resolver);
11
- }
12
-
13
- content(children: $NodeContentResolver<this>) {
14
- return chain(this, _null, _null, children, children => {
15
- this.nodes.clear();
16
- forEach(this.childNodes, node => node.remove());
17
- this.insert(children);
18
- })
19
- }
20
-
21
- insert(resolver: $NodeContentResolver<this>, position = -1) {
22
- // process nodes
23
- forEach(toArray(resolver), resolve_child => {
24
- forEach($Node.process(this, resolve_child), $node => {
25
- $Virtual.append(this, $node, position)
26
- if (position >= 0) position++;
27
- })
28
- });
29
- return this;
30
- }
31
-
32
- hide($node?: $Node | null) {
33
- if ($node && this.nodes.has($node)) this.hiddenNodes.add($node);
34
- return this;
35
- }
36
-
37
- show($node?: $Node | null) {
38
- if ($node) this.hiddenNodes.delete($node);
39
- return this;
40
- }
41
-
42
- render() {
43
- // remove hidden node
44
- forEach(this.childNodes, node => this.hiddenNodes.has($(node)) && node.remove());
45
- // get array of visible node
46
- const visibleNodes = _Array_from(this.nodes).filter($node => !this.hiddenNodes.has($node))
47
- // add visible node with position
48
- forEach(visibleNodes, ($node, i) => {
49
- if (
50
- !$node.inDOM() // node is not in dom tree
51
- && $(this.childNodes).at(i) !== $node // node not matched at position
52
- ) $Node.append(this, $node, i);
53
- })
54
- return this;
55
- }
56
-
57
- static append($node: $Virtual, child: $Node | undefined | null, position: number) {
58
- if (child) {
59
- const childList = _Array_from($node.nodes);
60
- if (!childList.at(position)) childList.push(child);
61
- else childList.splice(position >= 0 ? position : childList.length + 1 + position, 0, child);
62
- $node.nodes = new Set(childList);
63
- }
64
- }
65
- }
@@ -1,128 +0,0 @@
1
- # amateras/css
2
-
3
- ## Usage
4
- ```ts
5
- import 'amateras';
6
- import 'amateras/css';
7
- ```
8
-
9
- ## Define Style
10
- ```ts
11
- const style = $.css({
12
- backgroundColor: 'black',
13
- margin: 0,
14
-
15
- 'p': {
16
- color: 'blue'
17
-
18
- '@media (max-width: 800px)': {
19
- color: 'red'
20
- }
21
- }
22
- })
23
-
24
- $(document.body).css(style).content([
25
- $('p').content('Text with blue color.')
26
- ]);
27
- ```
28
-
29
- ## Define Style in Method Chain
30
- ```ts
31
- $(document.body).content([
32
- $('h1').css({ color: 'red' }).content('This is a title with red color!')
33
- ])
34
- ```
35
-
36
- ## Define Variables
37
-
38
- ### Single Variable
39
- ```ts
40
- const largeText = $.css.variables('1.2rem');
41
-
42
- $.css({
43
- fontSize: largeText
44
- })
45
- ```
46
-
47
- ### Variable Group
48
- ```ts
49
- const text = $.css.variables({
50
- small: '0.8rem',
51
- medium: '1rem',
52
- large: '1.2rem'
53
- })
54
-
55
- $.css({
56
- fontSize: text.large
57
- })
58
- ```
59
-
60
- ## Define Keyframes
61
- ```ts
62
- const keyframes = $.css.keyframes({
63
- fadeIn: {
64
- '0%': { opacity: 0 },
65
- '100%': { opacity: 1 }
66
- },
67
- fadeOut: {
68
- from: { opacity: 1 },
69
- to: { opacity: 0 }
70
- }
71
- })
72
-
73
- $.css({
74
- animation: keyframes.fadeIn
75
- })
76
- ```
77
-
78
- ## Define CSS Rules with Selectors
79
- ```ts
80
- $.CSS({
81
- 'html': {
82
- fontSize: '18px',
83
- fontFamily: 'Noto Sans',
84
-
85
- 'body': {
86
- margin: 0,
87
-
88
- '.title': {
89
- color: 'red'
90
- }
91
- }
92
- },
93
-
94
- '@media (max-width: 800px)': {
95
- 'html': {
96
- fontSize: '1rem',
97
-
98
- '@media (orientation: landscape)': {
99
- fontSize: '1.2rem'
100
- },
101
- }
102
- },
103
- })
104
-
105
- $(document.body).content([
106
- $('h1').class('title').content('A red color title.')
107
- ])
108
-
109
- ```
110
-
111
- ### CSS Colors Preset
112
- You can import colors preset from `amateras/color/COLOR_NAME` or `amateras/colors` path. These colors are reference from Tailwind colors, read the [documentation](https://tailwindcss.com/docs/colors) to know about the concepts.
113
- ```ts
114
- // import black and white color preset
115
- import 'amateras/color/blackwhite';
116
- $.color.black; // '#000000'
117
- $.color.white; // '#ffffff'
118
-
119
- // import slate colors preset
120
- import 'amateras/color/slate';
121
- $.color.slate[100]; // '#f1f5f9'
122
- $.color.slate[200]; // '#e2e8f0'
123
-
124
- // import all colors preset
125
- import 'amateras/colors';
126
- $.color.red[600]; // '#dc2626'
127
- $.color.zinc[500]; // '#71717a'
128
- ```
@@ -1,17 +0,0 @@
1
- {
2
- "name": "@amateras/css",
3
- "peerDependencies": {
4
- "@amateras/core": "workspace:*",
5
- "@amateras/utils": "workspace:*"
6
- },
7
- "imports": {
8
- "#structure/*": "./src/structure/*.ts",
9
- "#lib/*": "./src/lib/*.ts",
10
- "#node/*": "./src/node/*.ts"
11
- },
12
- "exports": {
13
- "./structure/*": "./src/structure/*.ts",
14
- "./lib/*": "./src/lib/*.ts",
15
- "./node/*": "./src/node/*.ts"
16
- }
17
- }
@@ -1,25 +0,0 @@
1
- import { colorAssign } from "../../lib/colorAssign";
2
-
3
- const _amber = {
4
- 50: '#fffbeb',
5
- 100: '#fef3c7',
6
- 200: '#fde68a',
7
- 300: '#fcd34d',
8
- 400: '#fbbf24',
9
- 500: '#f59e0b',
10
- 600: '#d97706',
11
- 700: '#b45309',
12
- 800: '#92400e',
13
- 900: '#78350f',
14
- 950: '#451a03',
15
- } as const;
16
-
17
- colorAssign('amber', _amber);
18
-
19
- declare module '@amateras/core' {
20
- export namespace $ {
21
- export namespace color {
22
- export const amber: typeof _amber;
23
- }
24
- }
25
- }
@@ -1,13 +0,0 @@
1
- import { colorAssign } from "../../lib/colorAssign";
2
-
3
- colorAssign('black', '#000000');
4
- colorAssign('white', '#ffffff');
5
-
6
- declare module '@amateras/core' {
7
- export namespace $ {
8
- export namespace color {
9
- export const black: '#000000';
10
- export const white: '#ffffff';
11
- }
12
- }
13
- }
@@ -1,25 +0,0 @@
1
- import { colorAssign } from "../../lib/colorAssign";
2
-
3
- const _blue = {
4
- 50: '#eff6ff',
5
- 100: '#dbeafe',
6
- 200: '#bfdbfe',
7
- 300: '#93c5fd',
8
- 400: '#60a5fa',
9
- 500: '#3b82f6',
10
- 600: '#2563eb',
11
- 700: '#1d4ed8',
12
- 800: '#1e40af',
13
- 900: '#1e3a8a',
14
- 950: '#172554',
15
- } as const;
16
-
17
- colorAssign('blue', _blue);
18
-
19
- declare module '@amateras/core' {
20
- export namespace $ {
21
- export namespace color {
22
- export const blue: typeof _blue;
23
- }
24
- }
25
- }
@@ -1,25 +0,0 @@
1
- import { colorAssign } from "../../lib/colorAssign";
2
-
3
- const _cyan = {
4
- 50: '#ecfeff',
5
- 100: '#cffafe',
6
- 200: '#a5f3fc',
7
- 300: '#67e8f9',
8
- 400: '#22d3ee',
9
- 500: '#06b6d4',
10
- 600: '#0891b2',
11
- 700: '#0e7490',
12
- 800: '#155e75',
13
- 900: '#164e63',
14
- 950: '#083344',
15
- } as const;
16
-
17
- colorAssign('cyan', _cyan);
18
-
19
- declare module '@amateras/core' {
20
- export namespace $ {
21
- export namespace color {
22
- export const cyan: typeof _cyan;
23
- }
24
- }
25
- }
@@ -1,25 +0,0 @@
1
- import { colorAssign } from "../../lib/colorAssign";
2
-
3
- const _emerald = {
4
- 50: '#ecfdf5',
5
- 100: '#d1fae5',
6
- 200: '#a7f3d0',
7
- 300: '#6ee7b7',
8
- 400: '#34d399',
9
- 500: '#10b981',
10
- 600: '#059669',
11
- 700: '#047857',
12
- 800: '#065f46',
13
- 900: '#064e3b',
14
- 950: '#022c22',
15
- } as const;
16
-
17
- colorAssign('emerald', _emerald);
18
-
19
- declare module '@amateras/core' {
20
- export namespace $ {
21
- export namespace color {
22
- export const emerald: typeof _emerald;
23
- }
24
- }
25
- }
@@ -1,25 +0,0 @@
1
- import { colorAssign } from "../../lib/colorAssign";
2
-
3
- const _fuchsia = {
4
- 50: '#fdf4ff',
5
- 100: '#fae8ff',
6
- 200: '#f5d0fe',
7
- 300: '#f0abfc',
8
- 400: '#e879f9',
9
- 500: '#d946ef',
10
- 600: '#c026d3',
11
- 700: '#a21caf',
12
- 800: '#86198f',
13
- 900: '#701a75',
14
- 950: '#4a044e',
15
- } as const;
16
-
17
- colorAssign('fuchsia', _fuchsia);
18
-
19
- declare module '@amateras/core' {
20
- export namespace $ {
21
- export namespace color {
22
- export const fuchsia: typeof _fuchsia;
23
- }
24
- }
25
- }
@@ -1,25 +0,0 @@
1
- import { colorAssign } from "../../lib/colorAssign";
2
-
3
- const _gray = {
4
- 50: '#f9fafb',
5
- 100: '#f3f4f6',
6
- 200: '#e5e7eb',
7
- 300: '#d1d5db',
8
- 400: '#9ca3af',
9
- 500: '#6b7280',
10
- 600: '#4b5563',
11
- 700: '#374151',
12
- 800: '#1f2937',
13
- 900: '#111827',
14
- 950: '#030712',
15
- } as const;
16
-
17
- colorAssign('gray', _gray);
18
-
19
- declare module '@amateras/core' {
20
- export namespace $ {
21
- export namespace color {
22
- export const gray: typeof _gray;
23
- }
24
- }
25
- }
@@ -1,25 +0,0 @@
1
- import { colorAssign } from "../../lib/colorAssign";
2
-
3
- const _green = {
4
- 50: '#f0fdf4',
5
- 100: '#dcfce7',
6
- 200: '#bbf7d0',
7
- 300: '#86efac',
8
- 400: '#4ade80',
9
- 500: '#22c55e',
10
- 600: '#16a34a',
11
- 700: '#15803d',
12
- 800: '#166534',
13
- 900: '#14532d',
14
- 950: '#052e16',
15
- } as const;
16
-
17
- colorAssign('green', _green);
18
-
19
- declare module '@amateras/core' {
20
- export namespace $ {
21
- export namespace color {
22
- export const green: typeof _green;
23
- }
24
- }
25
- }
@@ -1,25 +0,0 @@
1
- import { colorAssign } from "../../lib/colorAssign";
2
-
3
- const _indigo = {
4
- 50: '#eef2ff',
5
- 100: '#e0e7ff',
6
- 200: '#c7d2fe',
7
- 300: '#a5b4fc',
8
- 400: '#818cf8',
9
- 500: '#6366f1',
10
- 600: '#4f46e5',
11
- 700: '#4338ca',
12
- 800: '#3730a3',
13
- 900: '#312e81',
14
- 950: '#1e1b4b',
15
- } as const;
16
-
17
- colorAssign('indigo', _indigo);
18
-
19
- declare module '@amateras/core' {
20
- export namespace $ {
21
- export namespace color {
22
- export const indigo: typeof _indigo;
23
- }
24
- }
25
- }
@@ -1,25 +0,0 @@
1
- import { colorAssign } from "../../lib/colorAssign";
2
-
3
- const _lime = {
4
- 50: '#f7fee7',
5
- 100: '#ecfccb',
6
- 200: '#d9f99d',
7
- 300: '#bef264',
8
- 400: '#a3e635',
9
- 500: '#84cc16',
10
- 600: '#65a30d',
11
- 700: '#4d7c0f',
12
- 800: '#3f6212',
13
- 900: '#365314',
14
- 950: '#1a2e05',
15
- } as const;
16
-
17
- colorAssign('lime', _lime);
18
-
19
- declare module '@amateras/core' {
20
- export namespace $ {
21
- export namespace color {
22
- export const lime: typeof _lime;
23
- }
24
- }
25
- }
@@ -1,25 +0,0 @@
1
- import { colorAssign } from "../../lib/colorAssign";
2
-
3
- const _neutral = {
4
- 50: '#fafafa',
5
- 100: '#f5f5f5',
6
- 200: '#e5e5e5',
7
- 300: '#d4d4d4',
8
- 400: '#a3a3a3',
9
- 500: '#737373',
10
- 600: '#525252',
11
- 700: '#404040',
12
- 800: '#262626',
13
- 900: '#171717',
14
- 950: '#0a0a0a',
15
- } as const;
16
-
17
- colorAssign('neutral', _neutral);
18
-
19
- declare module '@amateras/core' {
20
- export namespace $ {
21
- export namespace color {
22
- export const neutral: typeof _neutral;
23
- }
24
- }
25
- }