django-bootstrap6-admin 0.1.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.
Files changed (52) hide show
  1. django_bootstrap6_admin/__init__.py +3 -0
  2. django_bootstrap6_admin/apps.py +13 -0
  3. django_bootstrap6_admin/static/django_bootstrap6_admin/css/admin.css +3530 -0
  4. django_bootstrap6_admin/static/django_bootstrap6_admin/css/widgets-overrides.css +47 -0
  5. django_bootstrap6_admin/static/django_bootstrap6_admin/js/admin.js +360 -0
  6. django_bootstrap6_admin/static/django_bootstrap6_admin/js/theme.js +108 -0
  7. django_bootstrap6_admin/static/django_bootstrap6_admin/vendor/bootstrap/LICENSE +21 -0
  8. django_bootstrap6_admin/static/django_bootstrap6_admin/vendor/bootstrap/css/bootstrap.min.css +2 -0
  9. django_bootstrap6_admin/static/django_bootstrap6_admin/vendor/bootstrap/js/bootstrap.bundle.min.js +9 -0
  10. django_bootstrap6_admin/templates/admin/404.html +17 -0
  11. django_bootstrap6_admin/templates/admin/500.html +31 -0
  12. django_bootstrap6_admin/templates/admin/actions.html +40 -0
  13. django_bootstrap6_admin/templates/admin/app_index.html +43 -0
  14. django_bootstrap6_admin/templates/admin/app_list.html +59 -0
  15. django_bootstrap6_admin/templates/admin/auth/user/add_form.html +11 -0
  16. django_bootstrap6_admin/templates/admin/auth/user/change_password.html +105 -0
  17. django_bootstrap6_admin/templates/admin/base.html +220 -0
  18. django_bootstrap6_admin/templates/admin/base_site.html +19 -0
  19. django_bootstrap6_admin/templates/admin/change_form.html +124 -0
  20. django_bootstrap6_admin/templates/admin/change_form_object_tools.html +14 -0
  21. django_bootstrap6_admin/templates/admin/change_list.html +179 -0
  22. django_bootstrap6_admin/templates/admin/change_list_object_tools.html +10 -0
  23. django_bootstrap6_admin/templates/admin/change_list_results.html +42 -0
  24. django_bootstrap6_admin/templates/admin/color_theme_toggle.html +15 -0
  25. django_bootstrap6_admin/templates/admin/date_hierarchy.html +27 -0
  26. django_bootstrap6_admin/templates/admin/delete_confirmation.html +89 -0
  27. django_bootstrap6_admin/templates/admin/delete_selected_confirmation.html +81 -0
  28. django_bootstrap6_admin/templates/admin/edit_inline/stacked.html +67 -0
  29. django_bootstrap6_admin/templates/admin/edit_inline/tabular.html +94 -0
  30. django_bootstrap6_admin/templates/admin/filter.html +17 -0
  31. django_bootstrap6_admin/templates/admin/includes/fieldset.html +54 -0
  32. django_bootstrap6_admin/templates/admin/includes/object_delete_summary.html +7 -0
  33. django_bootstrap6_admin/templates/admin/index.html +136 -0
  34. django_bootstrap6_admin/templates/admin/login.html +99 -0
  35. django_bootstrap6_admin/templates/admin/nav_sidebar.html +21 -0
  36. django_bootstrap6_admin/templates/admin/object_history.html +81 -0
  37. django_bootstrap6_admin/templates/admin/pagination.html +18 -0
  38. django_bootstrap6_admin/templates/admin/search_form.html +28 -0
  39. django_bootstrap6_admin/templates/admin/submit_line.html +35 -0
  40. django_bootstrap6_admin/templates/admin/widgets/foreign_key_raw_id.html +14 -0
  41. django_bootstrap6_admin/templates/admin/widgets/related_widget_wrapper.html +49 -0
  42. django_bootstrap6_admin/templates/registration/logged_out.html +32 -0
  43. django_bootstrap6_admin/templates/registration/password_change_done.html +30 -0
  44. django_bootstrap6_admin/templates/registration/password_change_form.html +74 -0
  45. django_bootstrap6_admin/templatetags/__init__.py +0 -0
  46. django_bootstrap6_admin/templatetags/bootstrap6_admin.py +38 -0
  47. django_bootstrap6_admin-0.1.0.dist-info/METADATA +262 -0
  48. django_bootstrap6_admin-0.1.0.dist-info/RECORD +52 -0
  49. django_bootstrap6_admin-0.1.0.dist-info/WHEEL +5 -0
  50. django_bootstrap6_admin-0.1.0.dist-info/licenses/LICENSE +21 -0
  51. django_bootstrap6_admin-0.1.0.dist-info/licenses/NOTICE +48 -0
  52. django_bootstrap6_admin-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,47 @@
