opus-toolkit-components 1.8.1 → 1.8.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,48 +1,53 @@
1
- export interface SidebarMenuItem {
2
- key: string | number;
3
- name: string;
4
- icon?: string;
5
- href?: string;
6
- }
7
-
8
- export interface SidebarMenuGroup {
9
- key: string | number;
10
- name: string;
11
- children: SidebarMenuItem[];
12
- }
13
-
14
- export type SidebarMenu = SidebarMenuItem | SidebarMenuGroup;
15
-
16
- export interface SidebarUser {
17
- id: string | number;
18
- name: string;
19
- role: string;
20
- avatar?: string;
21
- }
22
-
23
- export interface SidebarProps extends React.HTMLAttributes<HTMLDivElement> {
24
- menus: SidebarMenu[];
25
- user: SidebarUser;
26
-
27
- /** Currently selected (active) menu item */
28
- activeItem?: string | number | null;
29
- onItemClick?: (key: string | number) => void;
30
-
31
- /** Optional logo override */
32
- logo?: string;
33
-
34
- /** Controlled search input state */
35
- searchValue?: string;
36
- onSearchChange?: (value: string) => void;
37
-
38
- /** Controlled open/closed state for menu groups */
39
- openGroupKey?: string | number | null;
40
-
41
- /**
42
- * Fired when the user clicks a group header.
43
- * Use this to update `openGroupKey` in the parent.
44
- */
45
- onGroupToggle?: (key: string | number) => void;
46
- }
47
-
48
- export const Sidebar: React.FC<SidebarProps>;
1
+ export interface SidebarMenuItem {
2
+ key: string | number;
3
+ name: string;
4
+ icon?: string;
5
+ href?: string;
6
+ }
7
+
8
+ export interface SidebarMenuGroup {
9
+ key: string | number;
10
+ name: string;
11
+ children: SidebarMenuItem[];
12
+ }
13
+
14
+ export type SidebarMenu = SidebarMenuItem | SidebarMenuGroup;
15
+
16
+ export interface SidebarUser {
17
+ id: string | number;
18
+ name: string;
19
+ role: string;
20
+ avatar?: string;
21
+ }
22
+
23
+ export interface SidebarProps extends React.HTMLAttributes<HTMLDivElement> {
24
+ menus: SidebarMenu[];
25
+ user: SidebarUser;
26
+
27
+ /** Currently selected (active) menu item */
28
+ activeItem?: string | number | null;
29
+ onItemClick?: (key: string | number) => void;
30
+
31
+ /** Optional logo override */
32
+ logo?: string;
33
+
34
+ /** Controlled search input state */
35
+ searchValue?: string;
36
+ onSearchChange?: (value: string) => void;
37
+
38
+ /**
39
+ * REQUIRED.
40
+ * Key of the currently expanded group.
41
+ * Set to `null` to collapse all groups.
42
+ */
43
+ openGroupKey: string | number | null;
44
+
45
+ /**
46
+ * REQUIRED.
47
+ * Fired when the open group changes.
48
+ * Receives the NEXT openGroupKey value.
49
+ */
50
+ onGroupToggle: (openGroupKey: string | number | null) => void;
51
+ }
52
+
53
+ export const Sidebar: React.FC<SidebarProps>;
package/lib/main.js CHANGED
@@ -5563,8 +5563,8 @@ __webpack_require__.r(__webpack_exports__);
5563
5563
  * @typedef {Object} SidebarMenuItem
5564
5564
  * @property {string|number} key
5565
5565
  * @property {string} name
5566
- * @property {string} [icon] // optional icon name depending on your app
5567
- * @property {string} [href] // optional link target
5566
+ * @property {string} [icon]
5567
+ * @property {string} [href]
5568
5568
  */
5569
5569
 
5570
5570
  /**
@@ -5586,7 +5586,7 @@ __webpack_require__.r(__webpack_exports__);
5586
5586
  * @property {string|number} id
5587
5587
  * @property {string} name
5588
5588
  * @property {string} role
5589
- * @property {string} [avatar] // optional depending on your design
5589
+ * @property {string} [avatar]
5590
5590
  */
5591
5591
 
5592
5592
  /**
@@ -5609,15 +5609,16 @@ __webpack_require__.r(__webpack_exports__);
5609
5609
  * @property {string} [logo]
5610
5610
  * Optional logo override.
5611
5611
  *
5612
- * @property {string} [searchValue='']
5613
- /**
5614
- * @property {string|number|null} [openGroupKey]
5615
- * Key of the currently expanded group (controlled).
5616
- *
5617
- * @property {(key: string|number) => void} [onGroupToggle]
5618
- * Fired when a group header is clicked.
5612
+ * @property {string} [searchValue]
5613
+ * Controlled search input value.
5619
5614
  *
5620
5615
  * @property {(value: string) => void} [onSearchChange]
5616
+ *
5617
+ * @property {string|number|null} openGroupKey
5618
+ * REQUIRED. Key of the currently expanded group.
5619
+ *
5620
+ * @property {(openGroupKey: string|number|null) => void} onGroupToggle
5621
+ * REQUIRED. Receives the NEXT open group key.
5621
5622
  */
