@cbpds/react-components
Version:
React components encapsulating the CBP Design System web components.
31 lines • 977 B
JavaScript
import React from 'react';
export const setRef = (ref, value) => {
if (typeof ref === 'function') {
ref(value);
}
else if (ref != null) {
ref.current = value;
}
};
export const mergeRefs = (...refs) => {
return (value) => {
refs.forEach((ref) => {
setRef(ref, value);
});
};
};
export const createForwardRef = (ReactComponent, displayName) => {
const forwardRef = (props, ref) => {
return React.createElement(ReactComponent, Object.assign({}, props, { forwardedRef: ref }));
};
forwardRef.displayName = displayName;
return React.forwardRef(forwardRef);
};
export const defineCustomElement = (tagName, customElement) => {
if (customElement !== undefined && typeof customElements !== 'undefined' && !customElements.get(tagName)) {
customElements.define(tagName, customElement);
}
};
export * from './attachProps';
export * from './case';
//# sourceMappingURL=index.js.map