typecomposer 0.1.47 → 0.1.50

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 (364) hide show
  1. package/assets/index.js +1 -2
  2. package/core/components/AlertPanel.d.ts +6 -6
  3. package/core/components/AlertPanel.js +1 -75
  4. package/core/components/AlertPanel.js.map +1 -1
  5. package/core/components/AvatarPanel.d.ts +2 -2
  6. package/core/components/AvatarPanel.js +1 -62
  7. package/core/components/AvatarPanel.js.map +1 -1
  8. package/core/components/BorderPanel.d.ts +2 -2
  9. package/core/components/BorderPanel.js +1 -90
  10. package/core/components/BorderPanel.js.map +1 -1
  11. package/core/components/CardPanel.d.ts +2 -2
  12. package/core/components/CardPanel.js +1 -11
  13. package/core/components/CardPanel.js.map +1 -1
  14. package/core/components/CheckBox.d.ts +2 -2
  15. package/core/components/CheckBox.js +1 -109
  16. package/core/components/CheckBox.js.map +1 -1
  17. package/core/components/ColorPicker.d.ts +2 -2
  18. package/core/components/ColorPicker.js +1 -36
  19. package/core/components/ColorPicker.js.map +1 -1
  20. package/core/components/ContextMenu.d.ts +3 -3
  21. package/core/components/ContextMenu.js +1 -64
  22. package/core/components/ContextMenu.js.map +1 -1
  23. package/core/components/DialogPanel.d.ts +2 -2
  24. package/core/components/DialogPanel.js +1 -62
  25. package/core/components/DialogPanel.js.map +1 -1
  26. package/core/components/DropDown.d.ts +3 -3
  27. package/core/components/DropDown.js +1 -231
  28. package/core/components/DropDown.js.map +1 -1
  29. package/core/components/FlowPanel.d.ts +2 -2
  30. package/core/components/FlowPanel.js +1 -40
  31. package/core/components/FlowPanel.js.map +1 -1
  32. package/core/components/ForEach.d.ts +2 -2
  33. package/core/components/ForEach.js +1 -88
  34. package/core/components/ForEach.js.map +1 -1
  35. package/core/components/GridPanel.d.ts +4 -7
  36. package/core/components/GridPanel.js +1 -30
  37. package/core/components/GridPanel.js.map +1 -1
  38. package/core/components/HBox.d.ts +2 -2
  39. package/core/components/HBox.js +1 -10
  40. package/core/components/HBox.js.map +1 -1
  41. package/core/components/LazyLoading.d.ts +2 -2
  42. package/core/components/LazyLoading.js +1 -36
  43. package/core/components/LazyLoading.js.map +1 -1
  44. package/core/components/ListPanel.d.ts +2 -2
  45. package/core/components/ListPanel.js +1 -153
  46. package/core/components/ListPanel.js.map +1 -1
  47. package/core/components/PopUpButton.d.ts +2 -2
  48. package/core/components/PopUpButton.js +1 -57
  49. package/core/components/PopUpButton.js.map +1 -1
  50. package/core/components/ScrollPanel.d.ts +2 -2
  51. package/core/components/ScrollPanel.js +1 -35
  52. package/core/components/ScrollPanel.js.map +1 -1
  53. package/core/components/SliderPanel.d.ts +2 -2
  54. package/core/components/SliderPanel.js +1 -135
  55. package/core/components/SliderPanel.js.map +1 -1
  56. package/core/components/StackPanel.d.ts +2 -2
  57. package/core/components/StackPanel.js +1 -10
  58. package/core/components/StackPanel.js.map +1 -1
  59. package/core/components/TabItem.js +1 -84
  60. package/core/components/TabPanel.d.ts +2 -2
  61. package/core/components/TabPanel.js +1 -96
  62. package/core/components/TabPanel.js.map +1 -1
  63. package/core/components/TextEdit.js +1 -174
  64. package/core/components/TextField.d.ts +2 -2
  65. package/core/components/TextField.js +1 -140
  66. package/core/components/TextField.js.map +1 -1
  67. package/core/components/ToggleButton.d.ts +2 -2
  68. package/core/components/ToggleButton.js +1 -20
  69. package/core/components/ToggleButton.js.map +1 -1
  70. package/core/components/Tooltip.d.ts +4 -6
  71. package/core/components/Tooltip.js +1 -14
  72. package/core/components/Tooltip.js.map +1 -1
  73. package/core/components/VBox.d.ts +2 -2
  74. package/core/components/VBox.js +1 -10
  75. package/core/components/VBox.js.map +1 -1
  76. package/core/components/VirtualScroll.d.ts +2 -2
  77. package/core/components/VirtualScroll.js +1 -47
  78. package/core/components/index.d.ts +1 -2
  79. package/core/components/index.js +1 -30
  80. package/core/components/index.js.map +1 -1
  81. package/core/decorators/RegisterComponent.js +1 -20
  82. package/core/decorators/StyleLink.js +1 -13
  83. package/core/decorators/index.js +1 -6
  84. package/core/element/AbbreviationElement.d.ts +2 -4
  85. package/core/element/AbbreviationElement.js +1 -10
  86. package/core/element/AbbreviationElement.js.map +1 -1
  87. package/core/element/AnchorElement.d.ts +2 -18
  88. package/core/element/AnchorElement.js +1 -31
  89. package/core/element/AnchorElement.js.map +1 -1
  90. package/core/element/AreaElement.d.ts +2 -15
  91. package/core/element/AreaElement.js +1 -11
  92. package/core/element/AreaElement.js.map +1 -1
  93. package/core/element/ArticleElement.d.ts +2 -2
  94. package/core/element/ArticleElement.js +1 -12
  95. package/core/element/ArticleElement.js.map +1 -1
  96. package/core/element/AudioElement.d.ts +2 -9
  97. package/core/element/AudioElement.js +1 -10
  98. package/core/element/AudioElement.js.map +1 -1
  99. package/core/element/BaseElement.d.ts +2 -5
  100. package/core/element/BaseElement.js +1 -11
  101. package/core/element/BaseElement.js.map +1 -1
  102. package/core/element/BodyElement.d.ts +2 -2
  103. package/core/element/BodyElement.js +1 -11
  104. package/core/element/BodyElement.js.map +1 -1
  105. package/core/element/BoldElement.d.ts +2 -2
  106. package/core/element/BoldElement.js +1 -10
  107. package/core/element/BoldElement.js.map +1 -1
  108. package/core/element/BreakElement.d.ts +2 -2
  109. package/core/element/BreakElement.js +1 -10
  110. package/core/element/BreakElement.js.map +1 -1
  111. package/core/element/ButtonElement.d.ts +4 -21
  112. package/core/element/ButtonElement.js +1 -47
  113. package/core/element/ButtonElement.js.map +1 -1
  114. package/core/element/CanvasElement.d.ts +2 -2
  115. package/core/element/CanvasElement.js +1 -14
  116. package/core/element/CanvasElement.js.map +1 -1
  117. package/core/element/CaptionElement.d.ts +2 -2
  118. package/core/element/CaptionElement.js +1 -13
  119. package/core/element/CaptionElement.js.map +1 -1
  120. package/core/element/CiteElement.d.ts +2 -2
  121. package/core/element/CiteElement.js +1 -11
  122. package/core/element/CiteElement.js.map +1 -1
  123. package/core/element/CodeElement.d.ts +2 -2
  124. package/core/element/CodeElement.js +1 -13
  125. package/core/element/CodeElement.js.map +1 -1
  126. package/core/element/DataListElement.d.ts +2 -2
  127. package/core/element/DataListElement.js +1 -13
  128. package/core/element/DataListElement.js.map +1 -1
  129. package/core/element/DefinitionDescriptionElement.d.ts +2 -2
  130. package/core/element/DefinitionDescriptionElement.js +1 -13
  131. package/core/element/DefinitionDescriptionElement.js.map +1 -1
  132. package/core/element/DefinitionElement.d.ts +2 -2
  133. package/core/element/DefinitionElement.js +1 -13
  134. package/core/element/DefinitionElement.js.map +1 -1
  135. package/core/element/DeletedTextElement.d.ts +2 -4
  136. package/core/element/DeletedTextElement.js +1 -15
  137. package/core/element/DeletedTextElement.js.map +1 -1
  138. package/core/element/DetailsElement.d.ts +3 -6
  139. package/core/element/DetailsElement.js +1 -28
  140. package/core/element/DetailsElement.js.map +1 -1
  141. package/core/element/DialogElement.d.ts +2 -4
  142. package/core/element/DialogElement.js +1 -14
  143. package/core/element/DialogElement.js.map +1 -1
  144. package/core/element/DivElement.d.ts +2 -2
  145. package/core/element/DivElement.js +1 -10
  146. package/core/element/DivElement.js.map +1 -1
  147. package/core/element/EmElement.d.ts +2 -2
  148. package/core/element/EmElement.js +1 -10
  149. package/core/element/EmElement.js.map +1 -1
  150. package/core/element/EmbedElement.d.ts +2 -7
  151. package/core/element/EmbedElement.js +1 -19
  152. package/core/element/EmbedElement.js.map +1 -1
  153. package/core/element/FieldSetElement.d.ts +3 -6
  154. package/core/element/FieldSetElement.js +1 -34
  155. package/core/element/FieldSetElement.js.map +1 -1
  156. package/core/element/FooterElement.d.ts +2 -2
  157. package/core/element/FooterElement.js +1 -13
  158. package/core/element/FooterElement.js.map +1 -1
  159. package/core/element/FormElement.d.ts +2 -17
  160. package/core/element/FormElement.js +1 -36
  161. package/core/element/FormElement.js.map +1 -1
  162. package/core/element/Fragment.js +1 -103
  163. package/core/element/H1Element.d.ts +2 -2
  164. package/core/element/H1Element.js +1 -10
  165. package/core/element/H1Element.js.map +1 -1
  166. package/core/element/H2Element.d.ts +2 -2
  167. package/core/element/H2Element.js +1 -10
  168. package/core/element/H2Element.js.map +1 -1
  169. package/core/element/H3Element.d.ts +2 -2
  170. package/core/element/H3Element.js +1 -10
  171. package/core/element/H3Element.js.map +1 -1
  172. package/core/element/H4Element.d.ts +2 -2
  173. package/core/element/H4Element.js +1 -10
  174. package/core/element/H4Element.js.map +1 -1
  175. package/core/element/H5Element.d.ts +2 -2
  176. package/core/element/H5Element.js +1 -10
  177. package/core/element/H5Element.js.map +1 -1
  178. package/core/element/H6Element.d.ts +2 -2
  179. package/core/element/H6Element.js +1 -10
  180. package/core/element/H6Element.js.map +1 -1
  181. package/core/element/HeadElement.d.ts +2 -2
  182. package/core/element/HeadElement.js +1 -11
  183. package/core/element/HeadElement.js.map +1 -1
  184. package/core/element/HeaderElement.d.ts +2 -2
  185. package/core/element/HeaderElement.js +1 -13
  186. package/core/element/HeaderElement.js.map +1 -1
  187. package/core/element/HorizontalRuleElement.d.ts +2 -2
  188. package/core/element/HorizontalRuleElement.js +1 -13
  189. package/core/element/HorizontalRuleElement.js.map +1 -1
  190. package/core/element/HtmlElement.d.ts +2 -4
  191. package/core/element/HtmlElement.js +1 -19
  192. package/core/element/HtmlElement.js.map +1 -1
  193. package/core/element/IFrameElement.d.ts +2 -15
  194. package/core/element/IFrameElement.js +1 -67
  195. package/core/element/IFrameElement.js.map +1 -1
  196. package/core/element/ILayout.d.ts +2 -2
  197. package/core/element/ILayout.js +1 -9
  198. package/core/element/ILayout.js.map +1 -1
  199. package/core/element/IconElement.d.ts +2 -2
  200. package/core/element/IconElement.js +1 -32
  201. package/core/element/IconElement.js.map +1 -1
  202. package/core/element/IdiomaticElement.d.ts +2 -1
  203. package/core/element/IdiomaticElement.js +1 -6
  204. package/core/element/IdiomaticElement.js.map +1 -1
  205. package/core/element/ImageElement.d.ts +2 -2
  206. package/core/element/ImageElement.js +1 -17
  207. package/core/element/ImageElement.js.map +1 -1
  208. package/core/element/InputElement.d.ts +2 -16
  209. package/core/element/InputElement.js +1 -81
  210. package/core/element/InputElement.js.map +1 -1
  211. package/core/element/LabelElement.d.ts +2 -5
  212. package/core/element/LabelElement.js +1 -10
  213. package/core/element/LabelElement.js.map +1 -1
  214. package/core/element/LegendElement.d.ts +2 -4
  215. package/core/element/LegendElement.js +1 -15
  216. package/core/element/LegendElement.js.map +1 -1
  217. package/core/element/ListItemElement.d.ts +2 -4
  218. package/core/element/ListItemElement.js +1 -28
  219. package/core/element/ListItemElement.js.map +1 -1
  220. package/core/element/MainElement.d.ts +2 -2
  221. package/core/element/MainElement.js +1 -10
  222. package/core/element/MainElement.js.map +1 -1
  223. package/core/element/NavElement.d.ts +2 -2
  224. package/core/element/NavElement.js +1 -10
  225. package/core/element/NavElement.js.map +1 -1
  226. package/core/element/OrderedListElement.d.ts +2 -2
  227. package/core/element/OrderedListElement.js +1 -10
  228. package/core/element/OrderedListElement.js.map +1 -1
  229. package/core/element/ParagraphElement.d.ts +2 -2
  230. package/core/element/ParagraphElement.js +1 -10
  231. package/core/element/ParagraphElement.js.map +1 -1
  232. package/core/element/PreElement.d.ts +2 -2
  233. package/core/element/PreElement.js +1 -10
  234. package/core/element/PreElement.js.map +1 -1
  235. package/core/element/SectionElement.d.ts +2 -2
  236. package/core/element/SectionElement.js +1 -12
  237. package/core/element/SectionElement.js.map +1 -1
  238. package/core/element/SelectElement.d.ts +2 -2
  239. package/core/element/SelectElement.js +1 -12
  240. package/core/element/SelectElement.js.map +1 -1
  241. package/core/element/SourceElement.d.ts +2 -5
  242. package/core/element/SourceElement.js +1 -14
  243. package/core/element/SourceElement.js.map +1 -1
  244. package/core/element/SpanElement.d.ts +2 -2
  245. package/core/element/SpanElement.js +1 -10
  246. package/core/element/SpanElement.js.map +1 -1
  247. package/core/element/StrongElement.d.ts +2 -2
  248. package/core/element/StrongElement.js +1 -12
  249. package/core/element/StrongElement.js.map +1 -1
  250. package/core/element/StyleElement.d.ts +2 -2
  251. package/core/element/StyleElement.js +1 -10
  252. package/core/element/StyleElement.js.map +1 -1
  253. package/core/element/SummaryElement.d.ts +2 -2
  254. package/core/element/SummaryElement.js +1 -12
  255. package/core/element/SummaryElement.js.map +1 -1
  256. package/core/element/SvgElement.d.ts +3 -3
  257. package/core/element/SvgElement.js +1 -151
  258. package/core/element/SvgElement.js.map +1 -1
  259. package/core/element/TableBodyElement.d.ts +2 -2
  260. package/core/element/TableBodyElement.js +1 -10
  261. package/core/element/TableBodyElement.js.map +1 -1
  262. package/core/element/TableCellElement.d.ts +3 -6
  263. package/core/element/TableCellElement.js +1 -25
  264. package/core/element/TableCellElement.js.map +1 -1
  265. package/core/element/TableColElement.d.ts +2 -4
  266. package/core/element/TableColElement.js +1 -13
  267. package/core/element/TableColElement.js.map +1 -1
  268. package/core/element/TableColGroupElement.d.ts +2 -4
  269. package/core/element/TableColGroupElement.js +1 -15
  270. package/core/element/TableColGroupElement.js.map +1 -1
  271. package/core/element/TableElement.d.ts +2 -42
  272. package/core/element/TableElement.js +1 -228
  273. package/core/element/TableElement.js.map +1 -1
  274. package/core/element/TableFootElement.d.ts +2 -2
  275. package/core/element/TableFootElement.js +1 -10
  276. package/core/element/TableFootElement.js.map +1 -1
  277. package/core/element/TableFootRowElement.d.ts +2 -2
  278. package/core/element/TableFootRowElement.js +1 -23
  279. package/core/element/TableFootRowElement.js.map +1 -1
  280. package/core/element/TableHeadCellElement.d.ts +2 -2
  281. package/core/element/TableHeadCellElement.js +1 -24
  282. package/core/element/TableHeadCellElement.js.map +1 -1
  283. package/core/element/TableHeadElement.d.ts +2 -2
  284. package/core/element/TableHeadElement.js +1 -10
  285. package/core/element/TableHeadElement.js.map +1 -1
  286. package/core/element/TableHeadRowElement.d.ts +2 -2
  287. package/core/element/TableHeadRowElement.js +1 -29
  288. package/core/element/TableHeadRowElement.js.map +1 -1
  289. package/core/element/TableRowElement.d.ts +2 -2
  290. package/core/element/TableRowElement.js +1 -29
  291. package/core/element/TableRowElement.js.map +1 -1
  292. package/core/element/TextAreaElement.d.ts +2 -4
  293. package/core/element/TextAreaElement.js +1 -10
  294. package/core/element/TextAreaElement.js.map +1 -1
  295. package/core/element/UListElement.d.ts +2 -2
  296. package/core/element/UListElement.js +1 -10
  297. package/core/element/UListElement.js.map +1 -1
  298. package/core/element/VideoElement.d.ts +2 -10
  299. package/core/element/VideoElement.js +1 -16
  300. package/core/element/VideoElement.js.map +1 -1
  301. package/core/element/index.d.ts +3 -3
  302. package/core/element/index.js +1 -73
  303. package/core/element/index.js.map +1 -1
  304. package/core/event/index.js +1 -75
  305. package/core/index.d.ts +0 -3
  306. package/core/index.js +1 -10
  307. package/core/index.js.map +1 -1
  308. package/core/ref/Computed.js +1 -75
  309. package/core/ref/Computed.js.map +1 -1
  310. package/core/ref/RefBoolean.js +1 -119
  311. package/core/ref/RefContainer.js +1 -114
  312. package/core/ref/RefContainer.js.map +1 -1
  313. package/core/ref/RefList.js +1 -240
  314. package/core/ref/RefMap.js +1 -149
  315. package/core/ref/RefNumber.js +1 -157
  316. package/core/ref/RefObject.js +1 -265
  317. package/core/ref/RefObject.js.map +1 -1
  318. package/core/ref/RefProperty.js +1 -46
  319. package/core/ref/RefSet.js +1 -148
  320. package/core/ref/RefState.js +1 -89
  321. package/core/ref/RefString.js +1 -179
  322. package/core/ref/RefString.js.map +1 -1
  323. package/core/ref/index.js +1 -71
  324. package/core/router/RouteView.d.ts +2 -2
  325. package/core/router/RouteView.js +1 -84
  326. package/core/router/RouteView.js.map +1 -1
  327. package/core/router/Router.d.ts +8 -9
  328. package/core/router/Router.js +1 -307
  329. package/core/router/Router.js.map +1 -1
  330. package/core/router/RouterEvent.js +1 -43
  331. package/core/router/RouterGuard.js +1 -3
  332. package/core/router/index.js +1 -5
  333. package/core/styles/index.d.ts +3 -3
  334. package/core/styles/index.js +1 -36
  335. package/core/styles/index.js.map +1 -1
  336. package/{core/app/index.d.ts → global/app.d.ts} +5 -7
  337. package/global/app.js +1 -0
  338. package/global/app.js.map +1 -0
  339. package/global/index.d.ts +10 -4
  340. package/global/index.js +1 -1286
  341. package/global/index.js.map +1 -1
  342. package/global/safari-polyfill.js +1 -234
  343. package/index.d.ts +1 -0
  344. package/index.js +1 -4
  345. package/index.js.map +1 -1
  346. package/package.json +1 -1
  347. package/styles/style.scss +2 -17
  348. package/typings/index.d.ts +58 -66
  349. package/LICENSE +0 -21
  350. package/README.md +0 -62
  351. package/core/app/Validate.d.ts +0 -61
  352. package/core/app/Validate.js +0 -2
  353. package/core/app/Validate.js.map +0 -1
  354. package/core/app/index.js +0 -181
  355. package/core/app/index.js.map +0 -1
  356. package/core/components/TablePanel.d.ts +0 -34
  357. package/core/components/TablePanel.js +0 -127
  358. package/core/components/TablePanel.js.map +0 -1
  359. package/core/components/VirtualScroll copy 2.d.ts +0 -24
  360. package/core/components/VirtualScroll copy 2.js +0 -92
  361. package/core/components/VirtualScroll copy 2.js.map +0 -1
  362. package/core/ref/RefObject copy.d.ts +0 -124
  363. package/core/ref/RefObject copy.js +0 -271
  364. package/core/ref/RefObject copy.js.map +0 -1
