UNPKG

@porsche-design-system/components-react

Version:

Porsche Design System is a component library designed to help developers create the best experience for software or services distributed by Dr. Ing. h.c. F. Porsche AG.

28 lines (24 loc) 1.61 kB
"use client"; 'use strict'; var jsxRuntime = require('react/jsx-runtime'); var react = require('react'); var hooks = require('../../hooks.cjs'); var utils = require('../../utils.cjs'); const PCarousel = /*#__PURE__*/ react.forwardRef(({ activeSlideIndex = 0, alignControls = 'auto', alignHeader = 'start', aria, description, focusOnCenterSlide = false, gradient = false, heading, headingSize = 'x-large', intl, onUpdate, pagination = false, rewind = false, skipLinkTarget, slidesPerPage = 1, trimSpace = false, width = 'basic', className, ...rest }, ref) => { const elementRef = react.useRef(undefined); hooks.useEventCallback(elementRef, 'update', onUpdate); const WebComponentTag = hooks.usePrefix('p-carousel'); const propsToSync = [activeSlideIndex, alignControls, alignHeader, aria, description, focusOnCenterSlide, gradient, heading, headingSize, intl, pagination, rewind, skipLinkTarget, slidesPerPage, trimSpace, width]; hooks.useBrowserLayoutEffect(() => { const { current } = elementRef; ['activeSlideIndex', 'alignControls', 'alignHeader', 'aria', 'description', 'focusOnCenterSlide', 'gradient', 'heading', 'headingSize', 'intl', 'pagination', 'rewind', 'skipLinkTarget', 'slidesPerPage', 'trimSpace', 'width'].forEach((propName, i) => (current[propName] = propsToSync[i])); }, propsToSync); const props = { ...rest, class: hooks.useMergedClass(elementRef, className), ref: utils.syncRef(elementRef, ref) }; // @ts-ignore return jsxRuntime.jsx(WebComponentTag, { ...props }); }); exports.PCarousel = PCarousel;