@mezzanine-ui/react 1.0.0-beta.3 → 1.0.0-beta.5

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.
Files changed (146) hide show
  1. package/AutoComplete/AutoComplete.d.ts +23 -0
  2. package/AutoComplete/AutoComplete.js +39 -9
  3. package/Breadcrumb/Breadcrumb.js +16 -21
  4. package/Breadcrumb/BreadcrumbDropdown.d.ts +11 -0
  5. package/Breadcrumb/BreadcrumbDropdown.js +22 -0
  6. package/Breadcrumb/BreadcrumbItem.d.ts +2 -3
  7. package/Breadcrumb/BreadcrumbItem.js +13 -31
  8. package/Breadcrumb/BreadcrumbOverflowMenu.d.ts +7 -0
  9. package/Breadcrumb/BreadcrumbOverflowMenu.js +77 -0
  10. package/Breadcrumb/BreadcrumbOverflowMenuDropdown.d.ts +11 -0
  11. package/Breadcrumb/BreadcrumbOverflowMenuDropdown.js +21 -0
  12. package/Breadcrumb/BreadcrumbOverflowMenuItem.d.ts +3 -0
  13. package/Breadcrumb/BreadcrumbOverflowMenuItem.js +27 -0
  14. package/Breadcrumb/typings.d.ts +21 -39
  15. package/Calendar/Calendar.js +2 -6
  16. package/Calendar/CalendarCell.d.ts +22 -0
  17. package/Calendar/CalendarCell.js +6 -2
  18. package/Calendar/CalendarControls.js +1 -1
  19. package/Calendar/CalendarDayOfWeek.js +3 -2
  20. package/Calendar/CalendarDays.js +5 -1
  21. package/Calendar/CalendarHalfYears.js +13 -7
  22. package/Calendar/CalendarMonths.js +13 -6
  23. package/Calendar/CalendarQuarters.js +13 -7
  24. package/Calendar/CalendarWeeks.js +87 -34
  25. package/Calendar/CalendarYears.js +13 -12
  26. package/Calendar/useCalendarControlModifiers.d.ts +1 -1
  27. package/Calendar/useCalendarControlModifiers.js +12 -12
  28. package/Calendar/useCalendarControls.d.ts +4 -4
  29. package/Calendar/useCalendarControls.js +33 -19
  30. package/Calendar/useRangeCalendarControls.d.ts +8 -8
  31. package/Calendar/useRangeCalendarControls.js +42 -31
  32. package/Checkbox/index.d.ts +4 -5
  33. package/Checkbox/index.js +1 -5
  34. package/ContentHeader/ContentHeader.d.ts +160 -0
  35. package/ContentHeader/ContentHeader.js +54 -0
  36. package/ContentHeader/index.d.ts +2 -0
  37. package/ContentHeader/index.js +1 -0
  38. package/ContentHeader/utils.d.ts +23 -0
  39. package/ContentHeader/utils.js +215 -0
  40. package/DateRangePicker/useDateRangeCalendarControls.js +8 -2
  41. package/Dropdown/Dropdown.d.ts +48 -0
  42. package/Dropdown/Dropdown.js +16 -2
  43. package/Dropdown/DropdownItem.d.ts +42 -0
  44. package/Dropdown/DropdownItem.js +144 -13
  45. package/Dropdown/DropdownItemCard.d.ts +7 -2
  46. package/Dropdown/DropdownItemCard.js +12 -9
  47. package/Empty/Empty.js +2 -1
  48. package/Empty/icons/EmptyMainNotificationIcon.d.ts +4 -0
  49. package/Empty/icons/EmptyMainNotificationIcon.js +9 -0
  50. package/Empty/typings.d.ts +2 -2
  51. package/FilterArea/Filter.d.ts +32 -0
  52. package/FilterArea/Filter.js +23 -0
  53. package/FilterArea/FilterArea.d.ts +58 -0
  54. package/FilterArea/FilterArea.js +31 -0
  55. package/FilterArea/FilterLine.d.ts +11 -0
  56. package/FilterArea/FilterLine.js +13 -0
  57. package/FilterArea/index.d.ts +6 -0
  58. package/FilterArea/index.js +3 -0
  59. package/Form/useSelectValueControl.d.ts +3 -4
  60. package/Form/useSelectValueControl.js +51 -39
  61. package/Input/Input.d.ts +6 -4
  62. package/Input/Input.js +28 -10
  63. package/Input/index.d.ts +1 -1
  64. package/Modal/MediaPreviewModal.d.ts +54 -0
  65. package/Modal/MediaPreviewModal.js +158 -0
  66. package/Modal/Modal.js +1 -1
  67. package/Modal/index.d.ts +2 -0
  68. package/Modal/index.js +1 -0
  69. package/Navigation/Navigation.js +6 -5
  70. package/Navigation/NavigationOption.d.ts +6 -2
  71. package/Navigation/NavigationOption.js +19 -9
  72. package/Navigation/NavigationOverflowMenu.d.ts +6 -0
  73. package/Navigation/NavigationOverflowMenu.js +90 -0
  74. package/Navigation/NavigationOverflowMenuOption.d.ts +7 -0
  75. package/Navigation/NavigationOverflowMenuOption.js +68 -0
  76. package/Navigation/NavigationUserMenu.d.ts +4 -2
  77. package/Navigation/NavigationUserMenu.js +13 -5
  78. package/Navigation/context.d.ts +3 -2
  79. package/NotificationCenter/NotificationCenter.d.ts +1 -1
  80. package/NotificationCenter/NotificationCenter.js +34 -14
  81. package/NotificationCenter/NotificationCenterDrawer.d.ts +20 -0
  82. package/PageHeader/PageHeader.d.ts +32 -25
  83. package/PageHeader/PageHeader.js +49 -35
  84. package/Popper/Popper.js +2 -1
  85. package/ResultState/ResultState.d.ts +9 -0
  86. package/ResultState/ResultState.js +36 -4
  87. package/Scrollbar/Scrollbar.d.ts +9 -0
  88. package/Scrollbar/Scrollbar.js +79 -0
  89. package/Scrollbar/index.d.ts +2 -0
  90. package/Scrollbar/index.js +1 -0
  91. package/Scrollbar/typings.d.ts +47 -0
  92. package/Select/Select.d.ts +37 -18
  93. package/Select/Select.js +165 -51
  94. package/Select/SelectTrigger.js +5 -4
  95. package/Select/index.d.ts +8 -9
  96. package/Select/index.js +3 -3
  97. package/Select/typings.d.ts +6 -1
  98. package/Selection/Selection.js +1 -1
  99. package/Selection/SelectionGroup.d.ts +28 -0
  100. package/Table/Table.d.ts +2 -120
  101. package/Table/Table.js +148 -53
  102. package/Table/TableContext.d.ts +11 -12
  103. package/Table/components/TableActionsCell.js +12 -4
  104. package/Table/components/TableBody.js +2 -1
  105. package/Table/components/TableColGroup.d.ts +1 -4
  106. package/Table/components/TableColGroup.js +15 -16
  107. package/Table/components/TableCollectableCell.d.ts +17 -0
  108. package/Table/components/TableCollectableCell.js +54 -0
  109. package/Table/components/TableDragOrPinHandleCell.d.ts +20 -0
  110. package/Table/components/TableDragOrPinHandleCell.js +58 -0
  111. package/Table/components/TableExpandedRow.js +11 -2
  112. package/Table/components/TableHeader.js +12 -10
  113. package/Table/components/TableRow.js +38 -13
  114. package/Table/components/TableSelectionCell.js +1 -1
  115. package/Table/components/TableToggleableCell.d.ts +16 -0
  116. package/Table/components/TableToggleableCell.js +51 -0
  117. package/Table/components/index.d.ts +4 -1
  118. package/Table/components/index.js +3 -0
  119. package/Table/hooks/typings.d.ts +18 -4
  120. package/Table/hooks/useTableExpansion.d.ts +2 -2
  121. package/Table/hooks/useTableExpansion.js +5 -5
  122. package/Table/hooks/useTableFixedOffsets.d.ts +6 -2
  123. package/Table/hooks/useTableFixedOffsets.js +58 -24
  124. package/Table/hooks/useTableScroll.d.ts +9 -3
  125. package/Table/hooks/useTableScroll.js +34 -7
  126. package/Table/hooks/useTableVirtualization.d.ts +2 -1
  127. package/Table/hooks/useTableVirtualization.js +2 -8
  128. package/Table/index.d.ts +4 -3
  129. package/Table/index.js +3 -0
  130. package/Table/typings.d.ts +172 -0
  131. package/Transition/Slide.d.ts +9 -2
  132. package/Transition/Slide.js +7 -4
  133. package/Tree/TreeNode.js +1 -1
  134. package/index.d.ts +4 -2
  135. package/index.js +6 -3
  136. package/package.json +6 -4
  137. package/Navigation/CollapsedMenu.d.ts +0 -6
  138. package/Navigation/CollapsedMenu.js +0 -16
  139. package/PageToolbar/PageToolbar.d.ts +0 -110
  140. package/PageToolbar/PageToolbar.js +0 -23
  141. package/PageToolbar/index.d.ts +0 -2
  142. package/PageToolbar/index.js +0 -1
  143. package/PageToolbar/utils.d.ts +0 -23
  144. package/PageToolbar/utils.js +0 -157
  145. package/Table/components/TableDragHandleCell.d.ts +0 -11
  146. package/Table/components/TableDragHandleCell.js +0 -44
@@ -1,62 +1,76 @@
1
- import { jsx, jsxs } from 'react/jsx-runtime';
2
- import { forwardRef, Children, isValidElement, cloneElement } from 'react';
3
- import { ChevronLeftIcon } from '@mezzanine-ui/icons';
1
+ import { jsxs } from 'react/jsx-runtime';
2
+ import { forwardRef, isValidElement, cloneElement } from 'react';
4
3
  import { pageHeaderClasses } from '@mezzanine-ui/core/page-header';
5
- import Button from '../Button/Button.js';
6
- import Typography from '../Typography/Typography.js';
4
+ import { flattenChildren } from '../utils/flatten-children.js';
7
5
  import Breadcrumb from '../Breadcrumb/Breadcrumb.js';
8
- import PageToolbar from '../PageToolbar/PageToolbar.js';
6
+ import ContentHeader from '../ContentHeader/ContentHeader.js';
9
7
  import cx from 'clsx';
10
8
 
11
9
  const getBreadcrumbAndToolbar = (children) => {
12
10
  let breadcrumb;
13
- let pageToolbar;
14
- let backButtonOrLink;
15
- const childrenArray = Children.toArray(children);
11
+ let contentHeader;
12
+ const childrenArray = flattenChildren(children);
16
13
  if (children) {
17
14
  childrenArray.forEach((child) => {
18
15
  if (!isValidElement(child))
19
16
  return;
20
17
  if (child.type === Breadcrumb) {
18
+ if (breadcrumb) {
19
+ console.warn('[Mezzanine][PageHeader] only accepts one Breadcrumb as its child.');
20
+ }
21
21
  breadcrumb = child;
22
22
  }
23
- else if (child.type === PageToolbar) {
24
- pageToolbar = cloneElement(child, {
23
+ else if (child.type === ContentHeader) {
24
+ if (contentHeader) {
25
+ console.warn('[Mezzanine][PageHeader] only accepts one ContentHeader as its child.');
26
+ }
27
+ const sizeProp = child.props.size;
28
+ if (sizeProp !== undefined && sizeProp !== 'main') {
29
+ console.warn('[Mezzanine][PageHeader] ContentHeader size prop will be overridden to "main".');
30
+ }
31
+ contentHeader = cloneElement(child, {
25
32
  size: 'main',
26
33
  });
27
34
  }
28
- else if (child.type === Button) {
29
- backButtonOrLink = cloneElement(child, {
30
- iconType: 'icon-only',
31
- icon: ChevronLeftIcon,
32
- size: 'sub',
33
- variant: 'base-tertiary',
34
- });
35
- }
36
- else if (child.type === 'a') {
37
- backButtonOrLink = cloneElement(child, {
38
- children: (jsx(Button, { component: 'div', iconType: "icon-only", icon: ChevronLeftIcon, size: "sub", variant: "base-tertiary" })),
39
- });
40
- }
41
35
  else {
42
- if (process.env.NODE_ENV !== 'production') {
43
- console.warn('PageHeader only accepts Breadcrumb, PageToolbar, Button or component with href prop as its children.');
44
- }
36
+ console.warn('[Mezzanine][PageHeader] only accepts Breadcrumb or ContentHeader as its children.');
45
37
  }
46
38
  });
47
39
  }
48
- return { breadcrumb, backButtonOrLink, pageToolbar };
40
+ if (!contentHeader) {
41
+ console.error('[Mezzanine][PageHeader] requires a ContentHeader as its child.');
42
+ }
43
+ return { breadcrumb, contentHeader };
49
44
  };
50
45
  /**
51
- * PageHeader component displays a page title with optional breadcrumb navigation,
52
- * description, back button, and action toolbar.
46
+ * PageHeader component
47
+ *
48
+ * Used to display the page header, typically containing a `<Breadcrumb />` and a `<ContentHeader />`.
49
+ *
50
+ * @example
51
+ * ```tsx
52
+ * <PageHeader>
53
+ * <Breadcrumb
54
+ * links={[
55
+ * { id: '1', children: 'Home', href: '/' },
56
+ * { id: '2', children: 'Page Header' },
57
+ * ]}
58
+ * />
59
+ *
60
+ * <ContentHeader
61
+ * title="Page Title"
62
+ * description="This is the page description."
63
+ * >
64
+ * <Button variant="base-secondary">Secondary</Button>
65
+ * <Button>Primary</Button>
66
+ * </ContentHeader>
67
+ * </PageHeader>
68
+ * ```
53
69
  */
54
70
  const PageHeader = forwardRef(function PageHeader(props, ref) {
55
- const { children, className, description, onBackClick, title, titleComponent = 'h2', ...rest } = props;
56
- const { backButtonOrLink, breadcrumb, pageToolbar } = getBreadcrumbAndToolbar(children);
57
- // prop onBack takes precedence over backButtonOrLink
58
- const backButton = onBackClick ? (jsx(Button, { iconType: "icon-only", icon: ChevronLeftIcon, onClick: onBackClick, size: "sub", variant: "base-tertiary" })) : (backButtonOrLink);
59
- return (jsxs("header", { ...rest, className: cx(pageHeaderClasses.host, className), ref: ref, children: [breadcrumb, jsxs("span", { className: pageHeaderClasses.headerContent, children: [jsxs("span", { className: pageHeaderClasses.pageTitleWithIcon, children: [backButton && jsx("div", { children: backButton }), jsxs("div", { className: pageHeaderClasses.pageTitleText, children: [jsx(Typography, { align: "left", color: "text-neutral-solid", component: titleComponent, variant: "h2", children: title }), description && (jsx(Typography, { align: "left", color: "text-neutral", component: "p", variant: "caption", children: description }))] })] }), pageToolbar] })] }));
71
+ const { children, className, ...rest } = props;
72
+ const { breadcrumb, contentHeader } = getBreadcrumbAndToolbar(children);
73
+ return (jsxs("header", { ...rest, className: cx(pageHeaderClasses.host, className), ref: ref, children: [breadcrumb, contentHeader] }));
60
74
  });
61
75
 
62
76
  export { PageHeader as default };
package/Popper/Popper.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
  import { jsx, jsxs } from 'react/jsx-runtime';
3
3
  import { forwardRef, useRef, useImperativeHandle, useEffect, useCallback } from 'react';
4
- import { useFloating, arrow } from '@floating-ui/react-dom';
4
+ import { useFloating, arrow, autoUpdate } from '@floating-ui/react-dom';
5
5
  import { spacingPrefix } from '@mezzanine-ui/system/spacing';
6
6
  import { getElement } from '../utils/getElement.js';
7
7
  import { useComposeRefs } from '../hooks/useComposeRefs.js';
@@ -15,6 +15,7 @@ const Popper = forwardRef(function Popper(props, ref) {
15
15
  const anchorEl = getElement(anchor);
16
16
  const floatingReturn = useFloating({
17
17
  ...options,
18
+ whileElementsMounted: autoUpdate,
18
19
  middleware: [
19
20
  ...((_a = options === null || options === void 0 ? void 0 : options.middleware) !== null && _a !== void 0 ? _a : []),
20
21
  (arrow$1 === null || arrow$1 === void 0 ? void 0 : arrow$1.enabled)
@@ -1,4 +1,5 @@
1
1
  import type { ResultStateSize, ResultStateType } from '@mezzanine-ui/core/result-state';
2
+ import { ReactElement } from 'react';
2
3
  import type { ButtonProps } from '../Button';
3
4
  import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
4
5
  /**
@@ -26,6 +27,14 @@ export interface ResultStateProps extends NativeElementPropsWithoutKeyAndRef<'di
26
27
  * - Two buttons: Both `secondaryButton` and `primaryButton`
27
28
  */
28
29
  actions?: ResultStateActions;
30
+ /**
31
+ * Child button elements for actions. <br />
32
+ * Can be a single Button element or an array of one or two Button elements. <br />
33
+ * When using children, the first Button is treated as secondary and the second as primary. <br />
34
+ * If only one Button is provided, it is treated as secondary. <br />
35
+ * If actions provided, children will be ignored. <br />
36
+ */
37
+ children?: ReactElement<ButtonProps> | [ReactElement<ButtonProps>] | [ReactElement<ButtonProps>, ReactElement<ButtonProps>];
29
38
  /**
30
39
  * Optional description text displayed below the title.
31
40
  * Provides additional context or details about the result state.
@@ -1,9 +1,10 @@
1
- import { jsx, jsxs } from 'react/jsx-runtime';
1
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
2
2
  import { resultStateClasses } from '@mezzanine-ui/core/result-state';
3
- import { forwardRef, useMemo } from 'react';
3
+ import { forwardRef, useMemo, isValidElement, cloneElement } from 'react';
4
4
  import { DangerousFilledIcon, ErrorFilledIcon, WarningFilledIcon, QuestionFilledIcon, CheckedFilledIcon, InfoFilledIcon } from '@mezzanine-ui/icons';
5
5
  import Button from '../Button/Button.js';
6
6
  import ButtonGroup from '../Button/ButtonGroup.js';
7
+ import { flattenChildren } from '../utils/flatten-children.js';
7
8
  import Icon from '../Icon/Icon.js';
8
9
  import cx from 'clsx';
9
10
 
@@ -15,10 +16,41 @@ const iconMap = {
15
16
  error: ErrorFilledIcon,
16
17
  failure: DangerousFilledIcon,
17
18
  };
19
+ const renderButtonOrElement = (button, size, variant) => {
20
+ if (!button)
21
+ return null;
22
+ if (isValidElement(button)) {
23
+ return cloneElement(button, { size, variant });
24
+ }
25
+ return jsx(Button, { ...button, size: size, variant: variant });
26
+ };
18
27
  const ResultState = forwardRef(function ResultState(props, ref) {
19
- const { actions, className, description, size = 'main', title, type = 'information', ...rest } = props;
28
+ const { actions, className, children, description, size = 'main', title, type = 'information', ...rest } = props;
20
29
  const icon = useMemo(() => iconMap[type], [type]);
21
- return (jsx("div", { ...rest, ref: ref, className: cx(resultStateClasses.host, resultStateClasses.type(type), resultStateClasses.size(size), className), children: jsxs("div", { className: resultStateClasses.container, children: [jsx(Icon, { className: resultStateClasses.icon, icon: icon }), jsx("h3", { className: resultStateClasses.title, children: title }), description && jsx("p", { className: resultStateClasses.description, children: description }), ((actions === null || actions === void 0 ? void 0 : actions.secondaryButton) || (actions === null || actions === void 0 ? void 0 : actions.primaryButton)) && (jsxs(ButtonGroup, { className: resultStateClasses.actions, children: [(actions === null || actions === void 0 ? void 0 : actions.secondaryButton) && (jsx(Button, { size: size, variant: "base-secondary", ...actions.secondaryButton })), (actions === null || actions === void 0 ? void 0 : actions.primaryButton) && (jsx(Button, { size: size, variant: "base-primary", ...actions.primaryButton }))] }))] }) }));
30
+ const flatChildren = flattenChildren(children);
31
+ const fragmentButtons = actions &&
32
+ ('secondaryButton' in actions ? (jsxs(Fragment, { children: [renderButtonOrElement(actions.secondaryButton, size, 'base-secondary'), renderButtonOrElement(actions.primaryButton, size, 'base-primary')] })) : (renderButtonOrElement(actions, size, 'base-secondary')));
33
+ const renderChildren = !fragmentButtons &&
34
+ flatChildren.length > 0 &&
35
+ flatChildren.map((child, index) => {
36
+ if (!isValidElement(child)) {
37
+ return null;
38
+ }
39
+ else if (child.type === Button) {
40
+ switch (index) {
41
+ case 0:
42
+ return renderButtonOrElement(child, size, 'base-secondary');
43
+ case 1:
44
+ return renderButtonOrElement(child, size, 'base-primary');
45
+ default:
46
+ console.warn('Only up to two Button components are allowed as children of ResultState.');
47
+ return null;
48
+ }
49
+ }
50
+ console.warn('Only Button components are allowed as children of ResultState.');
51
+ return null;
52
+ });
53
+ return (jsx("div", { ...rest, ref: ref, className: cx(resultStateClasses.host, resultStateClasses.type(type), resultStateClasses.size(size), className), children: jsxs("div", { className: resultStateClasses.container, children: [jsx(Icon, { className: resultStateClasses.icon, icon: icon }), jsx("h3", { className: resultStateClasses.title, children: title }), description && jsx("p", { className: resultStateClasses.description, children: description }), actions || children ? (jsx(ButtonGroup, { className: resultStateClasses.actions, children: fragmentButtons || renderChildren })) : null] }) }));
22
54
  });
23
55
 
24
56
  export { ResultState as default };
@@ -0,0 +1,9 @@
1
+ import 'overlayscrollbars/overlayscrollbars.css';
2
+ import { OverlayScrollbarsComponentRef } from 'overlayscrollbars-react';
3
+ import type { ScrollbarProps } from './typings';
4
+ /**
5
+ * The react component for `mezzanine` scrollbar.
6
+ * A customizable scrollbar container that provides consistent styling across all browsers
7
+ */
8
+ declare const Scrollbar: import("react").ForwardRefExoticComponent<ScrollbarProps & import("react").RefAttributes<OverlayScrollbarsComponentRef<"div">>>;
9
+ export default Scrollbar;
@@ -0,0 +1,79 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import 'overlayscrollbars/overlayscrollbars.css';
3
+ import { forwardRef, useEffect, useMemo, useCallback } from 'react';
4
+ import { OverlayScrollbars, ClickScrollPlugin } from 'overlayscrollbars';
5
+ import { OverlayScrollbarsComponent } from 'overlayscrollbars-react';
6
+ import { scrollbarClasses } from '@mezzanine-ui/core/scrollbar';
7
+ import cx from 'clsx';
8
+
9
+ /**
10
+ * The react component for `mezzanine` scrollbar.
11
+ * A customizable scrollbar container that provides consistent styling across all browsers
12
+ */
13
+ const Scrollbar = forwardRef(function Scrollbar(props, ref) {
14
+ const { children, className, defer = true, disabled = false, events, maxHeight, maxWidth, onViewportReady, options, style, ...rest } = props;
15
+ // Register ClickScrollPlugin once (required for clickScroll option to work)
16
+ useEffect(() => {
17
+ OverlayScrollbars.plugin(ClickScrollPlugin);
18
+ }, []);
19
+ const mergedOptions = useMemo(() => ({
20
+ ...options,
21
+ overflow: {
22
+ x: 'scroll',
23
+ y: 'scroll',
24
+ },
25
+ scrollbars: {
26
+ autoHide: 'scroll',
27
+ autoHideDelay: 600,
28
+ clickScroll: true,
29
+ ...options === null || options === void 0 ? void 0 : options.scrollbars,
30
+ },
31
+ }), [options]);
32
+ const containerStyle = useMemo(() => ({
33
+ ...style,
34
+ maxHeight,
35
+ maxWidth,
36
+ }), [maxHeight, maxWidth, style]);
37
+ // Merge events with onViewportReady callback
38
+ const mergedEvents = useMemo(() => {
39
+ if (!onViewportReady && !events)
40
+ return undefined;
41
+ return {
42
+ ...events,
43
+ initialized: (instance) => {
44
+ const { viewport } = instance.elements();
45
+ onViewportReady === null || onViewportReady === void 0 ? void 0 : onViewportReady(viewport, instance);
46
+ if (events && typeof events !== 'boolean' && events.initialized) {
47
+ const initializedHandler = events.initialized;
48
+ if (Array.isArray(initializedHandler)) {
49
+ initializedHandler.forEach((handler) => handler(instance));
50
+ }
51
+ else {
52
+ initializedHandler(instance);
53
+ }
54
+ }
55
+ },
56
+ };
57
+ }, [events, onViewportReady]);
58
+ // Callback ref for disabled mode - triggers onViewportReady with the div element
59
+ const disabledRef = useCallback((element) => {
60
+ // Forward to user ref if provided
61
+ if (typeof ref === 'function') {
62
+ ref(element);
63
+ }
64
+ else if (ref) {
65
+ ref.current = element;
66
+ }
67
+ // Call onViewportReady with the div element (no OverlayScrollbars instance)
68
+ if (element && onViewportReady) {
69
+ onViewportReady(element);
70
+ }
71
+ }, [onViewportReady, ref]);
72
+ // When disabled, render a plain div instead of OverlayScrollbarsComponent
73
+ if (disabled) {
74
+ return (jsx("div", { ...rest, ref: disabledRef, className: className, style: containerStyle, children: children }));
75
+ }
76
+ return (jsx(OverlayScrollbarsComponent, { ...rest, ref: ref, className: cx(scrollbarClasses.host, className), defer: defer, element: "div", events: mergedEvents, options: mergedOptions, style: containerStyle, children: children }));
77
+ });
78
+
79
+ export { Scrollbar as default };
@@ -0,0 +1,2 @@
1
+ export type { ScrollbarProps } from './typings';
2
+ export { default } from './Scrollbar';
@@ -0,0 +1 @@
1
+ export { default } from './Scrollbar.js';
@@ -0,0 +1,47 @@
1
+ import type { OverlayScrollbars, PartialOptions } from 'overlayscrollbars';
2
+ import type { OverlayScrollbarsComponentProps } from 'overlayscrollbars-react';
3
+ import type { CSSProperties, ReactNode } from 'react';
4
+ import type { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
5
+ export interface ScrollbarProps extends Omit<NativeElementPropsWithoutKeyAndRef<'div'>, 'children'> {
6
+ /**
7
+ * The content to be rendered inside the scrollable container.
8
+ */
9
+ children?: ReactNode;
10
+ /**
11
+ * Whether to defer the initialization of OverlayScrollbars.
12
+ * This can improve initial render performance.
13
+ * @default true
14
+ */
15
+ defer?: boolean | object;
16
+ /**
17
+ * When true, disables the custom scrollbar and renders as a plain div.
18
+ * Useful for nested contexts where custom scrollbar is not needed.
19
+ * @default false
20
+ */
21
+ disabled?: boolean;
22
+ /**
23
+ * The maximum height of the scrollable container.
24
+ * Can be a CSS value string (e.g., '300px', '50vh') or a number (treated as pixels).
25
+ */
26
+ maxHeight?: CSSProperties['maxHeight'];
27
+ /**
28
+ * The maximum width of the scrollable container.
29
+ * Can be a CSS value string (e.g., '500px', '100%') or a number (treated as pixels).
30
+ */
31
+ maxWidth?: CSSProperties['maxWidth'];
32
+ /**
33
+ * Additional options to pass to OverlayScrollbars.
34
+ * @see https://kingsora.github.io/OverlayScrollbars/#!documentation/options
35
+ */
36
+ options?: PartialOptions;
37
+ /**
38
+ * Event handlers for OverlayScrollbars events.
39
+ * @see https://kingsora.github.io/OverlayScrollbars/#!documentation/events
40
+ */
41
+ events?: OverlayScrollbarsComponentProps['events'];
42
+ /**
43
+ * Callback fired when the scrollbar is initialized.
44
+ * Provides access to the viewport element for external integrations (e.g., virtualization, DnD).
45
+ */
46
+ onViewportReady?: (viewport: HTMLDivElement, instance?: OverlayScrollbars) => void;
47
+ }
@@ -1,33 +1,52 @@
1
+ import { DropdownOption, DropdownType } from '@mezzanine-ui/core/dropdown/dropdown';
1
2
  import { SelectInputSize } from '@mezzanine-ui/core/select';
3
+ import React, { ReactElement } from 'react';
2
4
  import { FormElementFocusHandlers } from '../Form';
3
- import { MenuProps } from '../Menu';
4
- import { PopperProps } from '../Popper';
5
- import { SelectValue } from './typings';
6
- import { PickRenameMulti } from '../utils/general';
7
- import { SelectTriggerProps, SelectTriggerInputProps } from './SelectTrigger';
8
- export interface SelectBaseProps extends Omit<SelectTriggerProps, 'active' | 'inputProps' | 'mode' | 'onBlur' | 'onChange' | 'onClick' | 'onFocus' | 'onKeyDown' | 'onScroll' | 'readOnly' | 'renderValue' | 'value'>, FormElementFocusHandlers, PickRenameMulti<Pick<MenuProps, 'itemsInView' | 'maxHeight' | 'role' | 'size'>, {
9
- maxHeight: 'menuMaxHeight';
10
- role: 'menuRole';
11
- size: 'menuSize';
12
- }>, PickRenameMulti<Pick<PopperProps, 'options' | 'disablePortal'>, {
13
- options: 'popperOptions';
14
- disablePortal: 'disablePortal';
15
- }>, Pick<MenuProps, 'children'> {
5
+ import { SelectTriggerInputProps, SelectTriggerProps, SelectValue } from './typings';
6
+ export interface SelectBaseProps extends Omit<SelectTriggerProps, 'active' | 'inputProps' | 'mode' | 'onBlur' | 'onChange' | 'onClick' | 'onFocus' | 'onKeyDown' | 'onScroll' | 'type' | 'renderValue' | 'value'>, FormElementFocusHandlers {
7
+ /**
8
+ * The children of select (Option components).
9
+ * If `options` is provided, this will be ignored.
10
+ */
11
+ children?: ReactElement | ReactElement[];
12
+ /**
13
+ * Direct options array for dropdown (supports tree structure).
14
+ * If provided, `children` will be ignored and `type` will be automatically set.
15
+ */
16
+ options?: DropdownOption[];
17
+ /**
18
+ * The type of dropdown.
19
+ * @default 'default'
20
+ */
21
+ type?: DropdownType;
16
22
  /**
17
23
  * The other native props for input element.
18
24
  */
19
25
  inputProps?: Omit<SelectTriggerInputProps, 'onBlur' | 'onChange' | 'onFocus' | 'placeholder' | 'role' | 'value' | `aria-${'controls' | 'expanded' | 'owns'}`>;
26
+ /**
27
+ * Whether to disable portal.
28
+ */
29
+ disablePortal?: boolean;
30
+ /**
31
+ * The max height of the dropdown list.
32
+ */
33
+ menuMaxHeight?: number | string;
20
34
  /**
21
35
  * Popup menu scroll listener
22
36
  */
23
- onMenuScroll?: (computed: {
37
+ onScroll?: (computed: {
24
38
  scrollTop: number;
25
39
  maxScrollTop: number;
26
- }, target: HTMLUListElement) => void;
40
+ }, target: HTMLDivElement) => void;
27
41
  /**
28
42
  * select input placeholder
29
43
  */
30
44
  placeholder?: string;
45
+ /**
46
+ * Whether the input is readonly.
47
+ * @default false
48
+ */
49
+ readOnly?: boolean;
31
50
  /**
32
51
  * To customize rendering select input value
33
52
  */
@@ -54,7 +73,7 @@ export type SelectMultipleProps = SelectBaseProps & {
54
73
  /**
55
74
  * The change event handler of input element.
56
75
  */
57
- onChange?(newOptions: SelectValue[]): any;
76
+ onChange?(newOptions: SelectValue[]): void;
58
77
  /**
59
78
  * To customize rendering select input value
60
79
  */
@@ -77,7 +96,7 @@ export type SelectSingleProps = SelectBaseProps & {
77
96
  /**
78
97
  * The change event handler of input element.
79
98
  */
80
- onChange?(newOptions: SelectValue): any;
99
+ onChange?(newOptions: SelectValue | null): void;
81
100
  /**
82
101
  * To customize rendering select input value
83
102
  */
@@ -89,5 +108,5 @@ export type SelectSingleProps = SelectBaseProps & {
89
108
  value?: SelectValue | null;
90
109
  };
91
110
  export type SelectProps = SelectMultipleProps | SelectSingleProps;
92
- declare const Select: import("react").ForwardRefExoticComponent<(Omit<SelectMultipleProps, "ref"> | Omit<SelectSingleProps, "ref">) & import("react").RefAttributes<HTMLDivElement>>;
111
+ declare const Select: React.ForwardRefExoticComponent<SelectProps & React.RefAttributes<HTMLDivElement>>;
93
112
  export default Select;