NAME
hyle-bud/hyle-bud.h - Bridge from hyle row data to bud tree rendering.
SYNOPSIS
#include <bud/bud.h>
#include <bud/bud_jsx.h>
#include <hyle/field.h>
#include <hyle-source/picker.h>
#include <hyle/schema.h>
Data Structures
Per-row action descriptor for hyle_bud_table_actions.
Spec for hyle_bud_action_picker.
Macros
Maximum number of option rows per picker page.
Maximum number of pinned selections per picker.
Maximum number of picker fields in a view.
Query-string budget for picker state.
Typedefs
Option row: an id/label pair. Alias for hyle_option_t.
Picker widget descriptor. Alias for hyle_picker_desc_t.
One picker field's view entry. Alias for hyle_picker_entry_t.
Collection of picker field entries. Alias for hyle_picker_view_t.
Storage buffers backing a picker view. Alias for hyle_picker_buffer_t.
Translation callback type.
Enumerations
Row-action descriptor for hyle_bud_table_actions.
Functions
Bind JSON object values onto a state struct described by a schema.
Bind JSON object values onto a state struct, with explicit length.
Parse picker JSON state into a view and its storage buffer.
Write a picker view's options and selections into a stl_json object.
Install the string translator used for UI labels.
Translate a message identifier via the installed translator.
Build a plain text filter input.
Filter widget for a field of a given type.
Schema-driven generic form for an entity record.
Render a standalone input control with label and container.
Render a standalone input field derived from a Hyle schema field descriptor.
Schema-driven generic filter component for one field.
Schema-driven filter built from explicit option rows.
Scoped/indexed filter for repeated rows, tables or cards.
Generic filter group / bar builder from a schema and field list.
Reset multi-select widget state.
Multi-select dropdown widget (SSR-first, WASM-enhanced).
Dropdown single-select widget (SSR-first, WASM-enhanced).
Build a sortable table header row.
Build a table body from row ids and values.
Build a full sortable table.
Build a pagination bar for a result table.
Build a table whose rows carry a uniform action overlay.
Full picker widget: trigger summary plus options panel.
Standalone action picker: field, sibling GET form and POST form.
Render panel innards and summary span HTML for the reset path.
Render only the option-row chunk (infinite-scroll append path).
Discover the active picker scope from a query string.
Collect picker entries for all reference fields in a schema.
Collect picker entries with an explicit scope suffix.
Collect the picker entry matching the query string's active field.
Add a C state struct's fields to a stl_json object.
Build a JSON array of objects from an array of C structs.
Store a query result or table slice in the client-side cache.
Retrieve a cached query result or table slice.
Invalidate all cache entries matching a dataset identifier.
Clear all entries in the client-side cache.
Return the number of active cached entries for a dataset.
Detailed Description
Bridge from hyle row data to bud tree rendering.
The only bud-dependent hyle bridge: binds JSON/state row values onto bud nodes and schema descriptors for SSR and WASM alike.
Typedef Documentation
typedef const char *(* hyle_bud_translate_fn) (const char *msgid)
Translation callback type.
Parameters
msgid Message identifier to translate.
Returns
Translated string.
Enumeration Type Documentation
enum hyle_row_action_kind_t
Row-action descriptor for hyle_bud_table_actions. Makes each row uniformly activable via a stretched overlay element in the first cell. LINK renders an (href defaults to /{module}/{id}); SUBMIT renders a <button type=submit>> that posts to the form named by form_id via the HTML5 form= attribute (no-JS friendly, works inside another enclosing form). css_class lets an look like a button.
Enumerator
- HYLE_ROW_ACTION_NONE
- No action; the row is not activable.
- HYLE_ROW_ACTION_LINK
- Row action is a link, defaulting to /{module}/{id}.
- HYLE_ROW_ACTION_SUBMIT
- Row action is a submit button posting to the named form.
Function Documentation
bud_node * hyle_bud_action_picker (const hyle_bud_action_picker_spec_t * spec, const hyle_bud_picker_view_t * pv)
Standalone action picker: field, sibling GET form and POST form.
Parameters
spec Spec describing the widget.
pv Picker view to render state from.
Returns
Fragment bud node, or NULL for invalid specs.
size_t hyle_bud_cache_count (const char * dataset_id)
Return the number of active cached entries for a dataset.
Parameters
dataset_id Dataset identifier (or NULL for total across all datasets).
Returns
Number of cached entries.
const char * hyle_bud_cache_get (const char * dataset_id, const char * query_str, size_t * len_out)
Retrieve a cached query result or table slice.
Parameters
dataset_id Dataset identifier.
query_str Query string or request key.
len_out Optional pointer to receive length in bytes.
Returns
Pointer to cached JSON string, or NULL if not in cache.
void hyle_bud_cache_invalidate (const char * dataset_id)
Invalidate all cache entries matching a dataset identifier.
Parameters
dataset_id Dataset identifier (or NULL to invalidate all datasets).
int hyle_bud_cache_put (const char * dataset_id, const char * query_str, const char * json, size_t len)
Store a query result or table slice in the client-side cache.
Parameters
dataset_id Dataset identifier (e.g. "song" or "song.items").
query_str Query string or request key.
json JSON state or response string to cache.
len Length of json in bytes (or 0 to measure via strlen).
Returns
0 on success, negative on error.
bud_node * hyle_bud_filter (const hyle_schema_desc_t * desc, const char * field_name, const char * current_value, const hyle_bud_picker_view_t * pv)
Schema-driven generic filter component for one field. Automatically draws the matching UI component (search input, boolean checkbox, single-reference dropdown, multi-reference facet dropdown, or omnisearch picker) from the field's entry in a schema descriptor.
Parameters
desc Zero-terminated schema descriptor array.
field_name Field whose descriptor drives the widget.
current_value Current value to prefill.
pv Picker view for reference fields.
Returns
Filter bud node.
bud_node * hyle_bud_filter_field (const char * key, const char * label, int type, const char * current_value, const hyle_bud_option_t * options, int noptions, const char * filter_style)
Filter widget for a field of a given type. Renders a boolean checkbox, multiselect, dropdown, or text input depending on the field type and the filter style.
Parameters
key Form field name.
label Display label.
type Hyle field type constant.
current_value Current value to prefill.
options Option rows for reference fields.
noptions Number of entries in options.
filter_style e.g. "dropdown", "multiselect", "grid".
Returns
Filter bud node.
bud_node * hyle_bud_filter_from_schema (const hyle_schema_desc_t * desc, const char * field_name, const char * current_value, const hyle_bud_option_t * options, int noptions)
Schema-driven filter built from explicit option rows.
Parameters
desc Zero-terminated schema descriptor array.
field_name Field whose descriptor drives the widget.
current_value Current value to prefill.
options Option rows for reference fields.
noptions Number of entries in options.
Returns
Filter bud node.
bud_node * hyle_bud_filter_group (const hyle_schema_desc_t * desc, const char ** field_names, int n_fields, const char * current_qs, const hyle_bud_picker_view_t * pv)
Generic filter group / bar builder from a schema and field list.
Parameters
desc Zero-terminated schema descriptor array.
field_names Array of field names to include.
n_fields Number of names in field_names.
current_qs Query string to read current values from.
pv Picker view for reference fields.
Returns
Fragment containing the filter widgets.
bud_node * hyle_bud_filter_scoped (const hyle_schema_desc_t * desc, const char * field_name, int scope, const char * current_value, const char * current_label, const char * get_action, const hyle_bud_picker_view_t * pv, int is_active, const char * extra_class, bud_node ** sibling_forms_out)
Scoped/indexed filter for repeated rows, tables or cards. A scope of 0 turns "field" into field_0, pickq-field_0, pick_q_field_0.
Parameters
desc Zero-terminated schema descriptor array.
field_name Field to build a filter for.
scope Row index, or -1 for unscoped.
current_value Current value to prefill.
current_label Label for the current selection.
get_action GET action for the sibling form.
pv Picker view for reference fields.
is_active Whether this scope is currently active.
extra_class Extra CSS class, or NULL.
sibling_forms_out Receives sibling GET forms, or NULL.
Returns
Filter bud node.
bud_node * hyle_bud_form (const hyle_schema_desc_t * schema, const void * record, const char * action, const char * cancel_href, const char * submit_label, const char * csrf_token, const hyle_bud_picker_view_t * pv, const char * vstr_val)
Schema-driven generic form for an entity record.
Parameters
schema Zero-terminated schema descriptor array.
record C struct to read current values from.
action Form action URL.
cancel_href Cancel link URL, or NULL to omit.
submit_label Submit button text.
csrf_token CSRF token for a hidden field, or NULL.
pv Picker view for reference fields.
vstr_val Value for variable-length string fields.
Returns
Form bud node.
void hyle_bud_ms_reset (void )
Reset multi-select widget state. Currently a no-op hook kept for symmetry between SSR and WASM builds.
bud_node * hyle_bud_multiselect_field (const char * key, const char * label, const char * current_value, const hyle_bud_option_t * options, int noptions)
Multi-select dropdown widget (SSR-first, WASM-enhanced). filter_style "dropdown" selects it for HYLE_FIELD_MULTI_REFERENCE fields.
Parameters
key Form field name.
label Display label.
current_value Comma-separated current selections.
options Option rows to choose from.
noptions Number of entries in options.
Returns
Multi-select bud node, or NULL without options.
bud_node * hyle_bud_pagination (int page, int per_page, int total, int row_count, const char * qs)
Build a pagination bar for a result table.
Parameters
page Current page number (1-based).
per_page Rows per page.
total Total row count.
row_count Rows on the current page.
qs Existing query string (reserved).
Returns
Pagination bud node.
int hyle_bud_pick_find_active_scope (const char * qs, char * scope_buf, size_t scope_sz)
Discover the active picker scope from a query string.
Parameters
qs Query string to scan.
scope_buf Buffer for the scope string.
scope_sz Size of scope_buf.
Returns
Scope index, or -1 when none is active.
bud_node * hyle_bud_picker_field (const hyle_bud_picker_desc_t * d)
Full picker widget: trigger summary plus options panel.
Parameters
d Picker descriptor.
Returns
Picker bud node, or NULL for an unusable descriptor.
void hyle_bud_picker_rows (const hyle_bud_picker_desc_t * d, char * rows, size_t rows_sz)
Render only the option-row chunk (infinite-scroll append path). Renders the desc's current page; caller owns the buffer.
Parameters
d Picker descriptor whose current page to render.
rows Buffer for the rows HTML.
rows_sz Size of rows.
void hyle_bud_picker_slots (const hyle_bud_picker_desc_t * d, char * panel, size_t panel_sz, char * values, size_t values_sz)
Render panel innards and summary span HTML for the reset path. Caller owns both buffers.
Parameters
d Picker descriptor.
panel Buffer for the panel HTML.
panel_sz Size of panel.
values Buffer for the summary span HTML.
values_sz Size of values.
void hyle_bud_picker_state_from_json (const char * json, size_t jlen, const char * key, const char * target, int multi, const char * q, int page, hyle_bud_picker_buffer_t * buf, hyle_bud_picker_view_t * pv_out)
Parse picker JSON state into a view and its storage buffer.
Parameters
json JSON state string to parse.
jlen Length of json in bytes.
key Form field name.
target Dataset the picker selects from.
multi Non-zero for multi-select, zero for single.
q Current search text.
page Current page number.
buf Storage buffers for the parsed options.
pv_out Picker view filled with the JSON contents.
void hyle_bud_picker_state_to_json (const hyle_bud_picker_view_t * pv, struct stl_json * j_root)
Write a picker view's options and selections into a stl_json object.
Parameters
pv Picker view to serialize.
j_root stl_json object to add the pick_opts/pick_sel keys to.
int hyle_bud_picker_view_collect_auto_fields_schema (const char * qs, const hyle_schema_desc_t * schema, hyle_bud_picker_view_t * pv_out, int * active_field_idx_out, int * active_scope_out)
Collect the picker entry matching the query string's active field.
Parameters
qs Query string to scan.
schema Zero-terminated schema descriptor array.
pv_out Picker view to fill.
active_field_idx_out Receives the matching field index, or NULL.
active_scope_out Receives the matching scope, or NULL.
Returns
Number of entries collected.
int hyle_bud_picker_view_collect_schema (const char * qs, const hyle_schema_desc_t * schema, const void * record, hyle_bud_picker_view_t * pv_out, int * active_scope_out)
Collect picker entries for all reference fields in a schema.
Parameters
qs Query string containing picker state.
schema Zero-terminated schema descriptor array.
record Record to read current values from.
pv_out Picker view to fill.
active_scope_out Receives the active scope, or NULL.
Returns
Number of entries collected.
int hyle_bud_picker_view_collect_scoped (const char * qs, const hyle_schema_desc_t * schema, const void * record, hyle_bud_picker_view_t * pv_out, const char * scope)
Collect picker entries with an explicit scope suffix.
Parameters
qs Query string containing picker state.
schema Zero-terminated schema descriptor array.
record Record to read current values from.
pv_out Picker view to fill.
scope Scope suffix, or NULL/empty for unscoped.
Returns
Number of entries collected.
bud_node * hyle_bud_reference_select_dropdown (const char * key, const char * label, const char * current_value, const hyle_bud_option_t * options, int noptions)
Dropdown single-select widget (SSR-first, WASM-enhanced). filter_style "dropdown" selects it for HYLE_FIELD_REFERENCE fields.
Parameters
key Form field name.
label Display label.
current_value Current selection id.
options Option rows to choose from.
noptions Number of entries in options.
Returns
Dropdown bud node, or NULL without options.
void hyle_bud_set_translator (hyle_bud_translate_fn fn)
Install the string translator used for UI labels.
Parameters
fn Translator callback, or NULL to clear.
void hyle_bud_state_apply (void * state, const hyle_schema_desc_t * fields, const char * json)
Bind JSON object values onto a state struct described by a schema.
Parameters
state Target struct to populate.
fields Zero-terminated schema descriptor array.
json JSON object string whose keys match field names.
void hyle_bud_state_apply_len (void * state, const hyle_schema_desc_t * fields, const char * json, size_t len)
Bind JSON object values onto a state struct, with explicit length.
Parameters
state Target struct to populate.
fields Zero-terminated schema descriptor array.
json JSON object string whose keys match field names.
len Length of json in bytes.
struct stl_json * hyle_bud_state_overlay_array (const void * items, int count, size_t elem_size, const bud_field_desc_t * fields, int int_kind, int str_kind)
Build a JSON array of objects from an array of C structs.
Parameters
items Array of C structs.
count Number of elements.
elem_size Byte size of one element.
fields Zero-terminated bud field descriptor array.
int_kind Field kind treated as int.
str_kind Field kind treated as string.
Returns
stl_json array object, or NULL on allocation failure.
int hyle_bud_state_overlay_from_desc (struct stl_json * jo, const void * state, const bud_field_desc_t * fields, int int_kind, int str_kind)
Add a C state struct's fields to a stl_json object.
Parameters
jo stl_json object to populate.
state C struct to read fields from.
fields Zero-terminated bud field descriptor array.
int_kind Field kind treated as int.
str_kind Field kind treated as string.
Returns
0 on success, -1 on NULL arguments.
bud_node * hyle_bud_table (const char ** col_keys, const char ** col_labels, int ncols, const char ** ids, int nids, const char ** values, const char * module, const char * sort_field, int sort_asc, const char * qs)
Build a full sortable table.
Parameters
col_keys Column keys used for sort URLs.
col_labels Column display labels.
ncols Number of columns.
ids Row ids.
nids Number of rows.
values Flat nids*ncols array of cell strings.
module Module name for row link URLs.
sort_field Currently sorted column key, or NULL.
sort_asc Non-zero for ascending sort.
qs Existing query string to preserve.
Returns
Table bud node.
bud_node * hyle_bud_table_actions (const char ** col_keys, const char ** col_labels, int ncols, const char ** ids, int nids, const char ** values, const char * module, const char * sort_field, int sort_asc, const char * qs, const hyle_bud_row_action_t * action)
Build a table whose rows carry a uniform action overlay.
Parameters
col_keys Column keys used for sort URLs.
col_labels Column display labels.
ncols Number of columns.
ids Row ids.
nids Number of rows.
values Flat nids*ncols array of cell strings.
module Module name for row link URLs.
sort_field Currently sorted column key, or NULL.
sort_asc Non-zero for ascending sort.
qs Existing query string to preserve.
action Row action to apply to every row.
Returns
Table bud node.
bud_node * hyle_bud_table_body (const char ** col_keys, const char ** col_labels, int ncols, const char ** ids, int nids, const char ** values, const char * module)
Build a table body from row ids and values.
Parameters
col_keys Column keys.
col_labels Column display labels.
ncols Number of columns.
ids Row ids; the first cell links to /{module}/{id}.
nids Number of rows.
values Flat nids*ncols array of cell strings.
module Module name for row link URLs.
Returns
tbody bud node.
bud_node * hyle_bud_table_header (const char ** col_keys, const char ** col_labels, int ncols, const char * sort_field, int sort_asc, const char * qs)
Build a sortable table header row.
Parameters
col_keys Column keys used for sort URLs.
col_labels Column display labels.
ncols Number of columns.
sort_field Currently sorted column key, or NULL.
sort_asc Non-zero for ascending sort.
qs Existing query string to preserve.
Returns
thead bud node.
bud_node * hyle_bud_text_input (const char * key, const char * label, const char * current_value)
Build a plain text filter input.
Parameters
key Form field name.
label Display label and placeholder.
current_value Current value to prefill.
Returns
Text input bud node.
const char * hyle_bud_tr (const char * msgid)
Translate a message identifier via the installed translator.
Parameters
msgid Message identifier.
Returns
Translated string, or msgid when no translator is set.
Author
Generated automatically by Doxygen for hyle-bud from the source code.