@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
package/Select/Select.js CHANGED
@@ -1,41 +1,34 @@
1
1
  'use client';
2
- import { jsx, jsxs } from 'react/jsx-runtime';
3
- import { forwardRef, useContext, useState, useRef, useCallback, useMemo } from 'react';
2
+ import { jsx } from 'react/jsx-runtime';
4
3
  import { selectClasses } from '@mezzanine-ui/core/select';
5
4
  import isArray from 'lodash/isArray';
5
+ import React, { forwardRef, useContext, useState, useCallback, useRef, useMemo, Children } from 'react';
6
+ import { useSelectValueControl } from '../Form/useSelectValueControl.js';
6
7
  import { useComposeRefs } from '../hooks/useComposeRefs.js';
8
+ import Option from './Option.js';
7
9
  import { SelectControlContext } from './SelectControlContext.js';
8
- import { useSelectValueControl } from '../Form/useSelectValueControl.js';
9
- import { useClickAway } from '../hooks/useClickAway.js';
10
10
  import SelectTrigger from './SelectTrigger.js';
11
11
  import { FormControlContext } from '../Form/FormControlContext.js';
12
- import InputTriggerPopper from '../_internal/InputTriggerPopper/InputTriggerPopper.js';
13
- import Menu from '../Menu/Menu.js';
12
+ import Dropdown from '../Dropdown/Dropdown.js';
14
13
  import cx from 'clsx';
15
14
 
