UNPKG

@chayns-components/core

Version:

A set of beautiful React components for developing your own applications with chayns.

38 lines 1.5 kB
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); } import React, { forwardRef } from 'react'; export const LIST_ITEM_MARKER = Symbol('ListItem'); const getDisplayName = Component => Component.displayName || Component.name || 'Component'; export const withListItemMarker = Component => { const WrappedComponent = props => { const { isExpandable = false, shouldHideIndicator = false, ...restProps } = props; return /*#__PURE__*/React.createElement(Component, _extends({}, restProps, { isExpandable: isExpandable, shouldHideIndicator: shouldHideIndicator })); }; WrappedComponent.$$listItem = LIST_ITEM_MARKER; WrappedComponent.displayName = `withListItemMarker(${getDisplayName(Component)})`; return WrappedComponent; }; export const withListItemMarkerForwardRef = (render, displayName) => { const Component = /*#__PURE__*/forwardRef((props, ref) => { const { isExpandable = false, shouldHideIndicator = false, ...restProps } = props; return render({ ...restProps, isExpandable, shouldHideIndicator }, ref); }); Component.$$listItem = LIST_ITEM_MARKER; Component.displayName = displayName; return Component; }; //# sourceMappingURL=ListItem.utils.js.map