@zolomedia/bifrost-client 1.7.74
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.
- package/L1_Foundation/L1_Foundation.js +13 -0
- package/L1_Foundation/bootstrap/bootstrap.js +11 -0
- package/L1_Foundation/bootstrap/bootstrap_hooks.js +123 -0
- package/L1_Foundation/bootstrap/bootstrap_index.js +15 -0
- package/L1_Foundation/bootstrap/bootstrap_logger.js +135 -0
- package/L1_Foundation/bootstrap/cdn_loader.js +217 -0
- package/L1_Foundation/bootstrap/module_registry.js +102 -0
- package/L1_Foundation/bootstrap/prism_loader.js +164 -0
- package/L1_Foundation/config/client_config.js +110 -0
- package/L1_Foundation/config/config.js +7 -0
- package/L1_Foundation/connection/connection.js +8 -0
- package/L1_Foundation/connection/websocket_connection.js +122 -0
- package/L1_Foundation/constants/bifrost_constants.js +284 -0
- package/L1_Foundation/constants/constants.js +7 -0
- package/L1_Foundation/logger/logger.js +10 -0
- package/L2_Handling/L2_Handling.js +15 -0
- package/L2_Handling/cache/cache.js +22 -0
- package/L2_Handling/cache/cache_constants.js +69 -0
- package/L2_Handling/cache/orchestration/cache_manager.js +299 -0
- package/L2_Handling/cache/orchestration/cache_orchestrator.js +260 -0
- package/L2_Handling/cache/orchestration/orchestration.js +12 -0
- package/L2_Handling/cache/storage/session_manager.js +289 -0
- package/L2_Handling/cache/storage/storage.js +10 -0
- package/L2_Handling/cache/storage/storage_manager.js +590 -0
- package/L2_Handling/display/composite/composite.js +13 -0
- package/L2_Handling/display/composite/dashboard_renderer.js +221 -0
- package/L2_Handling/display/composite/swiper_renderer.js +564 -0
- package/L2_Handling/display/composite/terminal_renderer.js +922 -0
- package/L2_Handling/display/composite/wizard_conditional_renderer.js +274 -0
- package/L2_Handling/display/display.js +30 -0
- package/L2_Handling/display/feedback/feedback.js +11 -0
- package/L2_Handling/display/feedback/progressbar_renderer.js +418 -0
- package/L2_Handling/display/feedback/spinner_renderer.js +246 -0
- package/L2_Handling/display/inputs/button_renderer.js +634 -0
- package/L2_Handling/display/inputs/form_renderer.js +583 -0
- package/L2_Handling/display/inputs/input_renderer.js +658 -0
- package/L2_Handling/display/inputs/inputs.js +12 -0
- package/L2_Handling/display/navigation/menu_renderer.js +206 -0
- package/L2_Handling/display/navigation/navigation.js +11 -0
- package/L2_Handling/display/navigation/navigation_renderer.js +703 -0
- package/L2_Handling/display/orchestration/orchestration.js +11 -0
- package/L2_Handling/display/orchestration/renderer.js +430 -0
- package/L2_Handling/display/orchestration/zdisplay_orchestrator.js +1759 -0
- package/L2_Handling/display/outputs/alert_renderer.js +161 -0
- package/L2_Handling/display/outputs/audio_renderer.js +94 -0
- package/L2_Handling/display/outputs/card_renderer.js +229 -0
- package/L2_Handling/display/outputs/code_renderer.js +66 -0
- package/L2_Handling/display/outputs/dl_renderer.js +131 -0
- package/L2_Handling/display/outputs/header_renderer.js +162 -0
- package/L2_Handling/display/outputs/icon_renderer.js +107 -0
- package/L2_Handling/display/outputs/image_renderer.js +145 -0
- package/L2_Handling/display/outputs/list_renderer.js +190 -0
- package/L2_Handling/display/outputs/outputs.js +19 -0
- package/L2_Handling/display/outputs/table_renderer.js +765 -0
- package/L2_Handling/display/outputs/text_renderer.js +818 -0
- package/L2_Handling/display/outputs/typography_renderer.js +293 -0
- package/L2_Handling/display/outputs/video_renderer.js +116 -0
- package/L2_Handling/display/primitives/document_structure_primitives.js +319 -0
- package/L2_Handling/display/primitives/form_primitives.js +526 -0
- package/L2_Handling/display/primitives/generic_containers.js +109 -0
- package/L2_Handling/display/primitives/interactive_primitives.js +305 -0
- package/L2_Handling/display/primitives/link_primitives.js +552 -0
- package/L2_Handling/display/primitives/lists_primitives.js +262 -0
- package/L2_Handling/display/primitives/media_primitives.js +383 -0
- package/L2_Handling/display/primitives/primitives.js +19 -0
- package/L2_Handling/display/primitives/semantic_element_primitive.js +226 -0
- package/L2_Handling/display/primitives/table_primitives.js +528 -0
- package/L2_Handling/display/primitives/typography_primitives.js +175 -0
- package/L2_Handling/display/specialized/input_request_renderer.js +467 -0
- package/L2_Handling/display/specialized/specialized.js +10 -0
- package/L2_Handling/hooks/hooks.js +9 -0
- package/L2_Handling/hooks/menu_integration.js +57 -0
- package/L2_Handling/hooks/widget_hook_manager.js +292 -0
- package/L2_Handling/message/message.js +8 -0
- package/L2_Handling/message/message_handler.js +701 -0
- package/L2_Handling/navigation/navigation.js +8 -0
- package/L2_Handling/navigation/navigation_manager.js +403 -0
- package/L2_Handling/zhooks/features/cache_live.js +287 -0
- package/L2_Handling/zhooks/features/crumbs_live.js +292 -0
- package/L2_Handling/zhooks/zhooks_manager.js +65 -0
- package/L2_Handling/zvaf/zvaf.js +8 -0
- package/L2_Handling/zvaf/zvaf_manager.js +334 -0
- package/L3_Abstraction/L3_Abstraction.js +12 -0
- package/L3_Abstraction/orchestrator/container_unwrapper.js +101 -0
- package/L3_Abstraction/orchestrator/group_renderer.js +698 -0
- package/L3_Abstraction/orchestrator/input_event_handler.js +797 -0
- package/L3_Abstraction/orchestrator/metadata_processor.js +249 -0
- package/L3_Abstraction/orchestrator/navbar_builder.js +201 -0
- package/L3_Abstraction/orchestrator/orchestrator.js +13 -0
- package/L3_Abstraction/orchestrator/wizard_gate_handler.js +360 -0
- package/L3_Abstraction/renderer/renderer.js +1 -0
- package/L3_Abstraction/session/session.js +1 -0
- package/L4_Orchestration/L4_Orchestration.js +11 -0
- package/L4_Orchestration/client/client.js +1 -0
- package/L4_Orchestration/facade/facade.js +9 -0
- package/L4_Orchestration/facade/manager_registry.js +118 -0
- package/L4_Orchestration/facade/renderer_registry.js +274 -0
- package/L4_Orchestration/lifecycle/asset_loader.js +255 -0
- package/L4_Orchestration/lifecycle/initializer.js +135 -0
- package/L4_Orchestration/lifecycle/lifecycle.js +8 -0
- package/L4_Orchestration/rendering/facade.js +94 -0
- package/L4_Orchestration/rendering/rendering.js +7 -0
- package/LICENSE +21 -0
- package/README.md +82 -0
- package/bifrost_client.js +204 -0
- package/bifrost_core.js +1686 -0
- package/docs/ARCHITECTURE.md +111 -0
- package/docs/PROTOCOL.md +106 -0
- package/docs/RENDERERS.md +101 -0
- package/docs/SECURITY.md +92 -0
- package/package.json +24 -0
- package/syntax/prism-zconfig.js +41 -0
- package/syntax/prism-zenv.js +69 -0
- package/syntax/prism-zolo-theme.css +288 -0
- package/syntax/prism-zolo.js +380 -0
- package/syntax/prism-zschema.js +38 -0
- package/syntax/prism-zspark.js +25 -0
- package/syntax/prism-zui.js +68 -0
- package/zSys/accessibility/accessibility.js +10 -0
- package/zSys/accessibility/emoji_accessibility.js +173 -0
- package/zSys/dom/block_utils.js +122 -0
- package/zSys/dom/container_utils.js +370 -0
- package/zSys/dom/dom.js +13 -0
- package/zSys/dom/dom_utils.js +328 -0
- package/zSys/dom/encoding_utils.js +117 -0
- package/zSys/dom/style_utils.js +71 -0
- package/zSys/errors/error_display.js +299 -0
- package/zSys/errors/errors.js +10 -0
- package/zSys/theme/color_utils.js +274 -0
- package/zSys/theme/dark_mode_utils.js +272 -0
- package/zSys/theme/size_utils.js +256 -0
- package/zSys/theme/spacing_utils.js +405 -0
- package/zSys/theme/theme.js +14 -0
- package/zSys/theme/zbase.css +1735 -0
- package/zSys/theme/zbase_inject.js +161 -0
- package/zSys/theme/ztheme_utils.js +305 -0
- package/zSys/validation/error_boundary.js +201 -0
- package/zSys/validation/validation.js +11 -0
- package/zSys/validation/validation_utils.js +238 -0
- package/zSys/zSys.js +14 -0
|
@@ -0,0 +1,528 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Table Primitives - Tabular Data Structure Elements
|
|
4
|
+
*
|
|
5
|
+
*
|
|
6
|
+
* HTML table elements for displaying structured tabular data.
|
|
7
|
+
* Used for data tables, grids, and any row/column data structure.
|
|
8
|
+
*
|
|
9
|
+
* @module rendering/table_primitives
|
|
10
|
+
* @layer 0.0 (RAWEST - table structure)
|
|
11
|
+
* @pattern Pure Factory Functions
|
|
12
|
+
*
|
|
13
|
+
* Philosophy:
|
|
14
|
+
* - Semantic table structure (thead/tbody/tfoot separation)
|
|
15
|
+
* - Row-oriented organization (tr contains th/td)
|
|
16
|
+
* - Accessibility (proper header associations)
|
|
17
|
+
* - NO styling, NO classes (dress up later)
|
|
18
|
+
*
|
|
19
|
+
* Table Structure:
|
|
20
|
+
* - <table>: Container for tabular data
|
|
21
|
+
* - <caption>: Table title/description
|
|
22
|
+
* - <colgroup> + <col>: Column grouping and styling
|
|
23
|
+
* - <thead>: Header rows
|
|
24
|
+
* - <tbody>: Data rows (main content)
|
|
25
|
+
* - <tfoot>: Footer rows (totals, summaries)
|
|
26
|
+
* - <tr>: Table row (contains th or td)
|
|
27
|
+
* - <th>: Header cell (for row/column headers)
|
|
28
|
+
* - <td>: Data cell (for actual data)
|
|
29
|
+
*
|
|
30
|
+
* Semantic Meaning:
|
|
31
|
+
* - Use <th> for headers (scope="col" or scope="row")
|
|
32
|
+
* - Use <td> for data cells
|
|
33
|
+
* - Separate header, body, and footer for clarity
|
|
34
|
+
* - Use <caption> for table title (accessibility)
|
|
35
|
+
*
|
|
36
|
+
* Accessibility:
|
|
37
|
+
* - <th> elements should have scope attribute (col/row)
|
|
38
|
+
* - Complex tables may need headers/id associations
|
|
39
|
+
* - <caption> provides context for screen readers
|
|
40
|
+
*
|
|
41
|
+
* Dependencies:
|
|
42
|
+
* - utils/dom_utils.js (createElement, setAttributes)
|
|
43
|
+
*
|
|
44
|
+
* Exports:
|
|
45
|
+
* - createTable(attributes) → HTMLTableElement
|
|
46
|
+
* - createCaption(attributes) → HTMLTableCaptionElement
|
|
47
|
+
* - createColgroup(attributes) → HTMLTableColElement
|
|
48
|
+
* - createCol(attributes) → HTMLTableColElement
|
|
49
|
+
* - createThead(attributes) → HTMLTableSectionElement
|
|
50
|
+
* - createTbody(attributes) → HTMLTableSectionElement
|
|
51
|
+
* - createTfoot(attributes) → HTMLTableSectionElement
|
|
52
|
+
* - createTr(attributes) → HTMLTableRowElement
|
|
53
|
+
* - createTh(scope, attributes) → HTMLTableCellElement
|
|
54
|
+
* - createTd(attributes) → HTMLTableCellElement
|
|
55
|
+
*
|
|
56
|
+
* Example:
|
|
57
|
+
* ```javascript
|
|
58
|
+
* import { createTable, createThead, createTbody, createTr, createTh, createTd } from './table_primitives.js';
|
|
59
|
+
*
|
|
60
|
+
* // Build a simple table
|
|
61
|
+
* const table = createTable({ id: 'users' });
|
|
62
|
+
* const thead = createThead();
|
|
63
|
+
* const headerRow = createTr();
|
|
64
|
+
* headerRow.appendChild(createTh('col').textContent = 'Name');
|
|
65
|
+
* headerRow.appendChild(createTh('col').textContent = 'Age');
|
|
66
|
+
* thead.appendChild(headerRow);
|
|
67
|
+
*
|
|
68
|
+
* const tbody = createTbody();
|
|
69
|
+
* const dataRow = createTr();
|
|
70
|
+
* dataRow.appendChild(createTd()).textContent = 'Alice';
|
|
71
|
+
* dataRow.appendChild(createTd()).textContent = '30';
|
|
72
|
+
* tbody.appendChild(dataRow);
|
|
73
|
+
*
|
|
74
|
+
* table.appendChild(thead);
|
|
75
|
+
* table.appendChild(tbody);
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
// ─────────────────────────────────────────────────────────────────
|
|
80
|
+
// Imports
|
|
81
|
+
// ─────────────────────────────────────────────────────────────────
|
|
82
|
+
|
|
83
|
+
// Layer 2: Utilities
|
|
84
|
+
import { createElement, setAttributes } from '../../../zSys/dom/dom_utils.js';
|
|
85
|
+
|
|
86
|
+
//
|
|
87
|
+
// Table Container
|
|
88
|
+
//
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Create a <table> element
|
|
92
|
+
*
|
|
93
|
+
* The main container for tabular data. Should contain thead, tbody,
|
|
94
|
+
* and optionally tfoot and caption elements.
|
|
95
|
+
*
|
|
96
|
+
* Semantic Meaning:
|
|
97
|
+
* - Represents data in rows and columns
|
|
98
|
+
* - Should be used for actual tabular data (not layout!)
|
|
99
|
+
* - Contains structured header, body, and footer sections
|
|
100
|
+
*
|
|
101
|
+
* Structure:
|
|
102
|
+
* - <caption> (optional, first child if present)
|
|
103
|
+
* - <colgroup> (optional, for column styling)
|
|
104
|
+
* - <thead> (optional but recommended)
|
|
105
|
+
* - <tbody> (required, main data)
|
|
106
|
+
* - <tfoot> (optional, for summaries)
|
|
107
|
+
*
|
|
108
|
+
* @param {Object} [attributes={}] - HTML attributes (id, class, role, etc.)
|
|
109
|
+
* @returns {HTMLTableElement} The created table element
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* // Basic table
|
|
113
|
+
* const table = createTable({ id: 'data-table' });
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* // Table with ARIA attributes
|
|
117
|
+
* const accessibleTable = createTable({
|
|
118
|
+
* role: 'table',
|
|
119
|
+
* 'aria-label': 'User data table',
|
|
120
|
+
* 'aria-describedby': 'table-description'
|
|
121
|
+
* });
|
|
122
|
+
*/
|
|
123
|
+
export function createTable(attributes = {}) {
|
|
124
|
+
const table = createElement('table');
|
|
125
|
+
|
|
126
|
+
if (Object.keys(attributes).length > 0) {
|
|
127
|
+
setAttributes(table, attributes);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return table;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
//
|
|
134
|
+
// Table Caption
|
|
135
|
+
//
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Create a <caption> element
|
|
139
|
+
*
|
|
140
|
+
* Provides a title or description for the table. Should be the first
|
|
141
|
+
* child of the <table> element if present.
|
|
142
|
+
*
|
|
143
|
+
* Semantic Meaning:
|
|
144
|
+
* - Describes the purpose/content of the table
|
|
145
|
+
* - Read by screen readers for context
|
|
146
|
+
* - Acts as a heading for the table
|
|
147
|
+
*
|
|
148
|
+
* Accessibility:
|
|
149
|
+
* - Highly recommended for screen reader users
|
|
150
|
+
* - Provides context before table content
|
|
151
|
+
* - Can replace need for separate heading
|
|
152
|
+
*
|
|
153
|
+
* @param {Object} [attributes={}] - HTML attributes (id, class, etc.)
|
|
154
|
+
* @returns {HTMLTableCaptionElement} The created caption element
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* const caption = createCaption();
|
|
158
|
+
* caption.textContent = 'Monthly Sales Data - 2024';
|
|
159
|
+
* table.appendChild(caption);
|
|
160
|
+
*/
|
|
161
|
+
export function createCaption(attributes = {}) {
|
|
162
|
+
const caption = createElement('caption');
|
|
163
|
+
|
|
164
|
+
if (Object.keys(attributes).length > 0) {
|
|
165
|
+
setAttributes(caption, attributes);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return caption;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
//
|
|
172
|
+
// Column Group Elements
|
|
173
|
+
//
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Create a <colgroup> element
|
|
177
|
+
*
|
|
178
|
+
* Groups columns together for styling or semantic purposes.
|
|
179
|
+
* Contains <col> elements that define column properties.
|
|
180
|
+
*
|
|
181
|
+
* Semantic Meaning:
|
|
182
|
+
* - Groups related columns
|
|
183
|
+
* - Allows column-wide styling
|
|
184
|
+
* - Can span multiple columns
|
|
185
|
+
*
|
|
186
|
+
* Usage:
|
|
187
|
+
* - Must come before thead/tbody/tfoot
|
|
188
|
+
* - Contains <col> elements
|
|
189
|
+
* - Can have span attribute for grouping
|
|
190
|
+
*
|
|
191
|
+
* @param {Object} [attributes={}] - HTML attributes (span, class, etc.)
|
|
192
|
+
* @returns {HTMLTableColElement} The created colgroup element
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* const colgroup = createColgroup();
|
|
196
|
+
* colgroup.appendChild(createCol({ style: 'width: 100px' }));
|
|
197
|
+
* colgroup.appendChild(createCol({ style: 'width: 200px' }));
|
|
198
|
+
* table.appendChild(colgroup);
|
|
199
|
+
*/
|
|
200
|
+
export function createColgroup(attributes = {}) {
|
|
201
|
+
const colgroup = createElement('colgroup');
|
|
202
|
+
|
|
203
|
+
if (Object.keys(attributes).length > 0) {
|
|
204
|
+
setAttributes(colgroup, attributes);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return colgroup;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Create a <col> element
|
|
212
|
+
*
|
|
213
|
+
* Defines properties for a column within a colgroup.
|
|
214
|
+
* Does not contain any content - it's a void element.
|
|
215
|
+
*
|
|
216
|
+
* Semantic Meaning:
|
|
217
|
+
* - Represents a column
|
|
218
|
+
* - Can span multiple columns
|
|
219
|
+
* - Used for column-wide styling
|
|
220
|
+
*
|
|
221
|
+
* Usage:
|
|
222
|
+
* - Child of <colgroup>
|
|
223
|
+
* - Can have span attribute
|
|
224
|
+
* - Used for styling, not content
|
|
225
|
+
*
|
|
226
|
+
* @param {Object} [attributes={}] - HTML attributes (span, style, class, etc.)
|
|
227
|
+
* @returns {HTMLTableColElement} The created col element
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* // Single column
|
|
231
|
+
* const col1 = createCol({ style: 'width: 150px' });
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* // Column spanning 3 columns
|
|
235
|
+
* const col2 = createCol({ span: '3', class: 'highlight-cols' });
|
|
236
|
+
*/
|
|
237
|
+
export function createCol(attributes = {}) {
|
|
238
|
+
const col = createElement('col');
|
|
239
|
+
|
|
240
|
+
if (Object.keys(attributes).length > 0) {
|
|
241
|
+
setAttributes(col, attributes);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return col;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
//
|
|
248
|
+
// Table Sections
|
|
249
|
+
//
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Create a <thead> element
|
|
253
|
+
*
|
|
254
|
+
* Contains header rows for the table. Typically contains <th> cells.
|
|
255
|
+
*
|
|
256
|
+
* Semantic Meaning:
|
|
257
|
+
* - Groups header content
|
|
258
|
+
* - Distinguishes headers from data
|
|
259
|
+
* - Can repeat on printed pages (print CSS)
|
|
260
|
+
*
|
|
261
|
+
* Usage:
|
|
262
|
+
* - Contains <tr> elements
|
|
263
|
+
* - Should come before <tbody>
|
|
264
|
+
* - Optional but highly recommended
|
|
265
|
+
*
|
|
266
|
+
* @param {Object} [attributes={}] - HTML attributes (id, class, etc.)
|
|
267
|
+
* @returns {HTMLTableSectionElement} The created thead element
|
|
268
|
+
*
|
|
269
|
+
* @example
|
|
270
|
+
* const thead = createThead();
|
|
271
|
+
* const headerRow = createTr();
|
|
272
|
+
* headerRow.appendChild(createTh('col'));
|
|
273
|
+
* thead.appendChild(headerRow);
|
|
274
|
+
* table.appendChild(thead);
|
|
275
|
+
*/
|
|
276
|
+
export function createThead(attributes = {}) {
|
|
277
|
+
const thead = createElement('thead');
|
|
278
|
+
|
|
279
|
+
if (Object.keys(attributes).length > 0) {
|
|
280
|
+
setAttributes(thead, attributes);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
return thead;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Create a <tbody> element
|
|
288
|
+
*
|
|
289
|
+
* Contains the main data rows of the table. This is where the actual
|
|
290
|
+
* tabular data goes.
|
|
291
|
+
*
|
|
292
|
+
* Semantic Meaning:
|
|
293
|
+
* - Groups body/data content
|
|
294
|
+
* - Main content of the table
|
|
295
|
+
* - Can have multiple tbody elements for grouping
|
|
296
|
+
*
|
|
297
|
+
* Usage:
|
|
298
|
+
* - Contains <tr> elements with <td> cells
|
|
299
|
+
* - Required (implicit if omitted)
|
|
300
|
+
* - Can have multiple tbody sections
|
|
301
|
+
*
|
|
302
|
+
* @param {Object} [attributes={}] - HTML attributes (id, class, etc.)
|
|
303
|
+
* @returns {HTMLTableSectionElement} The created tbody element
|
|
304
|
+
*
|
|
305
|
+
* @example
|
|
306
|
+
* const tbody = createTbody();
|
|
307
|
+
* const dataRow = createTr();
|
|
308
|
+
* dataRow.appendChild(createTd());
|
|
309
|
+
* tbody.appendChild(dataRow);
|
|
310
|
+
* table.appendChild(tbody);
|
|
311
|
+
*/
|
|
312
|
+
export function createTbody(attributes = {}) {
|
|
313
|
+
const tbody = createElement('tbody');
|
|
314
|
+
|
|
315
|
+
if (Object.keys(attributes).length > 0) {
|
|
316
|
+
setAttributes(tbody, attributes);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
return tbody;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Create a <tfoot> element
|
|
324
|
+
*
|
|
325
|
+
* Contains footer rows for the table. Typically used for summaries,
|
|
326
|
+
* totals, or footnotes.
|
|
327
|
+
*
|
|
328
|
+
* Semantic Meaning:
|
|
329
|
+
* - Groups footer content
|
|
330
|
+
* - For summaries and totals
|
|
331
|
+
* - Can repeat on printed pages (print CSS)
|
|
332
|
+
*
|
|
333
|
+
* Usage:
|
|
334
|
+
* - Contains <tr> elements
|
|
335
|
+
* - Should come after <tbody> (HTML5)
|
|
336
|
+
* - Optional
|
|
337
|
+
*
|
|
338
|
+
* @param {Object} [attributes={}] - HTML attributes (id, class, etc.)
|
|
339
|
+
* @returns {HTMLTableSectionElement} The created tfoot element
|
|
340
|
+
*
|
|
341
|
+
* @example
|
|
342
|
+
* const tfoot = createTfoot();
|
|
343
|
+
* const totalRow = createTr();
|
|
344
|
+
* totalRow.appendChild(createTd()).textContent = 'Total:';
|
|
345
|
+
* totalRow.appendChild(createTd()).textContent = '$500';
|
|
346
|
+
* tfoot.appendChild(totalRow);
|
|
347
|
+
* table.appendChild(tfoot);
|
|
348
|
+
*/
|
|
349
|
+
export function createTfoot(attributes = {}) {
|
|
350
|
+
const tfoot = createElement('tfoot');
|
|
351
|
+
|
|
352
|
+
if (Object.keys(attributes).length > 0) {
|
|
353
|
+
setAttributes(tfoot, attributes);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
return tfoot;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
//
|
|
360
|
+
// Table Row
|
|
361
|
+
//
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Create a <tr> element
|
|
365
|
+
*
|
|
366
|
+
* Represents a row in the table. Contains <th> or <td> cells.
|
|
367
|
+
*
|
|
368
|
+
* Semantic Meaning:
|
|
369
|
+
* - Groups cells into a row
|
|
370
|
+
* - Can contain header cells (<th>) or data cells (<td>)
|
|
371
|
+
* - Defines horizontal grouping of data
|
|
372
|
+
*
|
|
373
|
+
* Usage:
|
|
374
|
+
* - Child of <thead>, <tbody>, or <tfoot>
|
|
375
|
+
* - Contains <th> or <td> elements
|
|
376
|
+
* - Each row should have same number of cells (or use colspan)
|
|
377
|
+
*
|
|
378
|
+
* @param {Object} [attributes={}] - HTML attributes (id, class, role, etc.)
|
|
379
|
+
* @returns {HTMLTableRowElement} The created tr element
|
|
380
|
+
*
|
|
381
|
+
* @example
|
|
382
|
+
* const row = createTr({ id: 'row-1' });
|
|
383
|
+
* row.appendChild(createTd()).textContent = 'Data';
|
|
384
|
+
* tbody.appendChild(row);
|
|
385
|
+
*
|
|
386
|
+
* @example
|
|
387
|
+
* // Row with ARIA attributes
|
|
388
|
+
* const accessibleRow = createTr({ role: 'row', 'aria-selected': 'false' });
|
|
389
|
+
*/
|
|
390
|
+
export function createTr(attributes = {}) {
|
|
391
|
+
const tr = createElement('tr');
|
|
392
|
+
|
|
393
|
+
if (Object.keys(attributes).length > 0) {
|
|
394
|
+
setAttributes(tr, attributes);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
return tr;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
//
|
|
401
|
+
// Table Cells
|
|
402
|
+
//
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Create a <th> element (header cell)
|
|
406
|
+
*
|
|
407
|
+
* Represents a header cell in the table. Used for column headers,
|
|
408
|
+
* row headers, or both.
|
|
409
|
+
*
|
|
410
|
+
* Semantic Meaning:
|
|
411
|
+
* - Defines header for column or row
|
|
412
|
+
* - Typically bold and centered by default
|
|
413
|
+
* - Associates data cells with their headers (accessibility)
|
|
414
|
+
*
|
|
415
|
+
* Scope Attribute:
|
|
416
|
+
* - 'col': Header for a column (most common)
|
|
417
|
+
* - 'row': Header for a row
|
|
418
|
+
* - 'colgroup': Header for column group
|
|
419
|
+
* - 'rowgroup': Header for row group
|
|
420
|
+
*
|
|
421
|
+
* Accessibility:
|
|
422
|
+
* - Screen readers use <th> to identify headers
|
|
423
|
+
* - scope attribute clarifies header relationship
|
|
424
|
+
* - Critical for table accessibility
|
|
425
|
+
*
|
|
426
|
+
* @param {string} [scope='col'] - Scope of the header ('col', 'row', 'colgroup', 'rowgroup')
|
|
427
|
+
* @param {Object} [attributes={}] - HTML attributes (id, class, colspan, rowspan, etc.)
|
|
428
|
+
* @returns {HTMLTableCellElement} The created th element
|
|
429
|
+
*
|
|
430
|
+
* @example
|
|
431
|
+
* // Column header
|
|
432
|
+
* const colHeader = createTh('col');
|
|
433
|
+
* colHeader.textContent = 'Name';
|
|
434
|
+
*
|
|
435
|
+
* @example
|
|
436
|
+
* // Row header
|
|
437
|
+
* const rowHeader = createTh('row');
|
|
438
|
+
* rowHeader.textContent = 'Total';
|
|
439
|
+
*
|
|
440
|
+
* @example
|
|
441
|
+
* // Header spanning 2 columns
|
|
442
|
+
* const spanningHeader = createTh('col', { colspan: '2' });
|
|
443
|
+
* spanningHeader.textContent = 'Full Name';
|
|
444
|
+
*/
|
|
445
|
+
export function createTh(scope = 'col', attributes = {}) {
|
|
446
|
+
const th = createElement('th');
|
|
447
|
+
|
|
448
|
+
// Set scope attribute (critical for accessibility)
|
|
449
|
+
const validScopes = ['col', 'row', 'colgroup', 'rowgroup'];
|
|
450
|
+
if (validScopes.includes(scope)) {
|
|
451
|
+
th.scope = scope;
|
|
452
|
+
} else {
|
|
453
|
+
console.warn(`[table_primitives] createTh: Invalid scope "${scope}", defaulting to "col"`);
|
|
454
|
+
th.scope = 'col';
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
// Set additional attributes
|
|
458
|
+
if (Object.keys(attributes).length > 0) {
|
|
459
|
+
setAttributes(th, attributes);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
return th;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* Create a <td> element (data cell)
|
|
467
|
+
*
|
|
468
|
+
* Represents a data cell in the table. Contains the actual tabular data.
|
|
469
|
+
*
|
|
470
|
+
* Semantic Meaning:
|
|
471
|
+
* - Contains table data (not headers)
|
|
472
|
+
* - Associated with row/column headers via position
|
|
473
|
+
* - Can span multiple rows or columns
|
|
474
|
+
*
|
|
475
|
+
* Cell Spanning:
|
|
476
|
+
* - colspan: Span multiple columns
|
|
477
|
+
* - rowspan: Span multiple rows
|
|
478
|
+
* - Use sparingly for complex layouts
|
|
479
|
+
*
|
|
480
|
+
* Accessibility:
|
|
481
|
+
* - Automatically associated with <th> headers
|
|
482
|
+
* - Can use headers attribute for complex tables
|
|
483
|
+
* - Should contain meaningful data
|
|
484
|
+
*
|
|
485
|
+
* @param {Object} [attributes={}] - HTML attributes (id, class, colspan, rowspan, headers, etc.)
|
|
486
|
+
* @returns {HTMLTableCellElement} The created td element
|
|
487
|
+
*
|
|
488
|
+
* @example
|
|
489
|
+
* // Simple data cell
|
|
490
|
+
* const cell = createTd();
|
|
491
|
+
* cell.textContent = 'Alice';
|
|
492
|
+
*
|
|
493
|
+
* @example
|
|
494
|
+
* // Cell spanning 2 columns
|
|
495
|
+
* const spanningCell = createTd({ colspan: '2' });
|
|
496
|
+
* spanningCell.textContent = 'Merged data';
|
|
497
|
+
*
|
|
498
|
+
* @example
|
|
499
|
+
* // Cell with explicit header association
|
|
500
|
+
* const complexCell = createTd({ headers: 'header1 header2' });
|
|
501
|
+
* complexCell.textContent = 'Data';
|
|
502
|
+
*/
|
|
503
|
+
export function createTd(attributes = {}) {
|
|
504
|
+
const td = createElement('td');
|
|
505
|
+
|
|
506
|
+
if (Object.keys(attributes).length > 0) {
|
|
507
|
+
setAttributes(td, attributes);
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
return td;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
//
|
|
514
|
+
// Default Export (for convenience)
|
|
515
|
+
//
|
|
516
|
+
export default {
|
|
517
|
+
createTable,
|
|
518
|
+
createCaption,
|
|
519
|
+
createColgroup,
|
|
520
|
+
createCol,
|
|
521
|
+
createThead,
|
|
522
|
+
createTbody,
|
|
523
|
+
createTfoot,
|
|
524
|
+
createTr,
|
|
525
|
+
createTh,
|
|
526
|
+
createTd
|
|
527
|
+
};
|
|
528
|
+
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Typography Primitives - Raw Text Content Elements
|
|
4
|
+
*
|
|
5
|
+
*
|
|
6
|
+
* Core text content elements: headings and paragraphs.
|
|
7
|
+
* These define document structure and readable text blocks.
|
|
8
|
+
*
|
|
9
|
+
* @module rendering/typography_primitives
|
|
10
|
+
* @layer 0.0 (RAWEST - text primitives)
|
|
11
|
+
* @pattern Pure Factory Functions
|
|
12
|
+
* @version 2.0.0 - Added native <h0> support (2026-04-19)
|
|
13
|
+
*
|
|
14
|
+
* Philosophy:
|
|
15
|
+
* - Semantic hierarchy (h0-h6 for document structure)
|
|
16
|
+
* - Block-level text (paragraphs)
|
|
17
|
+
* - NO styling, NO classes (dress up later)
|
|
18
|
+
* - zReboot.css provides baseline (margins, font-sizes, line-height)
|
|
19
|
+
*
|
|
20
|
+
* zReboot Defaults (from zTheme):
|
|
21
|
+
* - Headings: margin-top: 0, margin-bottom: 0.5rem, font-weight: 500, line-height: 1.2
|
|
22
|
+
* - Paragraph: margin-top: 0, margin-bottom: 1rem
|
|
23
|
+
*
|
|
24
|
+
* Dependencies:
|
|
25
|
+
* - utils/dom_utils.js (createElement, setAttributes)
|
|
26
|
+
*
|
|
27
|
+
* Exports:
|
|
28
|
+
* - createHeading(level, attributes) → HTMLHeadingElement (h0-h6)
|
|
29
|
+
* - createParagraph(attributes) → HTMLParagraphElement
|
|
30
|
+
*
|
|
31
|
+
* Example:
|
|
32
|
+
* ```javascript
|
|
33
|
+
* import { createHeading, createParagraph } from './typography_primitives.js';
|
|
34
|
+
*
|
|
35
|
+
* // Raw elements
|
|
36
|
+
* const systemTitle = createHeading(0, { id: 'system-title' });
|
|
37
|
+
* systemTitle.textContent = 'zOS Dashboard';
|
|
38
|
+
*
|
|
39
|
+
* const title = createHeading(1, { id: 'page-title' });
|
|
40
|
+
* title.textContent = 'Welcome';
|
|
41
|
+
*
|
|
42
|
+
* const text = createParagraph({ class: 'intro' });
|
|
43
|
+
* text.textContent = 'This is the introduction.';
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
// ─────────────────────────────────────────────────────────────────
|
|
48
|
+
// Imports
|
|
49
|
+
// ─────────────────────────────────────────────────────────────────
|
|
50
|
+
|
|
51
|
+
// Layer 2: Utilities
|
|
52
|
+
import { createElement, setAttributes } from '../../../zSys/dom/dom_utils.js';
|
|
53
|
+
|
|
54
|
+
//
|
|
55
|
+
// Heading Elements (h1-h6)
|
|
56
|
+
//
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Create a heading element (<h0> through <h6>)
|
|
60
|
+
*
|
|
61
|
+
* Used for document structure and content hierarchy.
|
|
62
|
+
* Level is enforced: 0-6 only (defaults to 1, caps at 6).
|
|
63
|
+
*
|
|
64
|
+
* Semantic Meaning:
|
|
65
|
+
* - h0: System header (zOS semantic element, like <zNavBar>, <zVaF>)
|
|
66
|
+
* - h1: Page title (typically one per page)
|
|
67
|
+
* - h2: Major sections
|
|
68
|
+
* - h3: Subsections
|
|
69
|
+
* - h4-h6: Further nested subsections
|
|
70
|
+
*
|
|
71
|
+
* zReboot Defaults:
|
|
72
|
+
* - h0: Custom zOS element (36-56px)
|
|
73
|
+
* - h1: 2.5rem (40px)
|
|
74
|
+
* - h2: 2rem (32px)
|
|
75
|
+
* - h3: 1.75rem (28px)
|
|
76
|
+
* - h4: 1.5rem (24px)
|
|
77
|
+
* - h5: 1.25rem (20px)
|
|
78
|
+
* - h6: 1rem (16px)
|
|
79
|
+
*
|
|
80
|
+
* @param {number} [level=1] - Heading level (0-6), enforced and capped
|
|
81
|
+
* @param {Object} [attributes={}] - HTML attributes (id, class, data-*, etc.)
|
|
82
|
+
* @returns {HTMLHeadingElement} The created heading element (h0-h6)
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* // System header (h0) - zOS custom element
|
|
86
|
+
* const systemTitle = createHeading(0, { id: 'system-title' });
|
|
87
|
+
* systemTitle.textContent = 'zOS Dashboard';
|
|
88
|
+
*
|
|
89
|
+
* // Page title (h1)
|
|
90
|
+
* const title = createHeading(1, { id: 'page-title' });
|
|
91
|
+
* title.textContent = 'My Application';
|
|
92
|
+
*
|
|
93
|
+
* // Section header (h2)
|
|
94
|
+
* const sectionTitle = createHeading(2);
|
|
95
|
+
* sectionTitle.textContent = 'Features';
|
|
96
|
+
*
|
|
97
|
+
* // Subsection (h3)
|
|
98
|
+
* const subsection = createHeading(3, { class: 'subsection-header' });
|
|
99
|
+
*
|
|
100
|
+
* // Invalid level (caps at h6)
|
|
101
|
+
* const invalid = createHeading(10); // Creates h6 with console warning
|
|
102
|
+
*/
|
|
103
|
+
export function createHeading(level = 1, attributes = {}) {
|
|
104
|
+
// Enforce level 0-6 (0 = system/hero heading, rendered as native <h0>)
|
|
105
|
+
const rawLevel = parseInt(level);
|
|
106
|
+
|
|
107
|
+
if (isNaN(rawLevel) || rawLevel < 0) {
|
|
108
|
+
console.warn(`[typography_primitives] createHeading: Invalid level "${level}", defaulting to 1`);
|
|
109
|
+
level = 1;
|
|
110
|
+
} else if (rawLevel > 6) {
|
|
111
|
+
console.warn(`[typography_primitives] createHeading: Level ${rawLevel} exceeds h6, capping at 6`);
|
|
112
|
+
level = 6;
|
|
113
|
+
} else {
|
|
114
|
+
level = rawLevel;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// zH0: system-level heading rendered as native <h0> (zOS custom element)
|
|
118
|
+
const tag = `h${level}`;
|
|
119
|
+
console.log(`[typography_primitives] Creating heading: level=${level}, tag=${tag}`);
|
|
120
|
+
const heading = createElement(tag);
|
|
121
|
+
|
|
122
|
+
if (Object.keys(attributes).length > 0) {
|
|
123
|
+
setAttributes(heading, attributes);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return heading;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
//
|
|
130
|
+
// Paragraph Element
|
|
131
|
+
//
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Create a <p> (paragraph) element
|
|
135
|
+
*
|
|
136
|
+
* Used for blocks of text content (body copy, descriptions, etc.).
|
|
137
|
+
* The most common text container in web documents.
|
|
138
|
+
*
|
|
139
|
+
* zReboot Defaults:
|
|
140
|
+
* - margin-top: 0
|
|
141
|
+
* - margin-bottom: 1rem
|
|
142
|
+
*
|
|
143
|
+
* @param {Object} [attributes={}] - HTML attributes (id, class, data-*, etc.)
|
|
144
|
+
* @returns {HTMLParagraphElement} The created paragraph element
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* // Basic paragraph
|
|
148
|
+
* const intro = createParagraph();
|
|
149
|
+
* intro.textContent = 'Welcome to our application.';
|
|
150
|
+
*
|
|
151
|
+
* // Paragraph with class
|
|
152
|
+
* const lead = createParagraph({ class: 'lead' });
|
|
153
|
+
* lead.textContent = 'This is a lead paragraph.';
|
|
154
|
+
*
|
|
155
|
+
* // Paragraph with data attribute
|
|
156
|
+
* const content = createParagraph({ 'data-section': 'intro', id: 'intro-text' });
|
|
157
|
+
*/
|
|
158
|
+
export function createParagraph(attributes = {}) {
|
|
159
|
+
const p = createElement('p');
|
|
160
|
+
|
|
161
|
+
if (Object.keys(attributes).length > 0) {
|
|
162
|
+
setAttributes(p, attributes);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return p;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
//
|
|
169
|
+
// Default Export (for convenience)
|
|
170
|
+
//
|
|
171
|
+
export default {
|
|
172
|
+
createHeading,
|
|
173
|
+
createParagraph
|
|
174
|
+
};
|
|
175
|
+
|