fjkit 0.1.0.dev0__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 (127) hide show
  1. fjkit/__init__.py +49 -0
  2. fjkit/auth/__init__.py +54 -0
  3. fjkit/auth/csrf.py +88 -0
  4. fjkit/auth/errors.py +31 -0
  5. fjkit/auth/plugin.py +496 -0
  6. fjkit/auth/sources.py +24 -0
  7. fjkit/auth/stores.py +141 -0
  8. fjkit/auth/types.py +141 -0
  9. fjkit/cli/__init__.py +67 -0
  10. fjkit/cli/build_css.py +135 -0
  11. fjkit/cli/check.py +193 -0
  12. fjkit/cli/eject.py +562 -0
  13. fjkit/cli/ejected.py +202 -0
  14. fjkit/cli/vocabulary.py +85 -0
  15. fjkit/config.py +130 -0
  16. fjkit/errors.py +156 -0
  17. fjkit/flash.py +189 -0
  18. fjkit/forms.py +145 -0
  19. fjkit/htmx.py +76 -0
  20. fjkit/icons.py +60 -0
  21. fjkit/messages.py +227 -0
  22. fjkit/mounting.py +72 -0
  23. fjkit/plugins.py +223 -0
  24. fjkit/py.typed +0 -0
  25. fjkit/rendering.py +554 -0
  26. fjkit/signing.py +63 -0
  27. fjkit/static/brand/torii-bolt.png +0 -0
  28. fjkit/static/dist/fjkit-luma.css +2 -0
  29. fjkit/static/dist/fjkit-lyra.css +2 -0
  30. fjkit/static/dist/fjkit-maia.css +2 -0
  31. fjkit/static/dist/fjkit-mira.css +2 -0
  32. fjkit/static/dist/fjkit-nova.css +2 -0
  33. fjkit/static/dist/fjkit-rhea.css +2 -0
  34. fjkit/static/dist/fjkit-sera.css +2 -0
  35. fjkit/static/dist/fjkit-vega.css +2 -0
  36. fjkit/static/icons/lucide.json +1 -0
  37. fjkit/static/js/errors.js +117 -0
  38. fjkit/static/js/multiselect.js +126 -0
  39. fjkit/static/js/reveal.js +51 -0
  40. fjkit/static/js/select.js +113 -0
  41. fjkit/static/src/fjkit.css +385 -0
  42. fjkit/static/vendor/basecoat/base/base.css +136 -0
  43. fjkit/static/vendor/basecoat/basecoat-base.css +2 -0
  44. fjkit/static/vendor/basecoat/basecoat-components.css +39 -0
  45. fjkit/static/vendor/basecoat/basecoat-luma.css +2 -0
  46. fjkit/static/vendor/basecoat/basecoat-lyra.css +2 -0
  47. fjkit/static/vendor/basecoat/basecoat-maia.css +2 -0
  48. fjkit/static/vendor/basecoat/basecoat-mira.css +2 -0
  49. fjkit/static/vendor/basecoat/basecoat-nova.css +2 -0
  50. fjkit/static/vendor/basecoat/basecoat-rhea.css +2 -0
  51. fjkit/static/vendor/basecoat/basecoat-sera.css +2 -0
  52. fjkit/static/vendor/basecoat/basecoat-vega.css +2 -0
  53. fjkit/static/vendor/basecoat/basecoat.all.css +1 -0
  54. fjkit/static/vendor/basecoat/basecoat.css +1 -0
  55. fjkit/static/vendor/basecoat/components/accordion.css +27 -0
  56. fjkit/static/vendor/basecoat/components/alert.css +38 -0
  57. fjkit/static/vendor/basecoat/components/avatar.css +47 -0
  58. fjkit/static/vendor/basecoat/components/badge.css +6 -0
  59. fjkit/static/vendor/basecoat/components/breadcrumb.css +30 -0
  60. fjkit/static/vendor/basecoat/components/button-group.css +54 -0
  61. fjkit/static/vendor/basecoat/components/button.css +6 -0
  62. fjkit/static/vendor/basecoat/components/card.css +26 -0
  63. fjkit/static/vendor/basecoat/components/chart.css +56 -0
  64. fjkit/static/vendor/basecoat/components/checkbox.css +12 -0
  65. fjkit/static/vendor/basecoat/components/collapsible.css +21 -0
  66. fjkit/static/vendor/basecoat/components/combobox.css +99 -0
  67. fjkit/static/vendor/basecoat/components/command.css +140 -0
  68. fjkit/static/vendor/basecoat/components/dialog.css +101 -0
  69. fjkit/static/vendor/basecoat/components/drawer.css +89 -0
  70. fjkit/static/vendor/basecoat/components/dropdown-menu.css +56 -0
  71. fjkit/static/vendor/basecoat/components/empty.css +26 -0
  72. fjkit/static/vendor/basecoat/components/field.css +82 -0
  73. fjkit/static/vendor/basecoat/components/form.css +9 -0
  74. fjkit/static/vendor/basecoat/components/input-group.css +74 -0
  75. fjkit/static/vendor/basecoat/components/input.css +32 -0
  76. fjkit/static/vendor/basecoat/components/item.css +50 -0
  77. fjkit/static/vendor/basecoat/components/kbd.css +6 -0
  78. fjkit/static/vendor/basecoat/components/label.css +13 -0
  79. fjkit/static/vendor/basecoat/components/native-select.css +12 -0
  80. fjkit/static/vendor/basecoat/components/popover.css +107 -0
  81. fjkit/static/vendor/basecoat/components/progress.css +14 -0
  82. fjkit/static/vendor/basecoat/components/radio.css +11 -0
  83. fjkit/static/vendor/basecoat/components/range.css +50 -0
  84. fjkit/static/vendor/basecoat/components/scrollbar.css +46 -0
  85. fjkit/static/vendor/basecoat/components/select.css +64 -0
  86. fjkit/static/vendor/basecoat/components/sidebar.css +101 -0
  87. fjkit/static/vendor/basecoat/components/skeleton.css +6 -0
  88. fjkit/static/vendor/basecoat/components/switch.css +8 -0
  89. fjkit/static/vendor/basecoat/components/table.css +34 -0
  90. fjkit/static/vendor/basecoat/components/tabs.css +31 -0
  91. fjkit/static/vendor/basecoat/components/textarea.css +7 -0
  92. fjkit/static/vendor/basecoat/components/toast.css +57 -0
  93. fjkit/static/vendor/basecoat/components/tooltip.css +82 -0
  94. fjkit/static/vendor/basecoat/js/all.min.js +1 -0
  95. fjkit/static/vendor/basecoat/styles/luma.css +1376 -0
  96. fjkit/static/vendor/basecoat/styles/lyra.css +1379 -0
  97. fjkit/static/vendor/basecoat/styles/maia.css +1364 -0
  98. fjkit/static/vendor/basecoat/styles/mira.css +1373 -0
  99. fjkit/static/vendor/basecoat/styles/nova.css +1387 -0
  100. fjkit/static/vendor/basecoat/styles/rhea.css +1381 -0
  101. fjkit/static/vendor/basecoat/styles/sera.css +1397 -0
  102. fjkit/static/vendor/basecoat/styles/vega.css +1386 -0
  103. fjkit/static/vendor/htmx/htmx.min.js +1 -0
  104. fjkit/static/vendor/htmx/json-enc.js +38 -0
  105. fjkit/styles.py +30 -0
  106. fjkit/templates/errors/page.html +92 -0
  107. fjkit/templates/ui/attrs.html +18 -0
  108. fjkit/templates/ui/button.html +64 -0
  109. fjkit/templates/ui/data.html +362 -0
  110. fjkit/templates/ui/disclosure.html +89 -0
  111. fjkit/templates/ui/feedback.html +313 -0
  112. fjkit/templates/ui/form.html +595 -0
  113. fjkit/templates/ui/icon.html +13 -0
  114. fjkit/templates/ui/layout.html +189 -0
  115. fjkit/templates/ui/nav.html +110 -0
  116. fjkit/templates/ui/overlay.html +624 -0
  117. fjkit/templates/ui/shell.html +170 -0
  118. fjkit/templates/ui/sidebar.html +170 -0
  119. fjkit/templates/ui/table.html +427 -0
  120. fjkit/templates/ui/tabs.html +133 -0
  121. fjkit/templating.py +365 -0
  122. fjkit/vendored.py +46 -0
  123. fjkit-0.1.0.dev0.dist-info/METADATA +119 -0
  124. fjkit-0.1.0.dev0.dist-info/RECORD +127 -0
  125. fjkit-0.1.0.dev0.dist-info/WHEEL +4 -0
  126. fjkit-0.1.0.dev0.dist-info/entry_points.txt +2 -0
  127. fjkit-0.1.0.dev0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,313 @@
