@openmrs/esm-styleguide 8.0.1-pre.3504 → 8.0.1-pre.3511

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-styleguide",
3
- "version": "8.0.1-pre.3504",
3
+ "version": "8.0.1-pre.3511",
4
4
  "license": "MPL-2.0",
5
5
  "description": "The styleguide for OpenMRS SPA",
6
6
  "main": "dist/openmrs-esm-styleguide.js",
@@ -97,17 +97,17 @@
97
97
  "swr": "2.x"
98
98
  },
99
99
  "devDependencies": {
100
- "@openmrs/esm-api": "8.0.1-pre.3504",
101
- "@openmrs/esm-config": "8.0.1-pre.3504",
102
- "@openmrs/esm-emr-api": "8.0.1-pre.3504",
103
- "@openmrs/esm-error-handling": "8.0.1-pre.3504",
104
- "@openmrs/esm-extensions": "8.0.1-pre.3504",
105
- "@openmrs/esm-globals": "8.0.1-pre.3504",
106
- "@openmrs/esm-navigation": "8.0.1-pre.3504",
107
- "@openmrs/esm-react-utils": "8.0.1-pre.3504",
108
- "@openmrs/esm-state": "8.0.1-pre.3504",
109
- "@openmrs/esm-translations": "8.0.1-pre.3504",
110
- "@openmrs/esm-utils": "8.0.1-pre.3504",
100
+ "@openmrs/esm-api": "8.0.1-pre.3511",
101
+ "@openmrs/esm-config": "8.0.1-pre.3511",
102
+ "@openmrs/esm-emr-api": "8.0.1-pre.3511",
103
+ "@openmrs/esm-error-handling": "8.0.1-pre.3511",
104
+ "@openmrs/esm-extensions": "8.0.1-pre.3511",
105
+ "@openmrs/esm-globals": "8.0.1-pre.3511",
106
+ "@openmrs/esm-navigation": "8.0.1-pre.3511",
107
+ "@openmrs/esm-react-utils": "8.0.1-pre.3511",
108
+ "@openmrs/esm-state": "8.0.1-pre.3511",
109
+ "@openmrs/esm-translations": "8.0.1-pre.3511",
110
+ "@openmrs/esm-utils": "8.0.1-pre.3511",
111
111
  "@rspack/cli": "^1.3.11",
112
112
  "@rspack/core": "^1.3.11",
113
113
  "@types/geopattern": "^1.2.9",
@@ -8,6 +8,7 @@ import {
8
8
  useAssignedExtensions,
9
9
  useLeftNavStore,
10
10
  } from '@openmrs/esm-react-utils';
11
+ import { getCoreTranslation } from '@openmrs/esm-translations';
11
12
  import styles from './left-nav.module.scss';
12
13
 
13
14
  /**
@@ -36,7 +37,13 @@ export const LeftNavMenu = React.forwardRef<HTMLElement, LeftNavMenuProps>((prop
36
37
 
37
38
  if (props.isChildOfHeader && slotName && navMenuItems.length > 0) {
38
39
  return (
39
- <SideNav ref={ref} expanded aria-label="Left navigation" className={styles.leftNav} {...props}>
40
+ <SideNav
41
+ aria-label={getCoreTranslation('leftNavigation', 'Left navigation')}
42
+ className={styles.leftNav}
43
+ expanded
44
+ ref={ref}
45
+ {...props}
46
+ >
40
47
  <ExtensionSlot name="global-nav-menu-slot" />
41
48
  {slotName ? (
42
49
  <RenderIfValueIsTruthy
@@ -1,7 +1,7 @@
1
- import React, { useState, useRef, useCallback, useMemo } from 'react';
2
- import { useOnVisible } from '@openmrs/esm-framework';
3
- import { useTranslation } from 'react-i18next';
1
+ import React, { useCallback, useMemo, useState } from 'react';
4
2
  import { InlineLoading, RadioButton, RadioButtonGroup, RadioButtonSkeleton, Search } from '@carbon/react';
3
+ import { getCoreTranslation } from '@openmrs/esm-translations';
4
+ import { useOnVisible } from '@openmrs/esm-framework';
5
5
  import { useLocationByUuid, useLocations } from './location-picker.resource';
6
6
  import styles from './location-picker.module.scss';
7
7
 
@@ -20,10 +20,9 @@ export const LocationPicker: React.FC<LocationPickerProps> = ({
20
20
  locationsPerRequest = 50,
21
21
  onChange,
22
22
  }) => {
23
- const { t } = useTranslation();
24
23
  const [searchTerm, setSearchTerm] = useState<string>('');
25
24
 
26
- let defaultLocation = useLocationByUuid(defaultLocationUuid).location;
25
+ const { location: defaultLocation } = useLocationByUuid(defaultLocationUuid);
27
26
 
28
27
  const {
29
28
  locations: fetchedLocations,
@@ -34,11 +33,11 @@ export const LocationPicker: React.FC<LocationPickerProps> = ({
34
33
  } = useLocations(locationTag, locationsPerRequest, searchTerm);
35
34
 
36
35
  const locations = useMemo(() => {
37
- if (defaultLocation && !searchTerm) {
36
+ if (defaultLocation && !searchTerm && defaultLocationUuid) {
38
37
  return [defaultLocation, ...fetchedLocations?.filter(({ resource }) => resource.id !== defaultLocationUuid)];
39
38
  }
40
39
  return fetchedLocations;
41
- }, [defaultLocation, fetchedLocations]);
40
+ }, [defaultLocation, fetchedLocations, defaultLocationUuid, searchTerm]);
42
41
 
43
42
  const search = (location: string) => {
44
43
  onChange();
@@ -55,14 +54,14 @@ export const LocationPicker: React.FC<LocationPickerProps> = ({
55
54
 
56
55
  const loadingIconRef = useOnVisible(loadMore);
57
56
 
58
- const reloadIndex = hasMore ? locations.length - locationsPerRequest / 2 : -1;
57
+ const reloadIndex = hasMore ? Math.max(0, Math.floor(locations.length - locationsPerRequest / 2)) : -1;
59
58
 
60
59
  return (
61
60
  <div>
62
61
  <Search
63
- labelText={t('searchForLocation', 'Search for a location')}
62
+ labelText={getCoreTranslation('searchForLocation')}
64
63
  id="search-1"
65
- placeholder={t('searchForLocation', 'Search for a location')}
64
+ placeholder={getCoreTranslation('searchForLocation')}
66
65
  onChange={(event) => search(event.target.value)}
67
66
  size="lg"
68
67
  />
@@ -81,8 +80,8 @@ export const LocationPicker: React.FC<LocationPickerProps> = ({
81
80
  {locations?.length > 0 ? (
82
81
  <RadioButtonGroup
83
82
  name="loginLocations"
84
- onChange={(ev) => {
85
- onChange(ev?.toString());
83
+ onChange={(value) => {
84
+ onChange(value?.toString());
86
85
  }}
87
86
  orientation="vertical"
88
87
  valueSelected={selectedLocationUuid}
@@ -93,20 +92,20 @@ export const LocationPicker: React.FC<LocationPickerProps> = ({
93
92
  key={entry.resource.id}
94
93
  id={entry.resource.id}
95
94
  name={entry.resource.name}
96
- labelText={<span ref={i == reloadIndex ? loadingIconRef : null}>{entry.resource.name}</span>}
95
+ labelText={<span ref={i === reloadIndex ? loadingIconRef : null}>{entry.resource.name}</span>}
97
96
  value={entry.resource.id}
98
97
  />
99
98
  ))}
100
99
  </RadioButtonGroup>
101
100
  ) : (
102
101
  <div className={styles.emptyState}>
103
- <p className={styles.locationNotFound}>{t('noResultsToDisplay', 'No results to display')}</p>
102
+ <p className={styles.locationNotFound}>{getCoreTranslation('noResultsToDisplay')}</p>
104
103
  </div>
105
104
  )}
106
105
  </div>
107
106
  {loadingNewData && (
108
107
  <div className={styles.loadingIcon}>
109
- <InlineLoading description={t('loading', 'Loading')} />
108
+ <InlineLoading description={getCoreTranslation('loading')} />
110
109
  </div>
111
110
  )}
112
111
  </>
@@ -1,5 +1,6 @@
1
1
  import React, { useState } from 'react';
2
2
  import { ActionableNotification } from '@carbon/react';
3
+ import { getCoreTranslation } from '@openmrs/esm-translations';
3
4
  /** @module @category UI */
4
5
 
5
6
  export interface ActionableNotificationProps {
@@ -49,9 +50,9 @@ export const ActionableNotificationComponent: React.FC<ActionableNotificationPro
49
50
  <ActionableNotification
50
51
  kind={(kind as ActionableNotificationType) || 'info'}
51
52
  actionButtonLabel={actionText}
52
- ariaLabel="Closes actionable notification"
53
+ ariaLabel={getCoreTranslation('closesActionableNotification', 'Closes actionable notification')}
53
54
  onActionButtonClick={handleActionClick}
54
- statusIconDescription="Actionable notification"
55
+ statusIconDescription={getCoreTranslation('actionableNotification', 'Actionable notification')}
55
56
  subtitle={subtitle}
56
57
  title={title}
57
58
  lowContrast={critical}
@@ -165,7 +165,11 @@ const Relationships: React.FC<{ patientId: string }> = ({ patientId }) => {
165
165
  <div>{r.relationshipType}</div>
166
166
  <div>
167
167
  {`${r.relativeAge ? r.relativeAge : '--'} ${
168
- r.relativeAge ? (r.relativeAge === 1 ? 'yr' : 'yrs') : ''
168
+ r.relativeAge
169
+ ? r.relativeAge === 1
170
+ ? getCoreTranslation('yearAbbreviation', 'yr')
171
+ : getCoreTranslation('yearsAbbreviation', 'yrs')
172
+ : ''
169
173
  }`}
170
174
  </div>
171
175
  </li>
@@ -3,7 +3,7 @@ import React, { useEffect, useMemo, useState } from 'react';
3
3
  import Avatar from 'react-avatar';
4
4
  import GeoPattern from 'geopattern';
5
5
  import { SkeletonIcon } from '@carbon/react';
6
- import { useTranslation } from 'react-i18next';
6
+ import { getCoreTranslation } from '@openmrs/esm-translations';
7
7
  import { usePatientPhoto } from './usePatientPhoto';
8
8
  import PlaceholderIcon from './placeholder-icon.component';
9
9
  import styles from './patient-photo.module.scss';
@@ -18,7 +18,6 @@ export interface PatientPhotoProps {
18
18
  * A component which displays the patient photo https://zeroheight.com/23a080e38/p/6663f3-patient-header. If there is no photo, it will display a generated avatar. The default size is 56px.
19
19
  */
20
20
  export function PatientPhoto({ patientUuid, patientName, alt }: PatientPhotoProps) {
21
- const { t } = useTranslation();
22
21
  const { data: photo, isLoading } = usePatientPhoto(patientUuid);
23
22
  const [validImageSrc, setValidImageSrc] = useState<string | null>(null);
24
23
  const [isValidating, setIsValidating] = useState(false);
@@ -58,9 +57,9 @@ export function PatientPhoto({ patientUuid, patientName, alt }: PatientPhotoProp
58
57
  }
59
58
 
60
59
  return validImageSrc
61
- ? t('patientPhotoAlt', 'Profile photo of {{patientName}}', { patientName })
62
- : t('patientAvatarAlt', 'Avatar for {{patientName}}', { patientName });
63
- }, [alt, validImageSrc, patientName, t]);
60
+ ? getCoreTranslation('patientPhotoAlt', 'Profile photo of {{patientName}}', { patientName })
61
+ : getCoreTranslation('patientAvatarAlt', 'Avatar for {{patientName}}', { patientName });
62
+ }, [alt, validImageSrc, patientName]);
64
63
 
65
64
  if (isLoading || isValidating) {
66
65
  return <SkeletonIcon className={styles.skeleton} data-testid="skeleton-icon" />;
@@ -69,7 +68,9 @@ export function PatientPhoto({ patientUuid, patientName, alt }: PatientPhotoProp
69
68
  if (photo?.imageSrc && !validImageSrc) {
70
69
  return (
71
70
  <PlaceholderIcon
72
- aria-label={t('patientPhotoPlaceholder', 'Photo placeholder for {{patientName}}', { patientName })}
71
+ aria-label={getCoreTranslation('patientPhotoPlaceholder', 'Photo placeholder for {{patientName}}', {
72
+ patientName,
73
+ })}
73
74
  />
74
75
  );
75
76
  }
@@ -2,6 +2,7 @@
2
2
  import React, { useCallback, useState, useEffect } from 'react';
3
3
  import classnames from 'classnames';
4
4
  import { ActionableNotification } from '@carbon/react';
5
+ import { getCoreTranslation } from '@openmrs/esm-translations';
5
6
  import styles from './snackbar.module.scss';
6
7
 
7
8
  // Design documentation for Snackbars https://zeroheight.com/23a080e38/p/683580-notifications/t/468baf
@@ -84,7 +85,7 @@ export const Snackbar: React.FC<SnackbarProps> = ({ snackbar, closeSnackbar: rem
84
85
  return (
85
86
  <ActionableNotification
86
87
  actionButtonLabel={actionText}
87
- aria-label="Close snackbar"
88
+ aria-label={getCoreTranslation('closeSnackbar', 'Close snackbar')}
88
89
  className={classnames(styles.slideIn, {
89
90
  [styles.animated]: applyAnimation,
90
91
  [styles.slideOut]: isClosing,
@@ -94,7 +95,7 @@ export const Snackbar: React.FC<SnackbarProps> = ({ snackbar, closeSnackbar: rem
94
95
  lowContrast={isLowContrast}
95
96
  onActionButtonClick={handleActionClick}
96
97
  onClose={closeSnackbar}
97
- statusIconDescription="Snackbar notification"
98
+ statusIconDescription={getCoreTranslation('snackbarNotification', 'Snackbar notification')}
98
99
  subtitle={subtitle}
99
100
  title={title}
100
101
  {...props}
@@ -2,11 +2,11 @@
2
2
  import React, { useContext } from 'react';
3
3
  import classNames from 'classnames';
4
4
  import { Button, IconButton } from '@carbon/react';
5
- import { useLayoutType } from '@openmrs/esm-react-utils';
6
5
  import { SingleSpaContext } from 'single-spa-react';
6
+ import { useLayoutType } from '@openmrs/esm-react-utils';
7
7
  import { type OpenedWindow } from '@openmrs/esm-extensions';
8
+ import { launchWorkspace2, useWorkspace2Store } from '../workspace2';
8
9
  import styles from './action-menu-button2.module.scss';
9
- import { launchWorkspace2, useWorkspace2Store, useWorkspace2Context } from '../workspace2';
10
10
 
11
11
  interface TagsProps {
12
12
  getIcon: (props: object) => JSX.Element;
@@ -1,15 +1,15 @@
1
1
  /** @module @category Workspace */
2
2
  import React from 'react';
3
+ import Parcel from 'single-spa-react/parcel';
4
+ import { IconButton } from '@carbon/react';
3
5
  import { mountRootParcel } from 'single-spa';
4
6
  import { loadLifeCycles } from '@openmrs/esm-routes';
5
- import Parcel from 'single-spa-react/parcel';
6
- import { closeWorkspaceGroup2, useWorkspace2Store } from '../workspace2';
7
- import styles from './action-menu2.module.scss';
8
- import { type WorkspaceGroupDefinition2 } from '@openmrs/esm-globals';
9
- import { CloseIcon } from '../../icons';
10
7
  import { isDesktop, useLayoutType } from '@openmrs/esm-react-utils';
11
- import { IconButton } from '@carbon/react';
8
+ import { type WorkspaceGroupDefinition2 } from '@openmrs/esm-globals';
12
9
  import { getCoreTranslation } from '@openmrs/esm-translations';
10
+ import { closeWorkspaceGroup2, useWorkspace2Store } from '../workspace2';
11
+ import { CloseIcon } from '../../icons';
12
+ import styles from './action-menu2.module.scss';
13
13
 
14
14
  export interface ActionMenuProps {
15
15
  workspaceGroup: WorkspaceGroupDefinition2;
@@ -1,10 +1,10 @@
1
1
  import React, { useEffect, useMemo, useState } from 'react';
2
+ import Parcel from 'single-spa-react/parcel';
3
+ import { mountRootParcel, type ParcelConfig } from 'single-spa';
2
4
  import { InlineLoading } from '@carbon/react';
3
5
  import { type OpenedWindow, type OpenedWorkspace, workspace2Store } from '@openmrs/esm-extensions';
4
6
  import { loadLifeCycles } from '@openmrs/esm-routes';
5
7
  import { getCoreTranslation } from '@openmrs/esm-translations';
6
- import { mountRootParcel, type ParcelConfig } from 'single-spa';
7
- import Parcel from 'single-spa-react/parcel';
8
8
  import { promptForClosingWorkspaces, useWorkspace2Store } from './workspace2';
9
9
  import { type Workspace2DefinitionProps } from './workspace2.component';
10
10
 
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
+ import classNames from 'classnames';
2
3
  import { createRoot } from 'react-dom/client';
3
4
  import { ActionMenu } from './action-menu2/action-menu2.component';
4
- import ActiveWorkspaceWindow from './active-workspace-window.component';
5
5
  import { useWorkspace2Store } from './workspace2';
6
+ import ActiveWorkspaceWindow from './active-workspace-window.component';
6
7
  import styles from './workspace-windows-and-menu.module.scss';
7
- import classNames from 'classnames';
8
8
 
9
9
  export function renderWorkspaceWindowsAndMenu(target: HTMLElement | null) {
10
10
  if (target) {
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
2
  import { ModalHeader, ModalBody, ModalFooter, Button } from '@carbon/react';
3
- import { useTranslation } from 'react-i18next';
4
3
  import { getCoreTranslation } from '@openmrs/esm-translations';
5
4
  import styles from './workspace2-close-prompt.module.scss';
6
5
 
@@ -18,8 +17,6 @@ const Workspace2ClosePromptModal: React.FC<WorkspaceUnsavedChangesModal> = ({
18
17
  onCancel,
19
18
  affectedWorkspaceTitles,
20
19
  }) => {
21
- const { t } = useTranslation();
22
-
23
20
  return (
24
21
  <>
25
22
  <ModalHeader closeModal={onCancel} title={getCoreTranslation('closeWorkspaces2PromptTitle')} />
@@ -33,10 +30,10 @@ const Workspace2ClosePromptModal: React.FC<WorkspaceUnsavedChangesModal> = ({
33
30
  </ModalBody>
34
31
  <ModalFooter>
35
32
  <Button kind="secondary" onClick={onCancel}>
36
- {t('cancel', 'Cancel')}
33
+ {getCoreTranslation('cancel', 'Cancel')}
37
34
  </Button>
38
35
  <Button kind="danger" onClick={onConfirm}>
39
- {t('discardChanges', 'Discard changes')}
36
+ {getCoreTranslation('discardChanges', 'Discard changes')}
40
37
  </Button>
41
38
  </ModalFooter>
42
39
  </>
@@ -1,13 +1,14 @@
1
1
  import React, { useEffect, type ReactNode } from 'react';
2
+ import classNames from 'classnames';
2
3
  import { Header, HeaderGlobalAction, HeaderGlobalBar, HeaderName } from '@carbon/react';
3
4
  import { DownToBottom, Maximize, Minimize } from '@carbon/react/icons';
4
5
  import { isDesktop, useLayoutType } from '@openmrs/esm-react-utils';
5
- import { getOpenedWindowIndexByWorkspace } from '@openmrs/esm-extensions';
6
6
  import { getCoreTranslation } from '@openmrs/esm-translations';
7
- import classNames from 'classnames';
7
+ import { getOpenedWindowIndexByWorkspace } from '@openmrs/esm-extensions';
8
8
  import { ArrowRightIcon, CloseIcon } from '../icons';
9
- import styles from './workspace2.module.scss';
10
9
  import { useWorkspace2Store, useWorkspace2Context } from './workspace2';
10
+ import styles from './workspace2.module.scss';
11
+
11
12
  interface Workspace2Props {
12
13
  title: string;
13
14
  children: ReactNode;