opus-toolkit-components 2.0.1 → 2.0.2

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.
@@ -1,57 +1,60 @@
1
- import type { IconProps } from "../Icon";
2
-
3
- export interface SidebarMenuItem {
4
- key: string | number;
5
- name: string;
6
- path?: string;
7
- href?: string;
8
- iconProps?: IconProps;
9
- onClick?: (key: string | number) => void;
10
- }
11
-
12
- export interface SidebarMenuGroup {
13
- key: string | number;
14
- name: string;
15
- iconProps?: IconProps;
16
- children: SidebarMenuItem[];
17
- }
18
-
19
- export type SidebarMenu = SidebarMenuItem | SidebarMenuGroup;
20
-
21
- export interface SidebarUser {
22
- id: string | number;
23
- name: string;
24
- role: string;
25
- avatar?: string;
26
- }
27
-
28
- export interface SidebarProps extends React.HTMLAttributes<HTMLDivElement> {
29
- menus: SidebarMenu[];
30
- user: SidebarUser;
31
-
32
- /** Currently selected (active) menu item */
33
- activeItem?: string | number | null;
34
- onItemClick?: (key: string | number) => void;
35
-
36
- /** Optional logo override */
37
- logo?: string;
38
-
39
- /** Controlled search input state */
40
- searchValue?: string;
41
- onSearchChange?: (value: string) => void;
42
-
43
- /**
44
- * Optional controlled key of the currently expanded group.
45
- * Set to `null` to collapse all groups.
46
- * When omitted, the Sidebar manages expansion state internally.
47
- */
48
- openGroupKey?: string | number | null;
49
-
50
- /**
51
- * Optional controlled change handler.
52
- * Receives the NEXT openGroupKey value.
53
- */
54
- onGroupToggle?: (openGroupKey: string | number | null) => void;
55
- }
56
-
57
- export const Sidebar: React.FC<SidebarProps>;
1
+ import type { IconProps } from "../Icon";
2
+
3
+ export interface SidebarMenuItem {
4
+ key: string | number;
5
+ name: string;
6
+ path?: string;
7
+ href?: string;
8
+ iconProps?: IconProps;
9
+ onClick?: (key: string | number) => void;
10
+ }
11
+
12
+ export interface SidebarMenuGroup {
13
+ key: string | number;
14
+ name: string;
15
+ iconProps?: IconProps;
16
+ children: SidebarMenuItem[];
17
+ }
18
+
19
+ export type SidebarMenu = SidebarMenuItem | SidebarMenuGroup;
20
+
21
+ export interface SidebarUser {
22
+ id: string | number;
23
+ name: string;
24
+ role: string;
25
+ avatar?: string;
26
+ }
27
+
28
+ export interface SidebarProps extends React.HTMLAttributes<HTMLDivElement> {
29
+ menus: SidebarMenu[];
30
+ user: SidebarUser;
31
+
32
+ /** Currently selected (active) menu item */
33
+ activeItem?: string | number | null;
34
+ onItemClick?: (key: string | number) => void;
35
+
36
+ /** Optional logo override */
37
+ logo?: string;
38
+
39
+ /** Controlled search input state */
40
+ searchValue?: string;
41
+ onSearchChange?: (value: string) => void;
42
+
43
+ /**
44
+ * Optional controlled key of the currently expanded group.
45
+ * Set to `null` to collapse all groups.
46
+ * When omitted, the Sidebar manages expansion state internally.
47
+ */
48
+ openGroupKey?: string | number | null;
49
+
50
+ /**
51
+ * Optional controlled change handler.
52
+ * Receives the NEXT openGroupKey value.
53
+ */
54
+ onGroupToggle?: (openGroupKey: string | number | null) => void;
55
+
56
+ /** Optional callback fired when the user clicks the logout button in the profile card. */
57
+ onLogout?: () => void;
58
+ }
59
+
60
+ export const Sidebar: React.FC<SidebarProps>;
@@ -820,27 +820,41 @@ __webpack_require__.r(__webpack_exports__);
820
820
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
821
821
  /* harmony export */ "default": () => (/* binding */ SidebarProfile)
