@progressiveui/react 1.22.1 → 2.0.0
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/.storybook/WfpTheme.js +1 -1
- package/.storybook/main.ts +4 -4
- package/.storybook/preview.tsx +0 -25
- package/es/dist/components/Accordion/hooks/useAccordionItemEffect.d.ts +1 -1
- package/es/dist/components/Footer/Footer.d.ts +0 -8
- package/es/dist/components/Footer/index.d.ts +2 -2
- package/es/dist/components/Input/useInput.d.ts +2 -0
- package/es/dist/components/MainNavigation/index.d.ts +3 -4
- package/es/dist/hooks/useHeightTransition.d.ts +1 -1
- package/es/dist/index.d.ts +1 -1
- package/es/index.js +231 -1316
- package/lib/dist/components/Accordion/hooks/useAccordionItemEffect.d.ts +1 -1
- package/lib/dist/components/Footer/Footer.d.ts +0 -8
- package/lib/dist/components/Footer/index.d.ts +2 -2
- package/lib/dist/components/Input/useInput.d.ts +2 -0
- package/lib/dist/components/MainNavigation/index.d.ts +3 -4
- package/lib/dist/hooks/useHeightTransition.d.ts +1 -1
- package/lib/dist/index.d.ts +1 -1
- package/lib/index.js +256 -1353
- package/package.json +68 -78
- package/src/components/Accordion/hooks/useAccordion.ts +13 -9
- package/src/components/BannerNavigation/BannerNavigation.stories.tsx +0 -2
- package/src/components/Button/Button.stories.tsx +0 -16
- package/src/components/Button/Button.tsx +14 -11
- package/src/components/ContextMenu/ContextMenu.stories.tsx +0 -2
- package/src/components/Empty/Empty.stories.tsx +1 -2
- package/src/components/Footer/Footer.tsx +2 -42
- package/src/components/Footer/index.ts +2 -2
- package/src/components/Hero/Hero.stories.tsx +0 -2
- package/src/components/MainNavigation/MainNavigation.stories.tsx +1 -4
- package/src/components/MainNavigation/MainNavigation.tsx +1 -23
- package/src/components/MainNavigation/index.ts +3 -4
- package/src/components/Pagination/Pagination.stories.tsx +0 -2
- package/src/components/Search/Search.tsx +1 -1
- package/src/components/Text/Text.tsx +7 -4
- package/src/components/Toggle/Toggle.tsx +4 -4
- package/src/index.ts +0 -1
- package/umd/dist/components/Accordion/hooks/useAccordionItemEffect.d.ts +1 -1
- package/umd/dist/components/Footer/Footer.d.ts +0 -8
- package/umd/dist/components/Footer/index.d.ts +2 -2
- package/umd/dist/components/Input/useInput.d.ts +2 -0
- package/umd/dist/components/MainNavigation/index.d.ts +3 -4
- package/umd/dist/hooks/useHeightTransition.d.ts +1 -1
- package/umd/dist/index.d.ts +1 -1
- package/umd/index.js +231 -1316
- package/umd/index.min.js +1 -1
- package/src/components/MainNavigation/MainNavigationExternal.tsx +0 -338
|
@@ -1,338 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { useEffect, useRef } from "react";
|
|
3
|
-
import { WfpLogoVerticalEn } from "@progressiveui/icons-react";
|
|
4
|
-
import { ChevronDown, ChevronUp } from "@progressiveui/icons-react";
|
|
5
|
-
|
|
6
|
-
import Button from "../Button";
|
|
7
|
-
import User from "../User";
|
|
8
|
-
import Wrapper from "../Wrapper";
|
|
9
|
-
import PropTypes from "prop-types";
|
|
10
|
-
import { useTogglable } from "../../hooks";
|
|
11
|
-
import useSettings from "../../hooks/useSettings";
|
|
12
|
-
|
|
13
|
-
const LanguageExternal = ({ children, primaryLanguage }) => {
|
|
14
|
-
const { prefix } = useSettings();
|
|
15
|
-
const ref = useRef<HTMLInputElement>(null);
|
|
16
|
-
const languageTogglable = useTogglable();
|
|
17
|
-
|
|
18
|
-
useEffect(() => {
|
|
19
|
-
const checkIfClickedOutside = (e) => {
|
|
20
|
-
// If the menu is open and the clicked target is not within the menu,
|
|
21
|
-
// then close the menu
|
|
22
|
-
if (
|
|
23
|
-
languageTogglable.isOpen &&
|
|
24
|
-
ref.current &&
|
|
25
|
-
!ref.current.contains(e.target)
|
|
26
|
-
) {
|
|
27
|
-
languageTogglable.close();
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
document.addEventListener("mousedown", checkIfClickedOutside);
|
|
31
|
-
return () => {
|
|
32
|
-
// Cleanup the event listener
|
|
33
|
-
document.removeEventListener("mousedown", checkIfClickedOutside);
|
|
34
|
-
};
|
|
35
|
-
}, [languageTogglable.isOpen]);
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<div className={`${prefix}--language-ext`} ref={ref}>
|
|
39
|
-
<div
|
|
40
|
-
className={`${prefix}--language-ext__trigger`}
|
|
41
|
-
role="presentation"
|
|
42
|
-
onClick={() =>
|
|
43
|
-
languageTogglable.isOpen
|
|
44
|
-
? languageTogglable.close()
|
|
45
|
-
: languageTogglable.open()
|
|
46
|
-
}
|
|
47
|
-
>
|
|
48
|
-
<span>{primaryLanguage}</span>
|
|
49
|
-
{languageTogglable.isOpen ? <ChevronUp /> : <ChevronDown />}
|
|
50
|
-
</div>
|
|
51
|
-
<ul
|
|
52
|
-
className={`${prefix}--language-ext__dropdown ${
|
|
53
|
-
languageTogglable.isOpen
|
|
54
|
-
? `${prefix}--language-ext__dropdown--is-shown`
|
|
55
|
-
: ""
|
|
56
|
-
}`}
|
|
57
|
-
>
|
|
58
|
-
{children}
|
|
59
|
-
</ul>
|
|
60
|
-
</div>
|
|
61
|
-
);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const UserExternal = ({ username, children, userImage }) => {
|
|
65
|
-
const { prefix } = useSettings();
|
|
66
|
-
|
|
67
|
-
const ref = useRef<HTMLInputElement>(null);
|
|
68
|
-
const userTogglable = useTogglable();
|
|
69
|
-
|
|
70
|
-
useEffect(() => {
|
|
71
|
-
const checkIfClickedOutside = (e) => {
|
|
72
|
-
// If the menu is open and the clicked target is not within the menu,
|
|
73
|
-
// then close the menu
|
|
74
|
-
if (
|
|
75
|
-
userTogglable.isOpen &&
|
|
76
|
-
ref?.current &&
|
|
77
|
-
!ref.current.contains(e.target)
|
|
78
|
-
) {
|
|
79
|
-
userTogglable.close();
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
document.addEventListener("mousedown", checkIfClickedOutside);
|
|
83
|
-
return () => {
|
|
84
|
-
// Cleanup the event listener
|
|
85
|
-
document.removeEventListener("mousedown", checkIfClickedOutside);
|
|
86
|
-
};
|
|
87
|
-
}, [userTogglable.isOpen]);
|
|
88
|
-
|
|
89
|
-
return (
|
|
90
|
-
<div className={`${prefix}--user-ext`} ref={ref}>
|
|
91
|
-
<div
|
|
92
|
-
className={`${prefix}--user-ext__trigger`}
|
|
93
|
-
role="presentation"
|
|
94
|
-
onClick={() =>
|
|
95
|
-
userTogglable.isOpen ? userTogglable.close() : userTogglable.open()
|
|
96
|
-
}
|
|
97
|
-
>
|
|
98
|
-
<User alt="User avatar" name={username} image={userImage} />
|
|
99
|
-
{userTogglable.isOpen ? <ChevronUp /> : <ChevronDown />}
|
|
100
|
-
</div>
|
|
101
|
-
<ul
|
|
102
|
-
className={`${prefix}--user-ext__dropdown ${
|
|
103
|
-
userTogglable.isOpen ? `${prefix}--user-ext__dropdown--is-shown` : ""
|
|
104
|
-
}`}
|
|
105
|
-
>
|
|
106
|
-
{children}
|
|
107
|
-
</ul>
|
|
108
|
-
</div>
|
|
109
|
-
);
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
interface MainNavigationExternalProps {
|
|
113
|
-
/**
|
|
114
|
-
* The name of your product can be applied to this prop
|
|
115
|
-
*/
|
|
116
|
-
productName?: string;
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* The CSS class name to be placed on the wrapping element.
|
|
120
|
-
*/
|
|
121
|
-
className?: string;
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* List of laguages your site support
|
|
125
|
-
*/
|
|
126
|
-
languageList?: React.ReactNode;
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* The name of signed in user can be applied to this prop
|
|
130
|
-
*/
|
|
131
|
-
username?: string;
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* The image of signed in user can be applied to this prop
|
|
135
|
-
*/
|
|
136
|
-
userImage?: string;
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* The dropdown details of user can be applied to this prop
|
|
140
|
-
*/
|
|
141
|
-
userDetails?: React.ReactNode;
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* This prop accepts the first language your website is in. Default: English
|
|
145
|
-
*/
|
|
146
|
-
primaryLanguage?: string;
|
|
147
|
-
components?: any;
|
|
148
|
-
children?: React.ReactNode;
|
|
149
|
-
pageWidth?:
|
|
150
|
-
| "sm"
|
|
151
|
-
| "md"
|
|
152
|
-
| "lg"
|
|
153
|
-
| "full"
|
|
154
|
-
| "xs"
|
|
155
|
-
| "narrow"
|
|
156
|
-
| "narrower"
|
|
157
|
-
| "narrowest";
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
const MainNavigationExternal = ({
|
|
161
|
-
productName,
|
|
162
|
-
primaryLanguage,
|
|
163
|
-
languageList,
|
|
164
|
-
username,
|
|
165
|
-
pageWidth = "full",
|
|
166
|
-
components = {},
|
|
167
|
-
userImage,
|
|
168
|
-
userDetails,
|
|
169
|
-
children,
|
|
170
|
-
}: MainNavigationExternalProps) => {
|
|
171
|
-
const { prefix } = useSettings();
|
|
172
|
-
const ref = useRef<HTMLDivElement | null>(null);
|
|
173
|
-
const navTogglable = useTogglable();
|
|
174
|
-
|
|
175
|
-
useEffect(() => {
|
|
176
|
-
const checkIfClickedOutside = (e) => {
|
|
177
|
-
// If the menu is open and the clicked target is not within the menu,
|
|
178
|
-
// then close the menu
|
|
179
|
-
if (
|
|
180
|
-
navTogglable.isOpen &&
|
|
181
|
-
ref.current &&
|
|
182
|
-
!ref.current.contains(e.target)
|
|
183
|
-
) {
|
|
184
|
-
navTogglable.close();
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
document.addEventListener("mousedown", checkIfClickedOutside);
|
|
188
|
-
return () => {
|
|
189
|
-
// Cleanup the event listener
|
|
190
|
-
document.removeEventListener("mousedown", checkIfClickedOutside);
|
|
191
|
-
};
|
|
192
|
-
}, [navTogglable.isOpen]);
|
|
193
|
-
|
|
194
|
-
const defaultComponents = {
|
|
195
|
-
LanguageExternal,
|
|
196
|
-
UserExternal,
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
const c = { ...defaultComponents, ...components };
|
|
200
|
-
|
|
201
|
-
return (
|
|
202
|
-
<header className={`${prefix}--main-navigation-ext`}>
|
|
203
|
-
<Wrapper
|
|
204
|
-
pageWidth={pageWidth}
|
|
205
|
-
className={`${prefix}--main-navigation-ext__wrapper`}
|
|
206
|
-
>
|
|
207
|
-
<div className={`${prefix}--main-navigation-ext__branding`}>
|
|
208
|
-
<div className={`${prefix}--main-navigation-ext__wfp-logo`}>
|
|
209
|
-
<WfpLogoVerticalEn
|
|
210
|
-
className={`${prefix}--main-navigation-ext__wfp-logo-svg`}
|
|
211
|
-
alt="WFP"
|
|
212
|
-
width="100%"
|
|
213
|
-
/>
|
|
214
|
-
</div>
|
|
215
|
-
<div className={`${prefix}--main-navigation-ext__product-name`}>
|
|
216
|
-
{productName}
|
|
217
|
-
</div>
|
|
218
|
-
</div>
|
|
219
|
-
<div className={`${prefix}--main-navigation-ext__main`}>
|
|
220
|
-
<div className={`${prefix}--main-navigation-ext__settings`}>
|
|
221
|
-
<c.LanguageExternal primaryLanguage={primaryLanguage}>
|
|
222
|
-
{languageList}
|
|
223
|
-
</c.LanguageExternal>
|
|
224
|
-
<c.UserExternal username={username} userImage={userImage}>
|
|
225
|
-
{userDetails}
|
|
226
|
-
</c.UserExternal>
|
|
227
|
-
</div>
|
|
228
|
-
<div className={`${prefix}--main-navigation-ext__nav`} ref={ref}>
|
|
229
|
-
<div
|
|
230
|
-
className={`${prefix}--main-navigation-ext__mobile-menu-button`}
|
|
231
|
-
>
|
|
232
|
-
<Button
|
|
233
|
-
kind="secondary"
|
|
234
|
-
small
|
|
235
|
-
onClick={() =>
|
|
236
|
-
navTogglable.isOpen
|
|
237
|
-
? navTogglable.close()
|
|
238
|
-
: navTogglable.open()
|
|
239
|
-
}
|
|
240
|
-
>
|
|
241
|
-
Menu
|
|
242
|
-
</Button>
|
|
243
|
-
</div>
|
|
244
|
-
<div
|
|
245
|
-
className={`${prefix}--main-navigation-ext__nav-wrapper
|
|
246
|
-
${navTogglable.isOpen ? "wfp--main-navigation-ext--is-shown" : ""}`}
|
|
247
|
-
>
|
|
248
|
-
{/* This nav can include both links and buttons */}
|
|
249
|
-
<nav
|
|
250
|
-
className={`${prefix}--main-navigation-ext__site-nav ${
|
|
251
|
-
navTogglable.isOpen
|
|
252
|
-
? "wfp--main-navigation-ext--is-shown"
|
|
253
|
-
: ""
|
|
254
|
-
}`}
|
|
255
|
-
>
|
|
256
|
-
<ul className={`${prefix}--main-navigation-ext__site-nav-list`}>
|
|
257
|
-
{children}
|
|
258
|
-
<div
|
|
259
|
-
className={`${prefix}--main-navigation-ext__mobile-settings`}
|
|
260
|
-
>
|
|
261
|
-
<li className={`${prefix}--main-navigation-ext__site-link`}>
|
|
262
|
-
<LanguageExternal primaryLanguage={primaryLanguage}>
|
|
263
|
-
{languageList}
|
|
264
|
-
</LanguageExternal>
|
|
265
|
-
</li>
|
|
266
|
-
<li className={`${prefix}--main-navigation-ext__site-link`}>
|
|
267
|
-
<UserExternal username={username} userImage={userImage}>
|
|
268
|
-
{userDetails}
|
|
269
|
-
</UserExternal>
|
|
270
|
-
</li>
|
|
271
|
-
</div>
|
|
272
|
-
</ul>
|
|
273
|
-
</nav>
|
|
274
|
-
{/* To show if the user is a guest */}
|
|
275
|
-
{/* <nav className={`${prefix}--main-navigation-ext__auth`}>
|
|
276
|
-
<ul className={`${prefix}--main-navigation-ext__auth-list`}>
|
|
277
|
-
<li className={`${prefix}--main-navigation-ext__auth-action`}>
|
|
278
|
-
<Button kind="accent" small>
|
|
279
|
-
Register
|
|
280
|
-
</Button>
|
|
281
|
-
</li>
|
|
282
|
-
<li className={`${prefix}--main-navigation-ext__auth-action`}>
|
|
283
|
-
<Button kind="primary" small>
|
|
284
|
-
Sign in
|
|
285
|
-
</Button>
|
|
286
|
-
</li>
|
|
287
|
-
</ul>
|
|
288
|
-
</nav> */}
|
|
289
|
-
</div>
|
|
290
|
-
</div>
|
|
291
|
-
</div>
|
|
292
|
-
</Wrapper>
|
|
293
|
-
</header>
|
|
294
|
-
);
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
MainNavigationExternal.propTypes = {
|
|
298
|
-
/**
|
|
299
|
-
* The name of your product can be applied to this prop
|
|
300
|
-
*/
|
|
301
|
-
productName: PropTypes.node,
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
* The CSS class name to be placed on the wrapping element.
|
|
305
|
-
*/
|
|
306
|
-
className: PropTypes.string,
|
|
307
|
-
|
|
308
|
-
/**
|
|
309
|
-
* List of laguages your site support
|
|
310
|
-
*/
|
|
311
|
-
languageList: PropTypes.node,
|
|
312
|
-
|
|
313
|
-
/**
|
|
314
|
-
* The name of signed in user can be applied to this prop
|
|
315
|
-
*/
|
|
316
|
-
username: PropTypes.node,
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
* The image of signed in user can be applied to this prop
|
|
320
|
-
*/
|
|
321
|
-
userImage: PropTypes.string,
|
|
322
|
-
|
|
323
|
-
/**
|
|
324
|
-
* The dropdown details of user can be applied to this prop
|
|
325
|
-
*/
|
|
326
|
-
userDetails: PropTypes.node,
|
|
327
|
-
|
|
328
|
-
/**
|
|
329
|
-
* This prop accepts the first language your website is in. Default: English
|
|
330
|
-
*/
|
|
331
|
-
primaryLanguage: PropTypes.string,
|
|
332
|
-
};
|
|
333
|
-
|
|
334
|
-
MainNavigationExternal.defaultProps = {
|
|
335
|
-
primaryLanguage: "English",
|
|
336
|
-
};
|
|
337
|
-
|
|
338
|
-
export default MainNavigationExternal;
|