@mezzanine-ui/react 0.13.0 → 0.13.2
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/Loading/Loading.js +5 -2
- package/Select/Select.d.ts +8 -1
- package/Select/Select.js +14 -3
- package/Select/TreeSelect.d.ts +1 -1
- package/Select/TreeSelect.js +3 -1
- package/Select/typings.d.ts +1 -0
- package/Table/Table.d.ts +8 -2
- package/Table/Table.js +38 -23
- package/Table/TableBodyRow.js +19 -15
- package/Table/TableContext.d.ts +4 -1
- package/Table/draggable/useTableDraggable.d.ts +14 -0
- package/Table/draggable/useTableDraggable.js +63 -0
- package/Table/index.d.ts +2 -0
- package/Table/index.js +2 -0
- package/Table/sorting/useTableSorting.d.ts +2 -0
- package/Table/sorting/useTableSorting.js +1 -1
- package/Tree/TreeNode.js +5 -3
- package/Tree/useTreeExpandedValue.d.ts +1 -1
- package/Tree/useTreeExpandedValue.js +2 -1
- package/index.d.ts +2 -1
- package/index.js +3 -0
- package/package.json +6 -4
- package/utils/array-move.d.ts +1 -0
- package/utils/array-move.js +13 -0
package/Loading/Loading.js
CHANGED
|
@@ -10,12 +10,15 @@ import cx from 'clsx';
|
|
|
10
10
|
const Loading = forwardRef(function Loading(props, ref) {
|
|
11
11
|
const hostRef = useRef(null);
|
|
12
12
|
const { children, className, stretch = false, iconProps = {}, loading = false, overlayProps = {}, tip, tipClassName, } = props;
|
|
13
|
-
const { className: iconClassName, color: iconColor, ...iconPropsRest } = iconProps;
|
|
13
|
+
const { className: iconClassName, color: iconColor, size: iconSize, style: iconStyle, ...iconPropsRest } = iconProps;
|
|
14
14
|
const isNestedPattern = typeof children !== 'undefined';
|
|
15
15
|
const composedHostRef = useComposeRefs([ref, hostRef]);
|
|
16
16
|
const spinElement = loading ? (jsxs("div", { ref: isNestedPattern ? null : ref, className: cx(iconClasses.spin, {
|
|
17
17
|
[iconClasses.stretch]: stretch,
|
|
18
|
-
}), children: [jsx(Icon, { ...iconPropsRest, className: cx(iconClasses.icon, iconClassName), color: iconColor || 'primary', icon: SpinnerIcon, spin: true
|
|
18
|
+
}), children: [jsx(Icon, { ...iconPropsRest, className: cx(iconClasses.icon, iconClassName), color: iconColor || 'primary', icon: SpinnerIcon, spin: true, style: {
|
|
19
|
+
...(iconSize ? { fontSize: `${iconSize}px` } : {}),
|
|
20
|
+
...(iconStyle || {}),
|
|
21
|
+
} }), tip ? (jsx("span", { className: cx(iconClasses.tip, tipClassName), children: tip })) : null] })) : null;
|
|
19
22
|
if (isNestedPattern) {
|
|
20
23
|
return (jsxs("div", { ref: composedHostRef, className: cx(iconClasses.host, {
|
|
21
24
|
[iconClasses.stretch]: stretch,
|
package/Select/Select.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { PopperProps } from '../Popper';
|
|
|
6
6
|
import { SelectValue } from './typings';
|
|
7
7
|
import { PickRenameMulti } from '../utils/general';
|
|
8
8
|
import { SelectTriggerProps, SelectTriggerInputProps } from './SelectTrigger';
|
|
9
|
-
export interface SelectBaseProps extends Omit<SelectTriggerProps, 'active' | 'inputProps' | 'mode' | 'onBlur' | 'onChange' | 'onClick' | 'onFocus' | 'onKeyDown' | 'readOnly' | 'renderValue' | 'value'>, FormElementFocusHandlers, PickRenameMulti<Pick<MenuProps, 'itemsInView' | 'maxHeight' | 'role' | 'size'>, {
|
|
9
|
+
export interface SelectBaseProps extends Omit<SelectTriggerProps, 'active' | 'inputProps' | 'mode' | 'onBlur' | 'onChange' | 'onClick' | 'onFocus' | 'onKeyDown' | 'onScroll' | 'readOnly' | 'renderValue' | 'value'>, FormElementFocusHandlers, PickRenameMulti<Pick<MenuProps, 'itemsInView' | 'maxHeight' | 'role' | 'size'>, {
|
|
10
10
|
maxHeight: 'menuMaxHeight';
|
|
11
11
|
role: 'menuRole';
|
|
12
12
|
size: 'menuSize';
|
|
@@ -18,6 +18,13 @@ export interface SelectBaseProps extends Omit<SelectTriggerProps, 'active' | 'in
|
|
|
18
18
|
* The other native props for input element.
|
|
19
19
|
*/
|
|
20
20
|
inputProps?: Omit<SelectTriggerInputProps, 'onBlur' | 'onChange' | 'onFocus' | 'placeholder' | 'role' | 'value' | `aria-${'controls' | 'expanded' | 'owns'}`>;
|
|
21
|
+
/**
|
|
22
|
+
* Popup menu scroll listener
|
|
23
|
+
*/
|
|
24
|
+
onMenuScroll?: (computed: {
|
|
25
|
+
scrollTop: number;
|
|
26
|
+
maxScrollTop: number;
|
|
27
|
+
}, target: HTMLUListElement) => void;
|
|
21
28
|
/**
|
|
22
29
|
* select input placeholder
|
|
23
30
|
*/
|
package/Select/Select.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import { forwardRef, useContext, useState, useRef, useMemo } from 'react';
|
|
2
|
+
import { forwardRef, useContext, useState, useRef, useCallback, useMemo } from 'react';
|
|
3
3
|
import { selectClasses } from '@mezzanine-ui/core/select';
|
|
4
4
|
import isArray from 'lodash/isArray';
|
|
5
5
|
import { useComposeRefs } from '../hooks/useComposeRefs.js';
|
|
@@ -16,7 +16,7 @@ const MENU_ID = 'mzn-select-menu-id';
|
|
|
16
16
|
const Select = forwardRef(function Select(props, ref) {
|
|
17
17
|
var _a, _b;
|
|
18
18
|
const { disabled: disabledFromFormControl, fullWidth: fullWidthFromFormControl, required: requiredFromFormControl, severity, } = useContext(FormControlContext) || {};
|
|
19
|
-
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, placeholder = '', popperOptions = {}, prefix, renderValue, required = requiredFromFormControl || false, size, suffixActionIcon, value: valueProp, } = props;
|
|
19
|
+
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;
|
|
20
20
|
const [open, toggleOpen] = useState(false);
|
|
21
21
|
const onOpen = () => {
|
|
22
22
|
onFocus === null || onFocus === void 0 ? void 0 : onFocus();
|
|
@@ -98,6 +98,17 @@ const Select = forwardRef(function Select(props, ref) {
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
|
+
/** menu onScroll listener */
|
|
102
|
+
const onMenuScrollCallback = useCallback(async (evt) => {
|
|
103
|
+
if (onMenuScroll) {
|
|
104
|
+
const target = evt.target;
|
|
105
|
+
const maxScrollTop = target.scrollHeight - target.getBoundingClientRect().height;
|
|
106
|
+
onMenuScroll({
|
|
107
|
+
scrollTop: target.scrollTop,
|
|
108
|
+
maxScrollTop,
|
|
109
|
+
}, target);
|
|
110
|
+
}
|
|
111
|
+
}, [onMenuScroll]);
|
|
101
112
|
const resolvedInputProps = {
|
|
102
113
|
...inputProps,
|
|
103
114
|
'aria-controls': MENU_ID,
|
|
@@ -110,7 +121,7 @@ const Select = forwardRef(function Select(props, ref) {
|
|
|
110
121
|
onChange,
|
|
111
122
|
value,
|
|
112
123
|
}), [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, 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, role: menuRole, size: menuSize, style: { border: 0 }, children: children }) })] }) }));
|
|
124
|
+
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, 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 }) })] }) }));
|
|
114
125
|
});
|
|
115
126
|
var Select$1 = Select;
|
|
116
127
|
|
package/Select/TreeSelect.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { InputTriggerPopperProps } from '../_internal/InputTriggerPopper';
|
|
|
7
7
|
import { SelectTriggerProps, SelectTriggerInputProps } from './SelectTrigger';
|
|
8
8
|
import { SelectValue, TreeSelectOption } from './typings';
|
|
9
9
|
import { TreeProps } from '../Tree';
|
|
10
|
-
export interface TreeSelectProps extends Omit<SelectTriggerProps, 'active' | 'onBlur' | 'onChange' | 'onClear' | 'onClick' | 'onFocus' | 'onKeyDown' | 'readOnly' | 'searchInputProps'>, FormElementFocusHandlers, Pick<TreeProps, 'defaultExpandAll' | 'disabledValues' | 'expandControllerRef'>, PickRenameMulti<Pick<MenuProps, 'itemsInView' | 'maxHeight' | 'role' | 'size'>, {
|
|
10
|
+
export interface TreeSelectProps extends Omit<SelectTriggerProps, 'active' | 'onBlur' | 'onChange' | 'onClear' | 'onClick' | 'onFocus' | 'onKeyDown' | 'readOnly' | 'searchInputProps'>, FormElementFocusHandlers, Pick<TreeProps, 'defaultExpandAll' | 'disabledValues' | 'expandControllerRef' | 'onExpand'>, PickRenameMulti<Pick<MenuProps, 'itemsInView' | 'maxHeight' | 'role' | 'size'>, {
|
|
11
11
|
maxHeight: 'menuMaxHeight';
|
|
12
12
|
role: 'menuRole';
|
|
13
13
|
size: 'menuSize';
|
package/Select/TreeSelect.js
CHANGED
|
@@ -14,7 +14,7 @@ import cx from 'clsx';
|
|
|
14
14
|
|
|
15
15
|
const TreeSelect = forwardRef((props, ref) => {
|
|
16
16
|
const { disabled: disabledFromFormControl, fullWidth: fullWidthFromFormControl, required: requiredFromFormControl, severity, } = useContext(FormControlContext) || {};
|
|
17
|
-
const { className, clearable = false, defaultExpandAll, depth, disabled = disabledFromFormControl || false, disabledValues, error = severity === 'error' || false, expandControllerRef, fullWidth = fullWidthFromFormControl || false, inputProps, inputRef, itemsInView = 4, menuMaxHeight, menuProps, menuRole = 'listbox', menuSize, mode = 'single', onBlur, onChange: onChangeProp, onFocus, options, placeholder = '', popperOptions, prefix, renderValue, required = requiredFromFormControl || false, sameWidth = false, size, suffixActionIcon, treeProps, value: valueProp, } = props;
|
|
17
|
+
const { className, clearable = false, defaultExpandAll, depth, disabled = disabledFromFormControl || false, disabledValues, error = severity === 'error' || false, expandControllerRef, fullWidth = fullWidthFromFormControl || false, inputProps, inputRef, itemsInView = 4, menuMaxHeight, menuProps, menuRole = 'listbox', menuSize, mode = 'single', onBlur, onChange: onChangeProp, onExpand: onExpandProp, onFocus, options, placeholder = '', popperOptions, prefix, renderValue, required = requiredFromFormControl || false, sameWidth = false, size, suffixActionIcon, treeProps, value: valueProp, } = props;
|
|
18
18
|
const { className: treeClassName, ...restTreeProps } = treeProps || {};
|
|
19
19
|
const { width, border, ...restStyle } = (menuProps === null || menuProps === void 0 ? void 0 : menuProps.style) || {};
|
|
20
20
|
const multiple = mode === 'multiple';
|
|
@@ -142,6 +142,7 @@ const TreeSelect = forwardRef((props, ref) => {
|
|
|
142
142
|
return {
|
|
143
143
|
label: option.name,
|
|
144
144
|
value: option.id,
|
|
145
|
+
dynamicNodesFetching: option.dynamicChildrenFetching,
|
|
145
146
|
nodes: (_a = option.siblings) === null || _a === void 0 ? void 0 : _a.map((sibling) => mapOptionToNode(sibling)),
|
|
146
147
|
};
|
|
147
148
|
}
|
|
@@ -186,6 +187,7 @@ const TreeSelect = forwardRef((props, ref) => {
|
|
|
186
187
|
const onExpand = (value) => {
|
|
187
188
|
const newExpandedValues = toggleValue(value, expandedValues);
|
|
188
189
|
setExpandedValues(newExpandedValues);
|
|
190
|
+
onExpandProp === null || onExpandProp === void 0 ? void 0 : onExpandProp(value);
|
|
189
191
|
};
|
|
190
192
|
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: {
|
|
191
193
|
...restStyle,
|
package/Select/typings.d.ts
CHANGED
package/Table/Table.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { TableColumn, TableComponents, TableDataSource, TableRowSelection, TableExpandable, TableFetchMore, TablePagination as TablePaginationType, TableRefresh as TableRefreshType, ExpandRowBySources, TableScrolling } from '@mezzanine-ui/core/table';
|
|
2
|
+
import { TableColumn, TableComponents, TableDataSource, TableRowSelection, TableExpandable, TableFetchMore, TablePagination as TablePaginationType, TableRefresh as TableRefreshType, ExpandRowBySources, TableScrolling, TableDraggable } from '@mezzanine-ui/core/table';
|
|
3
3
|
import { EmptyProps } from '../Empty';
|
|
4
4
|
import { NativeElementPropsWithoutKeyAndRef } from '../utils/jsx-types';
|
|
5
|
-
export interface TableBaseProps<T> extends Omit<NativeElementPropsWithoutKeyAndRef<'div'>, 'role'> {
|
|
5
|
+
export interface TableBaseProps<T> extends Omit<NativeElementPropsWithoutKeyAndRef<'div'>, 'role' | 'draggable'> {
|
|
6
6
|
/**
|
|
7
7
|
* customized body className
|
|
8
8
|
*/
|
|
@@ -28,6 +28,12 @@ export interface TableBaseProps<T> extends Omit<NativeElementPropsWithoutKeyAndR
|
|
|
28
28
|
* Notice that each source should contain `key` or `id` prop as data primary key.
|
|
29
29
|
*/
|
|
30
30
|
dataSource: TableDataSource[];
|
|
31
|
+
/**
|
|
32
|
+
* Draggable table row. This feature allows sort items by mouse dragging. Not supported when `fetchMore` is enabled and also buggy when use finger touch (mobile device).
|
|
33
|
+
* When `draggable.enabled` is true, draggable will be enabled.
|
|
34
|
+
* `draggable.onDragEnd` return new dataSource for you
|
|
35
|
+
*/
|
|
36
|
+
draggable?: TableDraggable;
|
|
31
37
|
/**
|
|
32
38
|
* props exported from `<Empty />` component.
|
|
33
39
|
*/
|
package/Table/Table.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import { forwardRef, useRef, useMemo } from 'react';
|
|
2
|
+
import { forwardRef, useRef, useMemo, Fragment } from 'react';
|
|
3
|
+
import { DragDropContext, Droppable } from 'react-beautiful-dnd';
|
|
3
4
|
import { tableClasses } from '@mezzanine-ui/core/table';
|
|
4
5
|
import { TableContext, TableDataContext, TableComponentContext } from './TableContext.js';
|
|
5
6
|
import TableHeader from './TableHeader.js';
|
|
@@ -10,14 +11,16 @@ import { useTableRowSelection } from './rowSelection/useTableRowSelection.js';
|
|
|
10
11
|
import { useTableSorting } from './sorting/useTableSorting.js';
|
|
11
12
|
import { useTableLoading } from './useTableLoading.js';
|
|
12
13
|
import { useTableFetchMore } from './useTableFetchMore.js';
|
|
14
|
+
import { useTableDraggable } from './draggable/useTableDraggable.js';
|
|
13
15
|
import useTableScroll from './useTableScroll.js';
|
|
14
16
|
import { useComposeRefs } from '../hooks/useComposeRefs.js';
|
|
17
|
+
import { composeRefs } from '../utils/composeRefs.js';
|
|
15
18
|
import Loading from '../Loading/Loading.js';
|
|
16
19
|
import cx from 'clsx';
|
|
17
20
|
|
|
18
21
|
const Table = forwardRef(function Table(props, ref) {
|
|
19
22
|
var _a;
|
|
20
|
-
const { bodyClassName, bodyRowClassName, className, columns, components, dataSource: dataSourceProp, emptyProps, expandable: expandableProp, fetchMore: fetchMoreProp, headerClassName, loading: loadingProp, loadingTip = '資料載入中...', pagination: paginationProp, refresh: refreshProp, rowSelection: rowSelectionProp, scroll: scrollProp, scrollContainerClassName, ...rest } = props;
|
|
23
|
+
const { bodyClassName, bodyRowClassName, className, columns, components, dataSource: dataSourceProp, draggable: draggableProp, emptyProps, expandable: expandableProp, fetchMore: fetchMoreProp, headerClassName, loading: loadingProp, loadingTip = '資料載入中...', pagination: paginationProp, refresh: refreshProp, rowSelection: rowSelectionProp, scroll: scrollProp, scrollContainerClassName, ...rest } = props;
|
|
21
24
|
const bodyRef = useRef(null);
|
|
22
25
|
/** Feature rowSelection */
|
|
23
26
|
const [selectedRowKeys, setSelectedRowKey] = useTableRowSelection({
|
|
@@ -35,7 +38,7 @@ const Table = forwardRef(function Table(props, ref) {
|
|
|
35
38
|
setSelectedRowKey,
|
|
36
39
|
]);
|
|
37
40
|
/** Feature sorting */
|
|
38
|
-
const [dataSource, onSort, { sortedOn, sortedType, onResetAll }] = useTableSorting({
|
|
41
|
+
const [dataSource, onSort, { sortedOn, sortedType, onResetAll, setDataSource, }] = useTableSorting({
|
|
39
42
|
dataSource: dataSourceProp,
|
|
40
43
|
});
|
|
41
44
|
/** Feature loading */
|
|
@@ -64,6 +67,12 @@ const Table = forwardRef(function Table(props, ref) {
|
|
|
64
67
|
loading,
|
|
65
68
|
scrollBarSize: 4,
|
|
66
69
|
});
|
|
70
|
+
/** Feature drag and drop */
|
|
71
|
+
const { draggingId, onBeforeDragStart, onDragEnd, } = useTableDraggable({
|
|
72
|
+
dataSource,
|
|
73
|
+
setDataSource,
|
|
74
|
+
draggable: draggableProp,
|
|
75
|
+
});
|
|
67
76
|
/** context */
|
|
68
77
|
const tableContextValue = useMemo(() => {
|
|
69
78
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
@@ -98,6 +107,10 @@ const Table = forwardRef(function Table(props, ref) {
|
|
|
98
107
|
},
|
|
99
108
|
} : undefined,
|
|
100
109
|
scroll: scrollProp,
|
|
110
|
+
draggable: draggableProp ? {
|
|
111
|
+
...draggableProp,
|
|
112
|
+
draggingId,
|
|
113
|
+
} : undefined,
|
|
101
114
|
});
|
|
102
115
|
}, [
|
|
103
116
|
dataSource,
|
|
@@ -116,6 +129,8 @@ const Table = forwardRef(function Table(props, ref) {
|
|
|
116
129
|
paginationProp,
|
|
117
130
|
isHorizontalScrolling,
|
|
118
131
|
scrollProp,
|
|
132
|
+
draggableProp,
|
|
133
|
+
draggingId,
|
|
119
134
|
]);
|
|
120
135
|
const tableDataContextValue = useMemo(() => ({
|
|
121
136
|
columns,
|
|
@@ -128,26 +143,26 @@ const Table = forwardRef(function Table(props, ref) {
|
|
|
128
143
|
});
|
|
129
144
|
}, [(_a = components === null || components === void 0 ? void 0 : components.body) === null || _a === void 0 ? void 0 : _a.cell]);
|
|
130
145
|
const tableRefs = useComposeRefs([ref, scrollBody.target]);
|
|
131
|
-
return (jsx(TableContext.Provider, { value: tableContextValue, children: jsx(TableDataContext.Provider, { value: tableDataContextValue, children: jsx(TableComponentContext.Provider, { value: tableComponentContextValue, children:
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
146
|
+
return (jsx(TableContext.Provider, { value: tableContextValue, children: jsx(TableDataContext.Provider, { value: tableDataContextValue, children: jsx(TableComponentContext.Provider, { value: tableComponentContextValue, children: jsx(DragDropContext, { onBeforeDragStart: onBeforeDragStart, onDragEnd: onDragEnd, children: jsx(Loading, { loading: loading, stretch: true, tip: loadingTip, overlayProps: {
|
|
147
|
+
className: tableClasses.loading,
|
|
148
|
+
}, children: jsx(Droppable, { droppableId: "mzn-table-dnd", isDropDisabled: !(draggableProp === null || draggableProp === void 0 ? void 0 : draggableProp.enabled), children: (provided) => (jsxs(Fragment, { children: [jsx("div", { ...provided.droppableProps, ref: composeRefs([scrollBody.ref, provided.innerRef]), className: cx(tableClasses.scrollContainer, scrollContainerClassName), onScroll: scrollBody.onScroll, style: tableContextValue.scroll ? {
|
|
149
|
+
'--table-scroll-x': tableContextValue.scroll.x
|
|
150
|
+
? `${tableContextValue.scroll.x}px`
|
|
151
|
+
: '100%',
|
|
152
|
+
'--table-scroll-y': tableContextValue.scroll.y
|
|
153
|
+
? `${tableContextValue.scroll.y}px`
|
|
154
|
+
: 'unset',
|
|
155
|
+
} : undefined, children: jsxs("table", { ref: tableRefs, ...rest, className: cx(tableClasses.host, className), children: [isRefreshShow ? (jsx("tbody", { children: jsx("tr", { children: jsx("td", { children: jsx(TableRefresh, { onClick: refreshProp.onClick }) }) }) })) : null, jsx(TableHeader, { className: headerClassName }), jsx(TableBody, { ref: bodyRef, className: bodyClassName, rowClassName: bodyRowClassName }), jsx("tbody", { children: provided.placeholder })] }) }), paginationProp ? (jsx(TablePagination, { bodyRef: bodyRef })) : null, jsx("div", { ref: scrollElement.trackRef, style: scrollElement.trackStyle, onMouseDown: scrollElement.onMouseDown, onMouseUp: scrollElement.onMouseUp, role: "button", tabIndex: -1, className: "mzn-table-scroll-bar-track", children: jsx("div", { style: {
|
|
156
|
+
width: '100%',
|
|
157
|
+
height: '100%',
|
|
158
|
+
position: 'relative',
|
|
159
|
+
}, children: jsx("div", { ref: scrollElement.ref, onMouseDown: scrollElement.onMouseDown, onMouseUp: scrollElement.onMouseUp, onMouseEnter: scrollElement.onMouseEnter, onMouseLeave: scrollElement.onMouseLeave, role: "button", style: scrollElement.style, tabIndex: -1, className: "mzn-table-scroll-bar", children: jsx("div", { style: {
|
|
160
|
+
width: `${scrollElement.scrollBarSize}px`,
|
|
161
|
+
height: '100%',
|
|
162
|
+
borderRadius: '10px',
|
|
163
|
+
backgroundColor: '#7d7d7d',
|
|
164
|
+
transition: '0.1s',
|
|
165
|
+
} }) }) }) })] })) }) }) }) }) }) }));
|
|
151
166
|
});
|
|
152
167
|
var Table$1 = Table;
|
|
153
168
|
|
package/Table/TableBodyRow.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { forwardRef, useContext, useState, useMemo, Fragment } from 'react';
|
|
3
3
|
import { tableClasses, getColumnStyle, getCellStyle } from '@mezzanine-ui/core/table';
|
|
4
|
+
import { Draggable } from 'react-beautiful-dnd';
|
|
4
5
|
import get from 'lodash/get';
|
|
5
6
|
import { TableContext, TableDataContext } from './TableContext.js';
|
|
6
7
|
import TableCell from './TableCell.js';
|
|
@@ -9,11 +10,12 @@ import TableRowSelection from './rowSelection/TableRowSelection.js';
|
|
|
9
10
|
import TableExpandable from './expandable/TableExpandable.js';
|
|
10
11
|
import TableEditRenderWrapper from './editable/TableEditRenderWrapper.js';
|
|
11
12
|
import AccordionDetails from '../Accordion/AccordionDetails.js';
|
|
13
|
+
import { composeRefs } from '../utils/composeRefs.js';
|
|
12
14
|
import cx from 'clsx';
|
|
13
15
|
|
|
14
16
|
const TableBodyRow = forwardRef(function TableBodyRow(props, ref) {
|
|
15
17
|
const { className, rowData, rowIndex, ...rest } = props;
|
|
16
|
-
const { rowSelection, expanding, isHorizontalScrolling, scroll, } = useContext(TableContext) || {};
|
|
18
|
+
const { rowSelection, expanding, isHorizontalScrolling, scroll, draggable, } = useContext(TableContext) || {};
|
|
17
19
|
const { columns, } = useContext(TableDataContext) || {};
|
|
18
20
|
/** Feature rowSelection */
|
|
19
21
|
const [selected, setSelected] = useState(false);
|
|
@@ -39,20 +41,22 @@ const TableBodyRow = forwardRef(function TableBodyRow(props, ref) {
|
|
|
39
41
|
expanding,
|
|
40
42
|
scroll === null || scroll === void 0 ? void 0 : scroll.fixedFirstColumn,
|
|
41
43
|
]);
|
|
42
|
-
return (jsxs(Fragment, { children: [jsxs("tr", { ...rest, ref: ref, className: cx(tableClasses.bodyRow, {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
44
|
+
return (jsxs(Fragment, { children: [jsx(Draggable, { index: rowIndex, draggableId: rowData.key || rowData.id, isDragDisabled: !(draggable === null || draggable === void 0 ? void 0 : draggable.enabled), children: (draggableProvided) => (jsxs("tr", { ...rest, ...draggableProvided.draggableProps, ...draggableProvided.dragHandleProps, ref: composeRefs([ref, draggableProvided.innerRef]), className: cx(tableClasses.bodyRow, {
|
|
45
|
+
[tableClasses.bodyRowHighlight]: selected || expanded,
|
|
46
|
+
[tableClasses.bodyRowDragging]: (draggable === null || draggable === void 0 ? void 0 : draggable.draggingId)
|
|
47
|
+
&& draggable.draggingId === (rowData.key || rowData.id),
|
|
48
|
+
}, className), children: [rowSelection ? (jsx("td", { className: tableClasses.bodyRowCellWrapper, style: {
|
|
49
|
+
flex: 'unset',
|
|
50
|
+
minWidth: 'unset',
|
|
51
|
+
}, children: jsx(TableRowSelection, { rowKey: (rowData.key || rowData.id), setChecked: (status) => setSelected(status), showDropdownIcon: false }) })) : null, expanding ? (jsx("td", { className: tableClasses.bodyRowCellWrapper, style: {
|
|
52
|
+
flex: 'unset',
|
|
53
|
+
minWidth: 'unset',
|
|
54
|
+
}, children: jsx(TableExpandable, { expandable: isExpandable, expanded: expanded, setExpanded: setExpanded, onExpand: (status) => { var _a; return (_a = expanding.onExpand) === null || _a === void 0 ? void 0 : _a.call(expanding, rowData, status); } }) })) : null, (columns !== null && columns !== void 0 ? columns : []).map((column, idx) => {
|
|
55
|
+
var _a, _b, _c, _d;
|
|
56
|
+
const ellipsis = !!(get(rowData, column.dataIndex)) && ((_a = column.ellipsis) !== null && _a !== void 0 ? _a : true);
|
|
57
|
+
const tooltipTitle = ((_c = (_b = column.renderTooltipTitle) === null || _b === void 0 ? void 0 : _b.call(column, rowData)) !== null && _c !== void 0 ? _c : get(rowData, column.dataIndex));
|
|
58
|
+
return (jsx("td", { className: cx(tableClasses.bodyRowCellWrapper, isFirstColumnShouldSticky && idx === 0 && tableClasses.bodyRowCellWrapperFixed, isFirstColumnShouldSticky && idx === 0 && isHorizontalScrolling && tableClasses.bodyRowCellWrapperFixedStuck, column.bodyClassName), style: getColumnStyle(column), children: jsx(TableEditRenderWrapper, { ...column, rowData: rowData, children: jsx(TableCell, { ellipsis: ellipsis, forceShownTooltipWhenHovered: column.forceShownTooltipWhenHovered, style: getCellStyle(column), tooltipTitle: tooltipTitle, children: ((_d = column.render) === null || _d === void 0 ? void 0 : _d.call(column, rowData, rowIndex, column)) || get(rowData, column.dataIndex) }) }) }, `${column.dataIndex}-${column.title}`));
|
|
59
|
+
})] })) }, rowData.key || rowData.id), renderedExpandedContent ? (jsx("tr", { children: jsx("td", { style: { padding: 0 }, children: jsx(AccordionDetails, { className: cx(expanding.className, tableClasses.bodyRowExpandedTableWrapper), expanded: expanded, children: (renderedExpandedContent === null || renderedExpandedContent === void 0 ? void 0 : renderedExpandedContent.dataSource) ? (jsx(TableExpandedTable, { renderedExpandedContent: renderedExpandedContent })) : renderedExpandedContent }) }) })) : null] }));
|
|
56
60
|
});
|
|
57
61
|
var TableBodyRow$1 = TableBodyRow;
|
|
58
62
|
|
package/Table/TableContext.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { TableRowSelection, TableColumn, TableExpandable, TablePagination, TableDataSource, TableRecord, ExpandRowBySources, TableScrolling } from '@mezzanine-ui/core/table';
|
|
2
|
+
import { TableRowSelection, TableColumn, TableExpandable, TablePagination, TableDataSource, TableRecord, ExpandRowBySources, TableScrolling, TableDraggable } from '@mezzanine-ui/core/table';
|
|
3
3
|
import { EmptyProps } from '../Empty';
|
|
4
4
|
/** typeof rowSelection */
|
|
5
5
|
export interface RowSelectionContext extends Pick<TableRowSelection, 'actions'> {
|
|
@@ -36,6 +36,9 @@ export interface TableContextProps {
|
|
|
36
36
|
fetchMore?: FetchMoreContext;
|
|
37
37
|
pagination?: TablePagination;
|
|
38
38
|
scroll?: TableScrolling;
|
|
39
|
+
draggable?: TableDraggable & {
|
|
40
|
+
draggingId: string;
|
|
41
|
+
};
|
|
39
42
|
}
|
|
40
43
|
export declare const TableContext: import("react").Context<TableContextProps | null>;
|
|
41
44
|
export interface TableDataContextProps {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
import { TableDataSource, TableDraggable } from '@mezzanine-ui/core/table';
|
|
3
|
+
export interface UseTableDraggable {
|
|
4
|
+
dataSource: TableDataSource[];
|
|
5
|
+
setDataSource: Dispatch<SetStateAction<TableDataSource[]>>;
|
|
6
|
+
draggable?: TableDraggable;
|
|
7
|
+
}
|
|
8
|
+
export declare function useTableDraggable(props: UseTableDraggable): {
|
|
9
|
+
draggingId: string;
|
|
10
|
+
onBeforeDragStart: (e: {
|
|
11
|
+
draggableId: SetStateAction<string>;
|
|
12
|
+
}) => void;
|
|
13
|
+
onDragEnd: import("react-beautiful-dnd").OnDragEndResponder;
|
|
14
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { useRef, useState, useEffect, useCallback } from 'react';
|
|
2
|
+
import isEqual from 'lodash/isEqual';
|
|
3
|
+
import debounce from 'lodash/debounce';
|
|
4
|
+
import { arrayMove } from '../../utils/array-move.js';
|
|
5
|
+
import { usePreviousValue } from '../../hooks/usePreviousValue.js';
|
|
6
|
+
|
|
7
|
+
function useTableDraggable(props) {
|
|
8
|
+
const { dataSource, setDataSource, draggable } = props;
|
|
9
|
+
const resultSnapshot = useRef(null);
|
|
10
|
+
const dataSnapShot = useRef(dataSource);
|
|
11
|
+
const isDragging = useRef(false);
|
|
12
|
+
const [draggingId, setDraggingId] = useState('');
|
|
13
|
+
const prevDataSource = usePreviousValue(dataSource);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (!isEqual(prevDataSource, dataSource)) {
|
|
16
|
+
dataSnapShot.current = dataSource;
|
|
17
|
+
}
|
|
18
|
+
}, [prevDataSource, dataSource]);
|
|
19
|
+
const onBeforeDragStart = useCallback((e) => {
|
|
20
|
+
isDragging.current = true;
|
|
21
|
+
setDraggingId(e.draggableId);
|
|
22
|
+
}, []);
|
|
23
|
+
const onDragEnd = useCallback(async (result, id) => {
|
|
24
|
+
var _a, _b;
|
|
25
|
+
resultSnapshot.current = [result, id];
|
|
26
|
+
isDragging.current = false;
|
|
27
|
+
setDraggingId('');
|
|
28
|
+
const temp = [...dataSnapShot.current];
|
|
29
|
+
const from = result.source.index;
|
|
30
|
+
const to = (_b = (_a = result.destination) === null || _a === void 0 ? void 0 : _a.index) !== null && _b !== void 0 ? _b : from;
|
|
31
|
+
const newData = arrayMove(temp, from, to);
|
|
32
|
+
dataSnapShot.current = newData;
|
|
33
|
+
setDataSource(newData);
|
|
34
|
+
}, [setDataSource]);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (!(draggable === null || draggable === void 0 ? void 0 : draggable.enabled))
|
|
37
|
+
return () => { };
|
|
38
|
+
async function onMouseUp() {
|
|
39
|
+
var _a, _b, _c;
|
|
40
|
+
if (isDragging.current)
|
|
41
|
+
return;
|
|
42
|
+
const args = resultSnapshot.current;
|
|
43
|
+
resultSnapshot.current = null;
|
|
44
|
+
if (!(args === null || args === void 0 ? void 0 : args[0]) || ((_a = args === null || args === void 0 ? void 0 : args[0]) === null || _a === void 0 ? void 0 : _a.source.index) === ((_c = (_b = args === null || args === void 0 ? void 0 : args[0]) === null || _b === void 0 ? void 0 : _b.destination) === null || _c === void 0 ? void 0 : _c.index))
|
|
45
|
+
return;
|
|
46
|
+
if ((draggable === null || draggable === void 0 ? void 0 : draggable.onDragEnd) && args) {
|
|
47
|
+
draggable.onDragEnd(Array.from(dataSnapShot.current));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const debouncedOnMouseUp = debounce(onMouseUp, 500);
|
|
51
|
+
window.addEventListener('mouseup', debouncedOnMouseUp, false);
|
|
52
|
+
return () => {
|
|
53
|
+
window.removeEventListener('mouseup', debouncedOnMouseUp, false);
|
|
54
|
+
};
|
|
55
|
+
}, [draggable]);
|
|
56
|
+
return {
|
|
57
|
+
draggingId,
|
|
58
|
+
onBeforeDragStart,
|
|
59
|
+
onDragEnd,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export { useTableDraggable };
|
package/Table/index.d.ts
CHANGED
|
@@ -2,3 +2,5 @@ export { TableProps, default, } from './Table';
|
|
|
2
2
|
export { TableRefreshProps, default as TableRefresh, } from './refresh/TableRefresh';
|
|
3
3
|
export { TableCellProps, default as TableCell, } from './TableCell';
|
|
4
4
|
export { EditableBodyCellProps, } from './editable/TableEditRenderWrapper';
|
|
5
|
+
export { useTableDraggable, } from './draggable/useTableDraggable';
|
|
6
|
+
export { default as useTableScroll, } from './useTableScroll';
|
package/Table/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { default } from './Table.js';
|
|
2
2
|
export { default as TableRefresh } from './refresh/TableRefresh.js';
|
|
3
3
|
export { default as TableCell } from './TableCell.js';
|
|
4
|
+
export { useTableDraggable } from './draggable/useTableDraggable.js';
|
|
5
|
+
export { default as useTableScroll } from './useTableScroll.js';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { TableDataSource, TableColumn, TableRecord } from '@mezzanine-ui/core/table';
|
|
2
3
|
export interface UseTableSorting {
|
|
3
4
|
dataSource: TableDataSource[];
|
|
@@ -7,4 +8,5 @@ export declare function useTableSorting(props: UseTableSorting): readonly [Table
|
|
|
7
8
|
readonly sortedOn: string;
|
|
8
9
|
readonly sortedType: SortedType;
|
|
9
10
|
readonly onResetAll: () => void;
|
|
11
|
+
readonly setDataSource: import("react").Dispatch<import("react").SetStateAction<TableDataSource[]>>;
|
|
10
12
|
}];
|
|
@@ -107,7 +107,7 @@ function useTableSorting(props) {
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
});
|
|
110
|
-
return [dataSource, onChange, { sortedOn, sortedType, onResetAll }];
|
|
110
|
+
return [dataSource, onChange, { sortedOn, sortedType, onResetAll, setDataSource }];
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
export { useTableSorting };
|
package/Tree/TreeNode.js
CHANGED
|
@@ -4,6 +4,7 @@ import { CaretRightIcon } from '@mezzanine-ui/icons';
|
|
|
4
4
|
import { forwardRef, useContext, useMemo } from 'react';
|
|
5
5
|
import Typography from '../Typography/Typography.js';
|
|
6
6
|
import { MezzanineConfig } from '../Provider/context.js';
|
|
7
|
+
import Loading from '../Loading/Loading.js';
|
|
7
8
|
import Icon from '../Icon/Icon.js';
|
|
8
9
|
import Checkbox from '../Checkbox/Checkbox.js';
|
|
9
10
|
import Collapse from '../Transition/Collapse.js';
|
|
@@ -14,7 +15,7 @@ import cx from 'clsx';
|
|
|
14
15
|
*/
|
|
15
16
|
const TreeNode = forwardRef(function TreeNode(props, ref) {
|
|
16
17
|
const { size: globalSize, } = useContext(MezzanineConfig);
|
|
17
|
-
const { children, className, disabled, expanded, indeterminate, label, multiple = false, onExpand: onExpandProp, onSelect: onSelectProp, selectable = false, selected, size = globalSize, value, ...restRootProps } = props;
|
|
18
|
+
const { children, className, disabled, dynamicNodesFetching, expanded, indeterminate, label, multiple = false, onExpand: onExpandProp, onSelect: onSelectProp, selectable = false, selected, size = globalSize, value, ...restRootProps } = props;
|
|
18
19
|
const variant = useMemo(() => {
|
|
19
20
|
if (size === 'small') {
|
|
20
21
|
return 'input3';
|
|
@@ -26,7 +27,8 @@ const TreeNode = forwardRef(function TreeNode(props, ref) {
|
|
|
26
27
|
}, [size]);
|
|
27
28
|
const onExpand = onExpandProp ? () => { onExpandProp(value); } : undefined;
|
|
28
29
|
const onSelect = selectable && onSelectProp && !disabled ? () => { onSelectProp(value); } : undefined;
|
|
29
|
-
|
|
30
|
+
const mayHaveChildren = children || dynamicNodesFetching;
|
|
31
|
+
return (jsxs("li", { ref: ref, ...restRootProps, className: cx(treeClasses.node, treeClasses.nodeSize(size), className), children: [jsxs("div", { className: treeClasses.nodeStem, children: [mayHaveChildren ? (jsx(Icon, { icon: CaretRightIcon, className: cx(treeClasses.nodeCaret, {
|
|
30
32
|
[treeClasses.nodeCaretExpanded]: expanded,
|
|
31
33
|
}), role: "button", onClick: onExpand })) : (jsx("div", {})), multiple
|
|
32
34
|
? (jsx(Checkbox, { checked: !!selected, disabled: disabled, indeterminate: indeterminate, onChange: onSelect, size: size, value: `${value}`, children: label }))
|
|
@@ -35,7 +37,7 @@ const TreeNode = forwardRef(function TreeNode(props, ref) {
|
|
|
35
37
|
[treeClasses.nodeLabelIndeterminate]: indeterminate,
|
|
36
38
|
[treeClasses.nodeLabelActive]: selected,
|
|
37
39
|
[treeClasses.nodeLabelDisabled]: disabled,
|
|
38
|
-
}), children: label }))] }),
|
|
40
|
+
}), children: label }))] }), mayHaveChildren && (jsx(Collapse, { in: expanded, appear: false, children: children || jsx(Loading, { loading: true, iconProps: { size: 16 } }) }))] }));
|
|
39
41
|
});
|
|
40
42
|
var TreeNode$1 = TreeNode;
|
|
41
43
|
|
|
@@ -10,6 +10,6 @@ export interface UseTreeExpandedValueProps {
|
|
|
10
10
|
}
|
|
11
11
|
export declare function useTreeExpandedValue(props: UseTreeExpandedValueProps): {
|
|
12
12
|
expandedValues: TreeNodeValue[];
|
|
13
|
-
onExpand: (value: TreeNodeValue) => void;
|
|
13
|
+
onExpand: ((value: TreeNodeValue) => void) | undefined;
|
|
14
14
|
setExpandedValues: import("react").Dispatch<import("react").SetStateAction<TreeNodeValue[]>>;
|
|
15
15
|
};
|
|
@@ -21,10 +21,11 @@ function useTreeExpandedValue(props) {
|
|
|
21
21
|
const onExpand = (value) => {
|
|
22
22
|
const newExpandedValues = toggleValue(value, expandedValues);
|
|
23
23
|
setExpandedValues(newExpandedValues);
|
|
24
|
+
onExpandProp === null || onExpandProp === void 0 ? void 0 : onExpandProp(value);
|
|
24
25
|
};
|
|
25
26
|
return {
|
|
26
27
|
expandedValues: expandedValuesProp || expandedValues,
|
|
27
|
-
onExpand:
|
|
28
|
+
onExpand: expandedValuesProp ? onExpandProp : onExpand,
|
|
28
29
|
setExpandedValues,
|
|
29
30
|
};
|
|
30
31
|
}
|
package/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from './utils/getElement';
|
|
|
4
4
|
export * from './utils/jsx-types';
|
|
5
5
|
export * from './utils/general';
|
|
6
6
|
export * from './utils/scroll-lock';
|
|
7
|
+
export * from './utils/array-move';
|
|
7
8
|
export * from './hooks/useClickAway';
|
|
8
9
|
export * from './hooks/useComposeRefs';
|
|
9
10
|
export * from './hooks/useDocumentEscapeKeyDown';
|
|
@@ -51,7 +52,7 @@ export { AccordionProps, AccordionSummaryProps, AccordionSummary, AccordionDetai
|
|
|
51
52
|
export { BadgeContainerProps, BadgeContainer, BadgeProps, default as Badge, } from './Badge';
|
|
52
53
|
export { CardProps, CardActionsProps, CardActions, default as Card, } from './Card';
|
|
53
54
|
export { EmptyProps, default as Empty, } from './Empty';
|
|
54
|
-
export { TableProps, TableRefreshProps, TableRefresh, default as Table, } from './Table';
|
|
55
|
+
export { TableProps, TableRefreshProps, TableRefresh, useTableDraggable, useTableScroll, default as Table, } from './Table';
|
|
55
56
|
export { TagSize, TagProps, default as Tag, } from './Tag';
|
|
56
57
|
export { usePagination, PaginationItemProps, PaginationItemType, PaginationItem, PaginationJumperProps, PaginationJumper, PaginationPageSizeProps, PaginationPageSize, PaginationProps, default as Pagination, } from './Pagination';
|
|
57
58
|
export { TreeNodeProp, TreeNodeData, TreeNodeEntity, TreeNodeEntities, TreeNodeRefsShape, TreeNodeRefs, TreeExpandControl, uniqueArray, toggleValue, toggleValueWithStatusControl, traverseTree, UseTreeExpandedValueProps, useTreeExpandedValue, GetTreeNodeEntitiesProps, getTreeNodeEntities, TreeNodeElementProps, TreeNodeProps, TreeNode, TreeNodeListElementProps, TreeNodeListProps, TreeNodeList, TreeProps, default as Tree, } from './Tree';
|
package/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { composeRefs } from './utils/composeRefs.js';
|
|
2
2
|
export { getElement } from './utils/getElement.js';
|
|
3
3
|
export { allowBodyScroll, lockBodyScroll } from './utils/scroll-lock.js';
|
|
4
|
+
export { arrayMove } from './utils/array-move.js';
|
|
4
5
|
export { useClickAway } from './hooks/useClickAway.js';
|
|
5
6
|
export { useComposeRefs } from './hooks/useComposeRefs.js';
|
|
6
7
|
export { useDocumentEscapeKeyDown } from './hooks/useDocumentEscapeKeyDown.js';
|
|
@@ -23,6 +24,7 @@ export { useSelectValueControl } from './Form/useSelectValueControl.js';
|
|
|
23
24
|
export { useSwitchControlValue } from './Form/useSwitchControlValue.js';
|
|
24
25
|
export { IconButton } from './Button/index.js';
|
|
25
26
|
export { default as Typography } from './Typography/Typography.js';
|
|
27
|
+
export { default as useTableScroll } from './Table/useTableScroll.js';
|
|
26
28
|
export { default as useModalContainer } from './Modal/useModalContainer.js';
|
|
27
29
|
export { default as Transition } from './Transition/Transition.js';
|
|
28
30
|
export { default as ConfigProvider } from './Provider/ConfigProvider.js';
|
|
@@ -57,6 +59,7 @@ export { default as CardActions } from './Card/CardActions.js';
|
|
|
57
59
|
export { default as Card } from './Card/Card.js';
|
|
58
60
|
export { default as Empty } from './Empty/Empty.js';
|
|
59
61
|
export { default as TableRefresh } from './Table/refresh/TableRefresh.js';
|
|
62
|
+
export { useTableDraggable } from './Table/draggable/useTableDraggable.js';
|
|
60
63
|
export { default as Table } from './Table/Table.js';
|
|
61
64
|
export { default as Tag } from './Tag/Tag.js';
|
|
62
65
|
export { usePagination } from './Pagination/usePagination.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mezzanine-ui/react",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.2",
|
|
4
4
|
"description": "React components for mezzanine-ui",
|
|
5
5
|
"author": "Mezzanine",
|
|
6
6
|
"repository": {
|
|
@@ -31,13 +31,14 @@
|
|
|
31
31
|
"react-dom": "^18.2.0"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@mezzanine-ui/core": "^0.13.
|
|
35
|
-
"@mezzanine-ui/icons": "^0.13.
|
|
36
|
-
"@mezzanine-ui/system": "^0.13.
|
|
34
|
+
"@mezzanine-ui/core": "^0.13.2",
|
|
35
|
+
"@mezzanine-ui/icons": "^0.13.2",
|
|
36
|
+
"@mezzanine-ui/system": "^0.13.2",
|
|
37
37
|
"@popperjs/core": "^2.11.6",
|
|
38
38
|
"@types/react-transition-group": "^4.4.5",
|
|
39
39
|
"clsx": "^1.2.1",
|
|
40
40
|
"lodash": "^4.17.21",
|
|
41
|
+
"react-beautiful-dnd": "^13.1.1",
|
|
41
42
|
"react-popper": "^2.3.0",
|
|
42
43
|
"react-transition-group": "^4.4.5",
|
|
43
44
|
"tslib": "^2.4.1"
|
|
@@ -49,6 +50,7 @@
|
|
|
49
50
|
"@types/lodash": "^4.14.188",
|
|
50
51
|
"@types/moment": "^2.13.0",
|
|
51
52
|
"@types/react": "^18.0.25",
|
|
53
|
+
"@types/react-beautiful-dnd": "^13.1.4",
|
|
52
54
|
"@types/react-dom": "^18.0.8",
|
|
53
55
|
"@types/react-test-renderer": "^18.0.0",
|
|
54
56
|
"chromatic": "^6.11.4",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function arrayMove(arr: any[], old_index: number, new_index: number): any[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
function arrayMove(arr, old_index, new_index) {
|
|
2
|
+
const temp = arr.slice(0);
|
|
3
|
+
if (new_index >= temp.length) {
|
|
4
|
+
let k = new_index - temp.length + 1;
|
|
5
|
+
while ((k -= 1)) {
|
|
6
|
+
temp.push();
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
temp.splice(new_index, 0, temp.splice(old_index, 1)[0]);
|
|
10
|
+
return temp;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { arrayMove };
|