@mezzanine-ui/react 1.0.0-beta.3 → 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 (121) hide show
  1. package/AutoComplete/AutoComplete.d.ts +23 -0
  2. package/AutoComplete/AutoComplete.js +23 -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/Checkbox/index.d.ts +4 -5
  16. package/Checkbox/index.js +1 -5
  17. package/ContentHeader/ContentHeader.d.ts +160 -0
  18. package/ContentHeader/ContentHeader.js +54 -0
  19. package/ContentHeader/index.d.ts +2 -0
  20. package/ContentHeader/index.js +1 -0
  21. package/ContentHeader/utils.d.ts +23 -0
  22. package/ContentHeader/utils.js +215 -0
  23. package/Dropdown/Dropdown.d.ts +17 -0
  24. package/Dropdown/Dropdown.js +6 -2
  25. package/Dropdown/DropdownItem.d.ts +10 -0
  26. package/Dropdown/DropdownItem.js +37 -8
  27. package/Dropdown/DropdownItemCard.d.ts +2 -2
  28. package/Dropdown/DropdownItemCard.js +11 -8
  29. package/Empty/Empty.js +2 -1
  30. package/Empty/icons/EmptyMainNotificationIcon.d.ts +4 -0
  31. package/Empty/icons/EmptyMainNotificationIcon.js +9 -0
  32. package/Empty/typings.d.ts +2 -2
  33. package/FilterArea/Filter.d.ts +32 -0
  34. package/FilterArea/Filter.js +23 -0
  35. package/FilterArea/FilterArea.d.ts +58 -0
  36. package/FilterArea/FilterArea.js +31 -0
  37. package/FilterArea/FilterLine.d.ts +11 -0
  38. package/FilterArea/FilterLine.js +13 -0
  39. package/FilterArea/index.d.ts +6 -0
  40. package/FilterArea/index.js +3 -0
  41. package/Input/Input.d.ts +6 -4
  42. package/Input/Input.js +28 -10
  43. package/Input/index.d.ts +1 -1
  44. package/Modal/MediaPreviewModal.d.ts +54 -0
  45. package/Modal/MediaPreviewModal.js +158 -0
  46. package/Modal/Modal.js +1 -1
  47. package/Modal/index.d.ts +2 -0
  48. package/Modal/index.js +1 -0
  49. package/Navigation/Navigation.js +6 -5
  50. package/Navigation/NavigationOption.d.ts +6 -2
  51. package/Navigation/NavigationOption.js +19 -9
  52. package/Navigation/NavigationOverflowMenu.d.ts +6 -0
  53. package/Navigation/NavigationOverflowMenu.js +90 -0
  54. package/Navigation/NavigationOverflowMenuOption.d.ts +7 -0
  55. package/Navigation/NavigationOverflowMenuOption.js +68 -0
  56. package/Navigation/NavigationUserMenu.d.ts +4 -2
  57. package/Navigation/NavigationUserMenu.js +13 -5
  58. package/Navigation/context.d.ts +3 -2
  59. package/NotificationCenter/NotificationCenter.d.ts +1 -1
  60. package/NotificationCenter/NotificationCenter.js +34 -14
  61. package/NotificationCenter/NotificationCenterDrawer.d.ts +20 -0
  62. package/PageHeader/PageHeader.d.ts +32 -25
  63. package/PageHeader/PageHeader.js +49 -35
  64. package/ResultState/ResultState.d.ts +9 -0
  65. package/ResultState/ResultState.js +36 -4
  66. package/Scrollbar/Scrollbar.d.ts +9 -0
  67. package/Scrollbar/Scrollbar.js +78 -0
  68. package/Scrollbar/index.d.ts +2 -0
  69. package/Scrollbar/index.js +1 -0
  70. package/Scrollbar/typings.d.ts +47 -0
  71. package/Select/SelectTrigger.js +5 -4
  72. package/Select/typings.d.ts +6 -1
  73. package/Selection/Selection.js +1 -1
  74. package/Selection/SelectionGroup.d.ts +28 -0
  75. package/Table/Table.d.ts +2 -120
  76. package/Table/Table.js +148 -53
  77. package/Table/TableContext.d.ts +11 -12
  78. package/Table/components/TableActionsCell.js +12 -4
  79. package/Table/components/TableBody.js +2 -1
  80. package/Table/components/TableColGroup.d.ts +1 -4
  81. package/Table/components/TableColGroup.js +15 -16
  82. package/Table/components/TableCollectableCell.d.ts +17 -0
  83. package/Table/components/TableCollectableCell.js +54 -0
  84. package/Table/components/TableDragOrPinHandleCell.d.ts +20 -0
  85. package/Table/components/TableDragOrPinHandleCell.js +58 -0
  86. package/Table/components/TableExpandedRow.js +11 -2
  87. package/Table/components/TableHeader.js +12 -10
  88. package/Table/components/TableRow.js +38 -13
  89. package/Table/components/TableSelectionCell.js +1 -1
  90. package/Table/components/TableToggleableCell.d.ts +16 -0
  91. package/Table/components/TableToggleableCell.js +51 -0
  92. package/Table/components/index.d.ts +4 -1
  93. package/Table/components/index.js +3 -0
  94. package/Table/hooks/typings.d.ts +18 -4
  95. package/Table/hooks/useTableExpansion.d.ts +2 -2
  96. package/Table/hooks/useTableExpansion.js +5 -5
  97. package/Table/hooks/useTableFixedOffsets.d.ts +6 -2
  98. package/Table/hooks/useTableFixedOffsets.js +58 -24
  99. package/Table/hooks/useTableScroll.d.ts +9 -3
  100. package/Table/hooks/useTableScroll.js +34 -7
  101. package/Table/hooks/useTableVirtualization.d.ts +2 -1
  102. package/Table/hooks/useTableVirtualization.js +2 -8
  103. package/Table/index.d.ts +4 -3
  104. package/Table/index.js +3 -0
  105. package/Table/typings.d.ts +172 -0
  106. package/Transition/Slide.d.ts +9 -2
  107. package/Transition/Slide.js +7 -4
  108. package/Tree/TreeNode.js +1 -1
  109. package/index.d.ts +4 -2
  110. package/index.js +6 -3
  111. package/package.json +6 -4
  112. package/Navigation/CollapsedMenu.d.ts +0 -6
  113. package/Navigation/CollapsedMenu.js +0 -16
  114. package/PageToolbar/PageToolbar.d.ts +0 -110
  115. package/PageToolbar/PageToolbar.js +0 -23
  116. package/PageToolbar/index.d.ts +0 -2
  117. package/PageToolbar/index.js +0 -1
  118. package/PageToolbar/utils.d.ts +0 -23
  119. package/PageToolbar/utils.js +0 -157
  120. package/Table/components/TableDragHandleCell.d.ts +0 -11
  121. package/Table/components/TableDragHandleCell.js +0 -44
