@porsche-design-system/components-react 3.1.0-rc.2 → 3.2.0-rc.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 +45 -6
- package/esm/lib/components/carousel.wrapper.js +3 -3
- package/esm/lib/components/pagination.wrapper.js +3 -3
- package/lib/components/carousel.wrapper.d.ts +8 -0
- package/lib/components/carousel.wrapper.js +3 -3
- package/lib/components/pagination.wrapper.d.ts +10 -2
- package/lib/components/pagination.wrapper.js +3 -3
- package/lib/types.d.ts +199 -199
- package/package.json +2 -2
- package/ssr/components/dist/styles/esm/styles-entry.js +79 -37
- package/ssr/components/dist/utils/esm/utils-entry.js +55 -89
- package/ssr/components-react/projects/react-ssr-wrapper/src/lib/components/carousel.wrapper.js +4 -4
- package/ssr/components-react/projects/react-ssr-wrapper/src/lib/components/pagination.wrapper.js +4 -4
- package/ssr/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/carousel.js +5 -4
- package/ssr/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/pagination.js +7 -6
- package/ssr/esm/components/dist/styles/esm/styles-entry.js +79 -37
- package/ssr/esm/components/dist/utils/esm/utils-entry.js +55 -89
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/components/carousel.wrapper.js +4 -4
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/components/pagination.wrapper.js +4 -4
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/carousel.js +5 -4
- package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/pagination.js +8 -7
- package/ssr/lib/components/carousel.wrapper.d.ts +8 -0
- package/ssr/lib/components/pagination.wrapper.d.ts +10 -2
- package/ssr/lib/dsr-components/pagination.d.ts +0 -1
- package/ssr/lib/types.d.ts +199 -199
|
@@ -156,14 +156,17 @@ const hasVisibleIcon = (iconName, iconSource) => {
|
|
|
156
156
|
};
|
|
157
157
|
|
|
158
158
|
const childrenMutationMap = new Map();
|
|
159
|
-
const getObservedNode = (mutatedNode) => childrenMutationMap.has(mutatedNode) ? mutatedNode : getObservedNode(mutatedNode.parentNode);
|
|
160
159
|
hasWindow &&
|
|
161
160
|
new MutationObserver((mutations) => {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
161
|
+
// there may be race conditions in jsdom-polyfill tests where the map is already empty when a mutation happens
|
|
162
|
+
if (childrenMutationMap.size) {
|
|
163
|
+
const mapKeys = Array.from(childrenMutationMap.keys());
|
|
164
|
+
mutations
|
|
165
|
+
// remove duplicates so we execute callback only once per node
|
|
166
|
+
.filter((mutation, idx, arr) => arr.findIndex((m) => m.target === mutation.target) === idx)
|
|
167
|
+
// find node in map that contains the mutated element to find and invoke its callback
|
|
168
|
+
.forEach((mutation) => { var _a; return (_a = childrenMutationMap.get(mapKeys.find((node) => node.contains(mutation.target)))) === null || _a === void 0 ? void 0 : _a(); });
|
|
169
|
+
}
|
|
167
170
|
});
|
|
168
171
|
|
|
169
172
|
const isTouchDevice = () => {
|
|
@@ -2757,7 +2760,7 @@ function convertCase(style) {
|
|
|
2757
2760
|
*/
|
|
2758
2761
|
|
|
2759
2762
|
|
|
2760
|
-
function camelCase
|
|
2763
|
+
function camelCase() {
|
|
2761
2764
|
function onProcessStyle(style) {
|
|
2762
2765
|
if (Array.isArray(style)) {
|
|
2763
2766
|
// Handle rules like @font-face, which can have multiple styles in an array
|
|
@@ -3627,7 +3630,7 @@ createJss({
|
|
|
3627
3630
|
plugins: [
|
|
3628
3631
|
jssGlobal(),
|
|
3629
3632
|
jssNested(),
|
|
3630
|
-
camelCase
|
|
3633
|
+
camelCase(),
|
|
3631
3634
|
jssPluginSortMediaQueries({ combineMediaQueries: true }),
|
|
3632
3635
|
],
|
|
3633
3636
|
});
|
|
@@ -3681,7 +3684,11 @@ const getButtonAriaAttributes = (isDisabled, isLoading, aria) => {
|
|
|
3681
3684
|
};
|
|
3682
3685
|
getMediaQueryMin('s');
|
|
3683
3686
|
getMediaQueryMin('xxl');
|
|
3684
|
-
|
|
3687
|
+
// Infinite bullets will be shown if the total number of bullets is greater than this value
|
|
3688
|
+
const INFINITE_BULLET_THRESHOLD = 5;
|
|
3689
|
+
const isInfinitePagination = (amountOfPages) => {
|
|
3690
|
+
return amountOfPages > INFINITE_BULLET_THRESHOLD;
|
|
3691
|
+
};
|
|
3685
3692
|
|
|
3686
3693
|
const CDN_BASE_URL$3 = (typeof window !== 'undefined' && window.PORSCHE_DESIGN_SYSTEM_CDN === 'cn' ? 'https://cdn.ui.porsche.cn' : 'https://cdn.ui.porsche.com') + '/porsche-design-system/crest';
|
|
3687
3694
|
const CRESTS_MANIFEST = { "porscheCrest": { "1x": { "png": "porsche-crest.min.d76137cf8cf94822b7aedb534ba88418@1x.png", "webp": "porsche-crest.min.0d0cc89ae5ee57c4c15bd0dbbcbfe5d0@1x.webp" }, "2x": { "png": "porsche-crest.min.8a292fbd35a5155789ddd011585e05c4@2x.png", "webp": "porsche-crest.min.2245c45e99be5a46b4b56e73c43d5c63@2x.webp" }, "3x": { "png": "porsche-crest.min.18d6f02003b0829bac939fade88fd4e6@3x.png", "webp": "porsche-crest.min.19b429278b158b5cb5aa6ce80751e3fe@3x.webp" } } };
|
|
@@ -3810,38 +3817,21 @@ const getSvgUrl = (model) => {
|
|
|
3810
3817
|
return `${cdnBaseUrl}/${MODEL_SIGNATURES_MANIFEST[model]}`;
|
|
3811
3818
|
};
|
|
3812
3819
|
const modelSignatureHeight = 36;
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
PAGE
|
|
3816
|
-
ELLIPSIS
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
};
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
FIRST_ELLIPSIS: -1,
|
|
3823
|
-
SECOND_ELLIPSIS: -2,
|
|
3824
|
-
PREVIOUS_PAGE_LINK: -4,
|
|
3825
|
-
NEXT_PAGE_LINK: -5,
|
|
3826
|
-
};
|
|
3827
|
-
// TODO: merge factories
|
|
3828
|
-
const createFirstEllipsis = (pageNumber) => ({
|
|
3829
|
-
type: itemTypes.ELLIPSIS,
|
|
3830
|
-
key: itemKeys.FIRST_ELLIPSIS,
|
|
3831
|
-
value: pageNumber,
|
|
3832
|
-
isActive: false,
|
|
3833
|
-
});
|
|
3834
|
-
const createSecondEllipsis = (pageNumber) => ({
|
|
3835
|
-
type: itemTypes.ELLIPSIS,
|
|
3836
|
-
key: itemKeys.SECOND_ELLIPSIS,
|
|
3837
|
-
value: pageNumber,
|
|
3820
|
+
var ItemType;
|
|
3821
|
+
(function (ItemType) {
|
|
3822
|
+
ItemType[ItemType["PAGE"] = 0] = "PAGE";
|
|
3823
|
+
ItemType[ItemType["ELLIPSIS"] = 1] = "ELLIPSIS";
|
|
3824
|
+
ItemType[ItemType["PREVIOUS"] = 2] = "PREVIOUS";
|
|
3825
|
+
ItemType[ItemType["NEXT"] = 3] = "NEXT";
|
|
3826
|
+
})(ItemType || (ItemType = {}));
|
|
3827
|
+
const ellipsisItem = {
|
|
3828
|
+
type: ItemType.ELLIPSIS,
|
|
3838
3829
|
isActive: false,
|
|
3839
|
-
}
|
|
3830
|
+
};
|
|
3840
3831
|
const createPreviousPageLink = (options) => {
|
|
3841
3832
|
const { activePage } = options;
|
|
3842
3833
|
return {
|
|
3843
|
-
type:
|
|
3844
|
-
key: itemKeys.PREVIOUS_PAGE_LINK,
|
|
3834
|
+
type: ItemType.PREVIOUS,
|
|
3845
3835
|
value: Math.max(1, activePage - 1),
|
|
3846
3836
|
isActive: activePage > 1,
|
|
3847
3837
|
};
|
|
@@ -3849,78 +3839,58 @@ const createPreviousPageLink = (options) => {
|
|
|
3849
3839
|
const createNextPageLink = (options) => {
|
|
3850
3840
|
const { activePage, pageTotal } = options;
|
|
3851
3841
|
return {
|
|
3852
|
-
type:
|
|
3853
|
-
key: itemKeys.NEXT_PAGE_LINK,
|
|
3842
|
+
type: ItemType.NEXT,
|
|
3854
3843
|
value: Math.min(pageTotal, activePage + 1),
|
|
3855
3844
|
isActive: activePage < pageTotal,
|
|
3856
3845
|
};
|
|
3857
3846
|
};
|
|
3858
3847
|
const createPageFunctionFactory = (options) => {
|
|
3859
|
-
const { activePage } = options;
|
|
3860
3848
|
return (pageNumber) => ({
|
|
3861
|
-
type:
|
|
3862
|
-
key: pageNumber,
|
|
3849
|
+
type: ItemType.PAGE,
|
|
3863
3850
|
value: pageNumber,
|
|
3864
|
-
isActive: pageNumber === activePage,
|
|
3851
|
+
isActive: pageNumber === options.activePage,
|
|
3865
3852
|
});
|
|
3866
3853
|
};
|
|
3867
3854
|
const createRange = (start, end) => Array.from(Array(end - start + 1)).map((_, i) => i + start);
|
|
3868
3855
|
const createPaginationModel = (options) => {
|
|
3869
|
-
|
|
3870
|
-
if (options == null) {
|
|
3871
|
-
throw new Error('createPaginationModel(): options object should be a passed');
|
|
3872
|
-
}
|
|
3873
|
-
const { pageTotal, activePage, pageRange } = options;
|
|
3856
|
+
const { pageTotal, activePage, pageRange, showLastPage } = options;
|
|
3874
3857
|
const boundaryPagesRange = 1;
|
|
3875
3858
|
const ellipsisSize = 1;
|
|
3876
|
-
const paginationModel = [];
|
|
3859
|
+
const paginationModel = [createPreviousPageLink(options)];
|
|
3877
3860
|
const createPage = createPageFunctionFactory(options);
|
|
3878
|
-
paginationModel.push(createPreviousPageLink(options));
|
|
3879
3861
|
// Simplify generation of pages if number of available items is equal or greater than total pages to show
|
|
3880
3862
|
if (1 + 2 * ellipsisSize + 2 * pageRange + 2 * boundaryPagesRange >= pageTotal) {
|
|
3881
3863
|
const allPages = createRange(1, pageTotal).map(createPage);
|
|
3882
3864
|
paginationModel.push(...allPages);
|
|
3883
3865
|
}
|
|
3884
3866
|
else {
|
|
3885
|
-
//
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
const
|
|
3889
|
-
|
|
3890
|
-
const
|
|
3891
|
-
|
|
3892
|
-
const
|
|
3893
|
-
|
|
3894
|
-
const
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
const
|
|
3901
|
-
const
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
// Calculate and add ellipsis after group of main pages
|
|
3908
|
-
const secondEllipsisPageNumber = mainPagesEnd + 1;
|
|
3909
|
-
const showPageInsteadOfSecondEllipsis = secondEllipsisPageNumber === lastPagesStart - 1;
|
|
3910
|
-
const createSecondEllipsisOrPage = showPageInsteadOfSecondEllipsis ? createPage : createSecondEllipsis;
|
|
3911
|
-
const secondEllipsis = createSecondEllipsisOrPage(secondEllipsisPageNumber);
|
|
3912
|
-
paginationModel.push(secondEllipsis);
|
|
3913
|
-
// Add group of last pages
|
|
3914
|
-
paginationModel.push(...lastPages);
|
|
3867
|
+
// Add first page
|
|
3868
|
+
paginationModel.push(createPage(1));
|
|
3869
|
+
// Calculate group of middle pages
|
|
3870
|
+
const middlePagesStart = Math.min(Math.max(activePage - pageRange, 2 + ellipsisSize), pageTotal - ellipsisSize - 2 * pageRange - (showLastPage ? 1 : 0));
|
|
3871
|
+
const middlePagesEnd = middlePagesStart + 2 * pageRange;
|
|
3872
|
+
const middlePages = createRange(middlePagesStart, middlePagesEnd).map(createPage);
|
|
3873
|
+
// Calculate and add ellipsis before group of middle pages
|
|
3874
|
+
const firstEllipsisPageNumber = middlePagesStart - 1;
|
|
3875
|
+
const showPageInsteadOfFirstEllipsis = firstEllipsisPageNumber === 2;
|
|
3876
|
+
const firstEllipsisOrPage = showPageInsteadOfFirstEllipsis ? createPage(firstEllipsisPageNumber) : ellipsisItem;
|
|
3877
|
+
paginationModel.push(firstEllipsisOrPage);
|
|
3878
|
+
// Add group of middle pages
|
|
3879
|
+
paginationModel.push(...middlePages);
|
|
3880
|
+
// Calculate and add ellipsis after group of middle pages
|
|
3881
|
+
const lastEllipsisPageNumber = middlePagesEnd + 1;
|
|
3882
|
+
const showPageInsteadOfLastEllipsis = lastEllipsisPageNumber === pageTotal - (showLastPage ? 1 : 0);
|
|
3883
|
+
const lastEllipsisOrPage = showPageInsteadOfLastEllipsis ? createPage(lastEllipsisPageNumber) : ellipsisItem;
|
|
3884
|
+
paginationModel.push(lastEllipsisOrPage);
|
|
3885
|
+
// Add last page
|
|
3886
|
+
if (showLastPage) {
|
|
3887
|
+
paginationModel.push(createPage(pageTotal));
|
|
3888
|
+
}
|
|
3915
3889
|
}
|
|
3916
3890
|
paginationModel.push(createNextPageLink(options));
|
|
3917
3891
|
return paginationModel;
|
|
3918
3892
|
};
|
|
3919
3893
|
const getCurrentActivePage = (activePage, totalPages) => {
|
|
3920
|
-
// exception tests
|
|
3921
|
-
if (activePage === undefined || totalPages === undefined) {
|
|
3922
|
-
throw new Error('getCurrentActivePage(): activePage and totalPages props must be provided');
|
|
3923
|
-
}
|
|
3924
3894
|
// Obviously we can't be on a negative or 0 page.
|
|
3925
3895
|
if (activePage < 1) {
|
|
3926
3896
|
activePage = 1;
|
|
@@ -3932,10 +3902,6 @@ const getCurrentActivePage = (activePage, totalPages) => {
|
|
|
3932
3902
|
return activePage;
|
|
3933
3903
|
};
|
|
3934
3904
|
const getTotalPages = (totalItemsCount, itemsPerPage) => {
|
|
3935
|
-
// exception test
|
|
3936
|
-
if (totalItemsCount === undefined || itemsPerPage === undefined) {
|
|
3937
|
-
throw new Error('getTotalPages(): totalItemsCount and itemsPerPage props must be provided');
|
|
3938
|
-
}
|
|
3939
3905
|
if (totalItemsCount < 1) {
|
|
3940
3906
|
totalItemsCount = 1;
|
|
3941
3907
|
}
|
|
@@ -4086,4 +4052,4 @@ const getTextTagType = (host, tag) => {
|
|
|
4086
4052
|
}
|
|
4087
4053
|
};
|
|
4088
4054
|
|
|
4089
|
-
export { DISPLAY_TAGS, HEADING_TAGS, HEADLINE_TAGS, TEXT_TAGS, _hasShowPickerSupport, attributeMutationMap, buildCrestSrcSet, buildIconUrl, buildSrcSet, cdnBaseUrl, childrenMutationMap, createPaginationModel, createRange, crestCdnBaseUrl, crestInnerManifest, crestSize, displaySizeToTagMap, getButtonAriaAttributes, getButtonAttributes, getButtonBaseAriaAttributes, getButtonPureAriaAttributes, getClosestHTMLElement, getContentAriaAttributes, getCurrentActivePage, getDirectChildHTMLElement, getDisplayTagType, getFilterInputAriaAttributes, getHTMLElement, getHeadingTagType, getHeadlineTagType, getHighlightedOptionMapIndex, getIconColor, getInlineNotificationIconName, getInnerManifest, getLinkButtonThemeForIcon, getRole, getSelectWrapperDropdownButtonAriaAttributes, getSelectedOptionMap, getStepperHorizontalIconName, getSvgUrl, getSwitchButtonAriaAttributes, getTextTagType, getThemeForIcon, getTotalPages, hasDocument, hasLocateAction, hasSpecificSlottedTag, hasVisibleIcon, hasWindow, isCustomDropdown, isDisabledOrLoading, isHighContrastMode, isListTypeOrdered, isScrollable, isSortable, isStateCompleteOrWarning, isThemeDark, isTouchDevice, isType, isUrl, isWithinForm,
|
|
4055
|
+
export { DISPLAY_TAGS, HEADING_TAGS, HEADLINE_TAGS, ItemType, TEXT_TAGS, _hasShowPickerSupport, attributeMutationMap, buildCrestSrcSet, buildIconUrl, buildSrcSet, cdnBaseUrl, childrenMutationMap, createPaginationModel, createRange, crestCdnBaseUrl, crestInnerManifest, crestSize, displaySizeToTagMap, getButtonAriaAttributes, getButtonAttributes, getButtonBaseAriaAttributes, getButtonPureAriaAttributes, getClosestHTMLElement, getContentAriaAttributes, getCurrentActivePage, getDirectChildHTMLElement, getDisplayTagType, getFilterInputAriaAttributes, getHTMLElement, getHeadingTagType, getHeadlineTagType, getHighlightedOptionMapIndex, getIconColor, getInlineNotificationIconName, getInnerManifest, getLinkButtonThemeForIcon, getRole, getSelectWrapperDropdownButtonAriaAttributes, getSelectedOptionMap, getStepperHorizontalIconName, getSvgUrl, getSwitchButtonAriaAttributes, getTextTagType, getThemeForIcon, getTotalPages, hasDocument, hasLocateAction, hasSpecificSlottedTag, hasVisibleIcon, hasWindow, isCustomDropdown, isDisabledOrLoading, isHighContrastMode, isInfinitePagination, isListTypeOrdered, isScrollable, isSortable, isStateCompleteOrWarning, isThemeDark, isTouchDevice, isType, isUrl, isWithinForm, modelSignatureHeight, parseAndGetAriaAttributes, parseJSONAttribute, resizeMap, showCustomCalendarOrTimeIndicator, supportsConstructableStylesheets, tempDiv, tempIcon, tempLabel };
|
package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/components/carousel.wrapper.js
CHANGED
|
@@ -4,15 +4,15 @@ import { useEventCallback, usePrefix, useBrowserLayoutEffect, useMergedClass } f
|
|
|
4
4
|
import { syncRef } from '../../utils.js';
|
|
5
5
|
import { DSRCarousel } from '../dsr-components/carousel.js';
|
|
6
6
|
|
|
7
|
-
const PCarousel = forwardRef(({ activeSlideIndex = 0, alignHeader = 'left', description, disablePagination, heading, intl, onCarouselChange, onUpdate, pagination = true, rewind = true, slidesPerPage = 1, theme = 'light', width = 'basic', wrapContent, className, children, ...rest }, ref) => {
|
|
7
|
+
const PCarousel = forwardRef(({ activeSlideIndex = 0, alignHeader = 'left', description, disablePagination, heading, intl, onCarouselChange, onUpdate, pagination = true, rewind = true, skipLinkTarget, slidesPerPage = 1, theme = 'light', width = 'basic', wrapContent, className, children, ...rest }, ref) => {
|
|
8
8
|
const elementRef = useRef();
|
|
9
9
|
useEventCallback(elementRef, 'carouselChange', onCarouselChange);
|
|
10
10
|
useEventCallback(elementRef, 'update', onUpdate);
|
|
11
11
|
const WebComponentTag = usePrefix('p-carousel');
|
|
12
|
-
const propsToSync = [activeSlideIndex, alignHeader, description, disablePagination, heading, intl, pagination, rewind, slidesPerPage, theme, width, wrapContent];
|
|
12
|
+
const propsToSync = [activeSlideIndex, alignHeader, description, disablePagination, heading, intl, pagination, rewind, skipLinkTarget, slidesPerPage, theme, width, wrapContent];
|
|
13
13
|
useBrowserLayoutEffect(() => {
|
|
14
14
|
const { current } = elementRef;
|
|
15
|
-
['activeSlideIndex', 'alignHeader', 'description', 'disablePagination', 'heading', 'intl', 'pagination', 'rewind', 'slidesPerPage', 'theme', 'width', 'wrapContent'].forEach((propName, i) => (current[propName] = propsToSync[i]));
|
|
15
|
+
['activeSlideIndex', 'alignHeader', 'description', 'disablePagination', 'heading', 'intl', 'pagination', 'rewind', 'skipLinkTarget', 'slidesPerPage', 'theme', 'width', 'wrapContent'].forEach((propName, i) => (current[propName] = propsToSync[i]));
|
|
16
16
|
}, propsToSync);
|
|
17
17
|
// @ts-ignore
|
|
18
18
|
if (!process.browser) {
|
|
@@ -23,7 +23,7 @@ const PCarousel = forwardRef(({ activeSlideIndex = 0, alignHeader = 'left', desc
|
|
|
23
23
|
// @ts-ignore
|
|
24
24
|
...(!process.browser
|
|
25
25
|
? {
|
|
26
|
-
children: (jsx(DSRCarousel, { ...{ activeSlideIndex, alignHeader, description, disablePagination, heading, intl, pagination, rewind, slidesPerPage, theme, width, wrapContent, children } })),
|
|
26
|
+
children: (jsx(DSRCarousel, { ...{ activeSlideIndex, alignHeader, description, disablePagination, heading, intl, pagination, rewind, skipLinkTarget, slidesPerPage, theme, width, wrapContent, children } })),
|
|
27
27
|
}
|
|
28
28
|
: {
|
|
29
29
|
children,
|
package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/components/pagination.wrapper.js
CHANGED
|
@@ -4,15 +4,15 @@ import { useEventCallback, usePrefix, useBrowserLayoutEffect, useMergedClass } f
|
|
|
4
4
|
import { syncRef } from '../../utils.js';
|
|
5
5
|
import { DSRPagination } from '../dsr-components/pagination.js';
|
|
6
6
|
|
|
7
|
-
const PPagination = forwardRef(({ activePage = 1, allyLabel, allyLabelNext, allyLabelPage, allyLabelPrev, intl = { root: 'Pagination', prev: 'Previous page', next: 'Next page', page: 'Page', }, itemsPerPage = 1, maxNumberOfPageLinks = { base: 5, xs: 7, }, onPageChange, onUpdate, theme = 'light', totalItemsCount = 1, className, ...rest }, ref) => {
|
|
7
|
+
const PPagination = forwardRef(({ activePage = 1, allyLabel, allyLabelNext, allyLabelPage, allyLabelPrev, intl = { root: 'Pagination', prev: 'Previous page', next: 'Next page', page: 'Page', }, itemsPerPage = 1, maxNumberOfPageLinks = { base: 5, xs: 7, }, onPageChange, onUpdate, showLastPage = true, theme = 'light', totalItemsCount = 1, className, ...rest }, ref) => {
|
|
8
8
|
const elementRef = useRef();
|
|
9
9
|
useEventCallback(elementRef, 'pageChange', onPageChange);
|
|
10
10
|
useEventCallback(elementRef, 'update', onUpdate);
|
|
11
11
|
const WebComponentTag = usePrefix('p-pagination');
|
|
12
|
-
const propsToSync = [activePage, allyLabel, allyLabelNext, allyLabelPage, allyLabelPrev, intl, itemsPerPage, maxNumberOfPageLinks, theme, totalItemsCount];
|
|
12
|
+
const propsToSync = [activePage, allyLabel, allyLabelNext, allyLabelPage, allyLabelPrev, intl, itemsPerPage, maxNumberOfPageLinks, showLastPage, theme, totalItemsCount];
|
|
13
13
|
useBrowserLayoutEffect(() => {
|
|
14
14
|
const { current } = elementRef;
|
|
15
|
-
['activePage', 'allyLabel', 'allyLabelNext', 'allyLabelPage', 'allyLabelPrev', 'intl', 'itemsPerPage', 'maxNumberOfPageLinks', 'theme', 'totalItemsCount'].forEach((propName, i) => (current[propName] = propsToSync[i]));
|
|
15
|
+
['activePage', 'allyLabel', 'allyLabelNext', 'allyLabelPage', 'allyLabelPrev', 'intl', 'itemsPerPage', 'maxNumberOfPageLinks', 'showLastPage', 'theme', 'totalItemsCount'].forEach((propName, i) => (current[propName] = propsToSync[i]));
|
|
16
16
|
}, propsToSync);
|
|
17
17
|
// @ts-ignore
|
|
18
18
|
if (!process.browser) {
|
|
@@ -23,7 +23,7 @@ const PPagination = forwardRef(({ activePage = 1, allyLabel, allyLabelNext, ally
|
|
|
23
23
|
// @ts-ignore
|
|
24
24
|
...(!process.browser
|
|
25
25
|
? {
|
|
26
|
-
children: (jsx(DSRPagination, { ...{ activePage, allyLabel, allyLabelNext, allyLabelPage, allyLabelPrev, intl, itemsPerPage, maxNumberOfPageLinks, theme, totalItemsCount } })),
|
|
26
|
+
children: (jsx(DSRPagination, { ...{ activePage, allyLabel, allyLabelNext, allyLabelPage, allyLabelPrev, intl, itemsPerPage, maxNumberOfPageLinks, showLastPage, theme, totalItemsCount } })),
|
|
27
27
|
}
|
|
28
28
|
: {
|
|
29
29
|
suppressHydrationWarning: true,
|
package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/carousel.js
CHANGED
|
@@ -23,7 +23,7 @@ import '../components/headline.wrapper.js';
|
|
|
23
23
|
import '../components/icon.wrapper.js';
|
|
24
24
|
import '../components/inline-notification.wrapper.js';
|
|
25
25
|
import '../components/link.wrapper.js';
|
|
26
|
-
import '../components/link-pure.wrapper.js';
|
|
26
|
+
import { PLinkPure } from '../components/link-pure.wrapper.js';
|
|
27
27
|
import '../components/link-social.wrapper.js';
|
|
28
28
|
import '../components/link-tile.wrapper.js';
|
|
29
29
|
import '../components/link-tile-model-signature.wrapper.js';
|
|
@@ -65,6 +65,7 @@ import { Component } from 'react';
|
|
|
65
65
|
import { minifyCss } from '../../minifyCss.js';
|
|
66
66
|
import { stripFocusAndHoverStyles } from '../../stripFocusAndHoverStyles.js';
|
|
67
67
|
import { getCarouselCss as getComponentCss$T } from '../../../../../../components/dist/styles/esm/styles-entry.js';
|
|
68
|
+
import { isInfinitePagination } from '../../../../../../components/dist/utils/esm/utils-entry.js';
|
|
68
69
|
|
|
69
70
|
class DSRCarousel extends Component {
|
|
70
71
|
constructor() {
|
|
@@ -87,9 +88,9 @@ class DSRCarousel extends Component {
|
|
|
87
88
|
? typeof this.props.disablePagination === 'object'
|
|
88
89
|
? Object.fromEntries(Object.entries(this.props.disablePagination).map(([key, value]) => [key, !value]))
|
|
89
90
|
: !this.props.disablePagination
|
|
90
|
-
: this.props.pagination, this.props.alignHeader, this.props.theme)));
|
|
91
|
-
return (jsxs(Fragment, { children: [jsxs("template", { shadowroot: "open", shadowrootmode: "open", children: [jsx("style", { dangerouslySetInnerHTML: { __html: style } }), jsxs(Fragment, { children: [jsxs("div", { className: "header", children: [this.props.heading ? jsx("h2", { children: this.props.heading }) : jsx("slot", { name: "heading" }), (this.props.description || namedSlotChildren.filter(({ props: { slot } }) => slot === 'description').length > 0) &&
|
|
92
|
-
((this.props.description && jsx("p", { children: this.props.description })) || jsx("slot", { name: "description" })), jsxs("div", { className: "nav", children: [jsx(PButtonPure, { ...btnProps, icon: "arrow-left" }), jsx(PButtonPure, { ...btnProps, icon: "arrow-right" })] })] }), jsx("div", { id: "splide", className: "splide", "aria-label": this.props.heading || ((_a = namedSlotChildren.find(({ props: { slot } }) => slot === 'heading')) === null || _a === void 0 ? void 0 : _a.props.children), children: jsx("div", { className: "splide__track", children: jsx("div", { className: "splide__list", children: otherChildren.map((_, i) => (jsx("div", { className: "splide__slide", children: jsx("slot", { name: `slide-${i}` }) }, i))) }) }) }), (this.props.disablePagination ? this.props.disablePagination !== true : this.props.pagination) && (jsx("div", { className: "pagination" }))] })] }), this.props.children] }));
|
|
91
|
+
: this.props.pagination, isInfinitePagination(this.props.amountOfPages), this.props.alignHeader, this.props.theme)));
|
|
92
|
+
return (jsxs(Fragment, { children: [jsxs("template", { shadowroot: "open", shadowrootmode: "open", children: [jsx("style", { dangerouslySetInnerHTML: { __html: style } }), jsxs(Fragment, { children: [jsxs("div", { className: "header", children: [this.props.heading ? jsx("h2", { id: "heading", children: this.props.heading }) : jsx("slot", { name: "heading" }), (this.props.description || namedSlotChildren.filter(({ props: { slot } }) => slot === 'description').length > 0) &&
|
|
93
|
+
((this.props.description && jsx("p", { children: this.props.description })) || jsx("slot", { name: "description" })), jsxs("div", { className: "nav", children: [this.props.skipLinkTarget && (jsx(PLinkPure, { href: this.props.skipLinkTarget, theme: this.props.theme, icon: "arrow-last", className: "btn skip-link", alignLabel: "left", hideLabel: true, "aria-describedby": this.props.heading ? 'heading' : null, children: "Skip carousel entries" })), jsx(PButtonPure, { ...btnProps, icon: "arrow-left" }), jsx(PButtonPure, { ...btnProps, icon: "arrow-right" })] })] }), jsx("div", { id: "splide", className: "splide", "aria-label": this.props.heading || ((_a = namedSlotChildren.find(({ props: { slot } }) => slot === 'heading')) === null || _a === void 0 ? void 0 : _a.props.children), children: jsx("div", { className: "splide__track", children: jsx("div", { className: "splide__list", children: otherChildren.map((_, i) => (jsx("div", { className: "splide__slide", tabIndex: 0, children: jsx("slot", { name: `slide-${i}` }) }, i))) }) }) }), (this.props.disablePagination ? this.props.disablePagination !== true : this.props.pagination) && (jsx("div", { className: "pagination-container", children: jsx("div", { className: "pagination" }) }))] })] }), this.props.children] }));
|
|
93
94
|
}
|
|
94
95
|
}
|
|
95
96
|
|
package/ssr/esm/components-react/projects/react-ssr-wrapper/src/lib/dsr-components/pagination.js
CHANGED
|
@@ -64,7 +64,7 @@ import { Component } from 'react';
|
|
|
64
64
|
import { minifyCss } from '../../minifyCss.js';
|
|
65
65
|
import { stripFocusAndHoverStyles } from '../../stripFocusAndHoverStyles.js';
|
|
66
66
|
import { getPaginationCss as getComponentCss$v } from '../../../../../../components/dist/styles/esm/styles-entry.js';
|
|
67
|
-
import { getTotalPages, createPaginationModel, getCurrentActivePage,
|
|
67
|
+
import { getTotalPages, createPaginationModel, getCurrentActivePage, ItemType } from '../../../../../../components/dist/utils/esm/utils-entry.js';
|
|
68
68
|
|
|
69
69
|
class DSRPagination extends Component {
|
|
70
70
|
constructor() {
|
|
@@ -77,6 +77,7 @@ class DSRPagination extends Component {
|
|
|
77
77
|
activePage: getCurrentActivePage(this.props.activePage, pageTotal),
|
|
78
78
|
pageTotal,
|
|
79
79
|
pageRange: this.props.breakpointMaxNumberOfPageLinks === 7 ? 1 : 0,
|
|
80
|
+
showLastPage: this.props.showLastPage,
|
|
80
81
|
});
|
|
81
82
|
const style = minifyCss(stripFocusAndHoverStyles(getComponentCss$v(this.props.maxNumberOfPageLinks, this.props.theme)));
|
|
82
83
|
return (jsx(Fragment, { children: jsxs("template", { shadowroot: "open", shadowrootmode: "open", shadowrootdelegatesfocus: "true", children: [jsx("style", { dangerouslySetInnerHTML: { __html: style } }), jsx("nav", { role: "navigation", "aria-label": this.props.allyLabel || this.props.intl.root, children: jsx("ul", { children: paginationModel.map((pageModel) => {
|
|
@@ -91,14 +92,14 @@ class DSRPagination extends Component {
|
|
|
91
92
|
'aria-hidden': 'true',
|
|
92
93
|
};
|
|
93
94
|
switch (type) {
|
|
94
|
-
case
|
|
95
|
-
return (jsx("li", { children: jsx("span", { ...spanProps, "aria-
|
|
96
|
-
case
|
|
95
|
+
case ItemType.PREVIOUS:
|
|
96
|
+
return (jsx("li", { children: jsx("span", { ...spanProps, "aria-label": this.props.allyLabelPrev || this.props.intl.prev, "aria-disabled": isActive ? null : 'true', children: jsx(PIcon, { name: "arrow-left", ...iconProps }) }) }, "prev"));
|
|
97
|
+
case ItemType.ELLIPSIS:
|
|
97
98
|
return (jsx("li", { children: jsx("span", { className: "ellipsis" }) }, "ellipsis"));
|
|
98
|
-
case
|
|
99
|
+
case ItemType.PAGE:
|
|
99
100
|
return (jsx("li", { children: jsx("span", { ...spanProps, tabIndex: 0, "aria-label": `${this.props.allyLabelPage || this.props.intl.page} ${value}`, "aria-current": isActive ? 'page' : null, children: value }) }, value));
|
|
100
|
-
case
|
|
101
|
-
return (jsx("li", { children: jsx("span", { ...spanProps, "aria-
|
|
101
|
+
case ItemType.NEXT:
|
|
102
|
+
return (jsx("li", { children: jsx("span", { ...spanProps, "aria-label": this.props.allyLabelNext || this.props.intl.next, "aria-disabled": isActive ? null : 'true', children: jsx(PIcon, { name: "arrow-right", ...iconProps }) }) }, "next"));
|
|
102
103
|
}
|
|
103
104
|
}) }) })] }) }));
|
|
104
105
|
}
|
|
@@ -41,6 +41,10 @@ export type PCarouselProps = Omit<HTMLAttributes<{}>, 'color'> & {
|
|
|
41
41
|
* Whether the slides should rewind from last to first slide and vice versa.
|
|
42
42
|
*/
|
|
43
43
|
rewind?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Defines target of skip link (to skip carousel entries).
|
|
46
|
+
*/
|
|
47
|
+
skipLinkTarget?: string;
|
|
44
48
|
/**
|
|
45
49
|
* Sets the amount of slides visible at the same time. Can be set to `auto` if you want to define different widths per slide via CSS.
|
|
46
50
|
*/
|
|
@@ -100,6 +104,10 @@ export declare const PCarousel: import("react").ForwardRefExoticComponent<Omit<H
|
|
|
100
104
|
* Whether the slides should rewind from last to first slide and vice versa.
|
|
101
105
|
*/
|
|
102
106
|
rewind?: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Defines target of skip link (to skip carousel entries).
|
|
109
|
+
*/
|
|
110
|
+
skipLinkTarget?: string;
|
|
103
111
|
/**
|
|
104
112
|
* Sets the amount of slides visible at the same time. Can be set to `auto` if you want to define different widths per slide via CSS.
|
|
105
113
|
*/
|
|
@@ -30,7 +30,7 @@ export type PPaginationProps = Omit<HTMLAttributes<{}>, 'color'> & {
|
|
|
30
30
|
*/
|
|
31
31
|
itemsPerPage?: number;
|
|
32
32
|
/**
|
|
33
|
-
* The maximum number of page links rendered
|
|
33
|
+
* The maximum number of page links rendered.
|
|
34
34
|
*/
|
|
35
35
|
maxNumberOfPageLinks?: BreakpointCustomizable<PaginationMaxNumberOfPageLinks>;
|
|
36
36
|
/**
|
|
@@ -41,6 +41,10 @@ export type PPaginationProps = Omit<HTMLAttributes<{}>, 'color'> & {
|
|
|
41
41
|
* Emitted when the page changes.
|
|
42
42
|
*/
|
|
43
43
|
onUpdate?: (event: CustomEvent<PaginationUpdateEvent>) => void;
|
|
44
|
+
/**
|
|
45
|
+
* Show or hide the button to jump to the last page.
|
|
46
|
+
*/
|
|
47
|
+
showLastPage?: boolean;
|
|
44
48
|
/**
|
|
45
49
|
* Adapts the color when used on dark background.
|
|
46
50
|
*/
|
|
@@ -80,7 +84,7 @@ export declare const PPagination: import("react").ForwardRefExoticComponent<Omit
|
|
|
80
84
|
*/
|
|
81
85
|
itemsPerPage?: number;
|
|
82
86
|
/**
|
|
83
|
-
* The maximum number of page links rendered
|
|
87
|
+
* The maximum number of page links rendered.
|
|
84
88
|
*/
|
|
85
89
|
maxNumberOfPageLinks?: BreakpointCustomizable<PaginationMaxNumberOfPageLinks>;
|
|
86
90
|
/**
|
|
@@ -91,6 +95,10 @@ export declare const PPagination: import("react").ForwardRefExoticComponent<Omit
|
|
|
91
95
|
* Emitted when the page changes.
|
|
92
96
|
*/
|
|
93
97
|
onUpdate?: (event: CustomEvent<PaginationUpdateEvent>) => void;
|
|
98
|
+
/**
|
|
99
|
+
* Show or hide the button to jump to the last page.
|
|
100
|
+
*/
|
|
101
|
+
showLastPage?: boolean;
|
|
94
102
|
/**
|
|
95
103
|
* Adapts the color when used on dark background.
|
|
96
104
|
*/
|