UNPKG

@amaui/ui-react

Version:
51 lines 2.87 kB
import _extends from "@babel/runtime/helpers/extends"; import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; import _defineProperty from "@babel/runtime/helpers/defineProperty"; const _excluded = ["values", "value", "ImageGalleryProps", "className"]; function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); 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 = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } import React from 'react'; import { is } from '@amaui/utils'; import { classNames, style as styleMethod, useAmauiTheme } from '@amaui/style-react'; import ImageGalleryElement from '../ImageGallery'; import SectionElement from '../Section/Section'; import { staticClassName } from '../utils'; const useStyle = styleMethod(theme => ({ root: {} }), { name: 'amaui-SectionImageGallery' }); const Element = /*#__PURE__*/React.forwardRef((props_, ref) => { const theme = useAmauiTheme(); const props = React.useMemo(() => _objectSpread(_objectSpread(_objectSpread({}, theme?.ui?.elements?.all?.props?.default), theme?.ui?.elements?.amauiSectionImageGallery?.props?.default), props_), [props_]); const Section = React.useMemo(() => theme?.elements?.Section || SectionElement, [theme]); const ImageGallery = React.useMemo(() => theme?.elements?.ImageGallery || ImageGalleryElement, [theme]); const { values, value, ImageGalleryProps, className } = props, other = _objectWithoutProperties(props, _excluded); const { classes } = useStyle(); const refs = { root: React.useRef(undefined) }; return /*#__PURE__*/React.createElement(Section, _extends({ ref: item => { if (ref) { if (is('function', ref)) ref(item);else ref.current = item; } refs.root.current = item; }, className: classNames([staticClassName('ImageGallery', theme) && ['amaui-SectionImageGallery-root'], className, classes.root]) }, other), !!values?.length && /*#__PURE__*/React.createElement(ImageGallery, _extends({ version: "regular", items: values, value: value }, ImageGalleryProps))); }); Element.displayName = 'amaui-SectionImageGallery'; export default Element;