UNPKG

@onesy/style-react

Version:

Onesy CSS in JS styling solution for React

23 lines (22 loc) 1.06 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const jsx_runtime_1 = require("react/jsx-runtime"); const react_1 = __importDefault(require("react")); const _1 = require("."); const withStyle = (Element) => (value, options = {}) => { var _a; // Name options.name = options.name !== undefined ? options.name : `${(Element === null || Element === void 0 ? void 0 : Element.displayName) || ((_a = Element === null || Element === void 0 ? void 0 : Element.type) === null || _a === void 0 ? void 0 : _a.displayName) || ''}WithStyle`; // Use styles const useStyle = (0, _1.style)(value, options); // Element const element = react_1.default.forwardRef((props, ref) => { const styles = useStyle(props); return ((0, jsx_runtime_1.jsx)(Element, Object.assign({ ref: ref, styles: styles }, props))); }); return element; }; exports.default = withStyle;