@kenyaemr/esm-version-app 5.4.6-pre.1419 → 5.4.6

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.
@@ -7,4 +7,21 @@ export const configSchema = {
7
7
  _description:
8
8
  'Path to the default facility logo (relative to SPA base), used when facility information has no logo.',
9
9
  },
10
+ supportPhoneNumber: {
11
+ _type: Type.String,
12
+ _default: '147',
13
+ _description: 'Phone number shown in the floating service support button. Leave empty to hide the button.',
14
+ },
15
+ supportButtonBackgroundColor: {
16
+ _type: Type.String,
17
+ _default: 'var(--cds-interactive, #0f62fe)',
18
+ _description:
19
+ 'Background color of the floating service support button. Accepts any CSS color value, e.g. "#da1e28" or "rgb(0, 128, 0)". Defaults to the Carbon interactive (primary) color.',
20
+ },
10
21
  };
22
+
23
+ export interface ConfigObject {
24
+ defaultLogoPath: string;
25
+ supportPhoneNumber: string;
26
+ supportButtonBackgroundColor: string;
27
+ }
package/src/index.ts CHANGED
@@ -12,6 +12,11 @@ export const importTranslations = require.context('../translations', false, /.js
12
12
 
13
13
  export const about = getAsyncLifecycle(() => import('./root.component'), options);
14
14
 
15
+ export const supportHelp = getAsyncLifecycle(() => import('./support-help/support-help.component'), {
16
+ featureName: 'support-help',
17
+ moduleName,
18
+ });
19
+
15
20
  export function startupApp() {
16
21
  defineConfigSchema(moduleName, configSchema);
17
22
  }
@@ -2,28 +2,28 @@
2
2
  // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
3
3
  /* tslint:disable */
4
4
  export const VERSION = {
5
- "dirty": true,
6
- "raw": "v5.4.5-84-g924ebcd0-dirty",
7
- "hash": "g924ebcd0",
8
- "distance": 84,
9
- "tag": "v5.4.5",
5
+ "dirty": false,
6
+ "raw": "v5.4.6-42-g35614686",
7
+ "hash": "g35614686",
8
+ "distance": 42,
9
+ "tag": "v5.4.6",
10
10
  "semver": {
11
11
  "options": {
12
12
  "loose": false,
13
13
  "includePrerelease": false
14
14
  },
15
15
  "loose": false,
16
- "raw": "v5.4.5",
16
+ "raw": "v5.4.6",
17
17
  "major": 5,
18
18
  "minor": 4,
19
- "patch": 5,
19
+ "patch": 6,
20
20
  "prerelease": [],
21
21
  "build": [],
22
- "version": "5.4.5"
22
+ "version": "5.4.6"
23
23
  },
24
- "suffix": "84-g924ebcd0-dirty",
25
- "semverString": "5.4.5+84.g924ebcd0",
26
- "version": "5.4.6-pre.1419",
27
- "buildDate": "2026-10-30T09:58:28.546Z"
24
+ "suffix": "42-g35614686",
25
+ "semverString": "5.4.6+42.g35614686",
26
+ "version": "5.4.6",
27
+ "buildDate": "2026-11-23T07:22:12.803Z"
28
28
  };
29
29
  /* tslint:enable */
package/src/routes.json CHANGED
@@ -9,6 +9,12 @@
9
9
  "route": "about",
10
10
  "online": true,
11
11
  "offline": true
12
+ },
13
+ {
14
+ "component": "supportHelp",
15
+ "route": true,
16
+ "online": true,
17
+ "offline": true
12
18
  }
13
19
  ],
