@moser-inc/moser-labs-custom-elements 2.1.0 → 2.2.1

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 CHANGED
@@ -10,30 +10,33 @@ npm i @moser-inc/moser-labs-custom-elements
10
10
 
11
11
  ## Usage
12
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.
13
+ For these custom elements to function properly, you must first authenticate the user with Keycloak before calling the provided `registerCustomElements` function, passing the Keycloak instance to it.
14
14
 
15
15
  ```ts
16
16
  import Keycloak from 'keycloak-js';
17
- import { authenticateCustomElements, registerCustomElements } from '@moser-inc/moser-labs-custom-elements';
17
+ import { registerCustomElements } from '@moser-inc/moser-labs-custom-elements';
18
18
 
19
19
  const keycloak = new Keycloak('/keycloak.json');
20
20
 
21
21
  keycloak.init({ onLoad: 'login-required' }).then((isAuthenticated) => {
22
22
  if (!isAuthenticated) return;
23
23
 
24
- authenticateCustomElements(keycloak);
25
- registerCustomElements();
24
+ registerCustomElements({ keycloak });
26
25
  });
27
26
  ```
28
27
 
29
- For greater flexibility, you are also able to import and define each custom element individually rather than registering them all at once.
28
+ ## API
29
+
30
+ In order for the custom elements to use the correct instance for calling API endpoints and getting profile pictures, pass the `apiUri` option to `registerCustomElements`, using an environment variable for it to be dynamic between staging and production. It defaults to using `window.location.origin`.
30
31
 
31
32
  ```ts
32
- import { LabsAppSwitcher, registerCustomElements } from '@moser-inc/moser-labs-custom-elements';
33
+ registerCustomElements({ keycloak, apiUri: import.meta.env.VITE_API_URI });
34
+ ```
33
35
 
34
- // Register all custom elements at once
35
- registerCustomElements();
36
+ ## External
36
37
 
37
- // Or register each custom element individually as needed
38
- customElements.register('labs-app-switcher', LabsAppSwitcher);
38
+ When using a Vue + PrimeVue based application, a version of the package is provided that marks these dependencies as external to drastically reduce the bundle size.
39
+
40
+ ```ts
41
+ import { registerCustomElements } from '@moser-inc/moser-labs-custom-elements/external';
39
42
  ```