nishant-design-system
Version:
Sense UI components library
182 lines (181 loc) • 6.42 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.TabSlot = exports.RightSlot = exports.PageTitle = exports.PageName = exports.PAGE_NAME_LIST = void 0;
var React = _interopRequireWildcard(require("react"));
var _classify = _interopRequireDefault(require("../../utils/classify"));
var _Icon = require("../Icon");
var _Text = require("../Text");
var _PageTitleModule = _interopRequireDefault(require("./PageTitle.module.css"));
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 (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); }
const PAGE_NAME_LIST = Object.freeze({
dashboard: {
title: 'Dashboard',
iconName: 'house',
iconType: 'duotone',
iconSwapOpacity: true
},
engage: {
title: 'Engage',
iconName: 'bullseye-pointer',
iconType: 'duotone',
iconSwapOpacity: true
},
trm: {
title: 'TRM',
iconName: 'screen-users',
iconType: 'duotone',
iconSwapOpacity: true
},
analytics: {
title: 'Analytics',
iconName: 'chart-column',
iconType: 'duotone',
iconSwapOpacity: true
},
messaging: {
title: 'Messaging',
iconName: 'messages',
iconType: 'duotone',
iconSwapOpacity: true
},
chatbot: {
title: 'Chatbot',
iconName: 'message-bot',
iconType: 'duotone',
iconSwapOpacity: true
},
referrals: {
title: 'Referrals',
iconName: 'user-check',
iconType: 'duotone',
iconSwapOpacity: true
},
records: {
title: 'Records',
iconName: 'folder-open',
iconType: 'duotone',
iconSwapOpacity: true
},
bulkCleanup: {
title: 'Bulk Cleanup',
iconName: 'retweet',
iconType: 'duotone',
iconSwapOpacity: true
},
support: {
title: 'Support',
iconName: 'headset',
iconType: 'duotone',
iconSwapOpacity: true
},
audit: {
title: 'Audit',
iconName: 'print-magnifying-glass',
iconType: 'duotone',
iconSwapOpacity: true
},
timeline: {
title: 'Timeline',
iconName: 'timeline',
iconType: 'duotone',
iconSwapOpacity: true
},
people: {
title: 'People',
iconName: 'people-group',
iconType: 'duotone',
iconSwapOpacity: true
},
contacts: {
title: 'Contacts',
iconName: 'address-card',
iconType: 'duotone',
iconSwapOpacity: true
},
contacts2: {
title: 'Contacts',
iconName: 'calendars',
iconType: 'duotone',
iconSwapOpacity: true
},
contacts3: {
title: 'Contacts',
iconName: 'browser',
iconType: 'duotone',
iconSwapOpacity: true
}
});
exports.PAGE_NAME_LIST = PAGE_NAME_LIST;
const TabSlot = _ref => {
let {
children,
className,
...props
} = _ref;
return /*#__PURE__*/React.createElement("div", _extends({}, props, {
className: (0, _classify.default)(_PageTitleModule.default.tabSlot, className)
}), children);
};
exports.TabSlot = TabSlot;
TabSlot.displayName = 'TabSlot';
const RightSlot = _ref2 => {
let {
children,
...props
} = _ref2;
return /*#__PURE__*/React.createElement("div", props, children);
};
exports.RightSlot = RightSlot;
RightSlot.displayName = 'RightSlot';
const PageName = _ref3 => {
let {
children,
...props
} = _ref3;
return /*#__PURE__*/React.createElement("div", _extends({}, props, {
className: _PageTitleModule.default.pageTitle
}), children);
};
exports.PageName = PageName;
PageName.displayName = 'PageName';
const PageTitle = /*#__PURE__*/React.forwardRef((_ref4, ref) => {
let {
classNames,
children,
pageNameKey
} = _ref4;
const getNamedComp = comp => {
const childrenArray = React.Children.toArray(children);
if (childrenArray.length) {
const nodes = [];
for (const child of childrenArray) {
if (child?.type?.displayName === comp) {
nodes.push(child);
}
}
return nodes.length > 1 ? nodes : nodes[0];
}
return null;
};
return /*#__PURE__*/React.createElement("div", {
"data-testid": "PageTitle",
className: (0, _classify.default)(_PageTitleModule.default.pageTitleWrapper, classNames?.wrapper),
ref: ref
}, /*#__PURE__*/React.createElement("div", {
className: (0, _classify.default)(_PageTitleModule.default.leftSlot, classNames?.leftSlot)
}, pageNameKey && PAGE_NAME_LIST[pageNameKey] ? /*#__PURE__*/React.createElement(PageName, null, /*#__PURE__*/React.createElement(_Text.TitleMedium, null, PAGE_NAME_LIST[pageNameKey].title, " "), /*#__PURE__*/React.createElement(_Icon.Icon, {
type: PAGE_NAME_LIST[pageNameKey].iconType,
name: PAGE_NAME_LIST[pageNameKey].iconName,
size: "medium",
color: _Text.TEXT_COLORS.primary,
swapOpacity: PAGE_NAME_LIST[pageNameKey].iconSwapOpacity
})) : getNamedComp('PageName'), getNamedComp('TabSlot')), /*#__PURE__*/React.createElement("div", {
className: (0, _classify.default)(_PageTitleModule.default.rightSlot, classNames?.rightSlot)
}, getNamedComp('RightSlot')));
});
exports.PageTitle = PageTitle;