fjkit 0.2.0__tar.gz → 0.3.0__tar.gz

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 (168) hide show
  1. {fjkit-0.2.0 → fjkit-0.3.0}/PKG-INFO +1 -1
  2. {fjkit-0.2.0 → fjkit-0.3.0}/docs/workbench/assets/components.js +15 -1
  3. {fjkit-0.2.0 → fjkit-0.3.0}/docs/workbench/build_data.py +18 -0
  4. {fjkit-0.2.0 → fjkit-0.3.0}/docs/workbench/cheatsheet.py +12 -7
  5. {fjkit-0.2.0 → fjkit-0.3.0}/pyproject.toml +1 -1
  6. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/templates/ui/shell.html +10 -1
  7. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/templates/ui/table.html +57 -2
  8. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/templates/ui/tabs.html +42 -9
  9. {fjkit-0.2.0 → fjkit-0.3.0}/tests/test_components.py +118 -0
  10. {fjkit-0.2.0 → fjkit-0.3.0}/.gitignore +0 -0
  11. {fjkit-0.2.0 → fjkit-0.3.0}/LICENSE +0 -0
  12. {fjkit-0.2.0 → fjkit-0.3.0}/README.md +0 -0
  13. {fjkit-0.2.0 → fjkit-0.3.0}/docs/README.md +0 -0
  14. {fjkit-0.2.0 → fjkit-0.3.0}/docs/workbench/assets/brand.css +0 -0
  15. {fjkit-0.2.0 → fjkit-0.3.0}/docs/workbench/assets/common.js +0 -0
  16. {fjkit-0.2.0 → fjkit-0.3.0}/docs/workbench/assets/learn.js +0 -0
  17. {fjkit-0.2.0 → fjkit-0.3.0}/docs/workbench/assets/mock-server.js +0 -0
  18. {fjkit-0.2.0 → fjkit-0.3.0}/docs/workbench/build.py +0 -0
  19. {fjkit-0.2.0 → fjkit-0.3.0}/docs/workbench/templates/_diagram.html +0 -0
  20. {fjkit-0.2.0 → fjkit-0.3.0}/docs/workbench/templates/_parts.html +0 -0
  21. {fjkit-0.2.0 → fjkit-0.3.0}/docs/workbench/templates/_shell_diagram.html +0 -0
  22. {fjkit-0.2.0 → fjkit-0.3.0}/docs/workbench/templates/base.html +0 -0
  23. {fjkit-0.2.0 → fjkit-0.3.0}/docs/workbench/templates/cheatsheet.html +0 -0
  24. {fjkit-0.2.0 → fjkit-0.3.0}/docs/workbench/templates/components.html +0 -0
  25. {fjkit-0.2.0 → fjkit-0.3.0}/docs/workbench/templates/introduction.html +0 -0
  26. {fjkit-0.2.0 → fjkit-0.3.0}/docs/workbench/templates/learn.html +0 -0
  27. {fjkit-0.2.0 → fjkit-0.3.0}/docs/workbench/templates/plugins.html +0 -0
  28. {fjkit-0.2.0 → fjkit-0.3.0}/docs/workbench/templates/zh/cheatsheet.html +0 -0
  29. {fjkit-0.2.0 → fjkit-0.3.0}/docs/workbench/templates/zh/components.html +0 -0
  30. {fjkit-0.2.0 → fjkit-0.3.0}/docs/workbench/templates/zh/introduction.html +0 -0
  31. {fjkit-0.2.0 → fjkit-0.3.0}/docs/workbench/templates/zh/learn.html +0 -0
  32. {fjkit-0.2.0 → fjkit-0.3.0}/docs/workbench/templates/zh/plugins.html +0 -0
  33. {fjkit-0.2.0 → fjkit-0.3.0}/scripts/vendor_icons.py +0 -0
  34. {fjkit-0.2.0 → fjkit-0.3.0}/scripts/vendor_ui.py +0 -0
  35. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/__init__.py +0 -0
  36. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/auth/__init__.py +0 -0
  37. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/auth/csrf.py +0 -0
  38. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/auth/errors.py +0 -0
  39. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/auth/plugin.py +0 -0
  40. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/auth/sources.py +0 -0
  41. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/auth/stores.py +0 -0
  42. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/auth/types.py +0 -0
  43. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/cli/__init__.py +0 -0
  44. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/cli/build_css.py +0 -0
  45. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/cli/check.py +0 -0
  46. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/cli/eject.py +0 -0
  47. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/cli/ejected.py +0 -0
  48. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/cli/vocabulary.py +0 -0
  49. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/config.py +0 -0
  50. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/errors.py +0 -0
  51. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/flash.py +0 -0
  52. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/forms.py +0 -0
  53. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/htmx.py +0 -0
  54. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/icons.py +0 -0
  55. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/messages.py +0 -0
  56. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/mounting.py +0 -0
  57. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/plugins.py +0 -0
  58. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/py.typed +0 -0
  59. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/rendering.py +0 -0
  60. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/signing.py +0 -0
  61. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/brand/torii-bolt.png +0 -0
  62. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/dist/fjkit-luma.css +0 -0
  63. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/dist/fjkit-lyra.css +0 -0
  64. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/dist/fjkit-maia.css +0 -0
  65. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/dist/fjkit-mira.css +0 -0
  66. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/dist/fjkit-nova.css +0 -0
  67. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/dist/fjkit-rhea.css +0 -0
  68. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/dist/fjkit-sera.css +0 -0
  69. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/dist/fjkit-vega.css +0 -0
  70. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/icons/lucide.json +0 -0
  71. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/js/errors.js +0 -0
  72. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/js/multiselect.js +0 -0
  73. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/js/resize.js +0 -0
  74. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/js/reveal.js +0 -0
  75. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/js/select.js +0 -0
  76. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/src/fjkit.css +0 -0
  77. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/base/base.css +0 -0
  78. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/basecoat-base.css +0 -0
  79. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/basecoat-components.css +0 -0
  80. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/basecoat-luma.css +0 -0
  81. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/basecoat-lyra.css +0 -0
  82. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/basecoat-maia.css +0 -0
  83. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/basecoat-mira.css +0 -0
  84. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/basecoat-nova.css +0 -0
  85. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/basecoat-rhea.css +0 -0
  86. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/basecoat-sera.css +0 -0
  87. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/basecoat-vega.css +0 -0
  88. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/basecoat.all.css +0 -0
  89. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/basecoat.css +0 -0
  90. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/components/accordion.css +0 -0
  91. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/components/alert.css +0 -0
  92. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/components/avatar.css +0 -0
  93. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/components/badge.css +0 -0
  94. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/components/breadcrumb.css +0 -0
  95. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/components/button-group.css +0 -0
  96. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/components/button.css +0 -0
  97. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/components/card.css +0 -0
  98. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/components/chart.css +0 -0
  99. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/components/checkbox.css +0 -0
  100. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/components/collapsible.css +0 -0
  101. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/components/combobox.css +0 -0
  102. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/components/command.css +0 -0
  103. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/components/dialog.css +0 -0
  104. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/components/drawer.css +0 -0
  105. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/components/dropdown-menu.css +0 -0
  106. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/components/empty.css +0 -0
  107. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/components/field.css +0 -0
  108. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/components/form.css +0 -0
  109. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/components/input-group.css +0 -0
  110. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/components/input.css +0 -0
  111. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/components/item.css +0 -0
  112. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/components/kbd.css +0 -0
  113. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/components/label.css +0 -0
  114. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/components/native-select.css +0 -0
  115. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/components/popover.css +0 -0
  116. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/components/progress.css +0 -0
  117. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/components/radio.css +0 -0
  118. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/components/range.css +0 -0
  119. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/components/scrollbar.css +0 -0
  120. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/components/select.css +0 -0
  121. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/components/sidebar.css +0 -0
  122. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/components/skeleton.css +0 -0
  123. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/components/switch.css +0 -0
  124. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/components/table.css +0 -0
  125. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/components/tabs.css +0 -0
  126. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/components/textarea.css +0 -0
  127. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/components/toast.css +0 -0
  128. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/components/tooltip.css +0 -0
  129. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/js/all.min.js +0 -0
  130. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/styles/luma.css +0 -0
  131. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/styles/lyra.css +0 -0
  132. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/styles/maia.css +0 -0
  133. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/styles/mira.css +0 -0
  134. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/styles/nova.css +0 -0
  135. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/styles/rhea.css +0 -0
  136. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/styles/sera.css +0 -0
  137. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/basecoat/styles/vega.css +0 -0
  138. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/htmx/htmx.min.js +0 -0
  139. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/htmx/idiomorph-ext.min.js +0 -0
  140. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/static/vendor/htmx/json-enc.js +0 -0
  141. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/styles.py +0 -0
  142. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/templates/errors/page.html +0 -0
  143. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/templates/ui/attrs.html +0 -0
  144. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/templates/ui/button.html +0 -0
  145. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/templates/ui/data.html +0 -0
  146. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/templates/ui/disclosure.html +0 -0
  147. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/templates/ui/feedback.html +0 -0
  148. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/templates/ui/form.html +0 -0
  149. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/templates/ui/icon.html +0 -0
  150. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/templates/ui/layout.html +0 -0
  151. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/templates/ui/nav.html +0 -0
  152. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/templates/ui/overlay.html +0 -0
  153. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/templates/ui/sidebar.html +0 -0
  154. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/templates/ui/swap.html +0 -0
  155. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/templating.py +0 -0
  156. {fjkit-0.2.0 → fjkit-0.3.0}/src/fjkit/vendored.py +0 -0
  157. {fjkit-0.2.0 → fjkit-0.3.0}/tests/conftest.py +0 -0
  158. {fjkit-0.2.0 → fjkit-0.3.0}/tests/test_auth.py +0 -0
  159. {fjkit-0.2.0 → fjkit-0.3.0}/tests/test_color_scheme.py +0 -0
  160. {fjkit-0.2.0 → fjkit-0.3.0}/tests/test_docs_site.py +0 -0
  161. {fjkit-0.2.0 → fjkit-0.3.0}/tests/test_errors.py +0 -0
  162. {fjkit-0.2.0 → fjkit-0.3.0}/tests/test_flash.py +0 -0
  163. {fjkit-0.2.0 → fjkit-0.3.0}/tests/test_messages.py +0 -0
  164. {fjkit-0.2.0 → fjkit-0.3.0}/tests/test_mounting.py +0 -0
  165. {fjkit-0.2.0 → fjkit-0.3.0}/tests/test_plugins.py +0 -0
  166. {fjkit-0.2.0 → fjkit-0.3.0}/tests/test_rendering.py +0 -0
  167. {fjkit-0.2.0 → fjkit-0.3.0}/tests/test_style_packs.py +0 -0
  168. {fjkit-0.2.0 → fjkit-0.3.0}/tests/test_vocabulary.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: fjkit
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: Server-rendered UI kit for FastAPI — Jinja2 + Basecoat + htmx, no front-end build
5
5
  Project-URL: Homepage, https://liweicheng00.github.io/fjkit/
