UNPKG

@geezee/react-ui

Version:

Modern and minimalist React UI library.

29 lines (25 loc) 1.64 kB
import _extends from "@babel/runtime/helpers/esm/extends"; import * as React from 'react'; import { useImperativeHandle, useRef } from 'react'; import { generatePickerGlobalStyle } from '../style'; import useTheme from '../../styles/use-theme'; // inject style to picker component var withStyle = function withStyle(Picker) { return React.forwardRef(function (props, ref) { var theme = useTheme(); var pickerRef = useRef(ref); // pick ref methods useImperativeHandle(ref, function () { var _pickerRef$current, _pickerRef$current2, _pickerRef$current3, _pickerRef$current4; return { focus: pickerRef === null || pickerRef === void 0 ? void 0 : (_pickerRef$current = pickerRef.current) === null || _pickerRef$current === void 0 ? void 0 : _pickerRef$current.focus, blur: pickerRef === null || pickerRef === void 0 ? void 0 : (_pickerRef$current2 = pickerRef.current) === null || _pickerRef$current2 === void 0 ? void 0 : _pickerRef$current2.blur, setValue: pickerRef === null || pickerRef === void 0 ? void 0 : (_pickerRef$current3 = pickerRef.current) === null || _pickerRef$current3 === void 0 ? void 0 : _pickerRef$current3.setValue, getValue: pickerRef === null || pickerRef === void 0 ? void 0 : (_pickerRef$current4 = pickerRef.current) === null || _pickerRef$current4 === void 0 ? void 0 : _pickerRef$current4.getValue }; }); return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Picker, _extends({ forwardedRef: pickerRef }, props)), generatePickerGlobalStyle(theme, props)); }); }; export default withStyle;