@openmrs/esm-styleguide 8.0.1-pre.3740 → 8.0.1-pre.3745

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.
@@ -1 +1 @@
1
- {"version":3,"file":"patient-banner-actions-menu.component.d.ts","sourceRoot":"","sources":["../../../src/patient-banner/actions-menu/patient-banner-actions-menu.component.tsx"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,OAAO,KAAkB,MAAM,OAAO,CAAC;AAOvC,MAAM,WAAW,6BAA6B;IAC5C,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,0BAA0B,CAAC,EAAE,MAAM,CAAC;CACrC;AAED,wBAAgB,wBAAwB,CAAC,EACvC,OAAO,EACP,WAAW,EACX,eAAe,EACf,0BAA0B,GAC3B,EAAE,6BAA6B,qBAyB/B"}
1
+ {"version":3,"file":"patient-banner-actions-menu.component.d.ts","sourceRoot":"","sources":["../../../src/patient-banner/actions-menu/patient-banner-actions-menu.component.tsx"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,OAAO,KAAyC,MAAM,OAAO,CAAC;AAQ9D,MAAM,WAAW,6BAA6B;IAC5C,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,0BAA0B,CAAC,EAAE,MAAM,CAAC;CACrC;AAED,wBAAgB,wBAAwB,CAAC,EACvC,OAAO,EACP,WAAW,EACX,eAAe,EACf,0BAA0B,GAC3B,EAAE,6BAA6B,qBAqE/B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-styleguide",
3
- "version": "8.0.1-pre.3740",
3
+ "version": "8.0.1-pre.3745",
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.3740",
102
- "@openmrs/esm-config": "8.0.1-pre.3740",
103
- "@openmrs/esm-emr-api": "8.0.1-pre.3740",
104
- "@openmrs/esm-error-handling": "8.0.1-pre.3740",
105
- "@openmrs/esm-extensions": "8.0.1-pre.3740",
106
- "@openmrs/esm-globals": "8.0.1-pre.3740",
107
- "@openmrs/esm-navigation": "8.0.1-pre.3740",
108
- "@openmrs/esm-react-utils": "8.0.1-pre.3740",
109
- "@openmrs/esm-state": "8.0.1-pre.3740",
110
- "@openmrs/esm-translations": "8.0.1-pre.3740",
111
- "@openmrs/esm-utils": "8.0.1-pre.3740",
101
+ "@openmrs/esm-api": "8.0.1-pre.3745",
102
+ "@openmrs/esm-config": "8.0.1-pre.3745",
103
+ "@openmrs/esm-emr-api": "8.0.1-pre.3745",
104
+ "@openmrs/esm-error-handling": "8.0.1-pre.3745",
105
+ "@openmrs/esm-extensions": "8.0.1-pre.3745",
106
+ "@openmrs/esm-globals": "8.0.1-pre.3745",
107
+ "@openmrs/esm-navigation": "8.0.1-pre.3745",
108
+ "@openmrs/esm-react-utils": "8.0.1-pre.3745",
109
+ "@openmrs/esm-state": "8.0.1-pre.3745",
110
+ "@openmrs/esm-translations": "8.0.1-pre.3745",
111
+ "@openmrs/esm-utils": "8.0.1-pre.3745",
112
112
  "@rspack/cli": "^1.3.11",
113
113
  "@rspack/core": "^1.3.11",
114
114
  "@types/geopattern": "^1.2.9",
@@ -1,9 +1,10 @@
1
1
  /** @module @category UI */
2
- import React, { useMemo } from 'react';
2
+ import React, { useCallback, useMemo, useState } from 'react';
3
+ import classNames from 'classnames';
3
4
  import { OverflowMenuVertical } from '@carbon/react/icons';
4
- import { ExtensionSlot, useExtensionSlot } from '@openmrs/esm-react-utils';
5
+ import { ExtensionSlot, useExtensionSlot, useLayoutType, useOnClickOutside } from '@openmrs/esm-react-utils';
5
6
  import { getCoreTranslation } from '@openmrs/esm-translations';
6
- import { CustomOverflowMenu } from '../../custom-overflow-menu/custom-overflow-menu.component';
7
+ import customOverflowMenuStyles from '../../custom-overflow-menu/custom-overflow-menu.module.scss';
7
8
  import styles from './patient-banner-actions-menu.module.scss';
8
9
 
9
10
  export interface PatientBannerActionsMenuProps {
@@ -23,26 +24,70 @@ export function PatientBannerActionsMenu({
23
24
  actionsSlotName,
24
25
  additionalActionsSlotState,
25
26
  }: PatientBannerActionsMenuProps) {
27
+ const [menuIsOpen, setMenuIsOpen] = useState(false);
26
28
  const { extensions: patientActions } = useExtensionSlot(actionsSlotName);
29
+ const isTablet = useLayoutType() === 'tablet';
30
+ const ref = useOnClickOutside<HTMLDivElement>(() => setMenuIsOpen(false), menuIsOpen);
31
+
32
+ const toggleShowMenu = useCallback(() => setMenuIsOpen((state) => !state), []);
33
+ const closeMenu = useCallback(() => setMenuIsOpen(false), []);
34
+
27
35
  const patientActionsSlotState = useMemo(
28
- () => ({ patientUuid, patient, ...additionalActionsSlotState }),
29
- [patientUuid, additionalActionsSlotState],
36
+ () => ({ patientUuid, patient, closeMenu, ...additionalActionsSlotState }),
37
+ [patientUuid, patient, closeMenu, additionalActionsSlotState],
30
38
  );
31
39
 
32
40
  return (
33
41
  <>
34
42
  {patientActions.length > 0 ? (
35
43
  <div className={styles.overflowMenuContainer}>
36
- <CustomOverflowMenu
37
- menuTitle={
38
- <>
39
- <span className={styles.actionsButtonText}>{getCoreTranslation('actions', 'Actions')}</span>{' '}
40
- <OverflowMenuVertical size={16} style={{ marginLeft: '0.5rem', fill: '#78A9FF' }} />
41
- </>
42
- }
44
+ <div
45
+ data-overflow-menu
46
+ className={classNames('cds--overflow-menu', customOverflowMenuStyles.container)}
47
+ ref={ref}
43
48
  >
44
- <ExtensionSlot name={actionsSlotName} key={actionsSlotName} state={patientActionsSlotState} />
45
- </CustomOverflowMenu>
49
+ <button
50
+ className={classNames(
51
+ 'cds--btn',
52
+ 'cds--btn--ghost',
53
+ 'cds--overflow-menu__trigger',
54
+ { 'cds--overflow-menu--open': menuIsOpen },
55
+ customOverflowMenuStyles.overflowMenuButton,
56
+ )}
57
+ aria-haspopup="true"
58
+ aria-expanded={menuIsOpen}
59
+ id="custom-actions-overflow-menu-trigger"
60
+ aria-controls="custom-actions-overflow-menu"
61
+ onClick={toggleShowMenu}
62
+ >
63
+ <span className={styles.actionsButtonText}>{getCoreTranslation('actions', 'Actions')}</span>{' '}
64
+ <OverflowMenuVertical size={16} style={{ marginLeft: '0.5rem', fill: '#78A9FF' }} />
65
+ </button>
66
+ <div
67
+ className={classNames(
68
+ 'cds--overflow-menu-options',
69
+ 'cds--overflow-menu--flip',
70
+ customOverflowMenuStyles.menu,
71
+ {
72
+ [customOverflowMenuStyles.show]: menuIsOpen,
73
+ },
74
+ )}
75
+ tabIndex={0}
76
+ data-floating-menu-direction="bottom"
77
+ role="menu"
78
+ aria-labelledby="custom-actions-overflow-menu-trigger"
79
+ id="custom-actions-overflow-menu"
80
+ >
81
+ <ul
82
+ className={classNames('cds--overflow-menu-options__content', {
83
+ 'cds--overflow-menu-options--lg': isTablet,
84
+ })}
85
+ >
86
+ <ExtensionSlot name={actionsSlotName} key={actionsSlotName} state={patientActionsSlotState} />
87
+ </ul>
88
+ <span />
89
+ </div>
90
+ </div>
46
91
  </div>
47
92
  ) : null}
48
93
  </>