@codezee/sixtify-brahma 0.2.43 → 0.2.44

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codezee/sixtify-brahma",
3
- "version": "0.2.43",
3
+ "version": "0.2.44",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/hardikranpariya/sixtify-brahma.git"
@@ -0,0 +1,21 @@
1
+ import type { TabProps as MuiTabProps } from "@mui/material";
2
+ import type { MouseEvent } from "react";
3
+ import type { MenuProps } from "./TabsMenus";
4
+ export type OnArrowClickFunction = (e: MouseEvent<SVGElement>) => void;
5
+ export type TabModel = {
6
+ label: string;
7
+ value: string | number;
8
+ hint?: string;
9
+ showDot?: boolean;
10
+ menu?: MenuProps[];
11
+ trimLabel?: boolean;
12
+ totalData: number;
13
+ };
14
+ export type TabProps = MuiTabProps & TabModel & {
15
+ activeTab: TabModel;
16
+ index: number;
17
+ onArrowClick: OnArrowClickFunction;
18
+ menuAnchor: HTMLElement | null;
19
+ };
20
+ export declare function Tab({ label, value, showDot, menu, trimLabel, activeTab, index, onArrowClick, menuAnchor, totalData, ...rest }: TabProps): import("react/jsx-runtime").JSX.Element;
21
+ //# sourceMappingURL=Tab.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tab.d.ts","sourceRoot":"","sources":["../../src/TabBar/Tab.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AAS7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAExC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;AAEvE,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,SAAS,EAAE,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAIF,MAAM,MAAM,QAAQ,GAAG,WAAW,GAChC,QAAQ,GAAG;IACT,SAAS,EAAE,QAAQ,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,oBAAoB,CAAC;IACnC,UAAU,EAAE,WAAW,GAAG,IAAI,CAAC;CAChC,CAAC;AAGJ,wBAAgB,GAAG,CAAC,EAClB,KAAK,EACL,KAAK,EACL,OAAO,EACP,IAAI,EACJ,SAAgB,EAChB,SAAS,EACT,KAAK,EACL,YAAY,EACZ,UAAU,EACV,SAAS,EACT,GAAG,IAAI,EACR,EAAE,QAAQ,2CAsFV"}
@@ -0,0 +1,56 @@
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
+ exports.Tab = Tab;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const ArrowDropDown_1 = __importDefault(require("@mui/icons-material/ArrowDropDown"));
9
+ const material_1 = require("@mui/material");
10
+ const truncate_1 = __importDefault(require("lodash/truncate"));
11
+ const Chips_1 = require("../Chips");
12
+ const TRIM_LABEL_LENGTH = 15;
13
+ // eslint-disable-next-line sonarjs/cognitive-complexity
14
+ function Tab({ label, value, showDot, menu, trimLabel = true, activeTab, index, onArrowClick, menuAnchor, totalData, ...rest }) {
15
+ const theme = (0, material_1.useTheme)();
16
+ const { butterflyBlue } = theme.palette.app.color;
17
+ const isActive = value === activeTab.value;
18
+ const fallbackTag = label.toLowerCase().replaceAll(/[ _]/g, "-");
19
+ const trimmed = (0, truncate_1.default)(label, {
20
+ length: trimLabel ? TRIM_LABEL_LENGTH : label.length,
21
+ omission: trimLabel ? "..." : "",
22
+ });
23
+ const labelText = isActive ? label : trimmed;
24
+ const props = {
25
+ key: label,
26
+ iconPosition: "end",
27
+ "data-cy": fallbackTag,
28
+ "data-ptag": fallbackTag,
29
+ value: value ?? index,
30
+ label: ((0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", gap: "6px", alignItems: "center", children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body1", children: labelText }), (0, jsx_runtime_1.jsx)(Chips_1.Chip, { label: totalData, sx: { height: "20px" }, size: "small", color: "info" })] })),
31
+ };
32
+ if (label.length > TRIM_LABEL_LENGTH && !isActive) {
33
+ props.title = label;
34
+ }
35
+ if (value === activeTab.value && menu?.length) {
36
+ props.icon = ((0, jsx_runtime_1.jsx)(ArrowDropDown_1.default, { onClick: onArrowClick, id: `tabDropDown-${value}`, "aria-controls": menuAnchor !== null ? `dropDownMenu-${value}` : undefined, "aria-expanded": menuAnchor !== null ? "true" : undefined, "aria-haspopup": "true", "data-cy": `${fallbackTag}-arrowicon`, "data-ptag": `${fallbackTag}-arrowicon` }));
37
+ }
38
+ return showDot ? ((0, jsx_runtime_1.jsx)(material_1.Tab, { sx: {
39
+ borderRadius: "5px",
40
+ borderBottom: "2px solid",
41
+ borderBottomColor: isActive ? butterflyBlue[900] : "white",
42
+ overflow: "visible",
43
+ [`&.${material_1.tabClasses.root}`]: {
44
+ minHeight: "40px",
45
+ height: "40px",
46
+ },
47
+ }, ...props, ...rest })) : ((0, jsx_runtime_1.jsx)(material_1.Tab, { sx: {
48
+ borderRadius: "5px",
49
+ borderBottom: "2px solid",
50
+ borderBottomColor: isActive ? butterflyBlue[900] : "white",
51
+ [`&.${material_1.tabClasses.root}`]: {
52
+ minHeight: "40px",
53
+ height: "40px",
54
+ },
55
+ }, ...props, ...rest }));
56
+ }
@@ -0,0 +1,12 @@
1
+ import type { ReactNode } from "react";
2
+ import type { TabModel } from "./Tab";
3
+ export type TabBarProps = {
4
+ tabs: TabModel[];
5
+ activeIndex?: number;
6
+ ariaLabel?: string;
7
+ addButton?: ReactNode;
8
+ actionButton?: ReactNode;
9
+ onChange?: (value: TabModel) => void;
10
+ };
11
+ export declare function TabBar({ tabs, onChange, addButton, actionButton, ariaLabel, activeIndex, }: Readonly<TabBarProps>): import("react/jsx-runtime").JSX.Element;
12
+ //# sourceMappingURL=TabBar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TabBar.d.ts","sourceRoot":"","sources":["../../src/TabBar/TabBar.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAc,SAAS,EAAkB,MAAM,OAAO,CAAC;AAEnE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAItC,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAC;CACtC,CAAC;AAEF,wBAAgB,MAAM,CAAC,EACrB,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,SAAS,EACT,WAAe,GAChB,EAAE,QAAQ,CAAC,WAAW,CAAC,2CAsFvB"}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TabBar = TabBar;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const material_1 = require("@mui/material");
6
+ const react_1 = require("react");
7
+ const Tab_1 = require("./Tab");
8
+ const TabsMenus_1 = require("./TabsMenus");
9
+ function TabBar({ tabs, onChange, addButton, actionButton, ariaLabel, activeIndex = 0, }) {
10
+ const [activeTab, setActiveTab] = (0, react_1.useState)(tabs[activeIndex]);
11
+ const [anchorEl, setAnchorEl] = (0, react_1.useState)(null);
12
+ (0, react_1.useEffect)(() => {
13
+ const activeTabIndex = tabs.findIndex((tab) => tab.value === activeTab.value);
14
+ if (activeTabIndex === -1) {
15
+ if (onChange && tabs[0]) {
16
+ onChange(tabs[0]);
17
+ }
18
+ setActiveTab(tabs[0]);
19
+ }
20
+ }, [tabs, activeTab, onChange]);
21
+ (0, react_1.useEffect)(() => {
22
+ setActiveTab(tabs[activeIndex]);
23
+ }, [activeIndex]);
24
+ const tabChangeHandler = (_event, newTabValue) => {
25
+ const newActiveTab = tabs.find((tab) => tab.value === newTabValue);
26
+ if (newActiveTab) {
27
+ setActiveTab(newActiveTab);
28
+ // eslint-disable-next-line sonarjs/no-gratuitous-expressions
29
+ if (onChange && newActiveTab) {
30
+ onChange(newActiveTab);
31
+ }
32
+ }
33
+ };
34
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsx)(TabsMenus_1.TabsMenus, { activeTab: activeTab, tabs: tabs, onClose: () => setAnchorEl(null), onMenuItemClick: () => setAnchorEl(null), menuAnchor: anchorEl }), (0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", justifyContent: "space-between", children: [(0, jsx_runtime_1.jsx)(material_1.Stack, { direction: "row", overflow: "hidden", children: (0, jsx_runtime_1.jsx)(material_1.Tabs, { value: activeTab.value, onChange: tabChangeHandler, TabIndicatorProps: {
35
+ sx: {
36
+ display: "none",
37
+ },
38
+ }, variant: "scrollable", scrollButtons: "auto", ScrollButtonComponent: material_1.TabScrollButton, "aria-label": ariaLabel ?? "Tabs", children: tabs.map((tab, index) => ((0, jsx_runtime_1.jsx)(Tab_1.Tab, { index: index, activeTab: activeTab, onArrowClick: (event) => {
39
+ setAnchorEl(event.target);
40
+ }, menuAnchor: anchorEl, ...tab }, tab.value))) }) }), (0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", gap: "10px", alignItems: "center", children: [addButton, actionButton] })] })] }));
41
+ }
@@ -0,0 +1,15 @@
1
+ import type { TabModel } from "./Tab";
2
+ export type MenuProps = {
3
+ label: string;
4
+ disabled?: boolean;
5
+ onClick: (tab: TabModel) => void;
6
+ };
7
+ export type TabsMenusProps = {
8
+ tabs: TabModel[];
9
+ menuAnchor: HTMLElement | null;
10
+ activeTab: TabModel;
11
+ onClose: () => void;
12
+ onMenuItemClick: () => void;
13
+ };
14
+ export declare function TabsMenus({ tabs, activeTab, menuAnchor, onClose, onMenuItemClick, }: Readonly<TabsMenusProps>): import("react/jsx-runtime").JSX.Element;
15
+ //# sourceMappingURL=TabsMenus.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TabsMenus.d.ts","sourceRoot":"","sources":["../../src/TabBar/TabsMenus.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtC,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,CAAC,GAAG,EAAE,QAAQ,KAAK,IAAI,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,UAAU,EAAE,WAAW,GAAG,IAAI,CAAC;IAC/B,SAAS,EAAE,QAAQ,CAAC;IACpB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,eAAe,EAAE,MAAM,IAAI,CAAC;CAC7B,CAAC;AAEF,wBAAgB,SAAS,CAAC,EACxB,IAAI,EACJ,SAAS,EACT,UAAU,EACV,OAAO,EACP,eAAe,GAChB,EAAE,QAAQ,CAAC,cAAc,CAAC,2CAgC1B"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TabsMenus = TabsMenus;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const material_1 = require("@mui/material");
6
+ function TabsMenus({ tabs, activeTab, menuAnchor, onClose, onMenuItemClick, }) {
7
+ return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: tabs
8
+ .filter((tab) => !!tab.menu)
9
+ .map((tab) => ((0, jsx_runtime_1.jsx)(material_1.Menu, { anchorEl: menuAnchor, open: tab.value === activeTab.value && !!menuAnchor, onClose: onClose, id: `dropDownMenu-${tab.value}`, MenuListProps: {
10
+ "aria-labelledby": `tabDropDown-${tab.value}`,
11
+ }, children: tab.menu?.map((menuItem) => ((0, jsx_runtime_1.jsx)(material_1.MenuItem, { onClick: () => {
12
+ onMenuItemClick();
13
+ menuItem.onClick(activeTab);
14
+ }, disabled: menuItem.disabled, children: menuItem.label }, menuItem.label))) }, tab.value))) }));
15
+ }
@@ -0,0 +1,7 @@
1
+ export { TabBar } from "./TabBar";
2
+ export type { TabBarProps } from "./TabBar";
3
+ export { Tab } from "./Tab";
4
+ export type { OnArrowClickFunction, TabModel, TabProps } from "./Tab";
5
+ export { TabsMenus } from "./TabsMenus";
6
+ export type { MenuProps as TabMenuProps, TabsMenusProps } from "./TabsMenus";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/TabBar/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,YAAY,EAAE,oBAAoB,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,SAAS,IAAI,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TabsMenus = exports.Tab = exports.TabBar = void 0;
4
+ var TabBar_1 = require("./TabBar");
5
+ Object.defineProperty(exports, "TabBar", { enumerable: true, get: function () { return TabBar_1.TabBar; } });
6
+ var Tab_1 = require("./Tab");
7
+ Object.defineProperty(exports, "Tab", { enumerable: true, get: function () { return Tab_1.Tab; } });
8
+ var TabsMenus_1 = require("./TabsMenus");
9
+ Object.defineProperty(exports, "TabsMenus", { enumerable: true, get: function () { return TabsMenus_1.TabsMenus; } });
@@ -20,6 +20,7 @@ export * from "./Pagination";
20
20
  export * from "./Stepper";
21
21
  export * from "./Svgs";
22
22
  export * from "./Tab";
23
+ export * from "./TabBar";
23
24
  export * from "./Timeline";
24
25
  export * from "./Toast";
25
26
  export * from "./Tooltip";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,SAAS,CAAC"}
@@ -36,6 +36,7 @@ __exportStar(require("./Pagination"), exports);
36
36
  __exportStar(require("./Stepper"), exports);
37
37
  __exportStar(require("./Svgs"), exports);
38
38
  __exportStar(require("./Tab"), exports);
39
+ __exportStar(require("./TabBar"), exports);
39
40
  __exportStar(require("./Timeline"), exports);
40
41
  __exportStar(require("./Toast"), exports);
41
42
  __exportStar(require("./Tooltip"), exports);