@@ -40,6 +40,11 @@ export interface AutoCompleteBaseProps extends Omit<SelectTriggerProps, 'active'
40
40
  * @important When using with react-hook-form or native forms, this prop is recommended.
41
41
  */
42
42
  id?: string;
43
+ /**
44
+ * Whether to keep search text visible after blur when no value is selected.
45
+ * @default false
46
+ */
47
+ keepSearchTextOnBlur?: boolean;
43
48
  /**
44
49
  * The position of the input.
45
50
  * @default 'outside'
@@ -86,6 +91,10 @@ export interface AutoCompleteBaseProps extends Omit<SelectTriggerProps, 'active'
86
91
  * Can return a Promise for async data loading
87
92
  */
88
93
  onSearch?(input: string): void | Promise<void>;
94
+ /**
95
+ * Callback fired on every input change (no debounce).
96
+ */
97
+ onSearchTextChange?(text: string): void;
89
98
  /**
90
99
  * Callback fired when the dropdown visibility changes.
91
100
  */
@@ -135,6 +144,20 @@ export interface AutoCompleteBaseProps extends Omit<SelectTriggerProps, 'active'
135
144
  * @default '建立 "{text}"'
136
145
  */
137
146
  createActionTextTemplate?: string;
147
+ /**
148
+ * The z-index of the dropdown.
149
+ */
150
+ dropdownZIndex?: number | string;
151
+ /**
152
+ * Callback fired when the dropdown list reaches the bottom.
153
+ * Only fires when `menuMaxHeight` is set and the list is scrollable.
154
+ */
155
+ onReachBottom?: () => void;
156
+ /**
157
+ * Callback fired when the dropdown list leaves the bottom.
158
+ * Only fires when `menuMaxHeight` is set and the list is scrollable.
159
+ */
160
+ onLeaveBottom?: () => void;
138
161
  }
