Shared table UI helpers (sorting, paging) for Hiccup-based web UIs.
Shared table UI helpers (sorting, paging) for Hiccup-based web UIs.
(encode-query-params m)Turn a string-keyed map into a query string (nil values are omitted).
Turn a string-keyed map into a query string (nil values are omitted).
(pagination {:keys [table-query total-count base-url push-url-base hx-target
hx-swap extra-params]
:or {hx-swap "outerHTML"}})Render pagination controls for a table.
Shows page numbers with ellipsis, first/last jump, prev/next arrows, and a 'Showing X-Y of Z' summary.
opts:
sortable-thReturns nil when a single page is sufficient.
Render pagination controls for a table. Shows page numbers with ellipsis, first/last jump, prev/next arrows, and a 'Showing X-Y of Z' summary. opts: - :table-query normalized TableQuery map - :total-count total number of items - :base-url base URL for hx-get links (e.g. "/web/users/table") - :hx-target HTMX target selector - :hx-swap default "outerHTML"; see `sortable-th` - :push-url-base optional path used for browser URL updates (defaults to :base-url) - :extra-params map of additional query params (filters, etc.) Returns nil when a single page is sufficient.
(search-filters->params filters)Convert parsed search/filter map back into a string-keyed param map.
Convert parsed search/filter map back into a string-keyed param map.
(sortable-th {:keys [label field current-sort current-dir base-url push-url-base
_page page-size hx-target hx-swap hx-push-url?
extra-params]
:or {hx-swap "outerHTML"}})Reusable sortable table header cell.
opts:
Behaviour:
Reusable sortable table header cell.
opts:
- :label string label to display
- :field keyword used as :sort in TableQuery
- :current-sort current :sort from TableQuery
- :current-dir current :dir from TableQuery
- :base-url base path (e.g. "/web/users")
- :page current page (integer)
- :page-size current page-size (integer)
- :hx-target HTMX target selector (string)
- :hx-swap default "outerHTML": the handler returns the target element
itself. Pass "innerHTML" if it returns only the contents.
- :hx-push-url? bool, default true
- :push-url-base optional path used for browser URL updates (defaults to :base-url)
- :extra-params map of additional query params (keyword/string keys)
Behaviour:
- Clicking toggles :dir between :asc and :desc for the same :field.
- When changing sort field or direction, page is reset to 1.
(table-query->params {:keys [sort dir page page-size]})Convert a TableQuery map into a string-keyed param map for query strings.
Convert a TableQuery map into a string-keyed param map for query strings.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |