@shko.online/lookupobjects-mock
Version:
Mocking Dataverse Lookup Objects to simplify writing soties for PCF components
75 lines • 2.54 kB
JavaScript
/*
MIT copyright
This file is part of the 'react-snap-carousel' https://github.com/richardscarrott/react-snap-carousel
*/
import React, { useImperativeHandle } from 'react';
import { useSnapCarousel } from './use-snap-carousel';
// eslint-disable-next-line react/display-name
export const Carousel = /*#__PURE__*/React.forwardRef(({
axis,
items,
renderItem,
scrollBehavior
}, ref) => {
const {
scrollRef,
next,
prev,
snapPointIndexes,
refresh
} = useSnapCarousel({
axis
});
useImperativeHandle(ref, () => ({
refresh
}));
return /*#__PURE__*/React.createElement("div", {
className: 'so.flex so.flex-row so.relative so.w-full so.justify-between'
}, /*#__PURE__*/React.createElement("button", {
className: "so.flex so.text-inherit so.w-8 so.cursor-pointer so.bg-transparent so.justify-center so.items-center so.box-border so.fill-neutral-600 hover:so.fill-blue-700",
onClick: () => prev({
behavior: scrollBehavior
})
}, /*#__PURE__*/React.createElement("svg", {
className: "so.fill-inherit ",
viewBox: "-8 -5 24 24",
width: "28",
xmlns: "http://www.w3.org/2000/svg"
}, /*#__PURE__*/React.createElement("path", {
d: "M2.757 7l4.95 4.95a1 1 0 1 1-1.414 1.414L.636 7.707a1 1 0 0 1 0-1.414L6.293.636A1 1 0 0 1 7.707 2.05L2.757 7z"
}))), /*#__PURE__*/React.createElement("ul", {
className: 'so.flex so.flex-1 so.flex-row so.relative so.overflow-hidden',
ref: scrollRef
}, items.map((item, index) => renderItem({
item,
index,
isSnapPoint: snapPointIndexes.has(index)
}))), /*#__PURE__*/React.createElement("button", {
className: 'so.flex so.text-inherit so.w-8 so.cursor-pointer so.bg-transparent so.justify-center so.items-center so.box-border so.fill-neutral-600 hover:so.fill-blue-700',
onClick: () => {
next({
behavior: scrollBehavior
});
}
}, /*#__PURE__*/React.createElement("svg", {
className: "so.fill-inherit",
viewBox: "-8 -5 24 24",
width: "28",
xmlns: "http://www.w3.org/2000/svg"
}, /*#__PURE__*/React.createElement("path", {
d: "M5.314 7.071l-4.95-4.95A1 1 0 0 1 1.778.707l5.657 5.657a1 1 0 0 1 0 1.414l-5.657 5.657a1 1 0 0 1-1.414-1.414l4.95-4.95z"
}))));
});
export const CarouselItem = ({
width,
children
}) => {
return /*#__PURE__*/React.createElement("li", {
className: 'item',
id: "corouselitem",
style: {
width: width !== null && width !== void 0 ? width : '',
scrollSnapAlign: 'start'
}
}, children);
};