qpp-style 9.41.0 → 9.41.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.
@@ -0,0 +1,186 @@
1
+ import React from "react";
2
+ import PropTypes from "prop-types";
3
+
4
+ import {
5
+ NavLinkContainer,
6
+ NavLinkInline,
7
+ NavLinkDrawer,
8
+ } from "../Links";
9
+ import AnimationGroup from "../AnimationGroup/AnimationGroup";
10
+ import { PracticeDetails, IndividualDetails } from "../Details";
11
+ import SanitizedContent from "../../SanitizedContent";
12
+ import * as SvgComponents from "../../../lib/SvgComponents.jsx";
13
+ import CmsSwitchLink from "../Links/CmsSwitchLink";
14
+
15
+ const DynamicContent = ({contentItems, className, recursionId, config, isExpandedState, expand}) => {
16
+ const { openDrawersByDefault, linkActiveFunc, linkCallback } = config;
17
+ let linkClass = isExpandedState ? "link-inline" : "link-collapsed";
18
+ const containerRecursionId = recursionId ? recursionId : 0;
19
+
20
+ const getDynamicIcon = (icon) => {
21
+ const Component = SvgComponents[icon];
22
+ return Component ? <Component /> : null;
23
+ };
24
+
25
+ const hasDarkerBackground = (darkerBackground) => {
26
+ return darkerBackground ? "hr-smaller-vertical-spacing" : "";
27
+ };
28
+
29
+ const itemsMarkup = (contentItems || []).map((item, index) => {
30
+ const key = `${JSON.stringify(item)}-${index}-${containerRecursionId}`;
31
+
32
+ return (
33
+ {
34
+ divider: (
35
+ <AnimationGroup
36
+ display={isExpandedState}
37
+ key={key}
38
+ darkerBackground={item.darkerBackground}
39
+ >
40
+ <hr className={`${hasDarkerBackground(item.darkerBackground)}`} />
41
+ </AnimationGroup>
42
+ ),
43
+ container: (
44
+ <DynamicContent
45
+ contentItems={item.items}
46
+ className={item.className}
47
+ recursionId={containerRecursionId + 1}
48
+ config={config}
49
+ isExpandedState={isExpandedState}
50
+ />
51
+ ),
52
+ linkBack: (
53
+ <AnimationGroup display={isExpandedState} key={key}>
54
+ <NavLinkInline
55
+ className="link-back"
56
+ icon={getDynamicIcon("ChevronLeft")}
57
+ url={item.url}
58
+ label={item.label}
59
+ linkCallback={linkCallback}
60
+ showLabel={true}
61
+ />
62
+ </AnimationGroup>
63
+ ),
64
+ linkHome: (
65
+ <AnimationGroup display={isExpandedState} key={key}>
66
+ <NavLinkInline
67
+ className="account-home-link"
68
+ icon={getDynamicIcon(item?.icon)}
69
+ url={item.url}
70
+ label={item.label}
71
+ linkCallback={linkCallback}
72
+ showLabel={true}
73
+ />
74
+ </AnimationGroup>
75
+ ),
76
+ practiceDetails: (
77
+ <AnimationGroup
78
+ display={isExpandedState}
79
+ className={"details"}
80
+ key={key}
81
+ >
82
+ <PracticeDetails
83
+ practiceName={item.practiceName}
84
+ {...(!item.practiceTin
85
+ ? {}
86
+ : { practiceTin: item.practiceTin })}
87
+ {...(!item.apmEntityId
88
+ ? {}
89
+ : { apmEntityId: item.apmEntityId })}
90
+ {...(!item.vgId ? {} : { vgId: item.vgId })}
91
+ {...(!item.cpcPlusId ? {} : { cpcPlusId: item.cpcPlusId })}
92
+ {...(!item.pcfId ? {} : { pcfId: item.pcfId })}
93
+ {...(!item.subgroupId ? {} : { subgroupId: item.subgroupId })}
94
+ />
95
+ </AnimationGroup>
96
+ ),
97
+ individualDetails: (
98
+ <AnimationGroup display={isExpandedState} key={key}>
99
+ <IndividualDetails
100
+ individualName={item.individualName}
101
+ individualNpi={item.individualNpi}
102
+ />
103
+ </AnimationGroup>
104
+ ),
105
+ linkDrawer: (
106
+ <NavLinkDrawer
107
+ key={key}
108
+ isExpanded={isExpandedState}
109
+ isAlwaysOpen={item.isAlwaysOpen}
110
+ openByDefault={openDrawersByDefault}
111
+ rightIcon="chevron-down"
112
+ leftIcon={getDynamicIcon(item?.icon)}
113
+ className={linkClass}
114
+ label={item.label}
115
+ linkActiveFunc={linkActiveFunc}
116
+ linkCallback={linkCallback}
117
+ listOfLinks={item.items}
118
+ url={item.url}
119
+ sidebarExpand={expand}
120
+ isHighlighted={item.isHighlighted}
121
+ darkerBackground={item.darkerBackground}
122
+ leftBorderHighlightDisabled={item.leftBorderHighlightDisabled}
123
+ hideLabelSection={item.hideLabelSection}
124
+ largerDrawerBottomPadding={item.largerDrawerBottomPadding}
125
+ />
126
+ ),
127
+ custom: (
128
+ <AnimationGroup display={isExpandedState} key={key}>
129
+ <SanitizedContent
130
+ html={item.content}
131
+ customClassName={item.customClassName}
132
+ />
133
+ </AnimationGroup>
134
+ ),
135
+ switchLink: (
136
+ <AnimationGroup display={isExpandedState} key={key}>
137
+ <CmsSwitchLink
138
+ linkCallback={linkCallback}
139
+ label={item.label}
140
+ url={item.url}
141
+ />
142
+ </AnimationGroup>
143
+ ),
144
+ }[item.type] || (
145
+ <NavLinkInline
146
+ key={key}
147
+ icon={getDynamicIcon(item?.icon)}
148
+ className={item.className ? item.className : linkClass}
149
+ url={item.url}
150
+ label={item.label}
151
+ linkCallback={linkCallback}
152
+ showLabel={isExpandedState}
153
+ disabled={item.disabled}
154
+ target={item.target}
155
+ />
156
+ )
157
+ );
158
+ });
159
+
160
+ if (className === "link-container") {
161
+ return (
162
+ <div
163
+ className="animation-flat"
164
+ key={`nav-link-container-${recursionId}`}
165
+ >
166
+ <NavLinkContainer
167
+ listOfLinks={itemsMarkup}
168
+ linkActiveFunc={linkActiveFunc}
169
+ />
170
+ </div>
171
+ );
172
+ } else {
173
+ return <div className={className}>{itemsMarkup}</div>;
174
+ }
175
+ };
176
+
177
+ export default DynamicContent
178
+
179
+ DynamicContent.propTypes = {
180
+ config: PropTypes.object,
181
+ isExpandedState: PropTypes.bool,
182
+ contentItems: PropTypes.array,
183
+ className: PropTypes.string,
184
+ recursionId: PropTypes.number,
185
+ expand: PropTypes.func
186
+ };
@@ -3,17 +3,8 @@ import PropTypes from "prop-types";
3
3
 
