@openmrs/esm-styleguide 8.0.1-pre.3592 → 8.0.1-pre.3600
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/.turbo/turbo-build.log +4 -7
- package/dist/brand.d.ts +1 -0
- package/dist/breakpoints/index.d.ts +11 -0
- package/dist/cards/card-header.component.d.ts +11 -0
- package/dist/cards/index.d.ts +1 -0
- package/dist/config-schema.d.ts +23 -0
- package/dist/custom-overflow-menu/custom-overflow-menu.component.d.ts +8 -0
- package/dist/custom-overflow-menu/index.d.ts +1 -0
- package/dist/dashboard-extension/index.d.ts +5 -2
- package/dist/datepicker/DatePickerIcon.d.ts +6 -0
- package/dist/datepicker/DatePickerInput.d.ts +11 -0
- package/dist/datepicker/MonthYear.d.ts +10 -0
- package/dist/datepicker/locale-context.d.ts +2 -0
- package/dist/datepicker/utils.d.ts +15 -0
- package/dist/empty-card/empty-card-registration.d.ts +1 -0
- package/dist/empty-card/empty-card.component.d.ts +4 -0
- package/dist/empty-card/index.d.ts +1 -1
- package/dist/error-state/error-state.component.d.ts +4 -0
- package/dist/icons/icon-registration.d.ts +1 -0
- package/dist/icons/icons.d.ts +329 -0
- package/dist/icons/index.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/internal.d.ts +0 -1
- package/dist/logo/index.d.ts +1 -0
- package/dist/openmrs-esm-styleguide.css +1 -1
- package/dist/openmrs-esm-styleguide.css.map +1 -1
- package/dist/openmrs-esm-styleguide.js +1 -1
- package/dist/openmrs-esm-styleguide.js.map +1 -1
- package/dist/pictograms/pictogram-registration.d.ts +1 -0
- package/dist/pictograms/pictograms.d.ts +64 -0
- package/dist/public.d.ts +0 -1
- package/dist/svg-utils.d.ts +1 -0
- package/dist/utils.d.ts +6 -0
- package/dist/workspaces2/workspace2-close-prompt.modal.d.ts +11 -0
- package/package.json +12 -12
- package/src/dashboard-extension/index.tsx +13 -3
- package/src/empty-card/empty-card.component.tsx +2 -2
- package/src/empty-card/index.ts +1 -1
- package/src/error-state/error-state.component.tsx +7 -6
- package/src/error-state/error-state.module.scss +0 -29
- package/src/error-state/error-state.test.tsx +2 -2
- package/src/icons/icons.tsx +3 -3
- package/src/internal.ts +0 -1
- package/src/public.ts +0 -1
- package/dist/error-card/error-card.component.d.ts +0 -11
- package/dist/error-card/index.d.ts +0 -1
- package/src/error-card/error-card.component.tsx +0 -35
- package/src/error-card/error-card.module.scss +0 -21
- package/src/error-card/error-card.test.tsx +0 -25
- package/src/error-card/index.ts +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function setupPictograms(): void;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/** @category Pictograms */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { type Argument } from 'classnames';
|
|
4
|
+
export declare const pictogramIds: readonly ["omrs-pict-appointments", "omrs-pict-assessment-1", "omrs-pict-assessment-2", "omrs-pict-blood-bank", "omrs-pict-cardiology", "omrs-pict-ct-scan", "omrs-pict-dentistry", "omrs-pict-emergency-department", "omrs-pict-facility", "omrs-pict-geriatrics", "omrs-pict-gynaecology", "omrs-pict-in-patient", "omrs-pict-laboratory", "omrs-pict-labs-2", "omrs-pict-obstetrics", "omrs-pict-patient-search", "omrs-pict-patients", "omrs-pict-payments-desk", "omrs-pict-pharmacy", "omrs-pict-pharmacy-2", "omrs-pict-registration", "omrs-pict-service-queues", "omrs-pict-stock-management", "omrs-pict-transfer", "omrs-pict-triage", "omrs-pict-x-ray"];
|
|
5
|
+
export type PictogramId = (typeof pictogramIds)[number];
|
|
6
|
+
export type PictogramProps = {
|
|
7
|
+
className?: Argument;
|
|
8
|
+
size?: number;
|
|
9
|
+
};
|
|
10
|
+
export declare const AppointmentsPictogram: React.MemoExoticComponent<React.ForwardRefExoticComponent<PictogramProps & React.RefAttributes<SVGSVGElement>>>;
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated use AppointmentsPictogram instead
|
|
13
|
+
*/
|
|
14
|
+
export declare const AppointmentsAltPictogram: React.MemoExoticComponent<React.ForwardRefExoticComponent<PictogramProps & React.RefAttributes<SVGSVGElement>>>;
|
|
15
|
+
export declare const Assessment1Pictogram: React.MemoExoticComponent<React.ForwardRefExoticComponent<PictogramProps & React.RefAttributes<SVGSVGElement>>>;
|
|
16
|
+
export declare const Assessment2Pictogram: React.MemoExoticComponent<React.ForwardRefExoticComponent<PictogramProps & React.RefAttributes<SVGSVGElement>>>;
|
|
17
|
+
export declare const BloodBankPictogram: React.MemoExoticComponent<React.ForwardRefExoticComponent<PictogramProps & React.RefAttributes<SVGSVGElement>>>;
|
|
18
|
+
export declare const CardiologyPictogram: React.MemoExoticComponent<React.ForwardRefExoticComponent<PictogramProps & React.RefAttributes<SVGSVGElement>>>;
|
|
19
|
+
export declare const CtScanPictogram: React.MemoExoticComponent<React.ForwardRefExoticComponent<PictogramProps & React.RefAttributes<SVGSVGElement>>>;
|
|
20
|
+
export declare const DentistryPictogram: React.MemoExoticComponent<React.ForwardRefExoticComponent<PictogramProps & React.RefAttributes<SVGSVGElement>>>;
|
|
21
|
+
export declare const EmergencyDepartmentPictogram: React.MemoExoticComponent<React.ForwardRefExoticComponent<PictogramProps & React.RefAttributes<SVGSVGElement>>>;
|
|
22
|
+
export declare const FacilityPictogram: React.MemoExoticComponent<React.ForwardRefExoticComponent<PictogramProps & React.RefAttributes<SVGSVGElement>>>;
|
|
23
|
+
export declare const GeriatricsPictogram: React.MemoExoticComponent<React.ForwardRefExoticComponent<PictogramProps & React.RefAttributes<SVGSVGElement>>>;
|
|
24
|
+
export declare const GynaecologyPictogram: React.MemoExoticComponent<React.ForwardRefExoticComponent<PictogramProps & React.RefAttributes<SVGSVGElement>>>;
|
|
25
|
+
export declare const InPatientPictogram: React.MemoExoticComponent<React.ForwardRefExoticComponent<PictogramProps & React.RefAttributes<SVGSVGElement>>>;
|
|
26
|
+
export declare const LaboratoryPictogram: React.MemoExoticComponent<React.ForwardRefExoticComponent<PictogramProps & React.RefAttributes<SVGSVGElement>>>;
|
|
27
|
+
export declare const Labs2Pictogram: React.MemoExoticComponent<React.ForwardRefExoticComponent<PictogramProps & React.RefAttributes<SVGSVGElement>>>;
|
|
28
|
+
export declare const ObstetricsPictogram: React.MemoExoticComponent<React.ForwardRefExoticComponent<PictogramProps & React.RefAttributes<SVGSVGElement>>>;
|
|
29
|
+
export declare const PatientSearchPictogram: React.MemoExoticComponent<React.ForwardRefExoticComponent<PictogramProps & React.RefAttributes<SVGSVGElement>>>;
|
|
30
|
+
export declare const PatientsPictogram: React.MemoExoticComponent<React.ForwardRefExoticComponent<PictogramProps & React.RefAttributes<SVGSVGElement>>>;
|
|
31
|
+
export declare const PaymentsDeskPictogram: React.MemoExoticComponent<React.ForwardRefExoticComponent<PictogramProps & React.RefAttributes<SVGSVGElement>>>;
|
|
32
|
+
export declare const PharmacyPictogram: React.MemoExoticComponent<React.ForwardRefExoticComponent<PictogramProps & React.RefAttributes<SVGSVGElement>>>;
|
|
33
|
+
export declare const Pharmacy2Pictogram: React.MemoExoticComponent<React.ForwardRefExoticComponent<PictogramProps & React.RefAttributes<SVGSVGElement>>>;
|
|
34
|
+
export declare const RegistrationPictogram: React.MemoExoticComponent<React.ForwardRefExoticComponent<PictogramProps & React.RefAttributes<SVGSVGElement>>>;
|
|
35
|
+
export declare const ServiceQueuesPictogram: React.MemoExoticComponent<React.ForwardRefExoticComponent<PictogramProps & React.RefAttributes<SVGSVGElement>>>;
|
|
36
|
+
export declare const StockManagementPictogram: React.MemoExoticComponent<React.ForwardRefExoticComponent<PictogramProps & React.RefAttributes<SVGSVGElement>>>;
|
|
37
|
+
export declare const TransferPictogram: React.MemoExoticComponent<React.ForwardRefExoticComponent<PictogramProps & React.RefAttributes<SVGSVGElement>>>;
|
|
38
|
+
export declare const TriagePictogram: React.MemoExoticComponent<React.ForwardRefExoticComponent<PictogramProps & React.RefAttributes<SVGSVGElement>>>;
|
|
39
|
+
export declare const XrayPictogram: React.MemoExoticComponent<React.ForwardRefExoticComponent<PictogramProps & React.RefAttributes<SVGSVGElement>>>;
|
|
40
|
+
export declare const HomePictogram: React.MemoExoticComponent<React.ForwardRefExoticComponent<PictogramProps & React.RefAttributes<SVGSVGElement>>>;
|
|
41
|
+
export declare const PatientListsPictogram: React.MemoExoticComponent<React.ForwardRefExoticComponent<PictogramProps & React.RefAttributes<SVGSVGElement>>>;
|
|
42
|
+
/**
|
|
43
|
+
* This is a utility component that takes an `pictogram` and render it if the sprite for the pictogram
|
|
44
|
+
* is available. The goal is to make it easier to conditionally render configuration-specified pictograms.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```tsx
|
|
48
|
+
* <MaybePictogram pictogram='omrs-icon-baby' className={styles.myPictogramStyles} />
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export declare const MaybePictogram: React.MemoExoticComponent<React.ForwardRefExoticComponent<{
|
|
52
|
+
pictogram: string;
|
|
53
|
+
fallback?: React.ReactNode;
|
|
54
|
+
} & PictogramProps & React.RefAttributes<SVGSVGElement>>>;
|
|
55
|
+
export type SvgPictogramProps = {
|
|
56
|
+
/** the id of the pictogram */
|
|
57
|
+
pictogram: PictogramId;
|
|
58
|
+
/** properties when using the pictogram */
|
|
59
|
+
pictogramProps: PictogramProps;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* This is a utility type for custom pictograms. Please maintain alphabetical order when adding new pictograms for readability.
|
|
63
|
+
*/
|
|
64
|
+
export declare const Pictogram: React.MemoExoticComponent<React.ForwardRefExoticComponent<SvgPictogramProps & React.RefAttributes<SVGSVGElement>>>;
|
package/dist/public.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function addSvg(htmlId: string, svgString: string): void;
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Array of valid values for Carbon tag's "type" attribute.
|
|
3
|
+
* Options from https://react.carbondesignsystem.com/?path=/docs/components-tag--overview
|
|
4
|
+
*/
|
|
5
|
+
export declare const carbonTagColors: readonly ["red", "magenta", "purple", "blue", "teal", "cyan", "gray", "green", "warm-gray", "cool-gray", "high-contrast", "outline"];
|
|
6
|
+
export type CarbonTagColor = (typeof carbonTagColors)[number];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface WorkspaceUnsavedChangesModal {
|
|
3
|
+
onConfirm: () => void;
|
|
4
|
+
onCancel: () => void;
|
|
5
|
+
affectedWorkspaceTitles: string[];
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* This modal is used for prompting user to confirm closing currently opened workspace.
|
|
9
|
+
*/
|
|
10
|
+
declare const Workspace2ClosePromptModal: React.FC<WorkspaceUnsavedChangesModal>;
|
|
11
|
+
export default Workspace2ClosePromptModal;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openmrs/esm-styleguide",
|
|
3
|
-
"version": "8.0.1-pre.
|
|
3
|
+
"version": "8.0.1-pre.3600",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"description": "The styleguide for OpenMRS SPA",
|
|
6
6
|
"main": "dist/openmrs-esm-styleguide.js",
|
|
@@ -98,17 +98,17 @@
|
|
|
98
98
|
"swr": "2.x"
|
|
99
99
|
},
|
|
100
100
|
"devDependencies": {
|
|
101
|
-
"@openmrs/esm-api": "8.0.1-pre.
|
|
102
|
-
"@openmrs/esm-config": "8.0.1-pre.
|
|
103
|
-
"@openmrs/esm-emr-api": "8.0.1-pre.
|
|
104
|
-
"@openmrs/esm-error-handling": "8.0.1-pre.
|
|
105
|
-
"@openmrs/esm-extensions": "8.0.1-pre.
|
|
106
|
-
"@openmrs/esm-globals": "8.0.1-pre.
|
|
107
|
-
"@openmrs/esm-navigation": "8.0.1-pre.
|
|
108
|
-
"@openmrs/esm-react-utils": "8.0.1-pre.
|
|
109
|
-
"@openmrs/esm-state": "8.0.1-pre.
|
|
110
|
-
"@openmrs/esm-translations": "8.0.1-pre.
|
|
111
|
-
"@openmrs/esm-utils": "8.0.1-pre.
|
|
101
|
+
"@openmrs/esm-api": "8.0.1-pre.3600",
|
|
102
|
+
"@openmrs/esm-config": "8.0.1-pre.3600",
|
|
103
|
+
"@openmrs/esm-emr-api": "8.0.1-pre.3600",
|
|
104
|
+
"@openmrs/esm-error-handling": "8.0.1-pre.3600",
|
|
105
|
+
"@openmrs/esm-extensions": "8.0.1-pre.3600",
|
|
106
|
+
"@openmrs/esm-globals": "8.0.1-pre.3600",
|
|
107
|
+
"@openmrs/esm-navigation": "8.0.1-pre.3600",
|
|
108
|
+
"@openmrs/esm-react-utils": "8.0.1-pre.3600",
|
|
109
|
+
"@openmrs/esm-state": "8.0.1-pre.3600",
|
|
110
|
+
"@openmrs/esm-translations": "8.0.1-pre.3600",
|
|
111
|
+
"@openmrs/esm-utils": "8.0.1-pre.3600",
|
|
112
112
|
"@rspack/cli": "^1.3.11",
|
|
113
113
|
"@rspack/core": "^1.3.11",
|
|
114
114
|
"@types/geopattern": "^1.2.9",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
|
-
import { useLocation } from 'react-router-dom';
|
|
4
|
+
import { BrowserRouter, useLocation } from 'react-router-dom';
|
|
5
5
|
import { shallowEqual } from '@openmrs/esm-utils';
|
|
6
6
|
import { ConfigurableLink, MaybeIcon } from '@openmrs/esm-framework';
|
|
7
7
|
import { type IconId } from '../icons';
|
|
@@ -10,8 +10,8 @@ import styles from './dashboard.module.scss';
|
|
|
10
10
|
export interface DashboardExtensionProps {
|
|
11
11
|
path: string;
|
|
12
12
|
title: string;
|
|
13
|
-
basePath
|
|
14
|
-
icon
|
|
13
|
+
basePath?: string;
|
|
14
|
+
icon?: IconId;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export const DashboardExtension = ({ path, title, basePath, icon }: DashboardExtensionProps) => {
|
|
@@ -49,3 +49,13 @@ export const DashboardExtension = ({ path, title, basePath, icon }: DashboardExt
|
|
|
49
49
|
</div>
|
|
50
50
|
);
|
|
51
51
|
};
|
|
52
|
+
|
|
53
|
+
export function createDashboard(props: Omit<DashboardExtensionProps, 'basePath'>) {
|
|
54
|
+
return function ({ basePath }: { basePath: string }) {
|
|
55
|
+
return (
|
|
56
|
+
<BrowserRouter>
|
|
57
|
+
<DashboardExtension basePath={basePath} {...props} />
|
|
58
|
+
</BrowserRouter>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
}
|
|
@@ -15,7 +15,7 @@ export interface EmptyCardProps {
|
|
|
15
15
|
launchForm?(): void;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
const
|
|
18
|
+
export const EmptyCardIllustration = ({ width = '64', height = '64' }) => {
|
|
19
19
|
return (
|
|
20
20
|
<svg width={width} height={height} viewBox="0 0 64 64">
|
|
21
21
|
<use href={`#omrs-empty-data-illustration`} />
|
|
@@ -34,7 +34,7 @@ export const EmptyCard: React.FC<EmptyCardProps> = (props) => {
|
|
|
34
34
|
<Layer className={styles.layer}>
|
|
35
35
|
<Tile className={styles.tile}>
|
|
36
36
|
<CardHeader title={props.headerTitle} />
|
|
37
|
-
<
|
|
37
|
+
<EmptyCardIllustration />
|
|
38
38
|
<p className={styles.content}>
|
|
39
39
|
{getCoreTranslation('emptyStateText', 'There are no {{displayText}} to display', {
|
|
40
40
|
displayText: props.displayText,
|
package/src/empty-card/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { EmptyCard, type EmptyCardProps } from './empty-card.component';
|
|
1
|
+
export { EmptyCard, EmptyCardIllustration, type EmptyCardProps } from './empty-card.component';
|
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Layer, Tile } from '@carbon/react';
|
|
3
3
|
import { getCoreTranslation } from '@openmrs/esm-translations';
|
|
4
|
-
import { useLayoutType } from '@openmrs/esm-react-utils';
|
|
5
4
|
import styles from './error-state.module.scss';
|
|
5
|
+
import { CardHeader } from '../cards';
|
|
6
6
|
|
|
7
7
|
export interface ErrorStateProps {
|
|
8
|
+
/** The error that caused this error card to be rendered. Expected to be a failed fetch result. */
|
|
8
9
|
error: any;
|
|
10
|
+
/** The title to use for this empty component. This must be a pre-translated string. */
|
|
9
11
|
headerTitle: string;
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
export const ErrorState: React.FC<ErrorStateProps> = ({ error, headerTitle }) => {
|
|
13
|
-
const isTablet = useLayoutType() === 'tablet';
|
|
14
|
-
|
|
15
15
|
return (
|
|
16
16
|
<Layer>
|
|
17
17
|
<Tile className={styles.tile}>
|
|
18
|
-
<
|
|
19
|
-
<h4>{headerTitle}</h4>
|
|
20
|
-
</div>
|
|
18
|
+
<CardHeader title={headerTitle} />
|
|
21
19
|
<p className={styles.errorMessage}>
|
|
22
20
|
{getCoreTranslation('error', 'Error')} {`${error?.response?.status}: `}
|
|
23
21
|
{error?.response?.statusText}
|
|
@@ -27,3 +25,6 @@ export const ErrorState: React.FC<ErrorStateProps> = ({ error, headerTitle }) =>
|
|
|
27
25
|
</Layer>
|
|
28
26
|
);
|
|
29
27
|
};
|
|
28
|
+
|
|
29
|
+
export const ErrorCard = ErrorState;
|
|
30
|
+
export type ErrorCardProps = ErrorStateProps;
|
|
@@ -15,35 +15,6 @@
|
|
|
15
15
|
color: $text-02;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
.desktopHeading {
|
|
19
|
-
h4 {
|
|
20
|
-
@include type.type-style('heading-compact-02');
|
|
21
|
-
color: $text-02;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.tabletHeading {
|
|
26
|
-
h4 {
|
|
27
|
-
@include type.type-style('heading-03');
|
|
28
|
-
color: $text-02;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
.desktopHeading,
|
|
33
|
-
.tabletHeading {
|
|
34
|
-
text-align: left;
|
|
35
|
-
text-transform: capitalize;
|
|
36
|
-
margin-bottom: layout.$spacing-05;
|
|
37
|
-
|
|
38
|
-
h4:after {
|
|
39
|
-
content: '';
|
|
40
|
-
display: block;
|
|
41
|
-
width: layout.$spacing-07;
|
|
42
|
-
padding-top: 0.188rem;
|
|
43
|
-
border-bottom: 0.375rem solid var(--brand-03);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
18
|
.tile {
|
|
48
19
|
text-align: center;
|
|
49
20
|
border: 1px solid $ui-03;
|
|
@@ -31,7 +31,7 @@ describe('ErrorState', () => {
|
|
|
31
31
|
|
|
32
32
|
render(<ErrorState headerTitle="test" error={{}} />);
|
|
33
33
|
// eslint-disable-next-line testing-library/no-node-access
|
|
34
|
-
expect(screen.getByRole('heading').parentElement?.getAttribute('class')).toContain('
|
|
34
|
+
expect(screen.getByRole('heading').parentElement?.getAttribute('class')).toContain('tabletHeader');
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
it('should render desktop layout when layout type is not tablet', () => {
|
|
@@ -39,7 +39,7 @@ describe('ErrorState', () => {
|
|
|
39
39
|
|
|
40
40
|
render(<ErrorState headerTitle="test" error={{}} />);
|
|
41
41
|
// eslint-disable-next-line testing-library/no-node-access
|
|
42
|
-
expect(screen.getByRole('heading').parentElement?.getAttribute('class')).toContain('
|
|
42
|
+
expect(screen.getByRole('heading').parentElement?.getAttribute('class')).toContain('desktopHeader');
|
|
43
43
|
});
|
|
44
44
|
|
|
45
45
|
it('should handle error with partial response data', () => {
|
package/src/icons/icons.tsx
CHANGED
|
@@ -862,18 +862,18 @@ export const ShoppingCartAddItemIcon = ShoppingCartArrowDownIcon;
|
|
|
862
862
|
* ```
|
|
863
863
|
*/
|
|
864
864
|
export const MaybeIcon = memo(
|
|
865
|
-
forwardRef<SVGSVGElement, { icon: string; fallback?: React.ReactNode } & IconProps>(function MaybeIcon(
|
|
865
|
+
forwardRef<SVGSVGElement, { icon: string | undefined; fallback?: React.ReactNode } & IconProps>(function MaybeIcon(
|
|
866
866
|
{ icon, fallback, ...iconProps },
|
|
867
867
|
ref,
|
|
868
868
|
) {
|
|
869
|
-
const iconRef = useRef(document.getElementById(icon));
|
|
869
|
+
const iconRef = useRef(icon ? document.getElementById(icon) : undefined);
|
|
870
870
|
|
|
871
871
|
useEffect(() => {
|
|
872
872
|
const container = document.getElementById('omrs-svgs-container');
|
|
873
873
|
const callback: MutationCallback = (mutationList) => {
|
|
874
874
|
for (const mutation of mutationList) {
|
|
875
875
|
if (mutation.type === 'childList') {
|
|
876
|
-
iconRef.current = document.getElementById(icon);
|
|
876
|
+
iconRef.current = icon ? document.getElementById(icon) : undefined;
|
|
877
877
|
}
|
|
878
878
|
}
|
|
879
879
|
};
|
package/src/internal.ts
CHANGED
|
@@ -6,7 +6,6 @@ export * from './dashboard-extension';
|
|
|
6
6
|
export * from './datepicker';
|
|
7
7
|
export * from './diagnosis-tags';
|
|
8
8
|
export * from './empty-card';
|
|
9
|
-
export * from './error-card';
|
|
10
9
|
export * from './error-state';
|
|
11
10
|
export * from './icons/icons';
|
|
12
11
|
export * from './left-nav';
|
package/src/public.ts
CHANGED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export interface ErrorCardProps {
|
|
3
|
-
/** This is the error that triggered rendering the card. It is expected to be the error returned from `openmrsFetch()` */
|
|
4
|
-
error: any;
|
|
5
|
-
/** The title for this card. This must be a pre-translated string. */
|
|
6
|
-
headerTitle: string;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Re-usable card for displaying a fetch error
|
|
10
|
-
*/
|
|
11
|
-
export declare const ErrorCard: React.FC<ErrorCardProps>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { ErrorCard, type ErrorCardProps } from './error-card.component';
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Layer, Tile } from '@carbon/react';
|
|
3
|
-
import { getCoreTranslation } from '@openmrs/esm-translations';
|
|
4
|
-
import { CardHeader } from '../cards';
|
|
5
|
-
import styles from './error-card.module.scss';
|
|
6
|
-
|
|
7
|
-
export interface ErrorCardProps {
|
|
8
|
-
/** This is the error that triggered rendering the card. It is expected to be the error returned from `openmrsFetch()` */
|
|
9
|
-
error: any;
|
|
10
|
-
/** The title for this card. This must be a pre-translated string. */
|
|
11
|
-
headerTitle: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Re-usable card for displaying a fetch error
|
|
16
|
-
*/
|
|
17
|
-
export const ErrorCard: React.FC<ErrorCardProps> = ({ error, headerTitle }) => {
|
|
18
|
-
return (
|
|
19
|
-
<Layer>
|
|
20
|
-
<Tile className={styles.tile}>
|
|
21
|
-
<CardHeader title={headerTitle} />
|
|
22
|
-
<p className={styles.errorMessage}>
|
|
23
|
-
{getCoreTranslation('error', 'Error')} {`${error?.response?.status}: `}
|
|
24
|
-
{error?.response?.statusText}
|
|
25
|
-
</p>
|
|
26
|
-
<p className={styles.errorCopy}>
|
|
27
|
-
{getCoreTranslation(
|
|
28
|
-
'errorCopy',
|
|
29
|
-
'Sorry, there was a problem displaying this information. You can try to reload this page, or contact the site administrator and quote the error code above.',
|
|
30
|
-
)}
|
|
31
|
-
</p>
|
|
32
|
-
</Tile>
|
|
33
|
-
</Layer>
|
|
34
|
-
);
|
|
35
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
@use '@carbon/layout';
|
|
2
|
-
@use '@carbon/type';
|
|
3
|
-
@use '@openmrs/esm-styleguide/src/vars' as *;
|
|
4
|
-
|
|
5
|
-
.errorMessage {
|
|
6
|
-
@include type.type-style('heading-compact-02');
|
|
7
|
-
|
|
8
|
-
margin-top: 2.25rem;
|
|
9
|
-
margin-bottom: layout.$spacing-03;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.errorCopy {
|
|
13
|
-
margin-bottom: layout.$spacing-03;
|
|
14
|
-
@include type.type-style('body-01');
|
|
15
|
-
color: $text-02;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.tile {
|
|
19
|
-
text-align: center;
|
|
20
|
-
border: 1px solid $ui-03;
|
|
21
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { describe, expect, it } from 'vitest';
|
|
3
|
-
import '@testing-library/jest-dom/vitest';
|
|
4
|
-
import { render, screen } from '@testing-library/react';
|
|
5
|
-
import { ErrorCard } from './error-card.component';
|
|
6
|
-
|
|
7
|
-
describe('ErrorCard', () => {
|
|
8
|
-
it('renders an error state widget card', () => {
|
|
9
|
-
const testError = {
|
|
10
|
-
response: {
|
|
11
|
-
status: 500,
|
|
12
|
-
statusText: 'Internal Server Error',
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
render(<ErrorCard headerTitle="appointments" error={testError} />);
|
|
16
|
-
|
|
17
|
-
expect(screen.getByRole('heading', { name: /appointments/i })).toBeInTheDocument();
|
|
18
|
-
expect(screen.getByText(/Error 500: Internal Server Error/i)).toBeInTheDocument();
|
|
19
|
-
expect(
|
|
20
|
-
screen.getByText(
|
|
21
|
-
/Sorry, there was a problem displaying this information. You can try to reload this page, or contact the site administrator and quote the error code above./i,
|
|
22
|
-
),
|
|
23
|
-
).toBeInTheDocument();
|
|
24
|
-
});
|
|
25
|
-
});
|
package/src/error-card/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { ErrorCard, type ErrorCardProps } from './error-card.component';
|