@vandenberghinc/volt 1.1.5 → 1.1.7

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 (287) hide show
  1. package/backend/dist/cjs/database.d.ts +41 -68
  2. package/backend/dist/cjs/database.js +127 -76
  3. package/backend/dist/cjs/endpoint.d.ts +23 -9
  4. package/backend/dist/cjs/endpoint.js +98 -21
  5. package/backend/dist/cjs/frontend.d.ts +0 -2
  6. package/backend/dist/cjs/frontend.js +9 -9
  7. package/backend/dist/cjs/image_endpoint.d.ts +3 -1
  8. package/backend/dist/cjs/image_endpoint.js +2 -1
  9. package/backend/dist/cjs/payments/paddle.js +10 -2
  10. package/backend/dist/cjs/plugins/css.d.ts +6 -5
  11. package/backend/dist/cjs/plugins/css.js +32 -7
  12. package/backend/dist/cjs/plugins/ts/compiler.d.ts +6 -1
  13. package/backend/dist/cjs/plugins/ts/compiler.js +26 -2
  14. package/backend/dist/cjs/plugins/ts/preprocessing.js +5 -3
  15. package/backend/dist/cjs/server.d.ts +7 -13
  16. package/backend/dist/cjs/server.js +184 -303
  17. package/backend/dist/cjs/status.d.ts +1 -0
  18. package/backend/dist/cjs/status.js +2 -1
  19. package/backend/dist/cjs/stream.d.ts +5 -3
  20. package/backend/dist/cjs/stream.js +13 -4
  21. package/backend/dist/cjs/users.d.ts +1 -1
  22. package/backend/dist/cjs/users.js +87 -72
  23. package/backend/dist/cjs/utils.d.ts +17 -9
  24. package/backend/dist/cjs/utils.js +22 -64
  25. package/backend/dist/cjs/view.d.ts +2 -2
  26. package/backend/dist/cjs/view.js +38 -40
  27. package/backend/dist/cjs/volt.d.ts +3 -2
  28. package/backend/dist/cjs/volt.js +2 -2
  29. package/backend/dist/css/volt.css +5 -0
  30. package/backend/dist/esm/database.d.ts +41 -68
  31. package/backend/dist/esm/database.js +127 -76
  32. package/backend/dist/esm/endpoint.d.ts +23 -9
  33. package/backend/dist/esm/endpoint.js +99 -22
  34. package/backend/dist/esm/frontend.d.ts +0 -2
  35. package/backend/dist/esm/frontend.js +9 -9
  36. package/backend/dist/esm/image_endpoint.d.ts +3 -1
  37. package/backend/dist/esm/image_endpoint.js +2 -1
  38. package/backend/dist/esm/payments/paddle.js +11 -3
  39. package/backend/dist/esm/plugins/css.d.ts +6 -5
  40. package/backend/dist/esm/plugins/css.js +32 -6
  41. package/backend/dist/esm/plugins/ts/compiler.d.ts +6 -1
  42. package/backend/dist/esm/plugins/ts/compiler.js +26 -2
  43. package/backend/dist/esm/plugins/ts/preprocessing.js +5 -3
  44. package/backend/dist/esm/server.d.ts +7 -13
  45. package/backend/dist/esm/server.js +182 -301
  46. package/backend/dist/esm/status.d.ts +1 -0
  47. package/backend/dist/esm/status.js +1 -0
  48. package/backend/dist/esm/stream.d.ts +5 -3
  49. package/backend/dist/esm/stream.js +13 -4
  50. package/backend/dist/esm/users.d.ts +1 -1
  51. package/backend/dist/esm/users.js +87 -72
  52. package/backend/dist/esm/utils.d.ts +17 -9
  53. package/backend/dist/esm/utils.js +21 -62
  54. package/backend/dist/esm/view.d.ts +2 -2
  55. package/backend/dist/esm/view.js +38 -40
  56. package/backend/dist/esm/volt.d.ts +3 -2
  57. package/backend/dist/esm/volt.js +2 -1
  58. package/backend/dist/esm-dev/blacklist.js +1 -1
  59. package/backend/dist/esm-dev/cli.js +2 -2
  60. package/backend/dist/esm-dev/database.d.ts +41 -68
  61. package/backend/dist/esm-dev/database.js +128 -77
  62. package/backend/dist/esm-dev/endpoint.d.ts +23 -9
  63. package/backend/dist/esm-dev/endpoint.js +100 -23
  64. package/backend/dist/esm-dev/file_watcher.js +1 -1
  65. package/backend/dist/esm-dev/frontend.d.ts +0 -2
  66. package/backend/dist/esm-dev/frontend.js +9 -9
  67. package/backend/dist/esm-dev/image_endpoint.d.ts +3 -1
  68. package/backend/dist/esm-dev/image_endpoint.js +2 -1
  69. package/backend/dist/esm-dev/logger.js +1 -1
  70. package/backend/dist/esm-dev/payments/paddle.js +12 -4
  71. package/backend/dist/esm-dev/plugins/css.d.ts +6 -5
  72. package/backend/dist/esm-dev/plugins/css.js +33 -7
  73. package/backend/dist/esm-dev/plugins/ts/compiler.d.ts +6 -1
  74. package/backend/dist/esm-dev/plugins/ts/compiler.js +27 -3
  75. package/backend/dist/esm-dev/plugins/ts/preprocessing.js +7 -5
  76. package/backend/dist/esm-dev/rate_limit.js +1 -1
  77. package/backend/dist/esm-dev/server.d.ts +7 -13
  78. package/backend/dist/esm-dev/server.js +184 -303
  79. package/backend/dist/esm-dev/status.d.ts +1 -0
  80. package/backend/dist/esm-dev/status.js +1 -0
  81. package/backend/dist/esm-dev/stream.d.ts +5 -3
  82. package/backend/dist/esm-dev/stream.js +13 -4
  83. package/backend/dist/esm-dev/users.d.ts +1 -1
  84. package/backend/dist/esm-dev/users.js +88 -73
  85. package/backend/dist/esm-dev/utils.d.ts +17 -9
  86. package/backend/dist/esm-dev/utils.js +22 -63
  87. package/backend/dist/esm-dev/view.d.ts +2 -2
  88. package/backend/dist/esm-dev/view.js +39 -41
  89. package/backend/dist/esm-dev/volt.d.ts +3 -2
  90. package/backend/dist/esm-dev/volt.js +2 -1
  91. package/backend/src/database.ts +163 -152
  92. package/backend/src/endpoint.ts +123 -31
  93. package/backend/src/frontend.ts +9 -8
  94. package/backend/src/image_endpoint.ts +4 -0
  95. package/backend/src/payments/paddle.ts +11 -3
  96. package/backend/src/plugins/css.ts +36 -8
  97. package/backend/src/plugins/ts/compiler.ts +37 -1
  98. package/backend/src/plugins/ts/preprocessing.ts +5 -3
  99. package/backend/src/server.ts +167 -306
  100. package/backend/src/status.ts +1 -0
  101. package/backend/src/stream.ts +28 -8
  102. package/backend/src/users.ts +87 -72
  103. package/backend/src/utils.ts +58 -25
  104. package/backend/src/view.ts +30 -28
  105. package/backend/src/{volt.js → volt.ts} +2 -1
  106. package/backend/tsconfig.cjs.json +3 -3
  107. package/backend/tsconfig.esm.json +3 -3
  108. package/frontend/dist/elements/base.d.ts +397 -415
  109. package/frontend/dist/elements/base.js +565 -328
  110. package/frontend/dist/elements/module.d.ts +26 -12
  111. package/frontend/dist/elements/module.js +69 -32
  112. package/frontend/dist/elements/register_element.d.ts +3 -0
  113. package/frontend/dist/elements/register_element.js +22 -0
  114. package/frontend/dist/modules/auth.d.ts +1 -0
  115. package/frontend/dist/modules/auth.js +6 -5
  116. package/frontend/dist/modules/color.d.ts +159 -0
  117. package/frontend/dist/modules/color.js +315 -0
  118. package/frontend/dist/modules/colors.d.ts +1 -26
  119. package/frontend/dist/modules/colors.js +417 -338
  120. package/frontend/dist/modules/cookies.d.ts +1 -0
  121. package/frontend/dist/modules/cookies.js +1 -0
  122. package/frontend/dist/modules/events.d.ts +1 -0
  123. package/frontend/dist/modules/events.js +1 -0
  124. package/frontend/dist/modules/google.d.ts +1 -0
  125. package/frontend/dist/modules/google.js +1 -0
  126. package/frontend/dist/modules/meta.d.ts +1 -0
  127. package/frontend/dist/modules/meta.js +1 -0
  128. package/frontend/dist/modules/mutex.d.ts +1 -2
  129. package/frontend/dist/modules/mutex.js +3 -4
  130. package/frontend/dist/modules/paddle.d.ts +1 -0
  131. package/frontend/dist/modules/paddle.js +14 -13
  132. package/frontend/dist/modules/scheme.d.ts +1 -0
  133. package/frontend/dist/modules/scheme.js +4 -2
  134. package/frontend/dist/modules/statics.d.ts +1 -0
  135. package/frontend/dist/modules/statics.js +1 -0
  136. package/frontend/dist/modules/support.d.ts +1 -0
  137. package/frontend/dist/modules/support.js +3 -2
  138. package/frontend/dist/modules/theme.d.ts +56 -0
  139. package/frontend/dist/{ui → modules}/theme.js +186 -75
  140. package/frontend/dist/modules/themes.d.ts +1 -1
  141. package/frontend/dist/modules/themes.js +1 -0
  142. package/frontend/dist/modules/user.d.ts +1 -0
  143. package/frontend/dist/modules/user.js +11 -10
  144. package/frontend/dist/modules/utils.d.ts +23 -2
  145. package/frontend/dist/modules/utils.js +93 -1
  146. package/frontend/dist/types/gradient.js +4 -0
  147. package/frontend/dist/ui/border_button.d.ts +0 -25
  148. package/frontend/dist/ui/border_button.js +50 -51
  149. package/frontend/dist/ui/button.d.ts +0 -21
  150. package/frontend/dist/ui/button.js +41 -46
  151. package/frontend/dist/ui/canvas.js +15 -15
  152. package/frontend/dist/ui/checkbox.d.ts +3 -17
  153. package/frontend/dist/ui/checkbox.js +36 -30
  154. package/frontend/dist/ui/code.d.ts +15 -82
  155. package/frontend/dist/ui/code.js +150 -125
  156. package/frontend/dist/ui/color.d.ts +0 -1
  157. package/frontend/dist/ui/color.js +1 -1
  158. package/frontend/dist/ui/context_menu.d.ts +4 -2
  159. package/frontend/dist/ui/context_menu.js +16 -17
  160. package/frontend/dist/ui/css.js +2 -0
  161. package/frontend/dist/ui/divider.d.ts +0 -7
  162. package/frontend/dist/ui/divider.js +21 -25
  163. package/frontend/dist/ui/dropdown.d.ts +13 -7
  164. package/frontend/dist/ui/dropdown.js +65 -30
  165. package/frontend/dist/ui/for_each.d.ts +0 -5
  166. package/frontend/dist/ui/for_each.js +17 -22
  167. package/frontend/dist/ui/form.d.ts +17 -12
  168. package/frontend/dist/ui/form.js +21 -18
  169. package/frontend/dist/ui/frame_modes.d.ts +9 -12
  170. package/frontend/dist/ui/frame_modes.js +8 -10
  171. package/frontend/dist/ui/google_map.d.ts +0 -11
  172. package/frontend/dist/ui/google_map.js +23 -28
  173. package/frontend/dist/ui/gradient.d.ts +0 -5
  174. package/frontend/dist/ui/gradient.js +17 -22
  175. package/frontend/dist/ui/image.d.ts +27 -58
  176. package/frontend/dist/ui/image.js +99 -93
  177. package/frontend/dist/ui/input.d.ts +20 -97
  178. package/frontend/dist/ui/input.js +192 -170
  179. package/frontend/dist/ui/link.d.ts +0 -18
  180. package/frontend/dist/ui/link.js +42 -48
  181. package/frontend/dist/ui/list.js +36 -37
  182. package/frontend/dist/ui/loader_button.d.ts +4 -19
  183. package/frontend/dist/ui/loader_button.js +35 -37
  184. package/frontend/dist/ui/loaders.d.ts +0 -8
  185. package/frontend/dist/ui/loaders.js +20 -25
  186. package/frontend/dist/ui/popup.d.ts +11 -8
  187. package/frontend/dist/ui/popup.js +183 -24
  188. package/frontend/dist/ui/pseudo.d.ts +3 -3
  189. package/frontend/dist/ui/pseudo.js +14 -17
  190. package/frontend/dist/ui/scroller.d.ts +10 -48
  191. package/frontend/dist/ui/scroller.js +306 -300
  192. package/frontend/dist/ui/slider.d.ts +9 -3
  193. package/frontend/dist/ui/slider.js +31 -17
  194. package/frontend/dist/ui/spacer.d.ts +0 -9
  195. package/frontend/dist/ui/spacer.js +21 -26
  196. package/frontend/dist/ui/span.js +13 -15
  197. package/frontend/dist/ui/stack.d.ts +14 -75
  198. package/frontend/dist/ui/stack.js +166 -169
  199. package/frontend/dist/ui/steps.d.ts +10 -23
  200. package/frontend/dist/ui/steps.js +47 -34
  201. package/frontend/dist/ui/style.d.ts +4 -3
  202. package/frontend/dist/ui/style.js +13 -18
  203. package/frontend/dist/ui/switch.d.ts +10 -4
  204. package/frontend/dist/ui/switch.js +24 -16
  205. package/frontend/dist/ui/table.d.ts +0 -23
  206. package/frontend/dist/ui/table.js +113 -119
  207. package/frontend/dist/ui/tabs.d.ts +3 -19
  208. package/frontend/dist/ui/tabs.js +35 -29
  209. package/frontend/dist/ui/text.d.ts +0 -8
  210. package/frontend/dist/ui/text.js +20 -25
  211. package/frontend/dist/ui/title.d.ts +0 -15
  212. package/frontend/dist/ui/title.js +39 -45
  213. package/frontend/dist/ui/ui.d.ts +0 -2
  214. package/frontend/dist/ui/ui.js +0 -2
  215. package/frontend/dist/ui/view.d.ts +3 -17
  216. package/frontend/dist/ui/view.js +27 -32
  217. package/frontend/dist/volt.d.ts +2 -1
  218. package/frontend/dist/volt.js +3 -1
  219. package/frontend/examples/dashboard/dashboard.ts +774 -0
  220. package/frontend/examples/theme/theme.ts +58 -0
  221. package/frontend/src/css/volt.css +5 -0
  222. package/frontend/src/elements/base.ts +767 -545
  223. package/frontend/src/elements/module.ts +90 -29
  224. package/frontend/src/elements/register_element.ts +24 -0
  225. package/frontend/src/modules/auth.ts +7 -6
  226. package/frontend/src/modules/color.ts +348 -0
  227. package/frontend/src/modules/colors.ts +468 -449
  228. package/frontend/src/modules/cookies.ts +1 -0
  229. package/frontend/src/modules/events.ts +1 -0
  230. package/frontend/src/modules/google.ts +1 -0
  231. package/frontend/src/modules/meta.ts +2 -1
  232. package/frontend/src/modules/mutex.ts +2 -4
  233. package/frontend/src/modules/paddle.ts +21 -20
  234. package/frontend/src/modules/scheme.ts +4 -3
  235. package/frontend/src/modules/statics.ts +2 -1
  236. package/frontend/src/modules/support.ts +3 -2
  237. package/frontend/src/modules/theme.ts +413 -0
  238. package/frontend/src/modules/themes.ts +2 -1
  239. package/frontend/src/modules/user.ts +12 -11
  240. package/frontend/src/modules/utils.ts +125 -2
  241. package/frontend/src/ui/border_button.ts +41 -37
  242. package/frontend/src/ui/button.ts +33 -32
  243. package/frontend/src/ui/canvas.ts +5 -2
  244. package/frontend/src/ui/checkbox.ts +21 -22
  245. package/frontend/src/ui/code.ts +92 -86
  246. package/frontend/src/ui/context_menu.ts +7 -5
  247. package/frontend/src/ui/css.ts +1 -1
  248. package/frontend/src/ui/divider.ts +15 -10
  249. package/frontend/src/ui/dropdown.ts +38 -21
  250. package/frontend/src/ui/for_each.ts +9 -8
  251. package/frontend/src/ui/form.ts +26 -21
  252. package/frontend/src/ui/frame_modes.ts +13 -17
  253. package/frontend/src/ui/google_map.ts +15 -13
  254. package/frontend/src/ui/gradient.ts +9 -8
  255. package/frontend/src/ui/image.ts +108 -86
  256. package/frontend/src/ui/input.ts +145 -144
  257. package/frontend/src/ui/link.ts +25 -23
  258. package/frontend/src/ui/list.ts +12 -6
  259. package/frontend/src/ui/loader_button.ts +26 -25
  260. package/frontend/src/ui/loaders.ts +12 -11
  261. package/frontend/src/ui/popup.ts +168 -14
  262. package/frontend/src/ui/pseudo.ts +5 -3
  263. package/frontend/src/ui/scroller.ts +303 -294
  264. package/frontend/src/ui/slider.ts +15 -10
  265. package/frontend/src/ui/spacer.ts +14 -11
  266. package/frontend/src/ui/span.ts +6 -2
  267. package/frontend/src/ui/stack.ts +196 -183
  268. package/frontend/src/ui/steps.ts +38 -22
  269. package/frontend/src/ui/style.ts +7 -4
  270. package/frontend/src/ui/switch.ts +16 -11
  271. package/frontend/src/ui/table.ts +42 -34
  272. package/frontend/src/ui/tabs.ts +20 -19
  273. package/frontend/src/ui/text.ts +12 -11
  274. package/frontend/src/ui/title.ts +22 -20
  275. package/frontend/src/ui/ui.ts +0 -2
  276. package/frontend/src/ui/view.ts +20 -19
  277. package/frontend/src/volt.ts +3 -1
  278. package/frontend/{compile.js → tools/compile.old.js} +2 -2
  279. package/frontend/tools/embed_scripts.js +69 -0
  280. package/frontend/tsconfig.json +26 -0
  281. package/package.json +8 -8
  282. package/frontend/dist/ui/theme.d.ts +0 -25
  283. package/frontend/exports.json +0 -1340
  284. package/frontend/src/modules/date.js +0 -535
  285. package/frontend/src/ui/color.ts +0 -117
  286. package/frontend/src/ui/theme.ts +0 -279
  287. /package/backend/src/{vinc.dev.js → vinc.dev.ts} +0 -0
