vlibras-player-webjs
Version:
Biblioteca JavaScript moderna para integração do VLibras Player com React, Vue, Angular e vanilla JS
40 lines • 1.7 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { NoSSR } from './NoSSR';
/**
* HOC que envolve um componente para renderização apenas no cliente
* @param Component - Componente a ser envolvido
* @param options - Opções de configuração
* @returns Componente envolvido com NoSSR
*/
export function withNoSSR(Component, options = {}) {
const { fallback, delay, displayName } = options;
const WrappedComponent = (props) => (_jsx(NoSSR, { fallback: fallback, delay: delay, children: _jsx(Component, { ...props }) }));
WrappedComponent.displayName = displayName || `withNoSSR(${Component.displayName || Component.name})`;
return WrappedComponent;
}
/**
* HOC específico para componentes VLibras
* Inclui fallback padrão e configurações otimizadas
*/
export function withVLibrasNoSSR(Component, customFallback) {
const defaultFallback = (_jsx("div", { className: "vlibras-ssr-placeholder", style: {
display: 'inline-block',
width: '50px',
height: '50px',
backgroundColor: '#1976d2',
borderRadius: '50%',
opacity: 0.7,
animation: 'vlibras-pulse 1.5s ease-in-out infinite alternate'
}, "aria-label": "Carregando VLibras...", children: _jsx("style", { children: `
@keyframes vlibras-pulse {
from { opacity: 0.7; }
to { opacity: 0.3; }
}
` }) }));
return withNoSSR(Component, {
fallback: customFallback || defaultFallback,
delay: 100, // Pequeno delay para melhor experiência
displayName: `withVLibrasNoSSR(${Component.displayName || Component.name})`
});
}
//# sourceMappingURL=withNoSSR.js.map