UNPKG

wix-style-react

Version:
103 lines (87 loc) 4.22 kB
import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; import _createClass from "@babel/runtime/helpers/createClass"; import _inherits from "@babel/runtime/helpers/inherits"; import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn"; import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf"; import _defineProperty from "@babel/runtime/helpers/defineProperty"; import _extends from "@babel/runtime/helpers/extends"; import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; var _excluded = ["data-click", "selected", "onClick", "focusableOnFocus", "focusableOnBlur", "children", "className"], _excluded2 = ["children", "selected", "tooltipText", "focusableOnFocus", "focusableOnBlur", "onClick", "dataHook", "data-click"]; function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } import React from 'react'; import PropTypes from 'prop-types'; import { withFocusable } from "wix-ui-core/dist/es/src/hocs/Focusable/FocusableHOC"; import Tooltip from '../../Tooltip'; import { st, classes } from './ToggleIcon.st.css'; var Icon = function Icon(_ref) { var dataClick = _ref['data-click'], selected = _ref.selected, onClick = _ref.onClick, focusableOnFocus = _ref.focusableOnFocus, focusableOnBlur = _ref.focusableOnBlur, children = _ref.children, className = _ref.className, rest = _objectWithoutProperties(_ref, _excluded); return /*#__PURE__*/React.createElement("button", _extends({}, rest, { className: st(classes.button, { selected: selected }, className), "data-click": dataClick, "data-hook": "toggle-icon", "data-selected": selected, onClick: onClick, onFocus: focusableOnFocus, onBlur: focusableOnBlur, type: "button" }), children); }; var FocusableIcon = withFocusable(Icon); var ToggleIcon = /*#__PURE__*/function (_React$Component) { _inherits(ToggleIcon, _React$Component); var _super = _createSuper(ToggleIcon); function ToggleIcon() { _classCallCheck(this, ToggleIcon); return _super.apply(this, arguments); } _createClass(ToggleIcon, [{ key: "render", value: function render() { var _this$props = this.props, children = _this$props.children, selected = _this$props.selected, tooltipText = _this$props.tooltipText, focusableOnFocus = _this$props.focusableOnFocus, focusableOnBlur = _this$props.focusableOnBlur, onClick = _this$props.onClick, dataHook = _this$props.dataHook, dataClick = _this$props['data-click'], rest = _objectWithoutProperties(_this$props, _excluded2); return /*#__PURE__*/React.createElement(Tooltip, { className: st(classes.tooltip), dataHook: dataHook, appendTo: "window", placement: "top", content: tooltipText, timeout: 0 }, /*#__PURE__*/React.createElement(FocusableIcon, _extends({}, rest, { selected: selected, "data-click": dataClick, onClick: onClick, onFocus: focusableOnFocus, onBlur: focusableOnBlur }), children)); } }]); return ToggleIcon; }(React.Component); _defineProperty(ToggleIcon, "displayName", 'SegmentedToggle.Icon'); _defineProperty(ToggleIcon, "propTypes", { children: PropTypes.node, selected: PropTypes.bool, value: PropTypes.string, tooltipText: PropTypes.string, disabled: PropTypes.bool }); export default ToggleIcon;