@@ -4,8 +4,9 @@
4
4
  */
5
5
 
6
6
  // Imports.
7
- import { Elements, VElementTagMap } from "../elements/module.js"
7
+ import { Elements, VElementBaseSignature, VElement, VElementTagMap, AppendType } from "../elements/module.js"
8
8
  import { Utils } from "../modules/utils.js"
9
+ import { AnyElement } from "./any_element.js";
9
10
  import { Span } from "./span"
10
11
  import { VStack, VStackElement } from "./stack"
11
12
 
@@ -19,10 +20,9 @@ interface ScrollCallbackItem {
19
20
 
20
21
  // Scroller.
21
22
  // - Warning: Setting padding on element attribute "content" may cause undefined behaviour.
22
- @Elements.register
23
- export class ScrollerElement extends VElementTagMap.div {
24
-
25
- static default_style = {
23
+ @Elements.create({
24
+ name: "ScrollerElement",
25
+ default_style: {
26
26
  "position": "relative", // is required for attribute "track"
27
27
  "margin": "0px",
28
28
  "padding": "0px",
@@ -39,7 +39,9 @@ export class ScrollerElement extends VElementTagMap.div {
39
39
  "content-visibility": "auto", // improve rendering.
40
40
  // "align-content": "flex-start", // align items at start, do not stretch / space when inside HStack.
41
41
  // "align-items": "flex-start", // align items at start, do not stretch / space when inside HStack.
42
- };
42
+ },
43
+ })
44
+ export class ScrollerElement extends VElementTagMap.div {
43
45
 
44
46
  // @ts-expect-error
45
47
  public content: VStackElement;
@@ -60,7 +62,7 @@ export class ScrollerElement extends VElementTagMap.div {
60
62
  public _fadeout_timeout: any;
61
63
 
62
64
  // Constructor.
63
- constructor(...children: any[]) {
65
+ constructor(...children: AppendType[]) {
64
66
 
65
67
  // Initialize base class.
66
68
  super({
@@ -340,7 +342,7 @@ export class ScrollerElement extends VElementTagMap.div {
340
342
  }
341
343
 
342
344
  // By default append items to the content.
343
- append(...children: any): this {
345
+ append(...children: AppendType[]): this {
344
346
  this.content.append(...children);
345
347
  return this;
346
348
  }
@@ -608,287 +610,287 @@ declare module './any_element.d.ts' { interface AnyElementMap { ScrollerElement:
608
610
  @description: The elements children.
609
611
  @type: array[Node]
610
612
  */
611
- @Elements.register
612
- export class VirtualScrollerElement extends ScrollerElement {
613
-
614
- public _v_children: any[];
615
- public top_diff: number;
616
- public scroll_top_value: number;
617
- public _last_v_children: number;
618
- public visible_container: VStackElement;
619
- public height_measurer: any;
620
-
621
- // Constructor.
622
- constructor(...children: any[]) {
623
-
624
- // Initialize base class.
625
- super();
626
- this._init_derived({ derived: VirtualScrollerElement, })
627
-
628
- // Virtual children.
629
- this._v_children = [];
630
-
631
- // Attributes.
632
- this.top_diff = 0;
633
- this.scroll_top_value = 0;
634
- this._last_v_children = 0;
635
-
636
- // Append children.
637
- this.append(...children);
638
-
639
- // The visible container with the scroll dimensions and positioned children inside.
640
- this.visible_container = VStack()
641
- .position("relative")
642
- .overflow_x("visible")
643
- .overflow_y("hidden")
644
- .styles({
645
- "content-visibility": "auto",
646
- })
647
- this.content.append(this.visible_container)
648
-
649
- // The height measurer.
650
- this.height_measurer = Span()
651
- .visibility("hidden")
652
- this.content.append(this.height_measurer)
653
-
654
- // Render.
655
- this.render();
656
-
657
- // Set scroll event listener.
658
- // @todo set_scroll_top_without event wont work with this new scroll event.
659
- this.content.addEventListener("scroll", () => this.render())
660
-
661
- }
662
-
663
- // Set default since it inherits HStackElement.
664
- set_default(): this {
665
- return super.set_default(VirtualScrollerElement);
666
- }
667
-
668
- // Replace overflow.
669
- overflow(): string;
670
- overflow(value: string): this;
671
- overflow(value?: string): string | this {
672
- if (value == null) {
673
- return this.content.overflow();
674
- }
675
- this.content.overflow(value);
676
- this.visible_container.overflow_x(value.split(" ")[0]);
677
- return this;
678
- }
679
- overflow_x(): string;
680
- overflow_x(value: string): this;
681
- overflow_x(value?: string): string | this {
682
- if (value == null) {
683
- return this.content.overflow_x();
684
- }
685
- this.content.overflow_x(value);
686
- this.visible_container.overflow_x(value);
687
- return this;
688
- }
689
- // keep overflow y on this.visible_container always hidden otherwise it may mess with expanding this.content and cause an infinite scroll event.
690
-
691
- // Set remove children to content.
692
- remove_children(): this {
693
- this._v_children = [];
694
- this.visible_container.min_height(0);
695
- this.visible_container.max_height(0);
696
- this.visible_container.inner_html("");
697
- return this;
698
- }
699
-
700
- // Render the visible content.
701
- render(): this {
702
- // Do not use a clearTimeout setTimout structure cause that will cause some elements to be appended too late on a very fast sroll.
703
-
704
- // Get scroll direction.
705
- const last_scroll_top = this.scroll_top_value;
706
- this.scroll_top_value = this.content.scrollTop;
707
- const last_v_children = this._last_v_children;
708
- this._last_v_children = this._v_children.length;
709
- let scrolling_down = true;
710
- if (this.scroll_top_value > last_scroll_top) {
711
- scrolling_down = true;
712
- } else if (this.scroll_top_value < last_scroll_top) {
713
- scrolling_down = false;
714
- }
715
- // Disable forced behaviour because when height edits are made it should also be updated, but this is easily forgotten by the user.
716
- // else if (!forced && this.last_v_children == last_v_children) {
717
- // return null; // horizontal scroll.
718
- // }
719
-
720
- // Get the start and end y.
721
- const start_y = this.content.scrollTop;
722
- const end_y = start_y + this.content.offsetHeight + this.top_diff;
723
-
724
- // Iterate.
725
- let is_first = true;
726
- let is_visible = false;
727
- let total_height = 0;
728
- let visible_height = 0;
729
- this._v_children.iterate((child) => {
730
-
731
- // Child vars.
732
- const height = child.v_height !== undefined ? child.v_height : this.get_height(child);
733
- if (height == 0) {
734
- return null; // no fixed height or no height.
735
- }
736
- const child_start_y = total_height;
737
- const child_end_y = total_height + height; // Adjust as needed
738
- total_height += height;
739
-
740
- // First item.
741
- if (is_first && child_end_y >= start_y) {
742
- child.transform(`translateY(${child_start_y}px)`); // also update when still visible but height changes may have been made to an element.
743
- visible_height += height;
744
- is_first = false;
745
- is_visible = true;
746
- if (!child.rendered) {
747
- if (scrolling_down) {
748
- this.visible_container.appendChild(child);
749
- } else {
750
- this.visible_container.insertBefore(child, this.visible_container.firstChild);
751
- }
752
- child.rendered = true;
753
- }
754
- }
755
-
756
- // Last visible element.
757
- else if (is_visible && child_start_y >= end_y) {
758
- child.transform(`translateY(${child_start_y - visible_height}px)`); // also update when still visible but height changes may have been made to an element.
759
- visible_height += height;
760
- is_visible = false;
761
- if (!child.rendered) {
762
- if (scrolling_down) {
763
- this.visible_container.appendChild(child);
764
- } else {
765
- this.visible_container.insertBefore(child, this.visible_container.firstChild);
766
- }
767
- child.rendered = true;
768
- }
769
- }
770
-
771
- // Visible elements.
772
- else if (is_visible) {
773
- child.transform(`translateY(${child_start_y - visible_height}px)`); // also update when still visible but height changes may have been made to an element.
774
- visible_height += height;
775
- if (!child.rendered) {
776
- if (scrolling_down) {
777
- this.visible_container.appendChild(child);
778
- } else {
779
- this.visible_container.insertBefore(child, this.visible_container.firstChild);
780
- }
781
- child.rendered = true;
782
- }
783
- }
784
-
785
- // Invisible elements.
786
- else if (child.rendered) {
787
- child.remove();
788
- child.rendered = false;
789
- }
790
- })
791
-
792
- // Set scroll dimension.
793
- this.visible_container.min_height(total_height);
794
- this.visible_container.max_height(total_height);
795
-
796
- // Return this.
797
- return this;
798
- }
799
-
800
- // Update heights.
801
- update_heights(): this {
802
- this._v_children.iterate((child) => {
803
- child.v_height = this.get_height(child, false);
804
- })
805
- return this;
806
- }
807
-
808
- // Update height of a certain child.
809
- update_height(child: any): this {
810
- child.v_height = this.get_height(child, false);
811
- return this;
812
- }
813
-
814
- // Get the height of an element.
815
- get_height(element, fixed = true): number {
816
- let height;
817
-
818
- // Get fixed height.
819
- if (fixed) {
820
- height = parseFloat(element.style.height);
821
- if (isNaN(height)) {
822
- console.error("Every element in the virtual scroller must have a fixed height, ignoring element: " + element);
823
- element.style.display = "none";
824
- return 0;
825
- }
826
- }
827
-
828
- // Append to document and get height.
829
- // Does not require fixed heights but is slow.
830
- else {
831
- element.rendered = false; // set rendered to false because this will remove the child from this.visible_container when it was rendered.
832
- this.height_measurer.appendChild(element);
833
- height = element.offsetHeight;
834
- this.height_measurer.removeChild(element);
835
- }
836
-
837
- // Add margin.
838
- const margin_top = parseFloat(element.style.marginTop);
839
- if (!isNaN(margin_top)) {
840
- height += margin_top;
841
- }
842
- const margin_bottom = parseFloat(element.style.marginBottom);
843
- if (!isNaN(margin_bottom)) {
844
- height += margin_bottom;
845
- }
846
-
847
- // Handler.
848
- return height;
849
- }
850
-
851
- // Custom append function.
852
- append(...children: any[]): this {
853
- for (let i = 0; i < children.length; i++) {
854
- const child = children[i];
855
- if (child != null) {
856
-
857
- // VWeb element.
858
- if (child.element_type != null) {
859
- if (
860
- child.element_type == "ForEach" ||
861
- child.element_type == "If" ||
862
- child.element_type == "IfDeviceWith"
863
- ) {
864
- child.append_children_to(this);
865
- } else {
866
- this._v_children.push(child);
867
- }
868
- }
869
-
870
- // Execute function.
871
- else if (Utils.is_func(child)) {
872
- this.append(child());
873
- }
874
-
875
- // Node element.
876
- else if (child instanceof Node) {
877
- this._v_children.push(child);
878
- }
879
-
880
- // Append text.
881
- else if (Utils.is_string(child)) {
882
- this._v_children.push(document.createTextNode(child));
883
- }
884
- }
885
- }
886
- return this;
887
- }
888
- }
889
- export const VirtualScroller = Elements.wrapper(VirtualScrollerElement);
890
- export const NullVirtualScroller = Elements.create_null(VirtualScrollerElement);
891
- declare module './any_element.d.ts' { interface AnyElementMap { VirtualScrollerElement: VirtualScrollerElement }}
613
+ // @Elements.register
614
+ // export class VirtualScrollerElement extends (ScrollerElement as any as VElementBaseSignature) {
615
+
616
+ // public _v_children: any[];
617
+ // public top_diff: number;
618
+ // public scroll_top_value: number;
619
+ // public _last_v_children: number;
620
+ // public visible_container: VStackElement;
621
+ // public height_measurer: any;
622
+
623
+ // // Constructor.
624
+ // constructor(...children: AppendType[]) {
625
+
626
+ // // Initialize base class.
627
+ // super();
628
+ // this._init_derived({ derived: VirtualScrollerElement, })
629
+
630
+ // // Virtual children.
631
+ // this._v_children = [];
632
+
633
+ // // Attributes.
634
+ // this.top_diff = 0;
635
+ // this.scroll_top_value = 0;
636
+ // this._last_v_children = 0;
637
+
638
+ // // Append children.
639
+ // this.append(...children);
640
+
641
+ // // The visible container with the scroll dimensions and positioned children inside.
642
+ // this.visible_container = VStack()
643
+ // .position("relative")
644
+ // .overflow_x("visible")
645
+ // .overflow_y("hidden")
646
+ // .styles({
647
+ // "content-visibility": "auto",
648
+ // })
649
+ // this.content.append(this.visible_container)
650
+
651
+ // // The height measurer.
652
+ // this.height_measurer = Span()
653
+ // .visibility("hidden")
654
+ // this.content.append(this.height_measurer)
655
+
656
+ // // Render.
657
+ // this.render();
658
+
659
+ // // Set scroll event listener.
660
+ // // @todo set_scroll_top_without event wont work with this new scroll event.
661
+ // this.content.addEventListener("scroll", () => this.render())
662
+
663
+ // }
664
+
665
+ // // Set default since it inherits HStackElement.
666
+ // set_default(): this {
667
+ // return super.set_default(VirtualScrollerElement);
668
+ // }
669
+
670
+ // // Replace overflow.
671
+ // overflow(): string;
672
+ // overflow(value: string): this;
673
+ // overflow(value?: string): string | this {
674
+ // if (value == null) {
675
+ // return this.content.overflow();
676
+ // }
677
+ // this.content.overflow(value);
678
+ // this.visible_container.overflow_x(value.split(" ")[0]);
679
+ // return this;
680
+ // }
681
+ // overflow_x(): string;
682
+ // overflow_x(value: string): this;
683
+ // overflow_x(value?: string): string | this {
684
+ // if (value == null) {
685
+ // return this.content.overflow_x();
686
+ // }
687
+ // this.content.overflow_x(value);
688
+ // this.visible_container.overflow_x(value);
689
+ // return this;
690
+ // }
691
+ // // keep overflow y on this.visible_container always hidden otherwise it may mess with expanding this.content and cause an infinite scroll event.
692
+
693
+ // // Set remove children to content.
694
+ // remove_children(): this {
695
+ // this._v_children = [];
696
+ // this.visible_container.min_height(0);
697
+ // this.visible_container.max_height(0);
698
+ // this.visible_container.inner_html("");
699
+ // return this;
700
+ // }
701
+
702
+ // // Render the visible content.
703
+ // render(): this {
704
+ // // Do not use a clearTimeout setTimout structure cause that will cause some elements to be appended too late on a very fast sroll.
705
+
706
+ // // Get scroll direction.
707
+ // const last_scroll_top = this.scroll_top_value;
708
+ // this.scroll_top_value = this.content.scrollTop;
709
+ // const last_v_children = this._last_v_children;
710
+ // this._last_v_children = this._v_children.length;
711
+ // let scrolling_down = true;
712
+ // if (this.scroll_top_value > last_scroll_top) {
713
+ // scrolling_down = true;
714
+ // } else if (this.scroll_top_value < last_scroll_top) {
715
+ // scrolling_down = false;
716
+ // }
717
+ // // Disable forced behaviour because when height edits are made it should also be updated, but this is easily forgotten by the user.
718
+ // // else if (!forced && this.last_v_children == last_v_children) {
719
+ // // return null; // horizontal scroll.
720
+ // // }
721
+
722
+ // // Get the start and end y.
723
+ // const start_y = this.content.scrollTop;
724
+ // const end_y = start_y + this.content.offsetHeight + this.top_diff;
725
+
726
+ // // Iterate.
727
+ // let is_first = true;
728
+ // let is_visible = false;
729
+ // let total_height = 0;
730
+ // let visible_height = 0;
731
+ // this._v_children.iterate((child) => {
732
+
733
+ // // Child vars.
734
+ // const height = child.v_height !== undefined ? child.v_height : this.get_height(child);
735
+ // if (height == 0) {
736
+ // return null; // no fixed height or no height.
737
+ // }
738
+ // const child_start_y = total_height;
739
+ // const child_end_y = total_height + height; // Adjust as needed
740
+ // total_height += height;
741
+
742
+ // // First item.
743
+ // if (is_first && child_end_y >= start_y) {
744
+ // child.transform(`translateY(${child_start_y}px)`); // also update when still visible but height changes may have been made to an element.
745
+ // visible_height += height;
746
+ // is_first = false;
747
+ // is_visible = true;
748
+ // if (!child.rendered) {
749
+ // if (scrolling_down) {
750
+ // this.visible_container.appendChild(child);
751
+ // } else {
752
+ // this.visible_container.insertBefore(child, this.visible_container.firstChild);
753
+ // }
754
+ // child.rendered = true;
755
+ // }
756
+ // }
757
+
758
+ // // Last visible element.
759
+ // else if (is_visible && child_start_y >= end_y) {
760
+ // child.transform(`translateY(${child_start_y - visible_height}px)`); // also update when still visible but height changes may have been made to an element.
761
+ // visible_height += height;
762
+ // is_visible = false;
763
+ // if (!child.rendered) {
764
+ // if (scrolling_down) {
765
+ // this.visible_container.appendChild(child);
766
+ // } else {
767
+ // this.visible_container.insertBefore(child, this.visible_container.firstChild);
768
+ // }
769
+ // child.rendered = true;
770
+ // }
771
+ // }
772
+
773
+ // // Visible elements.
774
+ // else if (is_visible) {
775
+ // child.transform(`translateY(${child_start_y - visible_height}px)`); // also update when still visible but height changes may have been made to an element.
776
+ // visible_height += height;
777
+ // if (!child.rendered) {
778
+ // if (scrolling_down) {
779
+ // this.visible_container.appendChild(child);
780
+ // } else {
781
+ // this.visible_container.insertBefore(child, this.visible_container.firstChild);
782
+ // }
783
+ // child.rendered = true;
784
+ // }
785
+ // }
786
+
787
+ // // Invisible elements.
788
+ // else if (child.rendered) {
789
+ // child.remove();
790
+ // child.rendered = false;
791
+ // }
792
+ // })
793
+
794
+ // // Set scroll dimension.
795
+ // this.visible_container.min_height(total_height);
796
+ // this.visible_container.max_height(total_height);
797
+
798
+ // // Return this.
799
+ // return this;
800
+ // }
801
+
802
+ // // Update heights.
803
+ // update_heights(): this {
804
+ // this._v_children.iterate((child) => {
805
+ // child.v_height = this.get_height(child, false);
806
+ // })
807
+ // return this;
808
+ // }
809
+
810
+ // // Update height of a certain child.
811
+ // update_height(child: any): this {
812
+ // child.v_height = this.get_height(child, false);
813
+ // return this;
814
+ // }
815
+
816
+ // // Get the height of an element.
817
+ // get_height(element, fixed = true): number {
818
+ // let height;
819
+
820
+ // // Get fixed height.
821
+ // if (fixed) {
822
+ // height = parseFloat(element.style.height);
823
+ // if (isNaN(height)) {
824
+ // console.error("Every element in the virtual scroller must have a fixed height, ignoring element: " + element);
825
+ // element.style.display = "none";
826
+ // return 0;
827
+ // }
828
+ // }
829
+
830
+ // // Append to document and get height.
831
+ // // Does not require fixed heights but is slow.
832
+ // else {
833
+ // element.rendered = false; // set rendered to false because this will remove the child from this.visible_container when it was rendered.
834
+ // this.height_measurer.appendChild(element);
835
+ // height = element.offsetHeight;
836
+ // this.height_measurer.removeChild(element);
837
+ // }
838
+
839
+ // // Add margin.
840
+ // const margin_top = parseFloat(element.style.marginTop);
841
+ // if (!isNaN(margin_top)) {
842
+ // height += margin_top;
843
+ // }
844
+ // const margin_bottom = parseFloat(element.style.marginBottom);
845
+ // if (!isNaN(margin_bottom)) {
846
+ // height += margin_bottom;
847
+ // }
848
+
849
+ // // Handler.
850
+ // return height;
851
+ // }
852
+
853
+ // // Custom append function.
854
+ // append(...children: AppendType[]): this {
855
+ // for (let i = 0; i < children.length; i++) {
856
+ // const child = children[i];
857
+ // if (child != null) {
858
+
859
+ // // VWeb element.
860
+ // if (child.element_name != null) {
861
+ // if (
862
+ // child.element_name == "ForEachElement" ||
863
+ // child.element_name == "IfElement" ||
864
+ // child.element_name == "IfDeviceWithElement"
865
+ // ) {
866
+ // child.append_children_to(this);
867
+ // } else {
868
+ // this._v_children.push(child);
869
+ // }
870
+ // }
871
+
872
+ // // Execute function.
873
+ // else if (Utils.is_func(child)) {
874
+ // this.append(child());
875
+ // }
876
+
877
+ // // Node element.
878
+ // else if (child instanceof Node) {
879
+ // this._v_children.push(child);
880
+ // }
881
+
882
+ // // Append text.
883
+ // else if (Utils.is_string(child)) {
884
+ // this._v_children.push(document.createTextNode(child));
885
+ // }
886
+ // }
887
+ // }
888
+ // return this;
889
+ // }
890
+ // }
891
+ // export const VirtualScroller = Elements.wrapper(VirtualScrollerElement);
892
+ // export const NullVirtualScroller = Elements.create_null(VirtualScrollerElement);
893
+ // declare module './any_element.d.ts' { interface AnyElementMap { VirtualScrollerElement: VirtualScrollerElement }}
892
894
 
893
895
  /* @docs:
894
896
  @nav: Frontend
@@ -901,13 +903,19 @@ declare module './any_element.d.ts' { interface AnyElementMap { VirtualScrollerE
901
903
 
902
904
  This class is still experimental.
903
905
  */
904
- @Elements.register
905
- export class SnapScrollerElement extends VStackElement {
906
- constructor(...children: any[]) {
906
+ @Elements.create({
907
+ name: "SnapScrollerElement",
908
+ })
909
+ export class SnapScrollerElement extends (VStackElement as any as VElementBaseSignature) {
910
+
911
+ // Constructor.
912
+ constructor(...children: VElement[]) {
907
913
 
908
914
  // Base.
909
915
  super();
910
- this._init_derived({ derived: SnapScrollerElement, })
916
+ this._init({
917
+ derived: SnapScrollerElement,
918
+ })
911
919
 
912
920
  // Style.
913
921
  this.overflow_y("scroll");
@@ -918,7 +926,8 @@ export class SnapScrollerElement extends VStackElement {
918
926
  }
919
927
 
920
928
  // Append.
921
- append(...children: any[]): this {
929
+ // @ts-ignore base type accepts more input types, this one only accepts velements
930
+ append(...children: AnyElement[]): this {
922
931
  for (let i = 0; i < children.length; i++) {
923
932
  const win = children[i];
924
933
  if (win == null) { continue; }