@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.
- package/AutoComplete/AutoComplete.d.ts +23 -0
- package/AutoComplete/AutoComplete.js +39 -9
- package/Breadcrumb/Breadcrumb.js +16 -21
- package/Breadcrumb/BreadcrumbDropdown.d.ts +11 -0
- package/Breadcrumb/BreadcrumbDropdown.js +22 -0
- package/Breadcrumb/BreadcrumbItem.d.ts +2 -3
- package/Breadcrumb/BreadcrumbItem.js +13 -31
- package/Breadcrumb/BreadcrumbOverflowMenu.d.ts +7 -0
- package/Breadcrumb/BreadcrumbOverflowMenu.js +77 -0
- package/Breadcrumb/BreadcrumbOverflowMenuDropdown.d.ts +11 -0
- package/Breadcrumb/BreadcrumbOverflowMenuDropdown.js +21 -0
- package/Breadcrumb/BreadcrumbOverflowMenuItem.d.ts +3 -0
- package/Breadcrumb/BreadcrumbOverflowMenuItem.js +27 -0
- package/Breadcrumb/typings.d.ts +21 -39
- package/Calendar/Calendar.js +2 -6
- package/Calendar/CalendarCell.d.ts +22 -0
- package/Calendar/CalendarCell.js +6 -2
- package/Calendar/CalendarControls.js +1 -1
- package/Calendar/CalendarDayOfWeek.js +3 -2
- package/Calendar/CalendarDays.js +5 -1
- package/Calendar/CalendarHalfYears.js +13 -7
- package/Calendar/CalendarMonths.js +13 -6
- package/Calendar/CalendarQuarters.js +13 -7
- package/Calendar/CalendarWeeks.js +87 -34
- package/Calendar/CalendarYears.js +13 -12
- package/Calendar/useCalendarControlModifiers.d.ts +1 -1
- package/Calendar/useCalendarControlModifiers.js +12 -12
- package/Calendar/useCalendarControls.d.ts +4 -4
- package/Calendar/useCalendarControls.js +33 -19
- package/Calendar/useRangeCalendarControls.d.ts +8 -8
- package/Calendar/useRangeCalendarControls.js +42 -31
- package/Checkbox/index.d.ts +4 -5
- package/Checkbox/index.js +1 -5
- package/ContentHeader/ContentHeader.d.ts +160 -0
- package/ContentHeader/ContentHeader.js +54 -0
- package/ContentHeader/index.d.ts +2 -0
- package/ContentHeader/index.js +1 -0
- package/ContentHeader/utils.d.ts +23 -0
- package/ContentHeader/utils.js +215 -0
- package/DateRangePicker/useDateRangeCalendarControls.js +8 -2
- package/Dropdown/Dropdown.d.ts +48 -0
- package/Dropdown/Dropdown.js +16 -2
- package/Dropdown/DropdownItem.d.ts +42 -0
- package/Dropdown/DropdownItem.js +144 -13
- package/Dropdown/DropdownItemCard.d.ts +7 -2
- package/Dropdown/DropdownItemCard.js +12 -9
- package/Empty/Empty.js +2 -1
- package/Empty/icons/EmptyMainNotificationIcon.d.ts +4 -0
- package/Empty/icons/EmptyMainNotificationIcon.js +9 -0
- package/Empty/typings.d.ts +2 -2
- package/FilterArea/Filter.d.ts +32 -0
- package/FilterArea/Filter.js +23 -0
- package/FilterArea/FilterArea.d.ts +58 -0
- package/FilterArea/FilterArea.js +31 -0
- package/FilterArea/FilterLine.d.ts +11 -0
- package/FilterArea/FilterLine.js +13 -0
- package/FilterArea/index.d.ts +6 -0
- package/FilterArea/index.js +3 -0
- package/Form/useSelectValueControl.d.ts +3 -4
- package/Form/useSelectValueControl.js +51 -39
- package/Input/Input.d.ts +6 -4
- package/Input/Input.js +28 -10
- package/Input/index.d.ts +1 -1
- package/Modal/MediaPreviewModal.d.ts +54 -0
- package/Modal/MediaPreviewModal.js +158 -0
- package/Modal/Modal.js +1 -1
- package/Modal/index.d.ts +2 -0
- package/Modal/index.js +1 -0
- package/Navigation/Navigation.js +6 -5
- package/Navigation/NavigationOption.d.ts +6 -2
- package/Navigation/NavigationOption.js +19 -9
- package/Navigation/NavigationOverflowMenu.d.ts +6 -0
- package/Navigation/NavigationOverflowMenu.js +90 -0
- package/Navigation/NavigationOverflowMenuOption.d.ts +7 -0
- package/Navigation/NavigationOverflowMenuOption.js +68 -0
- package/Navigation/NavigationUserMenu.d.ts +4 -2
- package/Navigation/NavigationUserMenu.js +13 -5
- package/Navigation/context.d.ts +3 -2
- package/NotificationCenter/NotificationCenter.d.ts +1 -1
- package/NotificationCenter/NotificationCenter.js +34 -14
- package/NotificationCenter/NotificationCenterDrawer.d.ts +20 -0
- package/PageHeader/PageHeader.d.ts +32 -25
- package/PageHeader/PageHeader.js +49 -35
- package/Popper/Popper.js +2 -1
- package/ResultState/ResultState.d.ts +9 -0
- package/ResultState/ResultState.js +36 -4
- package/Scrollbar/Scrollbar.d.ts +9 -0
- package/Scrollbar/Scrollbar.js +79 -0
- package/Scrollbar/index.d.ts +2 -0
- package/Scrollbar/index.js +1 -0
- package/Scrollbar/typings.d.ts +47 -0
- package/Select/Select.d.ts +37 -18
- package/Select/Select.js +165 -51
- package/Select/SelectTrigger.js +5 -4
- package/Select/index.d.ts +8 -9
- package/Select/index.js +3 -3
- package/Select/typings.d.ts +6 -1
- package/Selection/Selection.js +1 -1
- package/Selection/SelectionGroup.d.ts +28 -0
- package/Table/Table.d.ts +2 -120
- package/Table/Table.js +148 -53
- package/Table/TableContext.d.ts +11 -12
- package/Table/components/TableActionsCell.js +12 -4
- package/Table/components/TableBody.js +2 -1
- package/Table/components/TableColGroup.d.ts +1 -4
- package/Table/components/TableColGroup.js +15 -16
- package/Table/components/TableCollectableCell.d.ts +17 -0
- package/Table/components/TableCollectableCell.js +54 -0
- package/Table/components/TableDragOrPinHandleCell.d.ts +20 -0
- package/Table/components/TableDragOrPinHandleCell.js +58 -0
- package/Table/components/TableExpandedRow.js +11 -2
- package/Table/components/TableHeader.js +12 -10
- package/Table/components/TableRow.js +38 -13
- package/Table/components/TableSelectionCell.js +1 -1
- package/Table/components/TableToggleableCell.d.ts +16 -0
- package/Table/components/TableToggleableCell.js +51 -0
- package/Table/components/index.d.ts +4 -1
- package/Table/components/index.js +3 -0
- package/Table/hooks/typings.d.ts +18 -4
- package/Table/hooks/useTableExpansion.d.ts +2 -2
- package/Table/hooks/useTableExpansion.js +5 -5
- package/Table/hooks/useTableFixedOffsets.d.ts +6 -2
- package/Table/hooks/useTableFixedOffsets.js +58 -24
- package/Table/hooks/useTableScroll.d.ts +9 -3
- package/Table/hooks/useTableScroll.js +34 -7
- package/Table/hooks/useTableVirtualization.d.ts +2 -1
- package/Table/hooks/useTableVirtualization.js +2 -8
- package/Table/index.d.ts +4 -3
- package/Table/index.js +3 -0
- package/Table/typings.d.ts +172 -0
- package/Transition/Slide.d.ts +9 -2
- package/Transition/Slide.js +7 -4
- package/Tree/TreeNode.js +1 -1
- package/index.d.ts +4 -2
- package/index.js +6 -3
- package/package.json +6 -4
- package/Navigation/CollapsedMenu.d.ts +0 -6
- package/Navigation/CollapsedMenu.js +0 -16
- package/PageToolbar/PageToolbar.d.ts +0 -110
- package/PageToolbar/PageToolbar.js +0 -23
- package/PageToolbar/index.d.ts +0 -2
- package/PageToolbar/index.js +0 -1
- package/PageToolbar/utils.d.ts +0 -23
- package/PageToolbar/utils.js +0 -157
- package/Table/components/TableDragHandleCell.d.ts +0 -11
- package/Table/components/TableDragHandleCell.js +0 -44
package/Select/Select.js
CHANGED
|
@@ -1,41 +1,34 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx
|
|
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
|
|
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,
|
|
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
|
|
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
|
|
48
|
-
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
const
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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
|
-
}, [
|
|
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:
|
|
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 };
|
package/Select/SelectTrigger.js
CHANGED
|
@@ -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:
|
|
50
|
-
|
|
51
|
-
|
|
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
|
|
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';
|
package/Select/typings.d.ts
CHANGED
|
@@ -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
|
package/Selection/Selection.js
CHANGED
|
@@ -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, {
|
|
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 {
|
|
2
|
-
import type {
|
|
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,
|