822
822
  /* harmony export */ });
823
- /* harmony import */ var _Profile_ProfileCard_ProfileCard__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4977);
824
- /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4178);
825
- /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__);
823
+ /* harmony import */ var _heroicons_react_24_outline__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(148);
824
+ /* harmony import */ var _heroicons_react_24_outline__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_heroicons_react_24_outline__WEBPACK_IMPORTED_MODULE_0__);
825
+ /* harmony import */ var _Profile_ProfileCard_ProfileCard__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4977);
826
+ /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4178);
827
+ /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__);
828
+
826
829
 
827
830
 
828
831
  function SidebarProfile(_ref) {
829
832
  let {
830
833
  user,
831
834
  open,
832
- href
835
+ href,
836
+ onLogout
833
837
  } = _ref;
834
- return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)("div", {
838
+ return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)("div", {
835
839
  className: "mt-auto flex items-center gap-3 p-2 pb-4",
836
- children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)("img", {
840
+ children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("img", {
837
841
  src: user.avatar,
838
842
  alt: "profile",
839
843
  className: "h-8 w-8 rounded-full"
840
- }), open && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(_Profile_ProfileCard_ProfileCard__WEBPACK_IMPORTED_MODULE_0__["default"], {
841
- user: user,
842
- href: href,
843
- variant: "sidebar"
844
+ }), open && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)("div", {
845
+ className: "flex flex-1 items-center justify-between gap-2",
846
+ children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)(_Profile_ProfileCard_ProfileCard__WEBPACK_IMPORTED_MODULE_1__["default"], {
847
+ user: user,
848
+ href: href,
849
+ variant: "sidebar"
850
+ }), onLogout && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("button", {
851
+ onClick: onLogout,
852
+ title: "Log out",
853
+ className: "rounded p-1 text-[--color-text-strong] transition-colors hover:bg-[--color-primary-bg-hover] hover:text-[--color-primary]",
854
+ children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)(_heroicons_react_24_outline__WEBPACK_IMPORTED_MODULE_0__.ArrowRightOnRectangleIcon, {
855
+ className: "h-5 w-5"
856
+ })
857
+ })]
844
858
  })]
845
859
  });
846
860
  }
@@ -992,7 +1006,7 @@ __webpack_require__.r(__webpack_exports__);
992
1006
 
993
1007
  var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
994
1008
  // Module
995
- ___CSS_LOADER_EXPORT___.push([module.id, `.sidebar-logo{width:24px;height:auto}`, "",{"version":3,"sources":["webpack://./src/components/Sidebar/sidebar.scss"],"names":[],"mappings":"AAAA,cACI,UAAA,CACA,WAAA","sourcesContent":[".sidebar-logo {\r\n width:24px;\r\n height: auto;\r\n}"],"sourceRoot":""}]);
1009
+ ___CSS_LOADER_EXPORT___.push([module.id, `.sidebar-logo{width:24px;height:auto}.menu-item-container{overflow-y:auto;scrollbar-width:none;-ms-overflow-style:none;min-height:0}.menu-item-container::-webkit-scrollbar{display:none}`, "",{"version":3,"sources":["webpack://./src/components/Sidebar/sidebar.scss"],"names":[],"mappings":"AAAA,cACI,UAAA,CACA,WAAA,CAGJ,qBACI,eAAA,CACA,oBAAA,CACA,uBAAA,CACA,YAAA,CAEA,wCACI,YAAA","sourcesContent":[".sidebar-logo {\r\n width:24px;\r\n height: auto;\r\n}\r\n\r\n.menu-item-container {\r\n overflow-y: auto;\r\n scrollbar-width: none;\r\n -ms-overflow-style: none;\r\n min-height: 0;\r\n\r\n &::-webkit-scrollbar {\r\n display: none;\r\n }\r\n}"],"sourceRoot":""}]);
996
1010
  // Exports
997
1011
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
998
1012
 
@@ -1567,75 +1581,78 @@ __webpack_require__.r(__webpack_exports__);
1567
1581
 
1568
1582
 
1569
1583
 
