@mezzanine-ui/react 1.0.0-beta.2 → 1.0.0-beta.4

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 (193) hide show
  1. package/Anchor/Anchor.d.ts +51 -18
  2. package/Anchor/Anchor.js +15 -15
  3. package/Anchor/AnchorGroup.d.ts +34 -0
  4. package/Anchor/AnchorGroup.js +37 -0
  5. package/Anchor/AnchorItem.d.ts +30 -0
  6. package/Anchor/AnchorItem.js +65 -0
  7. package/Anchor/index.d.ts +2 -0
  8. package/Anchor/index.js +1 -0
  9. package/Anchor/utils.d.ts +13 -0
  10. package/Anchor/utils.js +95 -0
  11. package/AutoComplete/AutoComplete.d.ts +217 -0
  12. package/AutoComplete/AutoComplete.js +433 -0
  13. package/AutoComplete/index.d.ts +2 -0
  14. package/AutoComplete/index.js +1 -0
  15. package/AutoComplete/useAutoCompleteCreation.d.ts +33 -0
  16. package/AutoComplete/useAutoCompleteCreation.js +201 -0
  17. package/AutoComplete/useAutoCompleteKeyboard.d.ts +31 -0
  18. package/AutoComplete/useAutoCompleteKeyboard.js +149 -0
  19. package/AutoComplete/useAutoCompleteSearch.d.ts +16 -0
  20. package/AutoComplete/useAutoCompleteSearch.js +69 -0
  21. package/AutoComplete/useCreationTracker.d.ts +17 -0
  22. package/AutoComplete/useCreationTracker.js +47 -0
  23. package/Breadcrumb/Breadcrumb.js +16 -21
  24. package/Breadcrumb/BreadcrumbDropdown.d.ts +11 -0
  25. package/Breadcrumb/BreadcrumbDropdown.js +22 -0
  26. package/Breadcrumb/BreadcrumbItem.d.ts +2 -3
  27. package/Breadcrumb/BreadcrumbItem.js +13 -31
  28. package/Breadcrumb/BreadcrumbOverflowMenu.d.ts +7 -0
  29. package/Breadcrumb/BreadcrumbOverflowMenu.js +77 -0
  30. package/Breadcrumb/BreadcrumbOverflowMenuDropdown.d.ts +11 -0
  31. package/Breadcrumb/BreadcrumbOverflowMenuDropdown.js +21 -0
  32. package/Breadcrumb/BreadcrumbOverflowMenuItem.d.ts +3 -0
  33. package/Breadcrumb/BreadcrumbOverflowMenuItem.js +27 -0
  34. package/Breadcrumb/typings.d.ts +21 -39
  35. package/Button/Button.js +13 -11
  36. package/Button/index.d.ts +1 -1
  37. package/Button/typings.d.ts +27 -4
  38. package/Checkbox/index.d.ts +4 -5
  39. package/Checkbox/index.js +1 -5
  40. package/ContentHeader/ContentHeader.d.ts +160 -0
  41. package/ContentHeader/ContentHeader.js +54 -0
  42. package/ContentHeader/index.d.ts +2 -0
  43. package/ContentHeader/index.js +1 -0
  44. package/ContentHeader/utils.d.ts +23 -0
  45. package/ContentHeader/utils.js +215 -0
  46. package/Description/Description.d.ts +12 -22
  47. package/Description/Description.js +4 -24
  48. package/Dropdown/Dropdown.d.ts +46 -1
  49. package/Dropdown/Dropdown.js +99 -14
  50. package/Dropdown/DropdownAction.d.ts +1 -1
  51. package/Dropdown/DropdownAction.js +1 -4
  52. package/Dropdown/DropdownItem.d.ts +28 -1
  53. package/Dropdown/DropdownItem.js +56 -14
  54. package/Dropdown/DropdownItemCard.d.ts +2 -2
  55. package/Dropdown/DropdownItemCard.js +20 -16
  56. package/Dropdown/DropdownStatus.js +29 -0
  57. package/Dropdown/dropdownKeydownHandler.d.ts +2 -1
  58. package/Dropdown/dropdownKeydownHandler.js +73 -0
  59. package/Dropdown/highlightText.js +5 -1
  60. package/Dropdown/shortcutTextHandler.d.ts +24 -0
  61. package/Dropdown/shortcutTextHandler.js +171 -0
  62. package/Empty/Empty.js +2 -1
  63. package/Empty/icons/EmptyMainNotificationIcon.d.ts +4 -0
  64. package/Empty/icons/EmptyMainNotificationIcon.js +9 -0
  65. package/Empty/typings.d.ts +2 -2
  66. package/FilterArea/Filter.d.ts +32 -0
  67. package/FilterArea/Filter.js +23 -0
  68. package/FilterArea/FilterArea.d.ts +58 -0
  69. package/FilterArea/FilterArea.js +31 -0
  70. package/FilterArea/FilterLine.d.ts +11 -0
  71. package/FilterArea/FilterLine.js +13 -0
  72. package/FilterArea/index.d.ts +6 -0
  73. package/FilterArea/index.js +3 -0
  74. package/Form/FormField.js +3 -1
  75. package/Input/Input.d.ts +35 -7
  76. package/Input/Input.js +48 -14
  77. package/Input/index.d.ts +1 -1
  78. package/Modal/MediaPreviewModal.d.ts +54 -0
  79. package/Modal/MediaPreviewModal.js +158 -0
  80. package/Modal/Modal.d.ts +103 -11
  81. package/Modal/Modal.js +14 -9
  82. package/Modal/ModalBodyForVerification.d.ts +59 -0
  83. package/Modal/ModalBodyForVerification.js +99 -0
  84. package/Modal/ModalControl.d.ts +2 -2
  85. package/Modal/ModalControl.js +1 -1
  86. package/Modal/ModalFooter.d.ts +119 -1
  87. package/Modal/ModalFooter.js +15 -3
  88. package/Modal/ModalHeader.d.ts +26 -7
  89. package/Modal/ModalHeader.js +33 -7
  90. package/Modal/index.d.ts +6 -5
  91. package/Modal/index.js +2 -2
  92. package/Modal/useModalContainer.d.ts +12 -3
  93. package/Modal/useModalContainer.js +28 -6
  94. package/Navigation/Navigation.d.ts +7 -2
  95. package/Navigation/Navigation.js +36 -35
  96. package/Navigation/NavigationHeader.d.ts +4 -0
  97. package/Navigation/NavigationHeader.js +3 -2
  98. package/Navigation/NavigationOption.d.ts +8 -3
  99. package/Navigation/NavigationOption.js +46 -11
  100. package/Navigation/NavigationOptionCategory.js +1 -0
  101. package/Navigation/NavigationOverflowMenu.d.ts +6 -0
  102. package/Navigation/NavigationOverflowMenu.js +90 -0
  103. package/Navigation/NavigationOverflowMenuOption.d.ts +7 -0
  104. package/Navigation/NavigationOverflowMenuOption.js +68 -0
  105. package/Navigation/NavigationUserMenu.d.ts +4 -2
  106. package/Navigation/NavigationUserMenu.js +13 -5
  107. package/Navigation/context.d.ts +3 -2
  108. package/Navigation/useVisibleItems.d.ts +5 -0
  109. package/Navigation/useVisibleItems.js +54 -0
  110. package/NotificationCenter/NotificationCenter.d.ts +124 -0
  111. package/NotificationCenter/NotificationCenter.js +279 -0
  112. package/NotificationCenter/NotificationCenterDrawer.d.ts +109 -0
  113. package/NotificationCenter/index.d.ts +3 -0
  114. package/NotificationCenter/index.js +1 -0
  115. package/PageFooter/PageFooter.d.ts +19 -9
  116. package/PageFooter/PageFooter.js +10 -10
  117. package/PageHeader/PageHeader.d.ts +32 -25
  118. package/PageHeader/PageHeader.js +49 -43
  119. package/ResultState/ResultState.d.ts +9 -0
  120. package/ResultState/ResultState.js +36 -4
  121. package/Scrollbar/Scrollbar.d.ts +9 -0
  122. package/Scrollbar/Scrollbar.js +78 -0
  123. package/Scrollbar/index.d.ts +2 -0
  124. package/Scrollbar/index.js +1 -0
  125. package/Scrollbar/typings.d.ts +47 -0
  126. package/Select/SelectTrigger.js +5 -4
  127. package/Select/index.d.ts +0 -2
  128. package/Select/index.js +0 -1
  129. package/Select/typings.d.ts +6 -1
  130. package/Selection/Selection.js +1 -1
  131. package/Selection/SelectionGroup.d.ts +28 -0
  132. package/Slider/useSlider.js +1 -1
  133. package/Table/Table.d.ts +2 -120
  134. package/Table/Table.js +148 -53
  135. package/Table/TableContext.d.ts +11 -12
  136. package/Table/components/TableActionsCell.js +12 -4
  137. package/Table/components/TableBody.js +2 -1
  138. package/Table/components/TableBulkActions.js +1 -19
  139. package/Table/components/TableColGroup.d.ts +1 -4
  140. package/Table/components/TableColGroup.js +15 -16
  141. package/Table/components/TableCollectableCell.d.ts +17 -0
  142. package/Table/components/TableCollectableCell.js +54 -0
  143. package/Table/components/TableDragOrPinHandleCell.d.ts +20 -0
  144. package/Table/components/TableDragOrPinHandleCell.js +58 -0
  145. package/Table/components/TableExpandedRow.js +11 -2
  146. package/Table/components/TableHeader.js +12 -10
  147. package/Table/components/TableRow.js +38 -13
  148. package/Table/components/TableSelectionCell.js +1 -1
  149. package/Table/components/TableToggleableCell.d.ts +16 -0
  150. package/Table/components/TableToggleableCell.js +51 -0
  151. package/Table/components/index.d.ts +4 -1
  152. package/Table/components/index.js +3 -0
  153. package/Table/hooks/typings.d.ts +18 -4
  154. package/Table/hooks/useTableExpansion.d.ts +2 -2
  155. package/Table/hooks/useTableExpansion.js +5 -5
  156. package/Table/hooks/useTableFixedOffsets.d.ts +6 -2
  157. package/Table/hooks/useTableFixedOffsets.js +60 -26
  158. package/Table/hooks/useTableScroll.d.ts +9 -3
  159. package/Table/hooks/useTableScroll.js +34 -7
  160. package/Table/hooks/useTableVirtualization.d.ts +2 -1
  161. package/Table/hooks/useTableVirtualization.js +2 -8
  162. package/Table/index.d.ts +4 -3
  163. package/Table/index.js +3 -0
  164. package/Table/typings.d.ts +172 -0
  165. package/Table/utils/useTableRowSelection.js +13 -5
  166. package/Tag/TagGroup.d.ts +3 -0
  167. package/Tag/index.d.ts +2 -0
  168. package/Tag/index.js +1 -0
  169. package/Transition/Slide.d.ts +9 -2
  170. package/Transition/Slide.js +7 -4
  171. package/Tree/TreeNode.js +1 -1
  172. package/Upload/UploadPictureCard.js +1 -1
  173. package/index.d.ts +37 -21
  174. package/index.js +25 -11
  175. package/package.json +6 -4
  176. package/Modal/ModalActions.d.ts +0 -9
  177. package/Modal/ModalActions.js +0 -20
  178. package/Modal/ModalBody.d.ts +0 -7
  179. package/Modal/ModalBody.js +0 -14
  180. package/Notification/Notification.d.ts +0 -54
  181. package/Notification/Notification.js +0 -76
  182. package/Notification/index.d.ts +0 -3
  183. package/Notification/index.js +0 -1
  184. package/PageToolbar/PageToolbar.d.ts +0 -114
  185. package/PageToolbar/PageToolbar.js +0 -23
  186. package/PageToolbar/index.d.ts +0 -2
  187. package/PageToolbar/index.js +0 -1
  188. package/PageToolbar/utils.d.ts +0 -23
  189. package/PageToolbar/utils.js +0 -165
  190. package/Select/AutoComplete.d.ts +0 -107
  191. package/Select/AutoComplete.js +0 -114
  192. package/Table/components/TableDragHandleCell.d.ts +0 -11
  193. package/Table/components/TableDragHandleCell.js +0 -44
