UNPKG

@onesy/ui-react

Version:
54 lines 2.63 kB
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; import _defineProperty from "@babel/runtime/helpers/defineProperty"; const _excluded = ["ref", "values", "value", "ImageGalleryProps", "className"]; function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } import React from 'react'; import { is } from '@onesy/utils'; import { classNames, style as styleMethod, useOnesyTheme } from '@onesy/style-react'; import ImageGalleryElement from '../ImageGallery'; import SectionElement from '../Section/Section'; import { staticClassName } from '../utils'; import { jsx as _jsx } from "react/jsx-runtime"; const useStyle = styleMethod(theme => ({ root: {} }), { name: 'onesy-SectionImageGallery' }); const Element = props_ => { const theme = useOnesyTheme(); const props = _objectSpread(_objectSpread(_objectSpread({}, theme?.ui?.elements?.all?.props?.default), theme?.ui?.elements?.onesySectionImageGallery?.props?.default), props_); const Section = theme?.elements?.Section || SectionElement; const ImageGallery = theme?.elements?.ImageGallery || ImageGalleryElement; const { ref, values, value, ImageGalleryProps, className } = props, other = _objectWithoutProperties(props, _excluded); const { classes } = useStyle(); const refs = { root: React.useRef(undefined) }; return /*#__PURE__*/_jsx(Section, _objectSpread(_objectSpread({ ref: item => { if (ref) { if (is('function', ref)) ref(item);else ref.current = item; } refs.root.current = item; }, className: classNames([staticClassName('ImageGallery', theme) && ['onesy-SectionImageGallery-root'], className, classes.root]) }, other), {}, { children: !!values?.length && /*#__PURE__*/_jsx(ImageGallery, _objectSpread({ version: "regular", items: values, value: value }, ImageGalleryProps)) })); }; Element.displayName = 'onesy-SectionImageGallery'; export default Element;