1570
- /**
1571
- * A single menu item (no children).
1572
- * @typedef {Object} SidebarMenuItem
1573
- * @property {string|number} key
1574
- * @property {string} name
1575
- * @property {string} [path]
1576
- * @property {string} [href]
1577
- * @property {import('../Icon').IconProps} [iconProps]
1578
- * @property {(key: string|number) => void} [onClick]
1584
+ /**
1585
+ * A single menu item (no children).
1586
+ * @typedef {Object} SidebarMenuItem
1587
+ * @property {string|number} key
1588
+ * @property {string} name
1589
+ * @property {string} [path]
1590
+ * @property {string} [href]
1591
+ * @property {import('../Icon').IconProps} [iconProps]
1592
+ * @property {(key: string|number) => void} [onClick]
1579
1593
  */
1580
1594
 
1581
- /**
1582
- * A grouped menu entry with children.
1583
- * @typedef {Object} SidebarMenuGroup
1584
- * @property {string|number} key
1585
- * @property {string} name
1586
- * @property {SidebarMenuItem[]} children
1595
+ /**
1596
+ * A grouped menu entry with children.
1597
+ * @typedef {Object} SidebarMenuGroup
1598
+ * @property {string|number} key
1599
+ * @property {string} name
1600
+ * @property {SidebarMenuItem[]} children
1587
1601
  */
1588
1602
 
1589
- /**
1590
- * A full menu entry (either group or leaf item).
1591
- * @typedef {SidebarMenuItem | SidebarMenuGroup} SidebarMenu
1603
+ /**
1604
+ * A full menu entry (either group or leaf item).
1605
+ * @typedef {SidebarMenuItem | SidebarMenuGroup} SidebarMenu
1592
1606
  */
1593
1607
 
1594
- /**
1595
- * Minimal shape expected for SidebarProfile.
1596
- * @typedef {Object} SidebarUser
1597
- * @property {string|number} id
1598
- * @property {string} name
1599
- * @property {string} role
1600
- * @property {string} [avatar]
1608
+ /**
1609
+ * Minimal shape expected for SidebarProfile.
1610
+ * @typedef {Object} SidebarUser
1611
+ * @property {string|number} id
1612
+ * @property {string} name
1613
+ * @property {string} role
1614
+ * @property {string} [avatar]
1601
1615
  */
1602
1616
 
1603
- /**
1604
- * Props for Sidebar.
1605
- *
1606
- * @typedef {Object} SidebarProps
1607
- *
1608
- * @property {SidebarMenu[]} menus
1609
- * All sidebar menu items (groups + items).
1610
- *
1611
- * @property {SidebarUser} user
1612
- * The current logged-in user.
1613
- *
1614
- * @property {string|number|null} [activeItem]
1615
- * Key of the currently selected item.
1616
- *
1617
- * @property {(key: string|number) => void} [onItemClick]
1618
- * Fired when a menu item is clicked.
1619
- *
1620
- * @property {string} [logo]
1621
- * Optional logo override.
1622
- *
1623
- * @property {string} [searchValue]
1624
- * Controlled search input value.
1625
- *
1626
- * @property {(value: string) => void} [onSearchChange]
1627
- *
1628
- * @property {string|number|null} [openGroupKey]
1629
- * Optional controlled key of the currently expanded group.
1630
- *
1631
- * @property {(openGroupKey: string|number|null) => void} [onGroupToggle]
1632
- * Optional controlled change handler. If omitted, Sidebar manages group state internally.
1617
+ /**
1618
+ * Props for Sidebar.
1619
+ *
1620
+ * @typedef {Object} SidebarProps
1621
+ *
1622
+ * @property {SidebarMenu[]} menus
1623
+ * All sidebar menu items (groups + items).
1624
+ *
1625
+ * @property {SidebarUser} user
1626
+ * The current logged-in user.
1627
+ *
1628
+ * @property {string|number|null} [activeItem]
1629
+ * Key of the currently selected item.
1630
+ *
1631
+ * @property {(key: string|number) => void} [onItemClick]
1632
+ * Fired when a menu item is clicked.
1633
+ *
1634
+ * @property {string} [logo]
1635
+ * Optional logo override.
1636
+ *
1637
+ * @property {string} [searchValue]
1638
+ * Controlled search input value.
1639
+ *
1640
+ * @property {(value: string) => void} [onSearchChange]
1641
+ *
1642
+ * @property {string|number|null} [openGroupKey]
1643
+ * Optional controlled key of the currently expanded group.
1644
+ *
1645
+ * @property {(openGroupKey: string|number|null) => void} [onGroupToggle]
1646
+ * Optional controlled change handler. If omitted, Sidebar manages group state internally.
1647
+ *
1648
+ * @property {() => void} [onLogout]
1649
+ * Optional callback fired when the user clicks the logout button in the profile card.
1633
1650
  */
