@genesislcap/foundation-header 14.408.0 → 14.409.0

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.
Files changed (66) hide show
  1. package/README.md +6 -633
  2. package/dist/custom-elements.json +230 -230
  3. package/package.json +23 -23
  4. package/docs/api/foundation-header.configure.md +0 -75
  5. package/docs/api/foundation-header.defaultheaderconfig.md +0 -13
  6. package/docs/api/foundation-header.elementtargetid.md +0 -15
  7. package/docs/api/foundation-header.foundationheader.loadremotes.md +0 -15
  8. package/docs/api/foundation-header.foundationheader.md +0 -53
  9. package/docs/api/foundation-header.headerconfig.md +0 -59
  10. package/docs/api/foundation-header.headerconfig.templateoptions.md +0 -18
  11. package/docs/api/foundation-header.headertargetid.md +0 -13
  12. package/docs/api/foundation-header.languageoptions.md +0 -16
  13. package/docs/api/foundation-header.mainstyles.md +0 -13
  14. package/docs/api/foundation-header.md +0 -246
  15. package/docs/api/foundation-header.naveventdetailmap.md +0 -23
  16. package/docs/api/foundation-header.navigation.authrouting.md +0 -11
  17. package/docs/api/foundation-header.navigation.changelanguage.md +0 -56
  18. package/docs/api/foundation-header.navigation.connectedcallback.md +0 -17
  19. package/docs/api/foundation-header.navigation.container.md +0 -11
  20. package/docs/api/foundation-header.navigation.controlpanel.md +0 -11
  21. package/docs/api/foundation-header.navigation.disconnectedcallback.md +0 -17
  22. package/docs/api/foundation-header.navigation.enableinactivitymonitoring.md +0 -18
  23. package/docs/api/foundation-header.navigation.handlenavbuttonclick.md +0 -54
  24. package/docs/api/foundation-header.navigation.hasactivechild.md +0 -56
  25. package/docs/api/foundation-header.navigation.headerconfig.md +0 -11
  26. package/docs/api/foundation-header.navigation.hidesidebar.md +0 -13
  27. package/docs/api/foundation-header.navigation.i18next.md +0 -11
  28. package/docs/api/foundation-header.navigation.inactivitytimeoutminutes.md +0 -18
  29. package/docs/api/foundation-header.navigation.inactivitywarningminutes.md +0 -18
  30. package/docs/api/foundation-header.navigation.islayoutitemactive.md +0 -56
  31. package/docs/api/foundation-header.navigation.languageoptions.md +0 -13
  32. package/docs/api/foundation-header.navigation.layoutitemcheck.md +0 -30
  33. package/docs/api/foundation-header.navigation.loginrouting.md +0 -11
  34. package/docs/api/foundation-header.navigation.logoalttext.md +0 -18
  35. package/docs/api/foundation-header.navigation.logosrc.md +0 -18
  36. package/docs/api/foundation-header.navigation.logout.md +0 -17
  37. package/docs/api/foundation-header.navigation.logoutbuttonposition.md +0 -18
  38. package/docs/api/foundation-header.navigation.luminancetoggle.md +0 -11
  39. package/docs/api/foundation-header.navigation.md +0 -793
  40. package/docs/api/foundation-header.navigation.navigateto.md +0 -58
  41. package/docs/api/foundation-header.navigation.pathname.md +0 -13
  42. package/docs/api/foundation-header.navigation.routebuttons.md +0 -24
  43. package/docs/api/foundation-header.navigation.routenavitems.md +0 -13
  44. package/docs/api/foundation-header.navigation.selecttemplate.md +0 -19
  45. package/docs/api/foundation-header.navigation.setluminance.md +0 -15
  46. package/docs/api/foundation-header.navigation.shouldshowaccountmenu.md +0 -18
  47. package/docs/api/foundation-header.navigation.showaccountmenu.md +0 -18
  48. package/docs/api/foundation-header.navigation.showaiindicator.md +0 -13
  49. package/docs/api/foundation-header.navigation.showconnectionindicator.md +0 -13
  50. package/docs/api/foundation-header.navigation.showcontrolpanel.md +0 -13
  51. package/docs/api/foundation-header.navigation.showenvironmentindicator.md +0 -13
  52. package/docs/api/foundation-header.navigation.showlanguageselector.md +0 -18
  53. package/docs/api/foundation-header.navigation.showluminancetogglebutton.md +0 -18
  54. package/docs/api/foundation-header.navigation.showmisctogglebutton.md +0 -18
  55. package/docs/api/foundation-header.navigation.shownotificationsbutton.md +0 -23
  56. package/docs/api/foundation-header.navigation.tolocalisedtext.md +0 -56
  57. package/docs/api/foundation-header.navigation.user.md +0 -11
  58. package/docs/api/foundation-header.navigation.username.md +0 -18
  59. package/docs/api/foundation-header.navtargetid.md +0 -13
  60. package/docs/api/foundation-header.navtemplate.md +0 -18
  61. package/docs/api/foundation-header.rapidheader.md +0 -69
  62. package/docs/api/foundation-header.rapidheader.selecttemplate.md +0 -15
  63. package/docs/api/foundation-header.sidenavtargetid.md +0 -13
  64. package/docs/api/foundation-header.styletargetid.md +0 -13
  65. package/docs/api/index.md +0 -30
  66. package/docs/api-report.md.api.md +0 -260
