codecraftai-integration-runtime 1.3.0__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.
- ccai/integrationruntime/__init__.py +27 -0
- ccai/integrationruntime/entrypoints.py +59 -0
- ccai/integrationruntime/initialize.py +100 -0
- ccai/integrationruntime/integratedtestjob.py +100 -0
- ccai/integrationruntime/integrationruntimedefaulttypefactory.py +51 -0
- ccai/integrationruntime/py.typed +0 -0
- ccai/integrationruntime/results/__init__.py +13 -0
- ccai/integrationruntime/results/concentrators/__init__.py +13 -0
- ccai/integrationruntime/results/concentrators/progressconcentratorservice.py +526 -0
- ccai/integrationruntime/results/recorders/__init__.py +22 -0
- ccai/integrationruntime/results/recorders/integrationjsonresultrecorder.py +126 -0
- ccai/integrationruntime/results/recorders/streamingresultrecorder.py +271 -0
- ccai/integrationruntime/results/streaming/__init__.py +25 -0
- ccai/integrationruntime/results/streaming/resultstreamer.py +581 -0
- ccai/integrationruntime/runtimeoutputcontext.py +68 -0
- ccai/integrationruntime/runtimerunmetadata.py +165 -0
- ccai/integrationruntime/templates/v2/static/images/test-report-banner-background-image.png +0 -0
- ccai/integrationruntime/templates/v2/static/javascript/d3.v7.js +20625 -0
- ccai/integrationruntime/templates/v2/static/javascript/icon-components.js +510 -0
- ccai/integrationruntime/templates/v2/static/javascript/mojo-components.js +1417 -0
- ccai/integrationruntime/templates/v2/static/javascript/prism.js +1789 -0
- ccai/integrationruntime/templates/v2/static/javascript/testsummary-accessibility.js +704 -0
- ccai/integrationruntime/templates/v2/static/javascript/testsummary-comparison.js +1287 -0
- ccai/integrationruntime/templates/v2/static/javascript/testsummary-components.js +3499 -0
- ccai/integrationruntime/templates/v2/static/javascript/testsummary-helpers.js +426 -0
- ccai/integrationruntime/templates/v2/static/javascript/testsummary-responsive.js +493 -0
- ccai/integrationruntime/templates/v2/static/javascript/testsummary.js +1128 -0
- ccai/integrationruntime/templates/v2/static/javascript/webcomponent-helpers.js +112 -0
- ccai/integrationruntime/templates/v2/static/styles/branding-theme.css +144 -0
- ccai/integrationruntime/templates/v2/static/styles/icon-styles.css +9 -0
- ccai/integrationruntime/templates/v2/static/styles/mojo-components.css +384 -0
- ccai/integrationruntime/templates/v2/static/styles/prism.css +143 -0
- ccai/integrationruntime/templates/v2/static/styles/tabs-responsive.css +186 -0
- ccai/integrationruntime/templates/v2/static/styles/testsummary-accessibility.css +413 -0
- ccai/integrationruntime/templates/v2/static/styles/testsummary-comparison.css +746 -0
- ccai/integrationruntime/templates/v2/static/styles/testsummary-responsive.css +679 -0
- ccai/integrationruntime/templates/v2/static/styles/testsummary.css +1631 -0
- ccai/integrationruntime/templates/v2/tabs/tab-data.html +870 -0
- ccai/integrationruntime/templates/v2/tabs/tab-images.html +110 -0
- ccai/integrationruntime/templates/v2/tabs/tab-logs.html +594 -0
- ccai/integrationruntime/templates/v2/tabs/tab-sounds.html +112 -0
- ccai/integrationruntime/templates/v2/tabs/tab-timeseries.html +368 -0
- ccai/integrationruntime/templates/v2/tabs/tab-videos.html +372 -0
- ccai/integrationruntime/templates/v2/testsummary.html +81 -0
- codecraftai_integration_runtime-1.3.0.dist-info/METADATA +73 -0
- codecraftai_integration_runtime-1.3.0.dist-info/RECORD +48 -0
- codecraftai_integration_runtime-1.3.0.dist-info/WHEEL +4 -0
- codecraftai_integration_runtime-1.3.0.dist-info/licenses/LICENSE.md +204 -0
|
@@ -0,0 +1,1417 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Author: "Myron Walker"
|
|
3
|
+
Copyright: "Copyright 2024, Myron W Walker"
|
|
4
|
+
Version: = "2.0.0"
|
|
5
|
+
Email: myron.walker@gmail.com
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @fileoverview Base UI components for the Mojo component library.
|
|
10
|
+
* Provides reusable web components including collapsible panels, property displays,
|
|
11
|
+
* tab sets, and icon targets.
|
|
12
|
+
* @module mojo-components
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Flag indicating whether Mojo components have been registered with customElements.
|
|
17
|
+
* @type {boolean}
|
|
18
|
+
* @private
|
|
19
|
+
*/
|
|
20
|
+
let mojoComponentsRegistered = false;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* A clickable icon target component with tooltip support.
|
|
24
|
+
* Provides visual feedback on mouse interactions and optional tooltip display.
|
|
25
|
+
*
|
|
26
|
+
* @class MojoIconTarget
|
|
27
|
+
* @extends HTMLElement
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* <mojo-icon-target tooltip="Click me">
|
|
31
|
+
* <icon-settings></icon-settings>
|
|
32
|
+
* </mojo-icon-target>
|
|
33
|
+
*/
|
|
34
|
+
class MojoIconTarget extends HTMLElement {
|
|
35
|
+
static tagname = 'mojo-icon-target'
|
|
36
|
+
|
|
37
|
+
static template = `
|
|
38
|
+
<div id="id-icon-target" class="mojo-icon-target">
|
|
39
|
+
<icon-question-mark></icon-question-mark>
|
|
40
|
+
</div>
|
|
41
|
+
`
|
|
42
|
+
|
|
43
|
+
sel_container = "#id-icon-target"
|
|
44
|
+
sel_tooltip = "#id-tooltip"
|
|
45
|
+
|
|
46
|
+
static observedAttributes = ["tooltip"];
|
|
47
|
+
|
|
48
|
+
constructor() {
|
|
49
|
+
super();
|
|
50
|
+
|
|
51
|
+
const shadowRoot = this.attachShadow({mode: 'open'})
|
|
52
|
+
shadowRoot.innerHTML = this.getTemplate();
|
|
53
|
+
if (this.classList.length > 0) {
|
|
54
|
+
shadowRoot.classList = this.classList;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
addGlobalStylesToShadowRoot(shadowRoot);
|
|
58
|
+
|
|
59
|
+
var containerEl = this.shadowRoot.querySelector(this.sel_container);
|
|
60
|
+
|
|
61
|
+
var tooltip = this.getAttribute("tooltip");
|
|
62
|
+
if (tooltip != undefined) {
|
|
63
|
+
this.update_tooltip(containerEl, tooltip);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (this.innerHTML.trim().length > 0) {
|
|
67
|
+
containerEl.innerHTML = this.innerHTML;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
var thisComp = this;
|
|
71
|
+
|
|
72
|
+
containerEl.addEventListener("mousedown", (event) => { thisComp.mouse_down(event) });
|
|
73
|
+
containerEl.addEventListener("mouseleave", (event) => { thisComp.mouse_leave(event) });
|
|
74
|
+
containerEl.addEventListener("mouseup", (event) => { thisComp.mouse_up(event) });
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
78
|
+
if (name == "tooltip") {
|
|
79
|
+
var containerEl = this.shadowRoot.querySelector(this.sel_container);
|
|
80
|
+
|
|
81
|
+
this.update_tooltip(containerEl, newValue);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Gets the HTML template for this component.
|
|
87
|
+
* @returns {string} The HTML template string.
|
|
88
|
+
*/
|
|
89
|
+
getTemplate() {
|
|
90
|
+
return MojoIconTarget.template;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Handles mouse down event by inverting fill and background colors.
|
|
95
|
+
* @param {MouseEvent} event - The mouse down event.
|
|
96
|
+
*/
|
|
97
|
+
mouse_down(event) {
|
|
98
|
+
var thisStyle = getComputedStyle(this);
|
|
99
|
+
|
|
100
|
+
var fillColor = thisStyle.getPropertyValue("fill");
|
|
101
|
+
var backgroundColor = thisStyle.getPropertyValue("background-color");
|
|
102
|
+
|
|
103
|
+
var containerEl = this.shadowRoot.querySelector(this.sel_container);
|
|
104
|
+
|
|
105
|
+
containerEl.style.fill = backgroundColor;
|
|
106
|
+
containerEl.style.backgroundColor = fillColor;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Handles mouse leave event by resetting colors.
|
|
111
|
+
* @param {MouseEvent} event - The mouse leave event.
|
|
112
|
+
*/
|
|
113
|
+
mouse_leave(event) {
|
|
114
|
+
var containerEl = this.shadowRoot.querySelector(this.sel_container);
|
|
115
|
+
|
|
116
|
+
containerEl.style.fill = "";
|
|
117
|
+
containerEl.style.backgroundColor = "";
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Handles mouse up event by resetting colors.
|
|
122
|
+
* @param {MouseEvent} event - The mouse up event.
|
|
123
|
+
*/
|
|
124
|
+
mouse_up(event) {
|
|
125
|
+
var containerEl = this.shadowRoot.querySelector(this.sel_container);
|
|
126
|
+
|
|
127
|
+
containerEl.style.fill = "";
|
|
128
|
+
containerEl.style.backgroundColor = "";
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Updates the tooltip content for the icon target.
|
|
133
|
+
* @param {HTMLElement} containerEl - The container element.
|
|
134
|
+
* @param {string} tooltip - The tooltip text to display.
|
|
135
|
+
*/
|
|
136
|
+
update_tooltip(containerEl, tooltip) {
|
|
137
|
+
|
|
138
|
+
var ttEl = containerEl.querySelector(this.sel_tooltip);
|
|
139
|
+
|
|
140
|
+
if (tooltip.trim().length == 0) {
|
|
141
|
+
containerEl.classList.remove("mojo-tooltip");
|
|
142
|
+
|
|
143
|
+
if (ttEl != undefined) {
|
|
144
|
+
containerEl.removeChild(ttEl);
|
|
145
|
+
}
|
|
146
|
+
} else {
|
|
147
|
+
if (ttEl == undefined) {
|
|
148
|
+
ttEl = document.createElement("span");
|
|
149
|
+
|
|
150
|
+
ttEl.setAttribute("id", "id-tooltip");
|
|
151
|
+
ttEl.classList.add("mojo-tooltip-text");
|
|
152
|
+
|
|
153
|
+
containerEl.appendChild(ttEl);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
containerEl.classList.add("mojo-tooltip");
|
|
157
|
+
ttEl.innerHTML = tooltip;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* A collapsible panel component that can expand/collapse content.
|
|
167
|
+
* Provides a clickable header button that toggles content visibility.
|
|
168
|
+
*
|
|
169
|
+
* @class MojoCollapsible
|
|
170
|
+
* @extends HTMLElement
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* const collapsible = document.createElement('mojo-collapsible');
|
|
174
|
+
* collapsible.syncData('Section Title', contentElement, false);
|
|
175
|
+
*/
|
|
176
|
+
class MojoCollapsible extends HTMLElement {
|
|
177
|
+
|
|
178
|
+
static tagname = 'mojo-collapsible'
|
|
179
|
+
|
|
180
|
+
static template = `
|
|
181
|
+
<div id="id-collapsible-container" class="mojo-collapsible" >
|
|
182
|
+
<div id="id-collapsible-button" class="mojo-collapsible-button" role="button" tabindex="0" aria-expanded="false">
|
|
183
|
+
<div id="id-header-text" class="mojo-collapsible-header"></div>
|
|
184
|
+
<div id="id-header-icon" class="mojo-collapsible-icon" aria-hidden="true">+</div>
|
|
185
|
+
</div>
|
|
186
|
+
<div id="id-collapsible-content" class="mojo-collapsible-content" role="region">
|
|
187
|
+
</div>
|
|
188
|
+
</div>
|
|
189
|
+
`
|
|
190
|
+
|
|
191
|
+
// CSS selectors for accessing Shadow DOM elements
|
|
192
|
+
sel_container = "#id-collapsible-container"
|
|
193
|
+
sel_button = "#id-collapsible-button"
|
|
194
|
+
sel_header_text = "#id-header-text"
|
|
195
|
+
sel_header_icon = "#id-header-icon"
|
|
196
|
+
sel_content = "#id-collapsible-content"
|
|
197
|
+
|
|
198
|
+
// =========================================================================
|
|
199
|
+
// COMPONENT LIFECYCLE - Constructor Phase
|
|
200
|
+
// =========================================================================
|
|
201
|
+
// The constructor is called when the element is created (either via
|
|
202
|
+
// document.createElement() or when the HTML parser encounters the tag).
|
|
203
|
+
// This is the initialization phase where we set up the Shadow DOM.
|
|
204
|
+
constructor() {
|
|
205
|
+
// LIFECYCLE STEP 1: Call parent constructor (required for custom elements)
|
|
206
|
+
super();
|
|
207
|
+
|
|
208
|
+
// LIFECYCLE STEP 2: Attach Shadow DOM
|
|
209
|
+
// =====================================================================
|
|
210
|
+
// Shadow DOM provides encapsulation for the component's internal DOM
|
|
211
|
+
// structure and styles. Using mode: 'open' allows external JavaScript
|
|
212
|
+
// to access the shadow root via element.shadowRoot (useful for testing
|
|
213
|
+
// and debugging). Mode: 'closed' would hide it completely.
|
|
214
|
+
const shadowRoot = this.attachShadow({mode: 'open'})
|
|
215
|
+
|
|
216
|
+
// LIFECYCLE STEP 3: Populate Shadow DOM with template
|
|
217
|
+
// =====================================================================
|
|
218
|
+
// Set the shadow root's innerHTML to the component's HTML template.
|
|
219
|
+
// This creates the internal DOM structure that will be rendered.
|
|
220
|
+
shadowRoot.innerHTML = this.getTemplate();
|
|
221
|
+
|
|
222
|
+
// LIFECYCLE STEP 4: Adopt global styles
|
|
223
|
+
// =====================================================================
|
|
224
|
+
// Copy document-level stylesheets into the Shadow DOM so that global
|
|
225
|
+
// CSS custom properties (theming variables) and shared styles are
|
|
226
|
+
// available within the encapsulated component.
|
|
227
|
+
addGlobalStylesToShadowRoot(shadowRoot);
|
|
228
|
+
|
|
229
|
+
// LIFECYCLE STEP 5: Set up event listeners
|
|
230
|
+
// =====================================================================
|
|
231
|
+
// Query the Shadow DOM for interactive elements and attach event
|
|
232
|
+
// handlers. This must happen after the template is rendered.
|
|
233
|
+
var buttonEl = this.shadowRoot.querySelector(this.sel_button)
|
|
234
|
+
var thisComp = this;
|
|
235
|
+
|
|
236
|
+
// Use arrow function to preserve 'this' context in the event handler
|
|
237
|
+
buttonEl.addEventListener("click", (event) => { thisComp.toggle(event) });
|
|
238
|
+
|
|
239
|
+
// LIFECYCLE STEP 6: Set up keyboard navigation for accessibility
|
|
240
|
+
// =====================================================================
|
|
241
|
+
buttonEl.addEventListener("keydown", (event) => { thisComp.handleKeydown(event) });
|
|
242
|
+
|
|
243
|
+
// Generate unique IDs for ARIA relationships
|
|
244
|
+
this._buttonId = 'collapsible-btn-' + Math.random().toString(36).substr(2, 9);
|
|
245
|
+
this._contentId = 'collapsible-content-' + Math.random().toString(36).substr(2, 9);
|
|
246
|
+
buttonEl.setAttribute('id', this._buttonId);
|
|
247
|
+
buttonEl.setAttribute('aria-controls', this._contentId);
|
|
248
|
+
|
|
249
|
+
var contentEl = this.shadowRoot.querySelector(this.sel_content);
|
|
250
|
+
contentEl.setAttribute('id', this._contentId);
|
|
251
|
+
contentEl.setAttribute('aria-labelledby', this._buttonId);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Gets the HTML template for this component.
|
|
256
|
+
* @returns {string} The HTML template string.
|
|
257
|
+
*/
|
|
258
|
+
getTemplate() {
|
|
259
|
+
return MojoCollapsible.template;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Handles keyboard events for accessibility.
|
|
264
|
+
* @param {KeyboardEvent} event - The keyboard event.
|
|
265
|
+
*/
|
|
266
|
+
handleKeydown(event) {
|
|
267
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
268
|
+
event.preventDefault();
|
|
269
|
+
this.toggle(event);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// =========================================================================
|
|
274
|
+
// COMPONENT LIFECYCLE - Data Synchronization Phase
|
|
275
|
+
// =========================================================================
|
|
276
|
+
// syncData() is the primary method for updating component state with new
|
|
277
|
+
// data. Unlike React's props or Angular's inputs, Web Components don't
|
|
278
|
+
// have built-in data binding, so we use this explicit method pattern.
|
|
279
|
+
/**
|
|
280
|
+
* Synchronizes the component with data.
|
|
281
|
+
* Sets the header text, content, and initial expanded state.
|
|
282
|
+
*
|
|
283
|
+
* @param {string} header - The header text to display.
|
|
284
|
+
* @param {HTMLElement|string|undefined} content - The content to display (element, HTML string, or undefined to keep existing).
|
|
285
|
+
* @param {boolean} expanded - Whether the panel should be initially expanded.
|
|
286
|
+
*/
|
|
287
|
+
syncData(header, content, expanded) {
|
|
288
|
+
// DATA SYNC STEP 1: Update header text
|
|
289
|
+
// =====================================================================
|
|
290
|
+
// Query the Shadow DOM for the header element and update its content.
|
|
291
|
+
// Using innerHTML allows HTML formatting in the header if needed.
|
|
292
|
+
var headerTextEl = this.shadowRoot.querySelector(this.sel_header_text);
|
|
293
|
+
headerTextEl.innerHTML = header;
|
|
294
|
+
|
|
295
|
+
// DATA SYNC STEP 2: Update content area
|
|
296
|
+
// =====================================================================
|
|
297
|
+
// The content parameter can be:
|
|
298
|
+
// - HTMLElement: Append directly to the content container
|
|
299
|
+
// - String: Set as innerHTML (allows HTML markup)
|
|
300
|
+
// - undefined: Keep existing content unchanged
|
|
301
|
+
var contentEl = this.shadowRoot.querySelector(this.sel_content);
|
|
302
|
+
|
|
303
|
+
if (content != undefined) {
|
|
304
|
+
// Clear existing content before adding new content
|
|
305
|
+
contentEl.innerHTML = "";
|
|
306
|
+
|
|
307
|
+
if (content instanceof HTMLElement) {
|
|
308
|
+
// Append DOM element directly (preserves event handlers)
|
|
309
|
+
contentEl.appendChild(content);
|
|
310
|
+
} else {
|
|
311
|
+
// Set as HTML string (creates new DOM nodes)
|
|
312
|
+
contentEl.innerHTML = content;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// DATA SYNC STEP 3: Set initial expanded/collapsed state
|
|
317
|
+
// =====================================================================
|
|
318
|
+
// Control visibility using CSS display property.
|
|
319
|
+
// Empty string ("") uses the element's default display value.
|
|
320
|
+
if (expanded) {
|
|
321
|
+
contentEl.style.display = "";
|
|
322
|
+
} else {
|
|
323
|
+
contentEl.style.display = "none";
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// DATA SYNC STEP 4: Update visual indicator and ARIA state
|
|
327
|
+
// =====================================================================
|
|
328
|
+
// Sync the expand/collapse icon with the current state.
|
|
329
|
+
this.updateIconContent(contentEl);
|
|
330
|
+
this.updateAriaState(contentEl);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Toggles the visibility of the collapsible content.
|
|
335
|
+
* @param {Event} event - The click event.
|
|
336
|
+
*/
|
|
337
|
+
toggle (event) {
|
|
338
|
+
// Toggle content visibility by switching display property
|
|
339
|
+
var contentEl = this.shadowRoot.querySelector(this.sel_content);
|
|
340
|
+
|
|
341
|
+
if (contentEl.style.display == "none") {
|
|
342
|
+
contentEl.style.display = "";
|
|
343
|
+
} else {
|
|
344
|
+
contentEl.style.display = "none";
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
// Update icon to reflect new state
|
|
348
|
+
this.updateIconContent(contentEl);
|
|
349
|
+
// Update ARIA state for accessibility
|
|
350
|
+
this.updateAriaState(contentEl);
|
|
351
|
+
|
|
352
|
+
// Announce state change to screen readers if function is available
|
|
353
|
+
if (typeof updateCollapsibleAriaState === 'function') {
|
|
354
|
+
var buttonEl = this.shadowRoot.querySelector(this.sel_button);
|
|
355
|
+
updateCollapsibleAriaState(buttonEl, contentEl.style.display !== "none");
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Updates the icon content based on the expanded/collapsed state.
|
|
361
|
+
* Shows minus sign when expanded, plus sign when collapsed.
|
|
362
|
+
* @param {HTMLElement} contentEl - The content element to check visibility of.
|
|
363
|
+
*/
|
|
364
|
+
updateIconContent (contentEl) {
|
|
365
|
+
var iconEl = this.shadowRoot.querySelector(this.sel_header_icon);
|
|
366
|
+
|
|
367
|
+
// Use icon components for visual consistency
|
|
368
|
+
if (contentEl.style.display != "none") {
|
|
369
|
+
iconEl.innerHTML = "<icon-minus-sign></icon-minus-sign>";
|
|
370
|
+
} else {
|
|
371
|
+
iconEl.innerHTML = "<icon-plus-sign></icon-plus-sign>";
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Updates ARIA attributes based on the expanded/collapsed state.
|
|
377
|
+
* @param {HTMLElement} contentEl - The content element to check visibility of.
|
|
378
|
+
*/
|
|
379
|
+
updateAriaState(contentEl) {
|
|
380
|
+
var buttonEl = this.shadowRoot.querySelector(this.sel_button);
|
|
381
|
+
var isExpanded = contentEl.style.display !== "none";
|
|
382
|
+
buttonEl.setAttribute('aria-expanded', isExpanded);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* A level 2 nested collapsible panel with different styling.
|
|
389
|
+
* Extends MojoCollapsible with a different template for nested use.
|
|
390
|
+
*
|
|
391
|
+
* @class MojoCollapsibleLvl2
|
|
392
|
+
* @extends MojoCollapsible
|
|
393
|
+
*/
|
|
394
|
+
class MojoCollapsibleLvl2 extends MojoCollapsible {
|
|
395
|
+
|
|
396
|
+
static tagname = 'mojo-collapsible-lvl2'
|
|
397
|
+
|
|
398
|
+
static template = `
|
|
399
|
+
<div id="id-collapsible-container" class="mojo-collapsible-lvl2" >
|
|
400
|
+
<div id="id-collapsible-button" class="mojo-collapsible-lvl2-button" role="button" tabindex="0" aria-expanded="false">
|
|
401
|
+
<div id="id-header-text" class="mojo-collapsible-lvl2-header"></div>
|
|
402
|
+
<div id="id-header-icon" class="mojo-collapsible-lvl2-icon" aria-hidden="true">+</div>
|
|
403
|
+
</div>
|
|
404
|
+
<div id="id-collapsible-content" class="mojo-collapsible-lvl2-content" role="region">
|
|
405
|
+
</div>
|
|
406
|
+
</div>
|
|
407
|
+
`
|
|
408
|
+
|
|
409
|
+
constructor() {
|
|
410
|
+
super();
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* Gets the HTML template for this component.
|
|
415
|
+
* @returns {string} The HTML template string.
|
|
416
|
+
*/
|
|
417
|
+
getTemplate() {
|
|
418
|
+
return MojoCollapsibleLvl2.template;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* A level 3 nested collapsible panel with different styling.
|
|
425
|
+
* Extends MojoCollapsible with a different template for deeply nested use.
|
|
426
|
+
*
|
|
427
|
+
* @class MojoCollapsibleLvl3
|
|
428
|
+
* @extends MojoCollapsible
|
|
429
|
+
*/
|
|
430
|
+
class MojoCollapsibleLvl3 extends MojoCollapsible {
|
|
431
|
+
|
|
432
|
+
static tagname = 'mojo-collapsible-lvl3'
|
|
433
|
+
|
|
434
|
+
static template = `
|
|
435
|
+
<div id="id-collapsible-container" class="mojo-collapsible-lvl3" >
|
|
436
|
+
<div id="id-collapsible-button" class="mojo-collapsible-lvl3-button" role="button" tabindex="0" aria-expanded="false">
|
|
437
|
+
<div id="id-header-text" class="mojo-collapsible-lvl3-header"></div>
|
|
438
|
+
<div id="id-header-icon" class="mojo-collapsible-lvl3-icon" aria-hidden="true">+</div>
|
|
439
|
+
</div>
|
|
440
|
+
<div id="id-collapsible-content" class="mojo-collapsible-lvl3-content" role="region">
|
|
441
|
+
</div>
|
|
442
|
+
</div>
|
|
443
|
+
`
|
|
444
|
+
|
|
445
|
+
constructor() {
|
|
446
|
+
super();
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* Gets the HTML template for this component.
|
|
451
|
+
* @returns {string} The HTML template string.
|
|
452
|
+
*/
|
|
453
|
+
getTemplate() {
|
|
454
|
+
return MojoCollapsibleLvl3.template;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* A project timeline component (placeholder for future implementation).
|
|
462
|
+
*
|
|
463
|
+
* @class MojoProjectTimeline
|
|
464
|
+
* @extends HTMLElement
|
|
465
|
+
*/
|
|
466
|
+
class MojoProjectTimeline extends HTMLElement {
|
|
467
|
+
|
|
468
|
+
static tagname = "mojo-project-timeline"
|
|
469
|
+
|
|
470
|
+
static template = `
|
|
471
|
+
<div class="mojo-project-timeline">
|
|
472
|
+
</div>
|
|
473
|
+
`
|
|
474
|
+
|
|
475
|
+
constructor() {
|
|
476
|
+
super();
|
|
477
|
+
|
|
478
|
+
const shadowRoot = this.attachShadow({mode: 'open'});
|
|
479
|
+
shadowRoot.innerHTML = this.getTemplate();
|
|
480
|
+
|
|
481
|
+
addGlobalStylesToShadowRoot(shadowRoot);
|
|
482
|
+
|
|
483
|
+
var thisComp = this;
|
|
484
|
+
|
|
485
|
+
copyEl.addEventListener("mousedown", (event) => { thisComp.mouse_down(event) });
|
|
486
|
+
copyEl.addEventListener("mouseleave", (event) => { thisComp.mouse_leave(event) });
|
|
487
|
+
copyEl.addEventListener("mouseup", (event) => { thisComp.mouse_up(event) });
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* Gets the HTML template for this component.
|
|
492
|
+
* @returns {string} The HTML template string.
|
|
493
|
+
*/
|
|
494
|
+
getTemplate() {
|
|
495
|
+
return MojoProjectTimeline.template;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* Handles mouse down event (placeholder).
|
|
500
|
+
* @param {MouseEvent} event - The mouse down event.
|
|
501
|
+
*/
|
|
502
|
+
mouse_down(event) {
|
|
503
|
+
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* Handles mouse leave event (placeholder).
|
|
508
|
+
* @param {MouseEvent} event - The mouse leave event.
|
|
509
|
+
*/
|
|
510
|
+
mouse_leave(event) {
|
|
511
|
+
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Handles mouse up event (placeholder).
|
|
516
|
+
* @param {MouseEvent} event - The mouse up event.
|
|
517
|
+
*/
|
|
518
|
+
mouse_up(event) {
|
|
519
|
+
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* Synchronizes the component with project information (placeholder).
|
|
524
|
+
* @param {Object} projectInfo - The project information object.
|
|
525
|
+
*/
|
|
526
|
+
syncData(projectInfo) {
|
|
527
|
+
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* A component for displaying a single property with label, value, and copy button.
|
|
535
|
+
* Provides clipboard copy functionality for the property value.
|
|
536
|
+
*
|
|
537
|
+
* @class MojoPropertySingle
|
|
538
|
+
* @extends HTMLElement
|
|
539
|
+
*
|
|
540
|
+
* @example
|
|
541
|
+
* const prop = document.createElement('mojo-property-single');
|
|
542
|
+
* prop.syncData('API Key', 'abc123xyz');
|
|
543
|
+
*/
|
|
544
|
+
class MojoPropertySingle extends HTMLElement {
|
|
545
|
+
|
|
546
|
+
static tagname = "mojo-property-single"
|
|
547
|
+
|
|
548
|
+
static template = `
|
|
549
|
+
<div id="id-property-single-container" class="mojo-prop-single">
|
|
550
|
+
<div id="id-property-single-label" class="mojo-prop-single-label"></div>
|
|
551
|
+
<div id="id-property-single-value" class="mojo-prop-single-value"></div>
|
|
552
|
+
<button id="id-property-single-copy" class="mojo-prop-single-copy" type="button" aria-label="Copy value to clipboard" title="Copy to clipboard"><icon-copy aria-hidden="true"></icon-copy></button>
|
|
553
|
+
</div>
|
|
554
|
+
`
|
|
555
|
+
|
|
556
|
+
default_classes_container = ["mojo-prop-single"]
|
|
557
|
+
default_classes_copy = ["mojo-prop-single-copy"]
|
|
558
|
+
default_classes_label = ["mojo-prop-single-label"]
|
|
559
|
+
default_classes_value = ["mojo-prop-single-value"]
|
|
560
|
+
|
|
561
|
+
sel_copy = "#id-property-single-copy"
|
|
562
|
+
sel_label = "#id-property-single-label"
|
|
563
|
+
sel_value = "#id-property-single-value"
|
|
564
|
+
|
|
565
|
+
constructor() {
|
|
566
|
+
super();
|
|
567
|
+
|
|
568
|
+
const shadowRoot = this.attachShadow({mode: 'open'});
|
|
569
|
+
shadowRoot.innerHTML = this.getTemplate();
|
|
570
|
+
|
|
571
|
+
addGlobalStylesToShadowRoot(shadowRoot);
|
|
572
|
+
|
|
573
|
+
var copyEl = this.shadowRoot.querySelector(this.sel_copy);
|
|
574
|
+
var valueEl = this.shadowRoot.querySelector(this.sel_value);
|
|
575
|
+
|
|
576
|
+
var thisComp = this;
|
|
577
|
+
copyEl.onclick = function(e) { thisComp.copyValue(valueEl, e) };
|
|
578
|
+
|
|
579
|
+
copyEl.addEventListener("mousedown", (event) => { thisComp.mouse_down(event, copyEl) });
|
|
580
|
+
copyEl.addEventListener("mouseleave", (event) => { thisComp.mouse_leave(event, copyEl) });
|
|
581
|
+
copyEl.addEventListener("mouseup", (event) => { thisComp.mouse_up(event, copyEl) });
|
|
582
|
+
|
|
583
|
+
// Add keyboard support for copy button
|
|
584
|
+
copyEl.addEventListener("keydown", (event) => {
|
|
585
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
586
|
+
event.preventDefault();
|
|
587
|
+
thisComp.copyValue(valueEl, event);
|
|
588
|
+
}
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* Gets the HTML template for this component.
|
|
594
|
+
* @returns {string} The HTML template string.
|
|
595
|
+
*/
|
|
596
|
+
getTemplate() {
|
|
597
|
+
return MojoPropertySingle.template;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* Copies the property value to the clipboard.
|
|
602
|
+
* @param {HTMLElement} valueEl - The element containing the value to copy.
|
|
603
|
+
* @param {Event} e - The click event.
|
|
604
|
+
*/
|
|
605
|
+
copyValue(valueEl, e) {
|
|
606
|
+
var value = valueEl.innerHTML;
|
|
607
|
+
navigator.clipboard.writeText(value).then(function() {
|
|
608
|
+
// Announce to screen readers if function is available
|
|
609
|
+
if (typeof announceToScreenReader === 'function') {
|
|
610
|
+
announceToScreenReader('Value copied to clipboard');
|
|
611
|
+
}
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
* Handles mouse down event by inverting colors on the copy button.
|
|
617
|
+
* @param {MouseEvent} event - The mouse down event.
|
|
618
|
+
* @param {HTMLElement} copyEl - The copy button element.
|
|
619
|
+
*/
|
|
620
|
+
mouse_down(event, copyEl) {
|
|
621
|
+
var thisStyle = getComputedStyle(copyEl);
|
|
622
|
+
|
|
623
|
+
var fillColor = thisStyle.getPropertyValue("fill");
|
|
624
|
+
var backgroundColor = thisStyle.getPropertyValue("background-color");
|
|
625
|
+
|
|
626
|
+
copyEl.style.fill = backgroundColor;
|
|
627
|
+
copyEl.style.backgroundColor = fillColor;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
/**
|
|
631
|
+
* Handles mouse leave event by resetting colors on the copy button.
|
|
632
|
+
* @param {MouseEvent} event - The mouse leave event.
|
|
633
|
+
* @param {HTMLElement} copyEl - The copy button element.
|
|
634
|
+
*/
|
|
635
|
+
mouse_leave(event, copyEl) {
|
|
636
|
+
copyEl.style.fill = "";
|
|
637
|
+
copyEl.style.backgroundColor = "";
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* Handles mouse up event by resetting colors on the copy button.
|
|
642
|
+
* @param {MouseEvent} event - The mouse up event.
|
|
643
|
+
* @param {HTMLElement} copyEl - The copy button element.
|
|
644
|
+
*/
|
|
645
|
+
mouse_up(event, copyEl) {
|
|
646
|
+
copyEl.style.fill = "";
|
|
647
|
+
copyEl.style.backgroundColor = "";
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* Synchronizes the component with label and value data.
|
|
652
|
+
* @param {string} label - The property label.
|
|
653
|
+
* @param {string} value - The property value.
|
|
654
|
+
*/
|
|
655
|
+
syncData(label, value) {
|
|
656
|
+
var labelEl = this.shadowRoot.querySelector(this.sel_label);
|
|
657
|
+
var valueEl = this.shadowRoot.querySelector(this.sel_value);
|
|
658
|
+
|
|
659
|
+
labelEl.innerHTML = label;
|
|
660
|
+
valueEl.innerHTML = value;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
|
|
666
|
+
/**
|
|
667
|
+
* A component for displaying multiple properties in a grid table layout.
|
|
668
|
+
* Each property has a label, value, and copy button.
|
|
669
|
+
*
|
|
670
|
+
* @class MojoPropertyTable
|
|
671
|
+
* @extends HTMLElement
|
|
672
|
+
*
|
|
673
|
+
* @example
|
|
674
|
+
* const table = document.createElement('mojo-property-table');
|
|
675
|
+
* table.syncData({ 'Name': 'John', 'Email': 'john@example.com' });
|
|
676
|
+
*/
|
|
677
|
+
class MojoPropertyTable extends HTMLElement {
|
|
678
|
+
|
|
679
|
+
static tagname = "mojo-property-table";
|
|
680
|
+
|
|
681
|
+
static template = `
|
|
682
|
+
<div id="id-property-table-container" class="mojo-prop-table">
|
|
683
|
+
</div>
|
|
684
|
+
`
|
|
685
|
+
|
|
686
|
+
default_classes_container = ["mojo-prop-table"]
|
|
687
|
+
default_classes_item_copy = ["mojo-prop-table-item-copy"]
|
|
688
|
+
default_classes_item_label = ["mojo-prop-table-item-label"]
|
|
689
|
+
default_classes_item_value = ["mojo-prop-table-item-value"]
|
|
690
|
+
|
|
691
|
+
sel_container = "#id-property-table-container"
|
|
692
|
+
|
|
693
|
+
static observedAttributes = ["grid-class", "item-copy-class", "item-label-class", "item-value-class"]
|
|
694
|
+
|
|
695
|
+
constructor() {
|
|
696
|
+
super();
|
|
697
|
+
|
|
698
|
+
const shadowRoot = this.attachShadow({mode: 'open'});
|
|
699
|
+
shadowRoot.innerHTML = this.getTemplate();
|
|
700
|
+
|
|
701
|
+
addGlobalStylesToShadowRoot(shadowRoot);
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
705
|
+
|
|
706
|
+
var containerEl = this.shadowRoot.querySelector(this.sel_container);
|
|
707
|
+
|
|
708
|
+
if (name == "grid-class") {
|
|
709
|
+
containerEl.classList = newValue;
|
|
710
|
+
|
|
711
|
+
} else if ((name == "item-copy-class") || (name == "item-label-class") || (name == "item-value-class")) {
|
|
712
|
+
|
|
713
|
+
var columnIndex = 0;
|
|
714
|
+
if (name == "item-copy-class") {
|
|
715
|
+
columnIndex = 2;
|
|
716
|
+
} else if (name == "item-value-class") {
|
|
717
|
+
columnIndex = 1;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
var cindex = 0;
|
|
721
|
+
for (childEl in containerEl.childNodes) {
|
|
722
|
+
|
|
723
|
+
if ((cindex % 3) == columnIndex) {
|
|
724
|
+
childEl.classList = newValue;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
cindex += 1;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
/**
|
|
735
|
+
* Copies a property value to the clipboard.
|
|
736
|
+
* @param {HTMLElement} valEl - The element containing the value to copy.
|
|
737
|
+
* @param {Event} e - The click event.
|
|
738
|
+
*/
|
|
739
|
+
copyValue(valEl, e) {
|
|
740
|
+
var value = valEl.innerHTML;
|
|
741
|
+
navigator.clipboard.writeText(value).then(function() {
|
|
742
|
+
// Announce to screen readers if function is available
|
|
743
|
+
if (typeof announceToScreenReader === 'function') {
|
|
744
|
+
announceToScreenReader('Value copied to clipboard');
|
|
745
|
+
}
|
|
746
|
+
});
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
/**
|
|
750
|
+
* Creates a copy button element for a property value.
|
|
751
|
+
* @param {HTMLElement} valEl - The value element to copy from.
|
|
752
|
+
* @returns {HTMLElement} The copy button element.
|
|
753
|
+
*/
|
|
754
|
+
createPropertyCopy(valEl) {
|
|
755
|
+
|
|
756
|
+
var thisComp = this;
|
|
757
|
+
|
|
758
|
+
var copyEl = document.createElement("button");
|
|
759
|
+
copyEl.setAttribute("type", "button");
|
|
760
|
+
copyEl.setAttribute("aria-label", "Copy value to clipboard");
|
|
761
|
+
copyEl.setAttribute("title", "Copy to clipboard");
|
|
762
|
+
copyEl.classList = this.default_classes_item_copy;
|
|
763
|
+
copyEl.innerHTML = '<icon-copy aria-hidden="true"></icon-copy>';
|
|
764
|
+
|
|
765
|
+
copyEl.onclick = function(e) { thisComp.copyValue(valEl, e) };
|
|
766
|
+
|
|
767
|
+
copyEl.addEventListener("mousedown", (event) => { thisComp.mouse_down(event, copyEl) });
|
|
768
|
+
copyEl.addEventListener("mouseleave", (event) => { thisComp.mouse_leave(event, copyEl) });
|
|
769
|
+
copyEl.addEventListener("mouseup", (event) => { thisComp.mouse_up(event, copyEl) });
|
|
770
|
+
|
|
771
|
+
// Add keyboard support for copy button
|
|
772
|
+
copyEl.addEventListener("keydown", (event) => {
|
|
773
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
774
|
+
event.preventDefault();
|
|
775
|
+
thisComp.copyValue(valEl, event);
|
|
776
|
+
}
|
|
777
|
+
});
|
|
778
|
+
|
|
779
|
+
return copyEl;
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
/**
|
|
783
|
+
* Creates a label element for a property.
|
|
784
|
+
* @param {string} plabel - The label text.
|
|
785
|
+
* @returns {HTMLElement} The label span element.
|
|
786
|
+
*/
|
|
787
|
+
createPropertyLabel(plabel) {
|
|
788
|
+
|
|
789
|
+
var labelEl = document.createElement("span");
|
|
790
|
+
labelEl.innerHTML = plabel;
|
|
791
|
+
labelEl.classList = this.default_classes_item_label;
|
|
792
|
+
return labelEl;
|
|
793
|
+
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
/**
|
|
797
|
+
* Creates a value element for a property.
|
|
798
|
+
* @param {string} pval - The value text.
|
|
799
|
+
* @returns {HTMLElement} The value span element.
|
|
800
|
+
*/
|
|
801
|
+
createPropertyValue(pval) {
|
|
802
|
+
|
|
803
|
+
var valueEl = document.createElement("span");
|
|
804
|
+
valueEl.innerHTML = pval;
|
|
805
|
+
valueEl.classList = this.default_classes_item_value;
|
|
806
|
+
return valueEl;
|
|
807
|
+
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
/**
|
|
811
|
+
* Gets the HTML template for this component.
|
|
812
|
+
* @returns {string} The HTML template string.
|
|
813
|
+
*/
|
|
814
|
+
getTemplate() {
|
|
815
|
+
return MojoPropertyTable.template;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
/**
|
|
819
|
+
* Handles mouse down event by inverting colors on the copy button.
|
|
820
|
+
* @param {MouseEvent} event - The mouse down event.
|
|
821
|
+
* @param {HTMLElement} copyEl - The copy button element.
|
|
822
|
+
*/
|
|
823
|
+
mouse_down(event, copyEl) {
|
|
824
|
+
var thisStyle = getComputedStyle(copyEl);
|
|
825
|
+
|
|
826
|
+
var fillColor = thisStyle.getPropertyValue("fill");
|
|
827
|
+
var backgroundColor = thisStyle.getPropertyValue("background-color");
|
|
828
|
+
|
|
829
|
+
copyEl.style.fill = backgroundColor;
|
|
830
|
+
copyEl.style.backgroundColor = fillColor;
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
/**
|
|
834
|
+
* Handles mouse leave event by resetting colors on the copy button.
|
|
835
|
+
* @param {MouseEvent} event - The mouse leave event.
|
|
836
|
+
* @param {HTMLElement} copyEl - The copy button element.
|
|
837
|
+
*/
|
|
838
|
+
mouse_leave(event, copyEl) {
|
|
839
|
+
copyEl.style.fill = "";
|
|
840
|
+
copyEl.style.backgroundColor = "";
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
/**
|
|
844
|
+
* Handles mouse up event by resetting colors on the copy button.
|
|
845
|
+
* @param {MouseEvent} event - The mouse up event.
|
|
846
|
+
* @param {HTMLElement} copyEl - The copy button element.
|
|
847
|
+
*/
|
|
848
|
+
mouse_up(event, copyEl) {
|
|
849
|
+
copyEl.style.fill = "";
|
|
850
|
+
copyEl.style.backgroundColor = "";
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
/**
|
|
854
|
+
* Synchronizes the component with a properties table object.
|
|
855
|
+
* Creates label, value, and copy elements for each property.
|
|
856
|
+
* @param {Object} propertiesTable - Object with property names as keys and values as values.
|
|
857
|
+
*/
|
|
858
|
+
syncData(propertiesTable) {
|
|
859
|
+
|
|
860
|
+
var containerEl = this.shadowRoot.querySelector(this.sel_container);
|
|
861
|
+
containerEl.innerHTML = "";
|
|
862
|
+
|
|
863
|
+
var propNames = Object.keys(propertiesTable);
|
|
864
|
+
propNames.sort();
|
|
865
|
+
|
|
866
|
+
if (propNames.length > 0) {
|
|
867
|
+
|
|
868
|
+
for (const pindex in propNames) {
|
|
869
|
+
var plabel = propNames[pindex];
|
|
870
|
+
var pval = propertiesTable[plabel];
|
|
871
|
+
|
|
872
|
+
var labelEl = this.createPropertyLabel(plabel);
|
|
873
|
+
containerEl.appendChild(labelEl);
|
|
874
|
+
|
|
875
|
+
var valEl = this.createPropertyValue(pval);
|
|
876
|
+
containerEl.appendChild(valEl);
|
|
877
|
+
|
|
878
|
+
var copyEl = this.createPropertyCopy(valEl);
|
|
879
|
+
|
|
880
|
+
containerEl.appendChild(copyEl);
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
/**
|
|
890
|
+
* A tab label component for use within MojoTabSet.
|
|
891
|
+
* Displays the label/title for a tab.
|
|
892
|
+
*
|
|
893
|
+
* @class MojoTabLabel
|
|
894
|
+
* @extends HTMLElement
|
|
895
|
+
*/
|
|
896
|
+
class MojoTabLabel extends HTMLElement {
|
|
897
|
+
static tagname = "mojo-tab-label";
|
|
898
|
+
|
|
899
|
+
static observedAttributes = ["selected"]
|
|
900
|
+
|
|
901
|
+
static template = `
|
|
902
|
+
<div id="id-tab-label-container" class="mojo-tab-label-container">
|
|
903
|
+
</div>
|
|
904
|
+
`
|
|
905
|
+
|
|
906
|
+
sel_container = "#id-tab-label-container"
|
|
907
|
+
|
|
908
|
+
constructor() {
|
|
909
|
+
super();
|
|
910
|
+
|
|
911
|
+
const shadowRoot = this.attachShadow({mode: 'open'});
|
|
912
|
+
shadowRoot.innerHTML = this.getTemplate();
|
|
913
|
+
|
|
914
|
+
addGlobalStylesToShadowRoot(shadowRoot);
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
/**
|
|
918
|
+
* Gets the HTML template for this component.
|
|
919
|
+
* @returns {string} The HTML template string.
|
|
920
|
+
*/
|
|
921
|
+
getTemplate() {
|
|
922
|
+
return MojoTabLabel.template;
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
/**
|
|
926
|
+
* Synchronizes the component with label content.
|
|
927
|
+
* @param {HTMLElement|string} label - The label content (element or text).
|
|
928
|
+
*/
|
|
929
|
+
syncData(label) {
|
|
930
|
+
var containertEl = this.shadowRoot.querySelector(this.sel_container);
|
|
931
|
+
containertEl.innerHTML = "";
|
|
932
|
+
|
|
933
|
+
if (label instanceof HTMLElement) {
|
|
934
|
+
containertEl.appendChild(label);
|
|
935
|
+
} else {
|
|
936
|
+
containertEl.innerHTML = "<span>" + label + "</span>";
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
|
|
942
|
+
/**
|
|
943
|
+
* A tab content component for use within MojoTabSet.
|
|
944
|
+
* Contains the content displayed when a tab is selected.
|
|
945
|
+
*
|
|
946
|
+
* @class MojoTabContent
|
|
947
|
+
* @extends HTMLElement
|
|
948
|
+
*/
|
|
949
|
+
class MojoTabContent extends HTMLElement {
|
|
950
|
+
static tagname = "mojo-tab-content";
|
|
951
|
+
|
|
952
|
+
static observedAttributes = ["selected"]
|
|
953
|
+
|
|
954
|
+
static template = `
|
|
955
|
+
<div id="id-tab-content-container" class="mojo-tab-content-container">
|
|
956
|
+
</div>
|
|
957
|
+
`
|
|
958
|
+
|
|
959
|
+
sel_container = "#id-tab-content-container"
|
|
960
|
+
|
|
961
|
+
constructor() {
|
|
962
|
+
super();
|
|
963
|
+
|
|
964
|
+
const shadowRoot = this.attachShadow({mode: 'open'});
|
|
965
|
+
shadowRoot.innerHTML = this.getTemplate();
|
|
966
|
+
|
|
967
|
+
addGlobalStylesToShadowRoot(shadowRoot);
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
/**
|
|
971
|
+
* Gets the HTML template for this component.
|
|
972
|
+
* @returns {string} The HTML template string.
|
|
973
|
+
*/
|
|
974
|
+
getTemplate() {
|
|
975
|
+
return MojoTabContent.template;
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
/**
|
|
979
|
+
* Synchronizes the component with content.
|
|
980
|
+
* @param {HTMLElement|string} content - The content to display (element or HTML string).
|
|
981
|
+
*/
|
|
982
|
+
syncData(content) {
|
|
983
|
+
var containertEl = this.shadowRoot.querySelector(this.sel_container);
|
|
984
|
+
containertEl.innerHTML = "";
|
|
985
|
+
|
|
986
|
+
if (content instanceof HTMLElement) {
|
|
987
|
+
containertEl.appendChild(content);
|
|
988
|
+
} else {
|
|
989
|
+
containertEl.innerHTML = content;
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
|
|
995
|
+
/**
|
|
996
|
+
* Represents a single tab page with its label and content.
|
|
997
|
+
* Used by MojoTabSet to manage individual tabs.
|
|
998
|
+
*
|
|
999
|
+
* @class MojoTabPage
|
|
1000
|
+
*
|
|
1001
|
+
* @example
|
|
1002
|
+
* const tab = new MojoTabPage('settings', 'Settings', settingsContent);
|
|
1003
|
+
* const [labelEl, contentEl] = tab.createTabElements();
|
|
1004
|
+
*/
|
|
1005
|
+
class MojoTabPage {
|
|
1006
|
+
|
|
1007
|
+
/**
|
|
1008
|
+
* Creates a new MojoTabPage instance.
|
|
1009
|
+
* @param {string} key - Unique identifier for the tab.
|
|
1010
|
+
* @param {string|HTMLElement} label - The tab label (text or element).
|
|
1011
|
+
* @param {HTMLElement} content - The tab content element.
|
|
1012
|
+
*/
|
|
1013
|
+
constructor(key, label, content) {
|
|
1014
|
+
this.key = key;
|
|
1015
|
+
this.label = label;
|
|
1016
|
+
this.content = content;
|
|
1017
|
+
|
|
1018
|
+
this.labelEl = undefined;
|
|
1019
|
+
this.contentEl = undefined;
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
/**
|
|
1023
|
+
* Creates the content element for this tab.
|
|
1024
|
+
* @returns {HTMLElement} The MojoTabContent element.
|
|
1025
|
+
*/
|
|
1026
|
+
createContentElement() {
|
|
1027
|
+
|
|
1028
|
+
var contentEl = document.createElement("mojo-tab-content");
|
|
1029
|
+
|
|
1030
|
+
contentEl.classList.add("mojo-tab-content");
|
|
1031
|
+
contentEl.syncData(this.content);
|
|
1032
|
+
|
|
1033
|
+
this.contentEl = contentEl;
|
|
1034
|
+
|
|
1035
|
+
return contentEl;
|
|
1036
|
+
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
/**
|
|
1040
|
+
* Creates the label element for this tab.
|
|
1041
|
+
* @returns {HTMLElement} The MojoTabLabel element.
|
|
1042
|
+
*/
|
|
1043
|
+
createLabelElement() {
|
|
1044
|
+
|
|
1045
|
+
var labelEl = document.createElement("mojo-tab-label");
|
|
1046
|
+
|
|
1047
|
+
labelEl.classList.add("mojo-tab-label");
|
|
1048
|
+
labelEl.syncData(this.label);
|
|
1049
|
+
|
|
1050
|
+
this.labelEl = labelEl;
|
|
1051
|
+
|
|
1052
|
+
return labelEl;
|
|
1053
|
+
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
/**
|
|
1057
|
+
* Creates both label and content elements for this tab.
|
|
1058
|
+
* @returns {Array} A two-element array [labelEl, contentEl].
|
|
1059
|
+
*/
|
|
1060
|
+
createTabElements() {
|
|
1061
|
+
var labelEl = this.createLabelElement();
|
|
1062
|
+
var contentEl = this.createContentElement();
|
|
1063
|
+
|
|
1064
|
+
return [labelEl, contentEl];
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
/**
|
|
1068
|
+
* Removes the tab elements from the DOM.
|
|
1069
|
+
*/
|
|
1070
|
+
disposeTabElements() {
|
|
1071
|
+
this.labelEl.remove();
|
|
1072
|
+
this.contentEl.remove();
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
/**
|
|
1076
|
+
* Updates the selected state of this tab's elements.
|
|
1077
|
+
* @param {boolean} selected - Whether this tab is selected.
|
|
1078
|
+
*/
|
|
1079
|
+
updateSelected(selected) {
|
|
1080
|
+
if (selected) {
|
|
1081
|
+
this.contentEl.setAttribute("selected", selected);
|
|
1082
|
+
this.labelEl.setAttribute("selected", selected);
|
|
1083
|
+
} else {
|
|
1084
|
+
this.contentEl.removeAttribute("selected");
|
|
1085
|
+
this.labelEl.removeAttribute("selected");
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
|
|
1092
|
+
/**
|
|
1093
|
+
* A tabbed interface component that manages multiple tab pages.
|
|
1094
|
+
* Displays tab labels and switches between tab content on click.
|
|
1095
|
+
*
|
|
1096
|
+
* @class MojoTabSet
|
|
1097
|
+
* @extends HTMLElement
|
|
1098
|
+
*
|
|
1099
|
+
* @example
|
|
1100
|
+
* const tabset = document.createElement('mojo-tabset');
|
|
1101
|
+
* const tabs = [
|
|
1102
|
+
* new MojoTabPage('tab1', 'First Tab', content1),
|
|
1103
|
+
* new MojoTabPage('tab2', 'Second Tab', content2)
|
|
1104
|
+
* ];
|
|
1105
|
+
* tabset.syncData(tabs);
|
|
1106
|
+
*/
|
|
1107
|
+
class MojoTabSet extends HTMLElement {
|
|
1108
|
+
|
|
1109
|
+
static tagname = "mojo-tabset";
|
|
1110
|
+
|
|
1111
|
+
static template = `
|
|
1112
|
+
<div id="id-tabset-container" class="mojo-tabset">
|
|
1113
|
+
<div id="id-tabset-labels-collection" class="mojo-tabset-label-collection" role="tablist" aria-label="Tab navigation">
|
|
1114
|
+
</div>
|
|
1115
|
+
<div id="id-tabset-content-collection" class="mojo-tabset-content-collection">
|
|
1116
|
+
</div>
|
|
1117
|
+
</div>
|
|
1118
|
+
`
|
|
1119
|
+
|
|
1120
|
+
// CSS selectors for Shadow DOM element access
|
|
1121
|
+
sel_container = "#id-tabset-container"
|
|
1122
|
+
sel_labels = "#id-tabset-labels-collection"
|
|
1123
|
+
sel_content = "#id-tabset-content-collection"
|
|
1124
|
+
|
|
1125
|
+
// =========================================================================
|
|
1126
|
+
// COMPONENT LIFECYCLE - Constructor Phase
|
|
1127
|
+
// =========================================================================
|
|
1128
|
+
constructor() {
|
|
1129
|
+
super();
|
|
1130
|
+
|
|
1131
|
+
// Standard Shadow DOM setup (see MojoCollapsible for detailed comments)
|
|
1132
|
+
const shadowRoot = this.attachShadow({mode: 'open'});
|
|
1133
|
+
shadowRoot.innerHTML = this.getTemplate();
|
|
1134
|
+
|
|
1135
|
+
addGlobalStylesToShadowRoot(shadowRoot);
|
|
1136
|
+
|
|
1137
|
+
// Initialize tab state
|
|
1138
|
+
// pages: Object mapping tab keys to MojoTabPage instances
|
|
1139
|
+
// selected: Key of the currently selected tab
|
|
1140
|
+
this.pages = undefined;
|
|
1141
|
+
this.selected = undefined;
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
/**
|
|
1145
|
+
* Gets the HTML template for this component.
|
|
1146
|
+
* @returns {string} The HTML template string.
|
|
1147
|
+
*/
|
|
1148
|
+
getTemplate() {
|
|
1149
|
+
return MojoTabSet.template;
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
/**
|
|
1153
|
+
* Removes old tab pages (placeholder for cleanup).
|
|
1154
|
+
*/
|
|
1155
|
+
scrubOldPages() {
|
|
1156
|
+
// TODO: Implement cleanup of existing tab pages before adding new ones
|
|
1157
|
+
// This would call disposeTabElements() on each existing page
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
// =========================================================================
|
|
1161
|
+
// COMPONENT LIFECYCLE - Data Synchronization Phase
|
|
1162
|
+
// =========================================================================
|
|
1163
|
+
/**
|
|
1164
|
+
* Synchronizes the component with an array of tab pages.
|
|
1165
|
+
* Creates tab elements and sets up click handlers.
|
|
1166
|
+
* @param {MojoTabPage[]} tabPages - Array of MojoTabPage instances.
|
|
1167
|
+
*/
|
|
1168
|
+
syncData(tabPages) {
|
|
1169
|
+
|
|
1170
|
+
// Get references to the label and content container elements
|
|
1171
|
+
var labelsCollEl = this.shadowRoot.querySelector(this.sel_labels);
|
|
1172
|
+
var contentCollEl = this.shadowRoot.querySelector(this.sel_content);
|
|
1173
|
+
|
|
1174
|
+
// Clean up any existing tabs before adding new ones
|
|
1175
|
+
this.scrubOldPages();
|
|
1176
|
+
|
|
1177
|
+
if (tabPages.length > 0) {
|
|
1178
|
+
|
|
1179
|
+
// Store reference to this component for use in event handlers
|
|
1180
|
+
var tabsetComp = this;
|
|
1181
|
+
|
|
1182
|
+
// =====================================================================
|
|
1183
|
+
// TAB MANAGEMENT - Initialize Pages Registry
|
|
1184
|
+
// =====================================================================
|
|
1185
|
+
// The pages object maps tab keys to MojoTabPage instances.
|
|
1186
|
+
// This allows O(1) lookup when switching tabs by key.
|
|
1187
|
+
this.pages = {}
|
|
1188
|
+
|
|
1189
|
+
for (const tindex in tabPages) {
|
|
1190
|
+
const tpage = tabPages[tindex];
|
|
1191
|
+
|
|
1192
|
+
// =====================================================================
|
|
1193
|
+
// TAB MANAGEMENT - Create Tab Elements
|
|
1194
|
+
// =====================================================================
|
|
1195
|
+
// Each MojoTabPage creates two elements:
|
|
1196
|
+
// 1. labelEl - The clickable tab button
|
|
1197
|
+
// 2. contentEl - The content panel shown when tab is selected
|
|
1198
|
+
const [labelEl, contentEl] = tpage.createTabElements();
|
|
1199
|
+
|
|
1200
|
+
// =====================================================================
|
|
1201
|
+
// TAB MANAGEMENT - Set Up ARIA Attributes for Accessibility
|
|
1202
|
+
// =====================================================================
|
|
1203
|
+
var tabId = 'tab-' + tpage.key;
|
|
1204
|
+
var panelId = 'tabpanel-' + tpage.key;
|
|
1205
|
+
|
|
1206
|
+
labelEl.setAttribute('role', 'tab');
|
|
1207
|
+
labelEl.setAttribute('id', tabId);
|
|
1208
|
+
labelEl.setAttribute('aria-controls', panelId);
|
|
1209
|
+
labelEl.setAttribute('aria-selected', tindex == 0 ? 'true' : 'false');
|
|
1210
|
+
labelEl.setAttribute('tabindex', tindex == 0 ? '0' : '-1');
|
|
1211
|
+
|
|
1212
|
+
contentEl.setAttribute('role', 'tabpanel');
|
|
1213
|
+
contentEl.setAttribute('id', panelId);
|
|
1214
|
+
contentEl.setAttribute('aria-labelledby', tabId);
|
|
1215
|
+
contentEl.setAttribute('tabindex', '0');
|
|
1216
|
+
|
|
1217
|
+
// =====================================================================
|
|
1218
|
+
// TAB MANAGEMENT - Set Up Click Handler
|
|
1219
|
+
// =====================================================================
|
|
1220
|
+
// When a tab label is clicked, call tabClick() to switch to that tab.
|
|
1221
|
+
// We use a closure to capture the specific tpage for this handler.
|
|
1222
|
+
labelEl.onclick = function(e) {
|
|
1223
|
+
tabsetComp.tabClick(tpage, e)
|
|
1224
|
+
};
|
|
1225
|
+
|
|
1226
|
+
// =====================================================================
|
|
1227
|
+
// TAB MANAGEMENT - Set Up Keyboard Handler for Accessibility
|
|
1228
|
+
// =====================================================================
|
|
1229
|
+
labelEl.addEventListener('keydown', function(e) {
|
|
1230
|
+
tabsetComp.handleTabKeydown(e, tpage);
|
|
1231
|
+
});
|
|
1232
|
+
|
|
1233
|
+
// Register the page in the pages lookup table
|
|
1234
|
+
this.pages[tpage.key] = tpage;
|
|
1235
|
+
|
|
1236
|
+
// =====================================================================
|
|
1237
|
+
// TAB MANAGEMENT - Append Elements to DOM
|
|
1238
|
+
// =====================================================================
|
|
1239
|
+
// Add the label to the labels collection (tab bar)
|
|
1240
|
+
// Add the content to the content collection (content area)
|
|
1241
|
+
labelsCollEl.appendChild(labelEl);
|
|
1242
|
+
contentCollEl.appendChild(contentEl);
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
// =====================================================================
|
|
1246
|
+
// TAB MANAGEMENT - Set Initial Selection
|
|
1247
|
+
// =====================================================================
|
|
1248
|
+
// Select the first tab by default
|
|
1249
|
+
this.selected = tabPages[0].key;
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
// Update visual state to show the selected tab
|
|
1253
|
+
this.switchToSelected()
|
|
1254
|
+
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
/**
|
|
1258
|
+
* Handles keyboard navigation for tabs.
|
|
1259
|
+
* @param {KeyboardEvent} event - The keyboard event.
|
|
1260
|
+
* @param {MojoTabPage} currentPage - The currently focused tab page.
|
|
1261
|
+
*/
|
|
1262
|
+
handleTabKeydown(event, currentPage) {
|
|
1263
|
+
var pageKeys = Object.keys(this.pages);
|
|
1264
|
+
var currentIndex = pageKeys.indexOf(currentPage.key);
|
|
1265
|
+
var newIndex = currentIndex;
|
|
1266
|
+
|
|
1267
|
+
switch (event.key) {
|
|
1268
|
+
case 'ArrowLeft':
|
|
1269
|
+
case 'ArrowUp':
|
|
1270
|
+
event.preventDefault();
|
|
1271
|
+
newIndex = currentIndex > 0 ? currentIndex - 1 : pageKeys.length - 1;
|
|
1272
|
+
break;
|
|
1273
|
+
case 'ArrowRight':
|
|
1274
|
+
case 'ArrowDown':
|
|
1275
|
+
event.preventDefault();
|
|
1276
|
+
newIndex = currentIndex < pageKeys.length - 1 ? currentIndex + 1 : 0;
|
|
1277
|
+
break;
|
|
1278
|
+
case 'Home':
|
|
1279
|
+
event.preventDefault();
|
|
1280
|
+
newIndex = 0;
|
|
1281
|
+
break;
|
|
1282
|
+
case 'End':
|
|
1283
|
+
event.preventDefault();
|
|
1284
|
+
newIndex = pageKeys.length - 1;
|
|
1285
|
+
break;
|
|
1286
|
+
case 'Enter':
|
|
1287
|
+
case ' ':
|
|
1288
|
+
event.preventDefault();
|
|
1289
|
+
this.tabClick(currentPage, event);
|
|
1290
|
+
return;
|
|
1291
|
+
default:
|
|
1292
|
+
return;
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
// Focus and select the new tab
|
|
1296
|
+
var newKey = pageKeys[newIndex];
|
|
1297
|
+
var newPage = this.pages[newKey];
|
|
1298
|
+
if (newPage && newPage.labelEl) {
|
|
1299
|
+
newPage.labelEl.focus();
|
|
1300
|
+
this.tabClick(newPage, event);
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
// =========================================================================
|
|
1305
|
+
// TAB MANAGEMENT - Selection State Update
|
|
1306
|
+
// =========================================================================
|
|
1307
|
+
/**
|
|
1308
|
+
* Updates the visual state to show the currently selected tab.
|
|
1309
|
+
* Hides non-selected tabs and shows the selected one.
|
|
1310
|
+
*/
|
|
1311
|
+
switchToSelected() {
|
|
1312
|
+
var pageKeys = Object.keys(this.pages);
|
|
1313
|
+
|
|
1314
|
+
if (pageKeys.length > 0) {
|
|
1315
|
+
|
|
1316
|
+
// Iterate through all pages and update their selected state
|
|
1317
|
+
// Each page's updateSelected() method handles showing/hiding
|
|
1318
|
+
// and applying the appropriate CSS classes
|
|
1319
|
+
for (const pki in pageKeys) {
|
|
1320
|
+
var pkey = pageKeys[pki];
|
|
1321
|
+
var page = this.pages[pkey];
|
|
1322
|
+
var isSelected = pkey == this.selected;
|
|
1323
|
+
|
|
1324
|
+
// Pass true if this page's key matches the selected key
|
|
1325
|
+
page.updateSelected(isSelected);
|
|
1326
|
+
|
|
1327
|
+
// Update ARIA attributes for accessibility
|
|
1328
|
+
if (page.labelEl) {
|
|
1329
|
+
page.labelEl.setAttribute('aria-selected', isSelected ? 'true' : 'false');
|
|
1330
|
+
page.labelEl.setAttribute('tabindex', isSelected ? '0' : '-1');
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
// =========================================================================
|
|
1339
|
+
// TAB MANAGEMENT - User Interaction Handler
|
|
1340
|
+
// =========================================================================
|
|
1341
|
+
/**
|
|
1342
|
+
* Handles tab click events by selecting the clicked tab.
|
|
1343
|
+
* @param {MojoTabPage} tpage - The tab page that was clicked.
|
|
1344
|
+
* @param {Event} event - The click event.
|
|
1345
|
+
*/
|
|
1346
|
+
tabClick(tpage, event) {
|
|
1347
|
+
// Update the selected key to the clicked tab's key
|
|
1348
|
+
this.selected = tpage.key;
|
|
1349
|
+
// Refresh the visual state to reflect the new selection
|
|
1350
|
+
this.switchToSelected();
|
|
1351
|
+
|
|
1352
|
+
// Announce tab change to screen readers if function is available
|
|
1353
|
+
if (typeof announceToScreenReader === 'function') {
|
|
1354
|
+
var tabName = tpage.label || tpage.key;
|
|
1355
|
+
announceToScreenReader(tabName + ' tab selected');
|
|
1356
|
+
}
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
|
|
1361
|
+
|
|
1362
|
+
/**
|
|
1363
|
+
* Registers all Mojo base components with the customElements registry.
|
|
1364
|
+
* Should be called before using any Mojo components.
|
|
1365
|
+
* Safe to call multiple times - only registers once.
|
|
1366
|
+
*
|
|
1367
|
+
* @function register_mojo_components
|
|
1368
|
+
* @returns {void}
|
|
1369
|
+
*
|
|
1370
|
+
* @example
|
|
1371
|
+
* // Register components on page load
|
|
1372
|
+
* register_mojo_components();
|
|
1373
|
+
*/
|
|
1374
|
+
function register_mojo_components() {
|
|
1375
|
+
|
|
1376
|
+
// =========================================================================
|
|
1377
|
+
// COMPONENT REGISTRATION - Dependency Chain
|
|
1378
|
+
// =========================================================================
|
|
1379
|
+
// Register icon components first because Mojo components use them
|
|
1380
|
+
// (e.g., MojoCollapsible uses icon-plus-sign and icon-minus-sign).
|
|
1381
|
+
// This ensures icons are available when Mojo components render.
|
|
1382
|
+
register_icon_components()
|
|
1383
|
+
|
|
1384
|
+
// =========================================================================
|
|
1385
|
+
// COMPONENT REGISTRATION - Idempotency Guard
|
|
1386
|
+
// =========================================================================
|
|
1387
|
+
// Use a module-scoped flag to ensure components are only registered once.
|
|
1388
|
+
// Calling customElements.define() twice with the same tag name throws an
|
|
1389
|
+
// error, so this guard prevents crashes if register is called multiple times.
|
|
1390
|
+
if (!mojoComponentsRegistered) {
|
|
1391
|
+
mojoComponentsRegistered = true;
|
|
1392
|
+
|
|
1393
|
+
// =====================================================================
|
|
1394
|
+
// COMPONENT REGISTRATION - Custom Element Definition
|
|
1395
|
+
// =====================================================================
|
|
1396
|
+
// customElements.define() associates a tag name with a class.
|
|
1397
|
+
// After registration, the browser will:
|
|
1398
|
+
// 1. Upgrade existing elements with that tag name
|
|
1399
|
+
// 2. Create instances of the class for new elements
|
|
1400
|
+
// 3. Call the constructor when elements are created
|
|
1401
|
+
//
|
|
1402
|
+
// Tag names MUST contain a hyphen (e.g., "mojo-collapsible") to
|
|
1403
|
+
// distinguish them from standard HTML elements.
|
|
1404
|
+
customElements.define(MojoCollapsible.tagname, MojoCollapsible);
|
|
1405
|
+
customElements.define(MojoCollapsibleLvl2.tagname, MojoCollapsibleLvl2);
|
|
1406
|
+
customElements.define(MojoCollapsibleLvl3.tagname, MojoCollapsibleLvl3);
|
|
1407
|
+
customElements.define(MojoIconTarget.tagname, MojoIconTarget);
|
|
1408
|
+
customElements.define(MojoProjectTimeline.tagname, MojoProjectTimeline);
|
|
1409
|
+
customElements.define(MojoPropertySingle.tagname, MojoPropertySingle);
|
|
1410
|
+
customElements.define(MojoPropertyTable.tagname, MojoPropertyTable);
|
|
1411
|
+
customElements.define(MojoTabSet.tagname, MojoTabSet);
|
|
1412
|
+
customElements.define(MojoTabContent.tagname, MojoTabContent);
|
|
1413
|
+
customElements.define(MojoTabLabel.tagname, MojoTabLabel);
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
}
|
|
1417
|
+
|