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
@@ -1,127 +0,0 @@
1
- import { Component, DivElement, ButtonElement, SelectElement, TableElement, LabelElement, SpanElement, } from "../..";
2
- export class TablePagination extends Component {
3
- static TAG = "tc-table-pagination";
4
- // Total de itens (pode vir de API, props, etc.)
5
- totalItems = 15;
6
- // Estado interno
7
- currentPage = 1;
8
- rowsPerPage = 10;
9
- // Referências para atualização
10
- pageInfoText;
11
- prevButton;
12
- nextButton;
13
- rowsSelect;
14
- constructor(props) {
15
- super(props);
16
- this.addClassName("table-pagination"); // adiciona a classe principal
17
- // Container principal
18
- const container = new DivElement({ className: "pagination-container" });
19
- // --- Seção "Rows per page"
20
- const rowsPerPageContainer = new DivElement({ className: "rows-per-page" });
21
- const label = new LabelElement({ for: "rowsSelect", text: "Rows per page:" });
22
- this.rowsSelect = new SelectElement({ id: "rowsSelect" });
23
- const options = props?.options || [5, 10, 15];
24
- for (let i = 0; i < options.length; i++) {
25
- const option = new Option(options[i].toString(), options[i].toString());
26
- if (options[i] === props?.rowsPerPage) {
27
- option.selected = true;
28
- }
29
- this.rowsSelect.appendChild(option);
30
- }
31
- rowsPerPageContainer.appendChild(label);
32
- rowsPerPageContainer.appendChild(this.rowsSelect);
33
- const pageInfoContainer = new DivElement({ className: "page-info" });
34
- this.pageInfoText = new SpanElement();
35
- pageInfoContainer.append(this.pageInfoText);
36
- // --- Botões de navegação
37
- const navContainer = new DivElement({ className: "navigation-buttons" });
38
- this.prevButton = new ButtonElement({ text: "◀", id: "prevBtn" });
39
- this.nextButton = new ButtonElement({ text: "▶", id: "nextBtn" });
40
- navContainer.appendChild(this.prevButton);
41
- navContainer.appendChild(this.nextButton);
42
- // --- Monta tudo no container principal
43
- container.appendChild(rowsPerPageContainer);
44
- container.appendChild(pageInfoContainer);
45
- container.appendChild(navContainer);
46
- // Anexa ao componente
47
- this.appendChild(container);
48
- // Eventos
49
- this.prevButton.onclick = () => this.onPrevClick();
50
- this.nextButton.onclick = () => this.onNextClick();
51
- this.rowsSelect.onchange = (event) => this.onRowsChange(event);
52
- // Inicializa a informação de página
53
- this.updatePageInfo();
54
- }
55
- maxItems(value) {
56
- this.totalItems = value;
57
- this.updatePageInfo();
58
- }
59
- // Lógica de mudança de página anterior
60
- onPrevClick() {
61
- if (this.currentPage > 1) {
62
- this.currentPage--;
63
- this.updatePageInfo();
64
- }
65
- }
66
- // Lógica de mudança de página seguinte
67
- onNextClick() {
68
- if (this.currentPage * this.rowsPerPage < this.totalItems) {
69
- this.currentPage++;
70
- this.updatePageInfo();
71
- }
72
- }
73
- // Lógica de troca de número de linhas por página
74
- onRowsChange(event) {
75
- const newRowsPerPage = parseInt(event.target.value, 10);
76
- this.rowsPerPage = newRowsPerPage;
77
- this.currentPage = 1; // ao mudar, volta para página 1
78
- this.updatePageInfo();
79
- }
80
- // Atualiza o texto "1-10 of 15" e habilita/desabilita botões
81
- updatePageInfo() {
82
- const start = (this.currentPage - 1) * this.rowsPerPage + 1;
83
- const end = Math.min(this.currentPage * this.rowsPerPage, this.totalItems);
84
- // Exemplo: "1-10 of 15"
85
- this.pageInfoText.innerText = `${start}-${end} of ${this.totalItems}`;
86
- // Habilitar/desabilitar botões
87
- if (this.currentPage === 1) {
88
- this.prevButton.setAttribute("disabled", "true");
89
- }
90
- else {
91
- this.prevButton.removeAttribute("disabled");
92
- }
93
- if (this.currentPage * this.rowsPerPage >= this.totalItems) {
94
- this.nextButton.setAttribute("disabled", "true");
95
- }
96
- else {
97
- this.nextButton.removeAttribute("disabled");
98
- }
99
- }
100
- }
101
- TypeComposer.defineElement(TablePagination.TAG, TablePagination);
102
- export class TablePanel extends Component {
103
- static TAG = "tc-table-panel";
104
- table = new TableElement();
105
- #pagination;
106
- constructor(props) {
107
- super({ ...props });
108
- this.addClassName("table-panel");
109
- if (props?.stickyHeader) {
110
- this.addClassName("sticky-header");
111
- }
112
- this.table = this.appendChild(new TableElement(props?.tableProps));
113
- if (props?.pagination) {
114
- this.#pagination = new TablePagination(props?.paginationProps);
115
- this.#pagination.maxItems(this.table.values.length);
116
- this.appendChild(this.#pagination);
117
- this.table.onUpdateValues = (values) => {
118
- this.#pagination?.maxItems(values.length);
119
- };
120
- }
121
- }
122
- get pagination() {
123
- return this.#pagination;
124
- }
125
- }
126
- TypeComposer.defineElement(TablePanel.TAG, TablePanel);
127
- //# sourceMappingURL=TablePanel.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TablePanel.js","sourceRoot":"","sources":["../../../src/core/components/TablePanel.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EACT,UAAU,EACV,aAAa,EACb,aAAa,EACb,YAAY,EAEZ,YAAY,EACZ,WAAW,GACZ,MAAM,OAAO,CAAC;AAGf,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAC5C,MAAM,CAAU,GAAG,GAAW,qBAAqB,CAAC;IACpD,gDAAgD;IACxC,UAAU,GAAW,EAAE,CAAC;IAEhC,iBAAiB;IACT,WAAW,GAAW,CAAC,CAAC;IACxB,WAAW,GAAW,EAAE,CAAC;IAEjC,+BAA+B;IACv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M,CAAC,MAAM,CAAC,CAAC;YACpD,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YACnC,IAAI,CAAC,KAAK,CAAC,cAAc,GAAG,CAAC,MAAM,EAAE,EAAE;gBACrC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAC5C,CAAC,CAAA;QACH,CAAC;IACH,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;;AAIH,YAAY,CAAC,aAAa,CAAC,UAAU,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC"}
@@ -1,24 +0,0 @@
1
- import { Component } from "../";
2
- import { ElementProps } from "../styles";
3
- export interface VirtualScrollProps extends ElementProps {
4
- items: any[];
5
- renderItem: (item: any, index: number) => HTMLElement;
6
- itemHeight?: number;
7
- buffer?: number;
8
- }
9
- export declare class VirtualScroll extends Component {
10
- #private;
11
- private items;
12
- private renderItem;
13
- private itemHeight;
14
- private buffer;
15
- private heights;
16
- private lazyLoadEnd;
17
- chunkSize: number;
18
- constructor(props: VirtualScrollProps);
19
- private insertChunk;
20
- private check;
21
- get innerContainer(): HTMLElement;
22
- private onScroll;
23
- private renderVisibleItems;
24
- }
@@ -1,92 +0,0 @@
1
- import { Component, DivElement, LazyLoading } from "../";
2
- export class VirtualScroll extends Component {
3
- items;
4
- renderItem;
5
- itemHeight;
6
- buffer;
7
- heights = [];
8
- lazyLoadEnd;
9
- #innerContainer;
10
- chunkSize = 50;
11
- constructor(props) {
12
- super({ ...props, style: { overflowY: "auto", position: "relative", ...props.style }, });
13
- this.items = props.items;
14
- this.renderItem = props.renderItem;
15
- this.itemHeight = props.itemHeight ?? 50;
16
- this.buffer = props.buffer ?? 5;
17
- this.#innerContainer = new DivElement();
18
- //this.#innerContainer.style.position = "relative";
19
- //this.#innerContainer.style.height = `${this.items.length * this.itemHeight}px`;
20
- this.appendChild(this.#innerContainer);
21
- //this.addEventListener("scroll", this.onScroll.bind(this));
22
- this.addEventListener("onConnected", this.renderVisibleItems.bind(this));
23
- this.insertChunk(0, Math.min(this.items.length, this.chunkSize));
24
- }
25
- insertChunk(startIndex, endIndex) {
26
- const fragment = document.createDocumentFragment();
27
- for (let i = startIndex; i < endIndex; i++) {
28
- const item = this.renderItem(this.items[i], i);
29
- fragment.appendChild(item);
30
- }
31
- this.#innerContainer.appendChild(fragment);
32
- setTimeout(() => {
33
- this.check();
34
- }, 0);
35
- //this.lazyLoadEnd = new LazyLoading({
36
- // minHeight: heightMedia,
37
- // height: heightMedia,
38
- // onintersect: () => {
39
- // this.insertChunk(endIndex, Math.min(this.items.length, endIndex + this.chunkSize));
40
- // }
41
- //});
42
- //this.#innerContainer.append(this.lazyLoadEnd);
43
- }
44
- check() {
45
- let i = 0;
46
- const heights = [];
47
- for (const child of Array.from(this.#innerContainer.children)) {
48
- // @ts-ignore
49
- heights[i++] = child.clientHeight || child.offsetHeight;
50
- }
51
- const heightMedia = heights.filter(Boolean).reduce((a, b) => a + b, 0) / heights.length;
52
- // criar um array com a media de altura dos elementos
53
- const sobra = new Array(this.items.length - i).fill(heightMedia);
54
- this.heights = heights.concat(sobra);
55
- const height = (heightMedia * sobra.length) + "px";
56
- this.lazyLoadEnd = new LazyLoading({
57
- style: { minHeight: height, height: height },
58
- onintersect: (isIntersecting) => {
59
- if (isIntersecting) {
60
- this.insertChunk(i, Math.min(this.items.length, 5));
61
- }
62
- //this.insertChunk(endIndex, Math.min(this.items.length, endIndex + this.chunkSize));
63
- }
64
- });
65
- this.#innerContainer.append(this.lazyLoadEnd);
66
- }
67
- get innerContainer() {
68
- return this.#innerContainer;
69
- }
70
- onScroll() {
71
- //this.renderVisibleItems();
72
- }
73
- renderVisibleItems() {
74
- //const scrollTop = this.scrollTop;
75
- //const containerHeight = this.clientHeight;
76
- //const startIndex = Math.floor(scrollTop / this.itemHeight) - this.buffer;
77
- //const endIndex = Math.ceil((scrollTop + containerHeight) / this.itemHeight) + this.buffer;
78
- //const clampedStartIndex = Math.max(0, startIndex);
79
- //const clampedEndIndex = Math.min(this.items.length, endIndex);
80
- //this.#innerContainer.innerHTML = "";
81
- //for (let i = clampedStartIndex; i < clampedEndIndex; i++) {
82
- // const item = this.items[i];
83
- // const element = this.renderItem(item, i);
84
- // element.style.position = "absolute";
85
- // element.style.top = `${i * this.itemHeight}px`;
86
- // element.style.width = "100%";
87
- // this.#innerContainer.appendChild(element);
88
- //}
89
- }
90
- }
91
- TypeComposer.defineElement("virtual-scroll", VirtualScroll);
92
- //# sourceMappingURL=VirtualScroll%20copy%202.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"VirtualScroll copy 2.js","sourceRoot":"","sources":["../../../src/core/components/VirtualScroll copy 2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC;AAUzD,MAAM,OAAO,aAAc,SAAQ,SAAS;IAClC,KAAK,CAAQ;IACb,UAAU,CAA4C;IACtD,UAAU,CAAqB;IAC/B,MAAM,CAAS;IACf,OAAO,GAAa,EAAE,CAAC;IACvB,WAAW,CAAc;IACjC,eAAe,CAAc;IAC7B,SAAS,GAAW,EAAE,CAAC;IAEvB,YAAY,KAAyB;QACnC,KAAK,CAAC,EAAE,GAAG,KAAK,EAAG,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC1F,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QACzB,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC;QACnC,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,IAAI,EAAE,CAAC;QACzC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC;QAChC,IAAI,CAAC,eAAe,GAAG,IAAI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oD;QACpD,gEAAgE;QAChE,sCAAsC;QACtC,6DAA6D;QAC7D,+BAA+B;QAC/B,6CAA6C;QAC7C,wCAAwC;QACxC,mDAAmD;QACnD,iCAAiC;QACjC,8CAA8C;QAC9C,GAAG;IACL,CAAC;CACF;AAED,YAAY,CAAC,aAAa,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAC"}
@@ -1,124 +0,0 @@
1
- import { refBoolean, RefNumber, refNumber, refString, RefString, RefBoolean, RefMap, RefList, refMap, refList, RefState } from ".";
2
- import { RefSet, refSet } from "./RefSet";
3
- type refObject<T> = {
4
- [K in keyof T]: T[K] extends string | String ? refString : T[K] extends number | Number ? refNumber : T[K] extends boolean | Boolean ? refBoolean : T[K] extends Array<infer U> ? refList<U> : T[K] extends Map<infer MK, infer MV> ? refMap<MK, MV> : T[K] extends Set<infer SU> ? refSet<SU> : T[K] extends object ? refObject<T[K]> : T[K];
5
- };
6
- /**
7
- * Represents a reactive reference object that holds a value of type T,
8
- * allowing observers to subscribe to changes in that value.
9
- */
10
- interface RefObject<T> {
11
- readonly id: string;
12
- /**
13
- * The internal reference to another RefObject instance (if applicable).
14
- */
15
- value: refObject<T>;
16
- /**
17
- * Subscribes a function to be notified whenever the value changes.
18
- * The subscriber will immediately receive the current value.
19
- *
20
- * @param target - A function that will be called with the new value.
21
- * @returns true if the subscription was successful, false otherwise.
22
- */
23
- subscribe(target: (value: T, oldValue: T) => void): boolean;
24
- /**
25
- * Subscribes a function to be notified on value change, with an optional unsubscribe callback.
26
- *
27
- * @param target - A function that will be called with the new value.
28
- * @param onUnsubscribe - A callback that will be called when unsubscribed.
29
- * @returns true if the subscription was successful, false otherwise.
30
- */
31
- subscribe(target: (value: T, oldValue: T) => void, onUnsubscribe: Function): boolean;
32
- /**
33
- * Subscribes a property of an object to receive updates when the value changes.
34
- * The property will immediately be set to the current value.
35
- *
36
- * @param target - The target object to bind the value to.
37
- * @param propertyName - The name of the property to update on value change.
38
- * @returns true if the subscription was successful, false otherwise.
39
- */
40
- subscribe(target: object, propertyName: string | symbol): boolean;
41
- /**
42
- * Subscribes a property of an object with an optional unsubscribe callback.
43
- * The property will immediately be set to the current value.
44
- *
45
- * @param target - The target object to bind the value to.
46
- * @param propertyName - The name of the property to update.
47
- * @param onUnsubscribe - A callback that will be called when unsubscribed.
48
- * @returns true if the subscription was successful, false otherwise.
49
- */
50
- subscribe(target: object, propertyName: string | symbol, onUnsubscribe: Function): boolean;
51
- /**
52
- * Overloaded generic subscribe method that supports both function and object property subscriptions.
53
- * In all cases, the current value will be emitted immediately upon subscription.
54
- */
55
- subscribe(target: object | ((args: T) => void), propertyName: string | symbol | Function, onUnsubscribe?: Function): boolean;
56
- /**
57
- * Subscribes to value changes without immediately emitting the current value.
58
- * Use this to listen only for future changes.
59
- *
60
- * @param target - A function to be called on future value changes.
61
- * @returns true if the listener was successfully registered, false otherwise.
62
- */
63
- listen(target: (value: T, oldValue: T) => void): boolean;
64
- /**
65
- * Subscribes to value changes without emitting the current value,
66
- * with an optional unsubscribe callback.
67
- *
68
- * @param target - A function to be called on future value changes.
69
- * @param onUnsubscribe - A callback that will be triggered on unsubscription.
70
- * @returns true if the listener was successfully registered, false otherwise.
71
- */
72
- listen(target: (arg: T, oldValue: T) => void, onUnsubscribe?: Function): boolean;
73
- /**
74
- * Unsubscribes a previously registered function subscriber.
75
- *
76
- * @param target - The function that was subscribed.
77
- * @returns true if unsubscribed successfully, false otherwise.
78
- */
79
- unsubscribe(target: (args: T) => void): boolean;
80
- /**
81
- * Unsubscribes a previously registered object property subscriber.
82
- *
83
- * @param target - The target object.
84
- * @param propertyName - The name of the property that was bound to value changes.
85
- * @returns true if unsubscribed successfully, false otherwise.
86
- */
87
- unsubscribe(target: object, propertyName: string | symbol): boolean;
88
- /**
89
- * General unsubscribe method supporting both function and object property unsubscriptions.
90
- */
91
- unsubscribe(target: object | ((args: T) => void), propertyName: string | symbol): boolean;
92
- /**
93
- * Returns a string representation of the current value.
94
- */
95
- toString(): string;
96
- /**
97
- * Serializes the current value to JSON.
98
- */
99
- toJSON(): DynamicJSON<T>;
100
- /**
101
- * Returns the raw value of the RefObject.
102
- */
103
- valueOf(): T;
104
- /**
105
- * A unique key identifying this reference object.
106
- */
107
- readonly refKey: string;
108
- /**
109
- * Allows iteration over the reference value.
110
- */
111
- [Symbol.iterator](): Iterator<T>;
112
- }
113
- type DynamicJSON<T> = T extends object ? T : {
114
- value: T;
115
- };
116
- export type DynamicRef<T> = T extends string | String ? RefString : T extends number | Number ? RefNumber : T extends boolean | Boolean ? RefBoolean : T extends Array<infer U> ? RefList<U> : T extends Set<infer U> ? RefSet<U> : T extends Map<infer K, infer V> ? RefMap<K, V> : T extends object ? RefObject<T> : never;
117
- export declare function ref<T = any>(value?: T, refKey?: string): DynamicRef<T>;
118
- export type ref<T = any> = DynamicRef<T>;
119
- export type refType = RefString | RefNumber | RefBoolean | RefList<any> | RefSet<any> | RefMap<any, any> | RefObject<any> | RefState<any>;
120
- export declare const Interface: {
121
- empty: <T extends Record<string, any>>() => T;
122
- };
123
- export type Interface = typeof Interface;
124
- export {};
@@ -1,271 +0,0 @@
1
- import { RefNumber, RefString, RefBoolean, RefMap, RefList, Ref, RefState } from ".";
2
- import { RefContainer } from "./RefContainer";
3
- import { RefSet } from "./RefSet";
4
- class RefObjectContainer extends RefContainer {
5
- refKey;
6
- root;
7
- instance = { value: null };
8
- constructor(value, refKey, root) {
9
- super(value, root);
10
- this.refKey = refKey;
11
- this.root = root;
12
- this.value = createObservador(value, this);
13
- // if (isApplyProxy(value)) {
14
- // RefObjectContainer.createObject.bind(this)(this.value, value, this);
15
- // }
16
- // else
17
- // this.value = value;
18
- }
19
- valueOf() {
20
- return this.instance.value;
21
- }
22
- static create;
23
- static createObject(proxy, value, container) {
24
- if (Object.getPrototypeOf(proxy) === Object.prototype) {
25
- for (const key in value) {
26
- try {
27
- if (Object.getOwnPropertyDescriptor(proxy, key)?.writable === false
28
- || Object.getOwnPropertyDescriptor(proxy, key)?.get
29
- || Object.getOwnPropertyDescriptor(proxy, key)?.set) {
30
- continue;
31
- }
32
- if (value[key] === undefined || value[key] === null) {
33
- proxy[key] = value[key];
34
- continue;
35
- }
36
- const refKey = container.refKey && `${container.refKey}:${key}`;
37
- if (value[key] instanceof Array) {
38
- // @ts-ignore
39
- proxy[key] = new RefList(value[key], refKey);
40
- }
41
- else if (value[key] instanceof Set) {
42
- // @ts-ignore
43
- proxy[key] = new RefSet(value[key], refKey);
44
- }
45
- else if (value[key] instanceof Map) {
46
- // @ts-ignore
47
- proxy[key] = new RefMap(value[key], refKey);
48
- }
49
- else if (typeof value[key] === "string" || value[key] instanceof String) {
50
- // @ts-ignore
51
- proxy[key] = new RefString(value[key].valueOf(), refKey);
52
- }
53
- else if (typeof value[key] === "number" || value[key] instanceof Number) {
54
- // @ts-ignore
55
- proxy[key] = new RefNumber(value[key].valueOf(), refKey);
56
- }
57
- else if (typeof value[key] === "boolean" || value[key] instanceof Boolean) {
58
- // @ts-ignore
59
- proxy[key] = new RefBoolean(value[key].valueOf(), refKey);
60
- }
61
- else if (value[key] instanceof Element) {
62
- //proxy[key] =
63
- }
64
- else if (value[key] instanceof Object) {
65
- if (Object.getPrototypeOf(proxy) === Object.prototype) {
66
- const con = new RefObjectContainer(value[key], refKey, (container["root"] || this));
67
- proxy[key] = con.value;
68
- }
69
- else
70
- proxy[key] = value[key];
71
- }
72
- if (proxy[key] instanceof ref) {
73
- // @ts-ignore
74
- proxy[key]["container"].root = container.root || this;
75
- }
76
- }
77
- catch (e) {
78
- }
79
- }
80
- }
81
- }
82
- static applyObject(proxy, value, container) {
83
- const keysOld = Object.keys(proxy);
84
- const keys = Object.keys(value);
85
- const keysRemove = keysOld.filter((k) => !keys.includes(k));
86
- const keysUpdate = keys.filter((k) => keysOld.includes(k));
87
- const keysNew = keys.filter((k) => !keysOld.includes(k));
88
- for (const key of keysRemove) {
89
- if (!keys.includes(key)) {
90
- // @ts-ignore
91
- delete proxy[key];
92
- }
93
- }
94
- for (const key of keysUpdate) {
95
- // @ts-ignore
96
- if (proxy[key] instanceof ref) {
97
- // @ts-ignore
98
- proxy[key].emit(key, value[key]);
99
- }
100
- // @ts-ignore
101
- else if (!(proxy[key] instanceof Element) && proxy[key] instanceof Object) {
102
- // @ts-ignore
103
- RefObjectContainer.applyObject.bind(this)(proxy[key], value[key], container);
104
- }
105
- }
106
- if (keysNew.length === 0)
107
- return;
108
- const newObject = {};
109
- for (const key of keysNew) {
110
- // @ts-ignore
111
- newObject[key] = value[key];
112
- }
113
- RefObjectContainer.createObject.bind(this)(proxy, newObject, container);
114
- }
115
- emitAll(propertyName, value) {
116
- super.emitAll(propertyName, value, value);
117
- }
118
- }
119
- // @ts-ignore
120
- function applyProxy(target, key, value, receiver, container) {
121
- if (target[key] instanceof ref) {
122
- // @ts-ignore
123
- target[key].emit(key, value);
124
- }
125
- else if (!(target[key] instanceof Element) && target[key] instanceof Object) {
126
- if (Object.getPrototypeOf(target[key]) === Object.prototype)
127
- RefObjectContainer.applyObject(target[key], value, container);
128
- }
129
- else if (value !== undefined && value !== null) {
130
- RefObjectContainer.createObject(target, { [key]: value }, container);
131
- }
132
- else
133
- Reflect.set(target, key, value, receiver);
134
- return receiver;
135
- }
136
- function isApplyProxy(value) {
137
- if (!value)
138
- return false;
139
- if (typeof value !== "object")
140
- return true;
141
- return (Object.getPrototypeOf(value) === Object.prototype || Array.isArray(value)
142
- || value instanceof Map || value instanceof Set || value instanceof Number || value instanceof Boolean || value instanceof String);
143
- }
144
- function createObservador(obj, container) {
145
- const refObject = new Proxy(obj, {
146
- // @ts-ignore
147
- get(target, key, receiver) {
148
- if (key == "toString")
149
- return JSON.stringify(obj);
150
- if (key == "toJSON")
151
- return () => {
152
- return JSON.parse(JSON.stringify(obj));
153
- };
154
- if (key == "valueOf")
155
- return JSON.parse(JSON.stringify(obj));
156
- return Reflect.get(target, key, receiver);
157
- },
158
- // @ts-ignore
159
- set(target, key, value, receiver) {
160
- if (value && value instanceof ref)
161
- value = value?.valueOf() || value;
162
- if (isApplyProxy(value))
163
- receiver = applyProxy(target, key, value, receiver, container);
164
- else {
165
- receiver = Reflect.set(target, key, value, receiver);
166
- }
167
- container.emitAll(key, value);
168
- return receiver;
169
- },
170
- });
171
- container.value = refObject;
172
- return refObject;
173
- }
174
- export function ref(value, refKey) {
175
- if (value === undefined || value === null)
176
- throw new Error("ref: value cannot be null or undefined");
177
- value = deepCopy(value);
178
- if (typeof value === "string" || value instanceof String) {
179
- return new RefString(value.valueOf(), refKey);
180
- }
181
- else if (typeof value === "number" || value instanceof Number) {
182
- return new RefNumber(value.valueOf(), refKey);
183
- }
184
- else if (typeof value === "boolean" || value instanceof Boolean) {
185
- return new RefBoolean(value.valueOf(), refKey);
186
- }
187
- else if (value instanceof Array) {
188
- return new RefList(value, refKey);
189
- }
190
- else if (value instanceof Set) {
191
- return new RefSet(value, refKey);
192
- }
193
- else if (value instanceof Map) {
194
- return new RefMap(value, refKey);
195
- }
196
- const container = new RefObjectContainer(value, refKey || "");
197
- const instance = {
198
- value: container.value,
199
- subscribe: container.subscribe.bind(container),
200
- listen: container.listen.bind(container),
201
- unsubscribe: container.unsubscribe.bind(container),
202
- toString: container.toString.bind(container),
203
- toJSON: container.toJSON.bind(container),
204
- valueOf: container.valueOf.bind(container),
205
- id: container.id
206
- };
207
- container["instance"] = instance;
208
- Object.defineProperty(instance, Symbol.iterator, {
209
- value: function* () {
210
- for (const key in instance.value) {
211
- yield instance.value[key]?.valueOf() || instance.value[key];
212
- }
213
- },
214
- });
215
- Object.defineProperty(instance, "value", {
216
- get() {
217
- return container.value;
218
- },
219
- set(value) {
220
- RefObjectContainer.applyObject(container.value, value, container);
221
- container.emitAll("value", value);
222
- },
223
- });
224
- Object.setPrototypeOf(instance, ref.prototype);
225
- // @ts-ignore
226
- if (refKey)
227
- Ref.set(refKey, instance);
228
- return instance;
229
- }
230
- Object.defineProperty(ref, Symbol.hasInstance, {
231
- value: function (instance) {
232
- return (!!instance && typeof instance === "object" &&
233
- (instance === ref ||
234
- Object.getPrototypeOf(instance) === ref.prototype ||
235
- instance instanceof RefString ||
236
- instance instanceof RefNumber ||
237
- instance instanceof RefBoolean ||
238
- instance instanceof RefList ||
239
- instance instanceof RefSet ||
240
- instance instanceof RefMap ||
241
- instance instanceof RefState));
242
- },
243
- });
244
- // function computedTemplateStringsArray<T>(fn: TemplateStringsArray, ...values: any[]): DynamicRef<T> {
245
- // const observers: any[] = values.pop();
246
- // console.log("computed", fn, "values", values);
247
- // const r = ref(fn.reduce((acc, str, i) => {
248
- // // @ts-ignore
249
- // return acc + str + (values[i] !== undefined ? (values[i] instanceof ref) ? values[i].value : values[i] : "");
250
- // }, ""));
251
- // const func = () => {
252
- // r.value = fn.reduce((acc, str, i) => {
253
- // // @ts-ignore
254
- // return acc + str + (values[i] !== undefined ? (values[i] instanceof ref) ? values[i].value : values[i] : "");
255
- // }, "");
256
- // }
257
- // for (const item of observers) {
258
- // if (item instanceof ref) {
259
- // // @ts-ignore
260
- // item.listen(func);
261
- // }
262
- // }
263
- // // @ts-ignore
264
- // return r
265
- // }
266
- export const Interface = {
267
- empty: function () {
268
- return {};
269
- },
270
- };
271
- //# sourceMappingURL=RefObject%20copy.js.map