4
4
  import { setSideNavExpanded, isSideNavExpanded } from "../helpers";
5
5
  import { LevelOneContent } from "../Content";
6
- import {
7
- NavLinkContainer,
8
- NavLinkInline,
9
- NavLinkDrawer,
10
- NavLinkToggle,
11
- } from "../Links";
12
- import AnimationGroup from "../AnimationGroup/AnimationGroup";
13
- import { PracticeDetails, IndividualDetails } from "../Details";
14
- import SanitizedContent from "../../SanitizedContent";
15
- import * as SvgComponents from "../../../lib/SvgComponents.jsx";
16
- import CmsSwitchLink from "../Links/CmsSwitchLink";
6
+ import DynamicContent from "./DynamicContent";
7
+ import { NavLinkToggle } from "../Links";
17
8
  import defaultMarkup from "./default-markup";
18
9
 
19
10
  // TODO: For an SSR version of the SideNavUI we would need to have
@@ -112,164 +103,6 @@ const SideNavUI = ({
112
103
  };
113
104
  }, []);
114
105
 
115
- const getDynamicContent = (contentItems, className, recursionId) => {
116
- const { openDrawersByDefault, linkActiveFunc, linkCallback } = config;
117
- let linkClass = isExpandedState ? "link-inline" : "link-collapsed";
118
- const containerRecursionId = recursionId || 0;
119
-
120
- const getDynamicIcon = (icon) => {
121
- const Component = SvgComponents[icon];
122
- return Component ? <Component /> : null;
123
- };
124
-
125
- const hasDarkerBackground = (darkerBackground) => {
126
- return darkerBackground ? "hr-smaller-vertical-spacing" : "";
127
- };
128
-
129
- const itemsMarkup = (contentItems || []).map((item, index) => {
130
- const key = `${JSON.stringify(item)}-${index}-${containerRecursionId}`;
131
-
132
- return (
133
- {
134
- divider: (
135
- <AnimationGroup
136
- display={isExpandedState}
137
- key={key}
138
- darkerBackground={item.darkerBackground}
139
- >
140
- <hr className={`${hasDarkerBackground(item.darkerBackground)}`} />
141
- </AnimationGroup>
142
- ),
143
- container: getDynamicContent(
144
- item.items,
145
- item.className,
146
- containerRecursionId + 1,
147
- ),
148
- linkBack: (
149
- <AnimationGroup display={isExpandedState} key={key}>
150
- <NavLinkInline
151
- className="link-back"
152
- icon={getDynamicIcon("ChevronLeft")}
153
- url={item.url}
154
- label={item.label}
155
- linkCallback={linkCallback}
156
- showLabel={true}
157
- />
158
- </AnimationGroup>
159
- ),
160
- linkHome: (
161
- <AnimationGroup display={isExpandedState} key={key}>
162
- <NavLinkInline
163
- className="account-home-link"
164
- icon={getDynamicIcon(item?.icon)}
165
- url={item.url}
166
- label={item.label}
167
- linkCallback={linkCallback}
168
- showLabel={true}
169
- />
170
- </AnimationGroup>
171
- ),
172
- practiceDetails: (
173
- <AnimationGroup
174
- display={isExpandedState}
175
- className={"details"}
176
- key={key}
177
- >
178
- <PracticeDetails
179
- practiceName={item.practiceName}
180
- {...(!item.practiceTin
181
- ? {}
182
- : { practiceTin: item.practiceTin })}
183
- {...(!item.apmEntityId
184
- ? {}
185
- : { apmEntityId: item.apmEntityId })}
186
- {...(!item.vgId ? {} : { vgId: item.vgId })}
187
- {...(!item.cpcPlusId ? {} : { cpcPlusId: item.cpcPlusId })}
188
- {...(!item.pcfId ? {} : { pcfId: item.pcfId })}
189
- {...(!item.subgroupId ? {} : { subgroupId: item.subgroupId })}
190
- />
191
- </AnimationGroup>
192
- ),
193
- individualDetails: (
194
- <AnimationGroup display={isExpandedState} key={key}>
195
- <IndividualDetails
196
- individualName={item.individualName}
197
- individualNpi={item.individualNpi}
198
- />
199
- </AnimationGroup>
200
- ),
201
- linkDrawer: (
202
- <NavLinkDrawer
203
- key={key}
204
- isExpanded={isExpandedState}
205
- isAlwaysOpen={item.isAlwaysOpen}
206
- openByDefault={openDrawersByDefault}
207
- rightIcon="chevron-down"
208
- leftIcon={getDynamicIcon(item?.icon)}
209
- className={linkClass}
210
- label={item.label}
211
- linkActiveFunc={linkActiveFunc}
212
- linkCallback={linkCallback}
213
- listOfLinks={item.items}
214
- url={item.url}
215
- sidebarExpand={expand}
216
- isHighlighted={item.isHighlighted}
217
- darkerBackground={item.darkerBackground}
218
- leftBorderHighlightDisabled={item.leftBorderHighlightDisabled}
219
- hideLabelSection={item.hideLabelSection}
220
- largerDrawerBottomPadding={item.largerDrawerBottomPadding}
221
- />
222
- ),
223
- custom: (
224
- <AnimationGroup display={isExpandedState} key={key}>
225
- <SanitizedContent
226
- html={item.content}
227
- customClassName={item.customClassName}
228
- />
229
- </AnimationGroup>
230
- ),
231
- switchLink: (
232
- <AnimationGroup display={isExpandedState} key={key}>
233
- <CmsSwitchLink
234
- linkCallback={linkCallback}
235
- label={item.label}
236
- url={item.url}
237
- />
238
- </AnimationGroup>
239
- ),
240
- }[item.type] || (
241
- <NavLinkInline
242
- key={key}
243
- icon={getDynamicIcon(item?.icon)}
244
- className={item.className ? item.className : linkClass}
245
- url={item.url}
246
- label={item.label}
247
- linkCallback={linkCallback}
248
- showLabel={isExpandedState}
249
- disabled={item.disabled}
250
- target={item.target}
251
- />
252
- )
253
- );
254
- });
255
-
256
- if (className === "link-container") {
257
- return (
258
- <div
259
- className="animation-flat"
260
- key={`nav-link-container-${recursionId}`}
261
- >
262
- <NavLinkContainer
263
- listOfLinks={itemsMarkup}
264
- linkActiveFunc={linkActiveFunc}
265
- />
266
- </div>
267
- );
268
- } else {
269
- return <div className={className}>{itemsMarkup}</div>;
270
- }
271
- };
272
-
273
106
  const content = !items?.length ? (
274
107
  <LevelOneContent
275
108
  levelOneContent={sideNavContent}
@@ -277,10 +110,12 @@ const SideNavUI = ({
277
110
  config={config}
278
111
  />
279
112
  ) : (
280
- getDynamicContent(
281
- items,
282
- "sidebar-content" + (isAltStyle ? " alt-style" : ""),
283
- )
113
+ <DynamicContent
114
+ contentItems={items}
115
+ className={"sidebar-content" + (isAltStyle ? " alt-style" : "")}
116
+ config={config}
117
+ isExpandedState={isExpandedState}
118
+ />
284
119
  );
285
120
 
286
121
  return (