package/global/index.js CHANGED
@@ -1,1286 +1 @@
1
- import { EventComponent } from "../core/event";
2
- import { computed, InputElement, ref, RefBoolean, RefList, RefMap, RefNumber, RefSet, RefString } from "../";
3
- // safari-polyfill
4
- if (/^((?!chrome|android|crios|fxios).)*safari/i.test(navigator.userAgent) || /iP(hone|od|ad)/.test(navigator.userAgent)) {
5
- const { keys: e } = Object, t = !0, r = !1, n = "querySelectorAll", o = "querySelectorAll", { document: l, Element: s, MutationObserver: a, Set: c, WeakMap: u } = self,
6
- /// @ts-ignore
7
- i = (e) => o in e, { filter: d } = [];
8
- /// @ts-ignore
9
- var h = (e) => {
10
- const h = new u(),
11
- /// @ts-ignore
12
- f = (t, r) => {
13
- let n;
14
- if (r)
15
- for (let o, l = ((e) => e.matches || e.webkitMatchesSelector || e.msMatchesSelector)(t), s = 0, { length: a } = p; s < a; s++)
16
- l.call(t, (o = p[s])) &&
17
- (h.has(t) || h.set(t, new c()),
18
- (n = h.get(t)),
19
- n.has(o) || (n.add(o), e.handle(t, r, o)));
20
- else
21
- h.has(t) &&
22
- ((n = h.get(t)),
23
- h.delete(t),
24
- /// @ts-ignore
25
- n.forEach((n) => {
26
- e.handle(t, r, n);
27
- }));
28
- },
29
- /// @ts-ignore
30
- g = (e, t = !0) => {
31
- for (let r = 0, { length: n } = e; r < n; r++)
32
- f(e[r], t);
33
- }, { query: p } = e, b = e.root || l, y = ((e, o = document, l = MutationObserver, s = ["*"]) => {
34
- /// @ts-ignore
35
- const a = (r, o, l, s, c, u) => {
36
- for (const i of r)
37
- (u || n in i) &&
38
- (c
39
- ? l.has(i) || (l.add(i), s.delete(i), e(i, c))
40
- : s.has(i) || (s.add(i), l.delete(i), e(i, c)),
41
- u || a(i[n](o), o, l, s, c, t));
42
- }, c = new l((e) => {
43
- if (s.length) {
44
- const n = s.join(","), o = new Set(), l = new Set();
45
- for (const { addedNodes: s, removedNodes: c } of e)
46
- a(c, n, o, l, r, r), a(s, n, o, l, t, r);
47
- }
48
- }), { observe: u } = c;
49
- return ((c.observe = (e) => u.call(c, e, { subtree: t, childList: t }))(o), c);
50
- })(f, b, a, p), { attachShadow: w } = s.prototype;
51
- return (w &&
52
- (s.prototype.attachShadow = function (e) {
53
- const t = w.call(this, e);
54
- return y.observe(t), t;
55
- }),
56
- p.length && g(b[o](p)),
57
- {
58
- /// @ts-ignore
59
- drop: (e) => {
60
- for (let t = 0, { length: r } = e; t < r; t++)
61
- h.delete(e[t]);
62
- },
63
- flush: () => {
64
- const e = y.takeRecords();
65
- for (let t = 0, { length: r } = e; t < r; t++)
66
- g(d.call(e[t].removedNodes, i), !1),
67
- g(d.call(e[t].addedNodes, i), !0);
68
- },
69
- observer: y,
70
- parse: g,
71
- });
72
- };
73
- const { customElements: f, document: g, Element: p, MutationObserver: b, Object: y, Promise: w, Map: m, Set: S, WeakMap: v, Reflect: A, } = self, { createElement: E } = g, { define: M, get: O, upgrade: q } = f, { construct: k } = A || {
74
- /// @ts-ignore
75
- construct(e) {
76
- return e.call(this);
77
- },
78
- }, { defineProperty: N, getOwnPropertyNames: $, setPrototypeOf: P } = y, C = new v(), j = new S(), V = new m(), L = new m(), R = new m(), T = new m(),
79
- /// @ts-ignore
80
- W = [],
81
- /// @ts-ignore
82
- _ = [],
83
- /// @ts-ignore
84
- x = (e) => T.get(e) || O.call(f, e), { parse: D } = h({
85
- /// @ts-ignore
86
- query: _,
87
- /// @ts-ignore
88
- handle: (t, r, n) => {
89
- const o = R.get(n);
90
- if (r && !o.isPrototypeOf(t)) {
91
- const r = ((t) => {
92
- const r = e(t),
93
- /// @ts-ignore
94
- n = [], o = new Set(), { length: l } = r;
95
- for (let e = 0; e < l; e++) {
96
- n[e] = t[r[e]];
97
- try {
98
- delete t[r[e]];
99
- }
100
- catch (t) {
101
- o.add(e);
102
- }
103
- }
104
- return () => {
105
- /// @ts-ignore
106
- for (let e = 0; e < l; e++)
107
- o.has(e) || (t[r[e]] = n[e]);
108
- };
109
- })(t);
110
- B = P(t, o);
111
- try {
112
- new o.constructor();
113
- }
114
- finally {
115
- (B = null), r();
116
- }
117
- }
118
- const l = (r ? "" : "dis") + "connectedCallback";
119
- l in o && t[l]();
120
- },
121
- }), { parse: F } = h({
122
- /// @ts-ignore
123
- query: W,
124
- /// @ts-ignore
125
- handle(e, t) {
126
- /// @ts-ignore
127
- C.has(e) && (t ? j.add(e) : j.delete(e), _.length && G.call(_, e));
128
- },
129
- }), { attachShadow: H } = p.prototype;
130
- H &&
131
- (p.prototype.attachShadow = function (e) {
132
- const t = H.call(this, e);
133
- return C.set(this, t), t;
134
- });
135
- /// @ts-ignore
136
- const I = (e) => {
137
- if (!L.has(e)) {
138
- let t, r = new w((e) => {
139
- t = e;
140
- });
141
- L.set(e, { $: r, _: t });
142
- }
143
- return L.get(e).$;
144
- }, z = ((e, t) => {
145
- /// @ts-ignore
146
- const r = (e) => {
147
- for (let t = 0, { length: r } = e; t < r; t++)
148
- n(e[t]);
149
- },
150
- /// @ts-ignore
151
- n = ({ target: e, attributeName: t, oldValue: r }) => {
152
- e.attributeChangedCallback(t, r, e.getAttribute(t));
153
- };
154
- /// @ts-ignore
155
- return (o, l) => {
156
- const { observedAttributes: s } = o.constructor;
157
- return (s &&
158
- e(l).then(() => {
159
- new t(r).observe(o, {
160
- attributes: !0,
161
- attributeOldValue: !0,
162
- attributeFilter: s,
163
- });
164
- for (let e = 0, { length: t } = s; e < t; e++)
165
- o.hasAttribute(s[e]) &&
166
- n({ target: o, attributeName: s[e], oldValue: null });
167
- }),
168
- o);
169
- };
170
- })(I, b);
171
- /// @ts-ignore
172
- let B = null;
173
- /// @ts-ignore
174
- function G(e) {
175
- const t = C.get(e);
176
- /// @ts-ignore
177
- D(t.querySelectorAll(this), e.isConnected);
178
- }
179
- $(self)
180
- .filter((e) => /^HTML.*Element$/.test(e))
181
- .forEach((e) => {
182
- /// @ts-ignore
183
- const t = self[e];
184
- function r() {
185
- /// @ts-ignore
186
- const { constructor: e } = this;
187
- if (!V.has(e))
188
- throw new TypeError("Illegal constructor");
189
- const { is: r, tag: n } = V.get(e);
190
- if (r) {
191
- /// @ts-ignore
192
- if (B)
193
- return z(B, r);
194
- const t = E.call(g, n);
195
- return t.setAttribute("is", r), z(P(t, e.prototype), r);
196
- }
197
- /// @ts-ignore
198
- return k.call(this, t, [], e);
199
- }
200
- P(r, t),
201
- N((r.prototype = t.prototype), "constructor", { value: r }),
202
- N(self, e, { value: r });
203
- }),
204
- /// @ts-ignore
205
- (g.createElement = function (e, t) {
206
- const r = t && t.is;
207
- if (r) {
208
- const t = T.get(r);
209
- if (t && V.get(t).tag === e)
210
- return new t();
211
- }
212
- const n = E.call(g, e);
213
- return r && n.setAttribute("is", r), n;
214
- }),
215
- (f.get = x),
216
- (f.whenDefined = I),
217
- (f.upgrade = function (e) {
218
- /// @ts-ignore
219
- const t = e.getAttribute("is");
220
- if (t) {
221
- const r = T.get(t);
222
- if (r)
223
- return void z(P(e, r.prototype), t);
224
- }
225
- q.call(f, e);
226
- }),
227
- (f.define = function (e, t, r) {
228
- if (x(e))
229
- throw new Error(`'${e}' has already been defined as a custom element`);
230
- /// @ts-ignore
231
- let n;
232
- const o = r && r.extends;
233
- V.set(t, o ? { is: e, tag: o } : { is: "", tag: e }),
234
- o
235
- ? ((n = `${o}[is="${e}"]`),
236
- R.set(n, t.prototype),
237
- T.set(e, t),
238
- _.push(n))
239
- /// @ts-ignore
240
- : (M.apply(f, arguments), W.push((n = e))),
241
- I(e).then(() => {
242
- o
243
- /// @ts-ignore
244
- ? (D(g.querySelectorAll(n)), j.forEach(G, [n]))
245
- /// @ts-ignore
246
- : F(g.querySelectorAll(n));
247
- }),
248
- L.get(e)._(t);
249
- });
250
- }
251
- const styleRef = Symbol("styleRef");
252
- const variantAll = Symbol("variantAll");
253
- const variants = new Map();
254
- const mergeVariants = new Map();
255
- const TypeComposer = {
256
- defineElement(name, constructor, options) {
257
- Component.mergeVariant(constructor, Object.getPrototypeOf(constructor.prototype).constructor);
258
- customElements.define(name, constructor, options);
259
- },
260
- createElement: (tag, props, ...children) => {
261
- const isComponent = tag?.prototype instanceof HTMLElement;
262
- if (typeof tag === "string" || isComponent) {
263
- if (tag === "fragment") {
264
- const fragment = document.createDocumentFragment();
265
- for (const child of children) {
266
- if (Array.isArray(child)) {
267
- fragment.append(...child);
268
- }
269
- else if (child instanceof Node) {
270
- fragment.append(child);
271
- }
272
- }
273
- return fragment;
274
- }
275
- const key = props?.key;
276
- const isValideKey = key && typeof key === "object" && key["controller"] && key["controller"]["getCache"] && key["controller"]["setCache"];
277
- if (isValideKey) {
278
- const cacheElement = key.controller.getCache(key.key);
279
- if (cacheElement)
280
- return cacheElement;
281
- }
282
- const onInit = props?.onInit;
283
- const style = props?.style;
284
- const refKey = props?.ref;
285
- const className = props?.className || props?.class;
286
- delete props?.className;
287
- delete props?.class;
288
- delete props?.onInit;
289
- delete props?.ref;
290
- delete props?.key;
291
- if (style)
292
- props.style = {};
293
- const ElementProps = (props || {});
294
- const el = isComponent ? new tag(ElementProps) : document.createElement(tag);
295
- if (isValideKey)
296
- key.controller.setCache(key.key, el);
297
- if (style)
298
- el.setStyle(style);
299
- if (className)
300
- el.addClassName(className);
301
- if (refKey)
302
- refKey(el);
303
- Component.applyProps(el, ElementProps);
304
- const appendChild = (parent, child) => {
305
- if (child instanceof ref) {
306
- // @ts-ignore
307
- parent.append(child);
308
- }
309
- else if (Array.isArray(child)) {
310
- child.forEach(c => appendChild(parent, c));
311
- }
312
- else if (child instanceof Node) {
313
- parent.appendChild(child);
314
- }
315
- else if (child !== null && child !== undefined) {
316
- parent.appendChild(document.createTextNode(child.toString()));
317
- }
318
- };
319
- children.forEach(c => appendChild(el, c));
320
- if (onInit)
321
- onInit();
322
- return el;
323
- }
324
- return tag({ ...props, children });
325
- },
326
- createFragment: (...children) => {
327
- const fragment = document.createDocumentFragment();
328
- fragment.append(...children);
329
- return fragment;
330
- },
331
- computed: computed,
332
- Fragment: "fragment"
333
- };
334
- globalThis.TypeComposer = TypeComposer;
335
- export class Component extends HTMLElement {
336
- static TAG = "tc-component";
337
- constructor(props) {
338
- super();
339
- Component.applyProps(this, props);
340
- }
341
- static async applyProps(element, props, ignoreStyle = false) {
342
- const hasProxy = Object.hasOwn(element.style, "styleRef");
343
- if (!hasProxy) {
344
- const style = element.style;
345
- // @ts-ignore
346
- style["styleRef"] = styleRef;
347
- const customStyle = new Proxy(style, {
348
- get(target, property) {
349
- const value = Reflect.get(target, property);
350
- return typeof value === "function" ? value.bind(target) : value;
351
- },
352
- set(target, property, value) {
353
- if (value instanceof ref) {
354
- // @ts-ignore
355
- value.subscribe(target, property);
356
- }
357
- else {
358
- // @ts-ignore
359
- Reflect.set(target, property, value);
360
- }
361
- return true;
362
- }
363
- });
364
- Object.defineProperty(element, "style", {
365
- get: () => customStyle
366
- });
367
- }
368
- if (props) {
369
- // @ts-ignore
370
- // const isStyle = props?.style !== undefined;
371
- for (const [key, propValue] of Object.entries(props)) {
372
- if (propValue === undefined || propValue === null)
373
- continue;
374
- switch (key) {
375
- case "key":
376
- element.key = propValue;
377
- break;
378
- case "onInit":
379
- if (typeof propValue === "function") {
380
- element.onInit = () => propValue();
381
- }
382
- break;
383
- case "style":
384
- element.setStyle(propValue);
385
- break;
386
- case "itemLoading":
387
- element.setAttribute("item-loading", propValue);
388
- break;
389
- case "children":
390
- if (Array.isArray(propValue))
391
- element.append(...propValue);
392
- else
393
- element.append(propValue);
394
- break;
395
- case "for":
396
- element.setAttribute("for", propValue);
397
- break;
398
- case "className":
399
- element.addClassName(propValue);
400
- break;
401
- case "text":
402
- element.innerText = propValue;
403
- break;
404
- case "html":
405
- element.innerHTML = propValue;
406
- break;
407
- case "style":
408
- for (const [styleKey, styleValue] of Object.entries(propValue)) {
409
- element.style[styleKey] = styleValue;
410
- }
411
- break;
412
- default:
413
- if (key in element && propValue) {
414
- try {
415
- element[key] = propValue;
416
- if (propValue === undefined)
417
- element.removeAttribute(key);
418
- }
419
- catch {
420
- }
421
- }
422
- }
423
- }
424
- }
425
- }
426
- static initComponent(thisObj, constructorObj) {
427
- if (thisObj.constructor === constructorObj) {
428
- if (thisObj?.template && typeof thisObj.template === "function") {
429
- const templateResult = thisObj.template();
430
- if (templateResult) {
431
- thisObj.append(templateResult);
432
- }
433
- }
434
- thisObj?.onInit();
435
- }
436
- }
437
- static createElement(html) {
438
- const element = document.createElement("div");
439
- element.innerHTML = html;
440
- return (element?.children[0] || element);
441
- }
442
- static setVariant(element, variant, apply) {
443
- if (!variants.has(element)) {
444
- variants.set(element, new Map());
445
- }
446
- const map = variants.get(element);
447
- if (map) {
448
- map.set(variant, apply);
449
- }
450
- }
451
- static getVariant(element, variant) {
452
- const map = variants.get(element);
453
- let action = undefined;
454
- if (map) {
455
- action = map.get(variant);
456
- }
457
- if (!action) {
458
- const v = mergeVariants.get(element);
459
- if (!v)
460
- return action;
461
- const varia = v.get(variant) || v.get(variantAll);
462
- if (varia)
463
- return Component.getVariant(varia, variant);
464
- }
465
- return action;
466
- }
467
- static getVariants(element) {
468
- const map = variants.get(element);
469
- if (!map)
470
- return [];
471
- return Array.from(map.keys());
472
- }
473
- static removeVariant(element, variant) {
474
- const map = variants.get(element);
475
- if (map) {
476
- map.delete(variant);
477
- }
478
- }
479
- static mergeVariant(element, src, ...variant) {
480
- if (!mergeVariants.has(element)) {
481
- mergeVariants.set(element, new Map());
482
- }
483
- const map = mergeVariants.get(element);
484
- if (map) {
485
- if (variant && variant.length) {
486
- for (const v of variant)
487
- map.set(v, src);
488
- }
489
- else
490
- map.set(variantAll, src);
491
- }
492
- }
493
- static lazyLoad(source, options) {
494
- const component = new (options?.component || Component)();
495
- source().then((module) => {
496
- // @ts-ignore
497
- const TestLazy = module.default;
498
- const parent = component.parentElement;
499
- if (parent) {
500
- parent.replaceChild(new TestLazy(options?.props), component);
501
- }
502
- });
503
- return component;
504
- }
505
- }
506
- globalThis.Component = Component;
507
- TypeComposer.defineElement(Component.TAG, Component);
508
- const isValideRef = (value) => (value && typeof value === "object" && (value instanceof RefString || value instanceof RefNumber || value instanceof RefBoolean || value instanceof RefList || value instanceof RefMap || value instanceof RefSet));
509
- const consolecheck = (callback, message, ...optionalParams) => {
510
- if (isValideRef(message))
511
- message = message.valueOf();
512
- for (let i = 0; i < optionalParams.length; i++) {
513
- if (isValideRef(optionalParams[i])) {
514
- optionalParams[i] = optionalParams[i].valueOf();
515
- }
516
- }
517
- callback(message, ...optionalParams);
518
- };
519
- const originalConsoleLog = console.log;
520
- console.log = function (message, ...optionalParams) {
521
- consolecheck(originalConsoleLog, message, ...optionalParams);
522
- };
523
- const originalConsoleError = console.error;
524
- console.error = function (message, ...optionalParams) {
525
- consolecheck(originalConsoleError, message, ...optionalParams);
526
- };
527
- const originalConsoleWarn = console.warn;
528
- console.warn = function (message, ...optionalParams) {
529
- consolecheck(originalConsoleWarn, message, ...optionalParams);
530
- };
531
- const originalConsoleInfo = console.info;
532
- console.info = function (message, ...optionalParams) {
533
- consolecheck(originalConsoleInfo, message, ...optionalParams);
534
- };
535
- // function deepCopy<T>(obj: T, cache = new WeakMap()): T {
536
- // if (obj instanceof ref) {
537
- // // @ts-ignore
538
- // obj = obj.valueOf();
539
- // }
540
- // if (obj === null || typeof obj !== "object")
541
- // return obj;
542
- // if (cache.has(obj))
543
- // return cache.get(obj);
544
- // if (obj instanceof HTMLElement)
545
- // return obj;
546
- // if (Array.isArray(obj)) {
547
- // const clonedArray = obj.map((item) => deepCopy(item, cache)) as unknown as T;
548
- // cache.set(obj, clonedArray);
549
- // return clonedArray;
550
- // }
551
- // if (obj instanceof Date)
552
- // return new Date(obj) as unknown as T;
553
- // if (obj instanceof RegExp)
554
- // return new RegExp(obj) as unknown as T;
555
- // if (obj instanceof Map) {
556
- // const clonedMap = new Map();
557
- // cache.set(obj, clonedMap);
558
- // for (const [key, value] of obj) {
559
- // clonedMap.set(deepCopy(key, cache), deepCopy(value, cache));
560
- // }
561
- // return clonedMap as unknown as T;
562
- // }
563
- // if (obj instanceof Set) {
564
- // const clonedSet = new Set();
565
- // cache.set(obj, clonedSet);
566
- // for (const value of obj) {
567
- // clonedSet.add(deepCopy(value, cache));
568
- // }
569
- // return clonedSet as unknown as T;
570
- // }
571
- // if (typeof obj === "function") {
572
- // return obj;
573
- // }
574
- // if (typeof obj === "object" && Object.getPrototypeOf(obj) === null) {
575
- // return obj;
576
- // }
577
- // const clonedObj = Object.create(Object.getPrototypeOf(obj));
578
- // cache.set(obj, clonedObj);
579
- // for (const key of [...Object.keys(obj), ...Object.getOwnPropertySymbols(obj)]) {
580
- // (clonedObj as any)[key] = deepCopy((obj as any)[key], cache);
581
- // }
582
- // if (Object.isFrozen(obj)) Object.freeze(clonedObj);
583
- // if (Object.isSealed(obj)) Object.seal(clonedObj);
584
- // return clonedObj as T;
585
- // }
586
- function deepCopy(obj, cache = new WeakMap()) {
587
- // @ts-ignore
588
- if (obj instanceof ref)
589
- obj = obj.valueOf();
590
- if (obj === null || typeof obj !== "object")
591
- return obj;
592
- if (cache.has(obj))
593
- return cache.get(obj);
594
- if (obj instanceof HTMLElement)
595
- return obj;
596
- if (typeof obj === "function")
597
- return obj;
598
- if (Object.getPrototypeOf(obj) === null)
599
- return obj;
600
- if (Array.isArray(obj)) {
601
- const arr = obj.map(item => deepCopy(item, cache));
602
- cache.set(obj, arr);
603
- return arr;
604
- }
605
- if (obj instanceof Date)
606
- return new Date(obj);
607
- if (obj instanceof RegExp)
608
- return new RegExp(obj);
609
- if (obj instanceof Map) {
610
- const map = new Map();
611
- cache.set(obj, map);
612
- for (const [k, v] of obj)
613
- map.set(deepCopy(k, cache), deepCopy(v, cache));
614
- return map;
615
- }
616
- if (obj instanceof Set) {
617
- const set = new Set();
618
- cache.set(obj, set);
619
- for (const v of obj)
620
- set.add(deepCopy(v, cache));
621
- return set;
622
- }
623
- const clonedObj = Object.create(Object.getPrototypeOf(obj));
624
- cache.set(obj, clonedObj);
625
- for (const key of Reflect.ownKeys(obj)) {
626
- clonedObj[key] = deepCopy(obj[key], cache);
627
- }
628
- if (Object.isFrozen(obj))
629
- Object.freeze(clonedObj);
630
- else if (Object.isSealed(obj))
631
- Object.seal(clonedObj);
632
- return clonedObj;
633
- }
634
- globalThis.deepCopy = deepCopy;
635
- WeakRef.prototype.equals = function (value) {
636
- return this.deref() === value.deref();
637
- };
638
- Object.defineProperty(Element.prototype, "onInit", {
639
- value: function () { },
640
- writable: true,
641
- configurable: true,
642
- enumerable: true,
643
- });
644
- Object.defineProperty(Element.prototype, "getElementById", {
645
- value: function (id) {
646
- return this.querySelector(`#${id}`);
647
- },
648
- writable: true,
649
- configurable: true,
650
- enumerable: true,
651
- });
652
- function basePrototypeRefInjection(prototype) {
653
- Object.defineProperty(prototype, "value", {
654
- get: function () {
655
- return this.valueOf();
656
- },
657
- set: function (value) {
658
- this.valueOf(value);
659
- },
660
- });
661
- Object.defineProperty(prototype, "subscribe", {
662
- value: function (target) {
663
- return undefined;
664
- },
665
- });
666
- Object.defineProperty(prototype, "unsubscribe", {
667
- value: function (target) {
668
- return undefined;
669
- },
670
- });
671
- }
672
- basePrototypeRefInjection(String.prototype);
673
- basePrototypeRefInjection(Number.prototype);
674
- basePrototypeRefInjection(Boolean.prototype);
675
- basePrototypeRefInjection(Array.prototype);
676
- basePrototypeRefInjection(Map.prototype);
677
- basePrototypeRefInjection(Set.prototype);
678
- function componentInjectionValue(prototype) {
679
- const original = Object.getOwnPropertyDescriptor(prototype, "value");
680
- if (!original)
681
- return;
682
- Object.defineProperty(prototype, "value", {
683
- set: function (value) {
684
- if (value instanceof ref) {
685
- // @ts-ignore
686
- const onInput = () => (value.value = this.value);
687
- this.addEventListener("input", onInput);
688
- value.subscribe(this, "value", () => this.removeEventListener("input", onInput));
689
- }
690
- else {
691
- original.set.call(this, value);
692
- }
693
- },
694
- });
695
- }
696
- function componentInjectionChecked(prototype) {
697
- const original = Object.getOwnPropertyDescriptor(prototype, "checked");
698
- if (!original)
699
- return;
700
- Object.defineProperty(prototype, "checked", {
701
- set: function (value) {
702
- if (value instanceof ref) {
703
- const onInput = () => (value.value = this.checked);
704
- this.addEventListener("input", onInput);
705
- this.subscribe(this, "checked", () => this.removeEventListener("input", onInput));
706
- }
707
- else {
708
- original.set.call(this, value);
709
- }
710
- },
711
- });
712
- }
713
- function componentInjectionDisabled(prototype) {
714
- Object.defineProperty(prototype, "disabled", {
715
- get: function () {
716
- return this.hasAttribute("disabled");
717
- },
718
- set: function (value) {
719
- if (value instanceof ref)
720
- value.subscribe(this, "disabled");
721
- else {
722
- if (value)
723
- this.setAttribute("disabled", "");
724
- else
725
- this.removeAttribute("disabled");
726
- }
727
- },
728
- });
729
- }
730
- function componentInjectionHidden(prototype) {
731
- Object.defineProperty(prototype, "hidden", {
732
- get: function () {
733
- return this.hasAttribute("hidden");
734
- },
735
- set: function (value) {
736
- if (value instanceof ref)
737
- value.subscribe(this, "hidden");
738
- else {
739
- if (value)
740
- this.setAttribute("hidden", "");
741
- else
742
- this.removeAttribute("hidden");
743
- }
744
- },
745
- });
746
- }
747
- function isWritable(descriptor) {
748
- if (!descriptor || typeof descriptor?.value == "function") {
749
- return false;
750
- }
751
- if ("value" in descriptor) {
752
- return !!descriptor.writable;
753
- }
754
- if ("get" in descriptor || "set" in descriptor) {
755
- return typeof descriptor.set === "function";
756
- }
757
- return false;
758
- }
759
- function componentInjectionVariableController(prototype, propertyName) {
760
- const original = getOwnPropertyDescriptor(prototype, propertyName);
761
- if (!isWritable(original))
762
- return;
763
- Object.defineProperty(prototype, propertyName, {
764
- set: function (value) {
765
- if (value instanceof ref) {
766
- value.subscribe(this, propertyName?.toString());
767
- }
768
- else
769
- original.set.call(this, value?.valueOf());
770
- },
771
- });
772
- }
773
- function getOwnPropertyDescriptor(prototype, propertName) {
774
- if (prototype == null)
775
- return undefined;
776
- const d = Object.getOwnPropertyDescriptor(prototype, propertName) || getOwnPropertyDescriptor(Object.getPrototypeOf(prototype), propertName);
777
- return d;
778
- }
779
- function componentInjectionController(prototype, propertNames) {
780
- if (propertNames == undefined)
781
- propertNames = Object.getOwnPropertyNames(prototype);
782
- if (!propertNames.includes("disabled"))
783
- componentInjectionDisabled(prototype);
784
- if (!propertNames.includes("hidden"))
785
- componentInjectionHidden(prototype);
786
- for (const propertName of propertNames) {
787
- if (propertName == "value")
788
- componentInjectionValue(prototype);
789
- else if (propertName == "checked")
790
- componentInjectionChecked(prototype);
791
- else
792
- componentInjectionVariableController(prototype, propertName);
793
- }
794
- }
795
- componentInjectionController(Element.prototype);
796
- componentInjectionController(HTMLElement.prototype);
797
- componentInjectionController(HTMLButtonElement.prototype);
798
- componentInjectionController(HTMLInputElement.prototype);
799
- componentInjectionController(HTMLTextAreaElement.prototype);
800
- componentInjectionController(HTMLImageElement.prototype);
801
- Object.defineProperty(Element.prototype, "variant", {
802
- get: function () {
803
- return this.getAttribute("variant") || "default";
804
- },
805
- set: function (v) {
806
- // @ts-ignore
807
- if (v instanceof ref) {
808
- // @ts-ignore
809
- v.subscribe(this, "variant");
810
- }
811
- else {
812
- v = v?.toString()?.trim() || "default";
813
- if (v == "default" || v == undefined || v.trim().length == 0)
814
- this.removeAttribute("variant");
815
- else {
816
- this.setAttribute("variant", v);
817
- }
818
- Component.getVariant(this.constructor, v)?.(this);
819
- }
820
- },
821
- });
822
- Object.defineProperty(Element.prototype, "connectedCallback", {
823
- value: function () {
824
- this.dispatchEvent(new CustomEvent("onConnected", { bubbles: false, cancelable: true }));
825
- this?.onConnected();
826
- },
827
- writable: true,
828
- configurable: true,
829
- enumerable: true,
830
- });
831
- Object.defineProperty(Element.prototype, "disconnectedCallback", {
832
- value: function () {
833
- this.dispatchEvent(new CustomEvent("onDisconnected", { bubbles: false, cancelable: true }));
834
- this?.onDisconnected();
835
- },
836
- writable: true,
837
- configurable: true,
838
- enumerable: true,
839
- });
840
- Object.defineProperty(window, "scoped", {
841
- value: function (target) { },
842
- writable: true,
843
- configurable: true,
844
- enumerable: true,
845
- });
846
- try {
847
- const originalButton = Object.getOwnPropertyDescriptor(HTMLButtonElement.prototype, "type").set;
848
- Object.defineProperty(HTMLButtonElement.prototype, "onfile", {
849
- value: function (fileList) { },
850
- writable: true,
851
- configurable: true,
852
- enumerable: true,
853
- });
854
- Object.defineProperty(HTMLButtonElement.prototype, "accept", {
855
- get: function () {
856
- return this.getAttribute("accept") || "";
857
- },
858
- set: function (value) {
859
- this.setAttribute("accept", value);
860
- },
861
- });
862
- Object.defineProperty(HTMLButtonElement.prototype, "multiple", {
863
- get: function () {
864
- return this.hasAttribute("multiple");
865
- },
866
- set: function (value) {
867
- if (value)
868
- this.setAttribute("multiple", "");
869
- else
870
- this.removeAttribute("multiple");
871
- },
872
- });
873
- Object.defineProperty(HTMLButtonElement.prototype, "type", {
874
- set: function (value) {
875
- if (this.__onButtonFile__) {
876
- if (this.__input_file__)
877
- this.removeChild(this.__input_file__);
878
- this.__input_file__ = undefined;
879
- this.removeEventListener("click", this.__onButtonFile__);
880
- }
881
- if (value == "file") {
882
- this.__input_file__ = new InputElement({ type: "file", style: { display: "none" } });
883
- this.__input_file__.onchange = (event) => {
884
- this.onfile(event.target.files);
885
- event.stopPropagation();
886
- event.preventDefault();
887
- };
888
- this.__input_file__.onclick = (event) => {
889
- this.removeChild(this.__input_file__);
890
- event.stopPropagation();
891
- };
892
- this.__onButtonFile__ = () => {
893
- this.__input_file__.accept = this.accept;
894
- this.__input_file__.multiple = this.multiple;
895
- this.appendChild(this.__input_file__);
896
- this.__input_file__.click();
897
- };
898
- this.addEventListener("click", this.__onButtonFile__);
899
- }
900
- originalButton.call(this, value);
901
- },
902
- });
903
- }
904
- catch (__) { }
905
- Object.defineProperty(Element.prototype, "onInit", {
906
- value: function () { },
907
- writable: true,
908
- configurable: true,
909
- enumerable: true,
910
- });
911
- Object.defineProperty(Element.prototype, "getParent", {
912
- value: function () {
913
- return this.parentElement;
914
- },
915
- writable: true,
916
- configurable: true,
917
- enumerable: true,
918
- });
919
- Object.defineProperty(Element.prototype, "onConnected", {
920
- value: function () { },
921
- writable: true,
922
- configurable: true,
923
- enumerable: true,
924
- });
925
- Object.defineProperty(Element.prototype, "onDisconnected", {
926
- value: function () { },
927
- writable: true,
928
- configurable: true,
929
- enumerable: true,
930
- });
931
- Object.defineProperty(Element.prototype, "unmount", {
932
- value: function () { },
933
- writable: true,
934
- configurable: true,
935
- enumerable: true,
936
- });
937
- Object.defineProperty(Element.prototype, "addClassName", {
938
- value: function (...names) {
939
- for (const name of names) {
940
- const strs = name.match(/\S+/g) || [];
941
- if (strs.length > 0)
942
- this.classList.add(...strs);
943
- }
944
- },
945
- writable: true,
946
- configurable: true,
947
- enumerable: true,
948
- });
949
- // remove class
950
- Object.defineProperty(Element.prototype, "removeClassName", {
951
- value: function (...names) {
952
- for (const name of names) {
953
- const strs = name.match(/\S+/g) || [];
954
- if (strs.length > 0)
955
- this.classList.remove(...strs);
956
- }
957
- },
958
- writable: true,
959
- configurable: true,
960
- enumerable: true,
961
- });
962
- Object.defineProperty(Element.prototype, "setStyle", {
963
- value: function (style) {
964
- for (const [key, value] of Object.entries(style)) {
965
- this.style[key] = value;
966
- }
967
- },
968
- writable: true,
969
- configurable: true,
970
- enumerable: true,
971
- });
972
- Object.defineProperty(Element.prototype, "onEvent", {
973
- value: function (type, listener, options) {
974
- EventComponent.addEventListener(this, type, listener, options);
975
- },
976
- writable: true,
977
- configurable: true,
978
- enumerable: true,
979
- });
980
- Object.defineProperty(Element.prototype, "createEvent", {
981
- value: function (type, ...data) {
982
- return EventComponent.createEvent(type, ...data);
983
- },
984
- writable: true,
985
- configurable: true,
986
- enumerable: true,
987
- });
988
- Object.defineProperty(Element.prototype, "removeEvent", {
989
- value: function (type) {
990
- EventComponent.removeEventListener(this, type);
991
- },
992
- writable: true,
993
- configurable: true,
994
- enumerable: true,
995
- });
996
- Object.defineProperty(Element.prototype, "removeEvents", {
997
- value: function () {
998
- EventComponent.removeEventListeners(this);
999
- },
1000
- writable: true,
1001
- configurable: true,
1002
- enumerable: true,
1003
- });
1004
- Object.defineProperty(Element.prototype, "emitEvent", {
1005
- value: function (type, ...params) {
1006
- return EventComponent.emitEvent(type, ...params);
1007
- },
1008
- writable: true,
1009
- configurable: true,
1010
- enumerable: true,
1011
- });
1012
- Object.defineProperty(Element.prototype, "deleteEvent", {
1013
- value: function (type) {
1014
- EventComponent.deleteEvent(type);
1015
- },
1016
- writable: true,
1017
- configurable: true,
1018
- enumerable: true,
1019
- });
1020
- const originalAppend = Element.prototype.append;
1021
- // symb
1022
- const REF_MUTATION = Symbol('RefMutation');
1023
- class RefElementObserver {
1024
- element;
1025
- node;
1026
- index = -1;
1027
- head;
1028
- elements = [];
1029
- constructor(element, node) {
1030
- this.element = element;
1031
- this.node = node;
1032
- }
1033
- set value(val) {
1034
- const oldElements = this.elements;
1035
- const value = this.node.valueOf();
1036
- if (Array.isArray(this.node))
1037
- this.elements = value;
1038
- else if (typeof value === "function") {
1039
- const result = value();
1040
- this.elements = Array.isArray(result) ? result : [result];
1041
- }
1042
- else
1043
- this.elements = [value];
1044
- if (this.index == -1) {
1045
- this.index = this.element.children.length;
1046
- this.element.append(...this.elements);
1047
- }
1048
- else {
1049
- const childrens = Array.from(this.element.children);
1050
- this.index = childrens.findIndex(child => child === oldElements[0]);
1051
- childrens.splice(this.index, oldElements.length, ...this.elements);
1052
- this.syncComponentWithList(childrens, this.element);
1053
- }
1054
- }
1055
- syncComponentWithList(list, element) {
1056
- const currentChildren = Array.from(element.children);
1057
- currentChildren.forEach((child) => {
1058
- if (!list.includes(child)) {
1059
- element.removeChild(child);
1060
- }
1061
- });
1062
- list.forEach((el) => {
1063
- // @ts-ignore
1064
- if (el instanceof Node && !currentChildren.includes(el)) {
1065
- element.appendChild(el);
1066
- }
1067
- });
1068
- list.forEach((el, index) => {
1069
- if (el instanceof Node && element.children[index] !== el) {
1070
- element.insertBefore(el, element.children[index] || null);
1071
- }
1072
- });
1073
- }
1074
- disconnect() {
1075
- this.node.unsubscribe(this, "value");
1076
- }
1077
- }
1078
- class RefMutationObserver extends MutationObserver {
1079
- element;
1080
- observers = new Map();
1081
- data;
1082
- constructor(element) {
1083
- super((mutations) => {
1084
- for (const m of mutations) {
1085
- m.addedNodes.forEach(n => {
1086
- // console.log('Filho adicionado:', n);
1087
- });
1088
- m.removedNodes.forEach(n => {
1089
- // console.log('Filho removido:', n);
1090
- });
1091
- }
1092
- });
1093
- this.element = element;
1094
- this.observe(this.element, { childList: true });
1095
- this.element[REF_MUTATION] = this;
1096
- }
1097
- appendRef(node) {
1098
- this.data = new RefElementObserver(this.element, node);
1099
- this.observers.set(node, this.data);
1100
- }
1101
- disconnect() {
1102
- super.disconnect();
1103
- for (const [_node, data] of this.observers) {
1104
- data.disconnect();
1105
- }
1106
- }
1107
- }
1108
- function getIndexInKeepElements(element, keepElements) {
1109
- if (element instanceof HTMLElement)
1110
- return keepElements.length - keepElements.indexOf(element);
1111
- return -1;
1112
- }
1113
- function replaceElements(parentNode, start, end, newElements) {
1114
- const childNodes = Array.from(parentNode.childNodes);
1115
- const startIndex = childNodes.indexOf(start);
1116
- const endIndex = childNodes.indexOf(end);
1117
- if (!Array.isArray(newElements))
1118
- newElements = [newElements];
1119
- // @ts-ignore
1120
- newElements = newElements.filter(Boolean).map(e => e instanceof HTMLElement ? e : document.createTextNode(e?.toString() || e));
1121
- if (startIndex === -1 || endIndex === -1 || endIndex <= startIndex)
1122
- return;
1123
- const existingElements = childNodes.slice(startIndex + 1, endIndex);
1124
- const removeElements = existingElements.filter((e) => !newElements.find((ne) => ne === e));
1125
- const keepElements = existingElements.filter((e) => newElements.find((ne) => ne === e));
1126
- // console.log("replaceElements: existingElements:", keepElements);
1127
- const actions = [];
1128
- for (const element of removeElements)
1129
- element.remove();
1130
- for (const [index, element] of newElements.entries()) {
1131
- if (!element)
1132
- continue;
1133
- const indexInKeep = getIndexInKeepElements(element, keepElements);
1134
- const indexInNew = newElements.length - newElements.indexOf(element);
1135
- // console.log("replaceElements: element:", element, "indexInKeep:", indexInKeep , `(${keepElements.length})`, "indexInNew:", indexInNew, `(${newElements.length})`);
1136
- actions.unshift({
1137
- element: element,
1138
- action: keepElements[index] === element ? 'keep' : 'insert',
1139
- before: newElements[index + 1] ? newElements[index + 1] : end,
1140
- });
1141
- }
1142
- for (const action of actions) {
1143
- const { element, action: act, before } = action;
1144
- if (act === "keep")
1145
- continue;
1146
- // console.log("replaceElements: insert:", element, "before:", before);
1147
- if (act === "insert")
1148
- parentNode.insertBefore(element, before);
1149
- }
1150
- // console.log("replaceElements:", actions);
1151
- // console.log("newElements:", newElements);
1152
- }
1153
- // append
1154
- Element.prototype.append = function (...nodes) {
1155
- const isRef = nodes.find(node => node instanceof ref);
1156
- if (isRef) {
1157
- for (const n of nodes) {
1158
- if (n instanceof ref) {
1159
- const r = n;
1160
- const start = new Comment(`ref:${r.id}:start`);
1161
- const end = new Comment(`ref:${r.id}:end`);
1162
- originalAppend.call(this, start, end);
1163
- r.subscribe((value) => replaceElements(this, start, end, value));
1164
- }
1165
- else {
1166
- originalAppend.call(this, n);
1167
- }
1168
- }
1169
- }
1170
- else
1171
- originalAppend.call(this, ...nodes);
1172
- };
1173
- Window.prototype.getTheme = function () {
1174
- return localStorage.getItem("theme") || "light";
1175
- };
1176
- Window.prototype.setTheme = function (theme) {
1177
- const html = document.querySelector("html");
1178
- html?.setAttribute("data-theme", theme);
1179
- localStorage.setItem("theme", theme);
1180
- };
1181
- Array.prototype.clear = function () {
1182
- this.length = 0;
1183
- };
1184
- {
1185
- Object.defineProperty(SVGElement.prototype, "complete", {
1186
- value: false,
1187
- writable: true,
1188
- configurable: true,
1189
- enumerable: true,
1190
- });
1191
- Object.defineProperty(SVGElement.prototype, "src", {
1192
- get: function () {
1193
- return this.getAttribute("src") || "";
1194
- },
1195
- set: function (value) {
1196
- if (value)
1197
- this.setAttribute("src", value);
1198
- else
1199
- this.removeAttribute("src");
1200
- },
1201
- });
1202
- }
1203
- // const Fetch: {
1204
- // defaultHeaders?: HeadersInit | (() => HeadersInit);
1205
- // defaultCredentials?: RequestCredentials;
1206
- // //interceptors?: {
1207
- // // request?: (request: Request) => Request;
1208
- // // response?: (response: Response) => Response;
1209
- // //};
1210
- // invalidateCache: (key: string) => void;
1211
- // } = {
1212
- // defaultHeaders: undefined,
1213
- // invalidateCache(key: string) {
1214
- // if (key) {
1215
- // localStorage.removeItem(key);
1216
- // }
1217
- // }
1218
- // };
1219
- // (globalThis as any).Fetch = Fetch;
1220
- // (window as any).Fetch = Fetch;
1221
- // const orinalFetch = window.fetch;
1222
- // // @ts-ignore
1223
- // window.fetch = async (input: RequestInfo | ref<string>, init?: RequestInit): Promise<Response> => {
1224
- // const cache: { type: RequestCache | "localstorage" } = {
1225
- // type: init?.cache || "default",
1226
- // }
1227
- // if (input instanceof ref) {
1228
- // const _ref = input as ref<string>;
1229
- // _ref.subscribe((endpoint) => {
1230
- // endpoint && fetch(endpoint, init);
1231
- // })
1232
- // return null;
1233
- // }
1234
- // if (cache.type === "localstorage")
1235
- // delete init.cache;
1236
- // if (init?.params) {
1237
- // const params = new URLSearchParams();
1238
- // for (const key in init.params) {
1239
- // params.append(key, init.params[key]);
1240
- // }
1241
- // if (input instanceof Request) {
1242
- // input = new Request(input, { ...init, params });
1243
- // } else if (typeof input === "string") {
1244
- // input = new Request(`${input}${params.size ? '?' : ''}${params.toString()}`, init);
1245
- // }
1246
- // }
1247
- // const headers = Fetch?.defaultHeaders ? typeof Fetch.defaultHeaders === "function" ? Fetch?.defaultHeaders() : Fetch.defaultHeaders : {};
1248
- // const response = await orinalFetch(input, { headers: headers, credentials: Fetch?.defaultCredentials, ...(init || {}) });
1249
- // const { refKey } = init || {};
1250
- // if (refKey && response.ok) {
1251
- // const clone = response.clone();
1252
- // const contentType = response.headers.get('content-type');
1253
- // let data = "";
1254
- // if (contentType && contentType.includes('application/json')) {
1255
- // data = await clone.json();
1256
- // } else {
1257
- // data = await clone.text();
1258
- // }
1259
- // data = init.transform ? init.transform(data) : data;
1260
- // if (cache.type === "localstorage") {
1261
- // localStorage.setItem(input.toString(), data);
1262
- // }
1263
- // const _ref: ref = Ref.get(refKey);
1264
- // if (!_ref) {
1265
- // ref(data, refKey);
1266
- // } else {
1267
- // _ref.value = data;
1268
- // }
1269
- // // @ts-ignore
1270
- // Ref.getStatus(refKey).value = clone.status.toString();
1271
- // }
1272
- // return response;
1273
- // };
1274
- String.prototype.toNumber = function () {
1275
- // @ts-ignore
1276
- return new Number(this).valueOf();
1277
- };
1278
- String.prototype.toInt = function (radix) {
1279
- // @ts-ignore
1280
- return parseInt(this, radix);
1281
- };
1282
- String.prototype.toDate = function () {
1283
- // @ts-ignore
1284
- return new Date(this);
1285
- };
1286
- //# sourceMappingURL=index.js.map
1
+ import"./safari-polyfill";import{EventComponent}from"../core/event";import{computed,InputElement,ref,RefBoolean,RefList,RefMap,RefNumber,RefSet,RefString}from"../";function deepCopy(e,t=new WeakMap){if(e instanceof ref&&(e=e.valueOf()),null===e||"object"!=typeof e)return e;if(t.has(e))return t.get(e);if(e instanceof HTMLElement)return e;if("function"==typeof e)return e;if(null===Object.getPrototypeOf(e))return e;if(Array.isArray(e)){const n=e.map(e=>deepCopy(e,t));return t.set(e,n),n}if(e instanceof Date)return new Date(e);if(e instanceof RegExp)return new RegExp(e);if(e instanceof Map){const n=new Map;t.set(e,n);for(const[o,r]of e)n.set(deepCopy(o,t),deepCopy(r,t));return n}if(e instanceof Set){const n=new Set;t.set(e,n);for(const o of e)n.add(deepCopy(o,t));return n}const n=Object.create(Object.getPrototypeOf(e));t.set(e,n);for(const o of Reflect.ownKeys(e))n[o]=deepCopy(e[o],t);return Object.isFrozen(e)?Object.freeze(n):Object.isSealed(e)&&Object.seal(n),n}globalThis.deepCopy=deepCopy;const styleRef=Symbol("styleRef"),variantAll=Symbol("variantAll"),variants=new Map,mergeVariants=new Map;Object.defineProperty(Element.prototype,"extendedStyle",{get:function(){const e=this;return{add(t){const n=(e.getAttribute("tc-style")||"").split(/\s+/).filter(Boolean);n.includes(t)||(n.push(t),e.setAttribute("tc-style",n.join(" ")))},remove(t){const n=(e.getAttribute("tc-style")||"").split(/\s+/).filter(Boolean),o=n.indexOf(t);-1!==o&&(n.splice(o,1),e.setAttribute("tc-style",n.join(" ")))},has:t=>(e.getAttribute("tc-style")||"").split(/\s+/).filter(Boolean).includes(t),toggle(e){this.has(e)?this.remove(e):this.add(e)},clear(){e.removeAttribute("tc-style")},toString:()=>e.getAttribute("tc-style")||"",getReferences:()=>(e.getAttribute("tc-style")||"").split(/\s+/).filter(Boolean).map(e=>customElements.get(e)).filter(Boolean)}},configurable:!0});const TypeComposer={defineElement(e,t,n){Component.mergeVariant(t,Object.getPrototypeOf(t.prototype).constructor),customElements.define(e,t,n)},createElement:(e,t,...n)=>{const o=e?.prototype instanceof HTMLElement;if("string"==typeof e||o){if("fragment"===e){const e=document.createDocumentFragment();for(const t of n)Array.isArray(t)?e.append(...t):t instanceof Node&&e.append(t);return e}const r=t?.key,i=r&&"object"==typeof r&&r.controller&&r.controller.getCache&&r.controller.setCache;if(i){const e=r.controller.getCache(r.key);if(e)return e}const s=t?.onInit,c=t?.style,l=t?.ref,a=t?.className||t?.class;delete t?.className,delete t?.class,delete t?.onInit,delete t?.ref,delete t?.key,c&&(t.style={});const p=t||{},f=o?new e(p):document.createElement(e);i&&r.controller.setCache(r.key,f),c&&f.setStyle(c),a&&f.addClassName(a),l&&l(f),Component.applyProps(f,p);const u=(e,t)=>{t instanceof ref?e.append(t):Array.isArray(t)?t.forEach(t=>u(e,t)):t instanceof Node?e.appendChild(t):null!=t&&e.appendChild(document.createTextNode(t.toString()))};return n.forEach(e=>u(f,e)),s&&s(),f}return e({...t,children:n})},createFragment:(...e)=>{const t=document.createDocumentFragment();return t.append(...e),t},deepCopy:deepCopy,computed:computed,Fragment:"fragment"};globalThis.TypeComposer=TypeComposer;export const componentProps=Symbol("componentProps");export class Component extends HTMLElement{static TAG="tc-component";constructor(e){super(),Component.initComponent(this,Component,e)}static async applyProps(e,t,n=!1){if(!Object.hasOwn(e.style,"styleRef")){const t=e.style;t.styleRef=styleRef;const n=new Proxy(t,{get(e,t){const n=Reflect.get(e,t);return"function"==typeof n?n.bind(e):n},set:(e,t,n)=>(n instanceof ref?n.subscribe(e,t):Reflect.set(e,t,n),!0)});Object.defineProperty(e,"style",{get:()=>n})}if(t)for(const[n,o]of Object.entries(t))if(null!=o)switch(n){case"key":e.key=o;break;case"onInit":"function"==typeof o&&(e.onInit=()=>o());break;case"style":e.setStyle(o);break;case"itemLoading":e.setAttribute("item-loading",o);break;case"children":Array.isArray(o)?e.append(...o):e.append(o);break;case"for":e.setAttribute("for",o);break;case"className":e.addClassName(o);break;case"text":e.innerText=o;break;case"html":e.innerHTML=o;break;case"style":for(const[t,n]of Object.entries(o))e.style[t]=n;break;default:if(n in e&&o)try{e[n]=o,void 0===o&&e.removeAttribute(n)}catch{}}}static initComponent(e,t,n){if(e.constructor===t){if(Component.applyProps(e,e[componentProps]||n),e?.template&&"function"==typeof e.template){const t=e.template();t&&e.append(t)}return e?.onInit(),void(e[componentProps]&&delete e[componentProps])}n&&(e[componentProps]=n),Component.applyProps(e,n)}static createElement(e){const t=document.createElement("div");return t.innerHTML=e,t?.children[0]||t}static setVariant(e,t,n){variants.has(e)||variants.set(e,new Map);const o=variants.get(e);o&&o.set(t,n)}static getVariant(e,t){const n=variants.get(e);let o;if(n&&(o=n.get(t)),!o){const n=mergeVariants.get(e);if(!n)return o;const r=n.get(t)||n.get(variantAll);if(r)return Component.getVariant(r,t)}return o}static getVariants(e){const t=variants.get(e);return t?Array.from(t.keys()):[]}static removeVariant(e,t){const n=variants.get(e);n&&n.delete(t)}static mergeVariant(e,t,...n){mergeVariants.has(e)||mergeVariants.set(e,new Map);const o=mergeVariants.get(e);if(o)if(n&&n.length)for(const e of n)o.set(e,t);else o.set(variantAll,t)}static lazyLoad(e,t){const n=new(t?.component||Component);return e().then(e=>{const o=e.default,r=n.parentElement;r&&r.replaceChild(new o(t?.props),n)}),n}}globalThis.Component=Component,TypeComposer.defineElement(Component.TAG,Component);const isValideRef=e=>e&&"object"==typeof e&&(e instanceof RefString||e instanceof RefNumber||e instanceof RefBoolean||e instanceof RefList||e instanceof RefMap||e instanceof RefSet),consolecheck=(e,t,...n)=>{isValideRef(t)&&(t=t.valueOf());for(let e=0;e<n.length;e++)isValideRef(n[e])&&(n[e]=n[e].valueOf());e(t,...n)},originalConsoleLog=console.log;console.log=function(e,...t){consolecheck(originalConsoleLog,e,...t)};const originalConsoleError=console.error;console.error=function(e,...t){consolecheck(originalConsoleError,e,...t)};const originalConsoleWarn=console.warn;console.warn=function(e,...t){consolecheck(originalConsoleWarn,e,...t)};const originalConsoleInfo=console.info;function basePrototypeRefInjection(e){Object.defineProperty(e,"value",{get:function(){return this.valueOf()},set:function(e){this.valueOf(e)}}),Object.defineProperty(e,"subscribe",{value:function(e){}}),Object.defineProperty(e,"unsubscribe",{value:function(e){}})}function componentInjectionValue(e){const t=Object.getOwnPropertyDescriptor(e,"value");t&&Object.defineProperty(e,"value",{set:function(e){if(e instanceof ref){const t=()=>e.value=this.value;this.addEventListener("input",t),e.subscribe(this,"value",()=>this.removeEventListener("input",t))}else t.set.call(this,e)}})}function componentInjectionChecked(e){const t=Object.getOwnPropertyDescriptor(e,"checked");t&&Object.defineProperty(e,"checked",{set:function(e){if(e instanceof ref){const t=()=>e.value=this.checked;this.addEventListener("input",t),this.subscribe(this,"checked",()=>this.removeEventListener("input",t))}else t.set.call(this,e)}})}function componentInjectionDisabled(e){Object.defineProperty(e,"disabled",{get:function(){return this.hasAttribute("disabled")},set:function(e){e instanceof ref?e.subscribe(this,"disabled"):e?this.setAttribute("disabled",""):this.removeAttribute("disabled")}})}function componentInjectionHidden(e){Object.defineProperty(e,"hidden",{get:function(){return this.hasAttribute("hidden")},set:function(e){e instanceof ref?e.subscribe(this,"hidden"):e?this.setAttribute("hidden",""):this.removeAttribute("hidden")}})}function isWritable(e){return!(!e||"function"==typeof e?.value)&&("value"in e?!!e.writable:("get"in e||"set"in e)&&"function"==typeof e.set)}function componentInjectionVariableController(e,t){const n=getOwnPropertyDescriptor(e,t);isWritable(n)&&Object.defineProperty(e,t,{set:function(e){e instanceof ref?e.subscribe(this,t?.toString()):n.set.call(this,e?.valueOf())}})}function getOwnPropertyDescriptor(e,t){if(null==e)return;return Object.getOwnPropertyDescriptor(e,t)||getOwnPropertyDescriptor(Object.getPrototypeOf(e),t)}function componentInjectionController(e,t){null==t&&(t=Object.getOwnPropertyNames(e)),t.includes("disabled")||componentInjectionDisabled(e),t.includes("hidden")||componentInjectionHidden(e);for(const n of t)"value"==n?componentInjectionValue(e):"checked"==n?componentInjectionChecked(e):componentInjectionVariableController(e,n)}console.info=function(e,...t){consolecheck(originalConsoleInfo,e,...t)},WeakRef.prototype.equals=function(e){return this.deref()===e.deref()},Object.defineProperty(Element.prototype,"onInit",{value:function(){},writable:!0,configurable:!0,enumerable:!0}),Object.defineProperty(Element.prototype,"getElementById",{value:function(e){return this.querySelector(`#${e}`)},writable:!0,configurable:!0,enumerable:!0}),basePrototypeRefInjection(String.prototype),basePrototypeRefInjection(Number.prototype),basePrototypeRefInjection(Boolean.prototype),basePrototypeRefInjection(Array.prototype),basePrototypeRefInjection(Map.prototype),basePrototypeRefInjection(Set.prototype),componentInjectionController(Element.prototype),componentInjectionController(HTMLElement.prototype),componentInjectionController(HTMLButtonElement.prototype),componentInjectionController(HTMLInputElement.prototype),componentInjectionController(HTMLTextAreaElement.prototype),componentInjectionController(HTMLImageElement.prototype),Object.defineProperty(Element.prototype,"variant",{get:function(){return this.getAttribute("variant")||"default"},set:function(e){e instanceof ref?e.subscribe(this,"variant"):("default"==(e=e?.toString()?.trim()||"default")||null==e||0==e.trim().length?this.removeAttribute("variant"):this.setAttribute("variant",e),Component.getVariant(this.constructor,e)?.(this))}}),Object.defineProperty(Element.prototype,"connectedCallback",{value:function(){this.dispatchEvent(new CustomEvent("onConnected",{bubbles:!1,cancelable:!0})),this?.onConnected()},writable:!0,configurable:!0,enumerable:!0}),Object.defineProperty(Element.prototype,"disconnectedCallback",{value:function(){this.dispatchEvent(new CustomEvent("onDisconnected",{bubbles:!1,cancelable:!0})),this?.onDisconnected()},writable:!0,configurable:!0,enumerable:!0}),Object.defineProperty(window,"scoped",{value:function(e){},writable:!0,configurable:!0,enumerable:!0});try{const e=Object.getOwnPropertyDescriptor(HTMLButtonElement.prototype,"type").set;Object.defineProperty(HTMLButtonElement.prototype,"onfile",{value:function(e){},writable:!0,configurable:!0,enumerable:!0}),Object.defineProperty(HTMLButtonElement.prototype,"accept",{get:function(){return this.getAttribute("accept")||""},set:function(e){this.setAttribute("accept",e)}}),Object.defineProperty(HTMLButtonElement.prototype,"multiple",{get:function(){return this.hasAttribute("multiple")},set:function(e){e?this.setAttribute("multiple",""):this.removeAttribute("multiple")}}),Object.defineProperty(HTMLButtonElement.prototype,"type",{set:function(t){this.__onButtonFile__&&(this.__input_file__&&this.removeChild(this.__input_file__),this.__input_file__=void 0,this.removeEventListener("click",this.__onButtonFile__)),"file"==t&&(this.__input_file__=new InputElement({type:"file",style:{display:"none"}}),this.__input_file__.onchange=e=>{this.onfile(e.target.files),e.stopPropagation(),e.preventDefault()},this.__input_file__.onclick=e=>{this.removeChild(this.__input_file__),e.stopPropagation()},this.__onButtonFile__=()=>{this.__input_file__.accept=this.accept,this.__input_file__.multiple=this.multiple,this.appendChild(this.__input_file__),this.__input_file__.click()},this.addEventListener("click",this.__onButtonFile__)),e.call(this,t)}})}catch(e){}Object.defineProperty(Element.prototype,"onInit",{value:function(){},writable:!0,configurable:!0,enumerable:!0}),Object.defineProperty(Element.prototype,"getParent",{value:function(){return this.parentElement},writable:!0,configurable:!0,enumerable:!0}),Object.defineProperty(Element.prototype,"onConnected",{value:function(){},writable:!0,configurable:!0,enumerable:!0}),Object.defineProperty(Element.prototype,"onDisconnected",{value:function(){},writable:!0,configurable:!0,enumerable:!0}),Object.defineProperty(Element.prototype,"unmount",{value:function(){},writable:!0,configurable:!0,enumerable:!0}),Object.defineProperty(Element.prototype,"addClassName",{value:function(...e){for(const t of e){const e=t.match(/\S+/g)||[];e.length>0&&this.classList.add(...e)}},writable:!0,configurable:!0,enumerable:!0}),Object.defineProperty(Element.prototype,"removeClassName",{value:function(...e){for(const t of e){const e=t.match(/\S+/g)||[];e.length>0&&this.classList.remove(...e)}},writable:!0,configurable:!0,enumerable:!0}),Object.defineProperty(Element.prototype,"setStyle",{value:function(e){for(const[t,n]of Object.entries(e))this.style[t]=n},writable:!0,configurable:!0,enumerable:!0}),Object.defineProperty(Element.prototype,"onEvent",{value:function(e,t,n){EventComponent.addEventListener(this,e,t,n)},writable:!0,configurable:!0,enumerable:!0}),Object.defineProperty(Element.prototype,"createEvent",{value:function(e,...t){return EventComponent.createEvent(e,...t)},writable:!0,configurable:!0,enumerable:!0}),Object.defineProperty(Element.prototype,"removeEvent",{value:function(e){EventComponent.removeEventListener(this,e)},writable:!0,configurable:!0,enumerable:!0}),Object.defineProperty(Element.prototype,"removeEvents",{value:function(){EventComponent.removeEventListeners(this)},writable:!0,configurable:!0,enumerable:!0}),Object.defineProperty(Element.prototype,"emitEvent",{value:function(e,...t){return EventComponent.emitEvent(e,...t)},writable:!0,configurable:!0,enumerable:!0}),Object.defineProperty(Element.prototype,"deleteEvent",{value:function(e){EventComponent.deleteEvent(e)},writable:!0,configurable:!0,enumerable:!0});const originalAppend=Element.prototype.append,REF_MUTATION=Symbol("RefMutation");class RefElementObserver{element;node;index=-1;head;elements=[];constructor(e,t){this.element=e,this.node=t}set value(e){const t=this.elements,n=this.node.valueOf();if(Array.isArray(this.node))this.elements=n;else if("function"==typeof n){const e=n();this.elements=Array.isArray(e)?e:[e]}else this.elements=[n];if(-1==this.index)this.index=this.element.children.length,this.element.append(...this.elements);else{const e=Array.from(this.element.children);this.index=e.findIndex(e=>e===t[0]),e.splice(this.index,t.length,...this.elements),this.syncComponentWithList(e,this.element)}}syncComponentWithList(e,t){const n=Array.from(t.children);n.forEach(n=>{e.includes(n)||t.removeChild(n)}),e.forEach(e=>{e instanceof Node&&!n.includes(e)&&t.appendChild(e)}),e.forEach((e,n)=>{e instanceof Node&&t.children[n]!==e&&t.insertBefore(e,t.children[n]||null)})}disconnect(){this.node.unsubscribe(this,"value")}}class RefMutationObserver extends MutationObserver{element;observers=new Map;data;constructor(e){super(e=>{for(const t of e)t.addedNodes.forEach(e=>{}),t.removedNodes.forEach(e=>{})}),this.element=e,this.observe(this.element,{childList:!0}),this.element[REF_MUTATION]=this}appendRef(e){this.data=new RefElementObserver(this.element,e),this.observers.set(e,this.data)}disconnect(){super.disconnect();for(const[e,t]of this.observers)t.disconnect()}}function getIndexInKeepElements(e,t){return e instanceof HTMLElement?t.length-t.indexOf(e):-1}function replaceElements(e,t,n,o){const r=Array.from(e.childNodes),i=r.indexOf(t),s=r.indexOf(n);if(Array.isArray(o)||(o=[o]),o=o.filter(Boolean).map(e=>e instanceof HTMLElement?e:document.createTextNode(e?.toString()||e)),-1===i||-1===s||s<=i)return;const c=r.slice(i+1,s),l=c.filter(e=>!o.find(t=>t===e)),a=c.filter(e=>o.find(t=>t===e)),p=[];for(const e of l)e.remove();for(const[e,t]of o.entries())t&&p.unshift({element:t,action:a[e]===t?"keep":"insert",before:o[e+1]?o[e+1]:n});for(const t of p){const{element:n,action:o,before:r}=t;"keep"!==o&&("insert"===o&&e.insertBefore(n,r))}}Element.prototype.append=function(...e){if(e.find(e=>e instanceof ref))for(const t of e)if(t instanceof ref){const e=t,n=new Comment(`ref:${e.id}:start`),o=new Comment(`ref:${e.id}:end`);originalAppend.call(this,n,o),e.subscribe(e=>replaceElements(this,n,o,e))}else originalAppend.call(this,t);else originalAppend.call(this,...e)},Window.prototype.getTheme=function(){return localStorage.getItem("theme")||"light"},Window.prototype.setTheme=function(e){const t=document.querySelector("html");t?.setAttribute("data-theme",e),localStorage.setItem("theme",e)},Array.prototype.clear=function(){this.length=0},Object.defineProperty(SVGElement.prototype,"complete",{value:!1,writable:!0,configurable:!0,enumerable:!0}),Object.defineProperty(SVGElement.prototype,"src",{get:function(){return this.getAttribute("src")||""},set:function(e){e?this.setAttribute("src",e):this.removeAttribute("src")}}),String.prototype.toNumber=function(){return new Number(this).valueOf()},String.prototype.toInt=function(e){return parseInt(this,e)},String.prototype.toDate=function(){return new Date(this)};import{__App__}from"./app";export*from"../core/ref";export const App=new __App__;