@openmrs/esm-patient-common-lib 12.3.5-pre.12608 → 12.3.5-pre.12622

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-patient-common-lib",
3
- "version": "12.3.5-pre.12608",
3
+ "version": "12.3.5-pre.12622",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Library for common patient chart components",
6
6
  "browser": "dist/openmrs-esm-patient-common-lib.js",
package/src/index.ts CHANGED
@@ -19,3 +19,4 @@ export * from './useMaxAttachmentFileSize';
19
19
  export * from './useSystemVisitSetting';
20
20
  export * from './visit';
21
21
  export * from './workspaces';
22
+ export * from './workspace-back-button';
@@ -0,0 +1 @@
1
+ export * from './workspace-back-button.component';
@@ -0,0 +1,20 @@
1
+ import React, { type MouseEventHandler } from 'react';
2
+ import { Button } from '@carbon/react';
3
+ import { ArrowLeftIcon } from '@openmrs/esm-framework';
4
+ import styles from './workspace-back-button.scss';
5
+
6
+ export interface WorkspaceBackButtonProps {
7
+ label: string;
8
+ onClick: MouseEventHandler<HTMLButtonElement>;
9
+ }
10
+
11
+ export const WorkspaceBackButton: React.FC<WorkspaceBackButtonProps> = ({ label, onClick }) => {
12
+ return (
13
+ <div className={styles.backButton}>
14
+ <Button kind="ghost" size="sm" onClick={onClick}>
15
+ <ArrowLeftIcon size={16} />
16
+ <span>{label}</span>
17
+ </Button>
18
+ </div>
19
+ );
20
+ };
@@ -0,0 +1,15 @@
1
+ @use '@carbon/layout';
2
+
3
+ .backButton {
4
+ padding: layout.$spacing-03;
5
+
6
+ button {
7
+ display: flex;
8
+ margin-left: -(layout.$spacing-03);
9
+
10
+ svg {
11
+ align-self: center;
12
+ margin-right: layout.$spacing-03;
13
+ }
14
+ }
15
+ }
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import { describe, expect, it, vi } from 'vitest';
3
+ import userEvent from '@testing-library/user-event';
4
+ import { render, screen } from '@testing-library/react';
5
+ import { WorkspaceBackButton } from './workspace-back-button.component';
6
+
7
+ describe('WorkspaceBackButton', () => {
8
+ it('renders a button with the provided label and triggers onClick', async () => {
9
+ const user = userEvent.setup();
10
+ const handleClick = vi.fn();
11
+
12
+ render(<WorkspaceBackButton label="Back to order basket" onClick={handleClick} />);
13
+
14
+ const button = screen.getByRole('button', { name: /back to order basket/i });
15
+ expect(button).toBeInTheDocument();
16
+ expect(screen.getByText('Back to order basket')).toBeInTheDocument();
17
+
18
+ await user.click(button);
19
+ expect(handleClick).toHaveBeenCalledTimes(1);
20
+ });
21
+ });