@@ -0,0 +1,27 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { forwardRef } from 'react';
3
+ import { breadcrumbOverflowMenuItemClasses } from '@mezzanine-ui/core/breadcrumb';
4
+ import Typography from '../Typography/Typography.js';
5
+ import BreadcrumbOverflowMenuDropdown from './BreadcrumbOverflowMenuDropdown.js';
6
+ import cx from 'clsx';
7
+
8
+ const BreadcrumbOverflowMenuItem = forwardRef(function BreadcrumbOverflowMenuItem(props, ref) {
9
+ if ('options' in props)
10
+ return jsx(BreadcrumbOverflowMenuDropdown, { ...props });
11
+ const { className, component, current, href, name, onClick, rel, target, ...rest } = props;
12
+ const TriggerComponent = (() => {
13
+ if (component)
14
+ return component;
15
+ if ((!current && 'href' in props && typeof props.href === 'string') ||
16
+ 'onClick' in props) {
17
+ return 'a';
18
+ }
19
+ return 'span';
20
+ })();
21
+ const handleClick = () => {
22
+ onClick === null || onClick === void 0 ? void 0 : onClick();
23
+ };
24
+ return (jsx("span", { ...rest, className: cx(breadcrumbOverflowMenuItemClasses.host, className), ref: ref, children: jsx(TriggerComponent, { className: cx(breadcrumbOverflowMenuItemClasses.trigger), href: TriggerComponent === 'a' ? href : undefined, onClick: TriggerComponent === 'a' ? handleClick : undefined, rel: TriggerComponent === 'a' ? rel : undefined, target: TriggerComponent === 'a' ? target : undefined, children: jsx(Typography, { variant: 'label-primary', children: name }) }) }));
25
+ });
26
+
27
+ export { BreadcrumbOverflowMenuItem as default };
@@ -1,5 +1,6 @@
1
1
  import type { JSXElementConstructor, ReactElement } from 'react';