1634
1651
 
1635
- /**
1636
- * Fully typed Sidebar component.
1637
- *
1638
- * @param {SidebarProps & React.HTMLAttributes<HTMLDivElement>} props
1652
+ /**
1653
+ * Fully typed Sidebar component.
1654
+ *
1655
+ * @param {SidebarProps & React.HTMLAttributes<HTMLDivElement>} props
1639
1656
  */
1640
1657
 
1641
1658
  function Sidebar(_ref) {
@@ -1649,6 +1666,7 @@ function Sidebar(_ref) {
1649
1666
  onSearchChange,
1650
1667
  openGroupKey,
1651
1668
  onGroupToggle,
1669
+ onLogout,
1652
1670
  ...rest
1653
1671
  } = _ref;
1654
1672
  const [open, setOpen] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false);
@@ -1663,10 +1681,10 @@ function Sidebar(_ref) {
1663
1681
  setInternalOpenGroupKey(nextOpenGroupKey);
1664
1682
  };
1665
1683
  return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsx)("div", {
1666
- className: "flex",
1684
+ className: "flex h-full",
1667
1685
  ...rest,
1668
1686
  children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsxs)("div", {
1669
- className: `${open ? "w-[20rem]" : "w-[3rem]"} transition-width flex min-h-screen flex-col bg-[--color-primary-bg] text-[--color-text-strong] duration-300 ease-in-out`,
1687
+ className: `${open ? "w-[20rem]" : "w-[3rem]"} transition-width flex h-full flex-col bg-[--color-primary-bg] text-[--color-text-strong] duration-300 ease-in-out`,
1670
1688
  children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsxs)("div", {
1671
1689
  className: "flex items-center justify-between p-3 pr-0",
1672
1690
  children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsx)("img", {
@@ -1688,7 +1706,7 @@ function Sidebar(_ref) {
1688
1706
  className: "h-6 w-6 text-[--color-text-strong] hover:text-[--color-primary-hover]"
1689
1707
  })
1690
1708
  }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsxs)("nav", {
1691
- className: "mt-2 flex-1 space-y-1",
1709
+ className: "mt-2 flex min-h-0 flex-1 flex-col overflow-hidden",
1692
1710
  children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsx)("div", {
1693
1711
  className: "border-b-solid border-b-2 border-[--color-stroke] px-3 pb-2",
1694
1712
  children: open ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsxs)("div", {
@@ -1710,7 +1728,7 @@ function Sidebar(_ref) {
1710
1728
  })
1711
1729
  })
1712
1730
  }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsx)("div", {
1713
- className: "menu-item-container",
1731
+ className: "menu-item-container flex-1",
1714
1732
  children: menus.map(menu => menu.children ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsx)(_SidebarGroup__WEBPACK_IMPORTED_MODULE_3__["default"], {
1715
1733
  menu: menu,
1716
1734
  open: open,
@@ -1732,7 +1750,8 @@ function Sidebar(_ref) {
1732
1750
  }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsx)(_SidebarProfile__WEBPACK_IMPORTED_MODULE_4__["default"], {
1733
1751
  user: user,
1734
1752
  open: open,
1735
- href: `/users/${user.id}`
1753
+ href: `/users/${user.id}`,
1754
+ onLogout: onLogout
1736
1755
  })]
1737
1756
  })
1738
1757
  });