pixelize-design-library 2.2.144 → 2.2.145
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Components/SideBar/SideBar.d.ts +1 -1
- package/dist/Components/SideBar/SideBar.js +3 -1
- package/dist/Components/SideBar/SideBarProps.d.ts +11 -0
- package/dist/Components/SideBar/components/OtherApps.d.ts +4 -0
- package/dist/Components/SideBar/components/OtherApps.js +38 -0
- package/dist/Components/SideBar/components/OtherApps.test.d.ts +1 -0
- package/dist/Components/SideBar/components/OtherApps.test.js +112 -0
- package/package.json +1 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { SidebarProps } from "./SideBarProps";
|
|
3
|
-
export default function Sidebar({ menus, activeMenu, handleMenuClick, handleSecondaryNavClick, toggle, changeToggle, logo, companyName, isDisableAddNew, onAddNewClick, selectedSubMenu, selectedSecondaryItem, isLoading, loadingLines, open, }: SidebarProps): React.JSX.Element;
|
|
3
|
+
export default function Sidebar({ menus, activeMenu, handleMenuClick, handleSecondaryNavClick, toggle, changeToggle, logo, companyName, isDisableAddNew, onAddNewClick, selectedSubMenu, selectedSecondaryItem, isLoading, loadingLines, open, otherApps, }: SidebarProps): React.JSX.Element;
|
|
@@ -57,6 +57,7 @@ var MenuItems_1 = __importDefault(require("./components/MenuItems"));
|
|
|
57
57
|
var defaultLogo_1 = __importDefault(require("../../Assets/defaultLogo"));
|
|
58
58
|
var OverflowTooltipText_1 = __importDefault(require("./components/OverflowTooltipText"));
|
|
59
59
|
var SecondaryBar_1 = __importDefault(require("./SecondaryBar"));
|
|
60
|
+
var OtherApps_1 = __importDefault(require("./components/OtherApps"));
|
|
60
61
|
var SidebarHeader = function (_a) {
|
|
61
62
|
var logo = _a.logo, companyName = _a.companyName, toggle = _a.toggle, isLoading = _a.isLoading;
|
|
62
63
|
var theme = (0, useCustomTheme_1.useCustomTheme)();
|
|
@@ -107,7 +108,7 @@ var CollapseButton = function (_a) {
|
|
|
107
108
|
// --- Main Sidebar component ---
|
|
108
109
|
function Sidebar(_a) {
|
|
109
110
|
var _b;
|
|
110
|
-
var menus = _a.menus, activeMenu = _a.activeMenu, handleMenuClick = _a.handleMenuClick, handleSecondaryNavClick = _a.handleSecondaryNavClick, toggle = _a.toggle, changeToggle = _a.changeToggle, logo = _a.logo, companyName = _a.companyName, _c = _a.isDisableAddNew, isDisableAddNew = _c === void 0 ? false : _c, onAddNewClick = _a.onAddNewClick, selectedSubMenu = _a.selectedSubMenu, selectedSecondaryItem = _a.selectedSecondaryItem, isLoading = _a.isLoading, loadingLines = _a.loadingLines, _d = _a.open, open = _d === void 0 ? true : _d;
|
|
111
|
+
var menus = _a.menus, activeMenu = _a.activeMenu, handleMenuClick = _a.handleMenuClick, handleSecondaryNavClick = _a.handleSecondaryNavClick, toggle = _a.toggle, changeToggle = _a.changeToggle, logo = _a.logo, companyName = _a.companyName, _c = _a.isDisableAddNew, isDisableAddNew = _c === void 0 ? false : _c, onAddNewClick = _a.onAddNewClick, selectedSubMenu = _a.selectedSubMenu, selectedSecondaryItem = _a.selectedSecondaryItem, isLoading = _a.isLoading, loadingLines = _a.loadingLines, _d = _a.open, open = _d === void 0 ? true : _d, otherApps = _a.otherApps;
|
|
111
112
|
var theme = (0, useCustomTheme_1.useCustomTheme)();
|
|
112
113
|
// Refs let the effects read the latest values without adding them to dep arrays,
|
|
113
114
|
// which would cause infinite toggle loops since changeToggle flips state.
|
|
@@ -143,6 +144,7 @@ function Sidebar(_a) {
|
|
|
143
144
|
: (react_1.default.createElement(MenuItems_1.default, { activeMenu: activeMenu, menus: menus, handleMenuClick: handleMenuClick !== null && handleMenuClick !== void 0 ? handleMenuClick : (function () { }), toggle: toggle, selectedSubMenu: selectedSubMenu }))),
|
|
144
145
|
react_1.default.createElement(react_2.Box, { w: "100%", h: "0.063rem", bg: theme.colors.sidebar.background[200], mb: "0.125rem" }),
|
|
145
146
|
!isDisableAddNew && (react_1.default.createElement(AddNewButton, { toggle: toggle, isLoading: isLoading, onClick: onAddNewClick })),
|
|
147
|
+
react_1.default.createElement(OtherApps_1.default, { toggle: toggle, otherApps: otherApps !== null && otherApps !== void 0 ? otherApps : [] }),
|
|
146
148
|
react_1.default.createElement(CollapseButton, { toggle: toggle, onToggle: changeToggle })))),
|
|
147
149
|
secondaryItems.length > 0 && (react_1.default.createElement(SecondaryBar_1.default, { items: secondaryItems, defaultCollapsed: toggle, collapsedWidth: "3.5rem", expandedWidth: "10rem", selected: selectedSecondaryItem, onItemClick: handleSecondaryNavClick, title: activeTop === null || activeTop === void 0 ? void 0 : activeTop.title }))));
|
|
148
150
|
}
|
|
@@ -14,6 +14,7 @@ export type SidebarProps = {
|
|
|
14
14
|
isLoading?: boolean;
|
|
15
15
|
loadingLines?: number;
|
|
16
16
|
open?: boolean;
|
|
17
|
+
otherApps?: OtherAppsProps['otherApps'];
|
|
17
18
|
};
|
|
18
19
|
export type MenuProps = {
|
|
19
20
|
id: string | number;
|
|
@@ -50,3 +51,13 @@ export type SecondaryBarProps = {
|
|
|
50
51
|
onItemClick?: (item: MenuProps) => void;
|
|
51
52
|
title?: string;
|
|
52
53
|
};
|
|
54
|
+
export type OtherAppsProps = {
|
|
55
|
+
toggle: boolean;
|
|
56
|
+
otherApps: {
|
|
57
|
+
name: string;
|
|
58
|
+
color: string;
|
|
59
|
+
description?: string;
|
|
60
|
+
onClick: () => void;
|
|
61
|
+
icon?: React.ReactNode;
|
|
62
|
+
}[];
|
|
63
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var react_1 = __importDefault(require("react"));
|
|
7
|
+
var react_2 = require("@chakra-ui/react");
|
|
8
|
+
var useCustomTheme_1 = require("../../../Theme/useCustomTheme");
|
|
9
|
+
var OtherApps = function (_a) {
|
|
10
|
+
var toggle = _a.toggle, otherApps = _a.otherApps;
|
|
11
|
+
var theme = (0, useCustomTheme_1.useCustomTheme)();
|
|
12
|
+
if (!otherApps || otherApps.length === 0)
|
|
13
|
+
return null;
|
|
14
|
+
var row = function (app) { return (react_1.default.createElement(react_2.Flex, { alignItems: "center", gap: "0.625rem", px: "0.625rem", py: "0.5rem", w: "100%", cursor: "pointer", justifyContent: toggle ? "center" : "flex-start", _hover: { backgroundColor: theme.colors.primary[500] }, transition: "background 0.15s", onClick: app.onClick, as: "button", type: "button", border: "none", bg: "transparent", color: "inherit" },
|
|
15
|
+
react_1.default.createElement(react_2.Box, { w: "0.5rem", h: "0.5rem", borderRadius: "full", bg: app.color, flexShrink: 0, boxShadow: "0 0 5px ".concat(app.color) }),
|
|
16
|
+
!toggle && (react_1.default.createElement(react_2.Box, { flex: "1", minW: 0, textAlign: "left" },
|
|
17
|
+
react_1.default.createElement(react_2.Text, { fontSize: "0.8125rem", fontWeight: 500, color: theme.colors.white, isTruncated: true }, app.name),
|
|
18
|
+
app.description && (react_1.default.createElement(react_2.Text, { fontSize: "0.6875rem", color: theme.colors.gray[400], isTruncated: true }, app.description)))))); };
|
|
19
|
+
var flyoutBody = function (app) {
|
|
20
|
+
var _a;
|
|
21
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
22
|
+
react_1.default.createElement(react_2.Flex, { alignItems: "center", gap: "0.5rem", mb: "0.25rem", onClick: app.onClick }, (_a = app.icon) !== null && _a !== void 0 ? _a : (react_1.default.createElement(react_2.Box, { w: "0.5rem", h: "0.5rem", borderRadius: "full", bg: app.color, boxShadow: "0 0 5px ".concat(app.color), flexShrink: 0 })),
|
|
23
|
+
react_1.default.createElement(react_2.Text, { fontSize: "0.875rem", fontWeight: 700, color: theme.colors.white }, app.name)),
|
|
24
|
+
app.description && (react_1.default.createElement(react_2.Text, { fontSize: "0.75rem", color: theme.colors.gray[400] }, app.description))));
|
|
25
|
+
};
|
|
26
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
27
|
+
react_1.default.createElement(react_2.Box, { w: "100%", h: "0.063rem", bg: theme.colors.sidebar.background[200], mb: "0.125rem" }),
|
|
28
|
+
!toggle && (react_1.default.createElement(react_2.Text, { fontSize: "0.625rem", fontWeight: 600, color: theme.colors.gray[400], letterSpacing: "0.08em", textTransform: "uppercase", px: "0.625rem", pt: "0.5rem", pb: "0.25rem", w: "100%" }, "Other Apps")),
|
|
29
|
+
otherApps.map(function (app) {
|
|
30
|
+
return toggle ? (react_1.default.createElement(react_2.Popover, { key: app.name, trigger: "hover", placement: "right-start", closeOnBlur: false, isLazy: true },
|
|
31
|
+
react_1.default.createElement(react_2.PopoverTrigger, null,
|
|
32
|
+
react_1.default.createElement(react_2.Box, { w: "100%" }, row(app))),
|
|
33
|
+
react_1.default.createElement(react_2.Portal, null,
|
|
34
|
+
react_1.default.createElement(react_2.PopoverContent, { borderRadius: "0.063rem", bg: theme.colors.primary[700], boxShadow: "lg", minW: "10rem", maxW: "14rem", py: "0.125rem", ml: "-0.5rem", border: "none", cursor: "pointer", zIndex: 1500, color: "white" },
|
|
35
|
+
react_1.default.createElement(react_2.PopoverBody, { p: "0.75rem" }, flyoutBody(app)))))) : (react_1.default.createElement(react_2.Box, { key: app.name, w: "100%" }, row(app)));
|
|
36
|
+
})));
|
|
37
|
+
};
|
|
38
|
+
exports.default = OtherApps;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@testing-library/jest-dom";
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
var react_1 = __importDefault(require("react"));
|
|
43
|
+
var react_2 = require("@testing-library/react");
|
|
44
|
+
var user_event_1 = __importDefault(require("@testing-library/user-event"));
|
|
45
|
+
require("@testing-library/jest-dom");
|
|
46
|
+
var react_3 = require("@chakra-ui/react");
|
|
47
|
+
var OtherApps_1 = __importDefault(require("./OtherApps"));
|
|
48
|
+
jest.mock("../../../Theme/useCustomTheme", function () { return ({
|
|
49
|
+
useCustomTheme: function () { return ({
|
|
50
|
+
colors: {
|
|
51
|
+
white: "#fff",
|
|
52
|
+
gray: { 400: "#a0aec0" },
|
|
53
|
+
primary: { 500: "#3182ce", 700: "#2c5282" },
|
|
54
|
+
sidebar: {
|
|
55
|
+
background: {
|
|
56
|
+
200: "#2d3748",
|
|
57
|
+
500: "#1a202c",
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
}); },
|
|
62
|
+
}); });
|
|
63
|
+
var sampleApps = [
|
|
64
|
+
{
|
|
65
|
+
name: "Billing",
|
|
66
|
+
color: "#3182ce",
|
|
67
|
+
description: "Billing app",
|
|
68
|
+
onClick: jest.fn(),
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: "Tickets",
|
|
72
|
+
color: "#38a169",
|
|
73
|
+
onClick: jest.fn(),
|
|
74
|
+
},
|
|
75
|
+
];
|
|
76
|
+
var renderWithChakra = function (ui) { return (0, react_2.render)(react_1.default.createElement(react_3.ChakraProvider, null, ui)); };
|
|
77
|
+
describe("OtherApps", function () {
|
|
78
|
+
beforeEach(function () {
|
|
79
|
+
jest.clearAllMocks();
|
|
80
|
+
});
|
|
81
|
+
it("does not render flyout copy when expanded", function () {
|
|
82
|
+
renderWithChakra(react_1.default.createElement(OtherApps_1.default, { toggle: false, otherApps: sampleApps }));
|
|
83
|
+
expect(react_2.screen.getByText("Other Apps")).toBeInTheDocument();
|
|
84
|
+
expect(react_2.screen.getByText("Billing")).toBeInTheDocument();
|
|
85
|
+
expect(react_2.screen.queryByText(/Open Billing/)).not.toBeInTheDocument();
|
|
86
|
+
});
|
|
87
|
+
it("shows flyout with Open label on hover when collapsed", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
88
|
+
var buttons;
|
|
89
|
+
return __generator(this, function (_a) {
|
|
90
|
+
switch (_a.label) {
|
|
91
|
+
case 0:
|
|
92
|
+
renderWithChakra(react_1.default.createElement(OtherApps_1.default, { toggle: true, otherApps: sampleApps }));
|
|
93
|
+
buttons = react_2.screen.getAllByRole("button");
|
|
94
|
+
expect(buttons).toHaveLength(2);
|
|
95
|
+
return [4 /*yield*/, user_event_1.default.hover(buttons[0])];
|
|
96
|
+
case 1:
|
|
97
|
+
_a.sent();
|
|
98
|
+
return [4 /*yield*/, (0, react_2.waitFor)(function () {
|
|
99
|
+
expect(react_2.screen.getByText(/Open Billing/)).toBeInTheDocument();
|
|
100
|
+
})];
|
|
101
|
+
case 2:
|
|
102
|
+
_a.sent();
|
|
103
|
+
return [2 /*return*/];
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}); });
|
|
107
|
+
it("renders no app rows when otherApps is empty", function () {
|
|
108
|
+
renderWithChakra(react_1.default.createElement(OtherApps_1.default, { toggle: true, otherApps: [] }));
|
|
109
|
+
expect(react_2.screen.queryByRole("button")).not.toBeInTheDocument();
|
|
110
|
+
expect(react_2.screen.queryByText("Billing")).not.toBeInTheDocument();
|
|
111
|
+
});
|
|
112
|
+
});
|