qpp-style 9.10.0 → 9.11.1

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.
@@ -79,14 +79,22 @@ const LevelOneContent = ({
79
79
  const hasAuthorizations = qpp_has_authorizations === 'true';
80
80
  const hasApmPayments = user_has_apm_payments === 'true';
81
81
  const isDevPre = qpp_is_dev_pre === 'true';
82
- const internalReviewerNames = JSON.parse(qpp_cms_internal_authorized || 'null');
82
+ const internalReviewerNames = JSON.parse(
83
+ qpp_cms_internal_authorized || 'null'
84
+ );
83
85
  const ehrAuthorized = qpp_ehr_authorized === 'true';
84
86
  const hasNonRegistryAuthorizations =
85
87
  qpp_has_non_registry_authorizations === 'true';
86
88
 
87
89
  const linkClass = isExpanded ? 'link-inline' : 'link-collapsed';
88
90
  let content = isDevPre ? levelOneContent?.devPre : levelOneContent?.default;
89
- if (internalReviewerNames) {
91
+ if (
92
+ (internalReviewerNames || []).some(
93
+ (name) =>
94
+ name === 'QPP Self-Nomination' ||
95
+ name === 'QPP Targeted Review & Exceptions'
96
+ )
97
+ ) {
90
98
  content =
91
99
  levelOneContent?.internalReviewers || defaultContent.internalReviewers;
92
100
  }
@@ -1,56 +1,55 @@
1
- import React, { useEffect, useState } from 'react';
2
- import PropTypes from 'prop-types';
3
- import MuiTabs from '@material-ui/core/Tabs';
4
-
1
+ import React, { useEffect, useState } from 'react'
2
+ import PropTypes from 'prop-types'
3
+ import MuiTabs from '@material-ui/core/Tabs'
5
4
  import TabPanel from './TabPanel'
6
5
  import LinkTab from './Tab'
7
6
 
8
7
  const isTabPanel = (child) => child?.type === TabPanel
9
8
 
10
9
  const getPanelChildren = (children) => {
11
- return React.Children.toArray(children).filter(isTabPanel);
10
+ return React.Children.toArray(children).filter(isTabPanel)
12
11
  };
13
12
 
14
13
  const Tabs = ({ children, onChange, selected, defaultSelectedId, ariaLabel }) => {
15
- const [tabList, setTabList] = useState([]);
16
- const [value, setValue] = useState(defaultSelectedId || selected);
14
+ const [value, setValue] = useState(defaultSelectedId || selected)
15
+
16
+ useEffect(() => {
17
+ if (selected) {
18
+ setValue(selected)
19
+ }
20
+ }, [selected])
21
+
22
+ if (!children) return null
17
23
 
18
24
  const handleChange = (event, newValue) => {
19
25
  if (onChange) {
20
- onChange(tabList[newValue]?.id, event);
26
+ onChange(tabList[newValue]?.id, event)
21
27
  }
22
28
  if (setValue) {
23
- setValue(tabList[newValue]?.id);
29
+ setValue(tabList[newValue]?.id)
24
30
  }
25
- };
31
+ }
26
32
 
27
33
  const renderChildren = () => {
28
34
  return React.Children.map(children, (child, index) => {
29
35
  if (isTabPanel(child)) {
30
36
  return React.cloneElement(child, { index, value: tabIndex })
31
37
  }
32
- return child;
33
- });
34
- };
38
+ return child
39
+ })
40
+ }
35
41
 
36
- useEffect(() => {
37
- const panels = getPanelChildren(children);
38
- const tabs = panels.map(
39
- (panel) => {
40
- const { id, tab, tabHref, disabled } = panel?.props || {};
41
- return { tab, tabHref, disabled, id };
42
- },
43
- );
44
- setTabList(tabs);
45
- }, []);
42
+ const panels = getPanelChildren(children)
43
+
44
+ const tabList = panels.map(
45
+ (panel) => {
46
+ const { id, tab, tabHref, disabled } = panel?.props || {}
47
+ return { tab, tabHref, disabled, id }
48
+ },
49
+ )
46
50
 
47
- useEffect(() => {
48
- if (selected) {
49
- setValue(selected);
50
- }
51
- }, [selected]);
52
-
53
- const foundIndex = tabList.findIndex(({ id }) => id === value);
51
+ const foundIndex = tabList.findIndex(({ id }) => id === value)
52
+
54
53
  const tabIndex = foundIndex >= 0 ? foundIndex : 0
55
54
 
56
55
  return (
@@ -71,16 +70,19 @@ const Tabs = ({ children, onChange, selected, defaultSelectedId, ariaLabel }) =>
71
70
  </div>
72
71
  {renderChildren()}
73
72
  </>
74
- );
75
- };
73
+ )
74
+ }
76
75
 
77
76
  Tabs.propTypes = {
78
77
  ariaLabel: PropTypes.string,
79
78
  selected: PropTypes.string,
80
79
  defaultSelectedId: PropTypes.string,
81
80
  onChange: PropTypes.func,
82
- children: PropTypes.node,
83
- };
81
+ children: PropTypes.oneOfType([
82
+ PropTypes.node,
83
+ PropTypes.array,
84
+ ])
85
+ }
84
86
 
85
87
  Tabs.defaultProps = {
86
88
  ariaLabel: 'qpp tabs',
@@ -88,6 +90,6 @@ Tabs.defaultProps = {
88
90
  defaultSelectedId: null,
89
91
  onChange: null,
90
92
  children: null,
91
- };
93
+ }
92
94
 
93
- export default Tabs;
95
+ export default Tabs