volto-dropdownmenu 2.4.3 → 4.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/CHANGELOG.md +11 -2
- package/README.md +27 -2
- package/babel.config.js +1 -1
- package/package.json +5 -5
- package/src/index.js +13 -2
- package/src/widget/MenuConfigurationWidget.jsx +22 -20
package/CHANGELOG.md
CHANGED
|
@@ -4,11 +4,20 @@ 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
|
-
#### [
|
|
7
|
+
#### [v4.0.0](https://github.com/collective/volto-dropdownmenu/compare/v3.0.0...v4.0.0)
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
- chore: install nodes added (Fixes #14) [`#26`](https://github.com/collective/volto-dropdownmenu/pull/26)
|
|
10
|
+
- chore: install nodes added (Fixes #14) (#26) [`#14`](https://github.com/collective/volto-dropdownmenu/issues/14)
|
|
11
|
+
- feat!: use Volto component registry for MenuConfigurationForm [`46964e9`](https://github.com/collective/volto-dropdownmenu/commit/46964e98150bb576682e72013535604ab9a3f8d5)
|
|
12
|
+
|
|
13
|
+
### [v3.0.0](https://github.com/collective/volto-dropdownmenu/compare/v2.4.3...v3.0.0)
|
|
14
|
+
|
|
15
|
+
> 30 October 2022
|
|
10
16
|
|
|
17
|
+
- refactor: upgraded dependencies and babel config for volto 16 [`#27`](https://github.com/collective/volto-dropdownmenu/pull/27)
|
|
11
18
|
- fix: a11y handle dropdown navigation [`67e97c1`](https://github.com/collective/volto-dropdownmenu/commit/67e97c1947e6a392e82c3104b5797a9c7680812f)
|
|
19
|
+
- Release 2.4.3 [`3e30ff8`](https://github.com/collective/volto-dropdownmenu/commit/3e30ff8c11ff10c3408c72c3a39728714e76f5ba)
|
|
20
|
+
- Release 3.0.0 [`9db2d0a`](https://github.com/collective/volto-dropdownmenu/commit/9db2d0a8992d4876208004b064a27e0149443fe4)
|
|
12
21
|
- chore: rollback 2.4.3 release [`07b437b`](https://github.com/collective/volto-dropdownmenu/commit/07b437b365aaabc5a05e4d7adb7086f50186b3bc)
|
|
13
22
|
|
|
14
23
|
#### [v2.4.3](https://github.com/collective/volto-dropdownmenu/compare/v2.4.2...v2.4.3)
|
package/README.md
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
# volto-dropdownmenu
|
|
2
2
|
|
|
3
|
-
Volto addon for a customizable dropdown menu.
|
|
3
|
+
Volto addon for a customizable dropdown menu.
|
|
4
4
|
Intended to be used with [collective.volto.dropdownmenu](https://github.com/collective/collective.volto.dropdownmenu)
|
|
5
5
|
|
|
6
6
|
To be used with mrs-developer, see [Volto docs](https://docs.voltocms.com/customizing/add-ons/) for further usage informations.
|
|
7
7
|
|
|
8
8
|
Created with [voltocli](https://github.com/nzambello/voltocli).
|
|
9
9
|
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
Afer installation, please add following lines into package.json to enable it.
|
|
13
|
+
|
|
14
|
+
```json
|
|
15
|
+
|
|
16
|
+
"addons": [
|
|
17
|
+
"volto-dropdownmenu"
|
|
18
|
+
],
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
|
|
10
22
|
## Usage
|
|
11
23
|
|
|
12
|
-
> If you
|
|
24
|
+
> If you are using Volto < 16, then use [v2.4.3](https://github.com/collective/volto-dropdownmenu/tree/v2.4.3)
|
|
25
|
+
>
|
|
26
|
+
> If you are using Volto < 12, then use [v1.3.0](https://github.com/collective/volto-dropdownmenu/tree/v1.3.0)
|
|
13
27
|
|
|
14
28
|
Simply load the addon in your project, then edit the configuration in `/controlpanel/dropdown-menu-settings`.
|
|
15
29
|
Example configuration to be saved in Plone [here](./menuConfigurationExample.json).
|
|
@@ -23,6 +37,17 @@ To use the default template for the dropdown menu, add `src/addons/volto-dropdow
|
|
|
23
37
|
]
|
|
24
38
|
```
|
|
25
39
|
|
|
40
|
+
To customize the `MenuConfigurationForm` component, you can now create your own component in your site and replace it using the Volto component registry in your site config file:
|
|
41
|
+
|
|
42
|
+
```javascript
|
|
43
|
+
import MyMenuConfigurationForm from './src/MyMenuConfigurationForm';
|
|
44
|
+
|
|
45
|
+
config.registerComponent({
|
|
46
|
+
name: 'MenuConfigurationForm',
|
|
47
|
+
component: MyMenuConfigurationForm,
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
26
51
|
### Navigation roots
|
|
27
52
|
|
|
28
53
|
By default, navigations roots are clickable, but there's the possibility to make them not clickable.
|
package/babel.config.js
CHANGED
package/package.json
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "volto-dropdownmenu",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Volto addon for a customizable dropdown menu",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"repository": "https://github.com/collective/volto-dropdownmenu.git",
|
|
7
7
|
"author": "collective",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"devDependencies": {
|
|
10
|
-
"
|
|
10
|
+
"@plone/scripts": "^2.0.0",
|
|
11
|
+
"release-it": "^14.10.1"
|
|
11
12
|
},
|
|
12
13
|
"scripts": {
|
|
13
14
|
"i18n": "rm -rf build/messages && NODE_ENV=production i18n --addon",
|
|
14
15
|
"release": "release-it"
|
|
15
16
|
},
|
|
16
17
|
"dependencies": {
|
|
17
|
-
"react-outside-click-handler": "1.3.0"
|
|
18
|
-
"@plone/scripts": "*"
|
|
18
|
+
"react-outside-click-handler": "1.3.0"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
|
-
"@plone/volto": ">=
|
|
21
|
+
"@plone/volto": ">=16.0.0-alpha.38"
|
|
22
22
|
}
|
|
23
23
|
}
|
package/src/index.js
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import menuSVG from '@plone/volto/icons/menu.svg';
|
|
2
2
|
import { dropdownMenuNavItemsReducer } from './reducers';
|
|
3
3
|
import MenuConfigurationWidget from './widget/MenuConfigurationWidget';
|
|
4
|
+
import MenuConfigurationForm from './widget/MenuConfigurationForm';
|
|
4
5
|
import { getDropdownMenuNavitems } from './actions';
|
|
5
6
|
import { getItemsByPath } from './utils';
|
|
6
7
|
|
|
7
|
-
export {
|
|
8
|
+
export {
|
|
9
|
+
MenuConfigurationWidget,
|
|
10
|
+
getDropdownMenuNavitems,
|
|
11
|
+
getItemsByPath,
|
|
12
|
+
MenuConfigurationForm,
|
|
13
|
+
};
|
|
8
14
|
|
|
9
15
|
export default (config) => {
|
|
10
16
|
config.widgets.id = {
|
|
@@ -12,6 +18,11 @@ export default (config) => {
|
|
|
12
18
|
menu_configuration: MenuConfigurationWidget,
|
|
13
19
|
};
|
|
14
20
|
|
|
21
|
+
config.registerComponent({
|
|
22
|
+
name: 'MenuConfigurationForm',
|
|
23
|
+
component: MenuConfigurationForm,
|
|
24
|
+
});
|
|
25
|
+
|
|
15
26
|
config.addonReducers = {
|
|
16
27
|
...config.addonReducers,
|
|
17
28
|
dropdownMenuNavItems: dropdownMenuNavItemsReducer,
|
|
@@ -24,7 +35,7 @@ export default (config) => {
|
|
|
24
35
|
extend: (dispatchActions) => {
|
|
25
36
|
if (
|
|
26
37
|
dispatchActions.filter(
|
|
27
|
-
(asyncAction) => asyncAction.key === 'dropdownMenuNavItems'
|
|
38
|
+
(asyncAction) => asyncAction.key === 'dropdownMenuNavItems'
|
|
28
39
|
).length === 0
|
|
29
40
|
) {
|
|
30
41
|
dispatchActions.push({
|
|
@@ -9,10 +9,9 @@ import {
|
|
|
9
9
|
Segment,
|
|
10
10
|
Header,
|
|
11
11
|
} from 'semantic-ui-react';
|
|
12
|
-
import { TextWidget } from '@plone/volto/components';
|
|
12
|
+
import { TextWidget, Component } from '@plone/volto/components';
|
|
13
13
|
import { flattenToAppURL } from '@plone/volto/helpers/Url/Url';
|
|
14
14
|
|
|
15
|
-
import MenuConfigurationForm from './MenuConfigurationForm';
|
|
16
15
|
import './menu_configuration.css';
|
|
17
16
|
|
|
18
17
|
const messages = defineMessages({
|
|
@@ -58,14 +57,14 @@ const messages = defineMessages({
|
|
|
58
57
|
},
|
|
59
58
|
});
|
|
60
59
|
|
|
61
|
-
const defaultMenuItem = title => ({
|
|
60
|
+
const defaultMenuItem = (title) => ({
|
|
62
61
|
title,
|
|
63
62
|
visible: true,
|
|
64
63
|
mode: 'simpleLink',
|
|
65
64
|
linkUrl: [],
|
|
66
65
|
});
|
|
67
66
|
|
|
68
|
-
const defaultRootMenu = title => ({
|
|
67
|
+
const defaultRootMenu = (title) => ({
|
|
69
68
|
rootPath: '/',
|
|
70
69
|
items: [defaultMenuItem(title)],
|
|
71
70
|
});
|
|
@@ -82,17 +81,17 @@ const MenuConfigurationWidget = ({
|
|
|
82
81
|
}) => {
|
|
83
82
|
const intl = useIntl();
|
|
84
83
|
const [menuConfiguration, setMenuConfiguration] = useState(
|
|
85
|
-
value ? JSON.parse(value) : defaultMenuConfiguration
|
|
84
|
+
value ? JSON.parse(value) : defaultMenuConfiguration
|
|
86
85
|
);
|
|
87
86
|
const [activeMenu, setActiveMenu] = useState(0);
|
|
88
87
|
const [activeMenuItem, setActiveMenuItem] = useState(0);
|
|
89
88
|
|
|
90
|
-
const handleChangeConfiguration = value => {
|
|
89
|
+
const handleChangeConfiguration = (value) => {
|
|
91
90
|
setMenuConfiguration(value);
|
|
92
91
|
onChange(id, JSON.stringify(value));
|
|
93
92
|
};
|
|
94
93
|
|
|
95
|
-
const addMenuPath = e => {
|
|
94
|
+
const addMenuPath = (e) => {
|
|
96
95
|
e.preventDefault();
|
|
97
96
|
const menuItemsNumber = menuConfiguration.length;
|
|
98
97
|
const menuItem = `/tab${menuItemsNumber}`;
|
|
@@ -168,7 +167,7 @@ const MenuConfigurationWidget = ({
|
|
|
168
167
|
newMenuConfiguration[pathIndex].items.splice(
|
|
169
168
|
menuItemIndex + (up ? -1 : 1),
|
|
170
169
|
0,
|
|
171
|
-
menuItem
|
|
170
|
+
menuItem
|
|
172
171
|
);
|
|
173
172
|
|
|
174
173
|
handleChangeConfiguration(newMenuConfiguration);
|
|
@@ -221,7 +220,7 @@ const MenuConfigurationWidget = ({
|
|
|
221
220
|
description=""
|
|
222
221
|
required={true}
|
|
223
222
|
value={flattenToAppURL(
|
|
224
|
-
menuConfiguration[activeMenu].rootPath
|
|
223
|
+
menuConfiguration[activeMenu].rootPath
|
|
225
224
|
)}
|
|
226
225
|
onChange={(id, value) => {
|
|
227
226
|
onChangeMenuPath(activeMenu, {
|
|
@@ -244,9 +243,11 @@ const MenuConfigurationWidget = ({
|
|
|
244
243
|
<Button
|
|
245
244
|
icon="trash"
|
|
246
245
|
negative
|
|
247
|
-
onClick={e => deleteMenuPath(e, activeMenu)}
|
|
246
|
+
onClick={(e) => deleteMenuPath(e, activeMenu)}
|
|
248
247
|
id="delete-menupath"
|
|
249
|
-
content={intl.formatMessage(
|
|
248
|
+
content={intl.formatMessage(
|
|
249
|
+
messages.deleteButton
|
|
250
|
+
)}
|
|
250
251
|
/>
|
|
251
252
|
</Grid.Column>
|
|
252
253
|
</Grid.Row>
|
|
@@ -277,9 +278,9 @@ const MenuConfigurationWidget = ({
|
|
|
277
278
|
size="tiny"
|
|
278
279
|
icon={<Icon name="arrow left" />}
|
|
279
280
|
title={intl.formatMessage(
|
|
280
|
-
messages.moveMenuItemUp
|
|
281
|
+
messages.moveMenuItemUp
|
|
281
282
|
)}
|
|
282
|
-
onClick={e =>
|
|
283
|
+
onClick={(e) =>
|
|
283
284
|
moveMenuItem(e, activeMenu, idx, 'up')
|
|
284
285
|
}
|
|
285
286
|
/>
|
|
@@ -293,20 +294,20 @@ const MenuConfigurationWidget = ({
|
|
|
293
294
|
size="tiny"
|
|
294
295
|
icon={<Icon name="arrow right" />}
|
|
295
296
|
title={intl.formatMessage(
|
|
296
|
-
messages.moveMenuItemDown
|
|
297
|
+
messages.moveMenuItemDown
|
|
297
298
|
)}
|
|
298
|
-
onClick={e =>
|
|
299
|
+
onClick={(e) =>
|
|
299
300
|
moveMenuItem(e, activeMenu, idx, 'down')
|
|
300
301
|
}
|
|
301
302
|
/>
|
|
302
303
|
</Button.Group>
|
|
303
304
|
<span>{menuItem.title}</span>
|
|
304
305
|
</Menu.Item>
|
|
305
|
-
)
|
|
306
|
+
)
|
|
306
307
|
)}
|
|
307
308
|
<Menu.Item
|
|
308
309
|
name={intl.formatMessage(messages.addMenuItem)}
|
|
309
|
-
onClick={e => addMenuItem(e, activeMenu)}
|
|
310
|
+
onClick={(e) => addMenuItem(e, activeMenu)}
|
|
310
311
|
>
|
|
311
312
|
<Icon name="plus" />
|
|
312
313
|
</Menu.Item>
|
|
@@ -316,17 +317,18 @@ const MenuConfigurationWidget = ({
|
|
|
316
317
|
{activeMenuItem > -1 &&
|
|
317
318
|
activeMenuItem <
|
|
318
319
|
menuConfiguration[activeMenu].items?.length ? (
|
|
319
|
-
<
|
|
320
|
+
<Component
|
|
321
|
+
componentName="MenuConfigurationForm"
|
|
320
322
|
id={`${activeMenu}-${activeMenuItem}`}
|
|
321
323
|
menuItem={
|
|
322
324
|
menuConfiguration[activeMenu].items[
|
|
323
325
|
activeMenuItem
|
|
324
326
|
]
|
|
325
327
|
}
|
|
326
|
-
onChange={menu =>
|
|
328
|
+
onChange={(menu) =>
|
|
327
329
|
onChangeMenuItem(activeMenu, activeMenuItem, menu)
|
|
328
330
|
}
|
|
329
|
-
deleteMenuItem={e =>
|
|
331
|
+
deleteMenuItem={(e) =>
|
|
330
332
|
deleteMenuItem(e, activeMenu, activeMenuItem)
|
|
331
333
|
}
|
|
332
334
|
/>
|