6
6
  Project-URL: Documentation, https://liweicheng00.github.io/fjkit/
@@ -97,6 +97,7 @@ const TABLE_STATE = {
97
97
  sortable: "sorted",
98
98
  "batch select": "select",
99
99
  resizable: "resizable",
100
+ grouped: "grouped",
100
101
  };
101
102
 
102
103
  const TABLE_JINJA = {
@@ -152,6 +153,18 @@ const TABLE_JINJA = {
152
153
  {% endcall %}
153
154
 
154
155
  {% block scripts %}{{ resize_scripts() }}{% endblock %}`,
156
+
157
+ grouped: `{% set columns = [
158
+ {"label": "Adverse event"},
159
+ {"label": "n", "align": "end", "group": "Dose 1 (N=12)"},
160
+ {"label": "%", "align": "end", "group": "Dose 1 (N=12)"},
161
+ {"label": "n", "align": "end", "group": "Dose 2 (N=9)"},
162
+ {"label": "%", "align": "end", "group": "Dose 2 (N=9)"},
163
+ ] %}
164
+
165
+ {% call table(columns, rows=events) %}
166
+ {% for event in events %}{{ event_row(event) }}{% endfor %}
167
+ {% endcall %}`,
155
168
  };
156
169
 
157
170
  const TABLE_CAPTION = {
@@ -160,6 +173,7 @@ const TABLE_CAPTION = {
160
173
  sortable: "A column becomes sortable by carrying a sort_url, and sort says which way it is going now. The arrow and aria-sort are keyed off that one value, so they cannot disagree. Every header is an href before it is a swap: sorting works with JavaScript off, and a sorted view is a URL you can send someone.",
161
174
  "batch select": "{\"select\": true} is the header box, select_cell is the row box, and the name they share is the field the selection posts under — selected=3&selected=7, which is what a checkbox column has always sent. The action collects it with hx-include; nothing maintains a list. select_scripts() is what ticks the column, shows the partial state and tints the picked rows.",
162
175
  resizable: "Drag the edge of a heading, or focus it with Tab and press the arrow keys. Home or a double-click resets the column. The widths are stored in localStorage under the table's id and come back after a reload and after an htmx swap. Without resize_scripts() the handles stay hidden and the table is the ordinary one.",
176
+ grouped: "A group key puts a heading over its column in a second header row. Neighbours with the same group share one centred cell, and a column with none spans both rows, so the label column owns the corner. The heading lives on the column rather than in a list of spans, so adding a column to a set is one dict and nothing has to be recounted. A grouped table cannot also be resizable.",
163
177
  };
164
178
 
165
179
  const MACROS = {
@@ -283,7 +297,7 @@ const MACROS = {
283
297
  table: {
284
298
  label: "table",
285
299
  controls: [
286
- { key: "state", type: "select", label: "state", options: ["3 rows", "empty", "sortable", "batch select", "resizable"], value: "3 rows" },
300
+ { key: "state", type: "select", label: "state", options: ["3 rows", "empty", "sortable", "batch select", "resizable", "grouped"], value: "3 rows" },
287
301
  ],
288
302
  render: (p) => DATA.tables[TABLE_STATE[p.state]],
289
303
  jinja: (p) => TABLE_JINJA[p.state],
@@ -244,6 +244,23 @@ select_row_src = "".join(
244
244
  for n, (title, status, variant, owner, points) in enumerate(ROWS, start=1)
245
245
  )
246
246
 
247
+ # A count table: a heading over each population's n and %, and the label column
248
+ # spanning both header rows.
249
+ GROUPED_COLUMNS = (
250
+ '[{"label": "Adverse event"}, '
251
+ '{"label": "n", "align": "end", "group": "Dose 1 (N=12)"}, '
252
+ '{"label": "%", "align": "end", "group": "Dose 1 (N=12)"}, '
253
+ '{"label": "n", "align": "end", "group": "Dose 2 (N=9)"}, '
254
+ '{"label": "%", "align": "end", "group": "Dose 2 (N=9)"}]'
255
+ )
256
+ GROUPED_ROWS = [("Headache", 4, 33.3, 2, 22.2), ("Nausea", 3, 25.0, 5, 55.6), ("Fatigue", 1, 8.3, 0, 0.0)]
257
+ grouped_row_src = "".join(
258
+ f"<tr>{{{{ cell('{event}', tone='strong') }}}}"
259
+ + "".join(f"{{{{ cell('{value}', numeric=true, align='end') }}}}" for value in values)
260
+ + "</tr>"
261
+ for event, *values in GROUPED_ROWS
262
+ )
263
+
247
264
  tables = {
248
265
  "filled": render(
249
266
  f"{TABLE}{DATA}{BUTTON}{{% call table({COLUMNS}, rows=[1, 2, 3]) %}}{row_src}{{% endcall %}}"
@@ -269,6 +286,7 @@ tables = {
269
286
  f"{TABLE}{DATA}{BUTTON}"
270
287
  f'{{% call table({COLUMNS}, rows=[1, 2, 3], resizable=true, id="docs-resizable") %}}{row_src}{{% endcall %}}'
271
288
  ),
289
+ "grouped": render(f"{TABLE}{{% call table({GROUPED_COLUMNS}, rows=[1, 2, 3]) %}}{grouped_row_src}{{% endcall %}}"),
272
290
  }
273
291
 
274
292
  # ---------------------------------------------------------------- pagination
@@ -360,16 +360,17 @@ GROUPS = [
360
360
  ' select_label="Select all rows", resizable=false)',
361
361
  block="rows",
362
362
  en="columns is a list of dicts — label, and optionally align, width, "
363
- "sort, sort_url or select. Passing rows lets the macro own the empty "
363
+ "sort, sort_url, select or group. Passing rows lets the macro own the empty "
364
364
  "case; pass rows=none to always render the body yourself. A column with "
365
365
  "a sort_url becomes a sortable header, and target turns those links into "
366
366
  "htmx swaps. resizable=true puts a drag handle on each labelled column "
367
- "and needs an id=, the key the widths are stored under.",
368
- zh="columns 是 dict 的清單——label,可選 align、width、sort、sort_url 或 select。"
367
+ "and needs an id=, the key the widths are stored under. Columns sharing a "
368
+ "group get one heading above them in a second header row.",
369
+ zh="columns 是 dict 的清單——label,可選 align、width、sort、sort_url、select 或 group。"
369
370
  "傳了 rows,空資料的情況就歸 macro 管;傳 rows=none 則永遠自己渲染 body。"
370
371
  "有 sort_url 的欄位會變成可排序表頭,給了 target 那些連結就同時是 htmx swap。"
371
372
  "resizable=true 會在每個有 label 的欄位放一個拖曳把手,並且必須給 id=,"
372
- "欄寬就存在這個 id 底下。",
373
+ "欄寬就存在這個 id 底下。相鄰且 group 相同的欄位,會在上方第二列表頭共用一格標題。",
373
374
  ),
374
375
  _m(
375
376
  "cell(value=none, tone=none, numeric=false, align=none)",
@@ -641,15 +642,19 @@ GROUPS = [
641
642
  _m(
642
643
  'tab_panel("detail", lazy=url_for(request, "detail"),\n'
643
644
  ' on=["task-selected"], include="[name=task_id]")',
644
- block="the placeholder",
645
+ block="the placeholder, or the open tab's body",
645
646
  en="lazy is a URL: the panel fetches its own body when its tab is shown, "
646
- "and the block is what stands in until it arrives. on lists the "
647
+ "and the block is what stands in until it arrives. The open tab is the "
648
+ "exception: it does not fetch at load, so its block is the real body, "
649
+ "rendered by the page from the partial lazy returns. on lists the "
647
650
  "broadcasts it follows while it is visible, include the selector for "
648
651
  "what it sends. Not revealed — a panel hidden by display:none reports "
649
652
  "an all-zero rect, which passes htmx's visibility test, so a revealed "
650
653
  "panel fetches at page load.",
651
654
  zh="lazy 是一個 URL:分頁被選到時,這個面板才去抓自己的內容,"
652
- "區塊裡放的是在那之前的暫代內容。on 列出它顯示中要跟著更新的廣播,"
655
+ "區塊裡放的是在那之前的暫代內容。一開始就打開的分頁例外:它在載入時不抓,"
656
+ "所以區塊裡放的是真正的內容,由頁面用 lazy 回傳的同一個 partial 渲染。"
657
+ "on 列出它顯示中要跟著更新的廣播,"
653
658
  "include 是它要送出什麼的選擇器。不能用 revealed——"
654
659
  "被 display:none 藏起來的面板回報的是全為零的矩形,"
655
660
  "剛好通過 htmx 的可見性判斷,所以 revealed 會在頁面載入時就抓。",
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "fjkit"
3
- version = "0.2.0"
3
+ version = "0.3.0"
4
4
  description = "Server-rendered UI kit for FastAPI — Jinja2 + Basecoat + htmx, no front-end build"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.13"
@@ -88,8 +88,17 @@
88
88
  htmx's default handling: 2xx/3xx swap, 4xx/5xx do not. A 422 is read by
89
89
  `js/errors.js` in `htmx:beforeSwap` instead; 204 is what `fjkit.errors`
90
90
  answers a swap with when there is only a toast to raise.
91
+
92
+ No history snapshots: Back and Forward reload the URL instead. htmx saves
93
+ the snapshot of the page it is leaving when the reply arrives, and by then
94
+ a script may already have changed the page — Basecoat switches a tab on the
95
+ click. The snapshot then pairs the old URL with the new state, and restoring
96
+ it re-runs the new state's triggers, which push the new URL again: Back
97
+ never leaves. Every URL fjkit pushes is a real page (sort links, pagination
98
+ and tabs are `href`s first), so a reload is always right, and it costs one
99
+ request on Back.
91
100
  #}
92
- <meta name="htmx-config" content='{"responseHandling":[{"code":"204","swap":false},{"code":"[23]..","swap":true},{"code":"[45]..","swap":false,"error":true}]}'>
101
+ <meta name="htmx-config" content='{"historyCacheSize":0,"refreshOnHistoryMiss":true,"responseHandling":[{"code":"204","swap":false},{"code":"[23]..","swap":true},{"code":"[45]..","swap":false,"error":true}]}'>
93
102
  <script defer src="{{ fjkit_static('vendor/htmx/htmx.min.js') }}"></script>
94
103
  <script defer src="{{ fjkit_static('vendor/basecoat/js/all.min.js') }}"></script>
95
104
  {# Draws a 422 under the fields of the form that sent it. After htmx: it listens to htmx's events. #}
@@ -55,6 +55,7 @@
55
55
  sort_url where clicking the header goes; its presence is what makes
56
56
  the column sortable
57
57
  select true, for the batch-selection column
58
+ group a heading over this column, in a row above the labels
58
59
 
59
60
  `sort_url` is a URL the caller built, not a column key the macro turns into
60
61
  one. The router already owns the query string — it is the thing that knows
@@ -82,6 +83,25 @@
82
83
  its key with every other table on the site. The select column and the
83
84
  `width="min"` columns get no handle: they hold a control or a number whose
84
85
  width the macro already chose.
86
+
87
+ `group` adds a second header row, for the tables whose columns come in sets —
88
+ a population's "n" and "%", a quarter's three months:
89
+
90
+ columns=[{"label": "Category"},
91
+ {"label": "n", "align": "end", "group": "Dose 1 (N=12)"},
92
+ {"label": "%", "align": "end", "group": "Dose 1 (N=12)"},
93
+ {"label": "n", "align": "end", "group": "Dose 2 (N=9)"},
94
+ {"label": "%", "align": "end", "group": "Dose 2 (N=9)"}]
95
+
96
+ Neighbouring columns with the same `group` share one centred cell above them,
97
+ and a column with none spans both rows. The heading is a key on the column
98
+ rather than a separate list of spans, so a group cannot be wider or narrower
99
+ than the columns under it: adding a column to a set is one dict, and nothing
100
+ elsewhere has to be recounted. Two sets that must stay apart need different
101
+ text, which a population heading has anyway.
102
+
103
+ A grouped table cannot also be `resizable`. The handles store a width per
104
+ header cell, and with two rows a cell's position no longer names its column.
85
105
  #}
86
106
  {% macro table(columns, rows=none, empty_title="Nothing here", empty_description=none, empty_icon="list",
87
107
  target=none, swap="outerHTML", push_url=true,
@@ -90,14 +110,48 @@
90
110
  {% if resizable and not kwargs.get("id") %}
91
111
  {{- fjkit_raise("table(resizable=true) needs an id: it is the key the column widths are stored under.") }}
92
112
  {% endif %}
113
+ {% set head = namespace(grouped=false) %}
114
+ {% for column in columns if column.get("group") %}{% set head.grouped = true %}{% endfor %}
115
+ {% if resizable and head.grouped %}
116
+ {{- fjkit_raise("table(resizable=true) cannot take a column with a group: the stored widths are keyed by header position.") }}
117
+ {% endif %}
93
118
  <div class="table-container">
94
119
  <table class="table"{% if kwargs %}{{ attrs(kwargs) }}{% endif %}{% if resizable %} data-fjkit-resize{% endif %}>
95
120
  <thead>
121
+ {% if head.grouped %}
122
+ {#
123
+ One pass, emitting a group's cell when its run ends: by then the
124
+ counter holds its width, and a column outside any group has
125
+ already been written in its place between them.
126
+ #}
127
+ {% set run = namespace(span=0) %}
128
+ <tr>
129
+ {% for column in columns %}
130
+ {% if not column.get("group") %}
131
+ {{- _header(column, target, swap, push_url, select_name, select_label, false, rowspan=2) }}
132
+ {% else %}
133
+ {% set run.span = run.span + 1 %}
134
+ {% if loop.last or loop.nextitem.get("group") != column.group %}
135
+ <th class="text-center" scope="colgroup"{% if run.span > 1 %} colspan="{{ run.span }}"{% endif %}>
136
+ {{- column.group -}}
137
+ </th>
138
+ {% set run.span = 0 %}
139
+ {% endif %}
140
+ {% endif %}
141
+ {% endfor %}
142
+ </tr>
143
+ <tr>
144
+ {% for column in columns if column.get("group") %}
145
+ {{- _header(column, target, swap, push_url, select_name, select_label, false) }}
146
+ {% endfor %}
147
+ </tr>
148
+ {% else %}
96
149
  <tr>
97
150
  {% for column in columns %}
98
151
  {{- _header(column, target, swap, push_url, select_name, select_label, resizable) }}
99
152
  {% endfor %}
100
153
  </tr>
154
+ {% endif %}
101
155
  </thead>
102
156
  <tbody>{{ caller() }}</tbody>
103
157
  </table>
@@ -119,7 +173,7 @@
119
173
  who could reach this one would be able to build a table whose header count
120
174
  and column count disagree.
121
175
  #}
122
- {% macro _header(column, target, swap, push_url, select_name, select_label, resizable) -%}
176
+ {% macro _header(column, target, swap, push_url, select_name, select_label, resizable, rowspan=none) -%}
123
177
  {%- if column.get("select") -%}
124
178
  {#
125
179
  `role="checkbox"` is the implicit role of the element already. It is
@@ -127,7 +181,7 @@
127
181
  `[&:has([role=checkbox])]:pe-0` — to take the trailing padding off a
128
182
  column that holds nothing but a tick box.
129
183
  #}
130
- <th class="w-px">
184
+ <th class="w-px"{% if rowspan %} rowspan="{{ rowspan }}"{% endif %}>
131
185
  <input class="input" type="checkbox" role="checkbox"
132
186
  data-fjkit-select-all="{{ select_name }}" aria-label="{{ select_label }}">
133
187
  </th>
@@ -136,6 +190,7 @@
136
190
  {%- set sort_url = column.get("sort_url") -%}
137
191
  {%- set handle = resizable and column.get("label") and column.get("width") != "min" -%}
138
192
  <th class="{{ _WIDTH.get(column.get("width"), "") }} {{ _ALIGN.get(column.get("align"), "") }}"
193
+ {%- if rowspan %} rowspan="{{ rowspan }}"{% endif %}
139
194
  {%- if sort_url %} aria-sort="{{ _ARIA_SORT.get(sort, "none") }}"{% endif %}
140
195
  {#
141
196
  An unlabelled cell is invisible to a screen reader reading out the
@@ -63,7 +63,9 @@
63
63
 
64
64
  `selected` names the item that starts open; the first one by default. The
65
65
  server knows which tab the request was for, so this is a parameter and not
66
- something a script decides after paint.
66
+ something a script decides after paint. That tab also carries
67
+ `data-fjkit-open`, which Basecoat never moves: it is how a lazy panel knows,
68
+ after the user has switched tabs, which panel the server rendered.
67
69
  #}
68
70
  {% macro tabs(items, label="Tabs", selected=none, orientation="horizontal", variant="underline") -%}
69
71
  {%- set body = caller() -%}
@@ -77,7 +79,8 @@
77
79
  {%- if shape %} data-variant="{{ shape }}"{% endif %}>
78
80
  {% for item in items %}
79
81
  <button type="button" role="tab" id="{{ item.id }}-tab" aria-controls="{{ item.id }}"
80
- aria-selected="{{ "true" if item.id == active else "false" }}">{{ item.label }}</button>
82
+ aria-selected="{{ "true" if item.id == active else "false" }}"
83
+ {%- if item.id == active %} data-fjkit-open{% endif %}>{{ item.label }}</button>
81
84
  {% endfor %}
82
85
  </nav>
83
86
  {{- body -}}
@@ -93,12 +96,24 @@
93
96
  This way the panels stack and every one is legible.
94
97
 
95
98
  `lazy` is a URL, and it is all a panel needs to fetch its own body when it is
96
- shown rather than when the page loads. The block's body then stands in until
97
- the answer arrives — usually a `skeleton`. Without `lazy` the panel is inert
99
+ shown rather than when the page loads. Without `lazy` the panel is inert
98
100
  markup, and `on` and `include` are read only alongside it because neither
99
101
  means anything on its own.
100
102
 
101
- Three decisions are baked in here so that no app template has to remember
103
+ The block's body means two things, depending on the panel:
104
+
105
+ * **The open panel** — the one `tabs(selected=…)` names — holds its real
106
+ content, rendered by the page route: the same partial `lazy` returns. It
107
+ does not fetch at load. The server already knows which tab the request was
108
+ for, and a panel that fetched what the page had just rendered would cost a
109
+ request per page view and, with `hx_push_url`, a duplicate history entry
110
+ that makes Back land on the same URL.
111
+ * **Every other panel** holds a stand-in, usually a `skeleton`, shown until
112
+ its first fetch arrives.
113
+
114
+ Every panel fetches each later time it is shown, the open one included.
115
+
116
+ Four decisions are baked in here so that no app template has to remember
102
117
  them. Each is a way this goes silently wrong when written by hand:
103
118
 
104
119
  * `intersect`, never `revealed`. htmx tests `revealed` with
@@ -118,6 +133,18 @@
118
133
  * `innerHTML` onto the panel. An element carrying `intersect` has to survive
119
134
  its own reply. A panel replaced by markup that asked for `intersect` again
120
135
  would be processed while on screen, fire immediately, and loop.
136
+ * The first `intersect` of the open panel is dropped. The filter marks the
137
+ panel seen and lets the request through only when its tab is not the one
138
+ carrying `data-fjkit-open`. The mark is on the panel and the test is on the
139
+ tab because Basecoat moves `aria-selected` and `hidden` as the user clicks,
140
+ and neither says what the server rendered. The `!!` is load-bearing: htmx
141
+ runs the request only when a filter returns exactly `true`, and the mark
142
+ reads back as the string `"y"`.
143
+
144
+ `hx_push_url="true"` passes through and is supported: each tab becomes a URL.
145
+ Back and Forward then reload the page at that URL rather than restore an htmx
146
+ snapshot — `ui/shell.html` turns the snapshot cache off for every page, and
147
+ says why.
121
148
 
122
149
  `include` is a selector for what the panel has to send: the id it is about,
123
150
  the query it is filtered by. A selector rather than a value carried in the
@@ -132,13 +159,19 @@
132
159
  that would need a listener on `<body>` — a script, for a page that otherwise
133
160
  has none.
134
161
 
135
- {% call tab_panel("tab-detail", lazy=url_for(request, "search_detail"),
136
- on=["task-selected"], include="[name=task_id]") %}
137
- {{ skeleton(lines=4, label="Loading the detail") }}
162
+ {% call tabs(items, selected="tab-detail") %}
163
+ {% call tab_panel("tab-detail", lazy=url_for(request, "search_detail"),
164
+ on=["task-selected"], include="[name=task_id]") %}
165
+ {% include "search/_detail.html" %}
166
+ {% endcall %}
167
+ {% call tab_panel("tab-history", lazy=url_for(request, "search_history"),
168
+ include="[name=task_id]") %}
169
+ {{ skeleton(lines=4, label="Loading the history") }}
170
+ {% endcall %}
138
171
  {% endcall %}
139
172
  #}
140
173
  {% macro tab_panel(id, lazy=none, on=none, include=none) -%}
141
- {%- set trigger %}intersect
174
+ {%- set trigger %}intersect[!!this.dataset.fjkitSeen || (this.dataset.fjkitSeen = 'y', !document.getElementById(this.id + '-tab')?.hasAttribute('data-fjkit-open'))]
142
175
  {%- for event in on or [] %}, {{ event }}[!this.hidden] from:body{% endfor %}
143
176
  {%- endset -%}
144
177
  <div id="{{ id }}" role="tabpanel"
@@ -319,6 +319,85 @@ class TestSortableHeaders:
319
319
  assert "aria-sort" not in html
320
320
 
321
321
 
322
+ class TestHeaderGroups:
323
+ """A `group` key on a column puts a heading over it in a second header row,
324
+ for count tables whose columns come in sets — a population's n and %."""
325
+
326
+ GROUPED = (
327
+ '[{"label": "Category"},'
328
+ ' {"label": "n", "align": "end", "group": "Dose 1", "sort": "asc", "sort_url": "/t?o=-n1"},'
329
+ ' {"label": "%", "align": "end", "group": "Dose 1"},'
330
+ ' {"label": "n", "align": "end", "group": "Dose 2", "sort_url": "/t?o=n2"},'
331
+ ' {"label": "%", "align": "end", "group": "Dose 2"}]'
332
+ )
333
+
334
+ @staticmethod
335
+ def header_rows(html):
336
+ return re.findall(r"<tr>(.*?)</tr>", html.split("<tbody>")[0], re.S)
337
+
338
+ def test_no_group_keeps_a_single_header_row(self, render):
339
+ html = render(f'{TABLE}{{% call table([{{"label": "Task"}}]) %}}r{{% endcall %}}')
340
+ assert len(self.header_rows(html)) == 1
341
+ assert "rowspan" not in html
342
+ assert "colgroup" not in html
343
+
344
+ def test_neighbouring_columns_share_one_group_cell(self, render):
345
+ html = render(f"{TABLE}{{% call table({self.GROUPED}) %}}r{{% endcall %}}")
346
+ top, labels = self.header_rows(html)
347
+ assert re.findall(r'<th class="text-center" scope="colgroup" colspan="2">(.*?)</th>', top) == [
348
+ "Dose 1",
349
+ "Dose 2",
350
+ ]
351
+ assert len(re.findall(r"<th\b", labels)) == 4
352
+
353
+ def test_a_column_without_a_group_spans_both_rows(self, render):
354
+ """No empty cell sits over the label column: it owns the corner."""
355
+ html = render(f"{TABLE}{{% call table({self.GROUPED}) %}}r{{% endcall %}}")
356
+ top, labels = self.header_rows(html)
357
+ assert re.search(r'<th class="[^"]*" rowspan="2">Category</th>', top)
358
+ assert "Category" not in labels
359
+
360
+ def test_the_select_column_spans_both_rows(self, render):
361
+ columns = '[{"select": true}, {"label": "n", "group": "Dose 1"}]'
362
+ top, labels = self.header_rows(render(f"{TABLE}{{% call table({columns}) %}}r{{% endcall %}}"))
363
+ assert re.search(r'<th class="w-px" rowspan="2">\s*<input[^>]*data-fjkit-select-all', top)
364
+ assert "data-fjkit-select-all" not in labels
365
+
366
+ def test_a_one_column_group_carries_no_colspan(self, render):
367
+ columns = '[{"label": "n", "group": "Total"}]'
368
+ top, _ = self.header_rows(render(f"{TABLE}{{% call table({columns}) %}}r{{% endcall %}}"))
369
+ assert '<th class="text-center" scope="colgroup">Total</th>' in top
370
+
371
+ def test_the_same_group_apart_is_two_cells(self, render):
372
+ """Only neighbours merge. A heading cannot stretch over a column that
373
+ is not in its set."""
374
+ columns = '[{"label": "a", "group": "G"}, {"label": "b"}, {"label": "c", "group": "G"}]'
375
+ top, labels = self.header_rows(render(f"{TABLE}{{% call table({columns}) %}}r{{% endcall %}}"))
376
+ assert top.count(">G</th>") == 2
377
+ assert "colspan" not in top
378
+ assert re.findall(r">(\w)</th>", labels) == ["a", "c"]
379
+
380
+ def test_sorting_is_unchanged_under_a_group(self, render):
381
+ html = render(f'{TABLE}{{% call table({self.GROUPED}, target="#t") %}}r{{% endcall %}}')
382
+ _, labels = self.header_rows(html)
383
+ assert 'aria-sort="ascending"' in labels
384
+ assert 'aria-sort="none"' in labels
385
+ assert 'hx-get="/t?o=-n1"' in labels
386
+
387
+ def test_an_empty_grouped_table_renders_the_empty_state(self, render):
388
+ html = render(f'{TABLE}{{% call table({self.GROUPED}, rows=[], empty_title="Nothing") %}}r{{% endcall %}}')
389
+ assert "Nothing" in html
390
+ assert "<table" not in html
391
+
392
+ def test_a_grouped_table_cannot_be_resizable(self, render):
393
+ """`js/resize.js` keys a width by the header cell's position in the
394
+ first row, which with two rows is no longer its column."""
395
+ from jinja2 import TemplateRuntimeError
396
+
397
+ with pytest.raises(TemplateRuntimeError, match="group"):
398
+ render(f'{TABLE}{{% call table({self.GROUPED}, resizable=true, id="t") %}}r{{% endcall %}}')
399
+
400
+
322
401
  class TestSelectColumn:
323
402
  """0.4. The batch-selection column: a header box, a row box, and the
324
403
  readout that says what a bulk action is about to reach."""
@@ -1552,6 +1631,45 @@ class TestLazyTabPanel:
1552
1631
  assert 'aria-label="Detail"' in html
1553
1632
  assert 'hx-get="/x"' in html
1554
1633
 
1634
+ def test_only_the_tab_the_server_opened_is_marked(self, render):
1635
+ """Basecoat moves `aria-selected` as the user clicks, so the panel needs
1636
+ a mark it never moves to know which body the server rendered."""
1637
+ html = render(f'{TABS}{{% call tabs({FILE_ITEMS}, selected="b") %}}{{% endcall %}}')
1638
+ assert html.count("data-fjkit-open") == 1
1639
+ assert re.search(r'id="b-tab"[^>]*data-fjkit-open', html)
1640
+
1641
+ def test_the_open_panel_skips_its_first_intersect(self, render):
1642
+ """The open panel's body came with the page. Fetching it again costs a
1643
+ request per view, and with `hx_push_url` a duplicate history entry that
1644
+ makes Back land on the same URL. Every later showing still fetches."""
1645
+ html = render(f"{TABS}{self.LAZY}")
1646
+ trigger = re.search(r'hx-trigger="intersect\[(.*?)\]', html).group(1)
1647
+ assert "data-fjkit-open" in trigger
1648
+ assert "this.id + '-tab'" in trigger
1649
+
1650
+ def test_the_filter_returns_a_boolean(self, render):
1651
+ """htmx runs the request only when a filter returns exactly `true`.
1652
+ The mark reads back as a string, so without `!!` every panel would stop
1653
+ fetching after its first showing."""
1654
+ html = render(f"{TABS}{self.LAZY}")
1655
+ assert 'hx-trigger="intersect[!!this.dataset.fjkitSeen || ' in html
1656
+
1657
+
1658
+ class TestHistory:
1659
+ def test_back_reloads_instead_of_restoring_a_snapshot(self, render):
1660
+ """htmx saves the snapshot of the page it leaves when the reply arrives,
1661
+ after Basecoat has already switched the tab. Restoring that snapshot
1662
+ re-fires the new tab's request, which pushes again: Back never leaves."""
1663
+ from fjkit.config import TEMPLATE_DIR
1664
+
1665
+ shell = (TEMPLATE_DIR / "ui" / "shell.html").read_text(encoding="utf-8")
1666
+ config = re.search(r"<meta name=\"htmx-config\" content='([^']*)'>", shell).group(1)
1667
+ import json
1668
+
1669
+ parsed = json.loads(config)
1670
+ assert parsed["historyCacheSize"] == 0
1671
+ assert parsed["refreshOnHistoryMiss"] is True
1672
+
1555
1673
 
1556
1674
  class TestCodeBlock:
1557
1675
  def test_a_scroll_region_is_reachable_by_keyboard(self, render):
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes