opus-toolkit-components 2.0.0 → 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.
package/lib/main.js CHANGED
@@ -590,32 +590,32 @@ __webpack_require__.r(__webpack_exports__);
590
590
 
591
591
 
592
592
 
593
- /**
594
- * The visual intent / theme of the Card.
595
- * @typedef {'default'|'info'|'warning'|'success'|'error'|'brand'|'brandSecondary'} CardIntent
593
+ /**
594
+ * The visual intent / theme of the Card.
595
+ * @typedef {'default'|'info'|'warning'|'success'|'error'|'brand'|'brandSecondary'} CardIntent
596
596
  */
597
597
 
598
- /**
599
- * Props for the Card component.
600
- *
601
- * @typedef {Object} CardProps
602
- * @property {CardIntent} [intent]
603
- * Controls the background + text color theme of the card.
604
- *
605
- * @property {boolean} [hasOutline=true]
606
- * Toggles the default card outline.
607
- *
608
- * @property {string} [className]
609
- * Additional custom class names.
610
- *
611
- * @property {React.ReactNode} [children]
612
- * Card content.
598
+ /**
599
+ * Props for the Card component.
600
+ *
601
+ * @typedef {Object} CardProps
602
+ * @property {CardIntent} [intent]
603
+ * Controls the background + text color theme of the card.
604
+ *
605
+ * @property {boolean} [hasOutline=true]
606
+ * Toggles the default card outline.
607
+ *
608
+ * @property {string} [className]
609
+ * Additional custom class names.
610
+ *
611
+ * @property {React.ReactNode} [children]
612
+ * Card content.
613
613
  */
614
614
 
615
- /**
616
- * Card component with typed JSDoc for TS autocomplete.
617
- *
618
- * @param {CardProps & React.HTMLAttributes<HTMLDivElement>} props
615
+ /**
616
+ * Card component with typed JSDoc for TS autocomplete.
617
+ *
618
+ * @param {CardProps & React.HTMLAttributes<HTMLDivElement>} props
619
619
  */
620
620
 