14
20
  "extensions": [
@@ -0,0 +1,62 @@
1
+ import React from 'react';
2
+ import { render, screen } from '@testing-library/react';
3
+ import userEvent from '@testing-library/user-event';
4
+ import { useConfig } from '@openmrs/esm-framework';
5
+ import { beforeEach, describe, expect, it, vi } from 'vitest';
6
+ import SupportHelp from './support-help.component';
7
+
8
+ describe('SupportHelp', () => {
9
+ beforeEach(() => {
10
+ vi.mocked(useConfig).mockReturnValue({ supportPhoneNumber: '147' });
11
+ });
12
+
13
+ it('shows the service support number and toggles its expanded state', async () => {
14
+ const user = userEvent.setup();
15
+ render(<SupportHelp />);
16
+
17
+ const button = screen.getByRole('button', { name: 'Service support' });
18
+ expect(button).toHaveAttribute('aria-expanded', 'false');
19
+ expect(screen.getByRole('status')).toHaveTextContent('For service support: Dial 147');
20
+ expect(screen.getByRole('link', { name: '147' })).toHaveAttribute('href', 'tel:147');
21
+
22
+ await user.click(button);
23
+ expect(button).toHaveAttribute('aria-expanded', 'true');
24
+
25
+ await user.keyboard('{Escape}');
26
+ expect(button).toHaveAttribute('aria-expanded', 'false');
27
+ });
28
+
29
+ it('collapses when clicking outside', async () => {
30
+ const user = userEvent.setup();
31
+ render(<SupportHelp />);
32
+
33
+ const button = screen.getByRole('button', { name: 'Service support' });
34
+ await user.click(button);
35
+ expect(button).toHaveAttribute('aria-expanded', 'true');
36
+
37
+ await user.click(document.body);
38
+ expect(button).toHaveAttribute('aria-expanded', 'false');
39
+ });
40
+
41
+ it('uses the configured support phone number', () => {
42
+ vi.mocked(useConfig).mockReturnValue({ supportPhoneNumber: '0800 720 601' });
43
+ render(<SupportHelp />);
44
+
45
+ expect(screen.getByRole('status')).toHaveTextContent('For service support: Dial 0800 720 601');
46
+ expect(screen.getByRole('link', { name: '0800 720 601' })).toHaveAttribute('href', 'tel:0800720601');
47
+ });
48
+
49
+ it('renders nothing when no support phone number is configured', () => {
50
+ vi.mocked(useConfig).mockReturnValue({ supportPhoneNumber: '' });
51
+ const { container } = render(<SupportHelp />);
52
+
53
+ expect(container).toBeEmptyDOMElement();
54
+ });
55
+
56
+ it('applies the configured background color', () => {
57
+ vi.mocked(useConfig).mockReturnValue({ supportPhoneNumber: '147', supportButtonBackgroundColor: '#da1e28' });
58
+ const { container } = render(<SupportHelp />);
59
+
60
+ expect(container.firstElementChild).toHaveStyle('--support-help-background: #da1e28');
61
+ });
62
+ });
@@ -0,0 +1,84 @@
1
+ import React, { useCallback, useEffect, useRef, useState } from 'react';
2
+ import classNames from 'classnames';
3
+ import { useTranslation } from 'react-i18next';
4
+ import { Headset } from '@carbon/react/icons';
5
+ import { useConfig } from '@openmrs/esm-framework';
6
+ import { type ConfigObject } from '../config-schema';
7
+ import styles from './support-help.scss';
8
+
9
+ /**
10
+ * Its Registered as a new page in esm-version-app with "route": true.
11
+ * In @openmrs/esm-routes (src/loaders/pages.ts, getActivityFn),
12
+ * a boolean route returns () => route, so the page is mounted on every URL.
13
+ * The page wrapper (wrapPageActivityFn) only checks online/offline and
14
+ * feature flags, never authentication, so the button also shows on /login for users who aren't signed in.
15
+ * The component uses position: fixed, so it doesn't matter where the app shell places the page's container.
16
+ * @returns
17
+ */
18
+
19
+ const SupportHelp: React.FC = () => {
20
+ const { t } = useTranslation();
21
+ const { supportPhoneNumber, supportButtonBackgroundColor } = useConfig<ConfigObject>();
22
+ const phoneNumber = supportPhoneNumber?.trim();
23
+ const [isOpen, setIsOpen] = useState(false);
24
+ const containerRef = useRef<HTMLDivElement>(null);
25
+
26
+ const close = useCallback(() => setIsOpen(false), []);
27
+
28
+ useEffect(() => {
29
+ if (!isOpen) {
30
+ return;
31
+ }
32
+
33
+ const handleKeyDown = (event: KeyboardEvent) => {
34
+ if (event.key === 'Escape') {
35
+ close();
36
+ }
37
+ };
38
+ const handlePointerDown = (event: MouseEvent) => {
39
+ if (containerRef.current && !containerRef.current.contains(event.target as Node)) {
40
+ close();
41
+ }
42
+ };
43
+
44
+ document.addEventListener('keydown', handleKeyDown);
45
+ document.addEventListener('mousedown', handlePointerDown);
46
+ return () => {
47
+ document.removeEventListener('keydown', handleKeyDown);
48
+ document.removeEventListener('mousedown', handlePointerDown);
49
+ };
50
+ }, [isOpen, close]);
51
+
52
+ if (!phoneNumber) {
53
+ return null;
54
+ }
55
+
56
+ return (
57
+ <div
58
+ ref={containerRef}
59
+ className={classNames(styles.container, { [styles.expanded]: isOpen })}
60
+ style={
61
+ supportButtonBackgroundColor?.trim()
62
+ ? ({ '--support-help-background': supportButtonBackgroundColor.trim() } as React.CSSProperties)
63
+ : undefined
64
+ }>
65
+ <button
66
+ type="button"
67
+ className={styles.fab}
68
+ aria-label={t('serviceSupport', 'Service support')}
69
+ aria-expanded={isOpen}
70
+ aria-controls="kenyaemr-service-support-message"
71
+ onClick={() => setIsOpen((open) => !open)}>
72
+ <Headset size={24} />
73
+ </button>
74
+ <span id="kenyaemr-service-support-message" className={styles.message} role="status">
75
+ {t('serviceSupportMessage', 'For service support: Dial')}{' '}
76
+ <a className={styles.phone} href={`tel:${phoneNumber.replace(/\s+/g, '')}`}>
77
+ {phoneNumber}
78
+ </a>
79
+ </span>
80
+ </div>
81
+ );
82
+ };
83
+
84
+ export default SupportHelp;
@@ -0,0 +1,81 @@
1
+ @use '@carbon/styles/scss/spacing';
2
+ @use '@carbon/styles/scss/type';
3
+ @use '@carbon/styles/scss/theme';
4
+
5
+ .container {
6
+ position: fixed;
7
+ right: spacing.$spacing-07;
8
+ bottom: spacing.$spacing-07;
9
+ z-index: 9999;
10
+ display: flex;
11
+ flex-direction: row-reverse;
12
+ align-items: center;
13
+ height: 3.5rem;
14
+ border-radius: 1.75rem;
15
+ background-color: var(--support-help-background, #{theme.$interactive});
16
+ color: theme.$text-on-color;
17
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
18
+ transition: box-shadow 150ms ease-in-out;
19
+
20
+ &:hover {
21
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
22
+ }
23
+ }
24
+
25
+ .fab {
26
+ display: flex;
27
+ align-items: center;
28
+ justify-content: center;
29
+ flex-shrink: 0;
30
+ width: 3.5rem;
31
+ height: 3.5rem;
32
+ padding: 0;
33
+ border: none;
34
+ border-radius: 50%;
35
+ background: transparent;
36
+ color: inherit;
37
+ cursor: pointer;
38
+
39
+ svg {
40
+ fill: currentColor;
41
+ }
42
+
43
+ &:focus {
44
+ outline: 2px solid theme.$focus-inset;
45
+ outline-offset: -4px;
46
+ }
47
+ }
48
+
49
+ .message {
50
+ @include type.type-style('body-compact-02');
51
+ overflow: hidden;
52
+ white-space: nowrap;
53
+ max-width: 0;
54
+ opacity: 0;
55
+ padding-left: 0;
56
+ transition:
57
+ max-width 200ms ease-in-out,
58
+ opacity 200ms ease-in-out,
59
+ padding 200ms ease-in-out;
60
+ }
61
+
62
+ .container:hover .message,
63
+ .container:focus-within .message,
64
+ .expanded .message {
65
+ max-width: 20rem;
66
+ opacity: 1;
67
+ padding-left: spacing.$spacing-06;
68
+ }
69
+
70
+ .phone {
71
+ color: inherit;
72
+ font-weight: 600;
73
+ text-decoration: underline;
74
+ }
75
+
76
+ @media (prefers-reduced-motion: reduce) {
77
+ .container,
78
+ .message {
79
+ transition: none;
80
+ }
81
+ }
@@ -7,6 +7,8 @@
7
7
  "mainModuleVersion": "Main Module Version",
8
8
  "moduleName": "Module name",
9
9
  "noVersionFound": "No version found",
10
+ "serviceSupport": "Service support",
11
+ "serviceSupportMessage": "For service support: Dial",
10
12
  "spaVersion": "SPA Version",
11
13
  "systemInfo": "System Info",
12
14
  "version": "Version"
@@ -7,6 +7,8 @@
7
7
  "mainModuleVersion": "Main Module Version",
8
8
  "moduleName": "Module name",
9
9
  "noVersionFound": "No version found",
10
+ "serviceSupport": "Service support",
11
+ "serviceSupportMessage": "For service support: Dial",
10
12
  "spaVersion": "SPA Version",
11
13
  "systemInfo": "System Info",
12
14
  "version": "Version"
@@ -7,6 +7,8 @@
7
7
  "mainModuleVersion": "Version du module principal",
8
8
  "moduleName": "Nom du module",
9
9
  "noVersionFound": "Aucune version trouvée",
10
+ "serviceSupport": "Service support",
11
+ "serviceSupportMessage": "For service support: Dial",
10
12
  "spaVersion": "Version SPA",
11
13
  "systemInfo": "Informations système",
12
14
  "version": "Version"
@@ -7,6 +7,8 @@
7
7
  "mainModuleVersion": "Tafsiri ya Module",
8
8
  "moduleName": "Jina la mfumo",
9
9
  "noVersionFound": "Hakuna toleo lililopatikana",
10
+ "serviceSupport": "Service support",
11
+ "serviceSupportMessage": "For service support: Dial",
10
12
  "spaVersion": "Tafsiri ya SPA",
11
13
  "systemInfo": "Mfumo wa Info",
12
14
  "version": "Tafsiri ya Version"
package/dist/5526.js DELETED
@@ -1 +0,0 @@
1
- "use strict";(globalThis.webpackChunk_kenyaemr_esm_version_app=globalThis.webpackChunk_kenyaemr_esm_version_app||[]).push([["5526"],{54240(e,a,t){t.d(a,{aZ:()=>h});var r=t(58742),n=t(35400),l=t.n(n),s=t(31085);let h=l().forwardRef(function({children:e,size:a=16,...t},n){return l().createElement(r.A,{width:a,height:a,ref:n,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",fill:"currentColor",...t},(0,s.jsx)("path",{d:"M16,18a5,5,0,1,1,5-5A5.0057,5.0057,0,0,1,16,18Zm0-8a3,3,0,1,0,3,3A3.0033,3.0033,0,0,0,16,10Z"}),(0,s.jsx)("path",{d:"M16,30,7.5645,20.0513c-.0479-.0571-.3482-.4515-.3482-.4515A10.8888,10.8888,0,0,1,5,13a11,11,0,0,1,22,0,10.8844,10.8844,0,0,1-2.2148,6.5973l-.0015.0025s-.3.3944-.3447.4474ZM8.8125,18.395c.001.0007.2334.3082.2866.3744L16,26.9079l6.91-8.15c.0439-.0552.2783-.3649.2788-.3657A8.901,8.901,0,0,0,25,13,9,9,0,1,0,7,13a8.9054,8.9054,0,0,0,1.8125,5.395Z"}),e)})},43760(e,a,t){t.d(a,{qz:()=>h});var r=t(58742),n=t(35400),l=t.n(n),s=t(31085);let h=l().forwardRef(function({children:e,size:a=16,...t},n){return l().createElement(r.A,{width:a,height:a,ref:n,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",fill:"currentColor",...t},(0,s.jsx)("path",{d:"M14,4a7,7,0,1,1-7,7,7,7,0,0,1,7-7m0-2a9,9,0,1,0,9,9A9,9,0,0,0,14,2Z"}),(0,s.jsx)("path",{d:"M28,11a13.9563,13.9563,0,0,0-4.1051-9.8949L22.4813,2.5187A11.9944,11.9944,0,0,1,5.5568,19.5194l-.0381-.0381L4.1051,20.8949A13.9563,13.9563,0,0,0,14,25v3H10v2H20V28H16V24.84A14.0094,14.0094,0,0,0,28,11Z"}),e)})}}]);
package/dist/5526.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"5526.js","sources":["webpack://@kenyaemr/esm-version-app/../../node_modules/@carbon/icons-react/es/generated/bucket-11.js","webpack://@kenyaemr/esm-version-app/../../node_modules/@carbon/icons-react/es/generated/bucket-8.js"],"names":[],"mappings":"kNAohDA,IAAM,EAAyB,cAAgB,CAAC,SAAkB,CAAE,UAAQ,CAAE,OAAO,EAAE,CAAE,GAAG,EAAM,CAAE,CAAG,EACtG,OAAO,iBAAmB,CAAC,GAAI,CAAE,CAChC,MAAO,EACP,OAAQ,EACR,MACA,MAAO,6BACP,QAAS,YACT,KAAM,eACN,GAAG,CAAI,AACR,EAAmB,UAAI,OAAQ,CAAE,EAAG,8FAA+F,GAAoB,UAAI,OAAQ,CAAE,EAAG,yVAA0V,GAAI,EACvgB,E,+ECh9BA,IAAM,EAAsB,cAAgB,CAAC,SAAe,CAAE,UAAQ,CAAE,OAAO,EAAE,CAAE,GAAG,EAAM,CAAE,CAAG,EAChG,OAAO,iBAAmB,CAAC,GAAI,CAAE,CAChC,MAAO,EACP,OAAQ,EACR,MACA,MAAO,6BACP,QAAS,YACT,KAAM,eACN,GAAG,CAAI,AACR,EAAmB,UAAI,OAAQ,CAAE,EAAG,qEAAsE,GAAoB,UAAI,OAAQ,CAAE,EAAG,2MAA4M,GAAI,EAChW,E"}