@moser-inc/moser-labs-custom-elements 1.0.0 → 1.1.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.
package/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # Moser Labs Custom Elements
2
+
3
+ This package contains a collection of custom elements that can be used in any web application.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm i @moser-inc/moser-labs-custom-elements
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ For these custom elements to function properly, you must first authenticate the user with Keycloak and call the provided `authenticateCustomElements` function before registering.
14
+
15
+ ```ts
16
+ import Keycloak from 'keycloak-js';
17
+ import { authenticateCustomElements, registerCustomElements } from '@moser-inc/moser-labs-custom-elements';
18
+
19
+ const keycloak = new Keycloak('/keycloak.json');
20
+
21
+ keycloak.init({ onLoad: 'login-required' }).then((isAuthenticated) => {
22
+ if (!isAuthenticated) return;
23
+
24
+ authenticateCustomElements(keycloak);
25
+ registerCustomElements();
26
+ });
27
+ ```
28
+
29
+ For greater flexibility, you are also able to import and define each custom element individually rather than registering them all at once.
30
+
31
+ ```ts
32
+ import { LabsAppSwitcher, registerCustomElements } from '@moser-inc/moser-labs-custom-elements';
33
+
34
+ // Register all custom elements at once
35
+ registerCustomElements();
36
+
37
+ // Or register each custom element individually as needed
38
+ customElements.register('labs-app-switcher', LabsAppSwitcher);
39
+ ```