16
- const MENU_ID = 'mzn-select-menu-id';
17
15
  const Select = forwardRef(function Select(props, ref) {
18
- var _a, _b;
19
16
  const { disabled: disabledFromFormControl, fullWidth: fullWidthFromFormControl, required: requiredFromFormControl, severity, } = useContext(FormControlContext) || {};
20
- const { children, className, clearable = false, defaultValue, disabled = disabledFromFormControl || false, disablePortal = false, error = severity === 'error' || false, fullWidth = fullWidthFromFormControl || false, inputProps, inputRef, itemsInView = 4, menuMaxHeight, menuRole = 'listbox', menuSize, mode = 'single', onBlur, onChange: onChangeProp, onClear: onClearProp, onFocus, onMenuScroll, placeholder = '', popperOptions = {}, prefix, renderValue, required = requiredFromFormControl || false, size, suffixActionIcon, value: valueProp, } = props;
17
+ const { children, className, clearable = false, defaultValue, disabled = disabledFromFormControl || false, disablePortal = false, error = severity === 'error' || false, fullWidth = fullWidthFromFormControl || false, inputProps, inputRef, menuMaxHeight, mode = 'single', onBlur, onChange: onChangeProp, onClear: onClearProp, onFocus, onScroll, options: optionsProp, placeholder = '', prefix, readOnly = false, renderValue, required = requiredFromFormControl || false, size, suffixActionIcon, type = 'default', value: valueProp, } = props;
21
18
  const [open, toggleOpen] = useState(false);
22
- const onOpen = () => {
19
+ const onOpen = useCallback(() => {
20
+ // Prevent opening when readOnly is true
21
+ if (readOnly) {
22
+ return;
23
+ }
23
24
  onFocus === null || onFocus === void 0 ? void 0 : onFocus();
24
25
  toggleOpen(true);
25
- };
26
- const onClose = () => {
26
+ }, [onFocus, readOnly]);
27
+ const onClose = useCallback(() => {
27
28
  onBlur === null || onBlur === void 0 ? void 0 : onBlur();
28
29
  toggleOpen(false);
29
- };
30
- const onToggleOpen = () => {
31
- if (open) {
32
- onClose();
33
- }
34
- else {
35
- onOpen();
36
- }
37
- };
38
- const { onChange, onClear, value } = useSelectValueControl({
30
+ }, [onBlur]);
31
+ const { onChange, onClear: onClearFromControl, value } = useSelectValueControl({
39
32
  defaultValue,
40
33
  mode,
41
34
  onChange: onChangeProp,
@@ -43,9 +36,99 @@ const Select = forwardRef(function Select(props, ref) {
43
36
  onClose,
44
37
  value: valueProp,
45
38
  });
39
+ // Wrap onClear and delegate to control hook
40
+ const onClear = useCallback((e) => {
41
+ onClearFromControl(e);
42
+ }, [onClearFromControl]);
46
43
  const nodeRef = useRef(null);
47
- const controlRef = useRef(null);
48
- const composedRef = useComposeRefs([ref, controlRef]);
44
+ const composedRef = useComposeRefs([ref, nodeRef]);
45
+ // Helper function to recursively add checkbox to all options in tree structure
46
+ const addCheckboxToTreeOptions = useCallback((opts) => {
47
+ return opts.map((opt) => ({
48
+ ...opt,
49
+ showCheckbox: true,
50
+ checkSite: 'prefix',
51
+ children: opt.children
52
+ ? addCheckboxToTreeOptions(opt.children)
53
+ : undefined,
54
+ }));
55
+ }, []);
56
+ const getAllDescendantIds = useCallback((option) => {
57
+ const ids = new Set();
58
+ const collect = (opt) => {
59
+ ids.add(String(opt.id));
60
+ if (opt.children && opt.children.length > 0) {
61
+ opt.children.forEach(collect);
62
+ }
63
+ };
64
+ collect(option);
65
+ return Array.from(ids);
66
+ }, []);
67
+ const findOptionById = useCallback((id, opts) => {
68
+ for (const opt of opts) {
69
+ if (String(opt.id) === id) {
70
+ return opt;
71
+ }
72
+ if (opt.children) {
73
+ const found = findOptionById(id, opt.children);
74
+ if (found) {
75
+ return found;
76
+ }
77
+ }
78
+ }
79
+ return null;
80
+ }, []);
81
+ // Convert children (Option components) to DropdownOption format
82
+ // Or use provided options directly
83
+ const options = useMemo(() => {
84
+ // If options prop is provided, use it directly
85
+ if (optionsProp) {
86
+ // In tree mode (multiple mode with tree structure), ensure all options have checkbox
87
+ if (mode === 'multiple') {
88
+ const hasTreeStructure = optionsProp.some((opt) => opt.children && opt.children.length > 0);
89
+ if (hasTreeStructure) {
90
+ return addCheckboxToTreeOptions(optionsProp);
91
+ }
92
+ }
93
+ return optionsProp;
94
+ }
95
+ // Otherwise, convert children to options
96
+ if (!children)
97
+ return [];
98
+ return Children.toArray(children)
99
+ .filter((child) => {
100
+ var _a;
101
+ return (React.isValidElement(child) &&
102
+ (child.type === Option || ((_a = child.type) === null || _a === void 0 ? void 0 : _a.displayName) === 'Option'));
103
+ })
104
+ .map((child) => {
105
+ const props = child.props;
106
+ return {
107
+ id: props.value,
108
+ name: props.children,
109
+ showCheckbox: mode === 'multiple',
110
+ checkSite: mode === 'multiple' ? 'prefix' : 'suffix',
111
+ };
112
+ });
113
+ }, [children, mode, optionsProp, addCheckboxToTreeOptions]);
114
+ // Determine dropdown type based on options structure and mode
115
+ // Tree mode is only available in multiple mode
116
+ const dropdownType = useMemo(() => {
117
+ if (optionsProp && mode === 'multiple') {
118
+ // If options prop is provided and mode is multiple, check if it has tree structure
119
+ const hasTreeStructure = optionsProp.some((opt) => opt.children && opt.children.length > 0);
120
+ return hasTreeStructure ? 'tree' : type;
121
+ }
122
+ return type;
123
+ }, [optionsProp, type, mode]);
124
+ const dropdownValue = useMemo(() => {
125
+ if (!value)
126
+ return undefined;
127
+ if (Array.isArray(value)) {
128
+ return value.map((v) => String(v.id));
129
+ }
130
+ return String(value.id);
131
+ }, [value]);
49
132
  function getPlaceholder() {
50
133
  if (typeof renderValue === 'function') {
51
134
  return renderValue(value);
@@ -55,23 +138,15 @@ const Select = forwardRef(function Select(props, ref) {
55
138
  }
56
139
  return placeholder;
57
140
  }
58
- useClickAway(() => {
59
- if (!open)
60
- return;
61
- return () => {
62
- onClose();
63
- };
64
- }, nodeRef, [nodeRef, open, toggleOpen]);
65
- const onClickTextField = () => {
66
- if (!disabled) {
67
- onToggleOpen();
68
- }
69
- };
70
141
  /**
71
142
  * keyboard events for a11y
72
143
  * (@todo keyboard event map into option selection when menu is opened)
73
144
  */
74
145
  const onKeyDownTextField = (evt) => {
146
+ // Prevent keyboard events from opening when readOnly is true
147
+ if (readOnly) {
148
+ return;
149
+ }
75
150
  /** for a11y to open menu via keyboard */
76
151
  switch (evt.code) {
77
152
  case 'Enter':
@@ -94,23 +169,62 @@ const Select = forwardRef(function Select(props, ref) {
94
169
  }
95
170
  }
96
171
  };
97
- /** menu onScroll listener */
98
- const onMenuScrollCallback = useCallback(async (evt) => {
99
- evt.stopPropagation();
100
- if (onMenuScroll) {
101
- const target = evt.target;
102
- const maxScrollTop = target.scrollHeight - target.getBoundingClientRect().height;
103
- onMenuScroll({
104
- scrollTop: target.scrollTop,
105
- maxScrollTop,
106
- }, target);
172
+ const handleDropdownSelect = useCallback((option) => {
173
+ if (mode === 'multiple' && dropdownType === 'tree') {
174
+ const onChangeMultiple = onChange;
175
+ const currentValues = Array.isArray(value) ? value : [];
176
+ const allDescendantIds = getAllDescendantIds(option);
177
+ const allDescendantValues = allDescendantIds.map((id) => {
178
+ const foundOption = findOptionById(id, options);
179
+ return {
180
+ id,
181
+ name: (foundOption === null || foundOption === void 0 ? void 0 : foundOption.name) || id,
182
+ };
183
+ });
184
+ const selectedDescendantIds = allDescendantIds.filter((id) => currentValues.some((v) => String(v.id) === id));
185
+ const allSelected = selectedDescendantIds.length === allDescendantIds.length;
186
+ if (allSelected) {
187
+ // Deselect all descendants in a single update
188
+ const descendantIdSet = new Set(allDescendantIds.map((id) => String(id)));
189
+ const nextValues = currentValues.filter((v) => !descendantIdSet.has(String(v.id)));
190
+ onChangeMultiple(nextValues);
191
+ }
192
+ else {
193
+ // Select all descendants that are not yet selected in a single update
194
+ const existingIdSet = new Set(currentValues.map((v) => String(v.id)));
195
+ const valuesToAdd = allDescendantValues.filter((descValue) => !existingIdSet.has(String(descValue.id)));
196
+ const nextValues = [...currentValues, ...valuesToAdd];
197
+ onChangeMultiple(nextValues);
198
+ }
199
+ }
200
+ else {
201
+ // Normal selection logic for non-tree mode
202
+ const selectValue = {
203
+ id: String(option.id),
204
+ name: String(option.name),
205
+ };
206
+ if (mode === 'multiple') {
207
+ onChange(selectValue);
208
+ }
209
+ else {
210
+ onChange(selectValue);
211
+ onClose();
212
+ }
213
+ }
214
+ }, [mode, onChange, onClose, value, dropdownType, getAllDescendantIds, findOptionById, options]);
215
+ const handleVisibilityChange = useCallback((isOpen) => {
216
+ if (isOpen && readOnly) {
217
+ return;
218
+ }
219
+ if (isOpen) {
220
+ onOpen();
221
+ }
222
+ else {
223
+ onClose();
107
224
  }
108
- }, [onMenuScroll]);
225
+ }, [onOpen, onClose, readOnly]);
109
226
  const resolvedInputProps = {
110
227
  ...inputProps,
111
- 'aria-controls': MENU_ID,
112
- 'aria-expanded': open,
113
- 'aria-owns': MENU_ID,
114
228
  placeholder: getPlaceholder(),
115
229
  role: 'combobox',
116
230
  };
@@ -118,7 +232,7 @@ const Select = forwardRef(function Select(props, ref) {
118
232
  onChange,
119
233
  value,
120
234
  }), [onChange, value]);
121
- return (jsx(SelectControlContext.Provider, { value: context, children: jsxs("div", { ref: nodeRef, className: cx(selectClasses.host, fullWidth && selectClasses.hostFullWidth), children: [jsx(SelectTrigger, { ref: composedRef, active: open, className: className, clearable: clearable, disabled: disabled, error: error, fullWidth: fullWidth, inputRef: inputRef, mode: mode, onTagClose: onChange, onClear: onClear, onClick: onClickTextField, onKeyDown: onKeyDownTextField, prefix: prefix, readOnly: true, renderValue: renderValue, required: required, inputProps: resolvedInputProps, size: size, suffixActionIcon: suffixActionIcon, value: value }), jsx(InputTriggerPopper, { anchor: controlRef, className: selectClasses.popper, disablePortal: disablePortal, open: open, options: popperOptions, sameWidth: true, children: jsx(Menu, { id: MENU_ID, "aria-activedescendant": Array.isArray(value) ? ((_b = (_a = value === null || value === void 0 ? void 0 : value[0]) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : '') : value === null || value === void 0 ? void 0 : value.id, itemsInView: itemsInView, maxHeight: menuMaxHeight, onScroll: onMenuScrollCallback, role: menuRole, size: menuSize, style: { border: 0 }, children: children }) })] }) }));
235
+ return (jsx(SelectControlContext.Provider, { value: context, children: jsx("div", { ref: nodeRef, className: cx(selectClasses.host, fullWidth && selectClasses.hostFullWidth), children: jsx(Dropdown, { disabled: readOnly || disabled, disablePortal: disablePortal, maxHeight: menuMaxHeight, mode: mode, onScroll: onScroll, onSelect: handleDropdownSelect, onVisibilityChange: handleVisibilityChange, open: readOnly ? false : open, options: options, sameWidth: true, type: dropdownType, value: dropdownValue, children: jsx(SelectTrigger, { ref: composedRef, active: !readOnly && open, className: className, clearable: clearable, disabled: disabled, error: error, fullWidth: fullWidth, inputRef: inputRef, mode: mode, onTagClose: onChange, onClear: onClear, onKeyDown: onKeyDownTextField, prefix: prefix, readOnly: readOnly, ...(mode === 'single' && renderValue ? { renderValue } : {}), required: required, inputProps: resolvedInputProps, size: size, suffixActionIcon: suffixActionIcon, value: value === null ? undefined : value }) }) }) }));
122
236
  });
123
237
 
124
238
  export { Select as default };
@@ -11,7 +11,7 @@ import cx from 'clsx';
11
11
  const isMultipleSelection = (props) => props.mode === 'multiple';
12
12
  function SelectTriggerComponent(props) {
13
13
  var _a, _b, _c;
14
- const { active, className, disabled, forceHideSuffixActionIcon, inputProps, innerRef, inputRef, mode = 'single', onTagClose, overflowStrategy = 'counter', placeholder, readOnly, required, searchText, size = 'main', showTextInputAfterTags = false, suffixAction, suffixActionIcon: suffixActionIconProp, type = 'default', onClick, ...restTextFieldProps } = props;
14
+ const { active, className, disabled, forceHideSuffixActionIcon, inputProps, innerRef, inputRef, isForceClearable = false, mode = 'single', onTagClose, overflowStrategy = 'counter', placeholder, readOnly, required, searchText, size = 'main', showTextInputAfterTags = false, suffixAction, suffixActionIcon: suffixActionIconProp, type = 'default', onClick, ...restTextFieldProps } = props;
15
15
  /** Render value to string for single selection trigger input */
16
16
  const renderValue = () => {
17
17
  var _a, _b;
@@ -46,9 +46,10 @@ function SelectTriggerComponent(props) {
46
46
  return (jsxs(TextField, { ref: innerRef, ...interactiveProps, ...restTextFieldProps, onClick: onClick, active: active, className: cx(selectClasses.trigger, selectClasses.triggerMode(mode), selectClasses.triggerSelected(Array.isArray(props.value) ? (_a = props.value) === null || _a === void 0 ? void 0 : _a.length : props.value), {
47
47
  [selectClasses.triggerReadOnly]: readOnly,
48
48
  [selectClasses.triggerDisabled]: disabled,
49
- }, className), error: type === 'error', size: size, suffix: forceHideSuffixActionIcon ? undefined : suffixActionIcon, clearable: mode === 'multiple' &&
50
- Array.isArray(props.value) &&
51
- !!props.value.length, children: [jsx("input", { ...inputProps, ref: inputRef, "aria-autocomplete": "list", "aria-haspopup": "listbox", autoComplete: "off", className: cx(selectClasses.triggerInput, inputProps === null || inputProps === void 0 ? void 0 : inputProps.className), disabled: disabled, placeholder: placeholder, readOnly: (_b = inputProps === null || inputProps === void 0 ? void 0 : inputProps.readOnly) !== null && _b !== void 0 ? _b : true, required: required, type: "text", value: renderValue() }), isMultipleSelection(props) && ((_c = props.value) === null || _c === void 0 ? void 0 : _c.length) && (jsx(SelectTriggerTags, { disabled: disabled, overflowStrategy: overflowStrategy, inputProps: inputProps, inputRef: inputRef, onTagClose: onTagClose, readOnly: readOnly, required: required, searchText: searchText, size: size, showTextInputAfterTags: showTextInputAfterTags, value: props.value }))] }));
49
+ }, className), error: type === 'error', size: size, suffix: forceHideSuffixActionIcon ? undefined : suffixActionIcon, clearable: isForceClearable ||
50
+ (mode === 'multiple' &&
51
+ Array.isArray(props.value) &&
52
+ !!props.value.length), children: [jsx("input", { ...inputProps, ref: inputRef, "aria-autocomplete": "list", "aria-haspopup": "listbox", autoComplete: "off", className: cx(selectClasses.triggerInput, inputProps === null || inputProps === void 0 ? void 0 : inputProps.className), disabled: disabled, placeholder: placeholder, readOnly: (_b = inputProps === null || inputProps === void 0 ? void 0 : inputProps.readOnly) !== null && _b !== void 0 ? _b : true, required: required, type: "text", value: renderValue() }), isMultipleSelection(props) && ((_c = props.value) === null || _c === void 0 ? void 0 : _c.length) && (jsx(SelectTriggerTags, { disabled: disabled, overflowStrategy: overflowStrategy, inputProps: inputProps, inputRef: inputRef, onTagClose: onTagClose, readOnly: readOnly, required: required, searchText: searchText, size: size, showTextInputAfterTags: showTextInputAfterTags, value: props.value }))] }));
52
53
  }
53
54
  const SelectTrigger = forwardRef((props, ref) => {
54
55
  if (props.mode === 'multiple') {
package/Select/index.d.ts CHANGED
@@ -1,14 +1,13 @@
1
- export * from './typings';
1
+ export { default as OptionGroup } from '../Menu/MenuItemGroup';
2
+ export type { MenuItemGroupProps as OptionGroupProps } from '../Menu/MenuItemGroup';
3
+ export { default as Option } from './Option';
4
+ export type { OptionProps } from './Option';
5
+ export { default } from './Select';
6
+ export type { SelectProps } from './Select';
2
7
  export { SelectControlContext } from './SelectControlContext';
3
8
  export { default as SelectTrigger } from './SelectTrigger';
4
- export type { SelectTriggerProps, SelectTriggerInputProps, } from './SelectTrigger';
5
9
  export { default as SelectTriggerTags } from './SelectTriggerTags';
6
10
  export type { SelectTriggerTagsProps } from './SelectTriggerTags';
7
- export type { SelectProps } from './Select';
8
- export { default } from './Select';
9
- export { default as Option } from './Option';
10
- export type { OptionProps } from './Option';
11
- export { default as OptionGroup } from '../Menu/MenuItemGroup';
12
- export type { MenuItemGroupProps as OptionGroupProps } from '../Menu/MenuItemGroup';
13
- export type { TreeSelectProps } from './TreeSelect';
14
11
  export { default as TreeSelect } from './TreeSelect';
12
+ export type { TreeSelectProps } from './TreeSelect';
13
+ export * from './typings';
package/Select/index.js CHANGED
@@ -1,7 +1,7 @@
1
+ export { default as OptionGroup } from '../Menu/MenuItemGroup.js';
2
+ export { default as Option } from './Option.js';
3
+ export { default } from './Select.js';
1
4
  export { SelectControlContext } from './SelectControlContext.js';
2
5
  export { default as SelectTrigger } from './SelectTrigger.js';
3
6
  export { default as SelectTriggerTags } from './SelectTriggerTags.js';
4
- export { default } from './Select.js';
5
- export { default as Option } from './Option.js';
6
- export { default as OptionGroup } from '../Menu/MenuItemGroup.js';
7
7
  export { default as TreeSelect } from './TreeSelect.js';
@@ -1,6 +1,6 @@
1
+ import { SelectTriggerType } from '@mezzanine-ui/core/select';
1
2
  import { ReactElement, Ref } from 'react';
2
3
  import Icon, { IconProps } from '../Icon';
3
- import { SelectTriggerType } from '@mezzanine-ui/core/select';
4
4
  import { TextFieldProps } from '../TextField';
5
5
  import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
6
6
  export interface SelectValue<T = string> {
@@ -48,6 +48,11 @@ export interface SelectTriggerBaseProps extends Omit<TextFieldProps, 'active' |
48
48
  onTagClose?: (target: SelectValue) => void;
49
49
  /** Placeholder text when not selected */
50
50
  placeholder?: string;
51
+ /**
52
+ * Whether to force show clearable icon regardless of value state.
53
+ * @default false
54
+ */
55
+ isForceClearable?: boolean;
51
56
  /**
52
57
  * Whether the input is readonly.
53
58
  * @default false
@@ -36,7 +36,7 @@ const Selection = forwardRef(function Selection(props, ref) {
36
36
  [selectionClasses.readonly]: readonly,
37
37
  }, className), ...(disabled && { 'aria-disabled': true }), ...(onClick && { onClick }), children: [jsxs("div", { className: selectionClasses.container, children: [haveImage
38
38
  ? jsx("img", { src: image, alt: text, className: selectionClasses.selectionImage, style: { objectFit: imageObjectFit } })
39
- : jsx(Icon, { "aria-hidden": "true", className: selectionClasses.icon, color: "neutral-solid", icon: customIcon || FileIcon, size: SELECTION_ICON_SIZE }), jsxs("div", { className: selectionClasses.content, children: [jsx(Typography, { id: textId, color: "text-neutral-solid", variant: "body-highlight", className: selectionClasses.text, children: text }), supportingText && (jsx(Typography, { id: supportingTextId, color: "text-neutral", variant: "caption", className: selectionClasses.supportingText, children: supportingText }))] })] }), !readonly && (jsx("input", { ref: inputRefProp, type: selector, name: name, id: inputId, className: selectionClasses.input, disabled: disabled, ...(checkedProp !== undefined
39
+ : jsx(Icon, { "aria-hidden": "true", className: selectionClasses.icon, color: "neutral-solid", icon: customIcon || FileIcon, size: SELECTION_ICON_SIZE }), jsxs("div", { className: selectionClasses.content, children: [jsx(Typography, { className: selectionClasses.text, color: "text-neutral-solid", display: "block", ellipsis: true, id: textId, variant: "body-highlight", children: text }), supportingText && (jsx(Typography, { className: selectionClasses.supportingText, color: "text-neutral", display: "block", ellipsis: true, id: supportingTextId, variant: "caption", children: supportingText }))] })] }), !readonly && (jsx("input", { ref: inputRefProp, type: selector, name: name, id: inputId, className: selectionClasses.input, disabled: disabled, ...(checkedProp !== undefined
40
40
  ? { checked: checkedProp }
41
41
  : { defaultChecked }), value: value, onChange: onInputChange, ...(isRadioOrCheckbox && checkedProp !== undefined
42
42
  ? { 'aria-checked': checkedProp }
@@ -0,0 +1,28 @@
1
+ import { ComponentProps, ReactElement } from 'react';
2
+ import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
3
+ import Selection, { SelectionProps } from './Selection';
4
+ export interface SelectionGroupBaseProps extends Omit<NativeElementPropsWithoutKeyAndRef<'div'>, 'children'> {
5
+ /**
6
+ * The class name of the selection group.
7
+ */
8
+ className?: string;
9
+ }
10
+ export interface SelectionGroupProps extends SelectionGroupBaseProps {
11
+ /**
12
+ * The selections in the group.
13
+ * Only Selection components are allowed.
14
+ * When provided, will take priority over selections prop.
15
+ */
16
+ children?: ReactElement<ComponentProps<typeof Selection>> | ReactElement<ComponentProps<typeof Selection>>[];
17
+ /**
18
+ * The selections array.
19
+ * When provided, Selection components will be automatically rendered.
20
+ * Will be ignored if children is provided.
21
+ */
22
+ selections?: SelectionProps[];
23
+ }
24
+ /**
25
+ * The react component for `mezzanine` selection group.
26
+ */
27
+ declare const SelectionGroup: import("react").ForwardRefExoticComponent<SelectionGroupProps & import("react").RefAttributes<HTMLDivElement>>;
28
+ export default SelectionGroup;
package/Table/Table.d.ts CHANGED
@@ -1,123 +1,5 @@
1
- import { TableSize, type HighlightMode, type TableActions, type TableActionsWithMinWidth, type TableColumn, type TableColumnWithMinWidth, type TableDataSource, type TableDraggable, type TableExpandable, type TableRowSelection, type TableScroll } from '@mezzanine-ui/core/table';
2
- import type { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
3
- import type { TableTransitionState } from './hooks/useTableDataSource';
4
- import { TablePaginationProps } from './components/TablePagination';
5
- import type { EmptyProps } from '../Empty';
6
- export interface TableBaseProps<T extends TableDataSource = TableDataSource> extends Omit<NativeElementPropsWithoutKeyAndRef<'table'>, 'children' | 'draggable' | 'summary' | 'onChange'> {
7
- /** Data source */
8
- dataSource: T[];
9
- /** Props for Empty component when no data */
10
- emptyProps?: EmptyProps & {
11
- height?: number | string;
12
- };
13
- /** Expandable row configuration */
14
- expandable?: TableExpandable<T>;
15
- /**
16
- * Whether the table should stretch to fill its container width.
17
- * When true, the table will always be 100% width of its container.
18
- * Note: If the sum of all column widths is less than the table width,
19
- * columns will be proportionally stretched to fill the remaining space.
20
- * @default false
21
- */
22
- fullWidth?: boolean;
23
- /** Highlight mode for hover effects
24
- * @default 'row'
25
- */
26
- highlight?: HighlightMode;
27
- /** Loading state */
28
- loading?: boolean;
29
- /** Number of rows to display when loading */
30
- loadingRowsCount?: number;
31
- /** Minimum height of the table */
32
- minHeight?: number | string;
33
- /**
34
- * Whether the table is nested inside an expanded row content area
35
- */
36
- nested?: boolean;
37
- /** Pagination configuration */
38
- pagination?: TablePaginationProps;
39
- /**
40
- * Row height preset token.
41
- */
42
- rowHeightPreset?: 'base' | 'condensed' | 'detailed' | 'roomy';
43
- /** Row selection configuration */
44
- rowSelection?: TableRowSelection<T>;
45
- /** Row indexes where a separator border should be displayed */
46
- separatorAtRowIndexes?: number[];
47
- /** Show header row */
48
- showHeader?: boolean;
49
- /** Custom size variant
50
- * @default 'main'
51
- */
52
- size?: TableSize;
53
- /** Whether to enable sticky header
54
- * @default true
55
- */
56
- sticky?: boolean;
57
- /** Transition state for row add/remove animations (from useTableDataSource hook) */
58
- transitionState?: TableTransitionState;
59
- /** Enable zebra striping for alternating row backgrounds */
60
- zebraStriping?: boolean;
61
- }
62
- /**
63
- * Props when resizable is enabled.
64
- * Requires minWidth on all columns.
65
- */
66
- export interface TableResizableProps<T extends TableDataSource = TableDataSource> extends TableBaseProps<T> {
67
- /** Actions column configuration - minWidth required when resizable */
68
- actions?: TableActionsWithMinWidth<T>;
69
- /** Column configuration - minWidth required for each column when resizable */
70
- columns: TableColumnWithMinWidth<T>[];
71
- /**
72
- * Whether columns are resizable by user interaction
73
- */
74
- resizable: true;
75
- }
76
- /**
77
- * Props when resizable is disabled or not specified.
78
- */
79
- export interface TableNonResizableProps<T extends TableDataSource = TableDataSource> extends TableBaseProps<T> {
80
- /** Actions column configuration */
81
- actions?: TableActions<T>;
82
- /** Column configuration */
83
- columns: TableColumn<T>[];
84
- /**
85
- * Whether columns are resizable by user interaction
86
- * @default false
87
- */
88
- resizable?: false;
89
- }
90
- /**
91
- * Props when virtualized scrolling is enabled.
92
- * Draggable is not allowed in this mode.
93
- */
94
- export type TableVirtualizedProps<T extends TableDataSource = TableDataSource> = (TableResizableProps<T> | TableNonResizableProps<T>) & {
95
- /** Draggable row configuration - not available when virtualized is enabled */
96
- draggable?: never;
97
- /** Scroll configuration with virtualized enabled */
98
- scroll: TableScroll & {
99
- virtualized: true;
100
- y: number | string;
101
- };
102
- };
103
- /**
104
- * Props when virtualized scrolling is disabled or not specified.
105
- * Draggable is allowed in this mode.
106
- */
107
- export type TableNonVirtualizedProps<T extends TableDataSource = TableDataSource> = (TableResizableProps<T> | TableNonResizableProps<T>) & {
108
- /** Draggable row configuration */
109
- draggable?: TableDraggable<T>;
110
- /** Scroll configuration for scrolling (virtualized defaults to false) */
111
- scroll?: TableScroll & {
112
- virtualized?: false;
113
- };
114
- };
115
- /**
116
- * TableProps - discriminated union to ensure draggable and virtualized
117
- * scrolling are mutually exclusive at the type level, and resizable
118
- * requires minWidth on all columns.
119
- */
120
- export type TableProps<T extends TableDataSource = TableDataSource> = TableVirtualizedProps<T> | TableNonVirtualizedProps<T>;
1
+ import { type TableDataSource } from '@mezzanine-ui/core/table';
2
+ import type { TableProps } from './typings';
121
3
  /**
122
4
  * Table is a high-performance data table component with support for
123
5
  * virtual scrolling, column resizing, fixed columns, row selection,