5622
5623
 
5623
5624
  /**
@@ -5639,10 +5640,14 @@ function Sidebar(_ref) {
5639
5640
  onGroupToggle
5640
5641
  } = _ref;
5641
5642
  const [open, setOpen] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false);
5643
+ const handleGroupToggle = key => {
5644
+ const nextOpenGroupKey = openGroupKey === key ? null : key;
5645
+ onGroupToggle(nextOpenGroupKey);
5646
+ };
5642
5647
  return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsx)("div", {
5643
5648
  className: "flex",
5644
5649
  children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsxs)("div", {
5645
- className: " ".concat(open ? "w-[20rem]" : "w-[3rem]", " transition-width flex min-h-screen flex-col rounded bg-[--color-primary-bg] text-[--color-text-strong] duration-300 ease-in-out"),
5650
+ className: "".concat(open ? "w-[20rem]" : "w-[3rem]", " transition-width flex min-h-screen flex-col rounded bg-[--color-primary-bg] text-[--color-text-strong] duration-300 ease-in-out"),
5646
5651
  children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsxs)("div", {
5647
5652
  className: "flex items-center justify-between p-3 pr-0",
5648
5653
  children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsx)("img", {
@@ -5651,7 +5656,7 @@ function Sidebar(_ref) {
5651
5656
  alt: "C247 Logo",
5652
5657
  className: "sidebar-logo w-75 object-contain"
5653
5658
  }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsx)("button", {
5654
- className: "duration-400 rounded-l-lg bg-[--color-primary-btn] p-2 transition-all ease-in-out hover:bg-[--color-primary-btn-hover] focus:outline-none ".concat(open ? "translate-x-0 opacity-100" : "translate-x-4 opacity-0", " "),
5659
+ className: "duration-400 rounded-l-lg bg-[--color-primary-btn] p-2 transition-all ease-in-out hover:bg-[--color-primary-btn-hover] focus:outline-none ".concat(open ? "translate-x-0 opacity-100" : "translate-x-4 opacity-0"),
5655
5660
  onClick: () => setOpen(!open),
5656
5661
  children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsx)(_heroicons_react_24_outline__WEBPACK_IMPORTED_MODULE_1__.ArrowLeftIcon, {
5657
5662
  className: "h-5 w-5 text-[--color-white]"
@@ -5659,7 +5664,7 @@ function Sidebar(_ref) {
5659
5664
  })]
5660
5665
  }), !open && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsx)("button", {
5661
5666
  className: "p-3 transition-all duration-700 ease-in-out focus:outline-none",
5662
- onClick: () => setOpen(!open),
5667
+ onClick: () => setOpen(true),
5663
5668
  children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsx)(_heroicons_react_24_outline__WEBPACK_IMPORTED_MODULE_1__.Bars3Icon, {
5664
5669
  className: "h-6 w-6 text-[--color-text-strong] hover:text-[--color-primary-hover]"
5665
5670
  })
@@ -5688,20 +5693,18 @@ function Sidebar(_ref) {
5688
5693
  }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsx)("div", {
5689
5694
  className: "menu-item-container",
5690
5695
  children: menus.map(menu => menu.children ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsx)(_SidebarGroup__WEBPACK_IMPORTED_MODULE_3__["default"], {
5691
- // composite key
5692
5696
  menu: menu,
5693
5697
  open: open,
5694
5698
  activeItem: activeItem,
5695
5699
  onItemClick: onItemClick,
5696
5700
  toggleSidebar: setOpen,
5697
5701
  isOpen: openGroupKey === menu.key,
5698
- onToggle: () => onGroupToggle === null || onGroupToggle === void 0 ? void 0 : onGroupToggle(menu.key)
5702
+ onToggle: () => handleGroupToggle(menu.key)
5699
5703
  }, "group-".concat(menu.key, "-").concat(menu.name)) : /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsx)(_SidebarItem__WEBPACK_IMPORTED_MODULE_2__["default"], {
5700
- // composite key
5701
5704
  menu: menu,
5702
5705
  open: open,
5703
5706
  active: activeItem === menu.key,
5704
- onClick: () => onItemClick(menu.key)
5707
+ onClick: () => onItemClick === null || onItemClick === void 0 ? void 0 : onItemClick(menu.key)
5705
5708
  }, "item-".concat(menu.key, "-").concat(menu.name)))
5706
5709
  })]
5707
5710
  }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsx)(_SidebarProfile__WEBPACK_IMPORTED_MODULE_4__["default"], {
@@ -50782,14 +50785,12 @@ __webpack_require__.r(__webpack_exports__);
50782
50785
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
50783
50786
  /* harmony export */ "default": () => (/* binding */ SidebarGroup)
50784
50787
  /* harmony export */ });
50785
- /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9206);
50786
- /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
50787
- /* harmony import */ var _heroicons_react_24_outline__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(58964);
50788
- /* harmony import */ var _SidebarItem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(69374);
50789
- /* harmony import */ var _Text_Text__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(21111);
50790
- /* harmony import */ var _Icon_Icon__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(57739);
50791
- /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(94178);
50792
- /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__);
50788
+ /* harmony import */ var _heroicons_react_24_outline__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(58964);
50789
+ /* harmony import */ var _SidebarItem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(69374);
50790
+ /* harmony import */ var _Text_Text__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(21111);
50791
+ /* harmony import */ var _Icon_Icon__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(57739);
50792
+ /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(94178);
50793
+ /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__);
50793
50794
  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; }