package/README.md CHANGED
@@ -1,652 +1,25 @@
1
- # Foundation Header
1
+ # @genesislcap/foundation-header
2
2
 
3
- [API](./docs/api/index.md)
3
+ Documentation for this package is published on the Genesis docs site:
4
4
 
5
- ## Introduction
5
+ **Docs: [Header](https://docs.genesis.global/docs/develop/client-capabilities/header/)**
6
6
 
7
- The Header micro front-end is a semi-batteries-included component. It consists of a navigation bar and flyout menu, with routing and account-logout capabilities.
7
+ ## Installation
8
8
 
9
- ### Customise
10
-
11
- You can customise:
12
-
13
- - the icon shown on the navigation bar and flyout menu (this shows the Genesis logo by default)
14
- - navigation links at the left-hand side of the navigation bar
15
- - the control buttons on the right-hand side of the navigation bar; these can be shown or hidden, and their behaviour controlled via event listeners
16
- - the contents of the flyout menu
17
-
18
- ### Examples
19
-
20
- Here is an example of the navigation bar with three navigation items, and all three control buttons shown.
21
- ![Header with the standard genesis logo](./docs/img/foundation-header-standard.png)
22
-
23
- This next example is the same as the previous example, except the Genesis logo is replaced with a custom icon.
24
- ![Header with a customised logo](./docs/img/foundation-header-replaced-img.png)
25
-
26
- In this next example, we have put a set of example options set in the flyout menu.
27
- ![The sidebar included with the header opened with some example content](./docs/img/foundation-header-sidebar.png)
28
-
29
- ## Header set-up
30
-
31
- A lot of the Genesis seed apps come with the Header set up by default. To verify, you can do a text search in the client code for the `<rapid-header>` tag.
32
-
33
- ### Icon
34
-
35
- By default, the navigation bar and flyout menu show the Genesis logo. You can override this by setting the `logoSrc` attribute. For example:
36
-
37
- ```html
38
- <rapid-header logoSrc="https://icotar.com/avatar/genesis"></rapid-header>
39
- ```
40
-
41
- The `logoSrc` defines the image that you want to display. Adding this attribute updates the logo on both the flyout and navigation bar. If you want to keep the Genesis logo, just omit this attribute.
42
-
43
- ### Navigation items
44
-
45
- You can add navigation items to the left-hand side of the navigation bar. For each element, you can set `slot="routes"` attribute, so that navigation is controlled via a `@click` event. The following is a really basic example for adding a 'Home' button:
46
-
47
- ```javascript
48
- html`
49
- <rapid-header>
50
- <rapid-button
51
- slot="routes"
52
- value="1"
53
- @click=${(x, c) => c.parent.navigation.navigateTo("home")}
54
- >Home</rapid-button>
55
- </rapid-header>`;
56
- ```
57
-
58
- The `navigation` object referenced via the `parent` object is why the `navigation` object is added as an attribute to the `router` in the [setup step](#header-set-up). From it, the `navigateTo` method can be called, which allows the user to navigate around the finished application from the navigation buttons.
59
-
60
- Moving on from this basic example, a dynamic set of routes can be configured, using the `repeat` directive from `@genesislcap/web-core`.
61
-
62
- 1. Add the routes configuration into an array in the router configuration class.
63
-
64
- ```javascript
65
- export class MainRouterConfig extends RouterConfiguration<LoginSettings> {
66
-
67
- // New configuration added to existing MainRouterConfig class
68
- public allRoutes = [
69
- { index: 1, path: 'protected', title: 'Home', icon: 'home', variant: 'solid' },
70
- { index: 2, path: 'admin', title: 'Admin', icon: 'cog', variant: 'solid' },
71
- { index: 3, path: 'reporting', title: 'Reporting', variant: 'solid' },
72
- ];
73
-
74
- ...
75
- }
76
- ```
77
-
78
- 2. When setting the navigation items, use the `repeat` directive to iterate over the defined routes and create a navigation item for each one.
79
-
80
- The following example creates a button with an associated logo for each of the three defined routes:
81
-
82
- html`
83
- <rapid-header>
84
- <div slot="routes">
85
- ${repeat(
86
- (x) => x.config.allRoutes,
87
- html`
88
- <rapid-button
89
- appearance="neutral-grey"
90
- value="${(x) => x.index}"
91
- @click=${(x, c) => c.parent.navigation.navigateTo(x.path)}
92
- >
93
- <rapid-icon variant="${(x) => x.variant}" name="${(x) => x.icon}"></rapid-icon>
94
- ${(x) => x.title}
95
- </rapid-button>
96
- `
97
- )}
98
- </div>
99
- </rapid-header>`;
100
- ```
101
-
102
- ### Control buttons
103
-
104
- There are three control buttons that can be shown or hidden on the right-hand side of the navigation bar (these are hidden by default). Each one of them is a boolean attribute that can be added where the `<rapid-header>` tag is defined.
105
-
106
- | Logo | Toggle Attribute | Dispatched Event |
107
- |---------------|------------------------------|---------------------------|
108
- | Moon | show-luminance-toggle-button | luminance-icon-clicked |
109
- | Misc | show-misc-toggle-button | misc-icon-clicked |
110
- | Notifications | show-notification-button | notification-icon-clicked |
111
-
112
- Implementing the functionality of the buttons is up to the client. For example:
113
-
114
- - Define the functionality of the event callback in the class of a class which is a parent to the router.
115
-
116
- ```javascript
117
- export class MainApplication extends GenesisElement {
118
-
119
- onMiscButtonPressed() {
120
- // ... do something
121
- }
122
- //...
123
- }
124
- ```
125
-
126
- - Set the event listener in the parent html to call the defined functionality.
127
-
128
- ```javascript
129
- const MainTemplate: ViewTemplate<MainApplication> = html`
130
- <foundation-router
131
- :navigation=${(x) => x.navigation}
132
- @misc-icon-clicked=${(x) => x.onMiscButtonPressed()}
133
- >
134
- </foundation-router>
135
- `;
136
- ```
137
-
138
- ### Language Selector
139
-
140
- The rapid-header component can display a language selector if the ```show-language-selector``` attribute is set. This allows users to switch between different languages within the application.
141
-
142
- ```html
143
- <rapid-header show-language-selector></rapid-header>
144
- ```
145
-
146
- By default, the component uses the languageOptions object, which contains an availableLanguage array and a selectedLanguage property. These default options provide a list of available languages and the currently selected language.
147
-
148
- You can also pass custom language options by providing an attribute with this data. Here is an example of how to set up the rapid-header component with the show-language-selector attribute and custom language options:
149
-
150
- <rapid-header
151
- show-language-selector
152
- :languageOptions=${() => {
153
- return { availableLanguages: ['en', 'es'], selectedLanguage: 'es' };
154
- }}
155
- ></rapid-header>
156
-
157
- ### Menu contents
158
-
159
- To set the content of the flyout menu, add the content in the html within an element that has the `slot="menu-contents"` attribute.
160
- ```html
161
- <rapid-header>
162
- <div slot="menu-contents">
163
- <!-- Example markup -->
164
- <p>GROUP SLOT</p>
165
- <rapid-tree-view>
166
- <rapid-tree-item>
167
- <rapid-icon name="location-arrow"></rapid-icon>
168
- Slot Tree Item
169
- </rapid-tree-item>
170
- <rapid-tree-item>
171
- <rapid-icon name="location-arrow"></rapid-icon>
172
- Slot Tree Item
173
- </rapid-tree-item>
174
- </rapid-tree-view>
175
- <p>GROUP SLOT 2</p>
176
- <rapid-tree-view>
177
- <rapid-tree-item>
178
- <rapid-icon name="location-arrow"></rapid-icon>
179
- Slot Tree Item 2
180
- </rapid-tree-item>
181
- <rapid-tree-item>
182
- <rapid-icon name="location-arrow"></rapid-icon>
183
- Slot Tree Item 2
184
- </rapid-tree-item>
185
- </rapid-tree-view>
186
- </div>
187
- </rapid-header>
188
- ```
189
-
190
- :::tip
191
- The `allRoutes` array, which you need to change to set the navigation buttons on the Header, is found in **client/web/src/routes/config.ts**.
192
- :::
193
-
194
- ## Manual Header set-up
195
-
196
- If the rapid-header component has not been implemented in your project, follow the steps below to add this micro front-end to your application.
197
-
198
- 1. Add `@genesislcap/foundation-header` as a dependency in your **package.json** file. Whenever you change the dependencies of your project, ensure you run the bootstrap command again. There is more information in the [package.json basics](https://learn.genesis.global/secure/web/basics/package-json-basics/) page.
9
+ Add the package to your `package.json` dependencies. After changing dependencies, run `npm run bootstrap` (or your project's equivalent). See [package.json basics](https://learn.genesis.global/secure/web/basics/package-json-basics/) for more information.
199
10
 
200
11
  ```json
201
12
  {
202
- ...
203
13
  "dependencies": {
204
14
  "@genesislcap/foundation-header": "latest"
205
- },
206
- ...
207
- }
208
- ```
209
-
210
- :::note
211
- This page assumes you're already using the Login and Routing systems that are part of `foundation-ui` for the logout and routing functionality.
212
-
213
- It is possible for you to set up routing manually, but that won't be covered in this tutorial.
214
- :::
215
-
216
- 2. In the top-level class of your application, import the Navigation class and inject it as a dependency.
217
-
218
- ```javascript {1,6}
219
- import { GenesisElement, customElement, inject } from '@genesislcap/web-core';
220
- import { Navigation } from '@genesislcap/foundation-header';
221
-
222
- @customElement({ name, template, styles })
223
- export class MainApplication extends GenesisElement {
224
- @inject(MainRouterConfig) config!: MainRouterConfig;
225
- @inject(Navigation) navigation!: Navigation;
226
-
227
- //...
228
-
229
- }
230
- ```
231
-
232
- :::tip
233
- If you haven't used the `inject` annotation in your application yet, you'll need to get it from the `@genesislcap/web-core` package.
234
- :::
235
-
236
- 3. Set a reference to the `navigation` object on the foundation-router when you instantiate it; this enables you to set up navigation functionality from the navigation bar in the [navigation items step](#navigation-items).
237
-
238
- ```javascript
239
- const MainTemplate: ViewTemplate<MainApplication> = html`
240
- <foundation-router :navigation=${(x) => x.navigation}></foundation-router>
241
- `;
242
- ```
243
-
244
- 4. Add the `rapid-header` tag as part of the html that you set as the markup for the `defaultLayout` in your router configuration.
245
-
246
- ```javascript {3}
247
- export const defaultLayout = new GenesisElementLayout(html`
248
- <div class="container">
249
- <!-- show-luminance-toggle-button boolean attribute added to show that button on the navigation bar -->
250
- <rapid-header show-luminance-toggle-button></rapid-header>
251
- <!-- Other markup -->
252
- </div>`);
253
-
254
- export class MainRouterConfig extends RouterConfiguration<LoginSettings> {
255
- //...
256
-
257
- public configure() {
258
- this.title = 'Example app';
259
- this.defaultLayout = defaultLayout;
260
- //...
261
15
  }
262
16
  }
263
17
  ```
264
18
 
265
- ## Inactivity Monitoring
266
-
267
- The `foundation-header` component supports configurable inactivity monitoring through attributes.
268
-
269
- ### Configuration Attributes
270
-
271
- #### `inactivity-timeout-minutes`
272
- - **Type**: Number
273
- - **Default**: 30
274
- - **Description**: Sets the inactivity timeout in minutes before automatic logout
275
-
276
- #### `inactivity-warning-minutes`
277
- - **Type**: Number
278
- - **Default**: 5
279
- - **Description**: Sets the inactivity warning time in minutes before timeout
280
-
281
- #### `enable-inactivity-monitoring`
282
- - **Type**: Boolean
283
- - **Default**: `true`
284
- - **Description**: Controls whether inactivity monitoring is enabled
285
-
286
- ### Usage Examples
287
-
288
- #### Basic Configuration
289
- ```html
290
- <foundation-header
291
- inactivity-timeout-minutes="20"
292
- inactivity-warning-minutes="3"
293
- ></foundation-header>
294
- ```
295
-
296
- #### Short Session (15 minutes timeout, 2 minutes warning)
297
- ```html
298
- <foundation-header
299
- inactivity-timeout-minutes="15"
300
- inactivity-warning-minutes="2"
301
- ></foundation-header>
302
- ```
303
-
304
- #### Long Session (60 minutes timeout, 10 minutes warning)
305
- ```html
306
- <foundation-header
307
- inactivity-timeout-minutes="60"
308
- inactivity-warning-minutes="10"
309
- ></foundation-header>
310
- ```
311
-
312
- #### Default Configuration (30 minutes timeout, 5 minutes warning)
313
- ```html
314
- <foundation-header></foundation-header>
315
- ```
316
-
317
- #### Enable Inactivity Monitoring (Default)
318
- ```html
319
- <foundation-header></foundation-header>
320
- ```
321
-
322
- #### Enable Inactivity Monitoring (Explicit)
323
- ```html
324
- <foundation-header enable-inactivity-monitoring></foundation-header>
325
- ```
326
-
327
- #### Disable Inactivity Monitoring
328
- ```html
329
- <foundation-header enable-inactivity-monitoring="false"></foundation-header>
330
- ```
331
-
332
- #### Complete Configuration with Enable/Disable
333
- ```html
334
- <!-- Enabled with custom timeout -->
335
- <foundation-header
336
- enable-inactivity-monitoring
337
- inactivity-timeout-minutes="20"
338
- inactivity-warning-minutes="3"
339
- ></foundation-header>
340
-
341
- <!-- Disabled (other attributes ignored) -->
342
- <foundation-header
343
- enable-inactivity-monitoring="false"
344
- inactivity-timeout-minutes="30"
345
- inactivity-warning-minutes="5"
346
- ></foundation-header>
347
- ```
348
-
349
- ### Behavior
350
-
351
- #### When Enabled (Default)
352
- - InactivityManager is created and started
353
- - User activity is monitored
354
- - Warning dialog appears before timeout
355
- - Automatic logout occurs on timeout
356
- - Debug log: "Inactivity manager initialized and started..."
357
-
358
- #### When Disabled
359
- - No InactivityManager is created
360
- - No activity monitoring occurs
361
- - No warning dialogs or timeouts
362
- - Debug log: "Inactivity monitoring is disabled"
363
-
364
- ### Event Handling
365
-
366
- The component automatically emits events based on the configured timeout and warning settings:
367
-
368
- ```html
369
- <foundation-header
370
- id="app-header"
371
- inactivity-timeout-minutes="20"
372
- inactivity-warning-minutes="3"
373
- ></foundation-header>
374
-
375
- <script>
376
- const header = document.getElementById('app-header');
377
-
378
- // Warning will be triggered 3 minutes before timeout (at 17 minutes of inactivity)
379
- header.addEventListener('inactivity-warning', (event) => {
380
- const remainingSeconds = event.detail.remainingSeconds;
381
- console.log(`Warning: Session will expire in ${remainingSeconds} seconds`);
382
- });
383
-
384
- // Timeout will be triggered after 20 minutes of inactivity
385
- header.addEventListener('inactivity-timeout', () => {
386
- console.log('Session expired due to inactivity');
387
- });
388
-
389
- // Reset is triggered whenever user activity is detected
390
- header.addEventListener('inactivity-reset', () => {
391
- console.log('User activity detected - timer reset');
392
- });
393
- </script>
394
- ```
395
-
396
- ### Configuration Guidelines
397
-
398
- #### Recommended Settings
399
-
400
- | Use Case | Timeout | Warning | Description |
401
- |----------|---------|---------|-------------|
402
- | **High Security** | 15-20 min | 2-3 min | Banking, healthcare, sensitive data |
403
- | **Standard** | 30 min | 5 min | General business applications |
404
- | **Long Sessions** | 60 min | 10 min | Creative work, analysis tools |
405
- | **Development** | 120 min | 15 min | Development environments |
406
-
407
- #### Best Practices
408
-
409
- 1. **Warning Time**: Should be 10-20% of the timeout time
410
- 2. **Minimum Values**: Don't set timeout below 10 minutes or warning below 1 minute
411
- 3. **User Experience**: Consider the user's workflow when setting these values
412
- 4. **Security Requirements**: Align with your organization's security policies
413
-
414
- ### Use Cases
415
-
416
- #### Development/Testing
417
- ```html
418
- <!-- Disable during development -->
419
- <foundation-header enable-inactivity-monitoring="false"></foundation-header>
420
- ```
421
-
422
- #### Production with Monitoring
423
- ```html
424
- <!-- Enable with appropriate timeout for production -->
425
- <foundation-header
426
- enable-inactivity-monitoring
427
- inactivity-timeout-minutes="30"
428
- inactivity-warning-minutes="5"
429
- ></foundation-header>
430
- ```
431
-
432
- #### Conditional Monitoring
433
- ```javascript
434
- const header = document.querySelector('foundation-header');
435
-
436
- // Enable monitoring for admin users
437
- if (userRole === 'admin') {
438
- header.setAttribute('enable-inactivity-monitoring', 'true');
439
- } else {
440
- header.setAttribute('enable-inactivity-monitoring', 'false');
441
- }
442
- ```
443
-
444
- ### Dynamic Configuration
445
-
446
- You can also set these attributes programmatically:
447
-
448
- ```javascript
449
- const header = document.querySelector('foundation-header');
450
-
451
- // Set timeout to 45 minutes
452
- header.setAttribute('inactivity-timeout-minutes', '45');
453
-
454
- // Set warning to 5 minutes
455
- header.setAttribute('inactivity-warning-minutes', '5');
456
-
457
- // Disable monitoring
458
- header.setAttribute('enable-inactivity-monitoring', 'false');
459
-
460
- // Enable monitoring
461
- header.setAttribute('enable-inactivity-monitoring', 'true');
462
-
463
- // Check current state
464
- const isEnabled = header.hasAttribute('enable-inactivity-monitoring') &&
465
- header.getAttribute('enable-inactivity-monitoring') !== 'false';
466
- ```
467
-
468
- ### Integration with Authentication
469
-
470
- The inactivity monitoring integrates seamlessly with the existing authentication system:
471
-
472
- ```html
473
- <foundation-header
474
- inactivity-timeout-minutes="30"
475
- inactivity-warning-minutes="5"
476
- ></foundation-header>
477
-
478
- <script>
479
- const header = document.querySelector('foundation-header');
480
-
481
- // Handle logout when timeout occurs
482
- header.addEventListener('logout-clicked', () => {
483
- // Clear session data
484
- sessionStorage.clear();
485
- localStorage.removeItem('auth-token');
486
-
487
- // Redirect to login page
488
- window.location.href = '/login';
489
- });
490
- </script>
491
- ```
492
-
493
- ### Complete Example
494
-
495
- ```html
496
- <!DOCTYPE html>
497
- <html>
498
- <head>
499
- <title>Foundation Header with Inactivity Monitoring</title>
500
- </head>
501
- <body>
502
- <foundation-header
503
- id="app-header"
504
- enable-inactivity-monitoring
505
- inactivity-timeout-minutes="25"
506
- inactivity-warning-minutes="4"
507
- show-connection-indicator
508
- show-language-selector
509
- ></foundation-header>
510
-
511
- <div id="inactivity-notification" style="display: none; position: fixed; top: 20px; right: 20px; background: #ff9800; color: white; padding: 16px; border-radius: 4px; z-index: 1000;">
512
- <div id="notification-text"></div>
513
- <button onclick="extendSession()" style="margin-top: 8px; padding: 4px 8px;">Continue Session</button>
514
- </div>
515
-
516
- <!-- Control buttons -->
517
- <div style="margin: 20px;">
518
- <button onclick="enableMonitoring()">Enable Monitoring</button>
519
- <button onclick="disableMonitoring()">Disable Monitoring</button>
520
- <button onclick="checkStatus()">Check Status</button>
521
- </div>
522
-
523
- <script type="module">
524
- import { foundationHeader } from '@genesislcap/foundation-header';
525
-
526
- const header = document.getElementById('app-header');
527
- const notification = document.getElementById('inactivity-notification');
528
- const notificationText = document.getElementById('notification-text');
529
-
530
- header.addEventListener('inactivity-warning', (event) => {
531
- const remainingSeconds = event.detail.remainingSeconds;
532
- notificationText.textContent = `Your session will expire in ${remainingSeconds} seconds.`;
533
- notification.style.display = 'block';
534
- });
535
-
536
- header.addEventListener('inactivity-reset', () => {
537
- notification.style.display = 'none';
538
- });
539
-
540
- header.addEventListener('logout-clicked', () => {
541
- alert('Session expired. You will be redirected to the login page.');
542
- window.location.href = '/login';
543
- });
544
-
545
- function extendSession() {
546
- // Trigger user activity to reset the timer
547
- document.body.click();
548
- }
549
-
550
- function enableMonitoring() {
551
- header.setAttribute('enable-inactivity-monitoring', 'true');
552
- console.log('Inactivity monitoring enabled');
553
- }
554
-
555
- function disableMonitoring() {
556
- header.setAttribute('enable-inactivity-monitoring', 'false');
557
- console.log('Inactivity monitoring disabled');
558
- }
559
-
560
- function checkStatus() {
561
- const isEnabled = header.hasAttribute('enable-inactivity-monitoring') &&
562
- header.getAttribute('enable-inactivity-monitoring') !== 'false';
563
- console.log('Inactivity monitoring is:', isEnabled ? 'enabled' : 'disabled');
564
- }
565
-
566
- // Check initial status
567
- checkStatus();
568
- </script>
569
- </body>
570
- </html>
571
- ```
572
-
573
- ### Notes
574
-
575
- - When disabled, the InactivityManager is not created, saving memory and CPU
576
- - The enable/disable state is checked only during initialization
577
- - Changing the attribute after the component is created requires reconnecting the component to take effect
578
- - All other inactivity-related attributes are ignored when monitoring is disabled
579
-
580
- ## DOM API
581
-
582
- Property and attribute binding examples for foundation-header micro-frontend.
583
-
584
- ### Attributes
585
-
586
- | Attribute | Type | Use | Example |
587
- |---|---|---|---|
588
- | logo-src | `any` | Optional attribute which sets the source of the image in the navigation bar and flyout menu. The Genesis logo will be shown if this attribute is not provided. | `<foundation-header logo-src="path/to/logo.png">` |
589
- | logo-alt-text | `string` | Optional attribute which controls the alt text of the logo. If this attribute is not set then the alt text is set to 'Corporate Logo'. | `<foundation-header logo-alt-text="My Logo">` |
590
- | show-luminance-toggle-button | `boolean` | Boolean attribute which controls whether the navigation bar will display the luminance toggle icon. | `<foundation-header show-luminance-toggle-button>` |
591
- | show-misc-toggle-button | `boolean` | Boolean attribute which controls whether the navigation bar will display the miscellaneous behaviour icon. | `<foundation-header show-misc-toggle-button>` |
592
- | show-notification-button | `boolean` | Boolean attribute which controls whether the navigation bar will display the show notification icon. | `<foundation-header show-notification-button>` |
593
- | show-connection-indicator | `boolean` | Boolean attribute which controls whether the navigation bar will display the connection indicator. | `<foundation-header show-connection-indicator>` |
594
- | show-language-selector | `boolean` | Boolean attribute which controls whether the navigation bar will display the language selector. | `<foundation-header show-language-selector>` |
595
- | hide-side-bar | `boolean` | Boolean attribute which controls whether the navigation bar will display the side bar. | `<foundation-header hide-side-bar>` |
596
- | inactivity-timeout-minutes | `number` | Number attribute which sets the inactivity timeout in minutes (default: 30). | `<foundation-header inactivity-timeout-minutes="20">` |
597
- | inactivity-warning-minutes | `number` | Number attribute which sets the inactivity warning time in minutes (default: 5). | `<foundation-header inactivity-warning-minutes="3">` |
598
- | enable-inactivity-monitoring | `boolean` | Boolean attribute which controls whether inactivity monitoring is enabled (default: true). | `<foundation-header enable-inactivity-monitoring="false">` |
599
-
600
- ### Properties
601
-
602
- | Property | Type | Use | Example |
603
- |---|---|---|---|
604
- | userName | `string` | Username of the logged in user. | `<foundation-header ?userName="${(x) => x.userName}">` |
605
- | languageOptions | `LanguageOptions` | Object which defines the language options to be displayed in the language selector. | `<foundation-header :languageOptions="${(x) => x.languageOptions}">` |
606
- | routeButtons | `Array` | Array of objects which define the route buttons to be displayed in the navigation bar. | `<foundation-header :routeButtons="${(x) => x.routeButtons}">` |
607
- | routeNavItems | `FoundationRouteNavItem[]` | Array of FoundationRouteNavItems which define the route buttons to be displayed in the navigation bar. | `<foundation-header :routeNavItems="${(x) => x.routeNavItems}">` |
608
-
609
- ### Slots
610
-
611
- | Slot Name | Description |
612
- |-----------------|-----------------------------------------------------------------------------|
613
- | `menu-contents` | Slot for adding custom content to the flyout menu (side navigation). |
614
- | `routes` | Slot for adding custom route buttons to the navigation bar. |
615
- | `routes-end` | Slot for adding custom route buttons to the end of the navigation bar. |
616
-
617
- ### Parts
618
-
619
- | Part Name | Description |
620
- |-----------------|-----------------------------------------------------------------------------|
621
- | `dynamic-template` | The element representing the dynamic template content. |
622
-
623
- ### Methods
624
-
625
- | Method | Description |
626
- |---|---|
627
- | `logout` | Logs the user out of their session. |
628
- | `navigateTo` | Changes the route of the current page. |
629
-
630
- ### Fired Events
631
-
632
- | Event | Type | Description | Example |
633
- |---|---|---|---|
634
- | luminance-icon-clicked | `void` | Dispatched when the user clicks on the luminance toggle icon in the navigation bar. | `<foundation-header @luminance-icon-clicked="${(x) => x.handleLuminanceIconClick}">` |
635
- | misc-icon-clicked | `void` | Dispatched when the user clicks on the miscellaneous behaviour icon in the navigation bar. | `<foundation-header @misc-icon-clicked="${(x) => x.handleMiscIconClick}">` |
636
- | notification-icon-clicked | `void` | Dispatched when the user clicks on the notification icon in the navigation bar. | `<foundation-header @notification-icon-clicked="${(x) => x.handleNotificationIconClick}">` |
637
- | language-changed | `void` | Dispatched when the user changes the language in the language selector. | `<foundation-header @language-changed="${(x) => x.handleLanguageChange}">` |
638
- | inactivity-warning | `InactivityWarningEvent` | Dispatched when the inactivity warning is triggered. | `<foundation-header @inactivity-warning="${(x) => x.handleInactivityWarning}">` |
639
- | inactivity-timeout | `void` | Dispatched when the inactivity timeout is reached. | `<foundation-header @inactivity-timeout="${(x) => x.handleInactivityTimeout}">` |
640
- | inactivity-reset | `void` | Dispatched when user activity is detected and the timer is reset. | `<foundation-header @inactivity-reset="${(x) => x.handleInactivityReset}">` |
641
- | logout-clicked | `void` | Dispatched when logout is triggered due to inactivity timeout. | `<foundation-header @logout-clicked="${(x) => x.handleLogout}">` |
642
-
643
- ## Listened Events
644
-
645
- This component doesn't listen to any events.
646
-
647
19
  ## License
648
20
 
649
21
  Note: this project provides front-end dependencies and uses licensed components listed in the next section; thus, licenses for those components are required during development. Contact [Genesis Global](https://genesis.global/contact-us/) for more details.
650
22
 
651
23
  ### Licensed components
24
+
652
25
  Genesis low-code platform