diff --git a/CHANGELOG.md b/CHANGELOG.md index bec34fa0..9b4987e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ - Refined the official website with muted blue accents, simpler navigation, a clearer primary action, and a level SQL ribbon with vertical separators, and a grounded studio scene with brushed metal and physical reflections. Restored visible progress in the streaming comparison animation. +- The table component accepts a top-level `title`, shown in a header above the table like in the list and datagrid components. ([#1261](https://github.com/sqlpage/SQLPage/issues/1261)) + - Restored parameter reuse for repeated variables on SQL Server, PostgreSQL, and SQLite, fixing SQL Server and PostgreSQL queries that repeat a variable-dependent expression in `SELECT` and `GROUP BY`. ## v0.47.0 (2026-10-15) diff --git a/examples/official-site/sqlpage/migrations/01_documentation.sql b/examples/official-site/sqlpage/migrations/01_documentation.sql index 7766adbb..df638dd4 100644 --- a/examples/official-site/sqlpage/migrations/01_documentation.sql +++ b/examples/official-site/sqlpage/migrations/01_documentation.sql @@ -951,6 +951,7 @@ Advanced users can apply custom styles to table columns using a CSS class with t INSERT INTO parameter(component, name, description, type, top_level, optional) SELECT 'table', * FROM (VALUES -- top level + ('title', 'A title displayed above the table.', 'TEXT', TRUE, TRUE), ('sort', 'Make the columns clickable to let the user sort by the value contained in the column.', 'BOOLEAN', TRUE, TRUE), ('search', 'Add a search bar at the top of the table, letting users easily filter table rows by value.', 'BOOLEAN', TRUE, TRUE), ('initial_search_value', 'Pre-fills the search bar used to filter the table. The user will still be able to edit the value to display table rows that will initially be filtered out.', 'TEXT', TRUE, TRUE), diff --git a/sqlpage/templates/table.handlebars b/sqlpage/templates/table.handlebars index a40c6b1e..b368b20f 100644 --- a/sqlpage/templates/table.handlebars +++ b/sqlpage/templates/table.handlebars @@ -1,4 +1,9 @@
+ {{#if title}} +
+

{{title}}

+
+ {{/if}}
{{#if (or search initial_search_value)}}
diff --git a/tests/sql_test_files/component_rendering/table_title_1261.sql b/tests/sql_test_files/component_rendering/table_title_1261.sql new file mode 100644 index 00000000..5f2f8ed6 --- /dev/null +++ b/tests/sql_test_files/component_rendering/table_title_1261.sql @@ -0,0 +1,2 @@ +select 'table' as component, 'It works !' as title; +select 1 as x;