io-sanita-theme 2.5.2 → 2.5.3
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 +6 -0
- package/package.json +1 -1
- package/src/components/Blocks/SearchBandi/Body.jsx +4 -2
- package/src/components/Blocks/SearchFarmacia/Body.jsx +2 -1
- package/src/components/Blocks/SearchServiziProcedure/Body.jsx +3 -1
- package/src/components/Cards/CardSimple/CardSimple.jsx +9 -4
- package/src/components/View/commons/SideMenu/SideMenu.jsx +5 -18
- package/src/customizations/volto/components/manage/Blocks/Listing/ListingBody.jsx +6 -3
- package/src/helpers/ClientPagination/clientPagination.js +2 -3
- package/src/helpers/index.js +3 -0
- package/src/helpers/scroll.js +22 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.5.3](https://github.com/RedTurtle/io-sanita-theme/compare/2.5.2...2.5.3) (2025-03-05)
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* scroll bhv in paginations ([00b84e9](https://github.com/RedTurtle/io-sanita-theme/commit/00b84e9e2d8386552632fa92b968e59485638d1d))
|
|
8
|
+
|
|
3
9
|
## [2.5.2](https://github.com/RedTurtle/io-sanita-theme/compare/2.5.1...2.5.2) (2025-03-05)
|
|
4
10
|
|
|
5
11
|
### Bug Fixes
|
package/package.json
CHANGED
|
@@ -10,6 +10,7 @@ import { flattenToAppURL } from '@plone/volto/helpers/Url/Url';
|
|
|
10
10
|
import { BandiTemplate } from 'io-sanita-theme/components/Blocks';
|
|
11
11
|
import { Pagination } from 'io-sanita-theme/components';
|
|
12
12
|
import { resetQuerystringResults } from 'io-sanita-theme/actions';
|
|
13
|
+
import { scrollIntoView } from 'io-sanita-theme/helpers';
|
|
13
14
|
|
|
14
15
|
const messages = defineMessages({
|
|
15
16
|
find: {
|
|
@@ -146,8 +147,9 @@ const Body = ({ data, id, inEditMode, path, onChangeBlock, blocksConfig }) => {
|
|
|
146
147
|
);
|
|
147
148
|
|
|
148
149
|
function handleQueryPaginationChange(e, { activePage }) {
|
|
149
|
-
|
|
150
|
-
|
|
150
|
+
scrollIntoView({ ref: resultsRef.current });
|
|
151
|
+
|
|
152
|
+
const current = activePage?.children ?? activePage ?? 1;
|
|
151
153
|
setCurrentPage(current);
|
|
152
154
|
doRequest(current);
|
|
153
155
|
}
|
|
@@ -14,6 +14,7 @@ import SearchFilters from './SearchFilters';
|
|
|
14
14
|
|
|
15
15
|
/* Style */
|
|
16
16
|
import './search-farmacia.scss';
|
|
17
|
+
import { scrollIntoView } from 'io-sanita-theme/helpers';
|
|
17
18
|
|
|
18
19
|
const messages = defineMessages({
|
|
19
20
|
results: {
|
|
@@ -205,7 +206,7 @@ const Body = ({ isEditMode, data, id }) => {
|
|
|
205
206
|
activeScroll = true,
|
|
206
207
|
) => {
|
|
207
208
|
if (resultsRef.current && activeScroll) {
|
|
208
|
-
|
|
209
|
+
scrollIntoView({ ref: resultsRef.current });
|
|
209
210
|
}
|
|
210
211
|
setCurrentPage(activePage || 1);
|
|
211
212
|
};
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
SortByWidget,
|
|
16
16
|
LinkedHeadline,
|
|
17
17
|
} from 'io-sanita-theme/components';
|
|
18
|
+
import { scrollIntoView } from 'io-sanita-theme/helpers';
|
|
18
19
|
|
|
19
20
|
const messages = defineMessages({
|
|
20
21
|
results: {
|
|
@@ -190,7 +191,7 @@ const Body = ({ data, id, path, properties, inEditMode }) => {
|
|
|
190
191
|
activeScroll = true,
|
|
191
192
|
) => {
|
|
192
193
|
if (resultsRef.current && activeScroll) {
|
|
193
|
-
|
|
194
|
+
scrollIntoView({ ref: resultsRef.current });
|
|
194
195
|
}
|
|
195
196
|
const current = activePage ?? 1;
|
|
196
197
|
setCurrentPage(current);
|
|
@@ -237,6 +238,7 @@ const Body = ({ data, id, path, properties, inEditMode }) => {
|
|
|
237
238
|
(data.portal_type === 'Servizio'
|
|
238
239
|
? intl.formatMessage(messages.searchable_text_default_label_servizi)
|
|
239
240
|
: intl.formatMessage(messages.searchable_text_default_label_procedura));
|
|
241
|
+
|
|
240
242
|
return (
|
|
241
243
|
<div className="block iosanita-block-search servizi-procedure">
|
|
242
244
|
<div className="full-width bg-primary-lightest py-4">
|
|
@@ -30,6 +30,7 @@ export const CardSimple = ({
|
|
|
30
30
|
titleTag = 'h5',
|
|
31
31
|
titleDataElement,
|
|
32
32
|
highlight, //se si vuole evidenziare un testo, ad esempio nei risultati delle ricerche
|
|
33
|
+
badgeText,
|
|
33
34
|
}) => {
|
|
34
35
|
const intl = useIntl();
|
|
35
36
|
const date =
|
|
@@ -61,11 +62,13 @@ export const CardSimple = ({
|
|
|
61
62
|
) : (
|
|
62
63
|
item.description
|
|
63
64
|
);
|
|
65
|
+
|
|
66
|
+
const display_badge = isServizioOnline || badgeText?.length > 0;
|
|
64
67
|
return (
|
|
65
68
|
<Card className={`shadow rounded no-after card-simple ${className ?? ''}`}>
|
|
66
69
|
<CardBody>
|
|
67
70
|
<div className="card-body-main">
|
|
68
|
-
<CardTitle tag={titleTag} className={
|
|
71
|
+
<CardTitle tag={titleTag} className={display_badge ? 'mb-1' : ''}>
|
|
69
72
|
{item['@id'] ? (
|
|
70
73
|
<UniversalLink
|
|
71
74
|
item={!isEditMode ? item : null}
|
|
@@ -80,11 +83,13 @@ export const CardSimple = ({
|
|
|
80
83
|
)}
|
|
81
84
|
</CardTitle>
|
|
82
85
|
|
|
83
|
-
{/* Chip servizio attivo */}
|
|
84
|
-
{
|
|
86
|
+
{/* Chip badge: servizio attivo per servizi o badge con badgeText */}
|
|
87
|
+
{display_badge && (
|
|
85
88
|
<div className={showDescription ? 'mb-3' : ''}>
|
|
86
89
|
<Badge color="info">
|
|
87
|
-
{
|
|
90
|
+
{isServizioOnline
|
|
91
|
+
? intl.formatMessage(messages.servizioOnline)
|
|
92
|
+
: badgeText}
|
|
88
93
|
</Badge>
|
|
89
94
|
</div>
|
|
90
95
|
)}
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
AccordionHeader,
|
|
16
16
|
} from 'design-react-kit';
|
|
17
17
|
import config from '@plone/volto/registry';
|
|
18
|
+
import { scrollIntoView, getMainOffset } from 'io-sanita-theme/helpers';
|
|
18
19
|
import './_sideMenu.scss';
|
|
19
20
|
|
|
20
21
|
const messages = defineMessages({
|
|
@@ -91,14 +92,6 @@ const SideMenu = ({ data, content_uid }) => {
|
|
|
91
92
|
headers?.[0]?.title ??
|
|
92
93
|
intl.formatMessage(messages.progressBar);
|
|
93
94
|
|
|
94
|
-
const getMainOffset = () => {
|
|
95
|
-
return isClient
|
|
96
|
-
? document.querySelector('.it-header-wrapper.it-header-sticky')
|
|
97
|
-
?.clientHeight + 20
|
|
98
|
-
: 0;
|
|
99
|
-
};
|
|
100
|
-
const mainOffset = getMainOffset();
|
|
101
|
-
|
|
102
95
|
const handleScroll = useCallback(() => {
|
|
103
96
|
const windowHeight = window.innerHeight * 0.1;
|
|
104
97
|
const mainOffset = getMainOffset();
|
|
@@ -161,16 +154,8 @@ const SideMenu = ({ data, content_uid }) => {
|
|
|
161
154
|
// Scroll to section
|
|
162
155
|
// setTimeout hack should wait for rerender after setIsNavOpen
|
|
163
156
|
setTimeout(() => {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
// block: 'start',
|
|
167
|
-
// });
|
|
168
|
-
|
|
169
|
-
window.scrollTo({
|
|
170
|
-
behavior: 'smooth',
|
|
171
|
-
top: document.querySelector('#' + id).offsetTop - mainOffset,
|
|
172
|
-
});
|
|
173
|
-
}, 0);
|
|
157
|
+
scrollIntoView({ id });
|
|
158
|
+
});
|
|
174
159
|
};
|
|
175
160
|
|
|
176
161
|
const progressValue = useMemo(() => {
|
|
@@ -180,6 +165,8 @@ const SideMenu = ({ data, content_uid }) => {
|
|
|
180
165
|
: 0;
|
|
181
166
|
}, [scrollY, isClient]);
|
|
182
167
|
|
|
168
|
+
const mainOffset = getMainOffset();
|
|
169
|
+
|
|
183
170
|
return headers?.length > 0 ? (
|
|
184
171
|
<div
|
|
185
172
|
className="navbar-wrapper page-side-menu affix-top"
|
|
@@ -26,7 +26,10 @@ import {
|
|
|
26
26
|
ListingContainer,
|
|
27
27
|
//getPathFiltersButtons,
|
|
28
28
|
} from 'io-sanita-theme/components/Blocks';
|
|
29
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
checkRichTextHasContent,
|
|
31
|
+
scrollIntoView,
|
|
32
|
+
} from 'io-sanita-theme/helpers';
|
|
30
33
|
import config from '@plone/volto/registry';
|
|
31
34
|
|
|
32
35
|
const Headline = ({ headlineTag, id, data = {}, listingItems, isEditMode }) => {
|
|
@@ -207,8 +210,8 @@ const ListingBody = withQuerystringResults((props) => {
|
|
|
207
210
|
}
|
|
208
211
|
|
|
209
212
|
if (!isEditMode && page != currentPage) {
|
|
210
|
-
|
|
211
|
-
|
|
213
|
+
scrollIntoView({
|
|
214
|
+
ref: listingRef.current,
|
|
212
215
|
});
|
|
213
216
|
}
|
|
214
217
|
onPaginationChange(e, {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { useEffect, useState, createRef } from 'react';
|
|
2
|
+
import { scrollIntoView } from 'io-sanita-theme/helpers';
|
|
2
3
|
|
|
3
4
|
export const useClientPagination = ({ items, b_size = 4 }) => {
|
|
4
5
|
const [currentPage, setCurrentPage] = useState(1);
|
|
@@ -16,9 +17,7 @@ export const useClientPagination = ({ items, b_size = 4 }) => {
|
|
|
16
17
|
const onPaginationChange = (activePage) => {
|
|
17
18
|
let page = activePage;
|
|
18
19
|
if (page != currentPage && ref?.current) {
|
|
19
|
-
ref.current
|
|
20
|
-
behavior: 'smooth',
|
|
21
|
-
});
|
|
20
|
+
scrollIntoView({ ref: ref.current });
|
|
22
21
|
}
|
|
23
22
|
setCurrentPage(page);
|
|
24
23
|
};
|
package/src/helpers/index.js
CHANGED
|
@@ -81,3 +81,6 @@ export { getComponentWithFallback } from 'io-sanita-theme/helpers/registry';
|
|
|
81
81
|
export SchemaOrg, {
|
|
82
82
|
SchemaOrgUtils,
|
|
83
83
|
} from 'io-sanita-theme/helpers/SchemaOrg/SchemaOrg';
|
|
84
|
+
|
|
85
|
+
//scroll
|
|
86
|
+
export { scrollIntoView, getMainOffset } from 'io-sanita-theme/helpers/scroll';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/* scrollIntoView:
|
|
2
|
+
pass ref prop (reactRef) or html id if item
|
|
3
|
+
*/
|
|
4
|
+
export const getMainOffset = () => {
|
|
5
|
+
return __CLIENT__
|
|
6
|
+
? document.querySelector('.it-header-wrapper.it-header-sticky')
|
|
7
|
+
?.clientHeight + 20
|
|
8
|
+
: 0;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const scrollIntoView = ({ ref, id, behavior = 'smooth' }) => {
|
|
12
|
+
const mainOffset = getMainOffset();
|
|
13
|
+
|
|
14
|
+
const top = id
|
|
15
|
+
? document.querySelector('#' + id).offsetTop - mainOffset
|
|
16
|
+
: ref.getBoundingClientRect().top + window.scrollY - mainOffset;
|
|
17
|
+
|
|
18
|
+
window.scrollTo({
|
|
19
|
+
behavior,
|
|
20
|
+
top: top,
|
|
21
|
+
});
|
|
22
|
+
};
|