139
162
  export type AutoCompleteMultipleProps = AutoCompleteBaseProps & {
140
163
  /**
@@ -46,7 +46,7 @@ function isOptionSelected(option, value, isMultiple) {
46
46
  */
47
47
  const AutoComplete = forwardRef(function AutoComplete(props, ref) {
48
48
  const { disabled: disabledFromFormControl, fullWidth: fullWidthFromFormControl, required: requiredFromFormControl, severity, } = useContext(FormControlContext) || {};
49
- const { addable = false, asyncData = false, className, createSeparators = [',', '+', '\n'], defaultValue, disabled = disabledFromFormControl || false, disabledOptionsFilter = false, emptyText, error = severity === 'error' || false, fullWidth = fullWidthFromFormControl || false, id, inputPosition = 'outside', inputProps, inputRef, loading = false, loadingText, menuMaxHeight, mode = 'single', name, onClear: onClearProp, onChange: onChangeProp, onInsert, onSearch, onVisibilityChange, open: openProp, options: optionsProp, placeholder = '', prefix, required = requiredFromFormControl || false, searchDebounceTime = 300, searchTextControlRef, size, trimOnCreate = true, value: valueProp, createActionText, createActionTextTemplate = '建立 "{text}"', } = props;
49
+ const { addable = false, asyncData = false, className, createSeparators = [',', '+', '\n'], defaultValue, disabled = disabledFromFormControl || false, disabledOptionsFilter = false, emptyText, error = severity === 'error' || false, fullWidth = fullWidthFromFormControl || false, id, keepSearchTextOnBlur = false, inputPosition = 'outside', inputProps, inputRef, loading = false, loadingText, menuMaxHeight, mode = 'single', name, onClear: onClearProp, onChange: onChangeProp, onInsert, onSearch, onSearchTextChange, onVisibilityChange, open: openProp, options: optionsProp, placeholder = '', prefix, required = requiredFromFormControl || false, searchDebounceTime = 300, searchTextControlRef, size, trimOnCreate = true, value: valueProp, createActionText, createActionTextTemplate = '建立 "{text}"', dropdownZIndex, onReachBottom, onLeaveBottom, } = props;
50
50
  const [uncontrolledOpen, setUncontrolledOpen] = useState(false);
51
51
  const isMultiple = mode === 'multiple';
52
52
  const isSingle = !isMultiple;
@@ -147,14 +147,15 @@ const AutoComplete = forwardRef(function AutoComplete(props, ref) {
147
147
  // In single mode, show searchText when focused, otherwise show selected value
148
148
  // In multiple mode, always return empty string to avoid displaying "0"
149
149
  const renderValue = useMemo(() => {
150
- if (isSingle && focused) {
150
+ if (isSingle
151
+ && (focused || (keepSearchTextOnBlur && !value && searchText))) {
151
152
  return () => searchText;
152
153
  }
153
154
  if (isMultiple) {
154
155
  return () => '';
155
156
  }
156
157
  return undefined;
157
- }, [focused, isMultiple, isSingle, searchText]);
158
+ }, [focused, isMultiple, isSingle, keepSearchTextOnBlur, searchText, value]);
158
159
  function getPlaceholder() {
159
160
  if (isSingle && focused && isSingleValue(value)) {
160
161
  return value.name;
@@ -167,6 +168,7 @@ const AutoComplete = forwardRef(function AutoComplete(props, ref) {
167
168
  /** should sync both search input and value */
168
169
  setSearchText(nextSearch);
169
170
  setInsertText(nextSearch);
171
+ onSearchTextChange === null || onSearchTextChange === void 0 ? void 0 : onSearchTextChange(nextSearch);
170
172
  if (autoSelectMatchingOption(nextSearch))
171
173
  return;
172
174
  if (!nextSearch) {
@@ -231,10 +233,10 @@ const AutoComplete = forwardRef(function AutoComplete(props, ref) {
231
233
  // Multiple mode: show checkbox at prepend
232
234
  // Single mode: show checked icon at append when selected
233
235
  if (mode === 'multiple') {
234
- result.checkSite = 'prepend';
236
+ result.checkSite = 'prefix';
235
237
  }
236
238
  else {
237
- result.checkSite = 'append';
239
+ result.checkSite = 'suffix';
238
240
  }
239
241
  // Set shortcutText to "New" for created items (persists even after selection)
240
242
  if (created) {
@@ -267,14 +269,21 @@ const AutoComplete = forwardRef(function AutoComplete(props, ref) {
267
269
  const handleDropdownSelect = useCallback((option) => {
268
270
  const selectedValue = options.find((opt) => opt.id === option.id);
269
271
  if (selectedValue) {
270
- wrappedOnChange(selectedValue);
271
272
  // Close dropdown after selection in single mode
272
273
  if (mode === 'single') {
274
+ // Update searchText first to prevent showing old value
275
+ setSearchText(selectedValue.name);
276
+ setInsertText(selectedValue.name);
277
+ // Then update value and focus state
278
+ wrappedOnChange(selectedValue);
273
279
  toggleOpen(false);
274
280
  onFocus(false);
275
281
  }
282
+ else {
283
+ wrappedOnChange(selectedValue);
284
+ }
276
285
  }
277
- }, [mode, onFocus, options, toggleOpen, wrappedOnChange]);
286
+ }, [mode, onFocus, options, setSearchText, setInsertText, toggleOpen, wrappedOnChange]);
278
287
  // Active index for dropdown keyboard navigation
279
288
  const [activeIndex, setActiveIndex] = useState(null);
280
289
  const setListboxHasVisualFocus = useCallback(() => { }, []);
@@ -349,10 +358,13 @@ const AutoComplete = forwardRef(function AutoComplete(props, ref) {
349
358
  return false;
350
359
  if (isSingle) {
351
360
  if (!value) {
361
+ // Update searchText first to prevent showing old value
362
+ setSearchText(matchingOption.name);
363
+ setInsertText(matchingOption.name);
364
+ // Then update value and focus state
352
365
  wrappedOnChange(matchingOption);
353
366
  toggleOpen(false);
354
367
  onFocus(false);
355
- resetCreationInputs();
356
368
  return true;
357
369
  }
358
370
  return false;
@@ -371,6 +383,8 @@ const AutoComplete = forwardRef(function AutoComplete(props, ref) {
371
383
  onFocus,
372
384
  options,
373
385
  resetCreationInputs,
386
+ setSearchText,
387
+ setInsertText,
374
388
  toggleOpen,
375
389
  value,
376
390
  wrappedOnChange,
@@ -400,7 +414,7 @@ const AutoComplete = forwardRef(function AutoComplete(props, ref) {
400
414
  : createActionTextTemplate.replace('{text}', insertText))
401
415
  : undefined, activeIndex: activeIndex, disabled: isInputDisabled, emptyText: emptyText, followText: searchText, inputPosition: inputPosition, isMatchInputValue: true, listboxId: menuId, loadingText: loadingText, maxHeight: menuMaxHeight, mode: mode, onActionCustom: shouldShowCreateAction
402
416
  ? handleActionCustom
403
- : undefined, onItemHover: setActiveIndex, onSelect: handleDropdownSelect, onVisibilityChange: handleVisibilityChange, open: open, options: dropdownOptionsForRender, placement: "bottom", sameWidth: true, showDropdownActions: shouldShowCreateAction, showActionShowTopBar: shouldShowCreateAction, status: dropdownStatus, type: "default", value: dropdownValue, children: jsx(SelectTrigger, { ref: composedRef, active: open, className: className, clearable: true, disabled: isInputDisabled, fullWidth: fullWidth, inputRef: inputRef, mode: mode, onTagClose: wrappedOnChange, onClear: onClear, placeholder: getPlaceholder(), prefix: prefix, readOnly: false, required: required, type: error ? 'error' : 'default', inputProps: {
417
+ : undefined, onItemHover: setActiveIndex, onSelect: handleDropdownSelect, onVisibilityChange: handleVisibilityChange, open: open, options: dropdownOptionsForRender, placement: "bottom", sameWidth: true, showDropdownActions: shouldShowCreateAction, showActionShowTopBar: shouldShowCreateAction, status: dropdownStatus, type: "default", value: dropdownValue, zIndex: dropdownZIndex, onReachBottom: onReachBottom, onLeaveBottom: onLeaveBottom, children: jsx(SelectTrigger, { ref: composedRef, active: open, className: className, clearable: true, isForceClearable: true, disabled: isInputDisabled, fullWidth: fullWidth, inputRef: inputRef, mode: mode, onTagClose: wrappedOnChange, onClear: onClear, placeholder: getPlaceholder(), prefix: prefix, readOnly: false, required: required, type: error ? 'error' : 'default', inputProps: {
404
418
  ...resolvedInputProps,
405
419
  onClick: (e) => {
406
420
  var _a;
@@ -1,9 +1,10 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import { forwardRef, isValidElement, cloneElement } from 'react';
3
- import { SlashIcon } from '@mezzanine-ui/icons';
4
3
  import { breadcrumbClasses } from '@mezzanine-ui/core/breadcrumb';
5
- import BreadcrumbItem from './BreadcrumbItem.js';
4
+ import { SlashIcon } from '@mezzanine-ui/icons';
6
5
  import { flattenChildren } from '../utils/flatten-children.js';
6
+ import BreadcrumbItem from './BreadcrumbItem.js';
7
+ import { BreadcrumbOverflowMenu } from './BreadcrumbOverflowMenu.js';
7
8
  import Icon from '../Icon/Icon.js';
8
9
  import cx from 'clsx';
9
10
 
@@ -13,32 +14,26 @@ const renderItemWithProps = (item, appendProps) => {
13
14
  }
14
15
  return jsx(BreadcrumbItem, { ...item, ...appendProps });
15
16
  };
17
+ const convertToPropsWithId = (item) => {
18
+ if (isValidElement(item)) {
19
+ return { id: item.props.id || item.props.name, ...item.props };
20
+ }
21
+ return { id: item.id || item.name, ...item };
22
+ };
16
23
  const renderItems = (items, condensed) => {
17
24
  if (!items) {
18
25
  return null;
19
26
  }
20
27
  const lastIndex = items.length - 1;
28
+ const hasOverflowDropdownIcon = !condensed || items.length > 2;
29
+ const collapsedProps = hasOverflowDropdownIcon
30
+ ? condensed
31
+ ? items.map((v) => convertToPropsWithId(v)).slice(0, lastIndex - 1)
32
+ : items.map((v) => convertToPropsWithId(v)).slice(2, lastIndex - 1)
33
+ : [];
21
34
  return (jsxs(Fragment, { children: [!condensed &&
22
35
  lastIndex >= 0 &&
23
- renderItemWithProps(items[0], { current: lastIndex === 0 }), !condensed && lastIndex >= 1 && (jsxs(Fragment, { children: [jsx(Icon, { icon: SlashIcon, size: 14 }), renderItemWithProps(items[1], { current: lastIndex === 1 })] })), !condensed && items.length <= 4 && (jsxs(Fragment, { children: [lastIndex >= 2 && (jsxs(Fragment, { children: [jsx(Icon, { icon: SlashIcon, size: 14 }), renderItemWithProps(items[2], { current: lastIndex === 2 })] })), lastIndex === 3 && (jsxs(Fragment, { children: [jsx(Icon, { icon: SlashIcon, size: 14 }), renderItemWithProps(items[3], { current: true })] }))] })), (items.length > 4 || condensed) && (jsxs(Fragment, { children: [!condensed && jsx(Icon, { icon: SlashIcon, size: 14 }), (!condensed || items.length > 2) && (jsxs(Fragment, { children: [jsx(BreadcrumbItem, { options: (condensed
24
- ? items.slice(0, lastIndex - 1)
25
- : items.slice(2, lastIndex - 1)).map((item) => {
26
- if (isValidElement(item)) {
27
- const { props } = item;
28
- return {
29
- label: props.label,
30
- href: props.href,
31
- target: props.target,
32
- id: props.id,
33
- };
34
- }
35
- return {
36
- label: item.label,
37
- href: item.href,
38
- target: item.target,
39
- id: item.id,
40
- };
41
- }) }), jsx(Icon, { icon: SlashIcon, size: 14 })] })), lastIndex - 1 >= 0 && (jsxs(Fragment, { children: [renderItemWithProps(items[lastIndex - 1]), jsx(Icon, { icon: SlashIcon, size: 14 })] })), renderItemWithProps(items[lastIndex], { current: true })] }))] }));
36
+ renderItemWithProps(items[0], { current: lastIndex === 0 }), !condensed && lastIndex >= 1 && (jsxs(Fragment, { children: [jsx(Icon, { icon: SlashIcon, size: 14 }), renderItemWithProps(items[1], { current: lastIndex === 1 })] })), !condensed && items.length <= 4 && (jsxs(Fragment, { children: [lastIndex >= 2 && (jsxs(Fragment, { children: [jsx(Icon, { icon: SlashIcon, size: 14 }), renderItemWithProps(items[2], { current: lastIndex === 2 })] })), lastIndex === 3 && (jsxs(Fragment, { children: [jsx(Icon, { icon: SlashIcon, size: 14 }), renderItemWithProps(items[3], { current: true })] }))] })), (items.length > 4 || condensed) && (jsxs(Fragment, { children: [!condensed && jsx(Icon, { icon: SlashIcon, size: 14 }), hasOverflowDropdownIcon && (jsxs(Fragment, { children: [jsx(BreadcrumbOverflowMenu, { collapsedProps: collapsedProps }), jsx(Icon, { icon: SlashIcon, size: 14 })] })), lastIndex - 1 >= 0 && (jsxs(Fragment, { children: [renderItemWithProps(items[lastIndex - 1]), jsx(Icon, { icon: SlashIcon, size: 14 })] })), renderItemWithProps(items[lastIndex], { current: true })] }))] }));
42
37
  };
43
38
  /**
44
39
  * The react component for `mezzanine` breadcrumb.
@@ -0,0 +1,11 @@
1
+ declare const BreadcrumbDropdown: import("react").ForwardRefExoticComponent<Omit<import("../Dropdown").DropdownProps, "children"> & {
2
+ className?: string;
3
+ current?: boolean;
4
+ href?: never;
5
+ id?: string;
6
+ name: string;
7
+ onClick?: () => void;
8
+ open?: boolean;
9
+ target?: never;
10
+ } & import("react").RefAttributes<HTMLSpanElement>>;
11
+ export default BreadcrumbDropdown;
@@ -0,0 +1,22 @@
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import { forwardRef, useState } from 'react';
3
+ import { ChevronDownIcon } from '@mezzanine-ui/icons';
4
+ import { breadcrumbItemClasses } from '@mezzanine-ui/core/breadcrumb';
5
+ import Typography from '../Typography/Typography.js';
6
+ import Dropdown from '../Dropdown/Dropdown.js';
7
+ import Rotate from '../Transition/Rotate.js';
8
+ import Icon from '../Icon/Icon.js';
9
+ import cx from 'clsx';
10
+
11
+ const BreadcrumbDropdown = forwardRef(function BreadcrumbDropdown(props, ref) {
12
+ const { className, current, name, onClick, open: openProp, options, ...rest } = props;
13
+ const [_open, setOpen] = useState(false);
14
+ const open = openProp !== null && openProp !== void 0 ? openProp : _open;
15
+ const handleClick = () => {
16
+ setOpen(!open);
17
+ onClick === null || onClick === void 0 ? void 0 : onClick();
18
+ };
19
+ return (jsx("span", { className: cx(breadcrumbItemClasses.host, className), ref: ref, children: jsx(Dropdown, { onClose: () => setOpen(false), onOpen: () => handleClick(), options: options, placement: "bottom-start", ...rest, children: jsxs("button", { className: cx(breadcrumbItemClasses.trigger, open && breadcrumbItemClasses.expanded, current && breadcrumbItemClasses.current), type: "button", children: [name && (jsx(Typography, { variant: current ? 'caption-highlight' : 'caption', children: name })), jsx(Rotate, { in: open, children: jsx(Icon, { className: breadcrumbItemClasses.icon, icon: ChevronDownIcon, size: 14 }) })] }) }) }));
20
+ });
21
+
22
+ export { BreadcrumbDropdown as default };
@@ -1,4 +1,3 @@
1
- declare const BreadcrumbItem: import("react").ForwardRefExoticComponent<Omit<Omit<import("..").ComponentPropsWithoutKeyAndRef<"button">, "expand" | "label" | "component" | "current" | "options" | "href" | "target"> & (import("./typings").BreadcrumbDropdownItemProps | import("./typings").BreadcrumbItemTextProps | import("./typings").BreadcrumbLinkItemProps), "component"> & {
2
- component?: import("./typings").BreadcrumbItemComponent | undefined;
3
- } & import("react").RefAttributes<HTMLElement>>;
1
+ import type { BreadcrumbItemProps } from './typings';
2
+ declare const BreadcrumbItem: import("react").ForwardRefExoticComponent<BreadcrumbItemProps & import("react").RefAttributes<HTMLSpanElement>>;
4
3
  export default BreadcrumbItem;
@@ -1,45 +1,27 @@
1
- import { jsxs, jsx } from 'react/jsx-runtime';
2
- import { forwardRef, useState } from 'react';
3
- import { ChevronDownIcon, DotHorizontalIcon } from '@mezzanine-ui/icons';
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { forwardRef } from 'react';
4
3
  import { breadcrumbItemClasses } from '@mezzanine-ui/core/breadcrumb';
5
4
  import Typography from '../Typography/Typography.js';
6
- import Rotate from '../Transition/Rotate.js';
7
- import Icon from '../Icon/Icon.js';
8
- import Menu from '../Menu/Menu.js';
9
- import MenuItem from '../Menu/MenuItem.js';
5
+ import BreadcrumbDropdown from './BreadcrumbDropdown.js';
10
6
  import cx from 'clsx';
11
7
 
12
8
  const BreadcrumbItem = forwardRef(function BreadcrumbItem(props, ref) {
13
- const { className, component, current, expand: expandProp, label, onClick, onTouchEnd, options, ...rest } = props;
14
- const [_expand, setExpand] = useState(false);
15
- const expand = expandProp !== null && expandProp !== void 0 ? expandProp : _expand;
16
- const Component = (() => {
9
+ if ('options' in props)
10
+ return jsx(BreadcrumbDropdown, { ...props });
11
+ const { className, component, current, href, name, onClick, rel, target, ...rest } = props;
12
+ const TriggerComponent = (() => {
17
13
  if (component)
18
14
  return component;
19
- if ('onClick' in props || 'options' in props) {
20
- return 'button';
21
- }
22
- if (!current && 'href' in props && typeof props.href === 'string') {
15
+ if ((!current && 'href' in props && typeof props.href === 'string') ||
16
+ 'onClick' in props) {
23
17
  return 'a';
24
18
  }
25
- return 'div';
19
+ return 'span';
26
20
  })();
27
- const handleClick = (e) => {
28
- setExpand(!expand);
29
- onClick === null || onClick === void 0 ? void 0 : onClick(e);
30
- };
31
- const handleTouchEnd = (e) => {
32
- setExpand(!expand);
33
- onTouchEnd === null || onTouchEnd === void 0 ? void 0 : onTouchEnd(e);
21
+ const handleClick = () => {
22
+ onClick === null || onClick === void 0 ? void 0 : onClick();
34
23
  };
35
- return (jsxs(Component, { ...rest, "aria-expanded": options ? expand : undefined, "aria-haspopup": options ? 'true' : undefined, className: cx(breadcrumbItemClasses.host, expand && breadcrumbItemClasses.expanded, current && breadcrumbItemClasses.current, className), onClick: Component === 'button' ? handleClick : undefined, onTouchEnd: Component === 'button' ? handleTouchEnd : undefined, ref: ref, children: [label && (jsx(Typography, { variant: current ? 'caption-highlight' : 'caption', children: label })), 'options' in props &&
36
- (label ? (
37
- /* normal dropdown icon item */
38
- jsx(Rotate, { in: expand, children: jsx(Icon, { className: breadcrumbItemClasses.icon, icon: ChevronDownIcon, size: 14 }) })) : (
39
- /* overflow dropdown icon item */
40
- jsx(Icon, { className: breadcrumbItemClasses.icon, icon: DotHorizontalIcon, size: 14 }))), options && expand && (jsx(Menu, { className: breadcrumbItemClasses.menu, children: options
41
- .filter((v) => v.label)
42
- .map((option) => (jsx(MenuItem, { children: option.label }, option.id || option.label))) }))] }));
24
+ return (jsx("span", { ...rest, className: cx(breadcrumbItemClasses.host, className), ref: ref, children: jsx(TriggerComponent, { className: cx(breadcrumbItemClasses.trigger, current && breadcrumbItemClasses.current), href: TriggerComponent === 'a' ? href : undefined, onClick: TriggerComponent === 'a' ? handleClick : undefined, rel: TriggerComponent === 'a' ? rel : undefined, target: TriggerComponent === 'a' ? target : undefined, children: name && (jsx(Typography, { variant: current ? 'caption-highlight' : 'caption', children: name })) }) }));
43
25
  });
44
26
 
45
27
  export { BreadcrumbItem as default };
@@ -0,0 +1,7 @@
1
+ import { HtmlHTMLAttributes } from 'react';
2
+ import { BreadcrumbItemProps } from './typings';
3
+ export declare const BreadcrumbOverflowMenu: (props: HtmlHTMLAttributes<HTMLButtonElement> & {
4
+ collapsedProps: (BreadcrumbItemProps & {
5
+ id: string;
6
+ })[];
7
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,77 @@
1
+ 'use client';
2
+ import { useState, useRef, useMemo, useCallback, createElement } from 'react';
3
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
4
+ import { TransitionGroup } from 'react-transition-group';
5
+ import { breadcrumbClasses } from '@mezzanine-ui/core/breadcrumb';
6
+ import { DotHorizontalIcon } from '@mezzanine-ui/icons';
7
+ import { MOTION_EASING, MOTION_DURATION } from '@mezzanine-ui/system/motion';
8
+ import { useDocumentEvents } from '../hooks/useDocumentEvents.js';
9
+ import BreadcrumbOverflowMenuItem from './BreadcrumbOverflowMenuItem.js';
10
+ import Icon from '../Icon/Icon.js';
11
+ import Popper from '../Popper/Popper.js';
12
+ import Translate from '../Transition/Translate.js';
13
+ import cx from 'clsx';
14
+
15
+ const BreadcrumbOverflowMenu = (props) => {
16
+ const { onClick, className, collapsedProps, ...rest } = props;
17
+ const [menuOpen, setMenuOpen] = useState(false);
18
+ const targetRef = useRef(null);
19
+ const popperRef = useRef(null);
20
+ const translateProps = useMemo(() => ({
21
+ duration: {
22
+ enter: MOTION_DURATION.moderate,
23
+ exit: MOTION_DURATION.moderate,
24
+ },
25
+ easing: {
26
+ enter: MOTION_EASING.standard,
27
+ exit: MOTION_EASING.standard,
28
+ },
29
+ }), []);
30
+ useDocumentEvents(() => {
31
+ if (!menuOpen) {
32
+ return;
33
+ }
34
+ const handleClickAway = (event) => {
35
+ const target = event.target;
36
+ const anchor = targetRef.current;
37
+ const popper = popperRef.current;
38
+ if (!target)
39
+ return;
40
+ if (anchor &&
41
+ popper &&
42
+ !anchor.contains(target) &&
43
+ !popper.contains(target)) {
44
+ setMenuOpen(false);
45
+ }
46
+ };
47
+ return {
48
+ click: handleClickAway,
49
+ touchend: handleClickAway,
50
+ };
51
+ }, [menuOpen]);
52
+ const zIndexMiddleware = useMemo(() => {
53
+ const zIndexValue = 1;
54
+ return {
55
+ name: 'zIndex',
56
+ fn: ({ elements }) => {
57
+ const zIndexNum = zIndexValue
58
+ ;
59
+ Object.assign(elements.floating.style, {
60
+ zIndex: zIndexNum,
61
+ });
62
+ return {};
63
+ },
64
+ };
65
+ }, []);
66
+ const buttonOnClick = useCallback((e) => {
67
+ setMenuOpen(!menuOpen);
68
+ onClick === null || onClick === void 0 ? void 0 : onClick(e);
69
+ }, [menuOpen, onClick]);
70
+ return (jsxs(Fragment, { children: [jsx("button", { "aria-label": 'more options', type: "button", ...rest, ref: targetRef, className: cx(breadcrumbClasses.iconButton, className), onClick: buttonOnClick, children: jsx(Icon, { icon: DotHorizontalIcon, size: 14 }) }), jsx(Popper, { anchor: targetRef.current, disablePortal: true, open: menuOpen, options: {
71
+ middleware: [zIndexMiddleware],
72
+ placement: 'bottom-start',
73
+ }, ref: popperRef, children: jsx(TransitionGroup, { component: null, children: menuOpen && (createElement(Translate, { ...translateProps, from: 'bottom', in: true, key: "popper-list" },
74
+ jsx("span", { className: breadcrumbClasses.menu, children: jsx("span", { className: breadcrumbClasses.menuContent, children: collapsedProps.map((v) => (jsx(BreadcrumbOverflowMenuItem, { ...v }, v.id))) }) }))) }) })] }));
75
+ };
76
+
77
+ export { BreadcrumbOverflowMenu };
@@ -0,0 +1,11 @@
1
+ declare const BreadcrumbOverflowMenuDropdown: import("react").ForwardRefExoticComponent<Omit<import("../Dropdown").DropdownProps, "children"> & {
2
+ className?: string;
3
+ current?: boolean;
4
+ href?: never;
5
+ id?: string;
6
+ name: string;
7
+ onClick?: () => void;
8
+ open?: boolean;
9
+ target?: never;
10
+ } & import("react").RefAttributes<HTMLSpanElement>>;
11
+ export default BreadcrumbOverflowMenuDropdown;
@@ -0,0 +1,21 @@
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import { forwardRef, useState } from 'react';
3
+ import { breadcrumbOverflowMenuItemClasses } from '@mezzanine-ui/core/breadcrumb';
4
+ import { ChevronRightIcon } from '@mezzanine-ui/icons';
5
+ import Typography from '../Typography/Typography.js';
6
+ import Dropdown from '../Dropdown/Dropdown.js';
7
+ import Icon from '../Icon/Icon.js';
8
+ import cx from 'clsx';
9
+
10
+ const BreadcrumbOverflowMenuDropdown = forwardRef(function BreadcrumbOverflowMenuDropdown(props, ref) {
11
+ const { className, name, onClick, open: openProp, options, ...rest } = props;
12
+ const [_open, setOpen] = useState(false);
13
+ const open = openProp !== null && openProp !== void 0 ? openProp : _open;
14
+ const handleClick = () => {
15
+ setOpen(!open);
16
+ onClick === null || onClick === void 0 ? void 0 : onClick();
17
+ };
18
+ return (jsx("span", { className: cx(breadcrumbOverflowMenuItemClasses.host, open && breadcrumbOverflowMenuItemClasses.expanded, className), ref: ref, children: jsx(Dropdown, { onClose: () => setOpen(false), onOpen: () => handleClick(), options: options, placement: "right-start", ...rest, children: jsxs("button", { className: cx(breadcrumbOverflowMenuItemClasses.trigger), type: "button", children: [jsx(Typography, { variant: 'label-primary', children: name }), jsx(Icon, { className: breadcrumbOverflowMenuItemClasses.icon, icon: ChevronRightIcon, size: 16 })] }) }) }));
19
+ });
20
+
21
+ export { BreadcrumbOverflowMenuDropdown as default };
@@ -0,0 +1,3 @@
1
+ import type { BreadcrumbItemProps } from './typings';
2
+ declare const BreadcrumbOverflowMenuItem: import("react").ForwardRefExoticComponent<BreadcrumbItemProps & import("react").RefAttributes<HTMLSpanElement>>;
3
+ export default BreadcrumbOverflowMenuItem;
@@ -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
+ };
@@ -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';