1
+ {#
2
+ The feedback layer: what the page says while it is busy, and afterwards.
3
+
4
+ 0.6 fills the rest in (alert, toast, skeleton). 0.1 lands `spinner` and
5
+ `dialog`, because htmx makes both first-week states: "a request is in flight"
6
+ and "show me this row without leaving the page". Without a component for
7
+ either, the app writes its own <svg> and its own overlay — a colour literal
8
+ and a stack of utilities outside the closed vocabulary.
9
+ #}
10
+ {% from "ui/attrs.html" import attrs %}
11
+ {% from "ui/icon.html" import icon %}
12
+
13
+ {#
14
+ spinner(size, tone, label, indicator, **html_attrs)
15
+
16
+ size: xs | sm | default | lg
17
+ tone: muted | primary | success | warning | info | destructive
18
+
19
+ One Lucide arc plus `animate-spin`: no second SVG asset and no runtime JS.
20
+ `stroke="currentColor"` takes the colour of whatever it sits in, so a spinner
21
+ inside a primary button needs no tone.
22
+
23
+ `label` chooses between two accessibility modes:
24
+
25
+ * no label — the glyph stays `aria-hidden` and decorative. Correct when text
26
+ beside it already says what is happening ("Saving…"): announcing the glyph
27
+ as well says it twice.
28
+ * a label — `role="status"` and a visually hidden name. Correct when the
29
+ spinner is the only announcement. `role="status"` implies a polite live
30
+ region, so `aria-live` would repeat it.
31
+
32
+ `indicator=true` adds htmx's `htmx-indicator` class, which is all
33
+ `hx-indicator` needs: htmx injects the show/hide rule itself, so the spinner
34
+ renders hidden and appears only while the request naming it is in flight — a
35
+ loading state with no JavaScript of ours and no round trip to reveal it.
36
+
37
+ {{ button("Start", hx_post=…, hx_indicator="#busy") }}
38
+ {{ spinner(indicator=true, id="busy", label="Starting") }}
39
+ #}
40
+ {% macro spinner(size="default", tone="muted", label=none, indicator=false) -%}
41
+ {#
42
+ Closed lookups, not interpolation. Tailwind finds a class by scanning this
43
+ file's text, so `text-{{ tone }}` renders happily and is absent from the
44
+ stylesheet. Every value below appears here literally, and an unknown key
45
+ falls back rather than emitting a class that does not exist.
46
+ #}
47
+ {%- set sizes = {"xs": 12, "sm": 14, "default": 16, "lg": 24} -%}
48
+ {%- set tones = {
49
+ "muted": "text-muted-foreground",
50
+ "primary": "text-primary",
51
+ "success": "text-success",
52
+ "warning": "text-warning",
53
+ "info": "text-info",
54
+ "destructive": "text-destructive",
55
+ "current": "",
56
+ } -%}
57
+ {%- set tone_class = tones.get(tone, tones["muted"]) -%}
58
+ <span class="inline-flex items-center{% if tone_class %} {{ tone_class }}{% endif %}{% if indicator %} htmx-indicator{% endif %}"
59
+ {%- if label %} role="status"{% endif %}
60
+ {%- if kwargs %}{{ attrs(kwargs) }}{% endif %}>
61
+ {{- icon("loader-circle", sizes.get(size, 16), "animate-spin") -}}
62
+ {%- if label %}<span class="sr-only">{{ label }}</span>{% endif -%}
63
+ </span>
64
+ {%- endmacro %}
65
+
66
+ {#
67
+ dialog(id, title, description, size, footer, dismissible, **html_attrs)
68
+
69
+ size: sm | default | lg
70
+
71
+ A panel over the page, opened and closed by the browser, with no JavaScript
72
+ from us and none from the app:
73
+
74
+ {{ button("Details", popovertarget="task-7") }}
75
+
76
+ {% call dialog("task-7", title="Ship the render benchmark") %}
77
+ …
78
+ {% endcall %}
79
+
80
+ `popovertarget` is a plain HTML attribute and needs no macro of its own: it
81
+ passes through `**attrs` on whatever button you already have. Closing is the
82
+ same attribute plus `popovertargetaction="hide"`, which is what the ✕ in the
83
+ corner uses.
84
+
85
+ What the Popover API provides: open state, the top layer, the backdrop,
86
+ Escape-to-close, click-outside-to-close, and focus returned to the trigger.
87
+ What it lacks against `showModal()` is modality — the page behind stays
88
+ reachable by Tab and by a screen reader — so this is `role="dialog"` without
89
+ `aria-modal`, the honest label for what the markup does. That trade is right
90
+ for showing a record and wrong for a confirmation that must not be dodged:
91
+ `hx-confirm` covers that case, and a real modal is a decision to ship
92
+ JavaScript (CHARTER.md §11.3) rather than something to fake with CSS.
93
+
94
+ The body carries `id="<id>-body"`, the seam htmx needs: the trigger fetches
95
+ the content and targets that id, so a list of rows renders one shell per row
96
+ and pays for the contents only when one is opened.
97
+
98
+ {{ button("Details", popovertarget="task-7",
99
+ hx_get=url_for(request, "task_detail", task_id=7),
100
+ hx_target="#task-7-body") }}
101
+
102
+ Both happen on the one click, in the order that reads best: the panel opens
103
+ immediately with whatever the shell holds (a spinner), and the response
104
+ replaces it. htmx cancels the click's default action only for anchors and
105
+ submit buttons, so the popover on a plain button still opens.
106
+
107
+ A shell per row also keeps an open panel from showing the previous row's data
108
+ while a request is in flight. One shared dialog re-targeted at each row is
109
+ the right shape for a long list, and it has to accept that flash.
110
+
111
+ One trap, and it is silent: `hx-swap` is inherited. A trigger nested inside an
112
+ element that swaps itself with `outerHTML` — a row that polls, say — replaces
113
+ the body element rather than its contents, id and all, so the first open works
114
+ and none of the others do. Spell out `hx_swap="innerHTML"` there.
115
+ #}
116
+ {% macro dialog(id, title=none, description=none, size="default", footer=none, dismissible=true) -%}
117
+ {#
118
+ Basecoat sizes `.dialog > *` and gives `.alert-dialog` a `data-size`; the
119
+ two extra widths extend that same attribute API rather than inventing a
120
+ `dialog-lg` class. `default` emits nothing, so the common case inherits
121
+ Basecoat's own rule.
122
+ #}
123
+ {%- set sizes = {"sm": "sm", "default": "", "lg": "lg"} -%}
124
+ {%- set size_attr = sizes.get(size, "") -%}
125
+ <div class="dialog" popover id="{{ id }}" role="dialog"
126
+ {%- if size_attr %} data-size="{{ size_attr }}"{% endif %}
127
+ {%- if title %} aria-labelledby="{{ id }}-title"{% endif %}
128
+ {%- if description %} aria-describedby="{{ id }}-description"{% endif %}
129
+ {%- if kwargs %}{{ attrs(kwargs) }}{% endif %}>
130
+ {#
131
+ The inner element is the panel. Basecoat styles `.dialog > *`, so this
132
+ wrapper is load-bearing: the outer element is only a positioning context
133
+ and the backdrop's owner. That is also why it can be a <div> rather than
134
+ a <dialog> — nothing here calls `showModal()`, and `<dialog popover>`
135
+ mixes two open-state mechanisms for no gain.
136
+ #}
137
+ <div>
138
+ {%- if title or description %}
139
+ <header>
140
+ {% if title %}<h2 id="{{ id }}-title">{{ title }}</h2>{% endif %}
141
+ {% if description %}<p id="{{ id }}-description">{{ description }}</p>{% endif %}
142
+ </header>
143
+ {%- endif %}
144
+ <section id="{{ id }}-body">{{ caller() }}</section>
145
+ {%- if footer %}<footer>{{ footer }}</footer>{% endif %}
146
+ {%- if dismissible %}
147
+ {#
148
+ `autofocus` moves focus into the panel when it opens: a popover does
149
+ not do that on its own, and a screen reader never announces a dialog
150
+ nobody is focused in. It stays inert until the panel is shown, because
151
+ a closed popover is `display:none` and so not focusable — eight of
152
+ these on a page contend over nothing.
153
+ #}
154
+ <button class="btn" data-variant="ghost" data-size="icon-sm" type="button"
155
+ popovertarget="{{ id }}" popovertargetaction="hide"
156
+ aria-label="Close" autofocus>{{ icon("x", 16) }}</button>
157
+ {%- endif %}
158
+ </div>
159
+ </div>
160
+ {%- endmacro %}
161
+
162
+ {#
163
+ toaster(align) — the region toasts appear in. One per page, in the shell.
164
+
165
+ `id="toaster"` is fixed: Basecoat registers its controller against `#toaster`
166
+ and writes its CSS as `.toaster .toast`, so a toast outside this element gets
167
+ neither the behaviour nor the skin.
168
+
169
+ Empty is the normal state. It costs one element and no CSS, and keeping it
170
+ always present lets a server-rendered toast arrive on a page that did not
171
+ know in advance one was coming.
172
+ #}
173
+ {% macro toaster(align="end") -%}
174
+ <div id="toaster" class="toaster" data-align="{{ align }}">{{ caller() if caller else "" }}</div>
175
+ {%- endmacro %}
176
+
177
+ {#
178
+ toast(title, description, category, duration, action_label, action_href)
179
+
180
+ category: info | success | warning | error
181
+
182
+ Server-rendered, which is the point. Basecoat scans the DOM for `.toast` and
183
+ initialises whatever it finds, so a toast written into the page by a template
184
+ behaves like one raised by script: it animates in, times out, and dismisses
185
+ on click. No JavaScript of ours, and nothing to call after the page loads.
186
+
187
+ That is how a message survives a redirect. `HX-Trigger` cannot: the document
188
+ it would fire into is replaced before it arrives. Markup in the next page is
189
+ the only carrier a full navigation leaves intact.
190
+
191
+ `duration` is milliseconds, or -1 to stay until dismissed. Left unset,
192
+ Basecoat uses 3 s, and 5 s for `error`.
193
+
194
+ The icon is fjkit's rather than Basecoat's inline SVG: one icon set keeps
195
+ stroke weight and corner radius consistent across the page, and it costs
196
+ nothing because `icon()` is already resolved per render.
197
+ #}
198
+ {% set _TOAST_ICONS = {
199
+ "info": "info",
200
+ "success": "circle-check",
201
+ "warning": "triangle-alert",
202
+ "error": "circle-x",
203
+ } %}
204
+
205
+ {% macro toast(title, description=none, category="info", duration=none, action_label=none, action_href=none) -%}
206
+ <div class="toast"
207
+ role="{{ "alert" if category == "error" else "status" }}"
208
+ aria-atomic="true"
209
+ data-category="{{ category }}"
210
+ {%- if duration is not none %} data-duration="{{ duration }}"{% endif %}>
211
+ <div class="toast-content">
212
+ {{ icon(_TOAST_ICONS.get(category, "info"), 16) }}
213
+ <section>
214
+ <h2>{{ title }}</h2>
215
+ {% if description %}<p>{{ description }}</p>{% endif %}
216
+ </section>
217
+ {% if action_label and action_href %}
218
+ <footer>
219
+ <a href="{{ action_href }}" class="btn" data-toast-action>{{ action_label }}</a>
220
+ </footer>
221
+ {% endif %}
222
+ </div>
223
+ </div>
224
+ {%- endmacro %}
225
+
226
+ {#
227
+ alert(title, body, variant, icon_name)
228
+
229
+ Basecoat's alert is four optional slots under one `.alert` root: an icon, a
230
+ heading, a `<section>` of prose, and a `<footer>` of actions. The footer is
231
+ positioned absolutely against the root, so actions arrive through `{% call %}`
232
+ rather than as a parameter — a caller block is the only shape that lets a
233
+ button carry its own `hx-*` attributes.
234
+
235
+ `variant` is Basecoat's own `data-variant` plus the three fjkit adds in
236
+ `fjkit.css`, so the vocabulary matches `badge`. The icon follows the variant
237
+ when the caller names none: an alert marked "destructive" showing a tick is
238
+ worse than an alert with no icon.
239
+ #}
240
+ {% set _ALERT_ICONS = {
241
+ "destructive": "circle-alert",
242
+ "success": "circle-check",
243
+ "warning": "triangle-alert",
244
+ "info": "info",
245
+ } %}
246
+
247
+ {% macro alert(title, body=none, variant="", icon_name=none) -%}
248
+ {%- set glyph = icon_name if icon_name is not none else _ALERT_ICONS.get(variant) -%}
249
+ <div class="alert"
250
+ {%- if variant %} data-variant="{{ variant }}"{% endif %}
251
+ {#
252
+ `alert` for destructive, `status` for the rest: a screen reader
253
+ interrupts for the first and waits for a pause on the second, which is
254
+ the distinction the variant already draws.
255
+ #}
256
+ role="{{ "alert" if variant == "destructive" else "status" }}"
257
+ {%- if kwargs %}{{ attrs(kwargs) }}{% endif %}>
258
+ {%- if glyph %}{{ icon(glyph, 16) }}{% endif %}
259
+ <h2>{{ title }}</h2>
260
+ {%- if body %}<section>{{ body }}</section>{% endif %}
261
+ {%- if caller is defined %}<footer>{{ caller() }}</footer>{% endif %}
262
+ </div>
263
+ {%- endmacro %}
264
+
265
+ {#
266
+ skeleton(shape, width, lines)
267
+
268
+ Upstream's skeleton is a bare `.skeleton` sized by whatever utilities the
269
+ caller writes — `h-4 w-[150px]`, `size-10 rounded-full`. An app template
270
+ cannot write those (A2), so the sizes are parameters: `shape` picks the
271
+ geometry, `width` picks one of five fractions. Both are closed lookups, which
272
+ also keeps the classes in the stylesheet — Tailwind scans this file's text,
273
+ and an interpolated `w-{{ width }}` renders happily while missing from the
274
+ build.
275
+
276
+ `lines` > 1 renders a paragraph with a short last line. That is the shape
277
+ real text has; a placeholder that ignores it reads as a table.
278
+ #}
279
+ {% set _SKELETON_SHAPES = {
280
+ "text": "h-4 rounded-md",
281
+ "heading": "h-6 rounded-md",
282
+ "control": "h-9 rounded-md",
283
+ "avatar": "size-10 shrink-0 rounded-full",
284
+ "block": "aspect-video rounded-lg",
285
+ } %}
286
+ {% set _SKELETON_WIDTHS = {
287
+ "full": "w-full",
288
+ "three-quarters": "w-3/4",
289
+ "half": "w-1/2",
290
+ "third": "w-1/3",
291
+ "quarter": "w-1/4",
292
+ } %}
293
+
294
+ {% macro skeleton(shape="text", width="full", lines=1, label=none) -%}
295
+ {%- set geometry = _SKELETON_SHAPES.get(shape, _SKELETON_SHAPES["text"]) -%}
296
+ {%- set span = _SKELETON_WIDTHS.get(width, "w-full") -%}
297
+ {#
298
+ One `role="status"` on the group, not on every bar: a placeholder made of
299
+ six bars is one thing loading, and six live regions would be announced six
300
+ times. `aria-hidden` on the bars keeps their emptiness out of the tree.
301
+ #}
302
+ <div role="status"{% if label %} aria-label="{{ label }}"{% else %} aria-label="Loading"{% endif %}
303
+ class="flex flex-col gap-2"{% if kwargs %}{{ attrs(kwargs) }}{% endif %}>
304
+ {%- for line in range(lines) %}
305
+ {#
306
+ The last line of a multi-line block is short, so the paragraph ends
307
+ where a paragraph ends rather than squaring off.
308
+ #}
309
+ <div aria-hidden="true"
310
+ class="skeleton {{ geometry }} {{ "w-3/4" if lines > 1 and loop.last else span }}"></div>
311
+ {%- endfor %}
312
+ </div>
313
+ {%- endmacro %}