UNPKG

@zohodesk/dot

Version:

In this Library, we Provide Some Basic Components to Build Your Application

203 lines (167 loc) 11.2 kB
"use strict"; function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _react = _interopRequireWildcard(require("react")); var _defaultProps = require("./props/defaultProps"); var _propTypes = require("./props/propTypes"); var _AvatarUser = _interopRequireDefault(require("../avatar/AvatarUser/AvatarUser")); var _AvatarIcon = _interopRequireDefault(require("../avatar/AvatarIcon/AvatarIcon")); var _CheckBox = _interopRequireDefault(require("@zohodesk/components/lib/CheckBox/CheckBox")); var _Layout = require("@zohodesk/components/lib/Layout"); var _ChannelIcon = _interopRequireDefault(require("../ChannelIcon/ChannelIcon")); var _AvatarSize = _interopRequireDefault(require("@zohodesk/components/lib/Provider/AvatarSize")); var _FlipCardModule = _interopRequireDefault(require("./FlipCard.module.css")); var _General = require("../utils/General"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 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 _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } 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; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } var FlipCard = /*#__PURE__*/function (_Component) { _inherits(FlipCard, _Component); var _super = _createSuper(FlipCard); function FlipCard(props) { var _this; _classCallCheck(this, FlipCard); _this = _super.call(this, props); _this.onChange = _this.onChange.bind(_assertThisInitialized(_this)); _this.onClick = _this.onClick.bind(_assertThisInitialized(_this)); return _this; } _createClass(FlipCard, [{ key: "onClick", value: function onClick(e) { var noNeedFlip = this.props.noNeedFlip; if (!noNeedFlip) { (0, _General.stopBubbling)(e); } } }, { key: "onChange", value: function onChange(isChecked, e) { var onChange = this.props.onChange; (0, _General.stopBubbling)(e); var id = this.props.id; onChange(id, isChecked, e); } }, { key: "render", value: function render() { var _this$props = this.props, id = _this$props.id, action = _this$props.action, name = _this$props.name, initial = _this$props.initial, isChecked = _this$props.isChecked, noNeedFlip = _this$props.noNeedFlip, size = _this$props.size, channel = _this$props.channel, isPaidUser = _this$props.isPaidUser, isPortalUser = _this$props.isPortalUser, src = _this$props.src, icon = _this$props.icon, iconSize = _this$props.iconSize, iconClass = _this$props.iconClass, ticListContainer = _this$props.ticListContainer, ticList = _this$props.ticList, dataId = _this$props.dataId, className = _this$props.className, palette = _this$props.palette, textPalette = _this$props.textPalette, customTextClass = _this$props.customTextClass, frontClass = _this$props.frontClass, needTitle = _this$props.needTitle, iconColor = _this$props.iconColor, tourId = _this$props.tourId, isFilledCheckbox = _this$props.isFilledCheckbox, channelTitle = _this$props.channelTitle, customProps = _this$props.customProps; var _customProps$CheckBox = customProps.CheckBoxProps, CheckBoxProps = _customProps$CheckBox === void 0 ? {} : _customProps$CheckBox, _customProps$ChannelI = customProps.ChannelIconProps, ChannelIconProps = _customProps$ChannelI === void 0 ? {} : _customProps$ChannelI, _customProps$AvatarIc = customProps.AvatarIconProps, AvatarIconProps = _customProps$AvatarIc === void 0 ? {} : _customProps$AvatarIc, _customProps$AvatarUs = customProps.AvatarUserProps, AvatarUserProps = _customProps$AvatarUs === void 0 ? {} : _customProps$AvatarUs; return /*#__PURE__*/_react["default"].createElement("div", { className: "".concat((0, _AvatarSize["default"])(size), " ").concat(noNeedFlip ? _FlipCardModule["default"].flipNone : isChecked ? _FlipCardModule["default"].notFlip : _FlipCardModule["default"].flip), onClick: this.onClick, "data-id": ticListContainer, "data-test-id": ticListContainer, "data-tour": tourId }, /*#__PURE__*/_react["default"].createElement("div", { className: _FlipCardModule["default"].container, "data-id": ticList, "data-test-id": ticList }, !noNeedFlip ? /*#__PURE__*/_react["default"].createElement(_Layout.Container, { align: "both", className: "".concat(_FlipCardModule["default"].front, " ").concat(frontClass ? frontClass : '') }, /*#__PURE__*/_react["default"].createElement(_CheckBox["default"], _extends({ isFilled: isFilledCheckbox, checked: isChecked, onChange: this.onChange, id: "checkbox_".concat(id), dataId: "listViewCheckBox_".concat(id) }, CheckBoxProps))) : null, /*#__PURE__*/_react["default"].createElement(_Layout.Container, { align: "both", className: _FlipCardModule["default"].back }, channel && action ? /*#__PURE__*/_react["default"].createElement(_ChannelIcon["default"], _extends({ name: channel, action: action, size: size, iconSize: iconSize, iconClass: iconClass, dataId: channel, className: className, palette: palette, textPalette: textPalette, customTextClass: customTextClass, iconColor: iconColor, title: channelTitle, iconTitle: channelTitle }, ChannelIconProps)) : icon ? /*#__PURE__*/_react["default"].createElement(_AvatarIcon["default"], _extends({ name: icon, iconSize: iconSize, size: size, iconClass: iconClass, dataId: icon, className: className, iconColor: iconColor, title: needTitle ? name : '' }, AvatarIconProps)) : /*#__PURE__*/_react["default"].createElement(_AvatarUser["default"], _extends({ name: name, initial: initial, size: size, isPaid: isPaidUser, isPortal: isPortalUser, src: src, dataId: dataId, needTitle: needTitle, palette: palette, textPalette: textPalette, customTextClass: customTextClass }, AvatarUserProps))))); } }]); return FlipCard; }(_react.Component); exports["default"] = FlipCard; FlipCard.propTypes = _propTypes.propTypes; FlipCard.defaultProps = _defaultProps.defaultProps; // if (__DOCS__) { // FlipCard.docs = { // componentGroup: 'Molecule' // }; // }