@plone/volto 19.0.0-alpha.32 → 19.0.0-alpha.34
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/AGENTS.md +47 -0
- package/CHANGELOG.md +27 -0
- package/README.md +0 -1
- package/package.json +16 -19
- package/src/actions/controlpanels/controlpanels.js +7 -12
- package/src/actions/controlpanels/controlpanels.test.js +2 -3
- package/src/components/manage/Contents/Contents.jsx +410 -323
- package/src/components/manage/Contents/Contents.test.jsx +1 -1
- package/src/components/manage/Contents/ContentsIndexHeader.jsx +47 -81
- package/src/components/manage/Contents/ContentsIndexHeader.test.jsx +10 -3
- package/src/components/manage/Contents/ContentsItem.jsx +226 -278
- package/src/components/manage/Contents/ContentsItem.test.jsx +10 -6
- package/src/components/manage/Controlpanels/ContentType.jsx +131 -222
- package/src/components/manage/Controlpanels/Controlpanel.jsx +122 -218
- package/src/components/manage/Controlpanels/Controlpanel.test.jsx +1 -29
- package/src/components/manage/Form/Field.jsx +1 -69
- package/src/components/manage/Widgets/ArrayWidget.jsx +111 -88
- package/src/components/manage/Widgets/ArrayWidget.test.jsx +0 -6
- package/src/components/manage/Widgets/RecurrenceWidget/WeekdayOfTheMonthIndexField.jsx +56 -50
- package/src/components/manage/Widgets/SelectStyling.jsx +52 -20
- package/src/config/Loadables.jsx +1 -5
- package/src/server.jsx +7 -1
- package/theme/themes/default/globals/site.variables +3 -3
- package/theme/themes/pastanaga/extras/contents.less +0 -4
- package/theme/themes/pastanaga/globals/site.variables +0 -3
- package/types/components/manage/Contents/Contents.d.ts +1 -1
- package/types/components/manage/Contents/ContentsIndexHeader.d.ts +6 -11
- package/types/components/manage/Contents/ContentsItem.d.ts +3 -10
- package/types/components/manage/Controlpanels/ContentType.d.ts +2 -2
- package/types/components/manage/Controlpanels/Controlpanel.d.ts +2 -5
- package/types/components/manage/Controlpanels/index.d.ts +2 -2
- package/types/components/manage/Widgets/RecurrenceWidget/WeekdayOfTheMonthIndexField.d.ts +22 -5
- package/types/components/manage/Widgets/SelectStyling.d.ts +1 -0
|
@@ -4,7 +4,7 @@ import configureStore from 'redux-mock-store';
|
|
|
4
4
|
import { Provider } from 'react-intl-redux';
|
|
5
5
|
import { MemoryRouter } from 'react-router-dom';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { ContentsComponent as Contents } from './Contents';
|
|
8
8
|
|
|
9
9
|
const mockStore = configureStore();
|
|
10
10
|
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Contents index header component.
|
|
3
|
-
* @module components/manage/Contents/ContentsIndexHeader
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
1
|
import React from 'react';
|
|
7
2
|
import PropTypes from 'prop-types';
|
|
8
|
-
import {
|
|
3
|
+
import { useIntl } from 'react-intl';
|
|
9
4
|
import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable';
|
|
10
5
|
|
|
11
6
|
const widthValues = [
|
|
@@ -27,32 +22,52 @@ const widthValues = [
|
|
|
27
22
|
'sixteen',
|
|
28
23
|
];
|
|
29
24
|
|
|
30
|
-
/**
|
|
31
|
-
* Contents index header component class.
|
|
32
|
-
* @function ContentsIndexHeaderComponent
|
|
33
|
-
* @returns {string} Markup of the component.
|
|
34
|
-
*/
|
|
35
25
|
export const ContentsIndexHeaderComponent = ({
|
|
36
|
-
|
|
26
|
+
id,
|
|
37
27
|
width,
|
|
38
28
|
label,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
29
|
+
dndKitSortable,
|
|
30
|
+
dndKitUtilities,
|
|
31
|
+
}) => {
|
|
32
|
+
const intl = useIntl();
|
|
33
|
+
|
|
34
|
+
const { useSortable } = dndKitSortable;
|
|
35
|
+
const { CSS } = dndKitUtilities;
|
|
36
|
+
const {
|
|
37
|
+
attributes,
|
|
38
|
+
listeners,
|
|
39
|
+
setNodeRef,
|
|
40
|
+
transform,
|
|
41
|
+
transition,
|
|
42
|
+
isDragging,
|
|
43
|
+
} = useSortable({
|
|
44
|
+
id: `index:${id}`,
|
|
45
|
+
data: {
|
|
46
|
+
type: 'index',
|
|
47
|
+
indexId: id,
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<th
|
|
53
|
+
ref={setNodeRef}
|
|
54
|
+
className={`${widthValues[width - 2]} wide`}
|
|
55
|
+
style={{
|
|
56
|
+
transform: CSS.Transform.toString(transform),
|
|
57
|
+
transition,
|
|
58
|
+
opacity: isDragging ? 0.5 : 1,
|
|
59
|
+
cursor: 'move',
|
|
60
|
+
}}
|
|
61
|
+
{...attributes}
|
|
62
|
+
{...listeners}
|
|
63
|
+
>
|
|
64
|
+
{intl.formatMessage({
|
|
65
|
+
id: label,
|
|
66
|
+
defaultMessage: label,
|
|
67
|
+
})}
|
|
68
|
+
</th>
|
|
55
69
|
);
|
|
70
|
+
};
|
|
56
71
|
|
|
57
72
|
/**
|
|
58
73
|
* Property types.
|
|
@@ -60,60 +75,11 @@ export const ContentsIndexHeaderComponent = ({
|
|
|
60
75
|
* @static
|
|
61
76
|
*/
|
|
62
77
|
ContentsIndexHeaderComponent.propTypes = {
|
|
78
|
+
id: PropTypes.string.isRequired,
|
|
63
79
|
width: PropTypes.number.isRequired,
|
|
64
80
|
label: PropTypes.string.isRequired,
|
|
65
|
-
connectDragSource: PropTypes.func.isRequired,
|
|
66
|
-
connectDropTarget: PropTypes.func.isRequired,
|
|
67
|
-
isDragging: PropTypes.bool.isRequired,
|
|
68
|
-
order: PropTypes.number.isRequired,
|
|
69
|
-
onOrderIndex: PropTypes.func.isRequired,
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
const DragDropConnector = (props) => {
|
|
73
|
-
const { DropTarget, DragSource } = props.reactDnd;
|
|
74
|
-
|
|
75
|
-
const DndConnectedContentsIndexHeader = React.useMemo(
|
|
76
|
-
() =>
|
|
77
|
-
DropTarget(
|
|
78
|
-
'index',
|
|
79
|
-
{
|
|
80
|
-
hover(props, monitor) {
|
|
81
|
-
const dragOrder = monitor.getItem().order;
|
|
82
|
-
const hoverOrder = props.order;
|
|
83
|
-
|
|
84
|
-
if (dragOrder === hoverOrder) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
props.onOrderIndex(dragOrder, hoverOrder - dragOrder);
|
|
89
|
-
|
|
90
|
-
monitor.getItem().order = hoverOrder;
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
(connect) => ({
|
|
94
|
-
connectDropTarget: connect.dropTarget(),
|
|
95
|
-
}),
|
|
96
|
-
)(
|
|
97
|
-
DragSource(
|
|
98
|
-
'index',
|
|
99
|
-
{
|
|
100
|
-
beginDrag(props) {
|
|
101
|
-
return {
|
|
102
|
-
id: props.label,
|
|
103
|
-
order: props.order,
|
|
104
|
-
};
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
(connect, monitor) => ({
|
|
108
|
-
connectDragSource: connect.dragSource(),
|
|
109
|
-
isDragging: monitor.isDragging(),
|
|
110
|
-
}),
|
|
111
|
-
)(injectIntl(ContentsIndexHeaderComponent)),
|
|
112
|
-
),
|
|
113
|
-
[DragSource, DropTarget],
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
return <DndConnectedContentsIndexHeader {...props} />;
|
|
117
81
|
};
|
|
118
82
|
|
|
119
|
-
export default injectLazyLibs('
|
|
83
|
+
export default injectLazyLibs(['dndKitSortable', 'dndKitUtilities'])(
|
|
84
|
+
ContentsIndexHeaderComponent,
|
|
85
|
+
);
|
|
@@ -8,6 +8,15 @@ import ContentsIndexHeader from './ContentsIndexHeader';
|
|
|
8
8
|
|
|
9
9
|
const mockStore = configureStore([thunk]);
|
|
10
10
|
|
|
11
|
+
vi.mock('@plone/volto/helpers/Loadable/Loadable');
|
|
12
|
+
|
|
13
|
+
beforeAll(async () => {
|
|
14
|
+
const { __setLoadables } = await import(
|
|
15
|
+
'@plone/volto/helpers/Loadable/Loadable'
|
|
16
|
+
);
|
|
17
|
+
await __setLoadables();
|
|
18
|
+
});
|
|
19
|
+
|
|
11
20
|
describe('ContentsIndexHeader', () => {
|
|
12
21
|
it('renders a contents titles component', () => {
|
|
13
22
|
const store = mockStore({
|
|
@@ -19,11 +28,9 @@ describe('ContentsIndexHeader', () => {
|
|
|
19
28
|
const component = renderer.create(
|
|
20
29
|
<Provider store={store}>
|
|
21
30
|
<ContentsIndexHeader
|
|
31
|
+
id="review_state"
|
|
22
32
|
width={1}
|
|
23
33
|
label="Review state"
|
|
24
|
-
onOrderIndex={() => {}}
|
|
25
|
-
connectDragSource={(x) => x}
|
|
26
|
-
connectDropTarget={(x) => x}
|
|
27
34
|
order={1}
|
|
28
35
|
isDragging={false}
|
|
29
36
|
/>
|