621
621
  function Card(_ref) {
@@ -637,7 +637,7 @@ function Card(_ref) {
637
637
  brandSecondary: "bg-[--color-brand-secondary] text-[--color-white]"
638
638
  };
639
639
  const resolvedIntent = intent || "default";
640
- const cardClasses = (0,clsx__WEBPACK_IMPORTED_MODULE_1__["default"])("p-5", "rounded-lg", "shadow-lg", hasOutline ? "border-2 border-solid border-[--color-stroke]" : "border-0", intentClasses[resolvedIntent], className);
640
+ const cardClasses = (0,clsx__WEBPACK_IMPORTED_MODULE_1__["default"])("p-5", "rounded-lg", "shadow-lg", hasOutline ? "border border-solid border-[--color-stroke]" : "border-0", intentClasses[resolvedIntent], className);
641
641
  return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("div", {
642
642
  className: cardClasses,
643
643
  ...rest,
@@ -1413,34 +1413,37 @@ function DatePicker(_ref) {
1413
1413
  className: "ml-1 text-[--color-util-red]",
1414
1414
  children: "*"
1415
1415
  })]
1416
- }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)("input", {
1417
- type: "date",
1418
- id: name,
1419
- name: name,
1420
- ref: inputRef,
1421
- value: selectedDate,
1422
- min: normalizedMinDate,
1423
- max: normalizedMaxDate,
1424
- title: title,
1425
- onChange: handleDateChange,
1426
- required: required,
1427
- disabled: disabled,
1428
- "data-cy": (0,_utils_getDataCy__WEBPACK_IMPORTED_MODULE_3__.getDataCy)({
1429
- name,
1430
- dataCy
1431
- }),
1432
- "aria-invalid": !isValid,
1433
- "aria-describedby": !isValid ? `${name}-error` : undefined,
1434
- className: `w-full rounded-md border bg-[--color-input-bg] px-3 py-2 pr-10 ${isValid ? "border-[--color-stroke]" : "border-[--color-util-red]"} text-md font-normal text-[--color-text-strong] ${disabled ? "cursor-not-allowed opacity-50" : ""} ${className}`
1435
- }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)("button", {
1436
- type: "button",
1437
- onClick: handleIconClick,
1438
- className: "datepicker-icon-button absolute right-3 top-1/2 mt-1 transform",
1439
- "aria-label": "Open date picker",
1440
- disabled: disabled,
1441
- children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_heroicons_react_24_outline__WEBPACK_IMPORTED_MODULE_2__.CalendarIcon, {
1442
- className: `h-5 w-5 ${disabled ? "text-[--color-text-disabled]" : "text-[--color-text-weak] hover:text-[--color-primary-btn-hover]"} transition`
1443
- })
1416
+ }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)("div", {
1417
+ className: "relative",
1418
+ children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)("input", {
1419
+ type: "date",
1420
+ id: name,
1421
+ name: name,
1422
+ ref: inputRef,
1423
+ value: selectedDate,
1424
+ min: normalizedMinDate,
1425
+ max: normalizedMaxDate,
1426
+ title: title,
1427
+ onChange: handleDateChange,
1428
+ required: required,
1429
+ disabled: disabled,
1430
+ "data-cy": (0,_utils_getDataCy__WEBPACK_IMPORTED_MODULE_3__.getDataCy)({
1431
+ name,
1432
+ dataCy
1433
+ }),
1434
+ "aria-invalid": !isValid,
1435
+ "aria-describedby": !isValid ? `${name}-error` : undefined,
1436
+ className: `w-full rounded-md border bg-[--color-input-bg] px-3 py-2 pr-10 ${isValid ? "border-[--color-stroke]" : "border-[--color-util-red]"} text-md font-normal text-[--color-text-strong] ${disabled ? "cursor-not-allowed opacity-50" : ""} ${className}`
1437
+ }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)("button", {
1438
+ type: "button",
1439
+ onClick: handleIconClick,
1440
+ className: "datepicker-icon-button absolute right-3 top-1/2 -translate-y-1/2",
1441
+ "aria-label": "Open date picker",
1442
+ disabled: disabled,
1443
+ children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_heroicons_react_24_outline__WEBPACK_IMPORTED_MODULE_2__.CalendarIcon, {
1444
+ className: `h-5 w-5 ${disabled ? "text-[--color-text-disabled]" : "text-[--color-text-weak] hover:text-[--color-primary-btn-hover]"} transition`
1445
+ })
1446
+ })]
1444
1447
  }), !isValid && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_Text_Text__WEBPACK_IMPORTED_MODULE_1__["default"], {
1445
1448
  as: "span",
1446
1449
  id: `${name}-error`,
@@ -3912,75 +3915,78 @@ __webpack_require__.r(__webpack_exports__);
3912
3915
 
3913
3916
 
3914
3917
 
3915
- /**
3916
- * A single menu item (no children).
3917
- * @typedef {Object} SidebarMenuItem
3918
- * @property {string|number} key
3919
- * @property {string} name
3920
- * @property {string} [path]
3921
- * @property {string} [href]
3922
- * @property {import('../Icon').IconProps} [iconProps]
3923
- * @property {(key: string|number) => void} [onClick]
3918
+ /**
3919
+ * A single menu item (no children).
3920
+ * @typedef {Object} SidebarMenuItem
3921
+ * @property {string|number} key
3922
+ * @property {string} name
3923
+ * @property {string} [path]
3924
+ * @property {string} [href]
3925
+ * @property {import('../Icon').IconProps} [iconProps]
3926
+ * @property {(key: string|number) => void} [onClick]
3924
3927
  */
3925
3928
 
3926
- /**
3927
- * A grouped menu entry with children.
3928
- * @typedef {Object} SidebarMenuGroup
3929
- * @property {string|number} key
3930
- * @property {string} name
3931
- * @property {SidebarMenuItem[]} children
3929
+ /**
3930
+ * A grouped menu entry with children.
3931
+ * @typedef {Object} SidebarMenuGroup
3932
+ * @property {string|number} key
3933
+ * @property {string} name
3934
+ * @property {SidebarMenuItem[]} children
3932
3935
  */
3933
3936
 
3934
- /**
3935
- * A full menu entry (either group or leaf item).
3936
- * @typedef {SidebarMenuItem | SidebarMenuGroup} SidebarMenu
3937
+ /**
3938
+ * A full menu entry (either group or leaf item).
3939
+ * @typedef {SidebarMenuItem | SidebarMenuGroup} SidebarMenu
3937
3940
  */
3938
3941
 
3939
- /**
3940
- * Minimal shape expected for SidebarProfile.
3941
- * @typedef {Object} SidebarUser
3942
- * @property {string|number} id
3943
- * @property {string} name
3944
- * @property {string} role
3945
- * @property {string} [avatar]
3942
+ /**
3943
+ * Minimal shape expected for SidebarProfile.
3944
+ * @typedef {Object} SidebarUser
3945
+ * @property {string|number} id
3946
+ * @property {string} name
3947
+ * @property {string} role
3948
+ * @property {string} [avatar]
3946
3949
  */
3947
3950
 
3948
- /**
3949
- * Props for Sidebar.
3950
- *
3951
- * @typedef {Object} SidebarProps
3952
- *
3953
- * @property {SidebarMenu[]} menus
3954
- * All sidebar menu items (groups + items).
3955
- *
3956
- * @property {SidebarUser} user
3957
- * The current logged-in user.
3958
- *
3959
- * @property {string|number|null} [activeItem]
3960
- * Key of the currently selected item.
3961
- *
3962
- * @property {(key: string|number) => void} [onItemClick]
3963
- * Fired when a menu item is clicked.
3964
- *
3965
- * @property {string} [logo]
3966
- * Optional logo override.
3967
- *
3968
- * @property {string} [searchValue]
3969
- * Controlled search input value.
3970
- *
3971
- * @property {(value: string) => void} [onSearchChange]
3972
- *
3973
- * @property {string|number|null} [openGroupKey]
3974
- * Optional controlled key of the currently expanded group.
3975
- *
3976
- * @property {(openGroupKey: string|number|null) => void} [onGroupToggle]
3977
- * Optional controlled change handler. If omitted, Sidebar manages group state internally.
3951
+ /**
3952
+ * Props for Sidebar.
3953
+ *
3954
+ * @typedef {Object} SidebarProps
3955
+ *
3956
+ * @property {SidebarMenu[]} menus
3957
+ * All sidebar menu items (groups + items).
3958
+ *
3959
+ * @property {SidebarUser} user
3960
+ * The current logged-in user.
3961
+ *
3962
+ * @property {string|number|null} [activeItem]
3963
+ * Key of the currently selected item.
3964
+ *
3965
+ * @property {(key: string|number) => void} [onItemClick]
3966
+ * Fired when a menu item is clicked.
3967
+ *
3968
+ * @property {string} [logo]
3969
+ * Optional logo override.
3970
+ *
3971
+ * @property {string} [searchValue]
3972
+ * Controlled search input value.
3973
+ *
3974
+ * @property {(value: string) => void} [onSearchChange]
3975
+ *
3976
+ * @property {string|number|null} [openGroupKey]
3977
+ * Optional controlled key of the currently expanded group.
3978
+ *
3979
+ * @property {(openGroupKey: string|number|null) => void} [onGroupToggle]
3980
+ * Optional controlled change handler. If omitted, Sidebar manages group state internally.
3981
+ *
3982
+ * @property {() => void} [onLogout]
3983
+ * Optional callback fired when the user clicks the logout button in the profile card.
3978
3984
  */
3979
3985
 
3980
- /**
3981
- * Fully typed Sidebar component.
3982
- *
3983
- * @param {SidebarProps & React.HTMLAttributes<HTMLDivElement>} props
3986
+ /**
3987
+ * Fully typed Sidebar component.
3988
+ *
3989
+ * @param {SidebarProps & React.HTMLAttributes<HTMLDivElement>} props
3984
3990
  */
3985
3991
 
3986
3992
  function Sidebar(_ref) {
@@ -3994,6 +4000,7 @@ function Sidebar(_ref) {
3994
4000
  onSearchChange,
3995
4001
  openGroupKey,
3996
4002
  onGroupToggle,
4003
+ onLogout,
3997
4004
  ...rest
3998
4005
  } = _ref;
3999
4006
  const [open, setOpen] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false);
@@ -4008,10 +4015,10 @@ function Sidebar(_ref) {
4008
4015
  setInternalOpenGroupKey(nextOpenGroupKey);
4009
4016
  };
4010
4017
  return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsx)("div", {
4011
- className: "flex",
4018
+ className: "flex h-full",
4012
4019
  ...rest,
4013
4020
  children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsxs)("div", {
4014
- 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`,
4021
+ 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`,
4015
4022
  children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsxs)("div", {
4016
4023
  className: "flex items-center justify-between p-3 pr-0",
4017
4024
  children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsx)("img", {
@@ -4033,7 +4040,7 @@ function Sidebar(_ref) {
4033
4040
  className: "h-6 w-6 text-[--color-text-strong] hover:text-[--color-primary-hover]"
4034
4041
  })
4035
4042
  }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsxs)("nav", {
4036
- className: "mt-2 flex-1 space-y-1",
4043
+ className: "mt-2 flex min-h-0 flex-1 flex-col overflow-hidden",
4037
4044
  children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsx)("div", {
4038
4045
  className: "border-b-solid border-b-2 border-[--color-stroke] px-3 pb-2",
4039
4046
  children: open ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsxs)("div", {
@@ -4055,7 +4062,7 @@ function Sidebar(_ref) {
4055
4062
  })
4056
4063
  })
4057
4064
  }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsx)("div", {
4058
- className: "menu-item-container",
4065
+ className: "menu-item-container flex-1",
4059
4066
  children: menus.map(menu => menu.children ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsx)(_SidebarGroup__WEBPACK_IMPORTED_MODULE_3__["default"], {
4060
4067
  menu: menu,
4061
4068
  open: open,
@@ -4077,7 +4084,8 @@ function Sidebar(_ref) {
4077
4084
  }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_9__.jsx)(_SidebarProfile__WEBPACK_IMPORTED_MODULE_4__["default"], {
4078
4085
  user: user,
4079
4086
  open: open,
4080
- href: `/users/${user.id}`
4087
+ href: `/users/${user.id}`,
4088
+ onLogout: onLogout
4081
4089
  })]
4082
4090
  })
4083
4091
  });
