@mezzanine-ui/react 0.9.2 → 0.10.0
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/Accordion/Accordion.js +5 -4
- package/Accordion/AccordionDetails.js +2 -2
- package/Accordion/AccordionSummary.js +3 -4
- package/Alert/Alert.js +1 -3
- package/AppBar/AppBar.js +1 -1
- package/AppBar/AppBarBrand.d.ts +1 -1
- package/AppBar/AppBarBrand.js +1 -1
- package/AppBar/AppBarMain.d.ts +1 -1
- package/AppBar/AppBarMain.js +1 -1
- package/AppBar/AppBarSupport.d.ts +1 -1
- package/AppBar/AppBarSupport.js +1 -1
- package/Badge/Badge.js +2 -2
- package/Badge/BadgeContainer.d.ts +1 -1
- package/Badge/BadgeContainer.js +1 -1
- package/Button/Button.d.ts +2 -2
- package/Button/Button.js +3 -3
- package/Button/ButtonGroup.js +3 -3
- package/Button/IconButton.d.ts +3 -3
- package/Button/IconButton.js +1 -1
- package/Calendar/Calendar.js +9 -10
- package/Calendar/CalendarCell.js +2 -2
- package/Calendar/CalendarContext.d.ts +3 -3
- package/Calendar/CalendarContext.js +20 -12
- package/Calendar/CalendarControls.js +3 -3
- package/Calendar/CalendarDayOfWeek.js +1 -1
- package/Calendar/CalendarDays.js +4 -5
- package/Calendar/CalendarMonths.js +4 -4
- package/Calendar/CalendarWeeks.js +4 -5
- package/Calendar/CalendarYears.js +4 -4
- package/Calendar/useCalendarControls.d.ts +2 -3
- package/Card/Card.js +5 -5
- package/Card/CardActions.js +1 -2
- package/Checkbox/CheckAll.js +2 -2
- package/Checkbox/Checkbox.js +2 -2
- package/Checkbox/CheckboxGroup.js +2 -2
- package/ConfirmActions/ConfirmActions.js +1 -2
- package/DatePicker/DatePicker.js +2 -3
- package/DatePicker/DatePickerCalendar.js +1 -1
- package/DateRangePicker/DateRangePicker.js +2 -3
- package/DateRangePicker/DateRangePickerCalendar.js +3 -4
- package/DateRangePicker/useDateRangeCalendarControls.d.ts +1 -2
- package/DateRangePicker/useDateRangePickerValue.d.ts +12 -13
- package/DateTimePicker/DateTimePicker.js +2 -3
- package/DateTimePicker/DateTimePickerPanel.js +1 -3
- package/Drawer/Drawer.js +1 -1
- package/Dropdown/Dropdown.js +2 -2
- package/Empty/Empty.js +3 -4
- package/Form/FormField.js +2 -2
- package/Form/FormLabel.js +1 -2
- package/Form/FormMessage.d.ts +1 -1
- package/Form/FormMessage.js +1 -1
- package/Form/useAutoCompleteValueControl.d.ts +30 -11
- package/Form/useAutoCompleteValueControl.js +71 -31
- package/Form/useInputWithTagsModeValue.js +2 -1
- package/Form/useSelectValueControl.d.ts +1 -1
- package/Icon/Icon.js +2 -2
- package/Input/Input.js +2 -3
- package/Loading/Loading.js +4 -5
- package/Menu/Menu.js +1 -1
- package/Menu/MenuDivider.d.ts +1 -1
- package/Menu/MenuDivider.js +1 -1
- package/Menu/MenuItem.js +2 -3
- package/Menu/MenuItemGroup.js +1 -2
- package/Message/Message.js +2 -3
- package/Modal/Modal.js +2 -2
- package/Modal/ModalActions.js +1 -1
- package/Modal/ModalBody.d.ts +1 -1
- package/Modal/ModalBody.js +1 -1
- package/Modal/ModalFooter.d.ts +1 -1
- package/Modal/ModalFooter.js +1 -1
- package/Modal/ModalHeader.js +2 -3
- package/Modal/useModalContainer.js +1 -1
- package/Navigation/Navigation.js +2 -2
- package/Navigation/NavigationItem.js +1 -1
- package/Navigation/NavigationSubMenu.js +3 -5
- package/Notification/Notification.js +2 -7
- package/Notifier/NotifierManager.js +1 -1
- package/Notifier/createNotifier.js +1 -1
- package/Overlay/Overlay.js +3 -3
- package/PageFooter/PageFooter.js +1 -2
- package/Pagination/Pagination.js +2 -3
- package/Pagination/PaginationItem.js +4 -4
- package/Pagination/PaginationJumper.js +2 -4
- package/Picker/PickerTrigger.js +1 -1
- package/Picker/RangePickerTrigger.js +1 -3
- package/Picker/usePickerInputValue.d.ts +2 -2
- package/Picker/usePickerValue.d.ts +6 -7
- package/Picker/useRangePickerValue.d.ts +9 -10
- package/Popconfirm/Popconfirm.js +1 -1
- package/Popover/Popover.js +2 -3
- package/Popper/Popper.js +2 -2
- package/Portal/Portal.js +1 -1
- package/Progress/Progress.js +5 -7
- package/Radio/Radio.js +2 -2
- package/Radio/RadioGroup.js +2 -2
- package/Select/AutoComplete.d.ts +40 -13
- package/Select/AutoComplete.js +37 -28
- package/Select/Option.js +2 -2
- package/Select/Select.d.ts +2 -50
- package/Select/Select.js +15 -49
- package/Select/SelectTrigger.d.ts +8 -1
- package/Select/SelectTrigger.js +8 -12
- package/Select/SelectTriggerTags.d.ts +19 -0
- package/Select/SelectTriggerTags.js +33 -0
- package/Select/TreeSelect.js +2 -3
- package/Select/index.d.ts +1 -0
- package/Select/index.js +1 -0
- package/Select/useSelectTriggerTags.d.ts +19 -0
- package/Select/useSelectTriggerTags.js +61 -0
- package/Skeleton/Skeleton.js +1 -1
- package/Slider/Slider.d.ts +1 -1
- package/Slider/Slider.js +7 -11
- package/Stepper/Step.js +2 -2
- package/Stepper/Stepper.js +1 -1
- package/Switch/Switch.js +2 -3
- package/Table/Table.d.ts +1 -1
- package/Table/Table.js +3 -10
- package/Table/TableBody.js +2 -4
- package/Table/TableBodyRow.js +4 -7
- package/Table/TableCell.js +3 -3
- package/Table/TableExpandedTable.js +5 -6
- package/Table/TableHeader.d.ts +2 -1
- package/Table/TableHeader.js +3 -6
- package/Table/editable/TableEditRenderWrapper.js +2 -2
- package/Table/expandable/TableExpandable.js +2 -2
- package/Table/pagination/TablePagination.js +1 -2
- package/Table/refresh/TableRefresh.js +1 -1
- package/Table/rowSelection/TableRowSelection.js +5 -6
- package/Table/sorting/TableSortingIcon.js +2 -2
- package/Table/sorting/useTableSorting.d.ts +2 -2
- package/Table/useTableScroll.d.ts +178 -178
- package/Tabs/Tab.js +2 -2
- package/Tabs/TabPane.js +1 -1
- package/Tabs/Tabs.js +1 -3
- package/Tag/Tag.js +3 -4
- package/TextField/TextField.js +3 -3
- package/TextField/useTextFieldControl.d.ts +2 -2
- package/Textarea/Textarea.js +2 -3
- package/TimePanel/TimePanel.js +1 -4
- package/TimePanel/TimePanelAction.js +1 -1
- package/TimePanel/TimePanelColumn.js +2 -5
- package/TimePicker/TimePicker.js +2 -3
- package/TimePicker/TimePickerPanel.js +1 -1
- package/Tooltip/Tooltip.js +3 -3
- package/Transition/Collapse.js +3 -2
- package/Transition/Fade.js +2 -2
- package/Transition/Grow.js +3 -2
- package/Transition/SlideFade.js +2 -2
- package/Transition/Transition.js +2 -2
- package/Transition/Zoom.js +2 -2
- package/Tree/Tree.js +1 -1
- package/Tree/TreeNode.js +5 -7
- package/Tree/TreeNodeList.js +5 -4
- package/Tree/getTreeNodeEntities.js +6 -3
- package/Typography/Typography.d.ts +2 -2
- package/Typography/Typography.js +2 -2
- package/Upload/UploadButton.js +2 -2
- package/Upload/UploadInput.js +1 -1
- package/Upload/UploadPicture.js +1 -1
- package/Upload/UploadPictureBlock.js +2 -8
- package/Upload/UploadPictureWall.d.ts +1 -1
- package/Upload/UploadPictureWall.js +1 -2
- package/Upload/UploadPictureWallItem.js +1 -1
- package/Upload/UploadResult.js +2 -5
- package/_internal/InputCheck/InputCheck.js +2 -3
- package/_internal/InputCheck/InputCheckGroup.js +1 -1
- package/_internal/InputTriggerPopper/InputTriggerPopper.js +2 -2
- package/_internal/SlideFadeOverlay/SlideFadeOverlay.js +1 -1
- package/index.d.ts +1 -1
- package/index.js +1 -0
- package/package.json +3 -3
package/Select/Select.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import { forwardRef, useContext, useState, useRef,
|
|
2
|
+
import { forwardRef, useContext, useState, useRef, useMemo } from 'react';
|
|
3
3
|
import { selectClasses } from '@mezzanine-ui/core/select';
|
|
4
|
-
import
|
|
4
|
+
import isArray from 'lodash/isArray';
|
|
5
5
|
import { useComposeRefs } from '../hooks/useComposeRefs.js';
|
|
6
6
|
import { SelectControlContext } from './SelectControlContext.js';
|
|
7
7
|
import { useSelectValueControl } from '../Form/useSelectValueControl.js';
|
|
8
8
|
import { useClickAway } from '../hooks/useClickAway.js';
|
|
9
9
|
import SelectTrigger from './SelectTrigger.js';
|
|
10
|
-
import Icon from '../Icon/Icon.js';
|
|
11
10
|
import InputTriggerPopper from '../_internal/InputTriggerPopper/InputTriggerPopper.js';
|
|
12
11
|
import Menu from '../Menu/Menu.js';
|
|
13
12
|
import { FormControlContext } from '../Form/FormControlContext.js';
|
|
@@ -17,7 +16,7 @@ const MENU_ID = 'mzn-select-menu-id';
|
|
|
17
16
|
const Select = forwardRef(function Select(props, ref) {
|
|
18
17
|
var _a, _b;
|
|
19
18
|
const { disabled: disabledFromFormControl, fullWidth: fullWidthFromFormControl, required: requiredFromFormControl, severity, } = useContext(FormControlContext) || {};
|
|
20
|
-
const { children, className, clearable = false, defaultValue, disabled = disabledFromFormControl || false, error = severity === 'error' || false, fullWidth = fullWidthFromFormControl || false, inputProps, inputRef, itemsInView = 4, menuMaxHeight, menuRole = 'listbox', menuSize = 'medium', mode = 'single', onBlur, onChange: onChangeProp, onClear: onClearProp, onFocus,
|
|
19
|
+
const { children, className, clearable = false, defaultValue, disabled = disabledFromFormControl || false, error = severity === 'error' || false, fullWidth = fullWidthFromFormControl || false, inputProps, inputRef, itemsInView = 4, menuMaxHeight, menuRole = 'listbox', menuSize = 'medium', mode = 'single', onBlur, onChange: onChangeProp, onClear: onClearProp, onFocus, placeholder = '', popperOptions = {}, prefix, renderValue, required = requiredFromFormControl || false, size = 'medium', suffixActionIcon, value: valueProp, } = props;
|
|
21
20
|
const [open, toggleOpen] = useState(false);
|
|
22
21
|
const onOpen = () => {
|
|
23
22
|
onFocus === null || onFocus === void 0 ? void 0 : onFocus();
|
|
@@ -47,46 +46,28 @@ const Select = forwardRef(function Select(props, ref) {
|
|
|
47
46
|
const controlRef = useRef(null);
|
|
48
47
|
const popperRef = useRef(null);
|
|
49
48
|
const composedRef = useComposeRefs([ref, controlRef]);
|
|
50
|
-
const searchable = typeof onSearch === 'function';
|
|
51
|
-
const [searchText, changeSearchText] = useState('');
|
|
52
|
-
const [focused, setFocused] = useState(false);
|
|
53
|
-
const renderValue = focused && searchable ? () => searchText : renderValueProp;
|
|
54
49
|
function getPlaceholder() {
|
|
55
|
-
if (
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return value.name;
|
|
61
|
-
}
|
|
62
|
-
return placeholder;
|
|
50
|
+
if (typeof renderValue === 'function') {
|
|
51
|
+
return renderValue(value);
|
|
52
|
+
}
|
|
53
|
+
if (value && !isArray(value)) {
|
|
54
|
+
return value.name;
|
|
63
55
|
}
|
|
64
56
|
return placeholder;
|
|
65
57
|
}
|
|
66
|
-
useLayoutEffect(() => {
|
|
67
|
-
if (!focused) {
|
|
68
|
-
changeSearchText('');
|
|
69
|
-
if (typeof onSearch === 'function') {
|
|
70
|
-
onSearch('');
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}, [focused, onSearch]);
|
|
74
58
|
useClickAway(() => {
|
|
75
|
-
if (!open
|
|
59
|
+
if (!open)
|
|
76
60
|
return;
|
|
77
61
|
return () => {
|
|
78
62
|
onClose();
|
|
79
63
|
};
|
|
80
64
|
}, nodeRef, [
|
|
81
|
-
focused,
|
|
82
65
|
nodeRef,
|
|
83
66
|
open,
|
|
84
67
|
toggleOpen,
|
|
85
68
|
]);
|
|
86
|
-
const suffixActionIcon = suffixActionIconProp || (searchable && open ? (jsx(Icon, { icon: SearchIcon }, void 0)) : undefined);
|
|
87
69
|
const onClickTextField = () => {
|
|
88
|
-
|
|
89
|
-
if (!searchable && !disabled) {
|
|
70
|
+
if (!disabled) {
|
|
90
71
|
onToggleOpen();
|
|
91
72
|
}
|
|
92
73
|
};
|
|
@@ -117,34 +98,19 @@ const Select = forwardRef(function Select(props, ref) {
|
|
|
117
98
|
}
|
|
118
99
|
}
|
|
119
100
|
};
|
|
120
|
-
/** Trigger input props */
|
|
121
|
-
const onSearchInputChange = searchable ? (e) => {
|
|
122
|
-
changeSearchText(e.target.value);
|
|
123
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
124
|
-
onSearch(e.target.value);
|
|
125
|
-
} : undefined;
|
|
126
|
-
const onSearchInputFocus = searchable ? (e) => {
|
|
127
|
-
e.stopPropagation();
|
|
128
|
-
onToggleOpen();
|
|
129
|
-
setFocused(true);
|
|
130
|
-
} : undefined;
|
|
131
|
-
const onSearchInputBlur = () => setFocused(false);
|
|
132
101
|
const resolvedInputProps = {
|
|
133
102
|
...inputProps,
|
|
134
103
|
'aria-controls': MENU_ID,
|
|
135
104
|
'aria-expanded': open,
|
|
136
105
|
'aria-owns': MENU_ID,
|
|
137
|
-
onBlur: onSearchInputBlur,
|
|
138
|
-
onChange: onSearchInputChange,
|
|
139
|
-
onFocus: onSearchInputFocus,
|
|
140
106
|
placeholder: getPlaceholder(),
|
|
141
107
|
role: 'combobox',
|
|
142
108
|
};
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
109
|
+
const context = useMemo(() => ({
|
|
110
|
+
onChange,
|
|
111
|
+
value,
|
|
112
|
+
}), [onChange, value]);
|
|
113
|
+
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, { ref: popperRef, anchor: controlRef, className: selectClasses.popper, open: open, sameWidth: true, options: popperOptions, 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, role: menuRole, size: menuSize, style: { border: 0 }, children: children }) })] }) }));
|
|
148
114
|
});
|
|
149
115
|
var Select$1 = Select;
|
|
150
116
|
|
|
@@ -8,6 +8,10 @@ export interface SelectTriggerBaseProps extends Omit<TextFieldProps, 'active' |
|
|
|
8
8
|
* Controls the chevron icon layout.
|
|
9
9
|
*/
|
|
10
10
|
active?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Tags arg ellipsis or not.
|
|
13
|
+
*/
|
|
14
|
+
ellipsis?: boolean;
|
|
11
15
|
/**
|
|
12
16
|
* force hide suffixAction icons
|
|
13
17
|
*/
|
|
@@ -43,6 +47,9 @@ export interface SelectTriggerBaseProps extends Omit<TextFieldProps, 'active' |
|
|
|
43
47
|
* @default false
|
|
44
48
|
*/
|
|
45
49
|
required?: boolean;
|
|
50
|
+
searchText?: string;
|
|
51
|
+
showTextInputAfterTags?: boolean;
|
|
52
|
+
suffixAction?: VoidFunction;
|
|
46
53
|
}
|
|
47
54
|
export declare type SelectTriggerMultipleProps = SelectTriggerBaseProps & {
|
|
48
55
|
/**
|
|
@@ -78,5 +85,5 @@ export declare type SelectTriggerSingleProps = SelectTriggerBaseProps & {
|
|
|
78
85
|
};
|
|
79
86
|
export declare type SelectTriggerComponentProps = SelectTriggerMultipleProps | SelectTriggerSingleProps;
|
|
80
87
|
export declare type SelectTriggerProps = Omit<SelectTriggerComponentProps, 'innerRef'>;
|
|
81
|
-
declare const SelectTrigger: import("react").ForwardRefExoticComponent<
|
|
88
|
+
declare const SelectTrigger: import("react").ForwardRefExoticComponent<SelectTriggerProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
82
89
|
export default SelectTrigger;
|
package/Select/SelectTrigger.js
CHANGED
|
@@ -2,14 +2,13 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
3
|
import { selectClasses } from '@mezzanine-ui/core/select';
|
|
4
4
|
import { ChevronDownIcon } from '@mezzanine-ui/icons';
|
|
5
|
+
import SelectTriggerTags from './SelectTriggerTags.js';
|
|
5
6
|
import Icon from '../Icon/Icon.js';
|
|
6
7
|
import TextField from '../TextField/TextField.js';
|
|
7
|
-
import Tag from '../Tag/Tag.js';
|
|
8
8
|
import cx from 'clsx';
|
|
9
9
|
|
|
10
10
|
function SelectTriggerComponent(props) {
|
|
11
|
-
|
|
12
|
-
const { active, className, disabled, forceHideSuffixActionIcon, inputProps, innerRef, inputRef, mode, onTagClose, readOnly, renderValue: renderValueProp, required, size, suffixActionIcon: suffixActionIconProp, value, ...restTextFieldProps } = props;
|
|
11
|
+
const { active, className, disabled, ellipsis = false, forceHideSuffixActionIcon, inputProps, innerRef, inputRef, mode, onTagClose, readOnly, renderValue: renderValueProp, required, searchText, size, showTextInputAfterTags = false, suffixAction, suffixActionIcon: suffixActionIconProp, value, ...restTextFieldProps } = props;
|
|
13
12
|
/** Render value to string for input */
|
|
14
13
|
const renderValue = () => {
|
|
15
14
|
if (typeof renderValueProp === 'function') {
|
|
@@ -24,28 +23,25 @@ function SelectTriggerComponent(props) {
|
|
|
24
23
|
return '';
|
|
25
24
|
};
|
|
26
25
|
/** Compute suffix action icon */
|
|
27
|
-
const suffixActionIcon = suffixActionIconProp || (jsx(Icon, { icon: ChevronDownIcon, className: cx(selectClasses.triggerSuffixActionIcon, {
|
|
26
|
+
const suffixActionIcon = suffixActionIconProp || (jsx(Icon, { icon: ChevronDownIcon, onClick: suffixAction, className: cx(selectClasses.triggerSuffixActionIcon, {
|
|
28
27
|
[selectClasses.triggerSuffixActionIconActive]: active,
|
|
29
|
-
}) }
|
|
28
|
+
}) }));
|
|
30
29
|
const getTextFieldActive = () => {
|
|
31
30
|
if (value) {
|
|
32
31
|
if (Array.isArray(value)) {
|
|
33
|
-
return !!
|
|
32
|
+
return !!value.length;
|
|
34
33
|
}
|
|
35
34
|
return !!value;
|
|
36
35
|
}
|
|
37
36
|
return false;
|
|
38
37
|
};
|
|
39
|
-
return (jsx(TextField,
|
|
40
|
-
e.stopPropagation();
|
|
41
|
-
onTagClose === null || onTagClose === void 0 ? void 0 : onTagClose(selection);
|
|
42
|
-
}, size: size }, { children: selection.name }), selection.id))) }), void 0)) : (jsx("input", Object.assign({}, inputProps, { ref: inputRef, "aria-autocomplete": "list", "aria-disabled": disabled, "aria-haspopup": "listbox", "aria-readonly": readOnly, "aria-required": required, autoComplete: "false", disabled: disabled, readOnly: readOnly, required: required, type: "search", value: renderValue() }), void 0)) }), void 0));
|
|
38
|
+
return (jsx(TextField, { ref: innerRef, ...restTextFieldProps, active: getTextFieldActive(), className: cx(selectClasses.trigger, className), disabled: disabled, size: size, suffixActionIcon: forceHideSuffixActionIcon ? undefined : suffixActionIcon, children: mode === 'multiple' && (value === null || value === void 0 ? void 0 : value.length) ? (jsx(SelectTriggerTags, { disabled: disabled, ellipsis: ellipsis, inputProps: inputProps, inputRef: inputRef, onTagClose: onTagClose, readOnly: readOnly, required: required, searchText: searchText, size: size, showTextInputAfterTags: showTextInputAfterTags, value: value })) : (jsx("input", { ...inputProps, ref: inputRef, "aria-autocomplete": "list", "aria-disabled": disabled, "aria-haspopup": "listbox", "aria-readonly": readOnly, "aria-required": required, autoComplete: "false", disabled: disabled, readOnly: readOnly, required: required, type: "search", value: renderValue() })) }));
|
|
43
39
|
}
|
|
44
40
|
const SelectTrigger = forwardRef((props, ref) => {
|
|
45
41
|
if (props.mode === 'multiple') {
|
|
46
|
-
return (jsx(SelectTriggerComponent,
|
|
42
|
+
return (jsx(SelectTriggerComponent, { ...props, innerRef: ref }));
|
|
47
43
|
}
|
|
48
|
-
return (jsx(SelectTriggerComponent,
|
|
44
|
+
return (jsx(SelectTriggerComponent, { ...props, innerRef: ref }));
|
|
49
45
|
});
|
|
50
46
|
var SelectTrigger$1 = SelectTrigger;
|
|
51
47
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Ref } from 'react';
|
|
2
|
+
import { TagSize } from '@mezzanine-ui/core/tag';
|
|
3
|
+
import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
|
|
4
|
+
import { SelectValue } from './typings';
|
|
5
|
+
export interface SelectTriggerTagsProps {
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
ellipsis: boolean;
|
|
8
|
+
inputProps?: Omit<NativeElementPropsWithoutKeyAndRef<'input'>, 'autoComplete' | 'children' | 'defaultValue' | 'disabled' | 'readOnly' | 'required' | 'type' | 'value' | `aria-${'autocomplete' | 'disabled' | 'haspopup' | 'multiline' | 'readonly' | 'required'}`>;
|
|
9
|
+
inputRef?: Ref<HTMLInputElement>;
|
|
10
|
+
onTagClose?: (target: SelectValue) => void;
|
|
11
|
+
readOnly?: boolean;
|
|
12
|
+
required?: boolean;
|
|
13
|
+
searchText?: string;
|
|
14
|
+
size?: TagSize;
|
|
15
|
+
showTextInputAfterTags?: boolean;
|
|
16
|
+
value?: SelectValue[];
|
|
17
|
+
}
|
|
18
|
+
declare const SelectTriggerTags: import("react").ForwardRefExoticComponent<SelectTriggerTagsProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
19
|
+
export default SelectTriggerTags;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { forwardRef, useRef } from 'react';
|
|
3
|
+
import { selectClasses } from '@mezzanine-ui/core/select';
|
|
4
|
+
import take from 'lodash/take';
|
|
5
|
+
import { useComposeRefs } from '../hooks/useComposeRefs.js';
|
|
6
|
+
import { useSelectTriggerTags } from './useSelectTriggerTags.js';
|
|
7
|
+
import Tag from '../Tag/Tag.js';
|
|
8
|
+
import cx from 'clsx';
|
|
9
|
+
|
|
10
|
+
const SelectTriggerTags = forwardRef(function SelectTriggerTags(props, ref) {
|
|
11
|
+
const { disabled, ellipsis, inputProps, inputRef, onTagClose, readOnly, required, searchText, size = 'medium', showTextInputAfterTags, value, } = props;
|
|
12
|
+
const controlRef = useRef();
|
|
13
|
+
const composedRef = useComposeRefs([ref, controlRef]);
|
|
14
|
+
const { renderFakeTags, takeCount, } = useSelectTriggerTags({
|
|
15
|
+
controlRef,
|
|
16
|
+
value,
|
|
17
|
+
size,
|
|
18
|
+
});
|
|
19
|
+
return (jsxs("div", { ref: composedRef, className: cx(selectClasses.triggerTagsInputWrapper, {
|
|
20
|
+
[selectClasses.triggerTagsInputWrapperEllipsis]: ellipsis,
|
|
21
|
+
}), children: [jsxs("div", { className: cx(selectClasses.triggerTags, {
|
|
22
|
+
[selectClasses.triggerTagsEllipsis]: ellipsis,
|
|
23
|
+
}), children: [ellipsis ? (jsxs(Fragment, { children: [take(value, takeCount).map((selection) => (jsx(Tag, { closable: true, disabled: disabled, onClose: (e) => {
|
|
24
|
+
e.stopPropagation();
|
|
25
|
+
onTagClose === null || onTagClose === void 0 ? void 0 : onTagClose(selection);
|
|
26
|
+
}, size: size, children: selection.name }, selection.id))), value && value.length > takeCount ? (jsx(Tag, { disabled: disabled, size: size, children: `+${value.length - takeCount <= 99 ? value.length - takeCount : 99}...` })) : null] })) : (value === null || value === void 0 ? void 0 : value.map((selection) => (jsx(Tag, { closable: true, disabled: disabled, onClose: (e) => {
|
|
27
|
+
e.stopPropagation();
|
|
28
|
+
onTagClose === null || onTagClose === void 0 ? void 0 : onTagClose(selection);
|
|
29
|
+
}, size: size, children: selection.name }, selection.id)))), ellipsis ? renderFakeTags() : null] }), showTextInputAfterTags ? (jsx("div", { className: selectClasses.triggerTagsInput, children: jsx("input", { ...inputProps, ref: inputRef, "aria-autocomplete": "list", "aria-disabled": disabled, "aria-haspopup": "listbox", "aria-readonly": readOnly, "aria-required": required, autoComplete: "false", disabled: disabled, readOnly: readOnly, required: required, type: "search", value: searchText }) })) : null] }));
|
|
30
|
+
});
|
|
31
|
+
var SelectTriggerTags$1 = SelectTriggerTags;
|
|
32
|
+
|
|
33
|
+
export { SelectTriggerTags$1 as default };
|
package/Select/TreeSelect.js
CHANGED
|
@@ -187,12 +187,11 @@ const TreeSelect = forwardRef((props, ref) => {
|
|
|
187
187
|
const newExpandedValues = toggleValue(value, expandedValues);
|
|
188
188
|
setExpandedValues(newExpandedValues);
|
|
189
189
|
};
|
|
190
|
-
return (jsxs("div",
|
|
191
|
-
jsx(InputTriggerPopper, Object.assign({ ref: popperRef, anchor: controlRef, className: selectClasses.popper, controllerRef: controllerRef, open: open, options: popperOptions, sameWidth: sameWidth }, { children: jsx(Menu, Object.assign({ itemsInView: itemsInView, maxHeight: menuMaxHeight, role: menuRole, size: menuSize, style: {
|
|
190
|
+
return (jsxs("div", { ref: nodeRef, className: selectClasses.treeSelect, children: [jsx(SelectTrigger, { ref: composedRef, active: open, className: className, clearable: clearable, disabled: disabled, error: error, fullWidth: fullWidth, inputProps: resolvedInputProps, inputRef: inputRef, mode: mode, onClear: onClear, onClick: onTextFieldClick, onKeyDown: onTextFieldKeydown, onTagClose: onTagClose, prefix: prefix, readOnly: true, renderValue: renderValue, required: required, size: size, suffixActionIcon: suffixActionIcon, value: valueProp }), jsx(InputTriggerPopper, { ref: popperRef, anchor: controlRef, className: selectClasses.popper, controllerRef: controllerRef, open: open, options: popperOptions, sameWidth: sameWidth, children: jsx(Menu, { itemsInView: itemsInView, maxHeight: menuMaxHeight, role: menuRole, size: menuSize, style: {
|
|
192
191
|
...restStyle,
|
|
193
192
|
border: border || 0,
|
|
194
193
|
width: width || `${panelWidth}px`,
|
|
195
|
-
}
|
|
194
|
+
}, children: jsx(Tree, { ...restTreeProps, ref: ref, className: cx(selectClasses.tree, treeClassName), disabledValues: disabledValues, expandControllerRef: expandControllerRef, expandedValues: expandedValues, multiple: multiple, nodes: nodes, onExpand: onExpand, onSelect: onSelect, selectMethod: "target", selectable: true, values: selectedValues }) }) })] }));
|
|
196
195
|
});
|
|
197
196
|
var TreeSelect$1 = TreeSelect;
|
|
198
197
|
|
package/Select/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './typings';
|
|
2
2
|
export { SelectControlContext, } from './SelectControlContext';
|
|
3
3
|
export { SelectTriggerProps, SelectTriggerInputProps, default as SelectTrigger, } from './SelectTrigger';
|
|
4
|
+
export { SelectTriggerTagsProps, default as SelectTriggerTags, } from './SelectTriggerTags';
|
|
4
5
|
export { SelectProps, default, } from './Select';
|
|
5
6
|
export { OptionProps, default as Option, } from './Option';
|
|
6
7
|
export { MenuItemGroupProps as OptionGroupProps, default as OptionGroup, } from '../Menu/MenuItemGroup';
|
package/Select/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { SelectControlContext } from './SelectControlContext.js';
|
|
2
2
|
export { default as SelectTrigger } from './SelectTrigger.js';
|
|
3
|
+
export { default as SelectTriggerTags } from './SelectTriggerTags.js';
|
|
3
4
|
export { default } from './Select.js';
|
|
4
5
|
export { default as Option } from './Option.js';
|
|
5
6
|
export { default as OptionGroup } from '../Menu/MenuItemGroup.js';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { MutableRefObject } from 'react';
|
|
2
|
+
import { TagSize } from '@mezzanine-ui/core/tag';
|
|
3
|
+
import { SelectValue } from './typings';
|
|
4
|
+
export interface UseSelectTriggerTagsProps {
|
|
5
|
+
controlRef: MutableRefObject<HTMLDivElement | undefined>;
|
|
6
|
+
size?: TagSize;
|
|
7
|
+
value?: SelectValue[];
|
|
8
|
+
}
|
|
9
|
+
export interface UseSelectTriggerTagsValue {
|
|
10
|
+
renderFakeTags: () => JSX.Element | null;
|
|
11
|
+
takeCount: number;
|
|
12
|
+
}
|
|
13
|
+
export declare function calcTakeCount({ tagsWidths, maxWidth, ellipsisTagWidth, setTakeCount, }: {
|
|
14
|
+
tagsWidths: number[];
|
|
15
|
+
maxWidth: number;
|
|
16
|
+
ellipsisTagWidth: number;
|
|
17
|
+
setTakeCount: (count: number) => void;
|
|
18
|
+
}): void;
|
|
19
|
+
export declare function useSelectTriggerTags(props: UseSelectTriggerTagsProps): UseSelectTriggerTagsValue;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useState, useEffect } from 'react';
|
|
3
|
+
import take from 'lodash/take';
|
|
4
|
+
import Tag from '../Tag/Tag.js';
|
|
5
|
+
|
|
6
|
+
function calcTakeCount({ tagsWidths, maxWidth, ellipsisTagWidth, setTakeCount, }) {
|
|
7
|
+
let targetCount = 0;
|
|
8
|
+
for (let count = 0; count <= tagsWidths.length; count += 1) {
|
|
9
|
+
const prevTotal = take(tagsWidths, count).reduce((prev, curr) => prev + curr, 0);
|
|
10
|
+
const nowTotal = take(tagsWidths, count + 1).reduce((prev, curr) => prev + curr, 0);
|
|
11
|
+
targetCount = count;
|
|
12
|
+
if (prevTotal < maxWidth && nowTotal > maxWidth) {
|
|
13
|
+
if (prevTotal + ellipsisTagWidth > maxWidth) {
|
|
14
|
+
targetCount -= 1;
|
|
15
|
+
}
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
setTakeCount(targetCount);
|
|
20
|
+
}
|
|
21
|
+
function useSelectTriggerTags(props) {
|
|
22
|
+
const { controlRef, value, size, } = props;
|
|
23
|
+
const [tagsWidths, setTagsWidths] = useState([]);
|
|
24
|
+
const [takeCount, setTakeCount] = useState(0);
|
|
25
|
+
const mznFakeTagClassName = 'mzn-fake-tag';
|
|
26
|
+
const mznFakeEllipsisTagClassName = 'mzn-fake-ellipsis-tag';
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
var _a, _b, _c;
|
|
29
|
+
const elements = (_a = controlRef.current) === null || _a === void 0 ? void 0 : _a.getElementsByClassName(mznFakeTagClassName);
|
|
30
|
+
const ellipsisTagElement = (_b = controlRef.current) === null || _b === void 0 ? void 0 : _b.getElementsByClassName(mznFakeEllipsisTagClassName)[0];
|
|
31
|
+
if ((elements === null || elements === void 0 ? void 0 : elements.length) && ellipsisTagElement) {
|
|
32
|
+
const tagsWidthsArray = Array.from(elements).map((e) => e.clientWidth);
|
|
33
|
+
const parentWidth = ((_c = controlRef.current) === null || _c === void 0 ? void 0 : _c.clientWidth) || 0;
|
|
34
|
+
const maxWidth = parentWidth * 0.7;
|
|
35
|
+
const ellipsisTagWidth = ellipsisTagElement.clientWidth;
|
|
36
|
+
setTagsWidths(tagsWidthsArray);
|
|
37
|
+
calcTakeCount({
|
|
38
|
+
tagsWidths: tagsWidthsArray,
|
|
39
|
+
maxWidth,
|
|
40
|
+
ellipsisTagWidth,
|
|
41
|
+
setTakeCount,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}, [value, controlRef]);
|
|
45
|
+
const renderFakeTags = () => {
|
|
46
|
+
if (value && value.length === tagsWidths.length)
|
|
47
|
+
return null;
|
|
48
|
+
return (jsxs("div", { style: {
|
|
49
|
+
position: 'absolute',
|
|
50
|
+
visibility: 'hidden',
|
|
51
|
+
pointerEvents: 'none',
|
|
52
|
+
opacity: 0,
|
|
53
|
+
}, children: [value === null || value === void 0 ? void 0 : value.map((selection) => (jsx(Tag, { className: mznFakeTagClassName, closable: true, disabled: true, size: size, children: selection.name }, selection.id))), jsx(Tag, { disabled: true, className: mznFakeEllipsisTagClassName, size: size, children: "+99..." })] }));
|
|
54
|
+
};
|
|
55
|
+
return {
|
|
56
|
+
renderFakeTags,
|
|
57
|
+
takeCount,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export { calcTakeCount, useSelectTriggerTags };
|
package/Skeleton/Skeleton.js
CHANGED
|
@@ -8,7 +8,7 @@ import cx from 'clsx';
|
|
|
8
8
|
*/
|
|
9
9
|
const Skeleton = forwardRef(function Skeleton(props, ref) {
|
|
10
10
|
const { className, height: skeletonHeight, style: skeletonStyle, type, width: skeletonWidth, ...rest } = props;
|
|
11
|
-
return (jsx("div",
|
|
11
|
+
return (jsx("div", { ...rest, ref: ref, className: cx(skeletonClasses.host, type === 'circle' && skeletonClasses.circle, className), style: { width: skeletonWidth, height: skeletonHeight, ...skeletonStyle }, ...rest }));
|
|
12
12
|
});
|
|
13
13
|
var Skeleton$1 = Skeleton;
|
|
14
14
|
|
package/Slider/Slider.d.ts
CHANGED
|
@@ -47,5 +47,5 @@ export declare type SliderProps = Omit<SliderComponentProps, 'innerRef'>;
|
|
|
47
47
|
* The outcome will be base on the type of given value.
|
|
48
48
|
* Notice that slider is a fully controlled component. Property value is always needed.
|
|
49
49
|
*/
|
|
50
|
-
declare const Slider: import("react").ForwardRefExoticComponent<
|
|
50
|
+
declare const Slider: import("react").ForwardRefExoticComponent<SliderProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
51
51
|
export default Slider;
|
package/Slider/Slider.js
CHANGED
|
@@ -20,9 +20,9 @@ function SliderComponent(props) {
|
|
|
20
20
|
...styleProp,
|
|
21
21
|
};
|
|
22
22
|
const shouldHaveInputHandlers = withInput && onChange && !disabled;
|
|
23
|
-
const getHandle = (handlerValue, index) => (jsx("div",
|
|
23
|
+
const getHandle = (handlerValue, index) => (jsx("div", { className: cx(sliderClasses.handlerPosition, index === 0 && sliderClasses.handlerStartPosition, index === 1 && sliderClasses.handlerEndPosition), children: jsx(Tooltip, { disablePortal: true, options: {
|
|
24
24
|
placement: 'top',
|
|
25
|
-
}, title: handlerValue.toString()
|
|
25
|
+
}, title: handlerValue.toString(), children: ({ onMouseEnter, onMouseLeave }) => (jsx("div", { className: cx(sliderClasses.handler, index === activeHandleIndex && sliderClasses.handlerActive), "aria-disabled": disabled, "aria-label": `Slider Handler ${index}`, "aria-valuemax": max, "aria-valuemin": min, "aria-valuenow": handlerValue, onFocus: () => { }, onMouseDown: (e) => handlePress(e, index), onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, onTouchStart: (e) => handlePress(e, index), role: "slider", tabIndex: index })) }) }));
|
|
26
26
|
const inputSize = Math.max(min.toString().length, max.toString().length);
|
|
27
27
|
const [startInputValue, setStartInputValue] = useState(() => {
|
|
28
28
|
if (!isRangeSlider(value)) {
|
|
@@ -159,19 +159,15 @@ function SliderComponent(props) {
|
|
|
159
159
|
},
|
|
160
160
|
type: 'number',
|
|
161
161
|
};
|
|
162
|
-
return (jsxs("div",
|
|
162
|
+
return (jsxs("div", { ...rest, ref: innerRef, className: cx(sliderClasses.host, disabled && sliderClasses.disabled, className), style: style, children: [withInput && isRangeSlider(value) ? (jsx(Input, { className: sliderClasses.input, disabled: disabled, onChange: onStartInputChange, value: startInputValue, inputProps: {
|
|
163
163
|
...inputProps,
|
|
164
164
|
onKeyDown: onStartInputKeydown,
|
|
165
165
|
onBlur: onStartInputBlur,
|
|
166
|
-
} },
|
|
167
|
-
jsxs("div", Object.assign({ className: sliderClasses.controls }, { children: [jsx("div", { ref: railRef, className: sliderClasses.rail, role: "presentation", onMouseDown: handleClickTrackOrRail }, void 0),
|
|
168
|
-
jsx("div", { className: sliderClasses.track, role: "presentation", onMouseDown: handleClickTrackOrRail }, void 0),
|
|
169
|
-
isRangeSlider(value) ? (jsxs(Fragment, { children: [getHandle(value[0], 0), getHandle(value[1], 1)] }, void 0)) : getHandle(value, -1)] }), void 0),
|
|
170
|
-
withInput ? (jsx(Input, { className: sliderClasses.input, disabled: disabled, onChange: onEndInputChange, value: endInputValue, inputProps: {
|
|
166
|
+
} })) : null, jsxs("div", { className: sliderClasses.controls, children: [jsx("div", { ref: railRef, className: sliderClasses.rail, role: "presentation", onMouseDown: handleClickTrackOrRail }), jsx("div", { className: sliderClasses.track, role: "presentation", onMouseDown: handleClickTrackOrRail }), isRangeSlider(value) ? (jsxs(Fragment, { children: [getHandle(value[0], 0), getHandle(value[1], 1)] })) : getHandle(value, -1)] }), withInput ? (jsx(Input, { className: sliderClasses.input, disabled: disabled, onChange: onEndInputChange, value: endInputValue, inputProps: {
|
|
171
167
|
...inputProps,
|
|
172
168
|
onKeyDown: onEndInputKeydown,
|
|
173
169
|
onBlur: onEndInputBlur,
|
|
174
|
-
} }
|
|
170
|
+
} })) : null] }));
|
|
175
171
|
}
|
|
176
172
|
/**
|
|
177
173
|
* The react component for `mezzanine` slider.
|
|
@@ -180,9 +176,9 @@ function SliderComponent(props) {
|
|
|
180
176
|
*/
|
|
181
177
|
const Slider = forwardRef((props, ref) => {
|
|
182
178
|
if (isRangeSlider(props.value)) {
|
|
183
|
-
return (jsx(SliderComponent,
|
|
179
|
+
return (jsx(SliderComponent, { ...props, innerRef: ref }));
|
|
184
180
|
}
|
|
185
|
-
return (jsx(SliderComponent,
|
|
181
|
+
return (jsx(SliderComponent, { ...props, innerRef: ref }));
|
|
186
182
|
});
|
|
187
183
|
var Slider$1 = Slider;
|
|
188
184
|
|
package/Stepper/Step.js
CHANGED
|
@@ -12,8 +12,8 @@ import cx from 'clsx';
|
|
|
12
12
|
const Step = forwardRef(function Step(props, ref) {
|
|
13
13
|
const { active, children, className, completed, completedIconProps, disabled, index = -1, title, titleProps, ...rest } = props;
|
|
14
14
|
/** icon and step number */
|
|
15
|
-
const iconRender = (jsx(Typography,
|
|
16
|
-
return (jsxs("div",
|
|
15
|
+
const iconRender = (jsx(Typography, { className: stepClasses.iconBackground, variant: "button3", children: completed ? (jsx(Icon, { className: stepClasses.completedIcon, icon: CheckIcon, ...completedIconProps })) : index + 1 }));
|
|
16
|
+
return (jsxs("div", { className: cx(stepClasses.host, disabled && stepClasses.disabled, className), ref: ref, ...rest, children: [iconRender, /** title (optional) */ title && (jsx(Typography, { className: stepClasses.title, variant: "button2", ...titleProps, children: title })), children] }));
|
|
17
17
|
});
|
|
18
18
|
var Step$1 = Step;
|
|
19
19
|
|
package/Stepper/Stepper.js
CHANGED
|
@@ -27,7 +27,7 @@ const Stepper = forwardRef(function Stepper(props, ref) {
|
|
|
27
27
|
...step.props,
|
|
28
28
|
});
|
|
29
29
|
});
|
|
30
|
-
return (jsx("div",
|
|
30
|
+
return (jsx("div", { className: cx(stepperClasses.host, className), ref: ref, ...rest, children: stepsWithState }));
|
|
31
31
|
});
|
|
32
32
|
var Stepper$1 = Stepper;
|
|
33
33
|
|
package/Switch/Switch.js
CHANGED
|
@@ -18,12 +18,11 @@ const Switch = forwardRef(function Switch(props, ref) {
|
|
|
18
18
|
onChange: onChangeProp,
|
|
19
19
|
});
|
|
20
20
|
const disabled = loading || disabledProp;
|
|
21
|
-
return (jsxs("span",
|
|
21
|
+
return (jsxs("span", { ref: ref, ...rest, className: cx(switchClasses.host, {
|
|
22
22
|
[switchClasses.checked]: checked,
|
|
23
23
|
[switchClasses.disabled]: disabled,
|
|
24
24
|
[switchClasses.large]: size === 'large',
|
|
25
|
-
}, className)
|
|
26
|
-
jsx("input", Object.assign({}, inputProps, { "aria-checked": checked, "aria-disabled": disabled, checked: checked, className: switchClasses.input, disabled: disabled, onChange: onChange, type: "checkbox" }), void 0)] }), void 0));
|
|
25
|
+
}, className), children: [jsx("span", { className: switchClasses.control, children: loading && jsx(Icon, { icon: SwitchSpinnerIcon, spin: true }) }), jsx("input", { ...inputProps, "aria-checked": checked, "aria-disabled": disabled, checked: checked, className: switchClasses.input, disabled: disabled, onChange: onChange, type: "checkbox" })] }));
|
|
27
26
|
});
|
|
28
27
|
var Switch$1 = Switch;
|
|
29
28
|
|
package/Table/Table.d.ts
CHANGED
|
@@ -82,5 +82,5 @@ export interface TableWithPagination<T> extends TableBaseProps<T> {
|
|
|
82
82
|
fetchMore?: undefined;
|
|
83
83
|
}
|
|
84
84
|
export declare type TableProps<T> = TableWithFetchMore<T> | TableWithPagination<T>;
|
|
85
|
-
declare const Table: import("react").ForwardRefExoticComponent<
|
|
85
|
+
declare const Table: import("react").ForwardRefExoticComponent<TableProps<Record<string, unknown>> & import("react").RefAttributes<HTMLDivElement>>;
|
|
86
86
|
export default Table;
|
package/Table/Table.js
CHANGED
|
@@ -52,13 +52,9 @@ const Table = forwardRef(function Table(props, ref) {
|
|
|
52
52
|
/** Feature refresh */
|
|
53
53
|
const isRefreshShow = useMemo(() => {
|
|
54
54
|
var _a;
|
|
55
|
-
return (
|
|
55
|
+
return (
|
|
56
56
|
/** @default false */
|
|
57
|
-
refreshProp === null ||
|
|
58
|
-
/** @default false */
|
|
59
|
-
refreshProp === void 0 ? void 0 :
|
|
60
|
-
/** @default false */
|
|
61
|
-
refreshProp.show) !== null && _a !== void 0 ? _a : false);
|
|
57
|
+
(_a = refreshProp === null || refreshProp === void 0 ? void 0 : refreshProp.show) !== null && _a !== void 0 ? _a : false);
|
|
62
58
|
}, [refreshProp === null || refreshProp === void 0 ? void 0 : refreshProp.show]);
|
|
63
59
|
/** context */
|
|
64
60
|
const tableContextValue = useMemo(() => {
|
|
@@ -120,10 +116,7 @@ const Table = forwardRef(function Table(props, ref) {
|
|
|
120
116
|
const tableComponentContextValue = {
|
|
121
117
|
bodyCell: (_a = components === null || components === void 0 ? void 0 : components.body) === null || _a === void 0 ? void 0 : _a.cell,
|
|
122
118
|
};
|
|
123
|
-
return (jsx(Loading,
|
|
124
|
-
jsx(TableHeader, { className: headerClassName }, void 0),
|
|
125
|
-
jsx(TableBody, { ref: bodyRef, className: bodyClassName, rowClassName: bodyRowClassName }, void 0),
|
|
126
|
-
paginationProp ? (jsx(TablePagination, { bodyRef: bodyRef }, void 0)) : null] }), void 0) }), void 0) }), void 0) }), void 0) }), void 0));
|
|
119
|
+
return (jsx(Loading, { loading: loading, stretch: true, tip: "\u8CC7\u6599\u8F09\u5165\u4E2D...", children: jsx("div", { ref: ref, ...rest, className: cx(tableClasses.host, className), role: "grid", children: jsx(TableContext.Provider, { value: tableContextValue, children: jsx(TableDataContext.Provider, { value: tableDataContextValue, children: jsxs(TableComponentContext.Provider, { value: tableComponentContextValue, children: [isRefreshShow ? (jsx(TableRefresh, { onClick: refreshProp.onClick })) : null, jsx(TableHeader, { className: headerClassName }), jsx(TableBody, { ref: bodyRef, className: bodyClassName, rowClassName: bodyRowClassName }), paginationProp ? (jsx(TablePagination, { bodyRef: bodyRef })) : null] }) }) }) }) }));
|
|
127
120
|
});
|
|
128
121
|
var Table$1 = Table;
|
|
129
122
|
|
package/Table/TableBody.js
CHANGED
|
@@ -22,15 +22,13 @@ const TableBody = forwardRef(function TableBody(props, ref) {
|
|
|
22
22
|
const currentStartCount = (paginationOptions === null || paginationOptions === void 0 ? void 0 : paginationOptions.pageSize) && currentPage ? ((paginationOptions.pageSize) * (currentPage - 1)) : 0;
|
|
23
23
|
const currentEndCount = (paginationOptions === null || paginationOptions === void 0 ? void 0 : paginationOptions.pageSize) && currentPage && total ? (Math.min(((paginationOptions.pageSize) * currentPage), total)) : 0;
|
|
24
24
|
const currentDataSource = pagination && !disableAutoSlicing ? (dataSource.slice(currentStartCount, currentEndCount)) : dataSource;
|
|
25
|
-
return (jsxs("div",
|
|
26
|
-
(fetchMore === null || fetchMore === void 0 ? void 0 : fetchMore.isFetching) ? (jsx("div", Object.assign({ className: tableClasses.bodyFetchMore }, { children: jsx(Loading, { loading: true }, void 0) }), void 0)) : null,
|
|
27
|
-
jsx("div", Object.assign({ ref: scrollElement.ref, onMouseDown: scrollElement.onMouseDown, onMouseUp: scrollElement.onMouseUp, onMouseEnter: scrollElement.onMouseEnter, onMouseLeave: scrollElement.onMouseLeave, role: "button", style: scrollElement.style, tabIndex: -1 }, { children: jsx("div", { style: {
|
|
25
|
+
return (jsxs("div", { ...rest, ref: composedRefs, className: cx(tableClasses.body, className), onScroll: tableBody.onScroll, role: "rowgroup", children: [currentDataSource.length ? currentDataSource.map((rowData, index) => (jsx(TableBodyRow, { className: rowClassName, rowData: rowData, rowIndex: index }, (rowData.key || rowData.id)))) : (jsx(Empty, { ...restEmptyProps, className: cx(tableClasses.bodyEmpty, emptyComponentClassName), fullHeight: emptyComponentFullHeight, children: emptyComponentChildren })), (fetchMore === null || fetchMore === void 0 ? void 0 : fetchMore.isFetching) ? (jsx("div", { className: tableClasses.bodyFetchMore, children: jsx(Loading, { loading: true }) })) : null, jsx("div", { ref: scrollElement.ref, onMouseDown: scrollElement.onMouseDown, onMouseUp: scrollElement.onMouseUp, onMouseEnter: scrollElement.onMouseEnter, onMouseLeave: scrollElement.onMouseLeave, role: "button", style: scrollElement.style, tabIndex: -1, children: jsx("div", { style: {
|
|
28
26
|
width: `${scrollBarSize}px`,
|
|
29
27
|
height: '100%',
|
|
30
28
|
borderRadius: '10px',
|
|
31
29
|
backgroundColor: '#7d7d7d',
|
|
32
30
|
transition: '0.1s',
|
|
33
|
-
} }
|
|
31
|
+
} }) })] }));
|
|
34
32
|
});
|
|
35
33
|
var TableBody$1 = TableBody;
|
|
36
34
|
|