50794
50795
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).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; }
50795
50796
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
@@ -50800,7 +50801,6 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
50800
50801
 
50801
50802
 
50802
50803
 
50803
-
50804
50804
  /**
50805
50805
  * Icon props used by your dynamic Icon component (optional).
50806
50806
  * @typedef {import('../Icon/Icon').IconProps} IconProps
@@ -50845,14 +50845,11 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
50845
50845
  * @property {(open: boolean) => void} toggleSidebar
50846
50846
  * Opens the sidebar when a user clicks a collapsed group.
50847
50847
  *
50848
- *
50849
- * // NEW CONTROLLED STATE PROPS:
50850
- *
50851
50848
  * @property {boolean} isOpen
50852
- * Whether THIS group’s children are currently expanded.
50849
+ * REQUIRED. Whether this group’s children are expanded.
50853
50850
  *
50854
- * @property {(key: string|number) => void} onToggle
50855
- * Fired when the group header is clicked. Parent controls open/close.
50851
+ * @property {() => void} onToggle
50852
+ * REQUIRED. Called when the group header is clicked.
50856
50853
  */
50857
50854
 
50858
50855
  /**
@@ -50871,34 +50868,34 @@ function SidebarGroup(_ref) {
50871
50868
  isOpen,
50872
50869
  onToggle
50873
50870
  } = _ref;
50874
- return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)("div", {
50875
- children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)("div", {
50871
+ return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxs)("div", {
50872
+ children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxs)("div", {
50876
50873
  className: "group relative flex cursor-pointer items-center justify-between p-4 transition-all duration-500 ease-in-out",
50877
50874
  onClick: () => {
50878
50875
  if (!open) toggleSidebar(true);
50879
- onToggle(menu.key); // let parent handle open/close
50876
+ onToggle(); // Sidebar computes next openGroupKey
50880
50877
  },
50881
- children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)("div", {
50878
+ children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)("div", {
50882
50879
  className: "absolute left-0 top-0 h-full w-[5px] rounded-r transition-all duration-300 ease-in-out ".concat(isOpen || activeItem === menu.key ? "bg-[--color-brand-primary]" : "bg-[--color-stroke] group-hover:bg-[--color-brand-primary]")
50883
- }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)("div", {
50880
+ }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxs)("div", {
50884
50881
  className: "flex items-center gap-3",
50885
- children: [menu.iconProps && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_Icon_Icon__WEBPACK_IMPORTED_MODULE_4__["default"], _objectSpread({}, menu.iconProps)), !open && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)("span", {
50882
+ children: [menu.iconProps && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(_Icon_Icon__WEBPACK_IMPORTED_MODULE_3__["default"], _objectSpread({}, menu.iconProps)), !open && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)("span", {
50886
50883
  className: "absolute left-full top-1/2 ml-2 -translate-y-1/2 whitespace-nowrap rounded bg-[--color-primary-bg] px-2 py-1 text-xs text-[--color-text-strong] opacity-0 transition-opacity duration-300 group-hover:opacity-100",
50887
50884
  children: menu.name
50888
- }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)("div", {
50885
+ }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)("div", {
50889
50886
  className: "overflow-hidden whitespace-nowrap transition-all duration-500 ease-in-out ".concat(open ? "ml-2 w-auto translate-y-0 opacity-100" : "ml-0 w-0 translate-y-2 opacity-0"),
50890
- children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_Text_Text__WEBPACK_IMPORTED_MODULE_3__["default"], {
50887
+ children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(_Text_Text__WEBPACK_IMPORTED_MODULE_2__["default"], {
50891
50888
  as: "span",
50892
50889
  variant: "label",
50893
50890
  children: menu.name
50894
50891
  })
50895
50892
  })]
50896
- }), open && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_heroicons_react_24_outline__WEBPACK_IMPORTED_MODULE_1__.ChevronDownIcon, {
50893
+ }), open && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(_heroicons_react_24_outline__WEBPACK_IMPORTED_MODULE_0__.ChevronDownIcon, {
50897
50894
  className: "h-4 w-4 transition-transform duration-300 ".concat(isOpen ? "rotate-180" : "")
50898
50895
  })]
50899
- }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)("div", {
50896
+ }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)("div", {
50900
50897
  className: "ml-10 mt-1 overflow-hidden transition-all duration-300 ease-in-out ".concat(isOpen && open ? "max-h-96 opacity-100" : "max-h-0 opacity-0"),
50901
- children: menu.children.map(child => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_SidebarItem__WEBPACK_IMPORTED_MODULE_2__["default"], {
50898
+ children: menu.children.map(child => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(_SidebarItem__WEBPACK_IMPORTED_MODULE_1__["default"], {
50902
50899
  menu: child,
50903
50900
  open: open,
50904
50901
  active: activeItem === child.key,