@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,1324 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Author: Daan van den Bergh
|
|
3
|
+
* Copyright: © 2022 - 2024 Daan van den Bergh.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// Imports.
|
|
7
|
+
import { Elements, VElementTagMap } from "../elements/module.js"
|
|
8
|
+
import { Utils } from "../modules/utils.js"
|
|
9
|
+
import { Span } from "./span"
|
|
10
|
+
import { VStack, VStackElement } from "./stack"
|
|
11
|
+
|
|
12
|
+
// @todo convert to TS
|
|
13
|
+
|
|
14
|
+
type OnScrollCallback = ((element: ScrollerElement, event: Event) => any);
|
|
15
|
+
interface ScrollCallbackItem {
|
|
16
|
+
callback: (event: Event) => any;
|
|
17
|
+
user_callback: OnScrollCallback;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Scroller.
|
|
21
|
+
// - 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 = {
|
|
26
|
+
"position": "relative", // is required for attribute "track"
|
|
27
|
+
"margin": "0px",
|
|
28
|
+
"padding": "0px",
|
|
29
|
+
// "clear": "both",
|
|
30
|
+
"display": "flex", // to support vertical spacers.
|
|
31
|
+
"overflow": "hidden",
|
|
32
|
+
// "flex": "1", // disabled to support horizontal spacers in VStacks.
|
|
33
|
+
"align-content": "flex-start", // align items at start, do not stretch / space when inside HStack.
|
|
34
|
+
"flex-direction": "column",
|
|
35
|
+
// "text-align": "start",
|
|
36
|
+
"scroll-behavior": "auto",
|
|
37
|
+
"overscroll-behavior": "auto", // relay to parent to resume scroll when local scroll has ended.
|
|
38
|
+
"height": "fit-content", // set height to max compared to parents non overflow, so scrolling can take effect.
|
|
39
|
+
"content-visibility": "auto", // improve rendering.
|
|
40
|
+
// "align-content": "flex-start", // align items at start, do not stretch / space when inside HStack.
|
|
41
|
+
// "align-items": "flex-start", // align items at start, do not stretch / space when inside HStack.
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// @ts-expect-error
|
|
45
|
+
public content: VStackElement;
|
|
46
|
+
public thumb: VStackElement & { dragging: boolean };
|
|
47
|
+
public track: VStackElement & { __background_value__?: string };
|
|
48
|
+
|
|
49
|
+
public on_scroll_callbacks: ScrollCallbackItem[];
|
|
50
|
+
public iterate: (start: number | ((child: any, index: number) => any), end?: number, handler?: (child: any, index: number) => any) => any;
|
|
51
|
+
public iterate_nodes: (start: number | ((node: any, index: number) => any), end?: number, handler?: (node: any, index: number) => any) => any;
|
|
52
|
+
public m_delay: number;
|
|
53
|
+
|
|
54
|
+
public _h_alignment?: string;
|
|
55
|
+
public _current_h_alignment?: string;
|
|
56
|
+
public _v_alignment?: string;
|
|
57
|
+
public _current_v_alignment?: string;
|
|
58
|
+
public _alignment_callback_activated: boolean;
|
|
59
|
+
public _alignment_callback: any;
|
|
60
|
+
public _fadeout_timeout: any;
|
|
61
|
+
|
|
62
|
+
// Constructor.
|
|
63
|
+
constructor(...children: any[]) {
|
|
64
|
+
|
|
65
|
+
// Initialize base class.
|
|
66
|
+
super({
|
|
67
|
+
derived: ScrollerElement,
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// Style.
|
|
71
|
+
if (this.position() != "absolute") {
|
|
72
|
+
this.position("relative"); // is required for attribute "track"
|
|
73
|
+
}
|
|
74
|
+
super.overflow("hidden"); // should always be hidden to enable scrolling, and otherwise the thumb not be visible due to overflow width.
|
|
75
|
+
this.class("hide_scrollbar")
|
|
76
|
+
this.styles({
|
|
77
|
+
"content-visibility": "auto",
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
// Content.
|
|
81
|
+
this.content = VStack(...children)
|
|
82
|
+
.parent(this)
|
|
83
|
+
.class("hide_scrollbar")
|
|
84
|
+
.position("relative") // in case it has absolute children that should scroll, otherwise the content wont scroll without "relative".
|
|
85
|
+
.frame("100%", "100%")
|
|
86
|
+
.flex("1 1 0") // flex-basis 0 otherwise it expands its parent.
|
|
87
|
+
.overflow("scroll")
|
|
88
|
+
.overscroll_behavior(ScrollerElement.default_style["overscroll-behavior"])
|
|
89
|
+
.styles({
|
|
90
|
+
"content-visibility": "auto",
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
// Scroll bar.
|
|
94
|
+
this.thumb = VStack<{ dragging: boolean }>()
|
|
95
|
+
.parent(this)
|
|
96
|
+
.position(0, 0, null, 0)
|
|
97
|
+
.height(30)
|
|
98
|
+
.border_radius(10)
|
|
99
|
+
.overflow("visible") // for thumb shadow.
|
|
100
|
+
.background_color("#CCCCCC")
|
|
101
|
+
.opacity(0)
|
|
102
|
+
.transition("opacity 0.3s linear")
|
|
103
|
+
.box_shadow("0px 0px 5px #00000005")
|
|
104
|
+
this.track = VStack<{ __background_value__?: string }>(this.thumb)
|
|
105
|
+
.parent(this)
|
|
106
|
+
.class("hide_scrollbar")
|
|
107
|
+
.position(5, 5, 5, null)
|
|
108
|
+
.width(10)
|
|
109
|
+
.background_color("transparent")
|
|
110
|
+
.border_radius(10)
|
|
111
|
+
.transition("background-color 0.3s linear")
|
|
112
|
+
.assign("background_value", "#28292E")
|
|
113
|
+
.overflow("visible")
|
|
114
|
+
|
|
115
|
+
// Add children.
|
|
116
|
+
super.append(this.content, this.track);
|
|
117
|
+
|
|
118
|
+
// The on scroll callbacks.
|
|
119
|
+
this.on_scroll_callbacks = [];
|
|
120
|
+
|
|
121
|
+
// Alias functions.
|
|
122
|
+
// this.raw_append = super.append.bind(super);
|
|
123
|
+
this.iterate = this.content.iterate.bind(this.content);
|
|
124
|
+
this.iterate_nodes = this.content.iterate_nodes.bind(this.content);
|
|
125
|
+
|
|
126
|
+
// Set default delay.
|
|
127
|
+
this.m_delay = 1000;
|
|
128
|
+
|
|
129
|
+
// Overwrite track background functions to keep the background color.
|
|
130
|
+
// this.track.__background__ = this.track.background;
|
|
131
|
+
// this.track.__background_color__ = this.background_color;
|
|
132
|
+
(this.track as any).background = function(this, value) {
|
|
133
|
+
if (value == null) {
|
|
134
|
+
return this.__background_value__ ?? "";
|
|
135
|
+
}
|
|
136
|
+
this.__background_value__ = value;
|
|
137
|
+
return this;
|
|
138
|
+
};
|
|
139
|
+
(this.track as any).background_color = function(this, value) {
|
|
140
|
+
if (value == null) {
|
|
141
|
+
return this.__background_value__ ?? "";
|
|
142
|
+
}
|
|
143
|
+
this.__background_value__ = value;
|
|
144
|
+
return this;
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
// Mouse enter event.
|
|
148
|
+
this.track.addEventListener("mouseenter", (event) => {
|
|
149
|
+
if (!this.is_scrollable()) {
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
this.track.style.backgroundColor = this.track.__background_value__ as string;
|
|
153
|
+
clearTimeout(this._fadeout_timeout);
|
|
154
|
+
this.thumb.style.opacity = "1"; // keep as opacity for box shadow.
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
// Mouse leave event.
|
|
158
|
+
this.track.addEventListener("mouseleave", (event) => {
|
|
159
|
+
if (!this.is_scrollable()) {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
if (!this.thumb.dragging) {
|
|
163
|
+
this.track.style.backgroundColor = "transparent";
|
|
164
|
+
this.thumb.style.opacity = "0"; // keep as opacity for box shadow.
|
|
165
|
+
}
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
// Scroll event.
|
|
169
|
+
this.content.addEventListener("scroll", (event) => {
|
|
170
|
+
|
|
171
|
+
// Calculate thumb offset.
|
|
172
|
+
const height = this.content.clientHeight;
|
|
173
|
+
const relative_height = this.track.clientHeight; //this.content.clientHeight;
|
|
174
|
+
const thumb_height = this.thumb.clientHeight;
|
|
175
|
+
const scroll_height = this.content.scrollHeight;
|
|
176
|
+
const scroll_top = this.content.scrollTop;
|
|
177
|
+
let relative_top;
|
|
178
|
+
if (scroll_top >= scroll_height - height) {
|
|
179
|
+
relative_top = relative_height - thumb_height;
|
|
180
|
+
} else {
|
|
181
|
+
relative_top = relative_height * (scroll_top / (scroll_height - height)) - thumb_height / 2;
|
|
182
|
+
if (relative_top + thumb_height >= relative_height) {
|
|
183
|
+
relative_top = relative_height - thumb_height - 3;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
if (relative_top < 0) {
|
|
187
|
+
relative_top = 0;
|
|
188
|
+
}
|
|
189
|
+
this.thumb.style.transform = `translateY(${relative_top}px)`;
|
|
190
|
+
|
|
191
|
+
// Fade in.
|
|
192
|
+
// this.track.style.backgroundColor = this.track.__background_value__;
|
|
193
|
+
clearTimeout(this._fadeout_timeout);
|
|
194
|
+
this.thumb.style.opacity = "1";
|
|
195
|
+
|
|
196
|
+
// Fade out.
|
|
197
|
+
clearTimeout(this._fadeout_timeout);
|
|
198
|
+
this._fadeout_timeout = setTimeout(() => {
|
|
199
|
+
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.
|
|
200
|
+
this.thumb.style.opacity = "0";
|
|
201
|
+
}, this.m_delay)
|
|
202
|
+
})
|
|
203
|
+
|
|
204
|
+
// Set scroll by dragging thumb.
|
|
205
|
+
let start_y, old_user_select;
|
|
206
|
+
const mouse_up_handler = (event) => {
|
|
207
|
+
|
|
208
|
+
// No longer dragging.
|
|
209
|
+
this.thumb.dragging = false;
|
|
210
|
+
|
|
211
|
+
// Restore user select.
|
|
212
|
+
this.style.userSelect = old_user_select;
|
|
213
|
+
|
|
214
|
+
// Remove handler.
|
|
215
|
+
document.body.removeEventListener("mouseup", mouse_up_handler);
|
|
216
|
+
|
|
217
|
+
};
|
|
218
|
+
this.thumb.onmousedown = (event) => {
|
|
219
|
+
|
|
220
|
+
// Not scrollable.
|
|
221
|
+
if (!this.is_scrollable()) {
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// Set start y.
|
|
226
|
+
start_y = this.content.getBoundingClientRect().top + parseFloat(window.getComputedStyle(this.track as any).marginTop);
|
|
227
|
+
|
|
228
|
+
// Set user select.
|
|
229
|
+
// Should be set on "this" on "this.content" does not work correctly.
|
|
230
|
+
old_user_select = this.content.style.userSelect;
|
|
231
|
+
this.style.userSelect = "none";
|
|
232
|
+
|
|
233
|
+
// Set dragging.
|
|
234
|
+
this.thumb.dragging = true;
|
|
235
|
+
|
|
236
|
+
// Show track.
|
|
237
|
+
this.track.style.backgroundColor = this.track.__background_value__ as string;
|
|
238
|
+
clearTimeout(this._fadeout_timeout);
|
|
239
|
+
this.thumb.style.opacity = "1"; // keep as opacity for box shadow.
|
|
240
|
+
|
|
241
|
+
// Add mouse up handler to body.
|
|
242
|
+
document.body.addEventListener("mouseup", mouse_up_handler);
|
|
243
|
+
|
|
244
|
+
}
|
|
245
|
+
this.addEventListener("mousemove", (event) => {
|
|
246
|
+
if (this.thumb.dragging) {
|
|
247
|
+
|
|
248
|
+
// Vars.
|
|
249
|
+
const height = this.content.clientHeight;
|
|
250
|
+
const y = Math.max(0, (event as any).clientY - start_y);
|
|
251
|
+
let y_percentage = Utils.round(y / height, 2); // needs to be rounder otherwise it always remains at 0.9999 and never reaches the end.
|
|
252
|
+
const computed = window.getComputedStyle(this.content as any);
|
|
253
|
+
const max_scroll_top = (
|
|
254
|
+
this.content.scrollHeight -
|
|
255
|
+
this.content.clientHeight +
|
|
256
|
+
parseFloat(computed.paddingTop) +
|
|
257
|
+
parseFloat(computed.paddingBottom)
|
|
258
|
+
);
|
|
259
|
+
const scroll_top = Math.round(max_scroll_top * y_percentage);
|
|
260
|
+
|
|
261
|
+
// Set the scroll top.
|
|
262
|
+
this.content.scrollTop = scroll_top; // triggers on scroll which updates the thumb top.
|
|
263
|
+
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
// Scroll by clicking on the track.
|
|
268
|
+
this.track.onclick = (event) => {
|
|
269
|
+
|
|
270
|
+
// Not scrollable.
|
|
271
|
+
if (!this.is_scrollable()) {
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// Vars.
|
|
276
|
+
const height = this.content.clientHeight;
|
|
277
|
+
const start_y = this.content.getBoundingClientRect().top + parseFloat(window.getComputedStyle(this.track as any).marginTop);
|
|
278
|
+
const y = Math.max(0, event.clientY - start_y);
|
|
279
|
+
let y_percentage = Utils.round(y / height, 2); // needs to be rounder otherwise it always remains at 0.9999 and never reaches the end.
|
|
280
|
+
const computed = window.getComputedStyle(this.content as any);
|
|
281
|
+
const max_scroll_top = (
|
|
282
|
+
this.content.scrollHeight -
|
|
283
|
+
this.content.clientHeight +
|
|
284
|
+
parseFloat(computed.paddingTop) +
|
|
285
|
+
parseFloat(computed.paddingBottom)
|
|
286
|
+
);
|
|
287
|
+
const scroll_top = Math.round(max_scroll_top * y_percentage);
|
|
288
|
+
|
|
289
|
+
// Set the scroll top.
|
|
290
|
+
this.content.scrollTop = scroll_top; // triggers on scroll which updates the thumb top.
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
// On alignment check callback.
|
|
294
|
+
// 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.
|
|
295
|
+
this._h_alignment = undefined;
|
|
296
|
+
this._current_h_alignment = undefined;
|
|
297
|
+
this._v_alignment = undefined;
|
|
298
|
+
this._current_v_alignment = undefined;
|
|
299
|
+
this._alignment_callback_activated = false;
|
|
300
|
+
this._alignment_callback = () => {
|
|
301
|
+
if (this._h_alignment !== undefined) {
|
|
302
|
+
if (this.content.clientWidth >= this.clientWidth) {
|
|
303
|
+
if (this._current_h_alignment !== "normal") {
|
|
304
|
+
super.align_items("normal");
|
|
305
|
+
this._current_h_alignment = "normal";
|
|
306
|
+
}
|
|
307
|
+
} else {
|
|
308
|
+
if (this._current_h_alignment !== this._h_alignment) {
|
|
309
|
+
super.align(this._h_alignment);
|
|
310
|
+
this._current_h_alignment = this._h_alignment;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
if (this._v_alignment !== undefined) {
|
|
315
|
+
if (this.content.clientHeight > this.clientHeight) {
|
|
316
|
+
if (this._current_v_alignment !== "normal") {
|
|
317
|
+
super.align_vertical("normal");
|
|
318
|
+
this._current_v_alignment = "normal";
|
|
319
|
+
}
|
|
320
|
+
} else {
|
|
321
|
+
if (this._current_v_alignment !== this._v_alignment) {
|
|
322
|
+
super.align_vertical(this._v_alignment);
|
|
323
|
+
this._current_v_alignment = this._v_alignment;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// Is scrollable.
|
|
332
|
+
is_scrollable(): boolean {
|
|
333
|
+
return this.content.scrollHeight > this.content.clientHeight || this.content.scrollWidth > this.content.clientWidth;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// Set remove children to content.
|
|
337
|
+
remove_children(): this {
|
|
338
|
+
this.content.inner_html("");
|
|
339
|
+
return this;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// By default append items to the content.
|
|
343
|
+
append(...children: any): this {
|
|
344
|
+
this.content.append(...children);
|
|
345
|
+
return this;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// By default get child of the content.
|
|
349
|
+
child(index: number): any {
|
|
350
|
+
return this.content.child(index);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
// Replace overflow.
|
|
354
|
+
overflow(): string;
|
|
355
|
+
overflow(value: string): this;
|
|
356
|
+
overflow(value?: string): string | this {
|
|
357
|
+
if (value == null) {
|
|
358
|
+
return this.content.overflow();
|
|
359
|
+
}
|
|
360
|
+
this.content.overflow(value);
|
|
361
|
+
return this;
|
|
362
|
+
}
|
|
363
|
+
overflow_x(): string;
|
|
364
|
+
overflow_x(value: string): this;
|
|
365
|
+
overflow_x(value?: string): string | this {
|
|
366
|
+
if (value == null) {
|
|
367
|
+
return this.content.overflow_x();
|
|
368
|
+
}
|
|
369
|
+
this.content.overflow_x(value);
|
|
370
|
+
return this;
|
|
371
|
+
}
|
|
372
|
+
super_overflow_x(): string;
|
|
373
|
+
super_overflow_x(value: string): this;
|
|
374
|
+
super_overflow_x(value?: string): string | this {
|
|
375
|
+
if (value == null) {
|
|
376
|
+
return super.overflow_x();
|
|
377
|
+
}
|
|
378
|
+
super.overflow_x(value);
|
|
379
|
+
return this;
|
|
380
|
+
}
|
|
381
|
+
overflow_y(): string;
|
|
382
|
+
overflow_y(value: string): this;
|
|
383
|
+
overflow_y(value?: string): string | this {
|
|
384
|
+
if (value == null) {
|
|
385
|
+
return this.content.overflow_y();
|
|
386
|
+
}
|
|
387
|
+
this.content.overflow_y(value);
|
|
388
|
+
return this;
|
|
389
|
+
}
|
|
390
|
+
super_overflow_y(): string;
|
|
391
|
+
super_overflow_y(value: string): this;
|
|
392
|
+
super_overflow_y(value?: string): string | this {
|
|
393
|
+
if (value == null) {
|
|
394
|
+
return super.overflow_y();
|
|
395
|
+
}
|
|
396
|
+
super.overflow_y(value);
|
|
397
|
+
return this;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// Show the overflow so the scroller no longer scrolls.
|
|
401
|
+
show_overflow(): this {
|
|
402
|
+
super.overflow("visible");
|
|
403
|
+
this.content.overflow("visible");
|
|
404
|
+
return this;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// Hide the overflow so the scroller can scrolls.
|
|
408
|
+
hide_overflow(): this {
|
|
409
|
+
super.overflow("hidden");
|
|
410
|
+
this.content.overflow("auto");
|
|
411
|
+
return this;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
// Set the opactiy delay when finished scrolling.
|
|
415
|
+
delay(): number;
|
|
416
|
+
delay(msec: number): this;
|
|
417
|
+
delay(msec?: number): number | this {
|
|
418
|
+
if (msec == null) {
|
|
419
|
+
return this.m_delay;
|
|
420
|
+
}
|
|
421
|
+
this.m_delay = msec;
|
|
422
|
+
return this;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
// Get the scroll top.
|
|
426
|
+
scroll_top(): number | string;
|
|
427
|
+
scroll_top(value: number | string): this;
|
|
428
|
+
scroll_top(value?: number | string): number | string | this {
|
|
429
|
+
if (value == null) {
|
|
430
|
+
return this._try_parse_float(this.content.scrollTop, this.content.scrollTop);
|
|
431
|
+
}
|
|
432
|
+
this.content.scrollTop = this.pad_numeric(value) as any;
|
|
433
|
+
return this;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
// Get the scroll left.
|
|
437
|
+
scroll_left(): number | string;
|
|
438
|
+
scroll_left(value: number | string): this;
|
|
439
|
+
scroll_left(value?: number | string): number | string | this {
|
|
440
|
+
if (value == null) {
|
|
441
|
+
return this._try_parse_float(this.content.scrollLeft, this.content.scrollLeft);
|
|
442
|
+
}
|
|
443
|
+
this.content.scrollLeft = this.pad_numeric(value) as any;
|
|
444
|
+
return this;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
// Get the scroll height.
|
|
448
|
+
scroll_height(): number {
|
|
449
|
+
return this.content.scrollHeight;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
// Get the scroll width.
|
|
453
|
+
scroll_width(): number {
|
|
454
|
+
return this.content.scrollWidth;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
// Add a on scroll callback.
|
|
458
|
+
// @ts-expect-error
|
|
459
|
+
on_scroll(): ScrollCallbackItem[];
|
|
460
|
+
// @ts-expect-error
|
|
461
|
+
on_scroll(opts_or_callback: OnScrollCallback | {callback: OnScrollCallback, delay?: number} = {callback: null, delay: null}): this;
|
|
462
|
+
// @ts-expect-error
|
|
463
|
+
on_scroll(opts_or_callback?: OnScrollCallback | {callback: OnScrollCallback, delay?: number} = {callback: null, delay: null}): ScrollCallbackItem[] | this {
|
|
464
|
+
if (opts_or_callback == null) { return this.on_scroll_callbacks; }
|
|
465
|
+
let callback;
|
|
466
|
+
if (Utils.is_func(opts_or_callback)) {
|
|
467
|
+
const element = this;
|
|
468
|
+
callback = (event) => opts_or_callback(element, event);
|
|
469
|
+
this.on_scroll_callbacks.push({callback, user_callback: opts_or_callback});
|
|
470
|
+
} else {
|
|
471
|
+
if (opts_or_callback.delay == null) {
|
|
472
|
+
callback = opts_or_callback.callback;
|
|
473
|
+
} else {
|
|
474
|
+
let timer;
|
|
475
|
+
const element = this;
|
|
476
|
+
callback = function(event) {
|
|
477
|
+
clearTimeout(timer);
|
|
478
|
+
setTimeout(() => opts_or_callback.callback(element, event), opts_or_callback.delay);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
this.on_scroll_callbacks.push({callback, user_callback: opts_or_callback.callback});
|
|
482
|
+
}
|
|
483
|
+
this.content.addEventListener("scroll", callback);
|
|
484
|
+
return this;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
// Remove a on scroll callback.
|
|
488
|
+
remove_on_scroll(callback: OnScrollCallback): this {
|
|
489
|
+
let dropped: ScrollCallbackItem[] = [];
|
|
490
|
+
this.on_scroll_callbacks.iterate((item) => {
|
|
491
|
+
if (item.user_callback === callback) {
|
|
492
|
+
this.content.removeEventListener("scroll", item.callback);
|
|
493
|
+
} else {
|
|
494
|
+
dropped.push(item);
|
|
495
|
+
}
|
|
496
|
+
})
|
|
497
|
+
this.on_scroll_callbacks = dropped;
|
|
498
|
+
return this;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
// Small wrapper to set scroll top without triggering a certain on scroll handler.
|
|
502
|
+
set_scroll_top_without_event(top: number | string): this {
|
|
503
|
+
return this.set_scroll_position_without_event(top);
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
// Small wrapper to set scroll left without triggering a certain on scroll handler.
|
|
507
|
+
set_scroll_left_without_event(left: number | string): this {
|
|
508
|
+
return this.set_scroll_position_without_event(undefined, left);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
// Small wrapper to set scroll top / left without triggering a certain on scroll handler.
|
|
512
|
+
set_scroll_position_without_event(top?: number | string, left?: number | string) {
|
|
513
|
+
this.on_scroll_callbacks.iterate((item) => {
|
|
514
|
+
this.content.removeEventListener("scroll", item.callback);
|
|
515
|
+
});
|
|
516
|
+
if (top != null) {
|
|
517
|
+
this.scroll_top(top);
|
|
518
|
+
}
|
|
519
|
+
if (left != null) {
|
|
520
|
+
this.scroll_left(left);
|
|
521
|
+
}
|
|
522
|
+
this.on_scroll_callbacks.iterate((item) => {
|
|
523
|
+
this.content.addEventListener("scroll", item.callback);
|
|
524
|
+
});
|
|
525
|
+
return this;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
// Alignments.
|
|
529
|
+
// 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.
|
|
530
|
+
// @warning: This only works when a max width has been set on the content attribute.
|
|
531
|
+
align(): string;
|
|
532
|
+
align(value: string): this;
|
|
533
|
+
align(value?: string): string | this {
|
|
534
|
+
if (value == null) { return this._h_alignment ?? ""; }
|
|
535
|
+
super.align(value);
|
|
536
|
+
this._h_alignment = value;
|
|
537
|
+
if (this._alignment_callback_activated !== true) {
|
|
538
|
+
this._alignment_callback_activated = true;
|
|
539
|
+
this.on_resize(this._alignment_callback);
|
|
540
|
+
this.on_render(this._alignment_callback);
|
|
541
|
+
}
|
|
542
|
+
return this;
|
|
543
|
+
}
|
|
544
|
+
center(): this {
|
|
545
|
+
this.align("center");
|
|
546
|
+
return this;
|
|
547
|
+
}
|
|
548
|
+
leading(): this {
|
|
549
|
+
this.align("start");
|
|
550
|
+
return this;
|
|
551
|
+
}
|
|
552
|
+
trailing(): this {
|
|
553
|
+
this.align("end");
|
|
554
|
+
return this;
|
|
555
|
+
}
|
|
556
|
+
align_vertical(): string;
|
|
557
|
+
align_vertical(value: string): this;
|
|
558
|
+
align_vertical(value?: string): string | this {
|
|
559
|
+
if (value == null) { return this._v_alignment ?? ""; }
|
|
560
|
+
super.align_vertical(value);
|
|
561
|
+
this._v_alignment = value;
|
|
562
|
+
if (this._alignment_callback_activated !== true) {
|
|
563
|
+
this._alignment_callback_activated = true;
|
|
564
|
+
this.on_resize(this._alignment_callback);
|
|
565
|
+
this.on_render(this._alignment_callback);
|
|
566
|
+
}
|
|
567
|
+
return this;
|
|
568
|
+
}
|
|
569
|
+
center_vertical(): this {
|
|
570
|
+
this.align_vertical("center");
|
|
571
|
+
return this;
|
|
572
|
+
}
|
|
573
|
+
leading_vertical(): this {
|
|
574
|
+
this.align_vertical("start");
|
|
575
|
+
return this;
|
|
576
|
+
}
|
|
577
|
+
trailing_vertical(): this {
|
|
578
|
+
this.align_vertical("end");
|
|
579
|
+
return this;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
export const Scroller = Elements.wrapper(ScrollerElement);
|
|
583
|
+
export const NullScroller = Elements.create_null(ScrollerElement);
|
|
584
|
+
declare module './any_element.d.ts' { interface AnyElementMap { ScrollerElement: ScrollerElement }}
|
|
585
|
+
|
|
586
|
+
// Scroller.
|
|
587
|
+
/* @docs:
|
|
588
|
+
@nav: Frontend
|
|
589
|
+
@chapter: Elements
|
|
590
|
+
@title: Virtual Scroller
|
|
591
|
+
@experimental: true
|
|
592
|
+
@note: The `VirtualScrollerElement` is also initializable under function `VirtualScroller`.
|
|
593
|
+
@description:
|
|
594
|
+
The virtual scroller element.
|
|
595
|
+
|
|
596
|
+
Can be initialed with function `VirtualScroller()`.
|
|
597
|
+
|
|
598
|
+
After appending children you should call `render()` otherwise the children will only show up after a scroll event.
|
|
599
|
+
|
|
600
|
+
The virtual scroller can work in two ways.
|
|
601
|
+
1) You must set a fixed height for every direct child.
|
|
602
|
+
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.
|
|
603
|
+
@warning: Using content-visibility on the direct or nested children may cause undefined behaviour, it may cause elements to become hidden.
|
|
604
|
+
@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.
|
|
605
|
+
@warning: Setting padding on element attribute "content" may cause undefined behaviour.
|
|
606
|
+
@parameter:
|
|
607
|
+
@name: children
|
|
608
|
+
@description: The elements children.
|
|
609
|
+
@type: array[Node]
|
|
610
|
+
*/
|
|
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 }}
|
|
892
|
+
|
|
893
|
+
/* @docs:
|
|
894
|
+
@nav: Frontend
|
|
895
|
+
@chapter: Elements
|
|
896
|
+
@title: Snap Scroller
|
|
897
|
+
@experimental: true
|
|
898
|
+
@note: The `SnapScrollerElement` is also initializable under function `SnapScroller`.
|
|
899
|
+
@description:
|
|
900
|
+
Scrolls the windows per window (snap scrolling).
|
|
901
|
+
|
|
902
|
+
This class is still experimental.
|
|
903
|
+
*/
|
|
904
|
+
@Elements.register
|
|
905
|
+
export class SnapScrollerElement extends VStackElement {
|
|
906
|
+
constructor(...children: any[]) {
|
|
907
|
+
|
|
908
|
+
// Base.
|
|
909
|
+
super();
|
|
910
|
+
this._init_derived({ derived: SnapScrollerElement, })
|
|
911
|
+
|
|
912
|
+
// Style.
|
|
913
|
+
this.overflow_y("scroll");
|
|
914
|
+
this.scroll_snap_type("y mandatory");
|
|
915
|
+
|
|
916
|
+
// Add children.
|
|
917
|
+
this.append(...children);
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
// Append.
|
|
921
|
+
append(...children: any[]): this {
|
|
922
|
+
for (let i = 0; i < children.length; i++) {
|
|
923
|
+
const win = children[i];
|
|
924
|
+
if (win == null) { continue; }
|
|
925
|
+
|
|
926
|
+
// Style.
|
|
927
|
+
win.min_height("100%");
|
|
928
|
+
// win.scroll_snap_align("start");
|
|
929
|
+
|
|
930
|
+
// Set alignment.
|
|
931
|
+
win.on_render((e) => {
|
|
932
|
+
if (win.scrollHeight > this.clientHeight) {
|
|
933
|
+
e.align_vertical("default");
|
|
934
|
+
} else {
|
|
935
|
+
e.center_vertical();
|
|
936
|
+
}
|
|
937
|
+
})
|
|
938
|
+
win.on_resize((e) => {
|
|
939
|
+
if (win.scrollHeight > this.clientHeight) {
|
|
940
|
+
e.align_vertical("default");
|
|
941
|
+
} else {
|
|
942
|
+
e.center_vertical();
|
|
943
|
+
}
|
|
944
|
+
})
|
|
945
|
+
|
|
946
|
+
// Append.
|
|
947
|
+
win.style.height = "100%";
|
|
948
|
+
win.style.minHeight = "100%";
|
|
949
|
+
win.style.maxHeight = "100%";
|
|
950
|
+
win.style.overflowY = "scroll";
|
|
951
|
+
win.style["scroll-snap-align"] = "start";
|
|
952
|
+
super.append(win);
|
|
953
|
+
// const section = document.createElement("section");
|
|
954
|
+
// section.style.height = "100%";
|
|
955
|
+
// section.style.minHeight = "100%";
|
|
956
|
+
// section.style.maxHeight = "100%";
|
|
957
|
+
// section.style.overflowY = "scroll";
|
|
958
|
+
// section.style["scroll-snap-align"] = "start";
|
|
959
|
+
// section.appendChild(win);
|
|
960
|
+
// super.append(section);
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
// Response.
|
|
964
|
+
return this
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
// Scroll into child.
|
|
968
|
+
scroll_into_child(index: number, behaviour: string = "smooth"): this {
|
|
969
|
+
this.child(index).scrollIntoView({behavior: behaviour});
|
|
970
|
+
return this;
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
export const SnapScroller = Elements.wrapper(SnapScrollerElement);
|
|
974
|
+
export const NullSnapScroller = Elements.create_null(SnapScrollerElement);
|
|
975
|
+
declare module './any_element.d.ts' { interface AnyElementMap { SnapScrollerElement: SnapScrollerElement }}
|
|
976
|
+
|
|
977
|
+
// Window Scroller.
|
|
978
|
+
/*
|
|
979
|
+
@constructor_wrapper
|
|
980
|
+
@Elements.register
|
|
981
|
+
class WindowScrollerElement extends Elements.create({
|
|
982
|
+
type: "WindowScroller",
|
|
983
|
+
tag: "div",
|
|
984
|
+
default_style: {
|
|
985
|
+
"margin": "0px",
|
|
986
|
+
"padding": "0px",
|
|
987
|
+
"display": "flex", // to support vertical spacers.
|
|
988
|
+
"overflow": "visible",
|
|
989
|
+
"align-content": "flex-start", // align items at start, do not stretch / space when inside HStack.
|
|
990
|
+
"flex-direction": "column",
|
|
991
|
+
},
|
|
992
|
+
}) {
|
|
993
|
+
constructor({
|
|
994
|
+
duration = 500, // duration of the animation.
|
|
995
|
+
_topbar = null, // can be passed to assign a shadow to an item when the content is scrolling and a shadow should present.
|
|
996
|
+
} = {}) {
|
|
997
|
+
|
|
998
|
+
|
|
999
|
+
// Super.
|
|
1000
|
+
super();
|
|
1001
|
+
|
|
1002
|
+
// Attributes.
|
|
1003
|
+
this.duration = duration;
|
|
1004
|
+
this.index = 0;
|
|
1005
|
+
this.windows = [];
|
|
1006
|
+
this.last_scroll_top = 0;
|
|
1007
|
+
this.window_scroll_height = 50; // the minimum scroll required to go to the next window.
|
|
1008
|
+
|
|
1009
|
+
// Styling.
|
|
1010
|
+
this.min_width("100%");
|
|
1011
|
+
this.stretch(true);
|
|
1012
|
+
this.position("relative");
|
|
1013
|
+
this.overflow("hidden scroll");
|
|
1014
|
+
this.class("hide_scrollbar");
|
|
1015
|
+
|
|
1016
|
+
// The event that will be called when the window scrolls.
|
|
1017
|
+
this.on_animation_scroll = () => {};
|
|
1018
|
+
|
|
1019
|
+
// @todo update scroll position on resize.
|
|
1020
|
+
const _this_ = this;
|
|
1021
|
+
this.child_scrolling = false;
|
|
1022
|
+
this._child_on_scroll = function (e) {
|
|
1023
|
+
|
|
1024
|
+
// console.log("Child:", _this_.child_scrolling)
|
|
1025
|
+
_this_.child_scrolling = true;
|
|
1026
|
+
setTimeout(() => {_this_.child_scrolling = false}, 250)
|
|
1027
|
+
|
|
1028
|
+
// Set top bar shadow.
|
|
1029
|
+
if (_topbar != null) {
|
|
1030
|
+
if (this.scrollTop > 0 && _topbar.has_shadow !== true) {
|
|
1031
|
+
_topbar.has_shadow = true;
|
|
1032
|
+
_topbar.shadow("0px 0px 10px #000000")
|
|
1033
|
+
} else if (this.scrollTop === 0 && _topbar.has_shadow === true) {
|
|
1034
|
+
_topbar.has_shadow = false;
|
|
1035
|
+
_topbar.shadow("none")
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
// Relay scroll when the child can no longer scroll.
|
|
1040
|
+
if (this.scrollTop === 0) {
|
|
1041
|
+
_this_.scrollTop = (_this_.index - 1) * _this_.window_scroll_height;
|
|
1042
|
+
} else if (this.scrollTop + this.clientHeight >= this.scrollHeight) {
|
|
1043
|
+
_this_.scrollTop = (_this_.index + 1) * _this_.window_scroll_height;
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
// On wheel event.
|
|
1048
|
+
const _on_scroll_callback = (e) => {
|
|
1049
|
+
|
|
1050
|
+
// Prevent default on already animating.
|
|
1051
|
+
// console.log("Parent:", _this_.child_scrolling)
|
|
1052
|
+
if (this.animating === true || _this_.child_scrolling) {
|
|
1053
|
+
e.preventDefault();
|
|
1054
|
+
return ;
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
// Vars.
|
|
1058
|
+
const win = this.windows[this.index];
|
|
1059
|
+
const scroll_top = this.scrollTop;
|
|
1060
|
+
const height = this.clientHeight;
|
|
1061
|
+
const scroll_up = this.scrollTop > this.last_scroll_top;
|
|
1062
|
+
this.last_scroll_top = scroll_top;
|
|
1063
|
+
|
|
1064
|
+
// Set top bar shadow.
|
|
1065
|
+
if (_topbar != null) {
|
|
1066
|
+
if (win.scrollTop > 0 && _topbar.has_shadow !== true) {
|
|
1067
|
+
_topbar.has_shadow = true;
|
|
1068
|
+
_topbar.shadow("0px 0px 10px #000000")
|
|
1069
|
+
} else if (win.scrollTop === 0 && _topbar.has_shadow === true) {
|
|
1070
|
+
setTimeout(() => {
|
|
1071
|
+
_topbar.has_shadow = false;
|
|
1072
|
+
_topbar.shadow("none")
|
|
1073
|
+
}, this.duration) // must be the at least the duration of window transition.
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
// Prevent default on max scroll height.
|
|
1078
|
+
if (scroll_top > this.windows.length * this.window_scroll_height) {
|
|
1079
|
+
this.scrollTop = this.windows.length * this.window_scroll_height;
|
|
1080
|
+
e.stopPropagation();
|
|
1081
|
+
e.preventDefault();
|
|
1082
|
+
return null;
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
// Next or previous.
|
|
1086
|
+
// Skip when the child is not fully scroller.
|
|
1087
|
+
if (
|
|
1088
|
+
(win.scrollTop + win.clientHeight >= win.scrollHeight) ||
|
|
1089
|
+
(win.scrollTop === 0)
|
|
1090
|
+
) {
|
|
1091
|
+
|
|
1092
|
+
// Check views.
|
|
1093
|
+
const scroll_index = parseInt(scroll_top / this.window_scroll_height);
|
|
1094
|
+
const stop_animating = () => {
|
|
1095
|
+
setTimeout(() => {
|
|
1096
|
+
this.animating = false;
|
|
1097
|
+
this.scrollTop = this.index * this.window_scroll_height;
|
|
1098
|
+
}, 250)
|
|
1099
|
+
}
|
|
1100
|
+
if (scroll_index > this.index) {
|
|
1101
|
+
this.animating = true;
|
|
1102
|
+
e.preventDefault();
|
|
1103
|
+
this.next(scroll_index, false)
|
|
1104
|
+
.then(stop_animating)
|
|
1105
|
+
.catch(stop_animating)
|
|
1106
|
+
this.scrollTop = this.index * this.window_scroll_height;
|
|
1107
|
+
} else if (scroll_index < this.index) {
|
|
1108
|
+
this.animating = true;
|
|
1109
|
+
e.preventDefault();
|
|
1110
|
+
this.prev(scroll_index, false)
|
|
1111
|
+
.then(stop_animating)
|
|
1112
|
+
.catch(stop_animating)
|
|
1113
|
+
this.scrollTop = this.index * this.window_scroll_height;
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
// Add event listener.
|
|
1121
|
+
this.addEventListener("scroll", _on_scroll_callback, { passive: false });
|
|
1122
|
+
|
|
1123
|
+
// Add the on hash change listener for any direct children id's.
|
|
1124
|
+
window.addEventListener("hashchange", (e) => {
|
|
1125
|
+
const hash = window.location.hash.substr(1);
|
|
1126
|
+
if (hash != null && hash !== "") {
|
|
1127
|
+
this.windows.iterate((win) => {
|
|
1128
|
+
if (hash === win.id()) {
|
|
1129
|
+
console.log("Select", win.id())
|
|
1130
|
+
if (win.index > this.index) {
|
|
1131
|
+
this.next(win.index, true);
|
|
1132
|
+
} else {
|
|
1133
|
+
this.prev(win.index, true);
|
|
1134
|
+
}
|
|
1135
|
+
return false;
|
|
1136
|
+
}
|
|
1137
|
+
})
|
|
1138
|
+
// window.location.hash = ""; // reset the hash so that when the user clicks the hash button again it is rerendered.
|
|
1139
|
+
}
|
|
1140
|
+
})
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
|
|
1144
|
+
// Add a window.
|
|
1145
|
+
append(win) {
|
|
1146
|
+
|
|
1147
|
+
// Update window.
|
|
1148
|
+
win.transition(`opacity ${this.duration*2}ms, transform ${this.duration}ms ease`)
|
|
1149
|
+
win.fixed_frame("100%", "100%");
|
|
1150
|
+
win.position(0, 0, 0, 0);
|
|
1151
|
+
win.position("sticky");
|
|
1152
|
+
win.overflow("scroll");
|
|
1153
|
+
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.
|
|
1154
|
+
// win.align("default"); // must start with leading for checks will be centered later
|
|
1155
|
+
win.align_vertical("default"); // must start with leading for checks will be centered later
|
|
1156
|
+
win.addEventListener("scroll", this._child_on_scroll);
|
|
1157
|
+
win.outline("none"); // otherwise an outline border may appear while scrolling windows.
|
|
1158
|
+
win.border("none"); // otherwise an outline border may appear while scrolling windows.
|
|
1159
|
+
win.center();
|
|
1160
|
+
|
|
1161
|
+
// Add scroll forwarder.
|
|
1162
|
+
|
|
1163
|
+
// Initial window.
|
|
1164
|
+
if (this.windows.length > 0) {
|
|
1165
|
+
win.transform("translateY(100%)")
|
|
1166
|
+
win.opacity(0)
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
// Other windows.
|
|
1170
|
+
else {
|
|
1171
|
+
win.transform("translateY(0)")
|
|
1172
|
+
win.opacity(1)
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
// Set alignment.
|
|
1176
|
+
win.on_render((e) => {
|
|
1177
|
+
// Setting horizontal align causes issues with slide in animations.
|
|
1178
|
+
// setTimeout(() => {
|
|
1179
|
+
// const width = this.clientWidth;
|
|
1180
|
+
// const width = e.clientWidth;
|
|
1181
|
+
// if (e.scrollWidth > width) {
|
|
1182
|
+
// console.log(e.scrollWidth, width, "default", win.child(0).text().substr(0, 10))
|
|
1183
|
+
// e.align("default");
|
|
1184
|
+
// } else {
|
|
1185
|
+
// console.log(e.scrollWidth, width, "center", win.child(0).text().substr(0, 10))
|
|
1186
|
+
// e.center();
|
|
1187
|
+
// }
|
|
1188
|
+
if (win.scrollHeight > this.clientHeight) {
|
|
1189
|
+
e.align_vertical("default");
|
|
1190
|
+
} else {
|
|
1191
|
+
e.center_vertical();
|
|
1192
|
+
}
|
|
1193
|
+
})
|
|
1194
|
+
win.on_resize((e) => {
|
|
1195
|
+
if (win.scrollHeight > this.clientHeight) {
|
|
1196
|
+
e.align_vertical("default");
|
|
1197
|
+
} else {
|
|
1198
|
+
e.center_vertical();
|
|
1199
|
+
}
|
|
1200
|
+
})
|
|
1201
|
+
|
|
1202
|
+
// Append.
|
|
1203
|
+
win.index = this.windows.length;
|
|
1204
|
+
this.windows.push(win);
|
|
1205
|
+
super.append(win);
|
|
1206
|
+
|
|
1207
|
+
// Check if the href hash is set on this windows id.
|
|
1208
|
+
const hash = window.location.hash.substr(1);
|
|
1209
|
+
if (hash != null && hash !== "" && hash === win.id()) {
|
|
1210
|
+
this.on_render(() => {
|
|
1211
|
+
this.next(win.index, true);
|
|
1212
|
+
})
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
|
|
1216
|
+
// response.
|
|
1217
|
+
return this;
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
// Next window.
|
|
1221
|
+
async next(index, update_scroll_top = true) {
|
|
1222
|
+
return new Promise(async (resolve) => {
|
|
1223
|
+
if (index < this.windows.length) {
|
|
1224
|
+
|
|
1225
|
+
// Update scroll top.
|
|
1226
|
+
if (update_scroll_top) {
|
|
1227
|
+
this.scrollTop = this.window_scroll_height * index;
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
// Slide out.
|
|
1231
|
+
const current = this.windows[this.index];
|
|
1232
|
+
current.style.opacity = 0;
|
|
1233
|
+
current.style.transform = 'translateY(-100%)';
|
|
1234
|
+
|
|
1235
|
+
// Update index.
|
|
1236
|
+
this.index = index;
|
|
1237
|
+
|
|
1238
|
+
// Slide in.
|
|
1239
|
+
const next = this.windows[this.index];
|
|
1240
|
+
if (next.is_scrollable()) {
|
|
1241
|
+
next.leading_vertical()
|
|
1242
|
+
} else {
|
|
1243
|
+
next.center_vertical()
|
|
1244
|
+
}
|
|
1245
|
+
next.scrollTop = 0;
|
|
1246
|
+
next.style.opacity = 1;
|
|
1247
|
+
next.style.transform = 'translateY(0)';
|
|
1248
|
+
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.
|
|
1249
|
+
|
|
1250
|
+
// Call on appear on children.
|
|
1251
|
+
if (Array.isArray(next._on_appear_callbacks)) {
|
|
1252
|
+
let promises = [];
|
|
1253
|
+
for (let i = 0; i < next._on_appear_callbacks.length; i++) {
|
|
1254
|
+
const res = next._on_appear_callbacks[i].exec()
|
|
1255
|
+
if (res instanceof Promise) {
|
|
1256
|
+
promises.push(res);
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
await Promise.all(promises);
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
// Resolve.
|
|
1263
|
+
setTimeout(resolve, this.duration);
|
|
1264
|
+
}
|
|
1265
|
+
else {
|
|
1266
|
+
resolve();
|
|
1267
|
+
}
|
|
1268
|
+
});
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
// Previous window.
|
|
1272
|
+
async prev(index, update_scroll_top = true) {
|
|
1273
|
+
return new Promise(async (resolve) => {
|
|
1274
|
+
const old_index = this.index;
|
|
1275
|
+
if (index >= 0) {
|
|
1276
|
+
|
|
1277
|
+
// Update scroll top.
|
|
1278
|
+
if (update_scroll_top) {
|
|
1279
|
+
this.scrollTop = this.window_scroll_height * index;
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1282
|
+
// Slide out.
|
|
1283
|
+
const current = this.windows[this.index];
|
|
1284
|
+
current.style.opacity = 0;
|
|
1285
|
+
current.style.transform = 'translateY(100%)';
|
|
1286
|
+
|
|
1287
|
+
// Update index.
|
|
1288
|
+
this.index = index;
|
|
1289
|
+
|
|
1290
|
+
// Slide in.
|
|
1291
|
+
const next = this.windows[this.index];
|
|
1292
|
+
if (next.is_scrollable()) {
|
|
1293
|
+
next.leading_vertical()
|
|
1294
|
+
} else {
|
|
1295
|
+
next.center_vertical()
|
|
1296
|
+
}
|
|
1297
|
+
next.scrollTop = next.scrollHeight;
|
|
1298
|
+
next.style.opacity = 1;
|
|
1299
|
+
next.style.transform = 'translateY(0)';
|
|
1300
|
+
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.
|
|
1301
|
+
|
|
1302
|
+
// Call on appear on children.
|
|
1303
|
+
if (Array.isArray(next._on_appear_callbacks)) {
|
|
1304
|
+
let promises = [];
|
|
1305
|
+
for (let i = 0; i < next._on_appear_callbacks.length; i++) {
|
|
1306
|
+
const res = next._on_appear_callbacks[i].exec()
|
|
1307
|
+
if (res instanceof Promise) {
|
|
1308
|
+
promises.push(res);
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
await Promise.all(promises);
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
// Resolve.
|
|
1315
|
+
setTimeout(resolve, this.duration);
|
|
1316
|
+
}
|
|
1317
|
+
else {
|
|
1318
|
+
resolve();
|
|
1319
|
+
}
|
|
1320
|
+
});
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
}
|
|
1324
|
+
*/
|