@findify/react-components
Version:
Findify react UI components
64 lines (58 loc) • 3.75 kB
JavaScript
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
import { Children } from 'react';
import { Swiper, SwiperSlide } from 'swiper/react';
import SwiperCore, { Navigation, Pagination, Autoplay, Scrollbar } from 'swiper';
import cx from 'classnames';
import Icon from "../Icon";
import { jsx as _jsx } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
var styles = {
"root": "findify-components--swiper",
"prev": "findify-components--swiper__prev",
"next": "findify-components--swiper__next",
"arrow": "findify-components--swiper__arrow"
};
SwiperCore.use([Navigation, Pagination, Autoplay, Scrollbar]);
export default (function (_ref) {
var children = _ref.children,
_ref$theme = _ref.theme,
theme = _ref$theme === void 0 ? styles : _ref$theme,
slot = _ref.slot,
props = _objectWithoutProperties(_ref, ["children", "theme", "slot"]);
var navigation = {
nextEl: ".".concat(slot, "-next"),
prevEl: ".".concat(slot, "-prev")
};
return /*#__PURE__*/_jsxs("div", {
className: theme.root,
children: [/*#__PURE__*/_jsx("button", {
"aria-label": "previous",
className: cx(theme.prev, navigation.prevEl.substring(1)),
children: /*#__PURE__*/_jsx(Icon, {
name: "ArrowLeftBig",
title: "Previous slide",
className: theme.arrow
})
}), /*#__PURE__*/_jsx(Swiper, _objectSpread(_objectSpread({
navigation: navigation
}, props), {}, {
children: Children.map(children, function (child) {
return /*#__PURE__*/_jsx(SwiperSlide, {
children: child
});
})
})), /*#__PURE__*/_jsx("button", {
"aria-label": "next",
className: cx(theme.next, navigation.nextEl.substring(1)),
children: /*#__PURE__*/_jsx(Icon, {
name: "ArrowRightBig",
title: "Next slide",
className: theme.arrow
})
})]
});
});