@vandenberghinc/volt 1.1.2
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.
- package/.vrepo +28 -0
- package/.vscode/tasks.json +87 -0
- package/README.md +67 -0
- package/backend/dist/cjs/blacklist.d.ts +10 -0
- package/backend/dist/cjs/blacklist.js +53 -0
- package/backend/dist/cjs/cli.d.ts +2 -0
- package/backend/dist/cjs/cli.js +263 -0
- package/backend/dist/cjs/database.d.ts +364 -0
- package/backend/dist/cjs/database.js +1962 -0
- package/backend/dist/cjs/endpoint.d.ts +57 -0
- package/backend/dist/cjs/endpoint.js +425 -0
- package/backend/dist/cjs/file_watcher.d.ts +44 -0
- package/backend/dist/cjs/file_watcher.js +348 -0
- package/backend/dist/cjs/frontend.d.ts +13 -0
- package/backend/dist/cjs/frontend.js +30 -0
- package/backend/dist/cjs/image_endpoint.d.ts +24 -0
- package/backend/dist/cjs/image_endpoint.js +210 -0
- package/backend/dist/cjs/logger.d.ts +5 -0
- package/backend/dist/cjs/logger.js +16 -0
- package/backend/dist/cjs/meta.d.ts +50 -0
- package/backend/dist/cjs/meta.js +153 -0
- package/backend/dist/cjs/mutex.d.ts +24 -0
- package/backend/dist/cjs/mutex.js +52 -0
- package/backend/dist/cjs/package.json +1 -0
- package/backend/dist/cjs/payments/paddle.d.ts +161 -0
- package/backend/dist/cjs/payments/paddle.js +2301 -0
- package/backend/dist/cjs/plugins/browser.d.ts +36 -0
- package/backend/dist/cjs/plugins/browser.js +183 -0
- package/backend/dist/cjs/plugins/communication.d.ts +70 -0
- package/backend/dist/cjs/plugins/communication.js +177 -0
- package/backend/dist/cjs/plugins/css.d.ts +10 -0
- package/backend/dist/cjs/plugins/css.js +71 -0
- package/backend/dist/cjs/plugins/mail.d.ts +277 -0
- package/backend/dist/cjs/plugins/mail.js +1419 -0
- package/backend/dist/cjs/plugins/pdf.d.ts +757 -0
- package/backend/dist/cjs/plugins/pdf.js +1694 -0
- package/backend/dist/cjs/plugins/thread_monitor.d.ts +18 -0
- package/backend/dist/cjs/plugins/thread_monitor.js +127 -0
- package/backend/dist/cjs/plugins/ts/compiler.d.ts +132 -0
- package/backend/dist/cjs/plugins/ts/compiler.js +944 -0
- package/backend/dist/cjs/plugins/ts/preprocessing.d.ts +14 -0
- package/backend/dist/cjs/plugins/ts/preprocessing.js +762 -0
- package/backend/dist/cjs/rate_limit.d.ts +65 -0
- package/backend/dist/cjs/rate_limit.js +463 -0
- package/backend/dist/cjs/request.deprc.d.ts +48 -0
- package/backend/dist/cjs/request.deprc.js +572 -0
- package/backend/dist/cjs/response.deprc.d.ts +55 -0
- package/backend/dist/cjs/response.deprc.js +275 -0
- package/backend/dist/cjs/server.d.ts +311 -0
- package/backend/dist/cjs/server.js +3475 -0
- package/backend/dist/cjs/splash_screen.d.ts +35 -0
- package/backend/dist/cjs/splash_screen.js +152 -0
- package/backend/dist/cjs/status.d.ts +60 -0
- package/backend/dist/cjs/status.js +199 -0
- package/backend/dist/cjs/stream.d.ts +75 -0
- package/backend/dist/cjs/stream.js +954 -0
- package/backend/dist/cjs/users.d.ts +111 -0
- package/backend/dist/cjs/users.js +1945 -0
- package/backend/dist/cjs/utils.d.ts +27 -0
- package/backend/dist/cjs/utils.js +329 -0
- package/backend/dist/cjs/view.d.ts +52 -0
- package/backend/dist/cjs/view.js +568 -0
- package/backend/dist/cjs/vinc.d.ts +2 -0
- package/backend/dist/cjs/vinc.dev.d.ts +2 -0
- package/backend/dist/cjs/vinc.dev.js +42 -0
- package/backend/dist/cjs/vinc.js +42 -0
- package/backend/dist/cjs/volt.d.ts +15 -0
- package/backend/dist/cjs/volt.js +64 -0
- package/backend/dist/css/adyen.css +92 -0
- package/backend/dist/css/volt.css +65 -0
- package/backend/dist/esm/blacklist.d.ts +10 -0
- package/backend/dist/esm/blacklist.js +49 -0
- package/backend/dist/esm/cli.d.ts +2 -0
- package/backend/dist/esm/cli.js +228 -0
- package/backend/dist/esm/database.d.ts +364 -0
- package/backend/dist/esm/database.js +1957 -0
- package/backend/dist/esm/endpoint.d.ts +57 -0
- package/backend/dist/esm/endpoint.js +421 -0
- package/backend/dist/esm/file_watcher.d.ts +44 -0
- package/backend/dist/esm/file_watcher.js +313 -0
- package/backend/dist/esm/frontend.d.ts +13 -0
- package/backend/dist/esm/frontend.js +27 -0
- package/backend/dist/esm/image_endpoint.d.ts +24 -0
- package/backend/dist/esm/image_endpoint.js +206 -0
- package/backend/dist/esm/logger.d.ts +5 -0
- package/backend/dist/esm/logger.js +13 -0
- package/backend/dist/esm/meta.d.ts +50 -0
- package/backend/dist/esm/meta.js +149 -0
- package/backend/dist/esm/mutex.d.ts +24 -0
- package/backend/dist/esm/mutex.js +48 -0
- package/backend/dist/esm/payments/paddle.d.ts +161 -0
- package/backend/dist/esm/payments/paddle.js +2261 -0
- package/backend/dist/esm/plugins/browser.d.ts +36 -0
- package/backend/dist/esm/plugins/browser.js +176 -0
- package/backend/dist/esm/plugins/communication.d.ts +70 -0
- package/backend/dist/esm/plugins/communication.js +169 -0
- package/backend/dist/esm/plugins/css.d.ts +10 -0
- package/backend/dist/esm/plugins/css.js +64 -0
- package/backend/dist/esm/plugins/mail.d.ts +277 -0
- package/backend/dist/esm/plugins/mail.js +1403 -0
- package/backend/dist/esm/plugins/pdf.d.ts +757 -0
- package/backend/dist/esm/plugins/pdf.js +1694 -0
- package/backend/dist/esm/plugins/thread_monitor.d.ts +18 -0
- package/backend/dist/esm/plugins/thread_monitor.js +120 -0
- package/backend/dist/esm/plugins/ts/compiler.d.ts +132 -0
- package/backend/dist/esm/plugins/ts/compiler.js +907 -0
- package/backend/dist/esm/plugins/ts/preprocessing.d.ts +14 -0
- package/backend/dist/esm/plugins/ts/preprocessing.js +724 -0
- package/backend/dist/esm/rate_limit.d.ts +65 -0
- package/backend/dist/esm/rate_limit.js +425 -0
- package/backend/dist/esm/request.deprc.d.ts +48 -0
- package/backend/dist/esm/request.deprc.js +572 -0
- package/backend/dist/esm/response.deprc.d.ts +55 -0
- package/backend/dist/esm/response.deprc.js +275 -0
- package/backend/dist/esm/server.d.ts +311 -0
- package/backend/dist/esm/server.js +3435 -0
- package/backend/dist/esm/splash_screen.d.ts +35 -0
- package/backend/dist/esm/splash_screen.js +148 -0
- package/backend/dist/esm/status.d.ts +60 -0
- package/backend/dist/esm/status.js +196 -0
- package/backend/dist/esm/stream.d.ts +75 -0
- package/backend/dist/esm/stream.js +947 -0
- package/backend/dist/esm/users.d.ts +111 -0
- package/backend/dist/esm/users.js +1908 -0
- package/backend/dist/esm/utils.d.ts +27 -0
- package/backend/dist/esm/utils.js +324 -0
- package/backend/dist/esm/view.d.ts +52 -0
- package/backend/dist/esm/view.js +561 -0
- package/backend/dist/esm/vinc.d.ts +2 -0
- package/backend/dist/esm/vinc.dev.d.ts +2 -0
- package/backend/dist/esm/vinc.dev.js +6 -0
- package/backend/dist/esm/vinc.js +6 -0
- package/backend/dist/esm/volt.d.ts +15 -0
- package/backend/dist/esm/volt.js +23 -0
- package/backend/dist/esm-dev/blacklist.d.ts +10 -0
- package/backend/dist/esm-dev/blacklist.js +49 -0
- package/backend/dist/esm-dev/cli.d.ts +2 -0
- package/backend/dist/esm-dev/cli.js +228 -0
- package/backend/dist/esm-dev/database.d.ts +364 -0
- package/backend/dist/esm-dev/database.js +1957 -0
- package/backend/dist/esm-dev/endpoint.d.ts +57 -0
- package/backend/dist/esm-dev/endpoint.js +421 -0
- package/backend/dist/esm-dev/file_watcher.d.ts +44 -0
- package/backend/dist/esm-dev/file_watcher.js +313 -0
- package/backend/dist/esm-dev/frontend.d.ts +13 -0
- package/backend/dist/esm-dev/frontend.js +27 -0
- package/backend/dist/esm-dev/image_endpoint.d.ts +24 -0
- package/backend/dist/esm-dev/image_endpoint.js +206 -0
- package/backend/dist/esm-dev/logger.d.ts +5 -0
- package/backend/dist/esm-dev/logger.js +13 -0
- package/backend/dist/esm-dev/meta.d.ts +50 -0
- package/backend/dist/esm-dev/meta.js +149 -0
- package/backend/dist/esm-dev/mutex.d.ts +24 -0
- package/backend/dist/esm-dev/mutex.js +48 -0
- package/backend/dist/esm-dev/payments/paddle.d.ts +161 -0
- package/backend/dist/esm-dev/payments/paddle.js +2261 -0
- package/backend/dist/esm-dev/plugins/browser.d.ts +36 -0
- package/backend/dist/esm-dev/plugins/browser.js +176 -0
- package/backend/dist/esm-dev/plugins/communication.d.ts +70 -0
- package/backend/dist/esm-dev/plugins/communication.js +169 -0
- package/backend/dist/esm-dev/plugins/css.d.ts +10 -0
- package/backend/dist/esm-dev/plugins/css.js +64 -0
- package/backend/dist/esm-dev/plugins/mail.d.ts +277 -0
- package/backend/dist/esm-dev/plugins/mail.js +1403 -0
- package/backend/dist/esm-dev/plugins/pdf.d.ts +757 -0
- package/backend/dist/esm-dev/plugins/pdf.js +1694 -0
- package/backend/dist/esm-dev/plugins/thread_monitor.d.ts +18 -0
- package/backend/dist/esm-dev/plugins/thread_monitor.js +120 -0
- package/backend/dist/esm-dev/plugins/ts/compiler.d.ts +132 -0
- package/backend/dist/esm-dev/plugins/ts/compiler.js +907 -0
- package/backend/dist/esm-dev/plugins/ts/preprocessing.d.ts +14 -0
- package/backend/dist/esm-dev/plugins/ts/preprocessing.js +724 -0
- package/backend/dist/esm-dev/rate_limit.d.ts +65 -0
- package/backend/dist/esm-dev/rate_limit.js +425 -0
- package/backend/dist/esm-dev/request.deprc.d.ts +48 -0
- package/backend/dist/esm-dev/request.deprc.js +572 -0
- package/backend/dist/esm-dev/response.deprc.d.ts +55 -0
- package/backend/dist/esm-dev/response.deprc.js +275 -0
- package/backend/dist/esm-dev/server.d.ts +311 -0
- package/backend/dist/esm-dev/server.js +3435 -0
- package/backend/dist/esm-dev/splash_screen.d.ts +35 -0
- package/backend/dist/esm-dev/splash_screen.js +148 -0
- package/backend/dist/esm-dev/status.d.ts +60 -0
- package/backend/dist/esm-dev/status.js +196 -0
- package/backend/dist/esm-dev/stream.d.ts +75 -0
- package/backend/dist/esm-dev/stream.js +947 -0
- package/backend/dist/esm-dev/users.d.ts +111 -0
- package/backend/dist/esm-dev/users.js +1908 -0
- package/backend/dist/esm-dev/utils.d.ts +27 -0
- package/backend/dist/esm-dev/utils.js +324 -0
- package/backend/dist/esm-dev/view.d.ts +52 -0
- package/backend/dist/esm-dev/view.js +561 -0
- package/backend/dist/esm-dev/vinc.d.ts +2 -0
- package/backend/dist/esm-dev/vinc.dev.d.ts +2 -0
- package/backend/dist/esm-dev/vinc.dev.js +6 -0
- package/backend/dist/esm-dev/vinc.js +6 -0
- package/backend/dist/esm-dev/volt.d.ts +15 -0
- package/backend/dist/esm-dev/volt.js +23 -0
- package/backend/src/blacklist.ts +69 -0
- package/backend/src/cli.js +245 -0
- package/backend/src/database.ts +2241 -0
- package/backend/src/endpoint.ts +494 -0
- package/backend/src/file_watcher.ts +359 -0
- package/backend/src/frontend.ts +35 -0
- package/backend/src/globals.d.ts +8 -0
- package/backend/src/image_endpoint.ts +258 -0
- package/backend/src/logger.ts +18 -0
- package/backend/src/meta.ts +202 -0
- package/backend/src/mutex.ts +51 -0
- package/backend/src/payments/paddle.ts +2659 -0
- package/backend/src/plugins/browser.ts +188 -0
- package/backend/src/plugins/communication.ts +204 -0
- package/backend/src/plugins/css.ts +84 -0
- package/backend/src/plugins/fonts/Menlo-Bold.ttf +0 -0
- package/backend/src/plugins/fonts/Menlo-Regular.ttf +0 -0
- package/backend/src/plugins/mail.ts +1720 -0
- package/backend/src/plugins/pdf.js +1932 -0
- package/backend/src/plugins/thread_monitor.ts +164 -0
- package/backend/src/plugins/ts/compiler.ts +1242 -0
- package/backend/src/plugins/ts/preprocessing.ts +812 -0
- package/backend/src/rate_limit.ts +503 -0
- package/backend/src/request.deprc.js +626 -0
- package/backend/src/response.deprc.js +354 -0
- package/backend/src/server.ts +4149 -0
- package/backend/src/splash_screen.ts +192 -0
- package/backend/src/status.ts +199 -0
- package/backend/src/stream.ts +1070 -0
- package/backend/src/users.ts +2077 -0
- package/backend/src/utils.ts +359 -0
- package/backend/src/view.ts +655 -0
- package/backend/src/vinc.dev.js +6 -0
- package/backend/src/vinc.ts +6 -0
- package/backend/src/volt.js +25 -0
- package/backend/tsconfig.cjs.json +29 -0
- package/backend/tsconfig.esm.dev.json +34 -0
- package/backend/tsconfig.esm.json +30 -0
- package/backend/tsconfig.json +2 -0
- package/frontend/compile.js +436 -0
- package/frontend/dist/elements/base.d.ts +9891 -0
- package/frontend/dist/elements/base.js +8818 -0
- package/frontend/dist/elements/module.d.ts +16 -0
- package/frontend/dist/elements/module.js +178 -0
- package/frontend/dist/modules/array.d.ts +37 -0
- package/frontend/dist/modules/array.js +284 -0
- package/frontend/dist/modules/auth.d.ts +45 -0
- package/frontend/dist/modules/auth.js +138 -0
- package/frontend/dist/modules/colors.d.ts +26 -0
- package/frontend/dist/modules/colors.js +340 -0
- package/frontend/dist/modules/compression.d.ts +6 -0
- package/frontend/dist/modules/compression.js +999 -0
- package/frontend/dist/modules/cookies.d.ts +17 -0
- package/frontend/dist/modules/cookies.js +166 -0
- package/frontend/dist/modules/date.d.ts +142 -0
- package/frontend/dist/modules/date.js +493 -0
- package/frontend/dist/modules/events.d.ts +7 -0
- package/frontend/dist/modules/events.js +90 -0
- package/frontend/dist/modules/google.d.ts +10 -0
- package/frontend/dist/modules/google.js +53 -0
- package/frontend/dist/modules/meta.d.ts +9 -0
- package/frontend/dist/modules/meta.js +45 -0
- package/frontend/dist/modules/mutex.d.ts +8 -0
- package/frontend/dist/modules/mutex.js +52 -0
- package/frontend/dist/modules/number.d.ts +12 -0
- package/frontend/dist/modules/number.js +8 -0
- package/frontend/dist/modules/object.d.ts +50 -0
- package/frontend/dist/modules/object.js +147 -0
- package/frontend/dist/modules/paddle.d.ts +1403 -0
- package/frontend/dist/modules/paddle.js +2641 -0
- package/frontend/dist/modules/scheme.d.ts +207 -0
- package/frontend/dist/modules/scheme.js +649 -0
- package/frontend/dist/modules/settings.d.ts +3 -0
- package/frontend/dist/modules/settings.js +4 -0
- package/frontend/dist/modules/statics.d.ts +4 -0
- package/frontend/dist/modules/statics.js +45 -0
- package/frontend/dist/modules/string.d.ts +163 -0
- package/frontend/dist/modules/string.js +291 -0
- package/frontend/dist/modules/support.d.ts +18 -0
- package/frontend/dist/modules/support.js +102 -0
- package/frontend/dist/modules/themes.d.ts +8 -0
- package/frontend/dist/modules/themes.js +17 -0
- package/frontend/dist/modules/user.d.ts +58 -0
- package/frontend/dist/modules/user.js +279 -0
- package/frontend/dist/modules/utils.d.ts +58 -0
- package/frontend/dist/modules/utils.js +1159 -0
- package/frontend/dist/types/gradient.d.ts +12 -0
- package/frontend/dist/types/gradient.js +79 -0
- package/frontend/dist/ui/border_button.d.ts +177 -0
- package/frontend/dist/ui/border_button.js +235 -0
- package/frontend/dist/ui/button.d.ts +42 -0
- package/frontend/dist/ui/button.js +114 -0
- package/frontend/dist/ui/canvas.d.ts +56 -0
- package/frontend/dist/ui/canvas.js +411 -0
- package/frontend/dist/ui/checkbox.d.ts +72 -0
- package/frontend/dist/ui/checkbox.js +277 -0
- package/frontend/dist/ui/code.d.ts +232 -0
- package/frontend/dist/ui/code.js +977 -0
- package/frontend/dist/ui/color.d.ts +1 -0
- package/frontend/dist/ui/color.js +110 -0
- package/frontend/dist/ui/context_menu.d.ts +30 -0
- package/frontend/dist/ui/context_menu.js +211 -0
- package/frontend/dist/ui/css.d.ts +10 -0
- package/frontend/dist/ui/css.js +44 -0
- package/frontend/dist/ui/divider.d.ts +18 -0
- package/frontend/dist/ui/divider.js +82 -0
- package/frontend/dist/ui/dropdown.d.ts +115 -0
- package/frontend/dist/ui/dropdown.js +446 -0
- package/frontend/dist/ui/for_each.d.ts +38 -0
- package/frontend/dist/ui/for_each.js +97 -0
- package/frontend/dist/ui/form.d.ts +25 -0
- package/frontend/dist/ui/form.js +227 -0
- package/frontend/dist/ui/frame_modes.d.ts +28 -0
- package/frontend/dist/ui/frame_modes.js +116 -0
- package/frontend/dist/ui/google_map.d.ts +31 -0
- package/frontend/dist/ui/google_map.js +111 -0
- package/frontend/dist/ui/gradient.d.ts +24 -0
- package/frontend/dist/ui/gradient.js +115 -0
- package/frontend/dist/ui/image.d.ts +138 -0
- package/frontend/dist/ui/image.js +570 -0
- package/frontend/dist/ui/input.d.ts +316 -0
- package/frontend/dist/ui/input.js +1187 -0
- package/frontend/dist/ui/link.d.ts +39 -0
- package/frontend/dist/ui/link.js +146 -0
- package/frontend/dist/ui/list.d.ts +33 -0
- package/frontend/dist/ui/list.js +161 -0
- package/frontend/dist/ui/loader_button.d.ts +108 -0
- package/frontend/dist/ui/loader_button.js +207 -0
- package/frontend/dist/ui/loaders.d.ts +60 -0
- package/frontend/dist/ui/loaders.js +150 -0
- package/frontend/dist/ui/popup.d.ts +84 -0
- package/frontend/dist/ui/popup.js +331 -0
- package/frontend/dist/ui/pseudo.d.ts +16 -0
- package/frontend/dist/ui/pseudo.js +81 -0
- package/frontend/dist/ui/scroller.d.ts +131 -0
- package/frontend/dist/ui/scroller.js +1251 -0
- package/frontend/dist/ui/slider.d.ts +35 -0
- package/frontend/dist/ui/slider.js +203 -0
- package/frontend/dist/ui/spacer.d.ts +20 -0
- package/frontend/dist/ui/spacer.js +83 -0
- package/frontend/dist/ui/span.d.ts +11 -0
- package/frontend/dist/ui/span.js +75 -0
- package/frontend/dist/ui/stack.d.ts +123 -0
- package/frontend/dist/ui/stack.js +344 -0
- package/frontend/dist/ui/steps.d.ts +72 -0
- package/frontend/dist/ui/steps.js +306 -0
- package/frontend/dist/ui/style.d.ts +12 -0
- package/frontend/dist/ui/style.js +78 -0
- package/frontend/dist/ui/switch.d.ts +44 -0
- package/frontend/dist/ui/switch.js +280 -0
- package/frontend/dist/ui/table.d.ts +118 -0
- package/frontend/dist/ui/table.js +411 -0
- package/frontend/dist/ui/tabs.d.ts +85 -0
- package/frontend/dist/ui/tabs.js +392 -0
- package/frontend/dist/ui/text.d.ts +19 -0
- package/frontend/dist/ui/text.js +88 -0
- package/frontend/dist/ui/theme.d.ts +25 -0
- package/frontend/dist/ui/theme.js +237 -0
- package/frontend/dist/ui/title.d.ts +36 -0
- package/frontend/dist/ui/title.js +127 -0
- package/frontend/dist/ui/ui.d.ts +38 -0
- package/frontend/dist/ui/ui.js +41 -0
- package/frontend/dist/ui/view.d.ts +25 -0
- package/frontend/dist/ui/view.js +93 -0
- package/frontend/dist/volt.d.ts +22 -0
- package/frontend/dist/volt.js +27 -0
- package/frontend/exports.json +1340 -0
- package/frontend/src/css/adyen.css +92 -0
- package/frontend/src/css/volt.css +65 -0
- package/frontend/src/elements/base.ts +16790 -0
- package/frontend/src/elements/module.ts +184 -0
- package/frontend/src/elements/types.d.ts +155 -0
- package/frontend/src/modules/array.ts +366 -0
- package/frontend/src/modules/auth.ts +188 -0
- package/frontend/src/modules/colors.ts +449 -0
- package/frontend/src/modules/compression.ts +67 -0
- package/frontend/src/modules/cookies.ts +182 -0
- package/frontend/src/modules/date.js +535 -0
- package/frontend/src/modules/date.ts +583 -0
- package/frontend/src/modules/events.ts +96 -0
- package/frontend/src/modules/google.ts +60 -0
- package/frontend/src/modules/meta.ts +59 -0
- package/frontend/src/modules/mutex.ts +59 -0
- package/frontend/src/modules/number.ts +20 -0
- package/frontend/src/modules/object.ts +212 -0
- package/frontend/src/modules/paddle.ts +2990 -0
- package/frontend/src/modules/scheme.ts +740 -0
- package/frontend/src/modules/settings.ts +5 -0
- package/frontend/src/modules/statics.ts +47 -0
- package/frontend/src/modules/string.ts +500 -0
- package/frontend/src/modules/support.ts +118 -0
- package/frontend/src/modules/themes.ts +24 -0
- package/frontend/src/modules/user.ts +321 -0
- package/frontend/src/modules/utils.ts +1260 -0
- package/frontend/src/static/admin/admin.png +0 -0
- package/frontend/src/static/admin/password.webp +0 -0
- package/frontend/src/static/icons/copy.webp +0 -0
- package/frontend/src/static/payments/arrow.long.webp +0 -0
- package/frontend/src/static/payments/arrow.long2.webp +0 -0
- package/frontend/src/static/payments/cancelled.webp +0 -0
- package/frontend/src/static/payments/check.sign.webp +0 -0
- package/frontend/src/static/payments/check.webp +0 -0
- package/frontend/src/static/payments/close.webp +0 -0
- package/frontend/src/static/payments/error.webp +0 -0
- package/frontend/src/static/payments/exclamation.webp +0 -0
- package/frontend/src/static/payments/minus.webp +0 -0
- package/frontend/src/static/payments/party.webp +0 -0
- package/frontend/src/static/payments/plus.webp +0 -0
- package/frontend/src/static/payments/shopping_cart.webp +0 -0
- package/frontend/src/static/payments/trash.webp +0 -0
- package/frontend/src/types/global.d.ts +4 -0
- package/frontend/src/types/gradient.ts +87 -0
- package/frontend/src/ui/any_element.d.ts +5 -0
- package/frontend/src/ui/border_button.ts +320 -0
- package/frontend/src/ui/button.ts +62 -0
- package/frontend/src/ui/canvas.ts +431 -0
- package/frontend/src/ui/checkbox.ts +284 -0
- package/frontend/src/ui/code.ts +1049 -0
- package/frontend/src/ui/color.ts +117 -0
- package/frontend/src/ui/context_menu.ts +194 -0
- package/frontend/src/ui/css.ts +57 -0
- package/frontend/src/ui/divider.ts +28 -0
- package/frontend/src/ui/dropdown.ts +503 -0
- package/frontend/src/ui/for_each.ts +71 -0
- package/frontend/src/ui/form.ts +208 -0
- package/frontend/src/ui/frame_modes.ts +140 -0
- package/frontend/src/ui/google_map.ts +70 -0
- package/frontend/src/ui/gradient.ts +73 -0
- package/frontend/src/ui/image.ts +587 -0
- package/frontend/src/ui/input.ts +1284 -0
- package/frontend/src/ui/link.ts +77 -0
- package/frontend/src/ui/list.ts +88 -0
- package/frontend/src/ui/loader_button.ts +192 -0
- package/frontend/src/ui/loaders.ts +126 -0
- package/frontend/src/ui/popup.ts +370 -0
- package/frontend/src/ui/pseudo.ts +33 -0
- package/frontend/src/ui/scroller.ts +1324 -0
- package/frontend/src/ui/slider.ts +215 -0
- package/frontend/src/ui/spacer.ts +29 -0
- package/frontend/src/ui/span.ts +23 -0
- package/frontend/src/ui/stack.ts +238 -0
- package/frontend/src/ui/steps.ts +334 -0
- package/frontend/src/ui/style.ts +26 -0
- package/frontend/src/ui/switch.ts +286 -0
- package/frontend/src/ui/table.ts +323 -0
- package/frontend/src/ui/tabs.ts +441 -0
- package/frontend/src/ui/text.ts +38 -0
- package/frontend/src/ui/theme.ts +279 -0
- package/frontend/src/ui/title.ts +64 -0
- package/frontend/src/ui/ui.ts +47 -0
- package/frontend/src/ui/view.ts +44 -0
- package/frontend/src/volt.ts +31 -0
- package/package.json +58 -0
|
@@ -0,0 +1,1251 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Author: Daan van den Bergh
|
|
3
|
+
* Copyright: © 2022 - 2024 Daan van den Bergh.
|
|
4
|
+
*/
|
|
5
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
6
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
7
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
8
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
9
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
10
|
+
var _, done = false;
|
|
11
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
12
|
+
var context = {};
|
|
13
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
14
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
15
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
16
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
17
|
+
if (kind === "accessor") {
|
|
18
|
+
if (result === void 0) continue;
|
|
19
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
20
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
21
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
22
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
23
|
+
}
|
|
24
|
+
else if (_ = accept(result)) {
|
|
25
|
+
if (kind === "field") initializers.unshift(_);
|
|
26
|
+
else descriptor[key] = _;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
30
|
+
done = true;
|
|
31
|
+
};
|
|
32
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
33
|
+
var useValue = arguments.length > 2;
|
|
34
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
35
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
36
|
+
}
|
|
37
|
+
return useValue ? value : void 0;
|
|
38
|
+
};
|
|
39
|
+
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
40
|
+
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
41
|
+
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
42
|
+
};
|
|
43
|
+
// Imports.
|
|
44
|
+
import { Elements, VElementTagMap } from "../elements/module.js";
|
|
45
|
+
import { Utils } from "../modules/utils.js";
|
|
46
|
+
import { Span } from "./span";
|
|
47
|
+
import { VStack, VStackElement } from "./stack";
|
|
48
|
+
// Scroller.
|
|
49
|
+
// - Warning: Setting padding on element attribute "content" may cause undefined behaviour.
|
|
50
|
+
let ScrollerElement = (() => {
|
|
51
|
+
var _a;
|
|
52
|
+
let _classDecorators = [(_a = Elements).register.bind(_a)];
|
|
53
|
+
let _classDescriptor;
|
|
54
|
+
let _classExtraInitializers = [];
|
|
55
|
+
let _classThis;
|
|
56
|
+
let _classSuper = VElementTagMap.div;
|
|
57
|
+
var ScrollerElement = _classThis = class extends _classSuper {
|
|
58
|
+
// Constructor.
|
|
59
|
+
constructor(...children) {
|
|
60
|
+
// Initialize base class.
|
|
61
|
+
super({
|
|
62
|
+
derived: ScrollerElement,
|
|
63
|
+
});
|
|
64
|
+
// Style.
|
|
65
|
+
if (this.position() != "absolute") {
|
|
66
|
+
this.position("relative"); // is required for attribute "track"
|
|
67
|
+
}
|
|
68
|
+
super.overflow("hidden"); // should always be hidden to enable scrolling, and otherwise the thumb not be visible due to overflow width.
|
|
69
|
+
this.class("hide_scrollbar");
|
|
70
|
+
this.styles({
|
|
71
|
+
"content-visibility": "auto",
|
|
72
|
+
});
|
|
73
|
+
// Content.
|
|
74
|
+
this.content = VStack(...children)
|
|
75
|
+
.parent(this)
|
|
76
|
+
.class("hide_scrollbar")
|
|
77
|
+
.position("relative") // in case it has absolute children that should scroll, otherwise the content wont scroll without "relative".
|
|
78
|
+
.frame("100%", "100%")
|
|
79
|
+
.flex("1 1 0") // flex-basis 0 otherwise it expands its parent.
|
|
80
|
+
.overflow("scroll")
|
|
81
|
+
.overscroll_behavior(ScrollerElement.default_style["overscroll-behavior"])
|
|
82
|
+
.styles({
|
|
83
|
+
"content-visibility": "auto",
|
|
84
|
+
});
|
|
85
|
+
// Scroll bar.
|
|
86
|
+
this.thumb = VStack()
|
|
87
|
+
.parent(this)
|
|
88
|
+
.position(0, 0, null, 0)
|
|
89
|
+
.height(30)
|
|
90
|
+
.border_radius(10)
|
|
91
|
+
.overflow("visible") // for thumb shadow.
|
|
92
|
+
.background_color("#CCCCCC")
|
|
93
|
+
.opacity(0)
|
|
94
|
+
.transition("opacity 0.3s linear")
|
|
95
|
+
.box_shadow("0px 0px 5px #00000005");
|
|
96
|
+
this.track = VStack(this.thumb)
|
|
97
|
+
.parent(this)
|
|
98
|
+
.class("hide_scrollbar")
|
|
99
|
+
.position(5, 5, 5, null)
|
|
100
|
+
.width(10)
|
|
101
|
+
.background_color("transparent")
|
|
102
|
+
.border_radius(10)
|
|
103
|
+
.transition("background-color 0.3s linear")
|
|
104
|
+
.assign("background_value", "#28292E")
|
|
105
|
+
.overflow("visible");
|
|
106
|
+
// Add children.
|
|
107
|
+
super.append(this.content, this.track);
|
|
108
|
+
// The on scroll callbacks.
|
|
109
|
+
this.on_scroll_callbacks = [];
|
|
110
|
+
// Alias functions.
|
|
111
|
+
// this.raw_append = super.append.bind(super);
|
|
112
|
+
this.iterate = this.content.iterate.bind(this.content);
|
|
113
|
+
this.iterate_nodes = this.content.iterate_nodes.bind(this.content);
|
|
114
|
+
// Set default delay.
|
|
115
|
+
this.m_delay = 1000;
|
|
116
|
+
// Overwrite track background functions to keep the background color.
|
|
117
|
+
// this.track.__background__ = this.track.background;
|
|
118
|
+
// this.track.__background_color__ = this.background_color;
|
|
119
|
+
this.track.background = function (value) {
|
|
120
|
+
if (value == null) {
|
|
121
|
+
return this.__background_value__ ?? "";
|
|
122
|
+
}
|
|
123
|
+
this.__background_value__ = value;
|
|
124
|
+
return this;
|
|
125
|
+
};
|
|
126
|
+
this.track.background_color = function (value) {
|
|
127
|
+
if (value == null) {
|
|
128
|
+
return this.__background_value__ ?? "";
|
|
129
|
+
}
|
|
130
|
+
this.__background_value__ = value;
|
|
131
|
+
return this;
|
|
132
|
+
};
|
|
133
|
+
// Mouse enter event.
|
|
134
|
+
this.track.addEventListener("mouseenter", (event) => {
|
|
135
|
+
if (!this.is_scrollable()) {
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
this.track.style.backgroundColor = this.track.__background_value__;
|
|
139
|
+
clearTimeout(this._fadeout_timeout);
|
|
140
|
+
this.thumb.style.opacity = "1"; // keep as opacity for box shadow.
|
|
141
|
+
});
|
|
142
|
+
// Mouse leave event.
|
|
143
|
+
this.track.addEventListener("mouseleave", (event) => {
|
|
144
|
+
if (!this.is_scrollable()) {
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
if (!this.thumb.dragging) {
|
|
148
|
+
this.track.style.backgroundColor = "transparent";
|
|
149
|
+
this.thumb.style.opacity = "0"; // keep as opacity for box shadow.
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
// Scroll event.
|
|
153
|
+
this.content.addEventListener("scroll", (event) => {
|
|
154
|
+
// Calculate thumb offset.
|
|
155
|
+
const height = this.content.clientHeight;
|
|
156
|
+
const relative_height = this.track.clientHeight; //this.content.clientHeight;
|
|
157
|
+
const thumb_height = this.thumb.clientHeight;
|
|
158
|
+
const scroll_height = this.content.scrollHeight;
|
|
159
|
+
const scroll_top = this.content.scrollTop;
|
|
160
|
+
let relative_top;
|
|
161
|
+
if (scroll_top >= scroll_height - height) {
|
|
162
|
+
relative_top = relative_height - thumb_height;
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
relative_top = relative_height * (scroll_top / (scroll_height - height)) - thumb_height / 2;
|
|
166
|
+
if (relative_top + thumb_height >= relative_height) {
|
|
167
|
+
relative_top = relative_height - thumb_height - 3;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (relative_top < 0) {
|
|
171
|
+
relative_top = 0;
|
|
172
|
+
}
|
|
173
|
+
this.thumb.style.transform = `translateY(${relative_top}px)`;
|
|
174
|
+
// Fade in.
|
|
175
|
+
// this.track.style.backgroundColor = this.track.__background_value__;
|
|
176
|
+
clearTimeout(this._fadeout_timeout);
|
|
177
|
+
this.thumb.style.opacity = "1";
|
|
178
|
+
// Fade out.
|
|
179
|
+
clearTimeout(this._fadeout_timeout);
|
|
180
|
+
this._fadeout_timeout = setTimeout(() => {
|
|
181
|
+
this.track.style.backgroundColor = "transparent"; // also hide track so that when the user drags the thumb and the track becomes visible, the track and the thumb fade out simultaneously when the dragging ends.
|
|
182
|
+
this.thumb.style.opacity = "0";
|
|
183
|
+
}, this.m_delay);
|
|
184
|
+
});
|
|
185
|
+
// Set scroll by dragging thumb.
|
|
186
|
+
let start_y, old_user_select;
|
|
187
|
+
const mouse_up_handler = (event) => {
|
|
188
|
+
// No longer dragging.
|
|
189
|
+
this.thumb.dragging = false;
|
|
190
|
+
// Restore user select.
|
|
191
|
+
this.style.userSelect = old_user_select;
|
|
192
|
+
// Remove handler.
|
|
193
|
+
document.body.removeEventListener("mouseup", mouse_up_handler);
|
|
194
|
+
};
|
|
195
|
+
this.thumb.onmousedown = (event) => {
|
|
196
|
+
// Not scrollable.
|
|
197
|
+
if (!this.is_scrollable()) {
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
// Set start y.
|
|
201
|
+
start_y = this.content.getBoundingClientRect().top + parseFloat(window.getComputedStyle(this.track).marginTop);
|
|
202
|
+
// Set user select.
|
|
203
|
+
// Should be set on "this" on "this.content" does not work correctly.
|
|
204
|
+
old_user_select = this.content.style.userSelect;
|
|
205
|
+
this.style.userSelect = "none";
|
|
206
|
+
// Set dragging.
|
|
207
|
+
this.thumb.dragging = true;
|
|
208
|
+
// Show track.
|
|
209
|
+
this.track.style.backgroundColor = this.track.__background_value__;
|
|
210
|
+
clearTimeout(this._fadeout_timeout);
|
|
211
|
+
this.thumb.style.opacity = "1"; // keep as opacity for box shadow.
|
|
212
|
+
// Add mouse up handler to body.
|
|
213
|
+
document.body.addEventListener("mouseup", mouse_up_handler);
|
|
214
|
+
};
|
|
215
|
+
this.addEventListener("mousemove", (event) => {
|
|
216
|
+
if (this.thumb.dragging) {
|
|
217
|
+
// Vars.
|
|
218
|
+
const height = this.content.clientHeight;
|
|
219
|
+
const y = Math.max(0, event.clientY - start_y);
|
|
220
|
+
let y_percentage = Utils.round(y / height, 2); // needs to be rounder otherwise it always remains at 0.9999 and never reaches the end.
|
|
221
|
+
const computed = window.getComputedStyle(this.content);
|
|
222
|
+
const max_scroll_top = (this.content.scrollHeight -
|
|
223
|
+
this.content.clientHeight +
|
|
224
|
+
parseFloat(computed.paddingTop) +
|
|
225
|
+
parseFloat(computed.paddingBottom));
|
|
226
|
+
const scroll_top = Math.round(max_scroll_top * y_percentage);
|
|
227
|
+
// Set the scroll top.
|
|
228
|
+
this.content.scrollTop = scroll_top; // triggers on scroll which updates the thumb top.
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
// Scroll by clicking on the track.
|
|
232
|
+
this.track.onclick = (event) => {
|
|
233
|
+
// Not scrollable.
|
|
234
|
+
if (!this.is_scrollable()) {
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
// Vars.
|
|
238
|
+
const height = this.content.clientHeight;
|
|
239
|
+
const start_y = this.content.getBoundingClientRect().top + parseFloat(window.getComputedStyle(this.track).marginTop);
|
|
240
|
+
const y = Math.max(0, event.clientY - start_y);
|
|
241
|
+
let y_percentage = Utils.round(y / height, 2); // needs to be rounder otherwise it always remains at 0.9999 and never reaches the end.
|
|
242
|
+
const computed = window.getComputedStyle(this.content);
|
|
243
|
+
const max_scroll_top = (this.content.scrollHeight -
|
|
244
|
+
this.content.clientHeight +
|
|
245
|
+
parseFloat(computed.paddingTop) +
|
|
246
|
+
parseFloat(computed.paddingBottom));
|
|
247
|
+
const scroll_top = Math.round(max_scroll_top * y_percentage);
|
|
248
|
+
// Set the scroll top.
|
|
249
|
+
this.content.scrollTop = scroll_top; // triggers on scroll which updates the thumb top.
|
|
250
|
+
};
|
|
251
|
+
// On alignment check callback.
|
|
252
|
+
// When the alignment is set to not leading, and the content can scroll, then it is temporarily set to leading till the content is no longer scrollable.
|
|
253
|
+
this._h_alignment = undefined;
|
|
254
|
+
this._current_h_alignment = undefined;
|
|
255
|
+
this._v_alignment = undefined;
|
|
256
|
+
this._current_v_alignment = undefined;
|
|
257
|
+
this._alignment_callback_activated = false;
|
|
258
|
+
this._alignment_callback = () => {
|
|
259
|
+
if (this._h_alignment !== undefined) {
|
|
260
|
+
if (this.content.clientWidth >= this.clientWidth) {
|
|
261
|
+
if (this._current_h_alignment !== "normal") {
|
|
262
|
+
super.align_items("normal");
|
|
263
|
+
this._current_h_alignment = "normal";
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
if (this._current_h_alignment !== this._h_alignment) {
|
|
268
|
+
super.align(this._h_alignment);
|
|
269
|
+
this._current_h_alignment = this._h_alignment;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
if (this._v_alignment !== undefined) {
|
|
274
|
+
if (this.content.clientHeight > this.clientHeight) {
|
|
275
|
+
if (this._current_v_alignment !== "normal") {
|
|
276
|
+
super.align_vertical("normal");
|
|
277
|
+
this._current_v_alignment = "normal";
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
if (this._current_v_alignment !== this._v_alignment) {
|
|
282
|
+
super.align_vertical(this._v_alignment);
|
|
283
|
+
this._current_v_alignment = this._v_alignment;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
// Is scrollable.
|
|
290
|
+
is_scrollable() {
|
|
291
|
+
return this.content.scrollHeight > this.content.clientHeight || this.content.scrollWidth > this.content.clientWidth;
|
|
292
|
+
}
|
|
293
|
+
// Set remove children to content.
|
|
294
|
+
remove_children() {
|
|
295
|
+
this.content.inner_html("");
|
|
296
|
+
return this;
|
|
297
|
+
}
|
|
298
|
+
// By default append items to the content.
|
|
299
|
+
append(...children) {
|
|
300
|
+
this.content.append(...children);
|
|
301
|
+
return this;
|
|
302
|
+
}
|
|
303
|
+
// By default get child of the content.
|
|
304
|
+
child(index) {
|
|
305
|
+
return this.content.child(index);
|
|
306
|
+
}
|
|
307
|
+
overflow(value) {
|
|
308
|
+
if (value == null) {
|
|
309
|
+
return this.content.overflow();
|
|
310
|
+
}
|
|
311
|
+
this.content.overflow(value);
|
|
312
|
+
return this;
|
|
313
|
+
}
|
|
314
|
+
overflow_x(value) {
|
|
315
|
+
if (value == null) {
|
|
316
|
+
return this.content.overflow_x();
|
|
317
|
+
}
|
|
318
|
+
this.content.overflow_x(value);
|
|
319
|
+
return this;
|
|
320
|
+
}
|
|
321
|
+
super_overflow_x(value) {
|
|
322
|
+
if (value == null) {
|
|
323
|
+
return super.overflow_x();
|
|
324
|
+
}
|
|
325
|
+
super.overflow_x(value);
|
|
326
|
+
return this;
|
|
327
|
+
}
|
|
328
|
+
overflow_y(value) {
|
|
329
|
+
if (value == null) {
|
|
330
|
+
return this.content.overflow_y();
|
|
331
|
+
}
|
|
332
|
+
this.content.overflow_y(value);
|
|
333
|
+
return this;
|
|
334
|
+
}
|
|
335
|
+
super_overflow_y(value) {
|
|
336
|
+
if (value == null) {
|
|
337
|
+
return super.overflow_y();
|
|
338
|
+
}
|
|
339
|
+
super.overflow_y(value);
|
|
340
|
+
return this;
|
|
341
|
+
}
|
|
342
|
+
// Show the overflow so the scroller no longer scrolls.
|
|
343
|
+
show_overflow() {
|
|
344
|
+
super.overflow("visible");
|
|
345
|
+
this.content.overflow("visible");
|
|
346
|
+
return this;
|
|
347
|
+
}
|
|
348
|
+
// Hide the overflow so the scroller can scrolls.
|
|
349
|
+
hide_overflow() {
|
|
350
|
+
super.overflow("hidden");
|
|
351
|
+
this.content.overflow("auto");
|
|
352
|
+
return this;
|
|
353
|
+
}
|
|
354
|
+
delay(msec) {
|
|
355
|
+
if (msec == null) {
|
|
356
|
+
return this.m_delay;
|
|
357
|
+
}
|
|
358
|
+
this.m_delay = msec;
|
|
359
|
+
return this;
|
|
360
|
+
}
|
|
361
|
+
scroll_top(value) {
|
|
362
|
+
if (value == null) {
|
|
363
|
+
return this._try_parse_float(this.content.scrollTop, this.content.scrollTop);
|
|
364
|
+
}
|
|
365
|
+
this.content.scrollTop = this.pad_numeric(value);
|
|
366
|
+
return this;
|
|
367
|
+
}
|
|
368
|
+
scroll_left(value) {
|
|
369
|
+
if (value == null) {
|
|
370
|
+
return this._try_parse_float(this.content.scrollLeft, this.content.scrollLeft);
|
|
371
|
+
}
|
|
372
|
+
this.content.scrollLeft = this.pad_numeric(value);
|
|
373
|
+
return this;
|
|
374
|
+
}
|
|
375
|
+
// Get the scroll height.
|
|
376
|
+
scroll_height() {
|
|
377
|
+
return this.content.scrollHeight;
|
|
378
|
+
}
|
|
379
|
+
// Get the scroll width.
|
|
380
|
+
scroll_width() {
|
|
381
|
+
return this.content.scrollWidth;
|
|
382
|
+
}
|
|
383
|
+
// @ts-expect-error
|
|
384
|
+
on_scroll(opts_or_callback = { callback: null, delay: null }) {
|
|
385
|
+
if (opts_or_callback == null) {
|
|
386
|
+
return this.on_scroll_callbacks;
|
|
387
|
+
}
|
|
388
|
+
let callback;
|
|
389
|
+
if (Utils.is_func(opts_or_callback)) {
|
|
390
|
+
const element = this;
|
|
391
|
+
callback = (event) => opts_or_callback(element, event);
|
|
392
|
+
this.on_scroll_callbacks.push({ callback, user_callback: opts_or_callback });
|
|
393
|
+
}
|
|
394
|
+
else {
|
|
395
|
+
if (opts_or_callback.delay == null) {
|
|
396
|
+
callback = opts_or_callback.callback;
|
|
397
|
+
}
|
|
398
|
+
else {
|
|
399
|
+
let timer;
|
|
400
|
+
const element = this;
|
|
401
|
+
callback = function (event) {
|
|
402
|
+
clearTimeout(timer);
|
|
403
|
+
setTimeout(() => opts_or_callback.callback(element, event), opts_or_callback.delay);
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
this.on_scroll_callbacks.push({ callback, user_callback: opts_or_callback.callback });
|
|
407
|
+
}
|
|
408
|
+
this.content.addEventListener("scroll", callback);
|
|
409
|
+
return this;
|
|
410
|
+
}
|
|
411
|
+
// Remove a on scroll callback.
|
|
412
|
+
remove_on_scroll(callback) {
|
|
413
|
+
let dropped = [];
|
|
414
|
+
this.on_scroll_callbacks.iterate((item) => {
|
|
415
|
+
if (item.user_callback === callback) {
|
|
416
|
+
this.content.removeEventListener("scroll", item.callback);
|
|
417
|
+
}
|
|
418
|
+
else {
|
|
419
|
+
dropped.push(item);
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
this.on_scroll_callbacks = dropped;
|
|
423
|
+
return this;
|
|
424
|
+
}
|
|
425
|
+
// Small wrapper to set scroll top without triggering a certain on scroll handler.
|
|
426
|
+
set_scroll_top_without_event(top) {
|
|
427
|
+
return this.set_scroll_position_without_event(top);
|
|
428
|
+
}
|
|
429
|
+
// Small wrapper to set scroll left without triggering a certain on scroll handler.
|
|
430
|
+
set_scroll_left_without_event(left) {
|
|
431
|
+
return this.set_scroll_position_without_event(undefined, left);
|
|
432
|
+
}
|
|
433
|
+
// Small wrapper to set scroll top / left without triggering a certain on scroll handler.
|
|
434
|
+
set_scroll_position_without_event(top, left) {
|
|
435
|
+
this.on_scroll_callbacks.iterate((item) => {
|
|
436
|
+
this.content.removeEventListener("scroll", item.callback);
|
|
437
|
+
});
|
|
438
|
+
if (top != null) {
|
|
439
|
+
this.scroll_top(top);
|
|
440
|
+
}
|
|
441
|
+
if (left != null) {
|
|
442
|
+
this.scroll_left(left);
|
|
443
|
+
}
|
|
444
|
+
this.on_scroll_callbacks.iterate((item) => {
|
|
445
|
+
this.content.addEventListener("scroll", item.callback);
|
|
446
|
+
});
|
|
447
|
+
return this;
|
|
448
|
+
}
|
|
449
|
+
align(value) {
|
|
450
|
+
if (value == null) {
|
|
451
|
+
return this._h_alignment ?? "";
|
|
452
|
+
}
|
|
453
|
+
super.align(value);
|
|
454
|
+
this._h_alignment = value;
|
|
455
|
+
if (this._alignment_callback_activated !== true) {
|
|
456
|
+
this._alignment_callback_activated = true;
|
|
457
|
+
this.on_resize(this._alignment_callback);
|
|
458
|
+
this.on_render(this._alignment_callback);
|
|
459
|
+
}
|
|
460
|
+
return this;
|
|
461
|
+
}
|
|
462
|
+
center() {
|
|
463
|
+
this.align("center");
|
|
464
|
+
return this;
|
|
465
|
+
}
|
|
466
|
+
leading() {
|
|
467
|
+
this.align("start");
|
|
468
|
+
return this;
|
|
469
|
+
}
|
|
470
|
+
trailing() {
|
|
471
|
+
this.align("end");
|
|
472
|
+
return this;
|
|
473
|
+
}
|
|
474
|
+
align_vertical(value) {
|
|
475
|
+
if (value == null) {
|
|
476
|
+
return this._v_alignment ?? "";
|
|
477
|
+
}
|
|
478
|
+
super.align_vertical(value);
|
|
479
|
+
this._v_alignment = value;
|
|
480
|
+
if (this._alignment_callback_activated !== true) {
|
|
481
|
+
this._alignment_callback_activated = true;
|
|
482
|
+
this.on_resize(this._alignment_callback);
|
|
483
|
+
this.on_render(this._alignment_callback);
|
|
484
|
+
}
|
|
485
|
+
return this;
|
|
486
|
+
}
|
|
487
|
+
center_vertical() {
|
|
488
|
+
this.align_vertical("center");
|
|
489
|
+
return this;
|
|
490
|
+
}
|
|
491
|
+
leading_vertical() {
|
|
492
|
+
this.align_vertical("start");
|
|
493
|
+
return this;
|
|
494
|
+
}
|
|
495
|
+
trailing_vertical() {
|
|
496
|
+
this.align_vertical("end");
|
|
497
|
+
return this;
|
|
498
|
+
}
|
|
499
|
+
};
|
|
500
|
+
__setFunctionName(_classThis, "ScrollerElement");
|
|
501
|
+
(() => {
|
|
502
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
503
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
504
|
+
ScrollerElement = _classThis = _classDescriptor.value;
|
|
505
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
506
|
+
})();
|
|
507
|
+
_classThis.default_style = {
|
|
508
|
+
"position": "relative", // is required for attribute "track"
|
|
509
|
+
"margin": "0px",
|
|
510
|
+
"padding": "0px",
|
|
511
|
+
// "clear": "both",
|
|
512
|
+
"display": "flex", // to support vertical spacers.
|
|
513
|
+
"overflow": "hidden",
|
|
514
|
+
// "flex": "1", // disabled to support horizontal spacers in VStacks.
|
|
515
|
+
"align-content": "flex-start", // align items at start, do not stretch / space when inside HStack.
|
|
516
|
+
"flex-direction": "column",
|
|
517
|
+
// "text-align": "start",
|
|
518
|
+
"scroll-behavior": "auto",
|
|
519
|
+
"overscroll-behavior": "auto", // relay to parent to resume scroll when local scroll has ended.
|
|
520
|
+
"height": "fit-content", // set height to max compared to parents non overflow, so scrolling can take effect.
|
|
521
|
+
"content-visibility": "auto", // improve rendering.
|
|
522
|
+
// "align-content": "flex-start", // align items at start, do not stretch / space when inside HStack.
|
|
523
|
+
// "align-items": "flex-start", // align items at start, do not stretch / space when inside HStack.
|
|
524
|
+
};
|
|
525
|
+
(() => {
|
|
526
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
527
|
+
})();
|
|
528
|
+
return ScrollerElement = _classThis;
|
|
529
|
+
})();
|
|
530
|
+
export { ScrollerElement };
|
|
531
|
+
export const Scroller = Elements.wrapper(ScrollerElement);
|
|
532
|
+
export const NullScroller = Elements.create_null(ScrollerElement);
|
|
533
|
+
// Scroller.
|
|
534
|
+
/* @docs:
|
|
535
|
+
@nav: Frontend
|
|
536
|
+
@chapter: Elements
|
|
537
|
+
@title: Virtual Scroller
|
|
538
|
+
@experimental: true
|
|
539
|
+
@note: The `VirtualScrollerElement` is also initializable under function `VirtualScroller`.
|
|
540
|
+
@description:
|
|
541
|
+
The virtual scroller element.
|
|
542
|
+
|
|
543
|
+
Can be initialed with function `VirtualScroller()`.
|
|
544
|
+
|
|
545
|
+
After appending children you should call `render()` otherwise the children will only show up after a scroll event.
|
|
546
|
+
|
|
547
|
+
The virtual scroller can work in two ways.
|
|
548
|
+
1) You must set a fixed height for every direct child.
|
|
549
|
+
2) You call the member function `update_heights()` after any height involving edits are made and before you call member function `render()` for the first time.
|
|
550
|
+
@warning: Using content-visibility on the direct or nested children may cause undefined behaviour, it may cause elements to become hidden.
|
|
551
|
+
@warning: Every element must have a fixed height, Unless you use `update_heights()`. Otherwise the rendering will throw an error. Any incorrect heights may cause undefined behaviour.
|
|
552
|
+
@warning: Setting padding on element attribute "content" may cause undefined behaviour.
|
|
553
|
+
@parameter:
|
|
554
|
+
@name: children
|
|
555
|
+
@description: The elements children.
|
|
556
|
+
@type: array[Node]
|
|
557
|
+
*/
|
|
558
|
+
let VirtualScrollerElement = (() => {
|
|
559
|
+
var _a;
|
|
560
|
+
let _classDecorators = [(_a = Elements).register.bind(_a)];
|
|
561
|
+
let _classDescriptor;
|
|
562
|
+
let _classExtraInitializers = [];
|
|
563
|
+
let _classThis;
|
|
564
|
+
let _classSuper = ScrollerElement;
|
|
565
|
+
var VirtualScrollerElement = _classThis = class extends _classSuper {
|
|
566
|
+
// Constructor.
|
|
567
|
+
constructor(...children) {
|
|
568
|
+
// Initialize base class.
|
|
569
|
+
super();
|
|
570
|
+
this._init_derived({ derived: VirtualScrollerElement, });
|
|
571
|
+
// Virtual children.
|
|
572
|
+
this._v_children = [];
|
|
573
|
+
// Attributes.
|
|
574
|
+
this.top_diff = 0;
|
|
575
|
+
this.scroll_top_value = 0;
|
|
576
|
+
this._last_v_children = 0;
|
|
577
|
+
// Append children.
|
|
578
|
+
this.append(...children);
|
|
579
|
+
// The visible container with the scroll dimensions and positioned children inside.
|
|
580
|
+
this.visible_container = VStack()
|
|
581
|
+
.position("relative")
|
|
582
|
+
.overflow_x("visible")
|
|
583
|
+
.overflow_y("hidden")
|
|
584
|
+
.styles({
|
|
585
|
+
"content-visibility": "auto",
|
|
586
|
+
});
|
|
587
|
+
this.content.append(this.visible_container);
|
|
588
|
+
// The height measurer.
|
|
589
|
+
this.height_measurer = Span()
|
|
590
|
+
.visibility("hidden");
|
|
591
|
+
this.content.append(this.height_measurer);
|
|
592
|
+
// Render.
|
|
593
|
+
this.render();
|
|
594
|
+
// Set scroll event listener.
|
|
595
|
+
// @todo set_scroll_top_without event wont work with this new scroll event.
|
|
596
|
+
this.content.addEventListener("scroll", () => this.render());
|
|
597
|
+
}
|
|
598
|
+
// Set default since it inherits HStackElement.
|
|
599
|
+
set_default() {
|
|
600
|
+
return super.set_default(VirtualScrollerElement);
|
|
601
|
+
}
|
|
602
|
+
overflow(value) {
|
|
603
|
+
if (value == null) {
|
|
604
|
+
return this.content.overflow();
|
|
605
|
+
}
|
|
606
|
+
this.content.overflow(value);
|
|
607
|
+
this.visible_container.overflow_x(value.split(" ")[0]);
|
|
608
|
+
return this;
|
|
609
|
+
}
|
|
610
|
+
overflow_x(value) {
|
|
611
|
+
if (value == null) {
|
|
612
|
+
return this.content.overflow_x();
|
|
613
|
+
}
|
|
614
|
+
this.content.overflow_x(value);
|
|
615
|
+
this.visible_container.overflow_x(value);
|
|
616
|
+
return this;
|
|
617
|
+
}
|
|
618
|
+
// keep overflow y on this.visible_container always hidden otherwise it may mess with expanding this.content and cause an infinite scroll event.
|
|
619
|
+
// Set remove children to content.
|
|
620
|
+
remove_children() {
|
|
621
|
+
this._v_children = [];
|
|
622
|
+
this.visible_container.min_height(0);
|
|
623
|
+
this.visible_container.max_height(0);
|
|
624
|
+
this.visible_container.inner_html("");
|
|
625
|
+
return this;
|
|
626
|
+
}
|
|
627
|
+
// Render the visible content.
|
|
628
|
+
render() {
|
|
629
|
+
// Do not use a clearTimeout setTimout structure cause that will cause some elements to be appended too late on a very fast sroll.
|
|
630
|
+
// Get scroll direction.
|
|
631
|
+
const last_scroll_top = this.scroll_top_value;
|
|
632
|
+
this.scroll_top_value = this.content.scrollTop;
|
|
633
|
+
const last_v_children = this._last_v_children;
|
|
634
|
+
this._last_v_children = this._v_children.length;
|
|
635
|
+
let scrolling_down = true;
|
|
636
|
+
if (this.scroll_top_value > last_scroll_top) {
|
|
637
|
+
scrolling_down = true;
|
|
638
|
+
}
|
|
639
|
+
else if (this.scroll_top_value < last_scroll_top) {
|
|
640
|
+
scrolling_down = false;
|
|
641
|
+
}
|
|
642
|
+
// Disable forced behaviour because when height edits are made it should also be updated, but this is easily forgotten by the user.
|
|
643
|
+
// else if (!forced && this.last_v_children == last_v_children) {
|
|
644
|
+
// return null; // horizontal scroll.
|
|
645
|
+
// }
|
|
646
|
+
// Get the start and end y.
|
|
647
|
+
const start_y = this.content.scrollTop;
|
|
648
|
+
const end_y = start_y + this.content.offsetHeight + this.top_diff;
|
|
649
|
+
// Iterate.
|
|
650
|
+
let is_first = true;
|
|
651
|
+
let is_visible = false;
|
|
652
|
+
let total_height = 0;
|
|
653
|
+
let visible_height = 0;
|
|
654
|
+
this._v_children.iterate((child) => {
|
|
655
|
+
// Child vars.
|
|
656
|
+
const height = child.v_height !== undefined ? child.v_height : this.get_height(child);
|
|
657
|
+
if (height == 0) {
|
|
658
|
+
return null; // no fixed height or no height.
|
|
659
|
+
}
|
|
660
|
+
const child_start_y = total_height;
|
|
661
|
+
const child_end_y = total_height + height; // Adjust as needed
|
|
662
|
+
total_height += height;
|
|
663
|
+
// First item.
|
|
664
|
+
if (is_first && child_end_y >= start_y) {
|
|
665
|
+
child.transform(`translateY(${child_start_y}px)`); // also update when still visible but height changes may have been made to an element.
|
|
666
|
+
visible_height += height;
|
|
667
|
+
is_first = false;
|
|
668
|
+
is_visible = true;
|
|
669
|
+
if (!child.rendered) {
|
|
670
|
+
if (scrolling_down) {
|
|
671
|
+
this.visible_container.appendChild(child);
|
|
672
|
+
}
|
|
673
|
+
else {
|
|
674
|
+
this.visible_container.insertBefore(child, this.visible_container.firstChild);
|
|
675
|
+
}
|
|
676
|
+
child.rendered = true;
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
// Last visible element.
|
|
680
|
+
else if (is_visible && child_start_y >= end_y) {
|
|
681
|
+
child.transform(`translateY(${child_start_y - visible_height}px)`); // also update when still visible but height changes may have been made to an element.
|
|
682
|
+
visible_height += height;
|
|
683
|
+
is_visible = false;
|
|
684
|
+
if (!child.rendered) {
|
|
685
|
+
if (scrolling_down) {
|
|
686
|
+
this.visible_container.appendChild(child);
|
|
687
|
+
}
|
|
688
|
+
else {
|
|
689
|
+
this.visible_container.insertBefore(child, this.visible_container.firstChild);
|
|
690
|
+
}
|
|
691
|
+
child.rendered = true;
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
// Visible elements.
|
|
695
|
+
else if (is_visible) {
|
|
696
|
+
child.transform(`translateY(${child_start_y - visible_height}px)`); // also update when still visible but height changes may have been made to an element.
|
|
697
|
+
visible_height += height;
|
|
698
|
+
if (!child.rendered) {
|
|
699
|
+
if (scrolling_down) {
|
|
700
|
+
this.visible_container.appendChild(child);
|
|
701
|
+
}
|
|
702
|
+
else {
|
|
703
|
+
this.visible_container.insertBefore(child, this.visible_container.firstChild);
|
|
704
|
+
}
|
|
705
|
+
child.rendered = true;
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
// Invisible elements.
|
|
709
|
+
else if (child.rendered) {
|
|
710
|
+
child.remove();
|
|
711
|
+
child.rendered = false;
|
|
712
|
+
}
|
|
713
|
+
});
|
|
714
|
+
// Set scroll dimension.
|
|
715
|
+
this.visible_container.min_height(total_height);
|
|
716
|
+
this.visible_container.max_height(total_height);
|
|
717
|
+
// Return this.
|
|
718
|
+
return this;
|
|
719
|
+
}
|
|
720
|
+
// Update heights.
|
|
721
|
+
update_heights() {
|
|
722
|
+
this._v_children.iterate((child) => {
|
|
723
|
+
child.v_height = this.get_height(child, false);
|
|
724
|
+
});
|
|
725
|
+
return this;
|
|
726
|
+
}
|
|
727
|
+
// Update height of a certain child.
|
|
728
|
+
update_height(child) {
|
|
729
|
+
child.v_height = this.get_height(child, false);
|
|
730
|
+
return this;
|
|
731
|
+
}
|
|
732
|
+
// Get the height of an element.
|
|
733
|
+
get_height(element, fixed = true) {
|
|
734
|
+
let height;
|
|
735
|
+
// Get fixed height.
|
|
736
|
+
if (fixed) {
|
|
737
|
+
height = parseFloat(element.style.height);
|
|
738
|
+
if (isNaN(height)) {
|
|
739
|
+
console.error("Every element in the virtual scroller must have a fixed height, ignoring element: " + element);
|
|
740
|
+
element.style.display = "none";
|
|
741
|
+
return 0;
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
// Append to document and get height.
|
|
745
|
+
// Does not require fixed heights but is slow.
|
|
746
|
+
else {
|
|
747
|
+
element.rendered = false; // set rendered to false because this will remove the child from this.visible_container when it was rendered.
|
|
748
|
+
this.height_measurer.appendChild(element);
|
|
749
|
+
height = element.offsetHeight;
|
|
750
|
+
this.height_measurer.removeChild(element);
|
|
751
|
+
}
|
|
752
|
+
// Add margin.
|
|
753
|
+
const margin_top = parseFloat(element.style.marginTop);
|
|
754
|
+
if (!isNaN(margin_top)) {
|
|
755
|
+
height += margin_top;
|
|
756
|
+
}
|
|
757
|
+
const margin_bottom = parseFloat(element.style.marginBottom);
|
|
758
|
+
if (!isNaN(margin_bottom)) {
|
|
759
|
+
height += margin_bottom;
|
|
760
|
+
}
|
|
761
|
+
// Handler.
|
|
762
|
+
return height;
|
|
763
|
+
}
|
|
764
|
+
// Custom append function.
|
|
765
|
+
append(...children) {
|
|
766
|
+
for (let i = 0; i < children.length; i++) {
|
|
767
|
+
const child = children[i];
|
|
768
|
+
if (child != null) {
|
|
769
|
+
// VWeb element.
|
|
770
|
+
if (child.element_type != null) {
|
|
771
|
+
if (child.element_type == "ForEach" ||
|
|
772
|
+
child.element_type == "If" ||
|
|
773
|
+
child.element_type == "IfDeviceWith") {
|
|
774
|
+
child.append_children_to(this);
|
|
775
|
+
}
|
|
776
|
+
else {
|
|
777
|
+
this._v_children.push(child);
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
// Execute function.
|
|
781
|
+
else if (Utils.is_func(child)) {
|
|
782
|
+
this.append(child());
|
|
783
|
+
}
|
|
784
|
+
// Node element.
|
|
785
|
+
else if (child instanceof Node) {
|
|
786
|
+
this._v_children.push(child);
|
|
787
|
+
}
|
|
788
|
+
// Append text.
|
|
789
|
+
else if (Utils.is_string(child)) {
|
|
790
|
+
this._v_children.push(document.createTextNode(child));
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
return this;
|
|
795
|
+
}
|
|
796
|
+
};
|
|
797
|
+
__setFunctionName(_classThis, "VirtualScrollerElement");
|
|
798
|
+
(() => {
|
|
799
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
800
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
801
|
+
VirtualScrollerElement = _classThis = _classDescriptor.value;
|
|
802
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
803
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
804
|
+
})();
|
|
805
|
+
return VirtualScrollerElement = _classThis;
|
|
806
|
+
})();
|
|
807
|
+
export { VirtualScrollerElement };
|
|
808
|
+
export const VirtualScroller = Elements.wrapper(VirtualScrollerElement);
|
|
809
|
+
export const NullVirtualScroller = Elements.create_null(VirtualScrollerElement);
|
|
810
|
+
/* @docs:
|
|
811
|
+
@nav: Frontend
|
|
812
|
+
@chapter: Elements
|
|
813
|
+
@title: Snap Scroller
|
|
814
|
+
@experimental: true
|
|
815
|
+
@note: The `SnapScrollerElement` is also initializable under function `SnapScroller`.
|
|
816
|
+
@description:
|
|
817
|
+
Scrolls the windows per window (snap scrolling).
|
|
818
|
+
|
|
819
|
+
This class is still experimental.
|
|
820
|
+
*/
|
|
821
|
+
let SnapScrollerElement = (() => {
|
|
822
|
+
var _a;
|
|
823
|
+
let _classDecorators = [(_a = Elements).register.bind(_a)];
|
|
824
|
+
let _classDescriptor;
|
|
825
|
+
let _classExtraInitializers = [];
|
|
826
|
+
let _classThis;
|
|
827
|
+
let _classSuper = VStackElement;
|
|
828
|
+
var SnapScrollerElement = _classThis = class extends _classSuper {
|
|
829
|
+
constructor(...children) {
|
|
830
|
+
// Base.
|
|
831
|
+
super();
|
|
832
|
+
this._init_derived({ derived: SnapScrollerElement, });
|
|
833
|
+
// Style.
|
|
834
|
+
this.overflow_y("scroll");
|
|
835
|
+
this.scroll_snap_type("y mandatory");
|
|
836
|
+
// Add children.
|
|
837
|
+
this.append(...children);
|
|
838
|
+
}
|
|
839
|
+
// Append.
|
|
840
|
+
append(...children) {
|
|
841
|
+
for (let i = 0; i < children.length; i++) {
|
|
842
|
+
const win = children[i];
|
|
843
|
+
if (win == null) {
|
|
844
|
+
continue;
|
|
845
|
+
}
|
|
846
|
+
// Style.
|
|
847
|
+
win.min_height("100%");
|
|
848
|
+
// win.scroll_snap_align("start");
|
|
849
|
+
// Set alignment.
|
|
850
|
+
win.on_render((e) => {
|
|
851
|
+
if (win.scrollHeight > this.clientHeight) {
|
|
852
|
+
e.align_vertical("default");
|
|
853
|
+
}
|
|
854
|
+
else {
|
|
855
|
+
e.center_vertical();
|
|
856
|
+
}
|
|
857
|
+
});
|
|
858
|
+
win.on_resize((e) => {
|
|
859
|
+
if (win.scrollHeight > this.clientHeight) {
|
|
860
|
+
e.align_vertical("default");
|
|
861
|
+
}
|
|
862
|
+
else {
|
|
863
|
+
e.center_vertical();
|
|
864
|
+
}
|
|
865
|
+
});
|
|
866
|
+
// Append.
|
|
867
|
+
win.style.height = "100%";
|
|
868
|
+
win.style.minHeight = "100%";
|
|
869
|
+
win.style.maxHeight = "100%";
|
|
870
|
+
win.style.overflowY = "scroll";
|
|
871
|
+
win.style["scroll-snap-align"] = "start";
|
|
872
|
+
super.append(win);
|
|
873
|
+
// const section = document.createElement("section");
|
|
874
|
+
// section.style.height = "100%";
|
|
875
|
+
// section.style.minHeight = "100%";
|
|
876
|
+
// section.style.maxHeight = "100%";
|
|
877
|
+
// section.style.overflowY = "scroll";
|
|
878
|
+
// section.style["scroll-snap-align"] = "start";
|
|
879
|
+
// section.appendChild(win);
|
|
880
|
+
// super.append(section);
|
|
881
|
+
}
|
|
882
|
+
// Response.
|
|
883
|
+
return this;
|
|
884
|
+
}
|
|
885
|
+
// Scroll into child.
|
|
886
|
+
scroll_into_child(index, behaviour = "smooth") {
|
|
887
|
+
this.child(index).scrollIntoView({ behavior: behaviour });
|
|
888
|
+
return this;
|
|
889
|
+
}
|
|
890
|
+
};
|
|
891
|
+
__setFunctionName(_classThis, "SnapScrollerElement");
|
|
892
|
+
(() => {
|
|
893
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
894
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
895
|
+
SnapScrollerElement = _classThis = _classDescriptor.value;
|
|
896
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
897
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
898
|
+
})();
|
|
899
|
+
return SnapScrollerElement = _classThis;
|
|
900
|
+
})();
|
|
901
|
+
export { SnapScrollerElement };
|
|
902
|
+
export const SnapScroller = Elements.wrapper(SnapScrollerElement);
|
|
903
|
+
export const NullSnapScroller = Elements.create_null(SnapScrollerElement);
|
|
904
|
+
// Window Scroller.
|
|
905
|
+
/*
|
|
906
|
+
@constructor_wrapper
|
|
907
|
+
@Elements.register
|
|
908
|
+
class WindowScrollerElement extends Elements.create({
|
|
909
|
+
type: "WindowScroller",
|
|
910
|
+
tag: "div",
|
|
911
|
+
default_style: {
|
|
912
|
+
"margin": "0px",
|
|
913
|
+
"padding": "0px",
|
|
914
|
+
"display": "flex", // to support vertical spacers.
|
|
915
|
+
"overflow": "visible",
|
|
916
|
+
"align-content": "flex-start", // align items at start, do not stretch / space when inside HStack.
|
|
917
|
+
"flex-direction": "column",
|
|
918
|
+
},
|
|
919
|
+
}) {
|
|
920
|
+
constructor({
|
|
921
|
+
duration = 500, // duration of the animation.
|
|
922
|
+
_topbar = null, // can be passed to assign a shadow to an item when the content is scrolling and a shadow should present.
|
|
923
|
+
} = {}) {
|
|
924
|
+
|
|
925
|
+
|
|
926
|
+
// Super.
|
|
927
|
+
super();
|
|
928
|
+
|
|
929
|
+
// Attributes.
|
|
930
|
+
this.duration = duration;
|
|
931
|
+
this.index = 0;
|
|
932
|
+
this.windows = [];
|
|
933
|
+
this.last_scroll_top = 0;
|
|
934
|
+
this.window_scroll_height = 50; // the minimum scroll required to go to the next window.
|
|
935
|
+
|
|
936
|
+
// Styling.
|
|
937
|
+
this.min_width("100%");
|
|
938
|
+
this.stretch(true);
|
|
939
|
+
this.position("relative");
|
|
940
|
+
this.overflow("hidden scroll");
|
|
941
|
+
this.class("hide_scrollbar");
|
|
942
|
+
|
|
943
|
+
// The event that will be called when the window scrolls.
|
|
944
|
+
this.on_animation_scroll = () => {};
|
|
945
|
+
|
|
946
|
+
// @todo update scroll position on resize.
|
|
947
|
+
const _this_ = this;
|
|
948
|
+
this.child_scrolling = false;
|
|
949
|
+
this._child_on_scroll = function (e) {
|
|
950
|
+
|
|
951
|
+
// console.log("Child:", _this_.child_scrolling)
|
|
952
|
+
_this_.child_scrolling = true;
|
|
953
|
+
setTimeout(() => {_this_.child_scrolling = false}, 250)
|
|
954
|
+
|
|
955
|
+
// Set top bar shadow.
|
|
956
|
+
if (_topbar != null) {
|
|
957
|
+
if (this.scrollTop > 0 && _topbar.has_shadow !== true) {
|
|
958
|
+
_topbar.has_shadow = true;
|
|
959
|
+
_topbar.shadow("0px 0px 10px #000000")
|
|
960
|
+
} else if (this.scrollTop === 0 && _topbar.has_shadow === true) {
|
|
961
|
+
_topbar.has_shadow = false;
|
|
962
|
+
_topbar.shadow("none")
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
// Relay scroll when the child can no longer scroll.
|
|
967
|
+
if (this.scrollTop === 0) {
|
|
968
|
+
_this_.scrollTop = (_this_.index - 1) * _this_.window_scroll_height;
|
|
969
|
+
} else if (this.scrollTop + this.clientHeight >= this.scrollHeight) {
|
|
970
|
+
_this_.scrollTop = (_this_.index + 1) * _this_.window_scroll_height;
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
// On wheel event.
|
|
975
|
+
const _on_scroll_callback = (e) => {
|
|
976
|
+
|
|
977
|
+
// Prevent default on already animating.
|
|
978
|
+
// console.log("Parent:", _this_.child_scrolling)
|
|
979
|
+
if (this.animating === true || _this_.child_scrolling) {
|
|
980
|
+
e.preventDefault();
|
|
981
|
+
return ;
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
// Vars.
|
|
985
|
+
const win = this.windows[this.index];
|
|
986
|
+
const scroll_top = this.scrollTop;
|
|
987
|
+
const height = this.clientHeight;
|
|
988
|
+
const scroll_up = this.scrollTop > this.last_scroll_top;
|
|
989
|
+
this.last_scroll_top = scroll_top;
|
|
990
|
+
|
|
991
|
+
// Set top bar shadow.
|
|
992
|
+
if (_topbar != null) {
|
|
993
|
+
if (win.scrollTop > 0 && _topbar.has_shadow !== true) {
|
|
994
|
+
_topbar.has_shadow = true;
|
|
995
|
+
_topbar.shadow("0px 0px 10px #000000")
|
|
996
|
+
} else if (win.scrollTop === 0 && _topbar.has_shadow === true) {
|
|
997
|
+
setTimeout(() => {
|
|
998
|
+
_topbar.has_shadow = false;
|
|
999
|
+
_topbar.shadow("none")
|
|
1000
|
+
}, this.duration) // must be the at least the duration of window transition.
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
// Prevent default on max scroll height.
|
|
1005
|
+
if (scroll_top > this.windows.length * this.window_scroll_height) {
|
|
1006
|
+
this.scrollTop = this.windows.length * this.window_scroll_height;
|
|
1007
|
+
e.stopPropagation();
|
|
1008
|
+
e.preventDefault();
|
|
1009
|
+
return null;
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
// Next or previous.
|
|
1013
|
+
// Skip when the child is not fully scroller.
|
|
1014
|
+
if (
|
|
1015
|
+
(win.scrollTop + win.clientHeight >= win.scrollHeight) ||
|
|
1016
|
+
(win.scrollTop === 0)
|
|
1017
|
+
) {
|
|
1018
|
+
|
|
1019
|
+
// Check views.
|
|
1020
|
+
const scroll_index = parseInt(scroll_top / this.window_scroll_height);
|
|
1021
|
+
const stop_animating = () => {
|
|
1022
|
+
setTimeout(() => {
|
|
1023
|
+
this.animating = false;
|
|
1024
|
+
this.scrollTop = this.index * this.window_scroll_height;
|
|
1025
|
+
}, 250)
|
|
1026
|
+
}
|
|
1027
|
+
if (scroll_index > this.index) {
|
|
1028
|
+
this.animating = true;
|
|
1029
|
+
e.preventDefault();
|
|
1030
|
+
this.next(scroll_index, false)
|
|
1031
|
+
.then(stop_animating)
|
|
1032
|
+
.catch(stop_animating)
|
|
1033
|
+
this.scrollTop = this.index * this.window_scroll_height;
|
|
1034
|
+
} else if (scroll_index < this.index) {
|
|
1035
|
+
this.animating = true;
|
|
1036
|
+
e.preventDefault();
|
|
1037
|
+
this.prev(scroll_index, false)
|
|
1038
|
+
.then(stop_animating)
|
|
1039
|
+
.catch(stop_animating)
|
|
1040
|
+
this.scrollTop = this.index * this.window_scroll_height;
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
// Add event listener.
|
|
1048
|
+
this.addEventListener("scroll", _on_scroll_callback, { passive: false });
|
|
1049
|
+
|
|
1050
|
+
// Add the on hash change listener for any direct children id's.
|
|
1051
|
+
window.addEventListener("hashchange", (e) => {
|
|
1052
|
+
const hash = window.location.hash.substr(1);
|
|
1053
|
+
if (hash != null && hash !== "") {
|
|
1054
|
+
this.windows.iterate((win) => {
|
|
1055
|
+
if (hash === win.id()) {
|
|
1056
|
+
console.log("Select", win.id())
|
|
1057
|
+
if (win.index > this.index) {
|
|
1058
|
+
this.next(win.index, true);
|
|
1059
|
+
} else {
|
|
1060
|
+
this.prev(win.index, true);
|
|
1061
|
+
}
|
|
1062
|
+
return false;
|
|
1063
|
+
}
|
|
1064
|
+
})
|
|
1065
|
+
// window.location.hash = ""; // reset the hash so that when the user clicks the hash button again it is rerendered.
|
|
1066
|
+
}
|
|
1067
|
+
})
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
|
|
1071
|
+
// Add a window.
|
|
1072
|
+
append(win) {
|
|
1073
|
+
|
|
1074
|
+
// Update window.
|
|
1075
|
+
win.transition(`opacity ${this.duration*2}ms, transform ${this.duration}ms ease`)
|
|
1076
|
+
win.fixed_frame("100%", "100%");
|
|
1077
|
+
win.position(0, 0, 0, 0);
|
|
1078
|
+
win.position("sticky");
|
|
1079
|
+
win.overflow("scroll");
|
|
1080
|
+
win.overscroll_behavior("bounce"); // must be bounce so the on scroll event is also called when the user scrolls up and the page is already scrolled all the way up.
|
|
1081
|
+
// win.align("default"); // must start with leading for checks will be centered later
|
|
1082
|
+
win.align_vertical("default"); // must start with leading for checks will be centered later
|
|
1083
|
+
win.addEventListener("scroll", this._child_on_scroll);
|
|
1084
|
+
win.outline("none"); // otherwise an outline border may appear while scrolling windows.
|
|
1085
|
+
win.border("none"); // otherwise an outline border may appear while scrolling windows.
|
|
1086
|
+
win.center();
|
|
1087
|
+
|
|
1088
|
+
// Add scroll forwarder.
|
|
1089
|
+
|
|
1090
|
+
// Initial window.
|
|
1091
|
+
if (this.windows.length > 0) {
|
|
1092
|
+
win.transform("translateY(100%)")
|
|
1093
|
+
win.opacity(0)
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
// Other windows.
|
|
1097
|
+
else {
|
|
1098
|
+
win.transform("translateY(0)")
|
|
1099
|
+
win.opacity(1)
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
// Set alignment.
|
|
1103
|
+
win.on_render((e) => {
|
|
1104
|
+
// Setting horizontal align causes issues with slide in animations.
|
|
1105
|
+
// setTimeout(() => {
|
|
1106
|
+
// const width = this.clientWidth;
|
|
1107
|
+
// const width = e.clientWidth;
|
|
1108
|
+
// if (e.scrollWidth > width) {
|
|
1109
|
+
// console.log(e.scrollWidth, width, "default", win.child(0).text().substr(0, 10))
|
|
1110
|
+
// e.align("default");
|
|
1111
|
+
// } else {
|
|
1112
|
+
// console.log(e.scrollWidth, width, "center", win.child(0).text().substr(0, 10))
|
|
1113
|
+
// e.center();
|
|
1114
|
+
// }
|
|
1115
|
+
if (win.scrollHeight > this.clientHeight) {
|
|
1116
|
+
e.align_vertical("default");
|
|
1117
|
+
} else {
|
|
1118
|
+
e.center_vertical();
|
|
1119
|
+
}
|
|
1120
|
+
})
|
|
1121
|
+
win.on_resize((e) => {
|
|
1122
|
+
if (win.scrollHeight > this.clientHeight) {
|
|
1123
|
+
e.align_vertical("default");
|
|
1124
|
+
} else {
|
|
1125
|
+
e.center_vertical();
|
|
1126
|
+
}
|
|
1127
|
+
})
|
|
1128
|
+
|
|
1129
|
+
// Append.
|
|
1130
|
+
win.index = this.windows.length;
|
|
1131
|
+
this.windows.push(win);
|
|
1132
|
+
super.append(win);
|
|
1133
|
+
|
|
1134
|
+
// Check if the href hash is set on this windows id.
|
|
1135
|
+
const hash = window.location.hash.substr(1);
|
|
1136
|
+
if (hash != null && hash !== "" && hash === win.id()) {
|
|
1137
|
+
this.on_render(() => {
|
|
1138
|
+
this.next(win.index, true);
|
|
1139
|
+
})
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
|
|
1143
|
+
// response.
|
|
1144
|
+
return this;
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
// Next window.
|
|
1148
|
+
async next(index, update_scroll_top = true) {
|
|
1149
|
+
return new Promise(async (resolve) => {
|
|
1150
|
+
if (index < this.windows.length) {
|
|
1151
|
+
|
|
1152
|
+
// Update scroll top.
|
|
1153
|
+
if (update_scroll_top) {
|
|
1154
|
+
this.scrollTop = this.window_scroll_height * index;
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
// Slide out.
|
|
1158
|
+
const current = this.windows[this.index];
|
|
1159
|
+
current.style.opacity = 0;
|
|
1160
|
+
current.style.transform = 'translateY(-100%)';
|
|
1161
|
+
|
|
1162
|
+
// Update index.
|
|
1163
|
+
this.index = index;
|
|
1164
|
+
|
|
1165
|
+
// Slide in.
|
|
1166
|
+
const next = this.windows[this.index];
|
|
1167
|
+
if (next.is_scrollable()) {
|
|
1168
|
+
next.leading_vertical()
|
|
1169
|
+
} else {
|
|
1170
|
+
next.center_vertical()
|
|
1171
|
+
}
|
|
1172
|
+
next.scrollTop = 0;
|
|
1173
|
+
next.style.opacity = 1;
|
|
1174
|
+
next.style.transform = 'translateY(0)';
|
|
1175
|
+
next.scrollTop = 0; // required since sometimes it does not start at the start or end, which requires the user to scroll up and down before it can scroll to the next window.
|
|
1176
|
+
|
|
1177
|
+
// Call on appear on children.
|
|
1178
|
+
if (Array.isArray(next._on_appear_callbacks)) {
|
|
1179
|
+
let promises = [];
|
|
1180
|
+
for (let i = 0; i < next._on_appear_callbacks.length; i++) {
|
|
1181
|
+
const res = next._on_appear_callbacks[i].exec()
|
|
1182
|
+
if (res instanceof Promise) {
|
|
1183
|
+
promises.push(res);
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
await Promise.all(promises);
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
// Resolve.
|
|
1190
|
+
setTimeout(resolve, this.duration);
|
|
1191
|
+
}
|
|
1192
|
+
else {
|
|
1193
|
+
resolve();
|
|
1194
|
+
}
|
|
1195
|
+
});
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
// Previous window.
|
|
1199
|
+
async prev(index, update_scroll_top = true) {
|
|
1200
|
+
return new Promise(async (resolve) => {
|
|
1201
|
+
const old_index = this.index;
|
|
1202
|
+
if (index >= 0) {
|
|
1203
|
+
|
|
1204
|
+
// Update scroll top.
|
|
1205
|
+
if (update_scroll_top) {
|
|
1206
|
+
this.scrollTop = this.window_scroll_height * index;
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
// Slide out.
|
|
1210
|
+
const current = this.windows[this.index];
|
|
1211
|
+
current.style.opacity = 0;
|
|
1212
|
+
current.style.transform = 'translateY(100%)';
|
|
1213
|
+
|
|
1214
|
+
// Update index.
|
|
1215
|
+
this.index = index;
|
|
1216
|
+
|
|
1217
|
+
// Slide in.
|
|
1218
|
+
const next = this.windows[this.index];
|
|
1219
|
+
if (next.is_scrollable()) {
|
|
1220
|
+
next.leading_vertical()
|
|
1221
|
+
} else {
|
|
1222
|
+
next.center_vertical()
|
|
1223
|
+
}
|
|
1224
|
+
next.scrollTop = next.scrollHeight;
|
|
1225
|
+
next.style.opacity = 1;
|
|
1226
|
+
next.style.transform = 'translateY(0)';
|
|
1227
|
+
next.scrollTop = next.scrollHeight; // required since sometimes it does not start at the start or end, which requires the user to scroll up and down before it can scroll to the next window.
|
|
1228
|
+
|
|
1229
|
+
// Call on appear on children.
|
|
1230
|
+
if (Array.isArray(next._on_appear_callbacks)) {
|
|
1231
|
+
let promises = [];
|
|
1232
|
+
for (let i = 0; i < next._on_appear_callbacks.length; i++) {
|
|
1233
|
+
const res = next._on_appear_callbacks[i].exec()
|
|
1234
|
+
if (res instanceof Promise) {
|
|
1235
|
+
promises.push(res);
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
await Promise.all(promises);
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
// Resolve.
|
|
1242
|
+
setTimeout(resolve, this.duration);
|
|
1243
|
+
}
|
|
1244
|
+
else {
|
|
1245
|
+
resolve();
|
|
1246
|
+
}
|
|
1247
|
+
});
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
}
|
|
1251
|
+
*/
|