opus-toolkit-components 1.7.4 → 1.7.6

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.
@@ -5558,66 +5558,72 @@ __webpack_require__.r(__webpack_exports__);
5558
5558
 
5559
5559
 
5560
5560
 
5561
- /**
5562
- * A single menu item (no children).
5563
- * @typedef {Object} SidebarMenuItem
5564
- * @property {string|number} key
5565
- * @property {string} name
5566
- * @property {string} [icon] // optional icon name depending on your app
5567
- * @property {string} [href] // optional link target
5561
+ /**
5562
+ * A single menu item (no children).
5563
+ * @typedef {Object} SidebarMenuItem
5564
+ * @property {string|number} key
5565
+ * @property {string} name
5566
+ * @property {string} [icon] // optional icon name depending on your app
5567
+ * @property {string} [href] // optional link target
5568
5568
  */
5569
5569
 
5570
- /**
5571
- * A grouped menu entry with children.
5572
- * @typedef {Object} SidebarMenuGroup
5573
- * @property {string|number} key
5574
- * @property {string} name
5575
- * @property {SidebarMenuItem[]} children
5570
+ /**
5571
+ * A grouped menu entry with children.
5572
+ * @typedef {Object} SidebarMenuGroup
5573
+ * @property {string|number} key
5574
+ * @property {string} name
5575
+ * @property {SidebarMenuItem[]} children
5576
5576
  */
5577
5577
 
5578
- /**
5579
- * A full menu entry (either group or leaf item).
5580
- * @typedef {SidebarMenuItem | SidebarMenuGroup} SidebarMenu
5578
+ /**
5579
+ * A full menu entry (either group or leaf item).
5580
+ * @typedef {SidebarMenuItem | SidebarMenuGroup} SidebarMenu
5581
5581
  */
5582
5582
 
5583
- /**
5584
- * Minimal shape expected for SidebarProfile.
5585
- * @typedef {Object} SidebarUser
5586
- * @property {string|number} id
5587
- * @property {string} name
5588
- * @property {string} role
5589
- * @property {string} [avatar] // optional depending on your design
5583
+ /**
5584
+ * Minimal shape expected for SidebarProfile.
5585
+ * @typedef {Object} SidebarUser
5586
+ * @property {string|number} id
5587
+ * @property {string} name
5588
+ * @property {string} role
5589
+ * @property {string} [avatar] // optional depending on your design
5590
5590
  */
5591
5591
 
5592
- /**
5593
- * Props for Sidebar.
5594
- *
5595
- * @typedef {Object} SidebarProps
5596
- *
5597
- * @property {SidebarMenu[]} menus
5598
- * All sidebar menu items (groups + items).
5599
- *
5600
- * @property {SidebarUser} user
5601
- * The current logged-in user.
5602
- *
5603
- * @property {string|number|null} [activeItem]
5604
- * Key of the currently selected item.
5605
- *
5606
- * @property {(key: string|number) => void} [onItemClick]
5607
- * Fired when a menu item is clicked.
5608
- *
5609
- * @property {string} [logo]
5610
- * Optional logo override.
5611
- *
5612
- * @property {string} [searchValue='']
5613
- *
5614
- * @property {(value: string) => void} [onSearchChange]
5592
+ /**
5593
+ * Props for Sidebar.
5594
+ *
5595
+ * @typedef {Object} SidebarProps
5596
+ *
5597
+ * @property {SidebarMenu[]} menus
5598
+ * All sidebar menu items (groups + items).
5599
+ *
5600
+ * @property {SidebarUser} user
5601
+ * The current logged-in user.
5602
+ *
5603
+ * @property {string|number|null} [activeItem]
5604
+ * Key of the currently selected item.
5605
+ *
5606
+ * @property {(key: string|number) => void} [onItemClick]
5607
+ * Fired when a menu item is clicked.
5608
+ *
5609
+ * @property {string} [logo]
5610
+ * Optional logo override.
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.
5619
+ *
5620
+ * @property {(value: string) => void} [onSearchChange]
5615
5621
  */
5616
5622
 
5617
- /**
5618
- * Fully typed Sidebar component.
5619
- *
5620
- * @param {SidebarProps & React.HTMLAttributes<HTMLDivElement>} props
5623
+ /**
5624
+ * Fully typed Sidebar component.
5625
+ *
5626
+ * @param {SidebarProps & React.HTMLAttributes<HTMLDivElement>} props
5621
5627
  */
