hyper-admin 1.0.0__py3-none-any.whl
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.
- hyper_admin-1.0.0.dist-info/METADATA +366 -0
- hyper_admin-1.0.0.dist-info/RECORD +442 -0
- hyper_admin-1.0.0.dist-info/WHEEL +4 -0
- hyper_admin-1.0.0.dist-info/entry_points.txt +2 -0
- hyper_admin-1.0.0.dist-info/licenses/LICENSE +21 -0
- hyperadmin/__init__.py +52 -0
- hyperadmin/__main__.py +21 -0
- hyperadmin/adapters/__init__.py +28 -0
- hyperadmin/adapters/_estimate.py +33 -0
- hyperadmin/adapters/_filter_clause.py +9 -0
- hyperadmin/adapters/_occ.py +44 -0
- hyperadmin/adapters/_relation_loading.py +23 -0
- hyperadmin/adapters/_search.py +84 -0
- hyperadmin/adapters/filtering.py +86 -0
- hyperadmin/adapters/introspection.py +239 -0
- hyperadmin/adapters/registry.py +37 -0
- hyperadmin/adapters/schema.py +239 -0
- hyperadmin/adapters/sqlalchemy.py +423 -0
- hyperadmin/adapters/sqlmodel.py +650 -0
- hyperadmin/auth/__init__.py +156 -0
- hyperadmin/auth/_types.py +52 -0
- hyperadmin/auth/backend.py +37 -0
- hyperadmin/auth/bridge.py +351 -0
- hyperadmin/auth/exceptions.py +124 -0
- hyperadmin/auth/middleware.py +287 -0
- hyperadmin/auth/models.py +245 -0
- hyperadmin/auth/oauth/__init__.py +81 -0
- hyperadmin/auth/oauth/backend.py +611 -0
- hyperadmin/auth/oauth/providers.py +214 -0
- hyperadmin/auth/oauth/refresh.py +126 -0
- hyperadmin/auth/oauth/session.py +96 -0
- hyperadmin/auth/oauth/tokens.py +114 -0
- hyperadmin/auth/oauth/views.py +306 -0
- hyperadmin/auth/oauth/wiring.py +131 -0
- hyperadmin/auth/otp.py +189 -0
- hyperadmin/auth/permissions.py +232 -0
- hyperadmin/auth/session.py +81 -0
- hyperadmin/auth/session_middleware.py +164 -0
- hyperadmin/auth/token_handoff.py +452 -0
- hyperadmin/auth/user_cache.py +222 -0
- hyperadmin/auth/views.py +581 -0
- hyperadmin/core/__init__.py +76 -0
- hyperadmin/core/actions.py +151 -0
- hyperadmin/core/adapters.py +883 -0
- hyperadmin/core/app.py +1437 -0
- hyperadmin/core/auth.py +97 -0
- hyperadmin/core/bulk_results.py +28 -0
- hyperadmin/core/cache.py +68 -0
- hyperadmin/core/choices.py +38 -0
- hyperadmin/core/concurrency.py +107 -0
- hyperadmin/core/csrf.py +108 -0
- hyperadmin/core/discovery.py +161 -0
- hyperadmin/core/display.py +172 -0
- hyperadmin/core/fields.py +158 -0
- hyperadmin/core/fieldsets.py +22 -0
- hyperadmin/core/filtering.py +403 -0
- hyperadmin/core/filters_compat.py +78 -0
- hyperadmin/core/inlines.py +64 -0
- hyperadmin/core/introspection.py +280 -0
- hyperadmin/core/layouts.py +17 -0
- hyperadmin/core/lifecycle.py +278 -0
- hyperadmin/core/model.py +189 -0
- hyperadmin/core/navigation.py +354 -0
- hyperadmin/core/options.py +391 -0
- hyperadmin/core/palette.py +94 -0
- hyperadmin/core/panels.py +227 -0
- hyperadmin/core/plugin_wiring.py +205 -0
- hyperadmin/core/plugins.py +588 -0
- hyperadmin/core/primary_key.py +118 -0
- hyperadmin/core/rate_limit.py +90 -0
- hyperadmin/core/registry.py +129 -0
- hyperadmin/core/relation_loading.py +25 -0
- hyperadmin/core/schema.py +83 -0
- hyperadmin/core/sensitive.py +134 -0
- hyperadmin/core/settings.py +377 -0
- hyperadmin/core/storage_paths.py +54 -0
- hyperadmin/core/timezones.py +137 -0
- hyperadmin/core/uploads.py +16 -0
- hyperadmin/db.py +160 -0
- hyperadmin/discover.py +54 -0
- hyperadmin/filters/__init__.py +39 -0
- hyperadmin/filters/base.py +246 -0
- hyperadmin/filters/boolean.py +105 -0
- hyperadmin/filters/choice.py +74 -0
- hyperadmin/filters/date.py +265 -0
- hyperadmin/filters/relation.py +69 -0
- hyperadmin/filters/saved_views.py +203 -0
- hyperadmin/i18n/__init__.py +50 -0
- hyperadmin/i18n/loader.py +150 -0
- hyperadmin/i18n/middleware.py +159 -0
- hyperadmin/i18n/validation_messages.py +264 -0
- hyperadmin/loadtest/__init__.py +28 -0
- hyperadmin/loadtest/batch.py +263 -0
- hyperadmin/loadtest/checkpoint.py +168 -0
- hyperadmin/loadtest/generators/__init__.py +29 -0
- hyperadmin/loadtest/generators/auth.py +86 -0
- hyperadmin/loadtest/generators/erp.py +177 -0
- hyperadmin/loadtest/plan.py +189 -0
- hyperadmin/loadtest/pool.py +113 -0
- hyperadmin/loadtest/progress.py +150 -0
- hyperadmin/locale/ar/LC_MESSAGES/messages.mo +0 -0
- hyperadmin/locale/ar/LC_MESSAGES/messages.po +2139 -0
- hyperadmin/locale/de/LC_MESSAGES/messages.mo +0 -0
- hyperadmin/locale/de/LC_MESSAGES/messages.po +2114 -0
- hyperadmin/locale/en/LC_MESSAGES/messages.mo +0 -0
- hyperadmin/locale/en/LC_MESSAGES/messages.po +1780 -0
- hyperadmin/locale/es/LC_MESSAGES/messages.mo +0 -0
- hyperadmin/locale/es/LC_MESSAGES/messages.po +2094 -0
- hyperadmin/locale/fr/LC_MESSAGES/messages.mo +0 -0
- hyperadmin/locale/fr/LC_MESSAGES/messages.po +2100 -0
- hyperadmin/locale/he/LC_MESSAGES/messages.mo +0 -0
- hyperadmin/locale/he/LC_MESSAGES/messages.po +2076 -0
- hyperadmin/locale/hi/LC_MESSAGES/messages.mo +0 -0
- hyperadmin/locale/hi/LC_MESSAGES/messages.po +2084 -0
- hyperadmin/locale/id/LC_MESSAGES/messages.mo +0 -0
- hyperadmin/locale/id/LC_MESSAGES/messages.po +2071 -0
- hyperadmin/locale/it/LC_MESSAGES/messages.mo +0 -0
- hyperadmin/locale/it/LC_MESSAGES/messages.po +2098 -0
- hyperadmin/locale/ja/LC_MESSAGES/messages.mo +0 -0
- hyperadmin/locale/ja/LC_MESSAGES/messages.po +2049 -0
- hyperadmin/locale/ko/LC_MESSAGES/messages.mo +0 -0
- hyperadmin/locale/ko/LC_MESSAGES/messages.po +2049 -0
- hyperadmin/locale/nl/LC_MESSAGES/messages.mo +0 -0
- hyperadmin/locale/nl/LC_MESSAGES/messages.po +2100 -0
- hyperadmin/locale/pl/LC_MESSAGES/messages.mo +0 -0
- hyperadmin/locale/pl/LC_MESSAGES/messages.po +2112 -0
- hyperadmin/locale/pt_BR/LC_MESSAGES/messages.mo +0 -0
- hyperadmin/locale/pt_BR/LC_MESSAGES/messages.po +2098 -0
- hyperadmin/locale/ru/LC_MESSAGES/messages.mo +0 -0
- hyperadmin/locale/ru/LC_MESSAGES/messages.po +2112 -0
- hyperadmin/locale/th/LC_MESSAGES/messages.mo +0 -0
- hyperadmin/locale/th/LC_MESSAGES/messages.po +2065 -0
- hyperadmin/locale/tr/LC_MESSAGES/messages.mo +0 -0
- hyperadmin/locale/tr/LC_MESSAGES/messages.po +2084 -0
- hyperadmin/locale/uk/LC_MESSAGES/messages.mo +0 -0
- hyperadmin/locale/uk/LC_MESSAGES/messages.po +1889 -0
- hyperadmin/locale/vi/LC_MESSAGES/messages.mo +0 -0
- hyperadmin/locale/vi/LC_MESSAGES/messages.po +2063 -0
- hyperadmin/locale/zh_CN/LC_MESSAGES/messages.mo +0 -0
- hyperadmin/locale/zh_CN/LC_MESSAGES/messages.po +2049 -0
- hyperadmin/main.py +3 -0
- hyperadmin/management/__init__.py +0 -0
- hyperadmin/management/commands/__init__.py +0 -0
- hyperadmin/management/commands/createsuperuser.py +114 -0
- hyperadmin/management/commands/initdb.py +76 -0
- hyperadmin/management/commands/plugins.py +31 -0
- hyperadmin/management/commands/seed.py +125 -0
- hyperadmin/navigation/__init__.py +9 -0
- hyperadmin/navigation/pins.py +153 -0
- hyperadmin/panels/__init__.py +10 -0
- hyperadmin/panels/pdf.py +151 -0
- hyperadmin/permissions/__init__.py +59 -0
- hyperadmin/permissions/audit.py +109 -0
- hyperadmin/permissions/matrix.py +343 -0
- hyperadmin/permissions/object_rules.py +143 -0
- hyperadmin/realtime/__init__.py +51 -0
- hyperadmin/realtime/_debug.py +77 -0
- hyperadmin/realtime/config.py +124 -0
- hyperadmin/realtime/emitting.py +143 -0
- hyperadmin/realtime/events.py +107 -0
- hyperadmin/realtime/presence.py +193 -0
- hyperadmin/realtime/presence_redis.py +142 -0
- hyperadmin/realtime/pubsub.py +129 -0
- hyperadmin/realtime/pubsub_redis.py +159 -0
- hyperadmin/realtime/registry.py +102 -0
- hyperadmin/realtime/sse.py +82 -0
- hyperadmin/realtime/ws.py +477 -0
- hyperadmin/routing.py +680 -0
- hyperadmin/static/css/_accessibility.css +149 -0
- hyperadmin/static/css/_alerts.css +147 -0
- hyperadmin/static/css/_autocomplete.css +39 -0
- hyperadmin/static/css/_banner.css +118 -0
- hyperadmin/static/css/_buttons.css +241 -0
- hyperadmin/static/css/_card.css +86 -0
- hyperadmin/static/css/_dark-mode.css +232 -0
- hyperadmin/static/css/_fieldsets.css +71 -0
- hyperadmin/static/css/_filter.css +203 -0
- hyperadmin/static/css/_fonts.css +25 -0
- hyperadmin/static/css/_forms.css +862 -0
- hyperadmin/static/css/_inline-cell.css +222 -0
- hyperadmin/static/css/_inlines.css +160 -0
- hyperadmin/static/css/_layout.css +62 -0
- hyperadmin/static/css/_login.css +112 -0
- hyperadmin/static/css/_menu.css +156 -0
- hyperadmin/static/css/_navbar.css +299 -0
- hyperadmin/static/css/_page-header.css +139 -0
- hyperadmin/static/css/_pagination.css +125 -0
- hyperadmin/static/css/_palette.css +304 -0
- hyperadmin/static/css/_panels.css +174 -0
- hyperadmin/static/css/_permissions.css +547 -0
- hyperadmin/static/css/_pill.css +123 -0
- hyperadmin/static/css/_popover.css +170 -0
- hyperadmin/static/css/_popup.css +65 -0
- hyperadmin/static/css/_progress.css +161 -0
- hyperadmin/static/css/_realtime.css +78 -0
- hyperadmin/static/css/_reset.css +48 -0
- hyperadmin/static/css/_responsive.css +51 -0
- hyperadmin/static/css/_rtl.css +23 -0
- hyperadmin/static/css/_search.css +67 -0
- hyperadmin/static/css/_seg.css +95 -0
- hyperadmin/static/css/_sidebar.css +446 -0
- hyperadmin/static/css/_sticky.css +54 -0
- hyperadmin/static/css/_table.css +776 -0
- hyperadmin/static/css/_theme-terminal-type.css +92 -0
- hyperadmin/static/css/_theme-terminal.css +330 -0
- hyperadmin/static/css/_theme-toggle.css +46 -0
- hyperadmin/static/css/_tokens.css +232 -0
- hyperadmin/static/css/_utilities.css +133 -0
- hyperadmin/static/css/hyperadmin.css +58 -0
- hyperadmin/static/fonts/Inter-OFL.txt +93 -0
- hyperadmin/static/fonts/InterVariable.woff2 +0 -0
- hyperadmin/static/fonts/JetBrainsMono-OFL.txt +93 -0
- hyperadmin/static/fonts/JetBrainsMonoVariable.woff2 +0 -0
- hyperadmin/static/icons/arrow-down.svg +1 -0
- hyperadmin/static/icons/arrow-up.svg +1 -0
- hyperadmin/static/icons/bar-chart-3.svg +1 -0
- hyperadmin/static/icons/bell.svg +1 -0
- hyperadmin/static/icons/bookmark.svg +1 -0
- hyperadmin/static/icons/briefcase.svg +1 -0
- hyperadmin/static/icons/building-2.svg +1 -0
- hyperadmin/static/icons/calendar.svg +1 -0
- hyperadmin/static/icons/check.svg +1 -0
- hyperadmin/static/icons/chevron-down.svg +1 -0
- hyperadmin/static/icons/chevron-left.svg +1 -0
- hyperadmin/static/icons/chevron-right.svg +1 -0
- hyperadmin/static/icons/circle-check.svg +1 -0
- hyperadmin/static/icons/circle-help.svg +1 -0
- hyperadmin/static/icons/circle-x.svg +1 -0
- hyperadmin/static/icons/clock.svg +1 -0
- hyperadmin/static/icons/columns-3.svg +1 -0
- hyperadmin/static/icons/command.svg +1 -0
- hyperadmin/static/icons/copy.svg +1 -0
- hyperadmin/static/icons/credit-card.svg +1 -0
- hyperadmin/static/icons/database.svg +1 -0
- hyperadmin/static/icons/download.svg +1 -0
- hyperadmin/static/icons/ellipsis.svg +1 -0
- hyperadmin/static/icons/external-link.svg +1 -0
- hyperadmin/static/icons/eye.svg +1 -0
- hyperadmin/static/icons/file-text.svg +1 -0
- hyperadmin/static/icons/filter.svg +1 -0
- hyperadmin/static/icons/folder.svg +1 -0
- hyperadmin/static/icons/globe.svg +1 -0
- hyperadmin/static/icons/history.svg +1 -0
- hyperadmin/static/icons/home.svg +1 -0
- hyperadmin/static/icons/image.svg +1 -0
- hyperadmin/static/icons/info.svg +1 -0
- hyperadmin/static/icons/key-round.svg +1 -0
- hyperadmin/static/icons/layers.svg +1 -0
- hyperadmin/static/icons/layout-grid.svg +1 -0
- hyperadmin/static/icons/list-checks.svg +1 -0
- hyperadmin/static/icons/lock.svg +1 -0
- hyperadmin/static/icons/log-out.svg +1 -0
- hyperadmin/static/icons/mail.svg +1 -0
- hyperadmin/static/icons/map-pin.svg +1 -0
- hyperadmin/static/icons/menu.svg +1 -0
- hyperadmin/static/icons/moon.svg +1 -0
- hyperadmin/static/icons/package.svg +1 -0
- hyperadmin/static/icons/panel-left-close.svg +1 -0
- hyperadmin/static/icons/panel-left-open.svg +1 -0
- hyperadmin/static/icons/pencil.svg +1 -0
- hyperadmin/static/icons/pin-off.svg +1 -0
- hyperadmin/static/icons/pin.svg +1 -0
- hyperadmin/static/icons/plus.svg +1 -0
- hyperadmin/static/icons/receipt.svg +1 -0
- hyperadmin/static/icons/refresh-cw.svg +1 -0
- hyperadmin/static/icons/rotate-ccw.svg +1 -0
- hyperadmin/static/icons/search.svg +1 -0
- hyperadmin/static/icons/settings.svg +1 -0
- hyperadmin/static/icons/shield-check.svg +1 -0
- hyperadmin/static/icons/shopping-cart.svg +1 -0
- hyperadmin/static/icons/sliders-horizontal.svg +1 -0
- hyperadmin/static/icons/sparkles.svg +1 -0
- hyperadmin/static/icons/store.svg +1 -0
- hyperadmin/static/icons/sun.svg +1 -0
- hyperadmin/static/icons/tag.svg +1 -0
- hyperadmin/static/icons/trash-2.svg +1 -0
- hyperadmin/static/icons/triangle-alert.svg +1 -0
- hyperadmin/static/icons/truck.svg +1 -0
- hyperadmin/static/icons/upload.svg +1 -0
- hyperadmin/static/icons/user.svg +1 -0
- hyperadmin/static/icons/users.svg +1 -0
- hyperadmin/static/icons/wallet.svg +1 -0
- hyperadmin/static/icons/x.svg +1 -0
- hyperadmin/static/img/hyperadmin-favicon.svg +1 -0
- hyperadmin/static/img/hyperadmin-mark-mono.svg +1 -0
- hyperadmin/static/img/hyperadmin-mark.svg +1 -0
- hyperadmin/static/img/hyperadmin-wordmark-dark.svg +1 -0
- hyperadmin/static/img/hyperadmin-wordmark.svg +1 -0
- hyperadmin/static/img/terminal/hyperadmin-favicon-16.svg +1 -0
- hyperadmin/static/img/terminal/hyperadmin-favicon.svg +1 -0
- hyperadmin/static/img/terminal/hyperadmin-mark.svg +1 -0
- hyperadmin/static/img/terminal/hyperadmin-wordmark-dark.svg +1 -0
- hyperadmin/static/img/terminal/hyperadmin-wordmark.svg +1 -0
- hyperadmin/static/js/autocomplete.js +475 -0
- hyperadmin/static/js/confirm_delete.js +113 -0
- hyperadmin/static/js/error_summary.js +37 -0
- hyperadmin/static/js/form_guard.js +77 -0
- hyperadmin/static/js/inline_edit.js +97 -0
- hyperadmin/static/js/palette.js +292 -0
- hyperadmin/static/js/primitives.js +205 -0
- hyperadmin/static/js/realtime-status.js +515 -0
- hyperadmin/static/js/request_errors.js +85 -0
- hyperadmin/static/js/shortcuts.js +175 -0
- hyperadmin/static/js/sidebar.js +83 -0
- hyperadmin/static/js/vendor/LICENSE-alpinejs.txt +21 -0
- hyperadmin/static/js/vendor/LICENSE-htmx.txt +25 -0
- hyperadmin/static/js/vendor/alpinejs-3.17.4.min.js +21 -0
- hyperadmin/static/js/vendor/alpinejs-focus-3.17.4.min.js +18 -0
- hyperadmin/static/js/vendor/htmx-1.9.10.min.js +1 -0
- hyperadmin/templates/_base.html +161 -0
- hyperadmin/templates/_messages.html +11 -0
- hyperadmin/templates/_navbar.html +126 -0
- hyperadmin/templates/_sidebar.html +80 -0
- hyperadmin/templates/auth/mfa_challenge.html +75 -0
- hyperadmin/templates/auth/mfa_settings.html +110 -0
- hyperadmin/templates/auth/oauth_link_required.html +24 -0
- hyperadmin/templates/auth/oauth_settings.html +55 -0
- hyperadmin/templates/base.html +16 -0
- hyperadmin/templates/bulk_form.html +18 -0
- hyperadmin/templates/bulk_result.html +20 -0
- hyperadmin/templates/components/_icons.html +86 -0
- hyperadmin/templates/components/_macros.html +27 -0
- hyperadmin/templates/components/_nav.html +55 -0
- hyperadmin/templates/components/_row_access.html +26 -0
- hyperadmin/templates/components/banner.html +77 -0
- hyperadmin/templates/components/bulk_form.html +81 -0
- hyperadmin/templates/components/bulk_result.html +133 -0
- hyperadmin/templates/components/bulk_toolbar.html +63 -0
- hyperadmin/templates/components/command_palette.html +59 -0
- hyperadmin/templates/components/confirm_delete_dialog.html +26 -0
- hyperadmin/templates/components/conflict_dialog.html +42 -0
- hyperadmin/templates/components/csrf_reload_banner.html +20 -0
- hyperadmin/templates/components/error_summary.html +39 -0
- hyperadmin/templates/components/error_toast.html +18 -0
- hyperadmin/templates/components/fieldset.html +38 -0
- hyperadmin/templates/components/filter_bar.html +50 -0
- hyperadmin/templates/components/filter_sidebar.html +31 -0
- hyperadmin/templates/components/filters/boolean.html +10 -0
- hyperadmin/templates/components/filters/current_period.html +8 -0
- hyperadmin/templates/components/filters/date_range.html +26 -0
- hyperadmin/templates/components/filters/is_owner.html +8 -0
- hyperadmin/templates/components/filters/multi_choice.html +10 -0
- hyperadmin/templates/components/filters/multi_relation.html +20 -0
- hyperadmin/templates/components/filters/select.html +11 -0
- hyperadmin/templates/components/inline_cell.html +23 -0
- hyperadmin/templates/components/inline_cell_error.html +51 -0
- hyperadmin/templates/components/inline_cell_stale.html +20 -0
- hyperadmin/templates/components/inline_editor.html +85 -0
- hyperadmin/templates/components/inline_formset.html +34 -0
- hyperadmin/templates/components/inline_row.html +49 -0
- hyperadmin/templates/components/list_error.html +12 -0
- hyperadmin/templates/components/menu.html +74 -0
- hyperadmin/templates/components/nav_pinned.html +24 -0
- hyperadmin/templates/components/pagination.html +87 -0
- hyperadmin/templates/components/panel_document.html +19 -0
- hyperadmin/templates/components/panel_states.html +35 -0
- hyperadmin/templates/components/panel_tab_strip.html +31 -0
- hyperadmin/templates/components/pill.html +15 -0
- hyperadmin/templates/components/popover.html +59 -0
- hyperadmin/templates/components/presence_banner.html +28 -0
- hyperadmin/templates/components/progress.html +72 -0
- hyperadmin/templates/components/saved_views.html +61 -0
- hyperadmin/templates/components/search_input.html +19 -0
- hyperadmin/templates/components/seg.html +38 -0
- hyperadmin/templates/components/shortcuts_overlay.html +45 -0
- hyperadmin/templates/components/sortable_header.html +23 -0
- hyperadmin/templates/components/table.html +45 -0
- hyperadmin/templates/components/table_body.html +86 -0
- hyperadmin/templates/components/thumbnail.html +8 -0
- hyperadmin/templates/components/toast.html +36 -0
- hyperadmin/templates/components/tooltip.html +20 -0
- hyperadmin/templates/create.html +43 -0
- hyperadmin/templates/dashboard.html +8 -0
- hyperadmin/templates/detail.html +120 -0
- hyperadmin/templates/detail_layout.html +15 -0
- hyperadmin/templates/error.html +24 -0
- hyperadmin/templates/form_layout.html +26 -0
- hyperadmin/templates/list.html +5 -0
- hyperadmin/templates/list_layout.html +105 -0
- hyperadmin/templates/login.html +79 -0
- hyperadmin/templates/permissions/_banner.html +55 -0
- hyperadmin/templates/permissions/_diff_row.html +6 -0
- hyperadmin/templates/permissions/_group_gone.html +16 -0
- hyperadmin/templates/permissions/_macros.html +22 -0
- hyperadmin/templates/permissions/matrix.html +408 -0
- hyperadmin/templates/permissions/object_popover.html +95 -0
- hyperadmin/templates/update.html +69 -0
- hyperadmin/templates/widgets/autocomplete.html +100 -0
- hyperadmin/templates/widgets/checkbox_input.html +20 -0
- hyperadmin/templates/widgets/choices_options.html +3 -0
- hyperadmin/templates/widgets/date_input.html +13 -0
- hyperadmin/templates/widgets/datetime_input.html +18 -0
- hyperadmin/templates/widgets/encoded_textarea.html +4 -0
- hyperadmin/templates/widgets/file_input.html +15 -0
- hyperadmin/templates/widgets/float_input.html +12 -0
- hyperadmin/templates/widgets/image_input.html +108 -0
- hyperadmin/templates/widgets/multiselect_input.html +13 -0
- hyperadmin/templates/widgets/number_input.html +11 -0
- hyperadmin/templates/widgets/popup_form.html +64 -0
- hyperadmin/templates/widgets/relation_multiselect_input.html +36 -0
- hyperadmin/templates/widgets/relation_select_input.html +38 -0
- hyperadmin/templates/widgets/select_input.html +17 -0
- hyperadmin/templates/widgets/text_input.html +13 -0
- hyperadmin/templates/widgets/textarea.html +4 -0
- hyperadmin/uploads/__init__.py +44 -0
- hyperadmin/uploads/images.py +272 -0
- hyperadmin/uploads/storage.py +265 -0
- hyperadmin/uploads/validation.py +37 -0
- hyperadmin/views/__init__.py +3 -0
- hyperadmin/views/csrf.py +316 -0
- hyperadmin/views/dynamic/__init__.py +35 -0
- hyperadmin/views/dynamic/actions.py +264 -0
- hyperadmin/views/dynamic/base.py +576 -0
- hyperadmin/views/dynamic/concurrency.py +138 -0
- hyperadmin/views/dynamic/core.py +33 -0
- hyperadmin/views/dynamic/create.py +189 -0
- hyperadmin/views/dynamic/detail.py +231 -0
- hyperadmin/views/dynamic/files.py +233 -0
- hyperadmin/views/dynamic/form_data.py +162 -0
- hyperadmin/views/dynamic/helpers.py +151 -0
- hyperadmin/views/dynamic/inline.py +348 -0
- hyperadmin/views/dynamic/list_view.py +612 -0
- hyperadmin/views/dynamic/model_view.py +17 -0
- hyperadmin/views/dynamic/palette_search.py +78 -0
- hyperadmin/views/dynamic/relations.py +544 -0
- hyperadmin/views/dynamic/saved_views.py +159 -0
- hyperadmin/views/dynamic/update.py +313 -0
- hyperadmin/views/error_pages.py +46 -0
- hyperadmin/views/forms.py +1294 -0
- hyperadmin/views/htmx.py +53 -0
- hyperadmin/views/locale.py +113 -0
- hyperadmin/views/nav_pins.py +149 -0
- hyperadmin/views/navigation.py +143 -0
- hyperadmin/views/palette_context.py +91 -0
- hyperadmin/views/palette_search.py +103 -0
- hyperadmin/views/permissions_matrix.py +490 -0
- hyperadmin/views/rate_limit.py +87 -0
- hyperadmin/views/route.py +316 -0
- hyperadmin/views/static.py +138 -0
- hyperadmin/views/template_filters.py +305 -0
- hyperadmin/views/uploads.py +92 -0
- hyperadmin/views/urls.py +180 -0
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* HyperAdmin FK/M2M autocomplete — behaviour for widgets/autocomplete.html
|
|
3
|
+
* (H6, v0.5.5; design: components/AutocompleteStates).
|
|
4
|
+
*
|
|
5
|
+
* Everything is delegated on `document`, so widgets swapped in by HTMX need
|
|
6
|
+
* no initialisation. Without this script the widget still works: the native
|
|
7
|
+
* select carries the value and the search input swaps the choices fragment
|
|
8
|
+
* into it. This adds:
|
|
9
|
+
*
|
|
10
|
+
* - the dependent-field waiting state: while the parent field is empty the
|
|
11
|
+
* search input, the select and the "+" button are disabled and the select
|
|
12
|
+
* lists nothing; when the parent changes the field clears itself, says so
|
|
13
|
+
* in its help text and `role="status"`, and htmx fetches again;
|
|
14
|
+
* - the clear button (shown while the input has text) and the status
|
|
15
|
+
* announcements ("Searching", "3 results", "No results");
|
|
16
|
+
* - on a single-value widget the search input becomes the one visible control,
|
|
17
|
+
* an ARIA combobox: it shows the chosen label, the native select (still the
|
|
18
|
+
* value carrier) turns into the listbox popup, ArrowUp/ArrowDown move the
|
|
19
|
+
* active option (aria-activedescendant), Enter picks it, Escape closes;
|
|
20
|
+
* - the inline-create popup: the "+" button loads the popup into
|
|
21
|
+
* #ha-popup-root. A successful popup POST answers with an empty body and
|
|
22
|
+
* `HX-Trigger: {"hyperadminPopupCreated": {"target", "id", "label"}}`;
|
|
23
|
+
* this inserts the new row into the target field's select, selects it,
|
|
24
|
+
* fires `change` (so dependent widgets re-fetch) and closes the popup.
|
|
25
|
+
* Escape, the backdrop and any [data-ha-popup-close] element close it too;
|
|
26
|
+
* focus moves into the dialog when it opens and back to the "+" on close.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
(function () {
|
|
30
|
+
"use strict";
|
|
31
|
+
|
|
32
|
+
var WIDGET = ".ha-autocomplete";
|
|
33
|
+
var BLANK_OPTION = '<option value="">---------</option>';
|
|
34
|
+
var lastTrigger = null;
|
|
35
|
+
|
|
36
|
+
function popupRoot() {
|
|
37
|
+
return document.getElementById("ha-popup-root");
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function closePopup() {
|
|
41
|
+
var root = popupRoot();
|
|
42
|
+
if (!root || !root.firstElementChild) return;
|
|
43
|
+
root.innerHTML = "";
|
|
44
|
+
if (lastTrigger && document.contains(lastTrigger)) lastTrigger.focus();
|
|
45
|
+
lastTrigger = null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function targetSelect(name) {
|
|
49
|
+
var selects = document.querySelectorAll("select[data-ha-autocomplete-select]");
|
|
50
|
+
for (var i = 0; i < selects.length; i++) {
|
|
51
|
+
if (selects[i].name === name) return selects[i];
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function parts(widget) {
|
|
57
|
+
return {
|
|
58
|
+
widget: widget,
|
|
59
|
+
combobox: widget.querySelector(".ha-combobox"),
|
|
60
|
+
input: widget.querySelector(".ha-autocomplete__search"),
|
|
61
|
+
select: widget.querySelector("select[data-ha-autocomplete-select]"),
|
|
62
|
+
add: widget.querySelector(".ha-autocomplete__add"),
|
|
63
|
+
clear: widget.querySelector("[data-ha-autocomplete-clear]"),
|
|
64
|
+
status: widget.querySelector('[role="status"]'),
|
|
65
|
+
help: widget.parentNode ? widget.parentNode.querySelector("[data-ha-autocomplete-help]") : null
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function parentField(widget) {
|
|
70
|
+
var name = widget.getAttribute("data-depends-on");
|
|
71
|
+
if (!name) return null;
|
|
72
|
+
var form = widget.closest("form") || document;
|
|
73
|
+
return form.querySelector("[name='" + name + "']");
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function parentValue(widget) {
|
|
77
|
+
var parent = parentField(widget);
|
|
78
|
+
return parent ? parent.value : "";
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function setStatus(w, text) {
|
|
82
|
+
if (w.status) w.status.textContent = text;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function setHelp(w, key) {
|
|
86
|
+
if (!w.help) return;
|
|
87
|
+
w.help.textContent = w.help.getAttribute("data-text-" + key) || "";
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function setWaiting(w, waiting) {
|
|
91
|
+
if (!w.combobox) return;
|
|
92
|
+
w.combobox.classList.toggle("is-waiting", waiting);
|
|
93
|
+
if (waiting && isCombo(w.widget)) closeList(w);
|
|
94
|
+
if (w.input) w.input.disabled = waiting;
|
|
95
|
+
if (w.add) w.add.disabled = waiting;
|
|
96
|
+
if (w.select) {
|
|
97
|
+
w.select.disabled = waiting;
|
|
98
|
+
if (waiting && !w.select.multiple) w.select.innerHTML = BLANK_OPTION;
|
|
99
|
+
if (waiting && w.select.multiple) w.select.innerHTML = "";
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function syncClear(w) {
|
|
104
|
+
if (w.clear && w.input) w.clear.hidden = !w.input.value;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function resultCount(w) {
|
|
108
|
+
if (!w.select) return 0;
|
|
109
|
+
var n = 0;
|
|
110
|
+
for (var i = 0; i < w.select.options.length; i++) {
|
|
111
|
+
if (w.select.options[i].value !== "") n++;
|
|
112
|
+
}
|
|
113
|
+
return n;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function announceResults(w) {
|
|
117
|
+
var n = resultCount(w);
|
|
118
|
+
if (n === 0) {
|
|
119
|
+
setStatus(w, w.widget.getAttribute("data-text-no-results") || "No results");
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
var template = w.widget.getAttribute("data-text-results") || "{count} results";
|
|
123
|
+
setStatus(w, template.replace("{count}", String(n)));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
// ---- single-value combobox (st-ux-erp-12) ------------------------------
|
|
128
|
+
|
|
129
|
+
function isCombo(widget) {
|
|
130
|
+
return !!widget && widget.classList.contains("ha-autocomplete--combobox");
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function comboOptions(w) {
|
|
134
|
+
var out = [];
|
|
135
|
+
for (var i = 0; i < w.select.options.length; i++) {
|
|
136
|
+
if (w.select.options[i].value !== "") out.push(w.select.options[i]);
|
|
137
|
+
}
|
|
138
|
+
return out;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function syncLabel(w) {
|
|
142
|
+
var chosen = w.select.selectedOptions && w.select.selectedOptions[0];
|
|
143
|
+
w.input.value = chosen && chosen.value !== "" ? chosen.textContent : "";
|
|
144
|
+
syncClear(w);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function setActive(w, option) {
|
|
148
|
+
for (var i = 0; i < w.select.options.length; i++) {
|
|
149
|
+
w.select.options[i].removeAttribute("data-ha-active");
|
|
150
|
+
}
|
|
151
|
+
if (option) {
|
|
152
|
+
if (!option.id) option.id = w.select.id + "-opt-" + option.index;
|
|
153
|
+
option.setAttribute("data-ha-active", "");
|
|
154
|
+
w.input.setAttribute("aria-activedescendant", option.id);
|
|
155
|
+
if (option.scrollIntoView) option.scrollIntoView({ block: "nearest" });
|
|
156
|
+
} else {
|
|
157
|
+
w.input.removeAttribute("aria-activedescendant");
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function activeOption(w) {
|
|
162
|
+
return w.select.querySelector("option[data-ha-active]");
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function sizeList(w) {
|
|
166
|
+
w.select.size = Math.max(2, Math.min(6, comboOptions(w).length));
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// The list opens flush under the field, or flush above it when the viewport
|
|
170
|
+
// bottom leaves less room than the list needs and the top leaves more.
|
|
171
|
+
function placeList(w) {
|
|
172
|
+
var field = w.widget.getBoundingClientRect();
|
|
173
|
+
var below = window.innerHeight - field.bottom;
|
|
174
|
+
var above = w.select.offsetHeight > below && field.top > below;
|
|
175
|
+
w.widget.classList.toggle("is-above", above);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function openList(w) {
|
|
179
|
+
if (w.input.disabled || w.widget.classList.contains("is-open")) return;
|
|
180
|
+
sizeList(w);
|
|
181
|
+
w.widget.classList.add("is-open");
|
|
182
|
+
placeList(w);
|
|
183
|
+
w.input.setAttribute("aria-expanded", "true");
|
|
184
|
+
w.select.removeAttribute("aria-hidden");
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function closeList(w) {
|
|
188
|
+
setActive(w, null);
|
|
189
|
+
w.widget.classList.remove("is-open");
|
|
190
|
+
w.input.setAttribute("aria-expanded", "false");
|
|
191
|
+
w.select.setAttribute("aria-hidden", "true");
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function choose(w, option) {
|
|
195
|
+
option.selected = true;
|
|
196
|
+
w.select.dispatchEvent(new Event("change", { bubbles: true }));
|
|
197
|
+
w.input.focus();
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function enhance(w) {
|
|
201
|
+
if (!w.input || !w.select || w.select.multiple) return;
|
|
202
|
+
w.widget.classList.add("ha-autocomplete--combobox");
|
|
203
|
+
w.input.setAttribute("role", "combobox");
|
|
204
|
+
w.input.setAttribute("aria-autocomplete", "list");
|
|
205
|
+
w.input.setAttribute("aria-haspopup", "listbox");
|
|
206
|
+
w.input.setAttribute("aria-expanded", "false");
|
|
207
|
+
w.select.setAttribute("role", "listbox");
|
|
208
|
+
w.select.setAttribute("aria-hidden", "true");
|
|
209
|
+
w.select.setAttribute("tabindex", "-1");
|
|
210
|
+
sizeList(w);
|
|
211
|
+
syncLabel(w);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function comboOf(node) {
|
|
215
|
+
var widget = node && node.closest ? node.closest(WIDGET) : null;
|
|
216
|
+
return isCombo(widget) ? parts(widget) : null;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function init(widget) {
|
|
220
|
+
if (widget.hasAttribute("data-ha-autocomplete-ready")) return;
|
|
221
|
+
widget.setAttribute("data-ha-autocomplete-ready", "");
|
|
222
|
+
var w = parts(widget);
|
|
223
|
+
enhance(w);
|
|
224
|
+
syncClear(w);
|
|
225
|
+
if (widget.hasAttribute("data-depends-on")) {
|
|
226
|
+
setWaiting(w, parentValue(widget) === "");
|
|
227
|
+
setHelp(w, "waiting");
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function initAll(root) {
|
|
232
|
+
var scope = root && root.querySelectorAll ? root : document;
|
|
233
|
+
var widgets = scope.querySelectorAll(WIDGET);
|
|
234
|
+
for (var i = 0; i < widgets.length; i++) init(widgets[i]);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function dependents(parent) {
|
|
238
|
+
var form = parent.closest("form") || document;
|
|
239
|
+
var found = [];
|
|
240
|
+
var widgets = form.querySelectorAll(WIDGET + "[data-depends-on='" + parent.name + "']");
|
|
241
|
+
for (var i = 0; i < widgets.length; i++) found.push(widgets[i]);
|
|
242
|
+
return found;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
if (document.readyState === "loading") {
|
|
246
|
+
document.addEventListener("DOMContentLoaded", function () {
|
|
247
|
+
initAll(document);
|
|
248
|
+
});
|
|
249
|
+
} else {
|
|
250
|
+
initAll(document);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
document.addEventListener("htmx:load", function (event) {
|
|
254
|
+
initAll(event.target);
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
// Capture phase: runs before htmx's own `change from:[name=parent]` listener,
|
|
258
|
+
// so the dependent input is enabled (or blanked) before the re-fetch fires.
|
|
259
|
+
document.addEventListener(
|
|
260
|
+
"change",
|
|
261
|
+
function (event) {
|
|
262
|
+
var parent = event.target;
|
|
263
|
+
if (!parent || !parent.name) return;
|
|
264
|
+
var children = dependents(parent);
|
|
265
|
+
for (var i = 0; i < children.length; i++) {
|
|
266
|
+
var w = parts(children[i]);
|
|
267
|
+
if (w.input) w.input.value = "";
|
|
268
|
+
if (w.select && !w.select.multiple) w.select.value = "";
|
|
269
|
+
setWaiting(w, parent.value === "");
|
|
270
|
+
syncClear(w);
|
|
271
|
+
setHelp(w, "cleared");
|
|
272
|
+
if (w.help) setStatus(w, w.help.getAttribute("data-text-cleared-status") || "");
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
true
|
|
276
|
+
);
|
|
277
|
+
|
|
278
|
+
document.addEventListener("input", function (event) {
|
|
279
|
+
var input = event.target;
|
|
280
|
+
if (!input.closest || !input.classList.contains("ha-autocomplete__search")) return;
|
|
281
|
+
var widget = input.closest(WIDGET);
|
|
282
|
+
if (widget) syncClear(parts(widget));
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
document.addEventListener("htmx:beforeRequest", function (event) {
|
|
286
|
+
var input = event.target;
|
|
287
|
+
if (!input.closest || !input.classList.contains("ha-autocomplete__search")) return;
|
|
288
|
+
var widget = input.closest(WIDGET);
|
|
289
|
+
if (!widget) return;
|
|
290
|
+
setStatus(parts(widget), widget.getAttribute("data-text-searching") || "Searching");
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
// The choices fragment replaces every <option>; remember the chosen one so a search
|
|
294
|
+
// that no longer lists it does not silently change the submitted value.
|
|
295
|
+
document.addEventListener("htmx:beforeSwap", function (event) {
|
|
296
|
+
var select = event.target;
|
|
297
|
+
if (!select.hasAttribute || !select.hasAttribute("data-ha-autocomplete-select")) return;
|
|
298
|
+
var chosen = select.selectedOptions && select.selectedOptions[0];
|
|
299
|
+
select.haChosen =
|
|
300
|
+
chosen && chosen.value !== "" ? { value: chosen.value, label: chosen.textContent } : null;
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
document.addEventListener("htmx:afterSwap", function (event) {
|
|
304
|
+
var select = event.target;
|
|
305
|
+
if (!select.closest || !select.hasAttribute("data-ha-autocomplete-select")) return;
|
|
306
|
+
var widget = select.closest(WIDGET);
|
|
307
|
+
if (!widget) return;
|
|
308
|
+
announceResults(parts(widget));
|
|
309
|
+
if (isCombo(widget)) setActive(parts(widget), null);
|
|
310
|
+
var chosen = select.haChosen;
|
|
311
|
+
select.haChosen = null;
|
|
312
|
+
if (select.multiple) return;
|
|
313
|
+
var found = null;
|
|
314
|
+
for (var i = 0; chosen && i < select.options.length; i++) {
|
|
315
|
+
if (select.options[i].value === chosen.value) found = select.options[i];
|
|
316
|
+
}
|
|
317
|
+
select.insertAdjacentHTML("afterbegin", BLANK_OPTION);
|
|
318
|
+
if (found) {
|
|
319
|
+
found.selected = true;
|
|
320
|
+
} else if (chosen) {
|
|
321
|
+
var kept = document.createElement("option");
|
|
322
|
+
kept.value = chosen.value;
|
|
323
|
+
kept.textContent = chosen.label;
|
|
324
|
+
kept.selected = true;
|
|
325
|
+
select.options[0].after(kept);
|
|
326
|
+
} else {
|
|
327
|
+
select.selectedIndex = 0;
|
|
328
|
+
}
|
|
329
|
+
if (isCombo(widget)) {
|
|
330
|
+
sizeList(parts(widget));
|
|
331
|
+
if (widget.classList.contains("is-open")) placeList(parts(widget));
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
// Combobox behaviour: open on focus/click/typing, pick by click or keyboard.
|
|
337
|
+
document.addEventListener("focusin", function (event) {
|
|
338
|
+
var w = comboOf(event.target);
|
|
339
|
+
if (w && event.target === w.input) {
|
|
340
|
+
openList(w);
|
|
341
|
+
w.input.select();
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
document.addEventListener("focusout", function (event) {
|
|
346
|
+
var w = comboOf(event.target);
|
|
347
|
+
if (!w || (event.relatedTarget && w.widget.contains(event.relatedTarget))) return;
|
|
348
|
+
closeList(w);
|
|
349
|
+
syncLabel(w);
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
document.addEventListener("click", function (event) {
|
|
353
|
+
var target = event.target;
|
|
354
|
+
var w = comboOf(target);
|
|
355
|
+
if (!w) return;
|
|
356
|
+
if (target === w.input) {
|
|
357
|
+
openList(w);
|
|
358
|
+
} else if (target.tagName === "OPTION" && target.parentNode === w.select) {
|
|
359
|
+
if (target.value !== "") choose(w, target);
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
// Keep focus in the input while the pointer works the list.
|
|
364
|
+
document.addEventListener("mousedown", function (event) {
|
|
365
|
+
var target = event.target;
|
|
366
|
+
var w = comboOf(target);
|
|
367
|
+
if (w && (target === w.select || target.parentNode === w.select)) event.preventDefault();
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
document.addEventListener("input", function (event) {
|
|
371
|
+
var w = comboOf(event.target);
|
|
372
|
+
if (w && event.target === w.input) openList(w);
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
// The select is the value carrier: any change (pick, test, popup-created row) refreshes the label.
|
|
376
|
+
document.addEventListener("change", function (event) {
|
|
377
|
+
var w = comboOf(event.target);
|
|
378
|
+
if (!w || event.target !== w.select) return;
|
|
379
|
+
syncLabel(w);
|
|
380
|
+
closeList(w);
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
document.addEventListener("keydown", function (event) {
|
|
384
|
+
var w = comboOf(event.target);
|
|
385
|
+
if (!w || event.target !== w.input) return;
|
|
386
|
+
var open = w.widget.classList.contains("is-open");
|
|
387
|
+
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
388
|
+
event.preventDefault();
|
|
389
|
+
openList(w);
|
|
390
|
+
var options = comboOptions(w);
|
|
391
|
+
if (!options.length) return;
|
|
392
|
+
var at = options.indexOf(activeOption(w));
|
|
393
|
+
var step = event.key === "ArrowDown" ? 1 : -1;
|
|
394
|
+
var next = at === -1 ? (step === 1 ? 0 : options.length - 1) : (at + step + options.length) % options.length;
|
|
395
|
+
setActive(w, options[next]);
|
|
396
|
+
} else if (event.key === "Enter" && open && activeOption(w)) {
|
|
397
|
+
event.preventDefault();
|
|
398
|
+
choose(w, activeOption(w));
|
|
399
|
+
} else if (event.key === "Escape" && open) {
|
|
400
|
+
event.preventDefault(); // a type=search input would otherwise clear itself and reopen
|
|
401
|
+
event.stopPropagation();
|
|
402
|
+
closeList(w);
|
|
403
|
+
syncLabel(w);
|
|
404
|
+
} else if (event.key === "Tab") {
|
|
405
|
+
closeList(w);
|
|
406
|
+
}
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
document.addEventListener("hyperadminPopupCreated", function (event) {
|
|
410
|
+
var detail = event.detail || {};
|
|
411
|
+
var select = targetSelect(String(detail.target));
|
|
412
|
+
if (select && detail.id !== null && detail.id !== undefined) {
|
|
413
|
+
var value = String(detail.id);
|
|
414
|
+
var option = null;
|
|
415
|
+
for (var i = 0; i < select.options.length; i++) {
|
|
416
|
+
if (select.options[i].value === value) option = select.options[i];
|
|
417
|
+
}
|
|
418
|
+
if (!option) {
|
|
419
|
+
option = document.createElement("option");
|
|
420
|
+
option.value = value;
|
|
421
|
+
select.appendChild(option);
|
|
422
|
+
}
|
|
423
|
+
option.textContent = String(detail.label);
|
|
424
|
+
option.selected = true;
|
|
425
|
+
select.dispatchEvent(new Event("change", { bubbles: true }));
|
|
426
|
+
}
|
|
427
|
+
closePopup();
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
document.addEventListener("click", function (event) {
|
|
431
|
+
var target = event.target;
|
|
432
|
+
if (!target.closest) return;
|
|
433
|
+
|
|
434
|
+
var clear = target.closest("[data-ha-autocomplete-clear]");
|
|
435
|
+
if (clear) {
|
|
436
|
+
var widget = clear.closest(WIDGET);
|
|
437
|
+
var w = parts(widget);
|
|
438
|
+
if (isCombo(widget) && w.select.value !== "") {
|
|
439
|
+
w.select.value = "";
|
|
440
|
+
w.select.dispatchEvent(new Event("change", { bubbles: true }));
|
|
441
|
+
}
|
|
442
|
+
if (w.input) {
|
|
443
|
+
w.input.value = "";
|
|
444
|
+
w.input.focus();
|
|
445
|
+
w.input.dispatchEvent(new Event("search", { bubbles: true }));
|
|
446
|
+
}
|
|
447
|
+
syncClear(w);
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
var add = target.closest(".ha-autocomplete__add");
|
|
452
|
+
if (add) lastTrigger = add;
|
|
453
|
+
|
|
454
|
+
var root = popupRoot();
|
|
455
|
+
if (!root) return;
|
|
456
|
+
if (target === root || target.closest("[data-ha-popup-close]")) {
|
|
457
|
+
closePopup();
|
|
458
|
+
}
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
// The popup dialog takes focus when it is swapped in (WCAG: focus moves into a modal).
|
|
462
|
+
document.addEventListener("htmx:afterSwap", function (event) {
|
|
463
|
+
var root = popupRoot();
|
|
464
|
+
if (!root || event.target !== root) return;
|
|
465
|
+
var dialog = root.querySelector('[role="dialog"]');
|
|
466
|
+
if (!dialog) return;
|
|
467
|
+
var first = dialog.querySelector("input:not([type=hidden]), select, textarea, button");
|
|
468
|
+
(first || dialog).focus();
|
|
469
|
+
});
|
|
470
|
+
|
|
471
|
+
document.addEventListener("keydown", function (event) {
|
|
472
|
+
var root = popupRoot();
|
|
473
|
+
if (event.key === "Escape" && root && root.firstElementChild) closePopup();
|
|
474
|
+
});
|
|
475
|
+
})();
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* HyperAdmin shared delete confirmation (st-v059-list-03).
|
|
3
|
+
*
|
|
4
|
+
* One <dialog id="ha-confirm-delete"> (components/confirm_delete_dialog.html,
|
|
5
|
+
* included once by base.html) serves every delete button on the list, detail
|
|
6
|
+
* and edit pages. A trigger is any element with
|
|
7
|
+
*
|
|
8
|
+
* data-ha-confirm-delete="<DELETE url>" data-ha-label="<object name>"
|
|
9
|
+
*
|
|
10
|
+
* Clicking it dispatches a bubbling `ha-confirm-delete` event with
|
|
11
|
+
* {url, label}; other scripts may dispatch the same event to reuse the dialog.
|
|
12
|
+
* The dialog opens with showModal() (focus trap, Esc and backdrop come from the
|
|
13
|
+
* browser), says "Delete <label>?" and focuses Cancel. Confirm sends the DELETE
|
|
14
|
+
* with htmx.ajax, sourced from the dialog so the CSRF header from
|
|
15
|
+
* <body hx-headers> applies; the server's HX-Redirect then reloads the page and
|
|
16
|
+
* a refusal (403 / 404 / 409) arrives as the existing error toast. Closing, by
|
|
17
|
+
* Cancel, Esc or after the request, returns focus to the trigger.
|
|
18
|
+
*
|
|
19
|
+
* Delegated on document: rows swapped in by HTMX need no initialisation.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
(function () {
|
|
23
|
+
"use strict";
|
|
24
|
+
|
|
25
|
+
if (window.hyperadminConfirmDelete) return;
|
|
26
|
+
window.hyperadminConfirmDelete = true;
|
|
27
|
+
|
|
28
|
+
var DIALOG_ID = "ha-confirm-delete";
|
|
29
|
+
var state = { url: null, opener: null };
|
|
30
|
+
|
|
31
|
+
function dialog() {
|
|
32
|
+
return document.getElementById(DIALOG_ID);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function setBusy(box, busy) {
|
|
36
|
+
var ok = box.querySelector("[data-ha-confirm-ok]");
|
|
37
|
+
if (!ok) return;
|
|
38
|
+
ok.disabled = busy;
|
|
39
|
+
if (busy) ok.setAttribute("aria-busy", "true");
|
|
40
|
+
else ok.removeAttribute("aria-busy");
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function open(url, label, opener) {
|
|
44
|
+
var box = dialog();
|
|
45
|
+
if (!box || box.open || !url) return;
|
|
46
|
+
state.url = url;
|
|
47
|
+
state.opener = opener;
|
|
48
|
+
var title = box.querySelector("#" + DIALOG_ID + "-title");
|
|
49
|
+
var template = box.getAttribute("data-title-template");
|
|
50
|
+
if (title && template) title.textContent = template.replace("{name}", label || "");
|
|
51
|
+
setBusy(box, false);
|
|
52
|
+
box.showModal();
|
|
53
|
+
var cancel = box.querySelector("[data-ha-confirm-cancel]");
|
|
54
|
+
if (cancel) cancel.focus();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function close() {
|
|
58
|
+
var box = dialog();
|
|
59
|
+
if (box && box.open) box.close();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function confirm() {
|
|
63
|
+
var box = dialog();
|
|
64
|
+
if (!box || !state.url || !window.htmx) return;
|
|
65
|
+
setBusy(box, true);
|
|
66
|
+
var done = function () {
|
|
67
|
+
close();
|
|
68
|
+
};
|
|
69
|
+
window.htmx.ajax("DELETE", state.url, { source: box, swap: "none" }).then(done, done);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
document.addEventListener("click", function (event) {
|
|
73
|
+
var target = event.target;
|
|
74
|
+
if (!target || !target.closest) return;
|
|
75
|
+
var trigger = target.closest("[data-ha-confirm-delete]");
|
|
76
|
+
if (trigger) {
|
|
77
|
+
event.preventDefault();
|
|
78
|
+
trigger.dispatchEvent(
|
|
79
|
+
new CustomEvent("ha-confirm-delete", {
|
|
80
|
+
bubbles: true,
|
|
81
|
+
detail: {
|
|
82
|
+
url: trigger.getAttribute("data-ha-confirm-delete"),
|
|
83
|
+
label: trigger.getAttribute("data-ha-label") || "",
|
|
84
|
+
},
|
|
85
|
+
})
|
|
86
|
+
);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (!target.closest("#" + DIALOG_ID)) return;
|
|
90
|
+
if (target.closest("[data-ha-confirm-cancel]")) close();
|
|
91
|
+
else if (target.closest("[data-ha-confirm-ok]")) confirm();
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
document.addEventListener("ha-confirm-delete", function (event) {
|
|
95
|
+
var detail = event.detail || {};
|
|
96
|
+
var opener = event.target instanceof HTMLElement ? event.target : document.activeElement;
|
|
97
|
+
open(detail.url, detail.label, opener);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// "close" fires for Cancel, Esc and after the request alike.
|
|
101
|
+
document.addEventListener(
|
|
102
|
+
"close",
|
|
103
|
+
function (event) {
|
|
104
|
+
if (!event.target || event.target.id !== DIALOG_ID) return;
|
|
105
|
+
var opener = state.opener;
|
|
106
|
+
state.url = null;
|
|
107
|
+
state.opener = null;
|
|
108
|
+
setBusy(event.target, false);
|
|
109
|
+
if (opener && opener.isConnected && typeof opener.focus === "function") opener.focus();
|
|
110
|
+
},
|
|
111
|
+
true
|
|
112
|
+
);
|
|
113
|
+
})();
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* HyperAdmin form error summary (st-ux-erp-06).
|
|
3
|
+
*
|
|
4
|
+
* The summary rendered by components/error_summary.html takes focus when the
|
|
5
|
+
* page loads with it, and after an htmx swap puts a fresh one on screen. A link
|
|
6
|
+
* in it focuses the field it names instead of only scrolling to it.
|
|
7
|
+
*/
|
|
8
|
+
(function () {
|
|
9
|
+
'use strict';
|
|
10
|
+
var SUMMARY = '[data-testid="error-summary"]';
|
|
11
|
+
|
|
12
|
+
function focusSummary() {
|
|
13
|
+
var el = document.querySelector(SUMMARY);
|
|
14
|
+
if (el) { el.focus(); }
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
document.addEventListener('click', function (e) {
|
|
18
|
+
var link = e.target.closest && e.target.closest('a[data-ha-error-link]');
|
|
19
|
+
if (!link) { return; }
|
|
20
|
+
var field = document.getElementById((link.getAttribute('href') || '').slice(1));
|
|
21
|
+
if (!field) { return; }
|
|
22
|
+
e.preventDefault();
|
|
23
|
+
field.focus();
|
|
24
|
+
field.scrollIntoView({ block: 'center' });
|
|
25
|
+
});
|
|
26
|
+
// Only the form's own swap moves focus: a field's htmx validation, an
|
|
27
|
+
// autocomplete or an inline-row add settling must not pull focus away.
|
|
28
|
+
document.addEventListener('htmx:afterSettle', function (evt) {
|
|
29
|
+
var t = (evt.detail && evt.detail.target) || evt.target;
|
|
30
|
+
if (t && t.id && /-form-body$/.test(t.id)) { focusSummary(); }
|
|
31
|
+
});
|
|
32
|
+
if (document.readyState === 'loading') {
|
|
33
|
+
document.addEventListener('DOMContentLoaded', focusSummary);
|
|
34
|
+
} else {
|
|
35
|
+
focusSummary();
|
|
36
|
+
}
|
|
37
|
+
})();
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* HyperAdmin unsaved-changes guard and Cmd/Ctrl+S (st-v059-kbd-01).
|
|
3
|
+
*
|
|
4
|
+
* A form carrying data-ha-guard="<leave prompt>" (the model form, unless
|
|
5
|
+
* AdminOptions(warn_unsaved_changes=False), and the popup create form) turns
|
|
6
|
+
* dirty on its first input or change event, inline formset rows included.
|
|
7
|
+
* While any guarded form on the page is dirty:
|
|
8
|
+
* - leaving the page (link, reload, closing the tab) asks via beforeunload;
|
|
9
|
+
* - an htmx request whose target would replace the form (a boosted link,
|
|
10
|
+
* an hx-get on an ancestor) asks with the form's prompt first.
|
|
11
|
+
* Saving never asks: a form's own request is not guarded, and a 2xx answer
|
|
12
|
+
* (the server's HX-Redirect after a save) marks that form clean before htmx
|
|
13
|
+
* navigates. A 422 re-render keeps it dirty.
|
|
14
|
+
* Delete from the edit page asks once: the delete dialog is the confirmation.
|
|
15
|
+
* Its successful DELETE marks every form clean, so the redirect that follows
|
|
16
|
+
* does not ask again; Cancel or a refused delete (403/404/409) keeps the edits
|
|
17
|
+
* guarded.
|
|
18
|
+
* mod+s submits the open popup form, else the model form, with requestSubmit()
|
|
19
|
+
* (validation and htmx run as for Save); it does nothing while a modal
|
|
20
|
+
* <dialog> is open and leaves the browser's Save alone on pages without one.
|
|
21
|
+
*/
|
|
22
|
+
(function () {
|
|
23
|
+
'use strict';
|
|
24
|
+
var GUARD = 'form[data-ha-guard]';
|
|
25
|
+
|
|
26
|
+
function forms() { return [].slice.call(document.querySelectorAll(GUARD)); }
|
|
27
|
+
function dirty() { return forms().filter(function (f) { return f.haDirty; })[0]; }
|
|
28
|
+
function clean(f) { f.haDirty = false; }
|
|
29
|
+
|
|
30
|
+
function touch(e) {
|
|
31
|
+
var f = e.target.closest && e.target.closest(GUARD);
|
|
32
|
+
if (f) f.haDirty = true;
|
|
33
|
+
}
|
|
34
|
+
document.addEventListener('input', touch);
|
|
35
|
+
document.addEventListener('change', touch);
|
|
36
|
+
// A plain (non-htmx) submit leaves the page on purpose; htmx cancels its own.
|
|
37
|
+
document.addEventListener('submit', function (e) {
|
|
38
|
+
if (!e.defaultPrevented && e.target.matches(GUARD)) clean(e.target);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
window.addEventListener('beforeunload', function (e) {
|
|
42
|
+
if (!dirty()) return;
|
|
43
|
+
e.preventDefault();
|
|
44
|
+
e.returnValue = '';
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
document.addEventListener('htmx:confirm', function (e) {
|
|
48
|
+
var d = e.detail;
|
|
49
|
+
var f = dirty();
|
|
50
|
+
if (!f || !d.target || !d.target.contains(f) || f.contains(d.elt)) return;
|
|
51
|
+
e.preventDefault();
|
|
52
|
+
if (window.confirm(f.getAttribute('data-ha-guard'))) {
|
|
53
|
+
forms().forEach(clean);
|
|
54
|
+
d.issueRequest(true);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
document.addEventListener('htmx:beforeOnLoad', function (e) {
|
|
59
|
+
var s = e.detail.elt;
|
|
60
|
+
if (e.detail.xhr.status > 299) return;
|
|
61
|
+
if (s.matches(GUARD)) clean(s);
|
|
62
|
+
else if (s.closest('#ha-confirm-delete')) forms().forEach(clean);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
if (window.haShortcuts) {
|
|
66
|
+
window.haShortcuts.register({
|
|
67
|
+
keys: 'mod+s',
|
|
68
|
+
scope: 'form',
|
|
69
|
+
description: 'Save',
|
|
70
|
+
handler: function () {
|
|
71
|
+
var f = document.querySelector('#ha-popup-root form') || document.querySelector('[data-testid="model-form"]');
|
|
72
|
+
if (!f) return false;
|
|
73
|
+
if (!document.querySelector('dialog[open]')) f.requestSubmit();
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
})();
|