opus-toolkit-components 1.7.5 → 1.7.8

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.
@@ -3655,16 +3655,16 @@ __webpack_require__.r(__webpack_exports__);
3655
3655
  /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(94178);
3656
3656
  /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__);
3657
3657
 
3658
- /**
3659
- * @typedef {Object} BarLayoutProps
3660
- * @property {React.ReactNode} [left] Left content area
3661
- * @property {React.ReactNode} [center] Center content area
3662
- * @property {React.ReactNode} [right] Right content area
3663
- * @property {string} [className] Optional wrapper class
3658
+ /**
3659
+ * @typedef {Object} BarLayoutProps
3660
+ * @property {React.ReactNode} [left] Left content area
3661
+ * @property {React.ReactNode} [center] Center content area
3662
+ * @property {React.ReactNode} [right] Right content area
3663
+ * @property {string} [className] Optional wrapper class
3664
3664
  */
3665
3665
 
3666
- /**
3667
- * @param {BarLayoutProps} props
3666
+ /**
3667
+ * @param {BarLayoutProps} props
3668
3668
  */
3669
3669
 
3670
3670
  const BarLayout = _ref => {
@@ -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,
@@ -48689,80 +48699,80 @@ __webpack_require__.r(__webpack_exports__);
48689
48699
  // Import a spinner icon
48690
48700
 
48691
48701
 
48692
- /**
48693
- * @typedef {'primary'|'secondary'|'tertiary'|'outline'|'destructive'} ButtonRank
48702
+ /**
48703
+ * @typedef {'primary'|'secondary'|'tertiary'|'outline'|'destructive'} ButtonRank
48694
48704
  */
48695
48705
 
48696
- /**
48697
- * @typedef {'default'|'disabled'} ButtonState
48706
+ /**
48707
+ * @typedef {'default'|'disabled'} ButtonState
48698
48708
  */
48699
48709
 
48700
- /**
48701
- * @typedef {'sm'|'md'|'lg'|'xl'|string} ButtonSize
48702
- * (Supports custom tailwind text sizes too)
48710
+ /**
48711
+ * @typedef {'sm'|'md'|'lg'|'xl'|string} ButtonSize
48712
+ * (Supports custom tailwind text sizes too)
48703
48713
  */
48704
48714
 
48705
- /**
48706
- * Icon component type from react-icons or your own components
48707
- * @typedef {(props: React.SVGProps<SVGSVGElement>) => JSX.Element} IconComponent
48715
+ /**
48716
+ * Icon component type from react-icons or your own components
48717
+ * @typedef {(props: React.SVGProps<SVGSVGElement>) => JSX.Element} IconComponent
48708
48718
  */
48709
48719
 
48710
- /**
48711
- * @typedef {Object} ButtonProps
48712
- *
48713
- * @property {'button'|'submit'|'reset'} [type]
48714
- * Native button type.
48715
- *
48716
- * @property {ButtonRank} [rank]
48717
- * Visual rank: primary, secondary, etc.
48718
- *
48719
- * @property {ButtonState} [state]
48720
- * Current state (default, disabled).
48721
- *
48722
- * @property {string} [text]
48723
- * Text shown inside the button (ignored when isSaving is true).
48724
- *
48725
- * @property {ButtonSize} [size]
48726
- * Tailwind text size (sm, md, lg, xl).
48727
- *
48728
- * @property {string} [name]
48729
- * Standard HTML name attribute + for data-cy.
48730
- *
48731
- * @property {string} [dataCy]
48732
- * Override for auto-generated test selector.
48733
- *
48734
- * @property {number} [tabIndex]
48735
- *
48736
- * @property {boolean} [isFullWidth]
48737
- * Expand to full container width.
48738
- *
48739
- * @property {IconComponent} [icon]
48740
- * Optional icon component (left or right).
48741
- *
48742
- * @property {'left'|'right'} [iconPosition]
48743
- * Position of icon.
48744
- *
48745
- * @property {boolean} [isIconAnimated]
48746
- * Enables subtle translate animation on hover.
48747
- *
48748
- * @property {boolean} [isSaving]
48749
- * Shows a spinner and disables all interaction.
48750
- *
48751
- * @property {string} [savingText]
48752
- * Text shown when isSaving = true.
48753
- *
48754
- * @property {string} [className]
48755
- * Extra custom classes.
48756
- *
48757
- * @property {string} [title]
48758
- * Adds accessible label / tooltip.
48759
- *
48760
- * @property {(event: React.MouseEvent<HTMLButtonElement>) => void} [onClick]
48761
- * Click handler. Not called during saving or disabled state.
48720
+ /**
48721
+ * @typedef {Object} ButtonProps
48722
+ *
48723
+ * @property {'button'|'submit'|'reset'} [type]
48724
+ * Native button type.
48725
+ *
48726
+ * @property {ButtonRank} [rank]
48727
+ * Visual rank: primary, secondary, etc.
48728
+ *
48729
+ * @property {ButtonState} [state]
48730
+ * Current state (default, disabled).
48731
+ *
48732
+ * @property {string} [text]
48733
+ * Text shown inside the button (ignored when isSaving is true).
48734
+ *
48735
+ * @property {ButtonSize} [size]
48736
+ * Tailwind text size (sm, md, lg, xl).
48737
+ *
48738
+ * @property {string} [name]
48739
+ * Standard HTML name attribute + for data-cy.
48740
+ *
48741
+ * @property {string} [dataCy]
48742
+ * Override for auto-generated test selector.
48743
+ *
48744
+ * @property {number} [tabIndex]
48745
+ *
48746
+ * @property {boolean} [isFullWidth]
48747
+ * Expand to full container width.
48748
+ *
48749
+ * @property {IconComponent} [icon]
48750
+ * Optional icon component (left or right).
48751
+ *
48752
+ * @property {'left'|'right'} [iconPosition]
48753
+ * Position of icon.
48754
+ *
48755
+ * @property {boolean} [isIconAnimated]
48756
+ * Enables subtle translate animation on hover.
48757
+ *
48758
+ * @property {boolean} [isSaving]
48759
+ * Shows a spinner and disables all interaction.
48760
+ *
48761
+ * @property {string} [savingText]
48762
+ * Text shown when isSaving = true.
48763
+ *
48764
+ * @property {string} [className]
48765
+ * Extra custom classes.
48766
+ *
48767
+ * @property {string} [title]
48768
+ * Adds accessible label / tooltip.
48769
+ *
48770
+ * @property {(event: React.MouseEvent<HTMLButtonElement>) => void} [onClick]
48771
+ * Click handler. Not called during saving or disabled state.
48762
48772
  */
48763
48773
 
48764
- /**
48765
- * @param {ButtonProps & React.ButtonHTMLAttributes<HTMLButtonElement>} props
48774
+ /**
48775
+ * @param {ButtonProps & React.ButtonHTMLAttributes<HTMLButtonElement>} props
48766
48776
  */
48767
48777
 
48768
48778
  function Button(_ref) {
@@ -48794,7 +48804,7 @@ function Button(_ref) {
48794
48804
  // Define styles for button ranks
48795
48805
  const rankStyles = {
48796
48806
  primary: "bg-[--color-primary-btn] hover:bg-[--color-primary-btn-hover] text-[--color-primary-btn-txt] border-solid border-2 border-[--color-primary-btn] hover:border-[--color-primary-btn-hover]",
48797
- secondary: "bg-transparent border-2 border-2 border-[--color-primary-btn] hover:border-[--color-secondary-btn-hover] hover:text-[--color-secondary-btn-hover] text-[--color-primary-btn]",
48807
+ secondary: "border-2 border-2 bg-[--color-brand-secondary] border-[--color-stroke] hover:bg-[--color-primary-btn-hover] text-[--color-white]",
48798
48808
  tertiary: "bg-transparent underline text-[--color-text-strong]",
48799
48809
  outline: "bg-[--color-input-bg] border-solid border-2 border-[--color-outline-btn] hover:border-[--color-outline-btn-hover] text-[--color-text-strong]",
48800
48810
  destructive: "bg-[--color-destructive-btn] hover:bg-[--color-destructive-btn-hover] text-[--color-destructive-btn-txt] border-solid border-2 border-[--color-destructive-btn] hover:border-[--color-destructive-btn-hover]"
@@ -50661,55 +50671,64 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
50661
50671
 
50662
50672
 
50663
50673
 
50664
- /**
50665
- * Icon props used by your dynamic Icon component (optional).
50666
- * @typedef {import('../Icon/Icon').IconProps} IconProps
50674
+ /**
50675
+ * Icon props used by your dynamic Icon component (optional).
50676
+ * @typedef {import('../Icon/Icon').IconProps} IconProps
50667
50677
  */
50668
50678
 
50669
- /**
50670
- * A single child menu item.
50671
- * @typedef {Object} SidebarChild
50672
- * @property {string|number} key
50673
- * @property {string} name
50674
- * @property {string} [path]
50675
- * @property {string} [href]
50676
- * @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]
50677
50687
  */
50678
50688
 
50679
- /**
50680
- * Sidebar group object containing children.
50681
- * @typedef {Object} SidebarGroupMenu
50682
- * @property {string|number} key
50683
- * @property {string} name
50684
- * @property {SidebarChild[]} children
50685
- * @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]
50686
50696
  */
50687
50697
 
50688
- /**
50689
- * Props for SidebarGroup component.
50690
- *
50691
- * @typedef {Object} SidebarGroupProps
50692
- *
50693
- * @property {SidebarGroupMenu} menu
50694
- * The group menu containing children.
50695
- *
50696
- * @property {boolean} open
50697
- * Whether the sidebar is currently expanded.
50698
- *
50699
- * @property {string|number|null} activeItem
50700
- * The currently selected menu item key.
50701
- *
50702
- * @property {(key: string|number) => void} onItemClick
50703
- * Handler fired when a child item is selected.
50704
- *
50705
- * @property {(open: boolean) => void} toggleSidebar
50706
- * 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.
50707
50726
  */
50708
50727
 
50709
- /**
50710
- * Fully typed SidebarGroup component.
50711
- *
50712
- * @param {SidebarGroupProps & React.HTMLAttributes<HTMLDivElement>} props
50728
+ /**
50729
+ * Fully typed SidebarGroup component.
50730
+ *
50731
+ * @param {SidebarGroupProps & React.HTMLAttributes<HTMLDivElement>} props
50713
50732
  */
50714
50733
 
50715
50734
  function SidebarGroup(_ref) {
@@ -50718,25 +50737,26 @@ function SidebarGroup(_ref) {
50718
50737
  open,
50719
50738
  activeItem,
50720
50739
  onItemClick,
50721
- toggleSidebar
50740
+ toggleSidebar,
50741
+ isOpen,
50742
+ onToggle
50722
50743
  } = _ref;
50723
- const [expanded, setExpanded] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false);
50724
50744
  return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)("div", {
50725
50745
  children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)("div", {
50726
50746
  className: "group relative flex cursor-pointer items-center justify-between p-4 transition-all duration-500 ease-in-out",
50727
50747
  onClick: () => {
50728
50748
  if (!open) toggleSidebar(true);
50729
- setExpanded(!expanded);
50749
+ onToggle(menu.key); // let parent handle open/close
50730
50750
  },
50731
50751
  children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)("div", {
50732
- 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]")
50733
50753
  }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)("div", {
50734
50754
  className: "flex items-center gap-3",
50735
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", {
50736
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",
50737
50757
  children: menu.name
50738
50758
  }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)("div", {
50739
- 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"),
50740
50760
  children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_Text_Text__WEBPACK_IMPORTED_MODULE_3__["default"], {
50741
50761
  as: "span",
50742
50762
  variant: "label",
@@ -50744,12 +50764,11 @@ function SidebarGroup(_ref) {
50744
50764
  })
50745
50765
  })]
50746
50766
  }), open && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_heroicons_react_24_outline__WEBPACK_IMPORTED_MODULE_1__.ChevronDownIcon, {
50747
- 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" : "")
50748
50768
  })]
50749
50769
  }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)("div", {
50750
- 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"),
50751
50771
  children: menu.children.map(child => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_SidebarItem__WEBPACK_IMPORTED_MODULE_2__["default"], {
50752
- // composite unique key
50753
50772
  menu: child,
50754
50773
  open: open,
50755
50774
  active: activeItem === child.key,
@@ -63690,4 +63709,4 @@ __webpack_require__.r(__webpack_exports__);
63690
63709
  module.exports = __webpack_exports__;
63691
63710
  /******/ })()
63692
63711
  ;
63693
- //# sourceMappingURL=opus-components.main.js.map
63712
+ //# sourceMappingURL=main.js.map