1
+ /* Widget-specific overrides loaded after Django widget media. */
2
+
3
+ /* Django's select2 / autocomplete styles use hard-coded colours. */
4
+
5
+ .select2-container--admin-autocomplete .select2-selection--single,
6
+ .select2-container--admin-autocomplete .select2-selection--multiple {
7
+ min-height: 2.35rem;
8
+ border-color: var(--ba-control-border);
9
+ border-radius: var(--ba-radius-sm);
10
+ background: var(--bs-bg-body);
11
+ color: var(--bs-fg-body);
12
+ }
13
+
14
+ .select2-container--admin-autocomplete .select2-selection--single .select2-selection__rendered {
15
+ color: var(--bs-fg-body);
16
+ line-height: 2.2rem;
17
+ }
18
+
19
+ .select2-container--admin-autocomplete .select2-selection--multiple .select2-selection__choice {
20
+ border: 1px solid var(--bs-primary-border);
21
+ background: var(--bs-primary-bg-subtle);
22
+ color: var(--bs-primary-fg-emphasis);
23
+ }
24
+
25
+ .select2-container--admin-autocomplete .select2-selection--multiple .select2-selection__choice__remove {
26
+ color: var(--bs-primary-fg-emphasis);
27
+ }
28
+
29
+ .select2-dropdown {
30
+ border-color: var(--ba-control-border);
31
+ border-radius: var(--ba-radius-sm);
32
+ background: var(--bs-bg-body);
33
+ color: var(--bs-fg-body);
34
+ box-shadow: var(--ba-shadow-lg);
35
+ }
36
+
37
+ .select2-container--admin-autocomplete .select2-results__option--highlighted[aria-selected] {
38
+ background: var(--bs-primary-bg);
39
+ color: var(--bs-primary-contrast);
40
+ }
41
+
42
+ .select2-container--admin-autocomplete .select2-search--dropdown .select2-search__field {
43
+ border: 1px solid var(--ba-control-border);
44
+ border-radius: 0.3rem;
45
+ background: var(--bs-bg-body);
46
+ color: var(--bs-fg-body);
47
+ }
@@ -0,0 +1,360 @@
1
+ "use strict";
2
+
3
+ /*
4
+ * Small progressive enhancement layer for the Bootstrap 6 admin.
5
+ *
6
+ * Django's own admin JavaScript remains the source of truth for the
7
+ * sidebar state (`#main.shifted` and `#nav-sidebar[aria-expanded]`).
8
+ * This file only mirrors that state to the topbar button, adds a mobile
9
+ * backdrop, and closes the sidebar with Escape or an outside click.
10
+ */
11
+ (() => {
12
+ const MOBILE = window.matchMedia("(max-width: 1023.98px)");
13
+ const STORAGE_KEY = "django.admin.navSidebarIsOpen";
14
+
15
+ function initSidebar() {
16
+ const main = document.getElementById("main");
17
+ const sidebar = document.getElementById("nav-sidebar");
18
+ const nativeToggle = document.getElementById("toggle-nav-sidebar");
19
+ const topbarToggle = document.getElementById("ba-sidebar-toggle");
20
+ const closeButton = document.getElementById("ba-sidebar-close");
21
+ const backdrop = document.getElementById("ba-sidebar-backdrop");
22
+
23
+ if (!topbarToggle) {
24
+ return;
25
+ }
26
+
27
+ // Pages such as the dashboard and the login screen deliberately
28
+ // render without the navigation sidebar.
29
+ if (!main || !sidebar || !nativeToggle) {
30
+ topbarToggle.hidden = true;
31
+ return;
32
+ }
33
+
34
+ function isOpen() {
35
+ return main.classList.contains("shifted");
36
+ }
37
+
38
+ function sync() {
39
+ const open = isOpen();
40
+ topbarToggle.setAttribute("aria-expanded", open ? "true" : "false");
41
+ sidebar.toggleAttribute("inert", !open);
42
+ sidebar.setAttribute("aria-hidden", open ? "false" : "true");
43
+ document.body.classList.toggle(
44
+ "ba-sidebar-open",
45
+ open && MOBILE.matches,
46
+ );
47
+ if (backdrop) {
48
+ backdrop.hidden = !(open && MOBILE.matches);
49
+ }
50
+ }
51
+
52
+ function focusSidebar() {
53
+ if (!MOBILE.matches) {
54
+ return;
55
+ }
56
+ const target =
57
+ closeButton ||
58
+ sidebar.querySelector("#nav-filter, a, button");
59
+ if (target) {
60
+ window.requestAnimationFrame(() => target.focus());
61
+ }
62
+ }
63
+
64
+ function closeSidebar(returnFocus) {
65
+ if (isOpen()) {
66
+ nativeToggle.click();
67
+ }
68
+ if (returnFocus) {
69
+ topbarToggle.focus();
70
+ }
71
+ }
72
+
73
+ topbarToggle.addEventListener("click", () => {
74
+ const opening = !isOpen();
75
+ nativeToggle.click();
76
+ if (opening) {
77
+ focusSidebar();
78
+ }
79
+ });
80
+
81
+ if (closeButton) {
82
+ closeButton.addEventListener("click", () => {
83
+ closeSidebar(true);
84
+ });
85
+ }
86
+
87
+ if (backdrop) {
88
+ backdrop.addEventListener("click", () => {
89
+ closeSidebar(true);
90
+ });
91
+ }
92
+
93
+ document.addEventListener("keydown", (event) => {
94
+ if (event.key === "Escape" && MOBILE.matches && isOpen()) {
95
+ closeSidebar(true);
96
+ }
97
+ });
98
+
99
+ // Close the mobile drawer after choosing a destination. Keeping it
100
+ // open through navigation makes every link cost an extra close tap.
101
+ sidebar.addEventListener("click", (event) => {
102
+ if (!MOBILE.matches || !isOpen()) {
103
+ return;
104
+ }
105
+ const link = event.target.closest("a");
106
+ if (link && sidebar.contains(link)) {
107
+ nativeToggle.click();
108
+ }
109
+ });
110
+
111
+ const observer = new MutationObserver(sync);
112
+ observer.observe(main, {
113
+ attributes: true,
114
+ attributeFilter: ["class"],
115
+ });
116
+ observer.observe(sidebar, {
117
+ attributes: true,
118
+ attributeFilter: ["aria-expanded"],
119
+ });
120
+
121
+ if (MOBILE.addEventListener) {
122
+ MOBILE.addEventListener("change", sync);
123
+ }
124
+
125
+ // On the first mobile visit, open the page with the navigation
126
+ // closed. A stored preference always wins.
127
+ if (MOBILE.matches && localStorage.getItem(STORAGE_KEY) === null) {
128
+ window.requestAnimationFrame(() => {
129
+ if (isOpen()) {
130
+ nativeToggle.click();
131
+ }
132
+ });
133
+ }
134
+
135
+ sync();
136
+ }
137
+
138
+ function initAccessibility() {
139
+ // SelectFilter2 generates a span with aria-label but no role.
140
+ document
141
+ .querySelectorAll(
142
+ ".selector-filter .help-tooltip.search-label-icon[aria-label]",
143
+ )
144
+ .forEach((element) => {
145
+ if (!element.hasAttribute("role")) {
146
+ element.setAttribute("role", "img");
147
+ }
148
+ });
149
+
150
+ // Select2 replaces the labelled <select> with spans. Copy the label
151
+ // onto the generated container and selection elements.
152
+ document
153
+ .querySelectorAll("select.admin-autocomplete")
154
+ .forEach((select) => {
155
+ if (!select.id) {
156
+ return;
157
+ }
158
+ const labelElement = document.querySelector(
159
+ `label[for="${CSS.escape(select.id)}"]`,
160
+ );
161
+ const label =
162
+ labelElement?.textContent.trim() ||
163
+ select.getAttribute("aria-label") ||
164
+ select.name ||
165
+ "Select";
166
+ const container =
167
+ select.parentElement?.querySelector(".select2-container") ||
168
+ select.nextElementSibling;
169
+ if (!container) {
170
+ return;
171
+ }
172
+ const selection = container.querySelector(
173
+ ".select2-selection",
174
+ );
175
+ if (selection && !selection.getAttribute("aria-label")) {
176
+ selection.setAttribute("aria-label", label);
177
+ }
178
+ if (!container.getAttribute("aria-label")) {
179
+ container.setAttribute("aria-label", label);
180
+ }
181
+ const rendered = container.querySelector(
182
+ ".select2-selection__rendered",
183
+ );
184
+ if (rendered && !rendered.getAttribute("aria-label")) {
185
+ rendered.setAttribute("aria-label", label);
186
+ }
187
+ });
188
+
189
+ // Django renders list-editable widgets without labels. Give each
190
+ // control an accessible name derived from its column and row.
191
+ const table = document.getElementById("result_list");
192
+ if (!table || !table.tHead || !table.tBodies.length) {
193
+ return;
194
+ }
195
+ const headers = Array.from(table.tHead.rows[0]?.cells || []).map(
196
+ (cell) => cell.textContent.trim(),
197
+ );
198
+ Array.from(table.tBodies[0].rows).forEach((row) => {
199
+ const rowName =
200
+ row.querySelector("th a, td a")?.textContent.trim() || "";
201
+ Array.from(row.cells).forEach((cell, index) => {
202
+ cell.querySelectorAll("input, select, textarea").forEach(
203
+ (control) => {
204
+ if (
205
+ control.type === "hidden" ||
206
+ control.getAttribute("aria-label") ||
207
+ (control.labels && control.labels.length)
208
+ ) {
209
+ return;
210
+ }
211
+ const column = headers[index] || "Field";
212
+ control.setAttribute(
213
+ "aria-label",
214
+ rowName ? `${column} for ${rowName}` : column,
215
+ );
216
+ },
217
+ );
218
+ });
219
+ });
220
+ }
221
+
222
+ function initFilterDisclosure() {
223
+ const toggle = document.getElementById("ba-filters-toggle");
224
+ const changelist = document.getElementById("changelist");
225
+ const panel = document.getElementById("changelist-filter");
226
+ const close = document.getElementById("ba-filters-close");
227
+ if (!toggle || !changelist) {
228
+ return;
229
+ }
230
+
231
+ const sync = () => {
232
+ toggle.setAttribute(
233
+ "aria-expanded",
234
+ changelist.classList.contains("ba-filters-open")
235
+ ? "true"
236
+ : "false",
237
+ );
238
+ };
239
+
240
+ toggle.addEventListener("click", () => {
241
+ changelist.classList.toggle("ba-filters-open");
242
+ sync();
243
+ if (changelist.classList.contains("ba-filters-open")) {
244
+ const target =
245
+ panel?.querySelector(".ba-filters-close, summary, a, button");
246
+ window.requestAnimationFrame(() => target?.focus());
247
+ }
248
+ });
249
+
250
+ if (close) {
251
+ close.addEventListener("click", () => {
252
+ changelist.classList.remove("ba-filters-open");
253
+ sync();
254
+ toggle.focus();
255
+ });
256
+ }
257
+
258
+ sync();
259
+ }
260
+
261
+ function initDirtyGuard() {
262
+ const form =
263
+ document.querySelector(".ba-change-form form") ||
264
+ document.getElementById("changelist-form");
265
+ if (!form) {
266
+ return;
267
+ }
268
+
269
+ const isChangelist = form.id === "changelist-form";
270
+ let dirty = false;
271
+
272
+ const markDirty = (event) => {
273
+ if (
274
+ isChangelist &&
275
+ (!event.target.closest("#result_list") ||
276
+ event.target.matches(".action-select, #action-toggle"))
277
+ ) {
278
+ return;
279
+ }
280
+ dirty = true;
281
+ };
282
+
283
+ form.addEventListener("input", markDirty);
284
+ form.addEventListener("change", markDirty);
285
+ form.addEventListener("submit", () => {
286
+ dirty = false;
287
+ });
288
+ window.addEventListener("beforeunload", (event) => {
289
+ if (!dirty) {
290
+ return;
291
+ }
292
+ event.preventDefault();
293
+ event.returnValue = "";
294
+ });
295
+ }
296
+
297
+ function initErrorFocus() {
298
+ const alert = document.querySelector(".ba-form-alert");
299
+ if (!alert) {
300
+ return;
301
+ }
302
+
303
+ document.querySelectorAll("details.ba-collapse").forEach((details) => {
304
+ if (details.querySelector(".errors, .errorlist, .errornote")) {
305
+ details.open = true;
306
+ }
307
+ });
308
+
309
+ const errorList = document.querySelector(
310
+ ".ba-change-form .errors, .ba-change-form .errorlist",
311
+ );
312
+ const container = errorList?.closest(
313
+ ".form-row, .ba-field, .ba-inline-card, td",
314
+ );
315
+ const invalid = container?.querySelector(
316
+ "input:not([type=hidden]), select, textarea",
317
+ );
318
+
319
+ if (invalid) {
320
+ invalid.focus({ preventScroll: true });
321
+ invalid.scrollIntoView({ block: "center" });
322
+ } else {
323
+ alert.focus();
324
+ }
325
+ }
326
+
327
+ function initAll() {
328
+ initSidebar();
329
+ initFilterDisclosure();
330
+ initDirtyGuard();
331
+ initErrorFocus();
332
+ initAccessibility();
333
+ }
334
+
335
+ if (document.readyState === "loading") {
336
+ document.addEventListener(
337
+ "DOMContentLoaded",
338
+ initAll,
339
+ { once: true },
340
+ );
341
+ } else {
342
+ initAll();
343
+ }
344
+
345
+ // SelectFilter2 runs from jQuery's ready handler and may create its
346
+ // labelled icon spans just after ours. Re-run once the window is loaded
347
+ // and after each dynamically added inline formset.
348
+ window.addEventListener(
349
+ "load",
350
+ () => {
351
+ initAccessibility();
352
+ // Select2 can finish its DOM replacement a little later.
353
+ window.setTimeout(initAccessibility, 750);
354
+ },
355
+ { once: true },
356
+ );
357
+ document.addEventListener("formset:added", () => {
358
+ window.setTimeout(initAccessibility, 100);
359
+ });
360
+ })();
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+
3
+ /*
4
+ * Keeps Django's theme preference (auto/light/dark) in sync with
5
+ * Bootstrap 6's `data-bs-theme` attribute and `color-scheme`.
6
+ */
7
+ (() => {
8
+ const STORAGE_KEY = "theme";
9
+ const media = window.matchMedia("(prefers-color-scheme: dark)");
10
+ const modes = ["auto", "light", "dark"];
11
+
12
+ function normalize(mode) {
13
+ return modes.includes(mode) ? mode : "auto";
14
+ }
15
+
16
+ function current() {
17
+ const stored = localStorage.getItem(STORAGE_KEY);
18
+ if (modes.includes(stored)) {
19
+ return stored;
20
+ }
21
+ // First visit: start in the effective OS theme so the visible page
22
+ // and the toggle icon agree immediately. Auto remains in the cycle.
23
+ return media.matches ? "dark" : "light";
24
+ }
25
+
26
+ function updateButtons(mode) {
27
+ document.querySelectorAll(".theme-toggle").forEach((button) => {
28
+ const label =
29
+ button.dataset[
30
+ `label${mode.charAt(0).toUpperCase()}${mode.slice(1)}`
31
+ ];
32
+ button.dataset.theme = mode;
33
+ if (label) {
34
+ button.setAttribute("aria-label", label);
35
+ button.setAttribute("title", label);
36
+ }
37
+ });
38
+ }
39
+
40
+ function apply(mode) {
41
+ mode = normalize(mode);
42
+ const root = document.documentElement;
43
+ const effective =
44
+ mode === "auto" ? (media.matches ? "dark" : "light") : mode;
45
+
46
+ root.dataset.theme = mode;
47
+ root.dataset.effectiveTheme = effective;
48
+ if (mode === "auto") {
49
+ delete root.dataset.bsTheme;
50
+ } else {
51
+ root.dataset.bsTheme = mode;
52
+ }
53
+
54
+ updateButtons(mode);
55
+ }
56
+
57
+ function set(mode) {
58
+ mode = normalize(mode);
59
+ localStorage.setItem(STORAGE_KEY, mode);
60
+ apply(mode);
61
+ }
62
+
63
+ function cycle() {
64
+ const mode = current();
65
+ let next;
66
+
67
+ if (media.matches) {
68
+ next =
69
+ mode === "auto" ? "light" : mode === "light" ? "dark" : "auto";
70
+ } else {
71
+ next =
72
+ mode === "auto" ? "dark" : mode === "dark" ? "light" : "auto";
73
+ }
74
+
75
+ set(next);
76
+ }
77
+
78
+ function bindButtons() {
79
+ document.querySelectorAll(".theme-toggle").forEach((button) => {
80
+ if (button.dataset.themeBound === "true") {
81
+ return;
82
+ }
83
+ button.dataset.themeBound = "true";
84
+ button.addEventListener("click", cycle);
85
+ });
86
+ updateButtons(current());
87
+ }
88
+
89
+ apply(current());
90
+
91
+ if (document.readyState === "loading") {
92
+ document.addEventListener("DOMContentLoaded", bindButtons, {
93
+ once: true,
94
+ });
95
+ } else {
96
+ bindButtons();
97
+ }
98
+
99
+ if (media.addEventListener) {
100
+ media.addEventListener("change", () => {
101
+ if (current() === "auto") {
102
+ apply("auto");
103
+ }
104
+ });
105
+ }
106
+
107
+ window.Bootstrap6AdminTheme = { apply, current, cycle, set };
108
+ })();
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2011-2026 The Bootstrap Authors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.