2
2
  import type { ComponentOverridableForwardRefComponentPropsFactory, NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
3
+ import type { DropdownProps } from '../Dropdown';
3
4
  export type BreadcrumbProps = Omit<NativeElementPropsWithoutKeyAndRef<'nav'>, 'children'> & ({
4
5
  /**
5
6
  * Display only the last two items with an ellipsis dropdown for all previous items
@@ -12,64 +13,45 @@ export type BreadcrumbProps = Omit<NativeElementPropsWithoutKeyAndRef<'nav'>, 'c
12
13
  items?: never;
13
14
  children: ReactElement<BreadcrumbItemProps> | ReactElement<BreadcrumbItemProps>[];
14
15
  });
15
- export type BreadcrumbItemComponent = 'a' | 'button' | JSXElementConstructor<any>;
16
- export type BreadcrumbItemProps<C extends BreadcrumbItemComponent = 'button'> = ComponentOverridableForwardRefComponentPropsFactory<BreadcrumbItemComponent, C, BreadcrumbDropdownItemProps | BreadcrumbItemTextProps | BreadcrumbLinkItemProps>;
17
- export type BreadcrumbDropdownItemProps = Omit<NativeElementPropsWithoutKeyAndRef<'button'>, 'children'> & {
18
- component?: 'button';
19
- /**
20
- * Whether is the current page item.
21
- */
22
- current?: boolean;
23
- /**
24
- * Whether to expand the dropdown item icon.
25
- */
26
- expand?: boolean;
27
- href?: string;
28
- label?: string;
29
- /**
30
- * The dropdown options.
31
- */
32
- options: Array<{
33
- /**
34
- * The href of dropdown item.
35
- */
36
- href?: string;
37
- id?: string;
38
- /**
39
- * The content of dropdown item.
40
- */
41
- label?: string;
42
- target?: '_blank' | '_parent' | '_self' | '_top' | string;
43
- }>;
44
- target?: '_blank' | '_parent' | '_self' | '_top' | string;
45
- };
16
+ export type BreadcrumbItemComponent = 'a' | 'span' | JSXElementConstructor<any>;
17
+ export type BreadcrumbItemProps<C extends BreadcrumbItemComponent = 'span'> = Omit<ComponentOverridableForwardRefComponentPropsFactory<BreadcrumbItemComponent, C, BreadcrumbItemTextProps | BreadcrumbLinkItemProps>, 'children' | 'onSelect'> | BreadcrumbDropdownProps;
46
18
  export type BreadcrumbItemTextProps = {
47
- component?: 'div';
19
+ component?: 'span';
48
20
  /**
49
21
  * Whether is the current page item.
50
22
  */
51
23
  current?: boolean;
52
- expand?: never;
53
24
  href?: never;
25
+ id?: string;
54
26
  /**
55
- * The content of breadcrumb text.
27
+ * The content of breadcrumb item text.
56
28
  */
57
- label: string;
58
- options?: never;
29
+ name: string;
30
+ onClick?: never;
59
31
  target?: never;
60
32
  };
61
33
  export type BreadcrumbLinkItemProps = Omit<NativeElementPropsWithoutKeyAndRef<'a'>, 'children'> & {
62
34
  component?: 'a';
63
35
  current?: boolean;
64
- expand?: never;
65
36
  /**
66
37
  * The href of breadcrumb link.
67
38
  */
68
39
  href: string;
69
- label: string;
70
- options?: never;
40
+ id?: string;
41
+ name: string;
42
+ onClick?: () => void;
71
43
  /**
72
44
  * The target attribute specifies where to open the linked document.
73
45
  */
74
46
  target?: '_blank' | '_parent' | '_self' | '_top' | string;
75
47
  };
48
+ export type BreadcrumbDropdownProps = Omit<DropdownProps, 'children'> & {
49
+ className?: string;
50
+ current?: boolean;
51
+ href?: never;
52
+ id?: string;
53
+ name: string;
54
+ onClick?: () => void;
55
+ open?: boolean;
56
+ target?: never;
57
+ };
package/Button/Button.js CHANGED
@@ -4,18 +4,16 @@ import { forwardRef } from 'react';
4
4
  import { SpinnerIcon } from '@mezzanine-ui/icons';
5
5
  import { buttonClasses } from '@mezzanine-ui/core/button';
6
6
  import Icon from '../Icon/Icon.js';
7
+ import Tooltip from '../Tooltip/Tooltip.js';
7
8
  import cx from 'clsx';
8
9
 
9
10
  /**
10
11
  * The react component for `mezzanine` button.
11
12
  */
12
13
  const Button = forwardRef(function Button(props, ref) {
13
- const { children, className, component: Component = 'button', disabled = false, icon, loading = false, onClick, size = 'main', variant = 'base-primary', ...rest } = props;
14
- // 判斷是否為 icon-only 模式
15
- const isIconOnly = (icon === null || icon === void 0 ? void 0 : icon.position) === 'icon-only' || (!!icon && !children);
16
- // 判斷 icon 位置
17
- const hasLeadingIcon = (icon === null || icon === void 0 ? void 0 : icon.position) === 'leading' && !isIconOnly;
18
- const hasTrailingIcon = (icon === null || icon === void 0 ? void 0 : icon.position) === 'trailing' && !isIconOnly;
14
+ const { children, className, component: Component = 'button', disabled = false, disabledTooltip = false, icon, iconType, loading = false, onClick, size = 'main', tooltipPosition = 'bottom', variant = 'base-primary', ...rest } = props;
15
+ const isIconOnly = iconType === 'icon-only';
16
+ const showTooltip = isIconOnly && !disabledTooltip && Boolean(children);
19
17
  // Loading 狀態下的 icon
20
18
  const loadingIcon = jsx(Icon, { icon: SpinnerIcon, spin: true, size: 16 });
21
19
  // 渲染 icon 內容
@@ -24,21 +22,25 @@ const Button = forwardRef(function Button(props, ref) {
24
22
  return loadingIcon;
25
23
  }
26
24
  if (icon) {
27
- return jsx(Icon, { icon: icon.src, size: 16 });
25
+ return jsx(Icon, { icon: icon, size: 16 });
28
26
  }
29
27
  return null;
30
28
  };
31
- return (jsx(Component, { ...rest, ref: ref, "aria-disabled": disabled, className: cx(buttonClasses.host, buttonClasses.variant(variant), buttonClasses.size(size), {
29
+ const buttonElement = (tooltipProps) => (jsx(Component, { ...rest, ref: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.ref) || ref, "aria-disabled": disabled, className: cx(buttonClasses.host, buttonClasses.variant(variant), buttonClasses.size(size), {
32
30
  [buttonClasses.disabled]: disabled,
33
31
  [buttonClasses.loading]: loading,
34
- [buttonClasses.iconLeading]: hasLeadingIcon,
35
- [buttonClasses.iconTrailing]: hasTrailingIcon,
32
+ [buttonClasses.iconLeading]: iconType === 'leading',
33
+ [buttonClasses.iconTrailing]: iconType === 'trailing',
36
34
  [buttonClasses.iconOnly]: isIconOnly,
37
35
  }, className), disabled: disabled, onClick: (event) => {
38
36
  if (!disabled && !loading && onClick) {
39
37
  onClick(event);
40
38
  }
41
- }, children: loading ? (renderIcon()) : (jsxs(Fragment, { children: [(hasLeadingIcon || isIconOnly) && renderIcon(), !isIconOnly && children, hasTrailingIcon && renderIcon()] })) }));
39
+ }, onMouseEnter: tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.onMouseEnter, onMouseLeave: tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.onMouseLeave, children: loading ? (renderIcon()) : (jsxs(Fragment, { children: [(iconType === 'leading' || isIconOnly) && renderIcon(), !isIconOnly && children, iconType === 'trailing' && renderIcon()] })) }));
40
+ if (showTooltip) {
41
+ return (jsx(Tooltip, { options: { placement: tooltipPosition }, title: children, children: (tooltipProps) => buttonElement(tooltipProps) }));
42
+ }
43
+ return buttonElement();
42
44
  });
43
45
 
44
46
  export { Button as default };
package/Button/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { PropsWithoutRef, ReactElement, RefAttributes } from 'react';
2
2
  import { ButtonComponent, ButtonPropsBase } from './typings';
3
3
  import { ButtonProps } from './Button';
4
- export type { ButtonIcon, ButtonIconPosition, ButtonGroupOrientation, ButtonSize, ButtonVariant, } from '@mezzanine-ui/core/button';
4
+ export type { ButtonIconType, ButtonGroupOrientation, ButtonSize, ButtonVariant, } from '@mezzanine-ui/core/button';
5
5
  export { default as ButtonGroup } from './ButtonGroup';
6
6
  export type { ButtonGroupChild, ButtonGroupProps } from './ButtonGroup';
7
7
  export type { ButtonComponent, ButtonProps, ButtonPropsBase };
@@ -1,5 +1,7 @@
1
- import { JSXElementConstructor } from 'react';
2
- import { ButtonIcon, ButtonSize, ButtonVariant } from '@mezzanine-ui/core/button';
1
+ import { JSXElementConstructor, ReactNode } from 'react';
2
+ import { IconDefinition } from '@mezzanine-ui/icons';
3
+ import { ButtonIconType, ButtonSize, ButtonVariant } from '@mezzanine-ui/core/button';
4
+ import { PopperPlacement } from '../Popper';
3
5
  export type ButtonComponent = 'button' | 'a' | JSXElementConstructor<any>;
4
6
  export interface ButtonPropsBase {
5
7
  /**
@@ -23,7 +25,28 @@ export interface ButtonPropsBase {
23
25
  */
24
26
  loading?: boolean;
25
27
  /**
26
- * Icon configuration with position and icon source.
28
+ * The icon to display.
27
29
  */
28
- icon?: ButtonIcon;
30
+ icon?: IconDefinition;
31
+ /**
32
+ * The type of the icon relative to the text.
33
+ */
34
+ iconType?: ButtonIconType;
35
+ /**
36
+ * The button text content.
37
+ * When iconType is 'icon-only', children will be used as tooltip content.
38
+ */
39
+ children?: ReactNode;
40
+ /**
41
+ * If true, disable the tooltip for icon-only buttons.
42
+ * Only applies when iconType is 'icon-only'.
43
+ * @default false
44
+ */
45
+ disabledTooltip?: boolean;
46
+ /**
47
+ * The position of the tooltip.
48
+ * Only applies when iconType is 'icon-only'.
49
+ * @default 'bottom'
50
+ */
51
+ tooltipPosition?: PopperPlacement;
29
52
  }
@@ -1,5 +1,5 @@
1
- import { PropsWithoutRef, ReactElement, RefAttributes } from 'react';
2
- import { CheckboxProps } from './Checkbox';
1
+ import type { PropsWithoutRef, ReactElement, RefAttributes } from 'react';
2
+ import type { CheckboxProps } from './Checkbox';
3
3
  export type { CheckboxGroupLayout, CheckboxGroupOption, } from '@mezzanine-ui/core/checkbox';
4
4
  export { default as CheckAll } from './CheckAll';
5
5
  export type { CheckAllProps } from './CheckAll';
@@ -11,6 +11,5 @@ export type { CheckboxComponent, CheckboxPropsBase } from './typings';
11
11
  * @remark
12
12
  * Add type alias here for parsable to react docgen typescript.
13
13
  */
14
- type GenericCheckbox = (props: PropsWithoutRef<CheckboxProps> & RefAttributes<HTMLLabelElement>) => ReactElement<any>;
15
- declare const _default: GenericCheckbox;
16
- export default _default;
14
+ export type GenericCheckbox = (props: PropsWithoutRef<CheckboxProps> & RefAttributes<HTMLLabelElement>) => ReactElement<any>;
15
+ export { default } from './Checkbox';
package/Checkbox/index.js CHANGED
@@ -1,7 +1,3 @@
1
- import Checkbox from './Checkbox.js';
2
1
  export { default as CheckAll } from './CheckAll.js';
3
2
  export { default as CheckboxGroup } from './CheckboxGroup.js';
4
-
5
-
6
-
7
- export { Checkbox as default };
3
+ export { default } from './Checkbox.js';
@@ -0,0 +1,160 @@
1
+ import { ReactElement } from 'react';
2
+ import { ButtonProps } from '../Button';
3
+ import { SearchInputProps } from '../Input';
4
+ import { SelectProps } from '../Select';
5
+ import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
6
+ import { IconDefinition } from '@mezzanine-ui/icons';
7
+ import { DropdownProps } from '../Dropdown';
8
+ type SegmentedControlProps = {
9
+ mock: 'SegmentedControlProps';
10
+ };
11
+ type ContentHeaderChild = ReactElement<SearchInputProps> | ReactElement<SelectProps> | ReactElement<SegmentedControlProps> | ReactElement<ButtonProps> | ReactElement<DropdownProps> | ReactElement<{
12
+ href: string;
13
+ }> | null | false | undefined;
14
+ /**
15
+ * Props for the ContentHeader component.
16
+ *
17
+ * Defines a flexible header with title, description, filter, action buttons, and utility icons.
18
+ * Commonly used in page headers for primary user actions.
19
+ */
20
+ export type ContentHeaderProps = Omit<NativeElementPropsWithoutKeyAndRef<'header'>, 'children'> & {
21
+ /**
22
+ * Button configuration for actions. <br />
23
+ * Automatically applies proper styling and order. <br />
24
+ * When conflicting with other props, props take priority over children. <br />
25
+ * Buttons with variants other than primary, secondary, and destructive will not be rendered. <br />
26
+ */
27
+ actions?: ButtonProps[];
28
+ /**
29
+ * Children elements: <br />
30
+ * - Back button which Component with href prop.
31
+ * - example 1: `<a href="..." />` <br />
32
+ * - example 2: `<Link href="..." />` <br />
33
+ * - conflicting prop: `onBackClick` <br />
34
+ * - Filter component (SearchInput, Select, or SegmentedControl) <br />
35
+ * - Action buttons `<Button />` <br />
36
+ * - Icon-only utility buttons `<Button icon="..." />` <br />
37
+ * - Overflow icon utility dropdown `<Dropdown> <Button icon="..." /> </Dropdown>` <br />
38
+ * <br />
39
+ * Can mix and match the above children. <br />
40
+ * The order of children does not matter as they will be arranged properly. <br />
41
+ * When conflicting with other props, props take priority over children. <br />
42
+ */
43
+ children?: ContentHeaderChild[] | ContentHeaderChild;
44
+ /** Optional description text displayed below the title */
45
+ description?: string;
46
+ /** Filter component (SearchInput, Select, or SegmentedControl) */
47
+ filter?: {
48
+ variant: 'search' | 'select' | 'segmentedControl';
49
+ } & (SearchInputProps | SelectProps | SegmentedControlProps);
50
+ /**
51
+ * Optional back button properties. <br />
52
+ * When provided, a back button will be rendered on the left side of the title. <br />
53
+ * href prop from children will be ignored if onBackClick is provided. <br />
54
+ * */
55
+ onBackClick?: () => void;
56
+ /**
57
+ * Size variant of the toolbar. <br />
58
+ * Affects the size of buttons and filter component. <br />
59
+ */
60
+ size?: 'main' | 'sub';
61
+ /** Main title text for the content header */
62
+ title: string;
63
+ /**
64
+ * HTML element type for the title (defaults to 'h1' for main size and 'h2' for sub size)
65
+ */
66
+ titleComponent?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p';
67
+ /**
68
+ * Icon-only utility buttons `<Button icon="..." />`. <br />
69
+ * They usually appear as smaller buttons with only an icon and no text.
70
+ */
71
+ utilities?: ((ButtonProps & {
72
+ icon: IconDefinition;
73
+ }) | DropdownProps)[];
74
+ };
75
+ /**
76
+ * ContentHeader component. <br />
77
+ * A flexible header with title, description, filter, action buttons, and utility icons. <br />
78
+ * Commonly used in page headers for primary user actions. <br />
79
+ *
80
+ * @example
81
+ * ```tsx
82
+ * <ContentHeader
83
+ * size="main"
84
+ * title={'ContentHeader Title'}
85
+ * description="description."
86
+ * >
87
+ * <a href="" title="back" /> <-- Back button
88
+ *
89
+ * <Input variant="search" placeholder="Search..." /> <-- Filter component
90
+ * <Button variant="base-secondary">Secondary</Button> <-- Action buttons
91
+ * <Button>Primary</Button>
92
+ *
93
+ * <Button icon={PlusIcon} /> <-- Utility icon button
94
+ * <Dropdown
95
+ * options={[
96
+ * { id: '1', name: 'Option 1' },
97
+ * { id: '2', name: 'Option 2' },
98
+ * ]}
99
+ * >
100
+ * <Button icon={DotHorizontalIcon} />
101
+ * </Dropdown> <-- Utility dropdown
102
+ * </ContentHeader>
103
+ * ```
104
+ */
105
+ declare const ContentHeader: import("react").ForwardRefExoticComponent<Omit<NativeElementPropsWithoutKeyAndRef<"header">, "children"> & {
106
+ /**
107
+ * Button configuration for actions. <br />
108
+ * Automatically applies proper styling and order. <br />
109
+ * When conflicting with other props, props take priority over children. <br />
110
+ * Buttons with variants other than primary, secondary, and destructive will not be rendered. <br />
111
+ */
112
+ actions?: ButtonProps[];
113
+ /**
114
+ * Children elements: <br />
115
+ * - Back button which Component with href prop.
116
+ * - example 1: `<a href="..." />` <br />
117
+ * - example 2: `<Link href="..." />` <br />
118
+ * - conflicting prop: `onBackClick` <br />
119
+ * - Filter component (SearchInput, Select, or SegmentedControl) <br />
120
+ * - Action buttons `<Button />` <br />
121
+ * - Icon-only utility buttons `<Button icon="..." />` <br />
122
+ * - Overflow icon utility dropdown `<Dropdown> <Button icon="..." /> </Dropdown>` <br />
123
+ * <br />
124
+ * Can mix and match the above children. <br />
125
+ * The order of children does not matter as they will be arranged properly. <br />
126
+ * When conflicting with other props, props take priority over children. <br />
127
+ */
128
+ children?: ContentHeaderChild[] | ContentHeaderChild;
129
+ /** Optional description text displayed below the title */
130
+ description?: string;
131
+ /** Filter component (SearchInput, Select, or SegmentedControl) */
132
+ filter?: {
133
+ variant: "search" | "select" | "segmentedControl";
134
+ } & (SearchInputProps | SelectProps | SegmentedControlProps);
135
+ /**
136
+ * Optional back button properties. <br />
137
+ * When provided, a back button will be rendered on the left side of the title. <br />
138
+ * href prop from children will be ignored if onBackClick is provided. <br />
139
+ * */
140
+ onBackClick?: () => void;
141
+ /**
142
+ * Size variant of the toolbar. <br />
143
+ * Affects the size of buttons and filter component. <br />
144
+ */
145
+ size?: "main" | "sub";
146
+ /** Main title text for the content header */
147
+ title: string;
148
+ /**
149
+ * HTML element type for the title (defaults to 'h1' for main size and 'h2' for sub size)
150
+ */
151
+ titleComponent?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p";
152
+ /**
153
+ * Icon-only utility buttons `<Button icon="..." />`. <br />
154
+ * They usually appear as smaller buttons with only an icon and no text.
155
+ */
156
+ utilities?: ((ButtonProps & {
157
+ icon: IconDefinition;
158
+ }) | DropdownProps)[];
159
+ } & import("react").RefAttributes<HTMLElement>>;
160
+ export default ContentHeader;
@@ -0,0 +1,54 @@
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import { forwardRef } from 'react';
3
+ import { contentHeaderClasses } from '@mezzanine-ui/core/content-header';
4
+ import Button from '../Button/Button.js';
5
+ import ButtonGroup from '../Button/ButtonGroup.js';
6
+ import { ChevronLeftIcon } from '@mezzanine-ui/icons';
7
+ import { renderFilterProp, renderActionsProp, renderIconButtonsProp, resolveContentHeaderChild } from './utils.js';
8
+ import Typography from '../Typography/Typography.js';
9
+ import cx from 'clsx';
10
+
11
+ /**
12
+ * ContentHeader component. <br />
13
+ * A flexible header with title, description, filter, action buttons, and utility icons. <br />
14
+ * Commonly used in page headers for primary user actions. <br />
15
+ *
16
+ * @example
17
+ * ```tsx
18
+ * <ContentHeader
19
+ * size="main"
20
+ * title={'ContentHeader Title'}
21
+ * description="description."
22
+ * >
23
+ * <a href="" title="back" /> <-- Back button
24
+ *
25
+ * <Input variant="search" placeholder="Search..." /> <-- Filter component
26
+ * <Button variant="base-secondary">Secondary</Button> <-- Action buttons
27
+ * <Button>Primary</Button>
28
+ *
29
+ * <Button icon={PlusIcon} /> <-- Utility icon button
30
+ * <Dropdown
31
+ * options={[
32
+ * { id: '1', name: 'Option 1' },
33
+ * { id: '2', name: 'Option 2' },
34
+ * ]}
35
+ * >
36
+ * <Button icon={DotHorizontalIcon} />
37
+ * </Dropdown> <-- Utility dropdown
38
+ * </ContentHeader>
39
+ * ```
40
+ */
41
+ const ContentHeader = forwardRef(function ContentHeader(props, ref) {
42
+ const { actions, children, className, description, filter, onBackClick, size = 'main', title, titleComponent = size === 'main' ? 'h1' : 'h2', utilities, ...rest } = props;
43
+ const renderFilter = renderFilterProp(filter, size);
44
+ const renderActions = actions ? renderActionsProp(actions, size) : null;
45
+ const renderUtilities = utilities
46
+ ? renderIconButtonsProp(utilities, size)
47
+ : null;
48
+ const { backButton, filter: filterFromChildren, actions: actionsFromChildren, utilities: utilitiesFromChildren, } = resolveContentHeaderChild(children, size);
49
+ // prop onBack takes precedence over backButtonOrLink
50
+ const renderBackButton = onBackClick ? (jsx(Button, { iconType: "icon-only", icon: ChevronLeftIcon, onClick: onBackClick, "aria-label": "Back", type: "button", size: "sub", variant: "base-tertiary" })) : (backButton);
51
+ return (jsxs("header", { ...rest, className: cx(contentHeaderClasses.host, contentHeaderClasses.size(size), className), ref: ref, children: [jsxs("span", { className: contentHeaderClasses.titleArea, children: [renderBackButton && (jsx("span", { className: contentHeaderClasses.backButton, children: renderBackButton })), jsxs("span", { className: contentHeaderClasses.textGroup, children: [jsx(Typography, { component: titleComponent, align: "left", color: "text-neutral-solid", variant: size === 'main' ? 'h2' : 'h3', children: title }), description && (jsx(Typography, { align: "left", color: "text-neutral", variant: "caption", children: description }))] })] }), jsxs("span", { className: contentHeaderClasses.actionArea, children: [renderFilter || filterFromChildren, (renderActions || actionsFromChildren.length > 0) && (jsx(ButtonGroup, { children: renderActions || actionsFromChildren })), (renderUtilities || utilitiesFromChildren.length > 0) && (jsx("span", { className: contentHeaderClasses.utilities, children: renderUtilities || utilitiesFromChildren }))] })] }));
52
+ });
53
+
54
+ export { ContentHeader as default };
@@ -0,0 +1,2 @@
1
+ export type { ContentHeaderProps } from './ContentHeader';
2
+ export { default } from './ContentHeader';
@@ -0,0 +1 @@
1
+ export { default } from './ContentHeader.js';
@@ -0,0 +1,23 @@
1
+ import { ReactElement } from 'react';
2
+ import { ButtonProps, ButtonGroupChild } from '../Button';
3
+ import { ContentHeaderProps } from './ContentHeader';
4
+ import { DropdownProps } from '../Dropdown';
5
+ /**
6
+ * Renders a button from either ButtonProps or a React element.
7
+ * Applies the specified size and variant to the button.
8
+ */
9
+ export declare const renderButton: (button: ButtonProps | ButtonGroupChild | undefined, size: ButtonProps["size"]) => ReactElement<ButtonProps> | null;
10
+ export declare const renderFilterProp: (prop: ContentHeaderProps["filter"], size: "main" | "sub") => import("react/jsx-runtime").JSX.Element | null;
11
+ export declare const renderIconButtonWithProps: (child: ReactElement<ButtonProps>, size: ButtonProps["size"]) => ReactElement<ButtonProps>;
12
+ export declare const renderIconButtonsProp: (utilities: ContentHeaderProps["utilities"], size: ButtonProps["size"]) => ButtonGroupChild | ButtonGroupChild[];
13
+ /**
14
+ * Renders action buttons based on the actions configuration.
15
+ * Supports both structured actions object and single button element/props.
16
+ */
17
+ export declare const renderActionsProp: (actions: ContentHeaderProps["actions"], size: ButtonProps["size"]) => ButtonGroupChild | ButtonGroupChild[];
18
+ export declare const resolveContentHeaderChild: (children: ContentHeaderProps["children"], size: "main" | "sub") => {
19
+ filter: null;
20
+ actions: ReactElement<ButtonProps, string | import("react").JSXElementConstructor<any>>[];
21
+ utilities: (ButtonGroupChild | ReactElement<DropdownProps, string | import("react").JSXElementConstructor<any>>)[];
22
+ backButton: null;
23
+ };