5622
5628
 
5623
5629
  function Sidebar(_ref) {
@@ -5628,7 +5634,9 @@ function Sidebar(_ref) {
5628
5634
  onItemClick,
5629
5635
  logo,
5630
5636
  searchValue = "",
5631
- onSearchChange
5637
+ onSearchChange,
5638
+ openGroupKey,
5639
+ onGroupToggle
5632
5640
  } = _ref;
5633
5641
  const [open, setOpen] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false);
5634
5642
  return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsx)("div", {
@@ -5685,7 +5693,9 @@ function Sidebar(_ref) {
5685
5693
  open: open,
5686
5694
  activeItem: activeItem,
5687
5695
  onItemClick: onItemClick,
5688
- toggleSidebar: setOpen
5696
+ toggleSidebar: setOpen,
5697
+ isOpen: openGroupKey === menu.key,
5698
+ onToggle: () => onGroupToggle === null || onGroupToggle === void 0 ? void 0 : onGroupToggle(menu.key)
5689
5699
  }, "group-".concat(menu.key, "-").concat(menu.name)) : /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsx)(_SidebarItem__WEBPACK_IMPORTED_MODULE_2__["default"], {
5690
5700
  // composite key
5691
5701
  menu: menu,
@@ -46323,46 +46333,46 @@ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t =
46323
46333
 
46324
46334
 
46325
46335
 
46326
- /**
46327
- * Icon props (importing from your Icon component typedef).
46328
- * @typedef {import('../Icon/Icon').IconProps} IconProps
46336
+ /**
46337
+ * Icon props (importing from your Icon component typedef).
46338
+ * @typedef {import('../Icon/Icon').IconProps} IconProps
46329
46339
  */
46330
46340
 
46331
- /**
46332
- * A sidebar leaf item (no children).
46333
- * @typedef {Object} SidebarItemMenu
46334
- * @property {string|number} key
46335
- * @property {string} name
46336
- * @property {string} [path]
46337
- * @property {string} [href]
46338
- * @property {IconProps} [iconProps]
46341
+ /**
46342
+ * A sidebar leaf item (no children).
46343
+ * @typedef {Object} SidebarItemMenu
46344
+ * @property {string|number} key
46345
+ * @property {string} name
46346
+ * @property {string} [path]
46347
+ * @property {string} [href]
46348
+ * @property {IconProps} [iconProps]
46339
46349
  */
46340
46350
 
46341
- /**
46342
- * Props for SidebarItem.
46343
- *
46344
- * @typedef {Object} SidebarItemProps
46345
- *
46346
- * @property {SidebarItemMenu} menu
46347
- * The menu item to render.
46348
- *
46349
- * @property {boolean} open
46350
- * Whether the sidebar is expanded.
46351
- *
46352
- * @property {boolean} [active=false]
46353
- * Whether this item is currently active.
46354
- *
46355
- * @property {keyof JSX.IntrinsicElements | React.ComponentType<any>} [as='div']
46356
- * Polymorphic wrapper: div, a, button, Link, etc.
46357
- *
46358
- * @property {() => void} [onClick]
46359
- * Fired when the item is clicked.
46351
+ /**
46352
+ * Props for SidebarItem.
46353
+ *
46354
+ * @typedef {Object} SidebarItemProps
46355
+ *
46356
+ * @property {SidebarItemMenu} menu
46357
+ * The menu item to render.
46358
+ *
46359
+ * @property {boolean} open
46360
+ * Whether the sidebar is expanded.
46361
+ *
46362
+ * @property {boolean} [active=false]
46363
+ * Whether this item is currently active.
46364
+ *
46365
+ * @property {keyof JSX.IntrinsicElements | React.ComponentType<any>} [as='div']
46366
+ * Polymorphic wrapper: div, a, button, Link, etc.
46367
+ *
46368
+ * @property {() => void} [onClick]
46369
+ * Fired when the item is clicked.
46360
46370
  */
46361
46371
 
46362
- /**
46363
- * Fully typed SidebarItem component.
46364
- *
46365
- * @param {SidebarItemProps & React.HTMLAttributes<HTMLElement>} props
46372
+ /**
46373
+ * Fully typed SidebarItem component.
46374
+ *
46375
+ * @param {SidebarItemProps & React.HTMLAttributes<HTMLElement>} props
46366
46376
  */
46367
46377
 
46368
46378
  function SidebarItem(_ref) {
@@ -46370,12 +46380,22 @@ function SidebarItem(_ref) {
46370
46380
  menu,
46371
46381
  open,
46372
46382
  active = false,
46373
- as: Component = "div",
46383
+ as: Component = "a",
46374
46384
  onClick
46375
46385
  } = _ref,
46376
46386
  props = _objectWithoutProperties(_ref, _excluded);
46377
- return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)(Component, _objectSpread(_objectSpread({
46378
- onClick: onClick,
46387
+ // Support both "href" and "path"
46388
+ const navTarget = menu.href || menu.path;
46389
+ const wrapperProps = {};
46390
+ if (Component === "a" && navTarget) {
46391
+ wrapperProps.href = navTarget;
46392
+ }
46393
+ if ((Component === null || Component === void 0 ? void 0 : Component.displayName) === "Link" && navTarget) {
46394
+ wrapperProps.to = navTarget;
46395
+ }
46396
+ return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)(Component, _objectSpread(_objectSpread(_objectSpread({
46397
+ onClick: onClick
46398
+ }, wrapperProps), {}, {
46379
46399
  className: "group relative flex cursor-pointer items-center justify-between p-4 transition-all duration-500 ease-in-out ".concat(active ? "bg-[--color-primary-hover]" : "", " ")
46380
46400
  }, props), {}, {
46381
46401
  children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("div", {
@@ -50651,55 +50671,64 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
50651
50671
 
50652
50672
 
50653
50673
 
50654
- /**
50655
- * Icon props used by your dynamic Icon component (optional).
50656
- * @typedef {import('../Icon/Icon').IconProps} IconProps
50674
+ /**
50675
+ * Icon props used by your dynamic Icon component (optional).
50676
+ * @typedef {import('../Icon/Icon').IconProps} IconProps
50657
50677
  */
50658
50678
 
50659
- /**
50660
- * A single child menu item.
50661
- * @typedef {Object} SidebarChild
50662
- * @property {string|number} key
50663
- * @property {string} name
50664
- * @property {string} [path]
50665
- * @property {string} [href]
50666
- * @property {IconProps} [iconProps]
50679
+ /**
50680
+ * A single child menu item.
50681
+ * @typedef {Object} SidebarChild
50682
+ * @property {string|number} key
50683
+ * @property {string} name
50684
+ * @property {string} [path]
50685
+ * @property {string} [href]
50686
+ * @property {IconProps} [iconProps]
50667
50687
  */
50668
50688
 
50669
- /**
50670
- * Sidebar group object containing children.
50671
- * @typedef {Object} SidebarGroupMenu
50672
- * @property {string|number} key
50673
- * @property {string} name
50674
- * @property {SidebarChild[]} children
50675
- * @property {IconProps} [iconProps]
50689
+ /**
50690
+ * Sidebar group object containing children.
50691
+ * @typedef {Object} SidebarGroupMenu
50692
+ * @property {string|number} key
50693
+ * @property {string} name
50694
+ * @property {SidebarChild[]} children
50695
+ * @property {IconProps} [iconProps]
50676
50696
  */
50677
50697
 
50678
- /**
50679
- * Props for SidebarGroup component.
50680
- *
50681
- * @typedef {Object} SidebarGroupProps
50682
- *
50683
- * @property {SidebarGroupMenu} menu
50684
- * The group menu containing children.
50685
- *
50686
- * @property {boolean} open
50687
- * Whether the sidebar is currently expanded.
50688
- *
50689
- * @property {string|number|null} activeItem
50690
- * The currently selected menu item key.
50691
- *
50692
- * @property {(key: string|number) => void} onItemClick
50693
- * Handler fired when a child item is selected.
50694
- *
50695
- * @property {(open: boolean) => void} toggleSidebar
50696
- * Used to open the sidebar when clicking a group.
50698
+ /**
50699
+ * Props for SidebarGroup component.
50700
+ *
50701
+ * @typedef {Object} SidebarGroupProps
50702
+ *
50703
+ * @property {SidebarGroupMenu} menu
50704
+ * The group menu containing children.
50705
+ *
50706
+ * @property {boolean} open
50707
+ * Whether the sidebar itself is expanded (wide mode vs collapsed).
50708
+ *
50709
+ * @property {string|number|null} activeItem
50710
+ * The currently selected menu item key.
50711
+ *
50712
+ * @property {(key: string|number) => void} onItemClick
50713
+ * Handler fired when a child item is selected.
50714
+ *
50715
+ * @property {(open: boolean) => void} toggleSidebar
50716
+ * Opens the sidebar when a user clicks a collapsed group.
50717
+ *
50718
+ *
50719
+ * // NEW CONTROLLED STATE PROPS:
50720
+ *
50721
+ * @property {boolean} isOpen
50722
+ * Whether THIS group’s children are currently expanded.
50723
+ *
50724
+ * @property {(key: string|number) => void} onToggle
50725
+ * Fired when the group header is clicked. Parent controls open/close.
50697
50726
  */
50698
50727
 
50699
- /**
50700
- * Fully typed SidebarGroup component.
50701
- *
50702
- * @param {SidebarGroupProps & React.HTMLAttributes<HTMLDivElement>} props
50728
+ /**
50729
+ * Fully typed SidebarGroup component.
50730
+ *
50731
+ * @param {SidebarGroupProps & React.HTMLAttributes<HTMLDivElement>} props
50703
50732
  */
50704
50733
 
50705
50734
  function SidebarGroup(_ref) {
@@ -50708,25 +50737,26 @@ function SidebarGroup(_ref) {
50708
50737
  open,
50709
50738
  activeItem,
50710
50739
  onItemClick,
50711
- toggleSidebar
50740
+ toggleSidebar,
50741
+ isOpen,
50742
+ onToggle
50712
50743
  } = _ref;
50713
- const [expanded, setExpanded] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false);
50714
50744
  return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)("div", {
50715
50745
  children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)("div", {
50716
50746
  className: "group relative flex cursor-pointer items-center justify-between p-4 transition-all duration-500 ease-in-out",
50717
50747
  onClick: () => {
50718
50748
  if (!open) toggleSidebar(true);
50719
- setExpanded(!expanded);
50749
+ onToggle(menu.key); // let parent handle open/close
50720
50750
  },
50721
50751
  children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)("div", {
50722
- className: "absolute left-0 top-0 h-full w-[5px] rounded-r transition-all duration-300 ease-in-out ".concat(expanded || activeItem === menu.key ? "bg-[--color-brand-primary]" : "bg-[--color-stroke] group-hover:bg-[--color-brand-primary]", " ")
50752
+ 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]")
50723
50753
  }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)("div", {
50724
50754
  className: "flex items-center gap-3",
50725
50755
  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", {
50726
50756
  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",
50727
50757
  children: menu.name
50728
50758
  }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)("div", {
50729
- 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", " "),
50759
+ 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"),
50730
50760
  children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_Text_Text__WEBPACK_IMPORTED_MODULE_3__["default"], {
50731
50761
  as: "span",
50732
50762
  variant: "label",
@@ -50734,12 +50764,11 @@ function SidebarGroup(_ref) {
50734
50764
  })
50735
50765
  })]
50736
50766
  }), open && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_heroicons_react_24_outline__WEBPACK_IMPORTED_MODULE_1__.ChevronDownIcon, {
50737
- className: "h-4 w-4 transition-transform duration-300 ".concat(expanded ? "rotate-180" : "")
50767
+ className: "h-4 w-4 transition-transform duration-300 ".concat(isOpen ? "rotate-180" : "")
50738
50768
  })]
50739
50769
  }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)("div", {
50740
- className: "ml-10 mt-1 overflow-hidden transition-all duration-300 ease-in-out ".concat(expanded && open ? "max-h-96 opacity-100" : "max-h-0 opacity-0"),
50770
+ 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"),
50741
50771
  children: menu.children.map(child => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_SidebarItem__WEBPACK_IMPORTED_MODULE_2__["default"], {
50742
- // composite unique key
50743
50772
  menu: child,
50744
50773
  open: open,
50745
50774
  active: activeItem === child.key,