volto-dropdownmenu 2.3.0 → 2.4.2
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/CHANGELOG.md +23 -0
- package/README.md +13 -0
- package/locales/de/LC_MESSAGES/volto.po +5 -0
- package/locales/en/LC_MESSAGES/volto.po +5 -0
- package/locales/es/LC_MESSAGES/volto.po +5 -0
- package/locales/eu/LC_MESSAGES/volto.po +5 -0
- package/locales/fr/LC_MESSAGES/volto.po +5 -0
- package/locales/it/LC_MESSAGES/volto.po +5 -0
- package/locales/ja/LC_MESSAGES/volto.po +5 -0
- package/locales/nl/LC_MESSAGES/volto.po +5 -0
- package/locales/pt/LC_MESSAGES/volto.po +5 -0
- package/locales/pt_BR/LC_MESSAGES/volto.po +5 -0
- package/locales/ro/LC_MESSAGES/volto.po +5 -0
- package/locales/volto.pot +6 -1
- package/package.json +1 -1
- package/src/components/DropdownMenu.jsx +13 -3
- package/src/customizations/components/theme/Navigation/Navigation.jsx +9 -1
- package/src/index.js +6 -0
- package/src/widget/MenuConfigurationForm.jsx +23 -3
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,28 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
4
4
|
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
6
|
|
|
7
|
+
#### [v2.4.2](https://github.com/collective/volto-dropdownmenu/compare/v2.4.1...v2.4.2)
|
|
8
|
+
|
|
9
|
+
> 25 May 2022
|
|
10
|
+
|
|
11
|
+
- feat: added mobile-menu-opend class to body when mobile menu is opened [`659960c`](https://github.com/collective/volto-dropdownmenu/commit/659960c07782af2b0fe7d0686029bfea2ee0bac2)
|
|
12
|
+
|
|
13
|
+
#### [v2.4.1](https://github.com/collective/volto-dropdownmenu/compare/v2.4.0...v2.4.1)
|
|
14
|
+
|
|
15
|
+
> 14 March 2022
|
|
16
|
+
|
|
17
|
+
- Release 2.4.1 [`4fa2990`](https://github.com/collective/volto-dropdownmenu/commit/4fa2990e03ed41d2dddc5f7fecc6b271c2c356f6)
|
|
18
|
+
- chore: added close event on clickableNavigationRoots [`2cc495a`](https://github.com/collective/volto-dropdownmenu/commit/2cc495a7bd8db9dd6fd90dcafcf31ca31a06c2e8)
|
|
19
|
+
|
|
20
|
+
#### [v2.4.0](https://github.com/collective/volto-dropdownmenu/compare/v2.3.0...v2.4.0)
|
|
21
|
+
|
|
22
|
+
> 4 March 2022
|
|
23
|
+
|
|
24
|
+
- feat: added clickableNavigationRoots configurable option [`4f75f3b`](https://github.com/collective/volto-dropdownmenu/commit/4f75f3b8e1714b2e159bfe964d8ff7ca0bf445a9)
|
|
25
|
+
- Release 2.4.0 [`d20252a`](https://github.com/collective/volto-dropdownmenu/commit/d20252adb03fc04beb05a8189d51dd166eb8c6b8)
|
|
26
|
+
- fix: fix hasBlocks data if has only one empty text block [`584f6a2`](https://github.com/collective/volto-dropdownmenu/commit/584f6a280e38c8f2f589acb18534c8ca5d8163af)
|
|
27
|
+
- fix: fixed readme [`d16175a`](https://github.com/collective/volto-dropdownmenu/commit/d16175a99a68c6bc33c4b102f44d2479a30fafca)
|
|
28
|
+
|
|
7
29
|
#### [v2.3.0](https://github.com/collective/volto-dropdownmenu/compare/v2.2.9...v2.3.0)
|
|
8
30
|
|
|
9
31
|
> 26 October 2021
|
|
@@ -11,6 +33,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
11
33
|
- chore: added npm publish true [`b8b1b6c`](https://github.com/collective/volto-dropdownmenu/commit/b8b1b6c6428fac759a7345bb33df95533524e517)
|
|
12
34
|
- chore: removed yarn.lock [`3037dd0`](https://github.com/collective/volto-dropdownmenu/commit/3037dd0f53a23d7b6dfd1835b5454a824481315c)
|
|
13
35
|
- chore: updated volto 14 [`a81180e`](https://github.com/collective/volto-dropdownmenu/commit/a81180e8ff81e08045ea2c45abe658475bbfa195)
|
|
36
|
+
- Release 2.3.0 [`5f785c5`](https://github.com/collective/volto-dropdownmenu/commit/5f785c58cee5351c8b6996b9f2c715a07c2bd04d)
|
|
14
37
|
|
|
15
38
|
#### [v2.2.9](https://github.com/collective/volto-dropdownmenu/compare/v2.2.8...v2.2.9)
|
|
16
39
|
|
package/README.md
CHANGED
|
@@ -23,6 +23,19 @@ To use the default template for the dropdown menu, add `src/addons/volto-dropdow
|
|
|
23
23
|
]
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
+
### Navigation roots
|
|
27
|
+
|
|
28
|
+
By default, navigations roots are clickable, but there's the possibility to make them not clickable.
|
|
29
|
+
Enabling the field 'clickableNavigationRoots' in volto-dropdownmenu config, a field appears in configuration form and let editor to decide if make navigation roots clickable or not.
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
config.settings["volto-dropdownmenu"] = {
|
|
33
|
+
"options": {
|
|
34
|
+
"clickableNavigationRoots": true, //if true, a checkbox option in dropdown menu appears
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
```
|
|
38
|
+
|
|
26
39
|
## Screenshots and demo
|
|
27
40
|
|
|
28
41
|
### Controlpanel
|
|
@@ -46,6 +46,11 @@ msgstr ""
|
|
|
46
46
|
msgid "dropdownmenu-blocks-description"
|
|
47
47
|
msgstr ""
|
|
48
48
|
|
|
49
|
+
#: widget/MenuConfigurationForm
|
|
50
|
+
# defaultMessage: Clickable navigation roots
|
|
51
|
+
msgid "dropdownmenu-clickableNavigationRoots"
|
|
52
|
+
msgstr ""
|
|
53
|
+
|
|
49
54
|
#: components/DropdownMenu
|
|
50
55
|
# defaultMessage: Close menu
|
|
51
56
|
msgid "dropdownmenu-close-menu-button"
|
|
@@ -46,6 +46,11 @@ msgstr "Blocks"
|
|
|
46
46
|
msgid "dropdownmenu-blocks-description"
|
|
47
47
|
msgstr "Add some blocks to show in dropdown menu."
|
|
48
48
|
|
|
49
|
+
#: widget/MenuConfigurationForm
|
|
50
|
+
# defaultMessage: Clickable navigation roots
|
|
51
|
+
msgid "dropdownmenu-clickableNavigationRoots"
|
|
52
|
+
msgstr ""
|
|
53
|
+
|
|
49
54
|
#: components/DropdownMenu
|
|
50
55
|
# defaultMessage: Close menu
|
|
51
56
|
msgid "dropdownmenu-close-menu-button"
|
|
@@ -46,6 +46,11 @@ msgstr ""
|
|
|
46
46
|
msgid "dropdownmenu-blocks-description"
|
|
47
47
|
msgstr ""
|
|
48
48
|
|
|
49
|
+
#: widget/MenuConfigurationForm
|
|
50
|
+
# defaultMessage: Clickable navigation roots
|
|
51
|
+
msgid "dropdownmenu-clickableNavigationRoots"
|
|
52
|
+
msgstr ""
|
|
53
|
+
|
|
49
54
|
#: components/DropdownMenu
|
|
50
55
|
# defaultMessage: Close menu
|
|
51
56
|
msgid "dropdownmenu-close-menu-button"
|
|
@@ -46,6 +46,11 @@ msgstr ""
|
|
|
46
46
|
msgid "dropdownmenu-blocks-description"
|
|
47
47
|
msgstr ""
|
|
48
48
|
|
|
49
|
+
#: widget/MenuConfigurationForm
|
|
50
|
+
# defaultMessage: Clickable navigation roots
|
|
51
|
+
msgid "dropdownmenu-clickableNavigationRoots"
|
|
52
|
+
msgstr ""
|
|
53
|
+
|
|
49
54
|
#: components/DropdownMenu
|
|
50
55
|
# defaultMessage: Close menu
|
|
51
56
|
msgid "dropdownmenu-close-menu-button"
|
|
@@ -46,6 +46,11 @@ msgstr ""
|
|
|
46
46
|
msgid "dropdownmenu-blocks-description"
|
|
47
47
|
msgstr ""
|
|
48
48
|
|
|
49
|
+
#: widget/MenuConfigurationForm
|
|
50
|
+
# defaultMessage: Clickable navigation roots
|
|
51
|
+
msgid "dropdownmenu-clickableNavigationRoots"
|
|
52
|
+
msgstr ""
|
|
53
|
+
|
|
49
54
|
#: components/DropdownMenu
|
|
50
55
|
# defaultMessage: Close menu
|
|
51
56
|
msgid "dropdownmenu-close-menu-button"
|
|
@@ -46,6 +46,11 @@ msgstr "Blocchi"
|
|
|
46
46
|
msgid "dropdownmenu-blocks-description"
|
|
47
47
|
msgstr "Aggiungi i blocchi che verranno mostrati nel megamenu"
|
|
48
48
|
|
|
49
|
+
#: widget/MenuConfigurationForm
|
|
50
|
+
# defaultMessage: Clickable navigation roots
|
|
51
|
+
msgid "dropdownmenu-clickableNavigationRoots"
|
|
52
|
+
msgstr "Rendi cliccabili le radici di navigazione"
|
|
53
|
+
|
|
49
54
|
#: components/DropdownMenu
|
|
50
55
|
# defaultMessage: Close menu
|
|
51
56
|
msgid "dropdownmenu-close-menu-button"
|
|
@@ -46,6 +46,11 @@ msgstr ""
|
|
|
46
46
|
msgid "dropdownmenu-blocks-description"
|
|
47
47
|
msgstr ""
|
|
48
48
|
|
|
49
|
+
#: widget/MenuConfigurationForm
|
|
50
|
+
# defaultMessage: Clickable navigation roots
|
|
51
|
+
msgid "dropdownmenu-clickableNavigationRoots"
|
|
52
|
+
msgstr ""
|
|
53
|
+
|
|
49
54
|
#: components/DropdownMenu
|
|
50
55
|
# defaultMessage: Close menu
|
|
51
56
|
msgid "dropdownmenu-close-menu-button"
|
|
@@ -46,6 +46,11 @@ msgstr ""
|
|
|
46
46
|
msgid "dropdownmenu-blocks-description"
|
|
47
47
|
msgstr ""
|
|
48
48
|
|
|
49
|
+
#: widget/MenuConfigurationForm
|
|
50
|
+
# defaultMessage: Clickable navigation roots
|
|
51
|
+
msgid "dropdownmenu-clickableNavigationRoots"
|
|
52
|
+
msgstr ""
|
|
53
|
+
|
|
49
54
|
#: components/DropdownMenu
|
|
50
55
|
# defaultMessage: Close menu
|
|
51
56
|
msgid "dropdownmenu-close-menu-button"
|
|
@@ -46,6 +46,11 @@ msgstr ""
|
|
|
46
46
|
msgid "dropdownmenu-blocks-description"
|
|
47
47
|
msgstr ""
|
|
48
48
|
|
|
49
|
+
#: widget/MenuConfigurationForm
|
|
50
|
+
# defaultMessage: Clickable navigation roots
|
|
51
|
+
msgid "dropdownmenu-clickableNavigationRoots"
|
|
52
|
+
msgstr ""
|
|
53
|
+
|
|
49
54
|
#: components/DropdownMenu
|
|
50
55
|
# defaultMessage: Close menu
|
|
51
56
|
msgid "dropdownmenu-close-menu-button"
|
|
@@ -46,6 +46,11 @@ msgstr ""
|
|
|
46
46
|
msgid "dropdownmenu-blocks-description"
|
|
47
47
|
msgstr ""
|
|
48
48
|
|
|
49
|
+
#: widget/MenuConfigurationForm
|
|
50
|
+
# defaultMessage: Clickable navigation roots
|
|
51
|
+
msgid "dropdownmenu-clickableNavigationRoots"
|
|
52
|
+
msgstr ""
|
|
53
|
+
|
|
49
54
|
#: components/DropdownMenu
|
|
50
55
|
# defaultMessage: Close menu
|
|
51
56
|
msgid "dropdownmenu-close-menu-button"
|
|
@@ -46,6 +46,11 @@ msgstr ""
|
|
|
46
46
|
msgid "dropdownmenu-blocks-description"
|
|
47
47
|
msgstr ""
|
|
48
48
|
|
|
49
|
+
#: widget/MenuConfigurationForm
|
|
50
|
+
# defaultMessage: Clickable navigation roots
|
|
51
|
+
msgid "dropdownmenu-clickableNavigationRoots"
|
|
52
|
+
msgstr ""
|
|
53
|
+
|
|
49
54
|
#: components/DropdownMenu
|
|
50
55
|
# defaultMessage: Close menu
|
|
51
56
|
msgid "dropdownmenu-close-menu-button"
|
package/locales/volto.pot
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
msgid ""
|
|
2
2
|
msgstr ""
|
|
3
3
|
"Project-Id-Version: Plone\n"
|
|
4
|
-
"POT-Creation-Date:
|
|
4
|
+
"POT-Creation-Date: 2022-03-04T16:04:33.047Z\n"
|
|
5
5
|
"Last-Translator: Plone i18n <plone-i18n@lists.sourceforge.net>\n"
|
|
6
6
|
"Language-Team: Plone i18n <plone-i18n@lists.sourceforge.net>\n"
|
|
7
7
|
"MIME-Version: 1.0\n"
|
|
@@ -48,6 +48,11 @@ msgstr ""
|
|
|
48
48
|
msgid "dropdownmenu-blocks-description"
|
|
49
49
|
msgstr ""
|
|
50
50
|
|
|
51
|
+
#: widget/MenuConfigurationForm
|
|
52
|
+
# defaultMessage: Clickable navigation roots
|
|
53
|
+
msgid "dropdownmenu-clickableNavigationRoots"
|
|
54
|
+
msgstr ""
|
|
55
|
+
|
|
51
56
|
#: components/DropdownMenu
|
|
52
57
|
# defaultMessage: Close menu
|
|
53
58
|
msgid "dropdownmenu-close-menu-button"
|
package/package.json
CHANGED
|
@@ -32,7 +32,7 @@ const DropdownMenu = ({ menu, open = false, closeMenu }) => {
|
|
|
32
32
|
const location = useLocation();
|
|
33
33
|
const blocksFieldname = getBlocksFieldname(menu);
|
|
34
34
|
const blocksLayoutFieldname = getBlocksLayoutFieldname(menu);
|
|
35
|
-
|
|
35
|
+
const { clickableNavigationRoots = true } = menu;
|
|
36
36
|
const navItemWidth = menu.navigationRoot?.length > 1 ? 3 : 4;
|
|
37
37
|
const blocksWidth =
|
|
38
38
|
menu.navigationRoot?.length === 1
|
|
@@ -40,6 +40,13 @@ const DropdownMenu = ({ menu, open = false, closeMenu }) => {
|
|
|
40
40
|
: menu.navigationRoot?.length > 2 || menu.navigationRoot?.length === 0
|
|
41
41
|
? 12
|
|
42
42
|
: 6;
|
|
43
|
+
let hasBlocks = hasBlocksData(menu);
|
|
44
|
+
if (menu?.blocks && Object.keys(menu.blocks).length === 1) {
|
|
45
|
+
let b = menu.blocks[Object.keys(menu.blocks)[0]];
|
|
46
|
+
if (b['@type'] === 'text' && (!b.text || b.text?.length === 0)) {
|
|
47
|
+
hasBlocks = false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
43
50
|
|
|
44
51
|
return (
|
|
45
52
|
<div
|
|
@@ -69,7 +76,10 @@ const DropdownMenu = ({ menu, open = false, closeMenu }) => {
|
|
|
69
76
|
<h2>
|
|
70
77
|
<ConditionalLink
|
|
71
78
|
to={flattenToAppURL(navRoot['@id'])}
|
|
72
|
-
condition={
|
|
79
|
+
condition={
|
|
80
|
+
menu.navigationRoot?.length > 1 &&
|
|
81
|
+
clickableNavigationRoots
|
|
82
|
+
}
|
|
73
83
|
>
|
|
74
84
|
<span>{navRoot.title}</span>
|
|
75
85
|
</ConditionalLink>
|
|
@@ -87,7 +97,7 @@ const DropdownMenu = ({ menu, open = false, closeMenu }) => {
|
|
|
87
97
|
)}
|
|
88
98
|
</Grid.Column>
|
|
89
99
|
))}
|
|
90
|
-
{
|
|
100
|
+
{hasBlocks && (
|
|
91
101
|
<Grid.Column
|
|
92
102
|
width={blocksWidth}
|
|
93
103
|
className="dropdownmenu-blocks-column"
|
|
@@ -70,7 +70,7 @@ const Navigation = ({ pathname, type }) => {
|
|
|
70
70
|
const targetItem = getAnchorTarget(e.target);
|
|
71
71
|
const dropdownmenuLinks = [
|
|
72
72
|
...(document?.querySelectorAll(
|
|
73
|
-
'.navigation-dropdownmenu .dropdown-menu-wrapper ul li a, .navigation-dropdownmenu .dropdownmenu-blocks-column a, .dropdownmenu-footer a, .navigation-dropdownmenu .menu > a',
|
|
73
|
+
'.navigation-dropdownmenu .dropdown-menu-wrapper ul li a, .navigation-dropdownmenu .dropdown-menu-wrapper h2 a, .navigation-dropdownmenu .dropdownmenu-blocks-column a, .dropdownmenu-footer a, .navigation-dropdownmenu .menu > a',
|
|
74
74
|
) ?? []),
|
|
75
75
|
];
|
|
76
76
|
|
|
@@ -88,6 +88,14 @@ const Navigation = ({ pathname, type }) => {
|
|
|
88
88
|
return () => document.body.removeEventListener('click', clickListener);
|
|
89
89
|
}, []);
|
|
90
90
|
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
if (isMobileMenuOpen) {
|
|
93
|
+
document.body.classList.add('mobile-menu-opened'); //to prevent scroll body
|
|
94
|
+
} else {
|
|
95
|
+
document.body.classList.remove('mobile-menu-opened'); //re-enable scroll body
|
|
96
|
+
}
|
|
97
|
+
}, [isMobileMenuOpen]);
|
|
98
|
+
|
|
91
99
|
const toggleMobileMenu = () => {
|
|
92
100
|
setMobileMenuOpen(!isMobileMenuOpen);
|
|
93
101
|
};
|
package/src/index.js
CHANGED
|
@@ -40,5 +40,11 @@ export default (config) => {
|
|
|
40
40
|
|
|
41
41
|
config.settings.controlPanelsIcons['dropdown-menu-settings'] = menuSVG;
|
|
42
42
|
|
|
43
|
+
config.settings['volto-dropdownmenu'] = {
|
|
44
|
+
options: {
|
|
45
|
+
clickableNavigationRoots: false, //if true, a checkbox option in dropdown menu appears
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
|
|
43
49
|
return config;
|
|
44
50
|
};
|
|
@@ -76,6 +76,10 @@ const messages = defineMessages({
|
|
|
76
76
|
id: 'dropdownmenu-deletemenuitem-button',
|
|
77
77
|
defaultMessage: 'Delete menu item',
|
|
78
78
|
},
|
|
79
|
+
clickableNavigationRoots: {
|
|
80
|
+
id: 'dropdownmenu-clickableNavigationRoots',
|
|
81
|
+
defaultMessage: 'Clickable navigation roots',
|
|
82
|
+
},
|
|
79
83
|
});
|
|
80
84
|
|
|
81
85
|
const MenuConfigurationForm = ({ id, menuItem, onChange, deleteMenuItem }) => {
|
|
@@ -117,11 +121,12 @@ const MenuConfigurationForm = ({ id, menuItem, onChange, deleteMenuItem }) => {
|
|
|
117
121
|
return () => {
|
|
118
122
|
document
|
|
119
123
|
.querySelector('form.ui.form')
|
|
120
|
-
|
|
124
|
+
?.removeEventListener('click', preventClick);
|
|
121
125
|
document.querySelectorAll('form.ui.form input').forEach((item) => {
|
|
122
|
-
item
|
|
126
|
+
item?.removeEventListener('keypress', preventEnter);
|
|
123
127
|
});
|
|
124
128
|
};
|
|
129
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
125
130
|
}, []);
|
|
126
131
|
|
|
127
132
|
const onChangeFormData = (id, value) => {
|
|
@@ -201,6 +206,22 @@ const MenuConfigurationForm = ({ id, menuItem, onChange, deleteMenuItem }) => {
|
|
|
201
206
|
}
|
|
202
207
|
/>
|
|
203
208
|
</div>
|
|
209
|
+
|
|
210
|
+
{config.settings?.['volto-dropdownmenu']?.options
|
|
211
|
+
?.clickableNavigationRoots && (
|
|
212
|
+
<div className="menu-item-field-clickableNavigationRoots">
|
|
213
|
+
<CheckboxWidget
|
|
214
|
+
id={`${id}-clickableNavigationRoots`}
|
|
215
|
+
title={intl.formatMessage(messages.clickableNavigationRoots)}
|
|
216
|
+
description=""
|
|
217
|
+
defaultValue={true}
|
|
218
|
+
value={!!menuItem.clickableNavigationRoots}
|
|
219
|
+
onChange={(id, value) =>
|
|
220
|
+
onChangeFormData('clickableNavigationRoots', value)
|
|
221
|
+
}
|
|
222
|
+
/>
|
|
223
|
+
</div>
|
|
224
|
+
)}
|
|
204
225
|
<div className="menu-item-field-showMoreLink">
|
|
205
226
|
<ObjectBrowserWidget
|
|
206
227
|
id={`${id}-showMoreLink`}
|
|
@@ -233,7 +254,6 @@ const MenuConfigurationForm = ({ id, menuItem, onChange, deleteMenuItem }) => {
|
|
|
233
254
|
}
|
|
234
255
|
/>
|
|
235
256
|
</div>
|
|
236
|
-
|
|
237
257
|
<UIForm.Field inline className="help wide" id="menu-blocks">
|
|
238
258
|
<Grid>
|
|
239
259
|
<Grid.Row stretched>
|