UNPKG

@bigbinary/neetoui

Version:

neetoUI drives the experience at all neeto products

118 lines (114 loc) 6.42 kB
import _defineProperty from '@babel/runtime/helpers/defineProperty'; import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties'; import 'react'; import classnames from 'classnames'; import { isEmpty, isNil, omit } from 'ramda'; import Button from './Button.js'; import Tooltip from './Tooltip.js'; import Typography from './Typography.js'; import { jsx, jsxs } from 'react/jsx-runtime'; import 'react-router-dom'; import './Spinner.js'; import '@babel/runtime/helpers/slicedToArray'; import '@tippyjs/react'; import 'tippy.js'; import '@bigbinary/neeto-hotkeys'; import './overlayManager.js'; import '@babel/runtime/helpers/classCallCheck'; import '@babel/runtime/helpers/createClass'; import '@bigbinary/neeto-cist'; import 'qs'; import './index-DyUNP5G9.js'; import '@babel/runtime/helpers/toConsumableArray'; import 'dayjs'; import 'dayjs/plugin/localeData'; import 'dayjs/plugin/utc'; import 'dayjs/plugin/weekday'; import 'dayjs/plugin/weekOfYear'; import 'i18next'; import './usePrefersReducedMotion-n4ZJtExQ.js'; var renderImage = function renderImage(image) { return typeof image === "string" ? /*#__PURE__*/jsx("img", { "data-testid": "no-data-image", src: image }) : image; }; var _excluded = ["image", "title", "description", "helpText", "className", "primaryButtonProps", "secondaryButtonProps", "buttonSeparatorText", "showTooltipWhenButtonDisabled"]; function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } var NoData = function NoData(_ref) { var _ref$image = _ref.image, image = _ref$image === void 0 ? null : _ref$image, _ref$title = _ref.title, title = _ref$title === void 0 ? "" : _ref$title, _ref$description = _ref.description, description = _ref$description === void 0 ? "" : _ref$description, _ref$helpText = _ref.helpText, helpText = _ref$helpText === void 0 ? null : _ref$helpText, _ref$className = _ref.className, className = _ref$className === void 0 ? "" : _ref$className, _ref$primaryButtonPro = _ref.primaryButtonProps, primaryButtonProps = _ref$primaryButtonPro === void 0 ? {} : _ref$primaryButtonPro, _ref$secondaryButtonP = _ref.secondaryButtonProps, secondaryButtonProps = _ref$secondaryButtonP === void 0 ? {} : _ref$secondaryButtonP, _ref$buttonSeparatorT = _ref.buttonSeparatorText, buttonSeparatorText = _ref$buttonSeparatorT === void 0 ? "" : _ref$buttonSeparatorT, _ref$showTooltipWhenB = _ref.showTooltipWhenButtonDisabled, showTooltipWhenButtonDisabled = _ref$showTooltipWhenB === void 0 ? false : _ref$showTooltipWhenB, otherProps = _objectWithoutProperties(_ref, _excluded); var hasPrimaryButtonProps = !isEmpty(primaryButtonProps); var hasSecondaryButtonProps = !isEmpty(secondaryButtonProps); var hasButtonSeparatorText = !isEmpty(buttonSeparatorText); var showButtonSeparator = hasButtonSeparatorText && hasPrimaryButtonProps && hasSecondaryButtonProps; return /*#__PURE__*/jsxs("div", _objectSpread(_objectSpread({ className: classnames("neeto-ui-no-data", [className]), "data-testid": "no-data-container" }, otherProps), {}, { children: [image ? /*#__PURE__*/jsx("div", { className: "neeto-ui-no-data__image", children: renderImage(image) }) : null, title && /*#__PURE__*/jsx(Typography, { className: "neeto-ui-text-center", "data-testid": "no-data-title", lineHeight: "none", style: "h3", children: title }), description && /*#__PURE__*/jsx(Typography, { className: "neeto-ui-text-center neeto-ui-no-data__description", "data-testid": "no-data-description", lineHeight: "normal", style: "body2", children: description }), helpText && /*#__PURE__*/jsx(Typography, { className: "neeto-ui-text-center neeto-ui-no-data__help-text", "data-testid": "no-data-help-text", lineHeight: "normal", style: "body2", children: helpText }), (hasPrimaryButtonProps || hasSecondaryButtonProps) && /*#__PURE__*/jsxs("div", { className: "neeto-ui-no-data__action-block", children: [hasPrimaryButtonProps && /*#__PURE__*/jsx(Tooltip, _objectSpread(_objectSpread({}, primaryButtonProps === null || primaryButtonProps === void 0 ? void 0 : primaryButtonProps.tooltipProps), {}, { disabled: isNil(primaryButtonProps === null || primaryButtonProps === void 0 ? void 0 : primaryButtonProps.tooltipProps) || !showTooltipWhenButtonDisabled && (primaryButtonProps === null || primaryButtonProps === void 0 ? void 0 : primaryButtonProps.disabled), children: /*#__PURE__*/jsx("div", { children: /*#__PURE__*/jsx(Button, _objectSpread({ "data-testid": "no-data-primary-button" }, omit(["tooltipProps"], primaryButtonProps))) }) })), showButtonSeparator && /*#__PURE__*/jsx(Typography, { lineHeight: "normal", style: "body2", children: buttonSeparatorText }), hasSecondaryButtonProps && /*#__PURE__*/jsx(Tooltip, _objectSpread(_objectSpread({}, secondaryButtonProps === null || secondaryButtonProps === void 0 ? void 0 : secondaryButtonProps.tooltipProps), {}, { disabled: isNil(secondaryButtonProps === null || secondaryButtonProps === void 0 ? void 0 : secondaryButtonProps.tooltipProps) || !showTooltipWhenButtonDisabled && (secondaryButtonProps === null || secondaryButtonProps === void 0 ? void 0 : secondaryButtonProps.disabled), children: /*#__PURE__*/jsx("div", { children: /*#__PURE__*/jsx(Button, _objectSpread({ "data-testid": "no-data-secondary-button", style: "secondary" }, omit(["tooltipProps"], secondaryButtonProps))) }) }))] })] })); }; export { NoData as default }; //# sourceMappingURL=NoData.js.map