@@ -4328,27 +4336,41 @@ __webpack_require__.r(__webpack_exports__);
4328
4336
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4329
4337
  /* harmony export */ "default": () => (/* binding */ SidebarProfile)
4330
4338
  /* harmony export */ });
4331
- /* harmony import */ var _Profile_ProfileCard_ProfileCard__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4977);
4332
- /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4178);
4333
- /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__);
4339
+ /* harmony import */ var _heroicons_react_24_outline__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(148);
4340
+ /* harmony import */ var _heroicons_react_24_outline__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_heroicons_react_24_outline__WEBPACK_IMPORTED_MODULE_0__);
4341
+ /* harmony import */ var _Profile_ProfileCard_ProfileCard__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4977);
4342
+ /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4178);
4343
+ /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__);
4344
+
4334
4345
 
4335
4346
 
4336
4347
  function SidebarProfile(_ref) {
4337
4348
  let {
4338
4349
  user,
4339
4350
  open,
4340
- href
4351
+ href,
4352
+ onLogout
4341
4353
  } = _ref;
4342
- return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)("div", {
4354
+ return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)("div", {
4343
4355
  className: "mt-auto flex items-center gap-3 p-2 pb-4",
4344
- children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)("img", {
4356
+ children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("img", {
4345
4357
  src: user.avatar,
4346
4358
  alt: "profile",
4347
4359
  className: "h-8 w-8 rounded-full"
4348
- }), open && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(_Profile_ProfileCard_ProfileCard__WEBPACK_IMPORTED_MODULE_0__["default"], {
4349
- user: user,
4350
- href: href,
4351
- variant: "sidebar"
4360
+ }), open && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)("div", {
4361
+ className: "flex flex-1 items-center justify-between gap-2",
4362
+ children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)(_Profile_ProfileCard_ProfileCard__WEBPACK_IMPORTED_MODULE_1__["default"], {
4363
+ user: user,
4364
+ href: href,
4365
+ variant: "sidebar"
4366
+ }), onLogout && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("button", {
4367
+ onClick: onLogout,
4368
+ title: "Log out",
4369
+ className: "rounded p-1 text-[--color-text-strong] transition-colors hover:bg-[--color-primary-bg-hover] hover:text-[--color-primary]",
4370
+ children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)(_heroicons_react_24_outline__WEBPACK_IMPORTED_MODULE_0__.ArrowRightOnRectangleIcon, {
4371
+ className: "h-5 w-5"
4372
+ })
4373
+ })]
4352
4374
  })]
4353
4375
  });
4354
4376
  }
@@ -4725,7 +4747,7 @@ __webpack_require__.r(__webpack_exports__);
4725
4747
 
4726
4748
  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()));
4727
4749
  // Module
4728
- ___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":""}]);
4750
+ ___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":""}]);
4729
4751
  // Exports
4730
4752
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
4731
4753